From 9f14d17b49ab102b3ce1dbe145df13b355102a68 Mon Sep 17 00:00:00 2001 From: sendbird-sdk-deployment Date: Fri, 27 Sep 2024 00:44:37 +0000 Subject: [PATCH 1/3] Release - 4.14.4 --- CHANGELOG.md | 3 +++ cjs/feedChannel.cjs | 2 +- cjs/groupChannel.cjs | 2 +- cjs/index.cjs | 2 +- cjs/lib/{__bundle-9d371926.cjs => __bundle-165fd6e1.cjs} | 2 +- cjs/lib/__bundle-1a495950.cjs | 2 ++ cjs/lib/{__bundle-290a02c3.cjs => __bundle-2ad218ff.cjs} | 2 +- cjs/lib/{__bundle-32f62cd2.cjs => __bundle-552fe22f.cjs} | 2 +- cjs/lib/{__bundle-441c4e66.cjs => __bundle-611abb88.cjs} | 2 +- cjs/lib/__bundle-ad182031.cjs | 2 -- cjs/lib/{__bundle-e8b53f2f.cjs => __bundle-bfe2e997.cjs} | 2 +- cjs/lib/{__bundle-a5185d74.cjs => __bundle-c127c886.cjs} | 2 +- cjs/lib/{__bundle-39ca4e91.cjs => __bundle-ca16c7ed.cjs} | 2 +- cjs/lib/{__bundle-5374ca23.cjs => __bundle-d3673ecc.cjs} | 2 +- cjs/lib/{__bundle-980f5f44.cjs => __bundle-dcf4d0c3.cjs} | 2 +- cjs/lib/__definition.d.cts | 2 +- cjs/message.cjs | 2 +- cjs/openChannel.cjs | 2 +- cjs/poll.cjs | 2 +- feedChannel.js | 2 +- groupChannel.js | 2 +- index.js | 2 +- lib/{__bundle-a7b76e00.js => __bundle-123134d8.js} | 2 +- lib/__bundle-1db3fd0b.js | 1 + lib/{__bundle-b7a55976.js => __bundle-24f017be.js} | 2 +- lib/__bundle-31d4ecef.js | 1 + lib/{__bundle-152581cd.js => __bundle-4b40b3a8.js} | 2 +- lib/__bundle-80bd1744.js | 1 - lib/__bundle-85fbca74.js | 1 - lib/{__bundle-0e590e6a.js => __bundle-cc71b396.js} | 2 +- lib/{__bundle-3ceb5f92.js => __bundle-e1a5e3f1.js} | 2 +- lib/{__bundle-ace226dc.js => __bundle-e53b9010.js} | 2 +- lib/__definition.d.ts | 2 +- message.js | 2 +- openChannel.js | 2 +- package.json | 2 +- poll.js | 2 +- sendbird.min.js | 2 +- 38 files changed, 38 insertions(+), 35 deletions(-) rename cjs/lib/{__bundle-9d371926.cjs => __bundle-165fd6e1.cjs} (63%) create mode 100644 cjs/lib/__bundle-1a495950.cjs rename cjs/lib/{__bundle-290a02c3.cjs => __bundle-2ad218ff.cjs} (97%) rename cjs/lib/{__bundle-32f62cd2.cjs => __bundle-552fe22f.cjs} (95%) rename cjs/lib/{__bundle-441c4e66.cjs => __bundle-611abb88.cjs} (91%) delete mode 100644 cjs/lib/__bundle-ad182031.cjs rename cjs/lib/{__bundle-e8b53f2f.cjs => __bundle-bfe2e997.cjs} (89%) rename cjs/lib/{__bundle-a5185d74.cjs => __bundle-c127c886.cjs} (65%) rename cjs/lib/{__bundle-39ca4e91.cjs => __bundle-ca16c7ed.cjs} (68%) rename cjs/lib/{__bundle-5374ca23.cjs => __bundle-d3673ecc.cjs} (97%) rename cjs/lib/{__bundle-980f5f44.cjs => __bundle-dcf4d0c3.cjs} (99%) rename lib/{__bundle-a7b76e00.js => __bundle-123134d8.js} (89%) create mode 100644 lib/__bundle-1db3fd0b.js rename lib/{__bundle-b7a55976.js => __bundle-24f017be.js} (85%) create mode 100644 lib/__bundle-31d4ecef.js rename lib/{__bundle-152581cd.js => __bundle-4b40b3a8.js} (86%) delete mode 100644 lib/__bundle-80bd1744.js delete mode 100644 lib/__bundle-85fbca74.js rename lib/{__bundle-0e590e6a.js => __bundle-cc71b396.js} (99%) rename lib/{__bundle-3ceb5f92.js => __bundle-e1a5e3f1.js} (59%) rename lib/{__bundle-ace226dc.js => __bundle-e53b9010.js} (97%) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4c79be..bcce086 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v4.14.4 (Sep 27, 2024) +### **Improvements** +- Fixed a bug that local cache data is broken in a certain condition ## v4.14.3 (Sep 13, 2024) ### **Improvements** - Fixed a bug where there was no mentionedUser when sending a message with mentionedUserId as CopyMessage diff --git a/cjs/feedChannel.cjs b/cjs/feedChannel.cjs index e2a657e..a793924 100644 --- a/cjs/feedChannel.cjs +++ b/cjs/feedChannel.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-ad182031.cjs"),t=require("./lib/__bundle-9d371926.cjs"),n=require("./lib/__bundle-980f5f44.cjs"),s=require("./lib/__bundle-39ca4e91.cjs"),i=require("./lib/__bundle-290a02c3.cjs"),a=require("./lib/__bundle-5374ca23.cjs");require("./lib/__bundle-e8b53f2f.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class o{constructor(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}static payloadify(t){return e.deundefined(e.undefineNullProps({id:t.id,name:t.name,is_default:t.isDefault}))}get customType(){return this.isDefault?"*":String(this.id)}}class r extends e.InstancedObject{constructor(e,{sdkState:t,cacheContext:n,channelManager:s}){super(e),this._channels=new Map,this._sdkState=t,this._cacheContext=n,this._channelManager=s}get collection(){const{nestdb:n}=this._cacheContext;return e.unless(!!n).throw(e.SendbirdError.databaseError),n.collection(t.NESTDB_FEEDCHANNEL_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 this._channelManager.buildFeedChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}get(t){return e.__awaiter(this,void 0,void 0,(function*(){if(this._channels.has(t))return this._channels.get(t);if(this.localCacheEnabled){const e=yield this.collection.getByKey(t);if(e)return this._channels.set(t,this._deserialize(e)),this._channels.get(t)}}))}fetch({token:n,limit:i=t.DEFAULT_FEED_LIMIT,backward:a=!1,order:o="latest_last_message",borderlineChannelUrl:r}){return e.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const e={where:e=>{if(n&&"latest_last_message"===o)if(!a&&e.lastMessageUpdatedAt>n||a&&e.lastMessageUpdatedAtthis._deserialize(e)));return l.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),l}return[]}))}upsert(t){return e.__awaiter(this,void 0,void 0,(function*(){const n=[];if(t.forEach((t=>{if(this._channels.has(t.url)){const s=this._channels.get(t.url),i=e.deundefined(t);Object.assign(s,i,{_iid:this._iid}),n.push(s)}else this._channels.set(t.url,t),n.push(t)})),this.localCacheEnabled){const e=[];for(let t=0;te.__awaiter(this,void 0,void 0,(function*(){if(s instanceof l){const{channels:e,context:i,isWebSocketEventComing:a}=s,o=e.filter((e=>e instanceof x)),r=yield t.upsert(o);yield Promise.all(o.map((e=>n.markAsReadByTimestamp(e.url,e.myLastRead)))),a||this._broadcastUpdateEvent(r,i)}else if(s instanceof d){const{channelUrls:i,context:a,isWebSocketEventComing:o}=s;yield t.remove(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of i)yield n.removeMessagesOfChannel(e)})))),o||this._broadcastRemoveEvent(i,a)}else s instanceof i.DatabaseOpenCommand&&(yield t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const n of this._observers.values())n.onUpdate&&n.onUpdate(e,t)}_broadcastRemoveEvent(e,t){for(const n of this._observers.values())n.onRemove&&n.onRemove(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const h=!1;class u extends e.APIRequestCommand{constructor(t){super();const{userId:n,token:s,limit:i,includeEmpty:a}=t;this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(n)}/my_group_channels`,this.params=e.deundefined({token:s,limit:i,show_empty:null!=a?a:h,show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0,is_feed_channel:!0,order:"latest_last_message"})}}class _ extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:n,channels:s,ts:i}=t;this.token=n,this.ts=null!=i?i:0,this.channels=(null!=s?s:[]).map((t=>(t.ts=i,new x(e,t))))}}class g extends e.APIRequestCommand{constructor({channelUrl:t,isInternalCall:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${n?e.API_PATH_GROUP_CHANNELS_INTERNAL:e.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,is_feed_channel:!0}}}class f extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new x(e,t)}}const C={includeEmpty:!0},m=t=>e.isTypeOf("boolean",t.includeEmpty);class p extends e.APIRequestCommand{constructor({userId:t,ts:n,token:s,params:i}){super();const{includeEmpty:a}=Object.assign(Object.assign({},C),i);this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels/changelogs`,this.params=e.deundefined(e.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,is_feed_channel:!0,show_empty:a,change_ts:n||null,token:s}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((t=>new x(e,t))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next}}class E extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/settings`}}class y extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}const b=20;class M extends e.APIRequestCommand{constructor(t){const{reverse:n=!1,keys:s,limit:i=b,token:a}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates`,this.params=e.deundefined({token:a,keys:s,limit:i,reverse:n,order:"updated_at",show_ui_template:!0,show_color_variables:!0})}}class w extends e.APIResponseCommand{constructor(t,n){super(t,n);const{next:s,has_more:i=!1}=n,a=e.__rest(n,["next","has_more"]);this.nextToken=s,this.hasMore=i,this.notificationTemplateList={jsonString:JSON.stringify(a)}}}const T={reverse:!1,keys:void 0,limit:20};class S extends e.APIRequestCommand{constructor(t){const{key:n}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates/${n}`,this.params=e.deundefined({key:n})}}class I extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}class N extends e.WebSocketEventCommand{constructor(n,s,i){var a,o,r;super(n,"ADMM",i),this.message=new t.NotificationMessage(n,i);const{sdkState:l}=e.Vault.of(n);this.isMentioned=e.checkIfMentioned(this.message.mentionType,null!==(r=null!==(a=this.message.mentionedUserIds)&&void 0!==a?a:null===(o=this.message.mentionedUsers)||void 0===o?void 0:o.map((e=>e.userId)))&&void 0!==r?r:[],l.userId)}}class A extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS_USERS}/${encodeURIComponent(t)}/unread_message_count`}}const O={};class k extends a.BaseChannelManager{get _notificationMessageCache(){return t.NotificationMessageCache.of(this._iid)}constructor(n,s){super(n,Object.assign(Object.assign({},s),{channelType:e.ChannelType.FEED})),this._feedChannelHandlers=new Map,this._feedChannelCache=new r(this._iid,{sdkState:this._sdkState,cacheContext:this._cacheContext,channelManager:this}),this._feedChannelBroadcast=new c({feedChannelCache:this._feedChannelCache,dispatcher:this._dispatcher,notificationMessageCache:t.NotificationMessageCache.of(n)}),this._dispatcher.on((t=>{t instanceof e.WebSocketEventCommand&&this._handleEvent(t).catch((t=>{if(e.isThrowingOutside(t))throw t}))})),O[n]||(O[n]=this)}static of(t){return O[t]||(O[t]=new k(t,e.Vault.of(t))),O[t]}static clear(e){O[e]&&delete O[e]}get handlers(){return[...this._feedChannelHandlers.values()]}buildFeedChannelFromSerializedData(t){const n=e.deserialize(t);return new x(this._iid,x.payloadify(n))}addHandler(e,t){this._feedChannelHandlers.set(e,t)}removeHandler(e){this._feedChannelHandlers.delete(e)}clearHandler(){this._feedChannelHandlers.clear()}getMyFeedChannels(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){const e=new u(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:s})),i=yield this._requestQueue.send(e),{channels:a,token:o}=i.as(_);return{channels:a,token:o}}))}getChannel(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(t);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(t,n)}))}getChannelFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),null!==(n=yield this._feedChannelCache.get(t))&&void 0!==n?n:null}))}getChannelWithoutCache(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const s=new g({channelUrl:t,isInternalCall:n}),i=yield this._requestQueue.send(s),{channel:a}=i.as(f),[o]=yield this.upsertChannelsToCache([a]);return o}))}getMyFeedChannelChangeLogs(t,n,s=e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},C),n);e.unless((e.isTypeOf("string",t)||e.isTypeOf("number",t))&&m(i)).throw(e.SendbirdError.invalidParameters);const a=new p(e.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,params:i})),o=yield this._requestQueue.send(a),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}=o.as(v);return r.length>0&&this._dispatcher.dispatch(new l({channels:r,context:{source:s}})),c.length>0&&this._dispatcher.dispatch(new d({channelUrls:c,context:{source:s}})),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}}))}getTotalUnreadMessageCount(t){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},n.TotalUnreadMessageCountParamsDefault),t);e.unless(n.validateTotalUnreadMessageCountParams(s)).throw(e.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:a}=e.Vault.of(this._iid),o=new n.GetTotalUnreadMessageCountRequestCommand({userId:i.userId,filter:s,includeFeedChannel:!0}),r=yield a.send(o),{unreadFeedCount:l=0}=r.as(n.GetTotalUnreadMessageCountResponseCommand);return l}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),i=new A({userId:t.userId}),a=yield s.send(i),{unreadFeedCount:o=0}=a.as(n.GetTotalUnreadMessageCountResponseCommand);return o}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){const e=new E,t=yield this._requestQueue.send(e),{jsonString:n}=t.as(y);return{jsonString:n}}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},T),n);e.unless(e.isTypeOf("string",t)&&(t=>e.isTypeOf("boolean",t.reverse,!0)&&e.isArrayOf("string",t.keys,!0)&&e.isTypeOf("number",t.limit,!0))(s)).throw(e.SendbirdError.invalidParameters);const i=new M({token:t,keys:s.keys,reverse:s.reverse,limit:s.limit}),a=yield this._requestQueue.send(i),{hasMore:o,nextToken:r,notificationTemplateList:l}=a.as(w);return{hasMore:o,token:r,notificationTemplateList:l}}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=new S({key:t}),s=yield this._requestQueue.send(n),{jsonString:i}=s.as(I);return{jsonString:i}}))}upsertChannelsToCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._feedChannelCache.upsert(t)}))}removeChannelsFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this._feedChannelCache.remove(t)}))}getNotificationMessageFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.get(t)}))}refreshChannel(t,s=!0,i=e.CollectionEventSource.REFRESH_CHANNEL){return e.__awaiter(this,void 0,void 0,(function*(){try{const e=new g({channelUrl:t,isInternalCall:s}),a=yield this._requestQueue.send(e),{channel:o}=a.as(f);if(o.myMemberState===n.MemberState.NONE)this._dispatcher.dispatch(new d({channelUrls:[o.url],context:{source:i}}));else{const e=yield this.upsertChannelsToCache([o]);this._dispatcher.dispatch(new l({channels:e,context:{source:i}}))}}catch(n){n.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&n.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new d({channelUrls:[t],context:{source:i}}))}}))}refreshNotificationCollections(){this._dispatcher.dispatch(new s.NotificationCollectionRefreshCommand)}subscribeChannelEvent(e,t){this._feedChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._feedChannelBroadcast.unsubscribe(e)}_handleEvent(n){return e.__awaiter(this,void 0,void 0,(function*(){switch(n.code){case"ADMM":case"BRDM":{const s="ADMM"===n.code||"BRDM"===n.code?n.as(N):null;if(s&&s.message.channelType===this._channelType){const{message:n,isMentioned:i}=s,a=yield this.getChannel(n.channelUrl,!0);a._runIfHandleableWithGroupChannel((s=>{var o;n instanceof t.NotificationMessage&&i&&(null===(o=n.mentionedUsers)||void 0===o||o.forEach((e=>{for(const t of s.members)if(e.userId===t.userId){e.nickname=t.nickname,e.plainProfileUrl=t.plainProfileUrl,e.metaData=t.metaData;break}}))),this._dispatcher.dispatch(new l({channels:[a],context:{source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),this._dispatcher.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageReceived&&e.onMessageReceived(a,n),i&&e.onMentionReceived&&e.onMentionReceived(a,n)}))))}))}break}case"READ":{const s="READ"===n.code?n.as(t.ReadEventCommand):null;if(s&&s.readStatus.channelType===this._channelType){const{readStatus:t}=s,n=this._feedChannelCache.isCachedInMemory(t.channelUrl),i=yield this.getChannel(t.channelUrl,!0);i._runIfHandleableWithGroupChannel((s=>{n&&s._updateUnreadMemberState(t.reader.userId,t.readAt),t.reader.userId===this._sdkState.userId&&(n?(s.unreadMessageCount>0||s.unreadMentionCount>0)&&(s._updateUnreadCount(0,0),this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))):0!==s.unreadMessageCount&&0!==s.unreadMentionCount||(this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))))}))}break}case"SYEV":{const t="SYEV"===n.code?n.as(a.ChannelEventCommand):null;if(t&&t.event.channelType===this._channelType){const{event:n}=t;switch(n.category){case a.ChannelEventCategory.CHANNEL_DELETED:{const t=yield this.getChannel(n.channelUrl,!0);this._dispatcher.dispatch(new d({channelUrls:[n.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(t.url,t.channelType)}))}))));break}case a.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const t=yield this.getChannelWithoutCache(n.channelUrl,!0);this._dispatcher.dispatch(new l({channels:[t],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(t)}))}))));break}}}break}}}))}getMessageFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(n=yield this._notificationMessageCache.get(t))&&void 0!==n?n:null}))}getExactlyMatchingMessagesForTokenFromCache(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:t,token:n,filter:s,exactMatch:!0})}))}getMessagesFromCache(n,s,i,a,o=t.DEFAULT_NOTIFICATION_LIMIT,r=!0){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:n,token:s,limit:o,filter:a,backward:"next"===i,inclusive:r})}))}}class R extends n.BaseMessageCollection{keyOf(e){return e.notificationId}get changelogIncludeParams(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}constructor(t,n){super(t,Object.assign(Object.assign({},n),{channelManager:k.of(t)}));const{connectionManager:i,dispatcher:a}=e.Vault.of(this._iid);this._notificationCollectionEventContext=a.on((t=>{t instanceof s.NotificationCollectionRefreshCommand&&e.sleep(10).then((()=>{i.isConnected||i.isConnecting||this.refresh()}))}))}dispose(){super.dispose(),this._notificationCollectionEventContext.close()}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_postprocessChannelUpdateEvent(e,n){const s=this._messages.filter((n=>n.messageStatus===t.NotificationMessageStatus.SENT&&n.createdAt<=e.myLastRead));if(s.length>0){for(const e of s)e.messageStatus=t.NotificationMessageStatus.READ;this._updateMessagesToView(s,n)}}_postprocessMessageUpdateEvent(n,s){switch(s){case e.CollectionEventSource.EVENT_CHANNEL_READ:{const e=[],i=this._messages.map((e=>e.notificationId));for(const{notificationId:s}of n){const n=i.indexOf(s);n>=0&&(this._messages[n].messageStatus=t.NotificationMessageStatus.READ,e.push(this._messages[n]))}e.length>0&&this._updateMessagesToView(e,s);break}}}_addMessagesToView(t,s){const i=this._filterUnderOffsetMessage(t),a=[],o=[];for(const t of i)if(s===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(n.indexOfMessage(this._messages,t)<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}}else{const e=n.indexOfMessage(this._messages,t);if(e<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}else this._messages[e]=t,o.push(t)}e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n,i;const r={source:s};a.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===t||t.call(e,r,this.channel,a)),o.length>0&&(null===(i=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===i||i.call(n,r,this.channel,o))}))))}_updateMessagesToView(t,s){const i=[];for(const e of t){const t=n.indexOfMessage(this._messages,e);t>=0&&(i.push(e),this._messages[t]=e)}return e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t;const n={source:s};i.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===t||t.call(e,n,this.channel,i))})))),i}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._activate()}))}}class x extends t.BaseChannel{static payloadify(e){var s;return Object.assign(Object.assign({},n.GroupChannel.payloadify(null!==(s=e._groupChannel)&&void 0!==s?s:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((e=>o.payloadify(e))),last_message:e.lastMessage?t.NotificationMessage.payloadify(e.lastMessage):null})}constructor(s,i){var a,r;super(s,i),this.channelType=e.ChannelType.FEED,this._groupChannel=new n.GroupChannel(s,i),this.isCategoryFilterEnabled=null!==(a=i.is_category_filter_enabled)&&void 0!==a&&a,this.isTemplateLabelEnabled=null===(r=i.is_template_label_enabled)||void 0===r||r,this.notificationCategories=i.categories?i.categories.map((e=>new o(e))):[],this.lastMessage=i.last_message?t.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},i.last_message)):null}get groupChannel(){return this._groupChannel}get url(){return this._groupChannel.url}get name(){return this._groupChannel.name}set name(e){this._groupChannel.name=e}get createdAt(){return this._groupChannel.createdAt}get members(){return this._groupChannel.members}get memberCount(){return this._groupChannel.memberCount}get myMemberState(){return this._groupChannel.myMemberState}get myLastRead(){return this._groupChannel.myLastRead}get unreadMessageCount(){return this._groupChannel.unreadMessageCount}serialize(){var t,n;return Object.assign(Object.assign({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((t=>e.serialize(t))),lastMessage:null!==(n=null===(t=this.lastMessage)||void 0===t?void 0:t.serialize())&&void 0!==n?n:null})}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannel._refresh(!0),this}))}markAsRead(n){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,dispatcher:i,requestQueue:a}=e.Vault.of(this._iid),o=null==n?void 0:n.filter((e=>!e||e.messageStatus===t.NotificationMessageStatus.SENT)).map((e=>e.notificationId));if(!o||o.length>0){const r=new t.ReadAPIRequestCommand({userId:s.userId,channelUrl:this.url,channelType:e.ChannelType.FEED,notificationIds:o}),d=yield a.send(r),{unreadMessageCount:c,readAt:h}=d.as(t.ReadAPIResponseCommand);if(n){if("number"==typeof c){this._groupChannel._updateUnreadCount(c,this._groupChannel.unreadMentionCount);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}n.forEach((e=>{e.messageStatus=t.NotificationMessageStatus.READ})),i.dispatch(new e.MessageUpdateEventCommand({messages:n,source:e.CollectionEventSource.EVENT_CHANNEL_READ}))}else if(this._groupChannel._updateUnreadMemberState(s.userId,h),this._groupChannel.unreadMessageCount!==c){this._groupChannel._updateUnreadCount(c,0);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}i.dispatch(new l({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}))}}))}markAsClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this.logClicked(t)}))}logClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30)for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}))}))}logImpression(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.logViewed(t)}))}logViewed(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30){for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}));return!0}return!1}))}logCustom(t,n){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:s}=e.Vault.of(this._iid);if(0{Object.prototype.hasOwnProperty.call(this,t)&&(this[t]=e[t])}))}}class D extends e.BaseListQuery{constructor(e,t){var n;super(e,t),this.includeEmpty=h,this.includeEmpty=null!==(n=t.includeEmpty)&&void 0!==n?n:h}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)}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 t=k.of(this._iid),n=e.undefineNullProps(Object.assign({},this)),{channels:s,token:i}=yield t.getMyFeedChannels(this._token,n,this.limit);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class F extends e.Module{constructor(){super(...arguments),this.name="feedChannel"}init(e,t){super.init(e,t),this._manager=new k(e,t)}buildFeedChannelFromSerializedData(e){return this._manager.buildFeedChannelFromSerializedData(e)}createMyFeedChannelListQuery(e={}){return new D(this._iid,e)}addFeedChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof P).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeFeedChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}removeAllFeedChannelHandlers(){this._manager.clearHandler()}getChannel(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getMyFeedChannelChangeLogsByTimestamp(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("number",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getMyFeedChannelChangeLogsByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("string",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.getTotalUnreadNotificationCount()}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadNotificationCount()}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getGlobalNotificationChannelSetting()}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplateListByToken(t,n)}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplate(t)}))}refreshNotificationCollections(){this._manager.refreshNotificationCollections()}}exports.NotificationMessage=t.NotificationMessage,Object.defineProperty(exports,"NotificationMessageStatus",{enumerable:!0,get:function(){return t.NotificationMessageStatus}}),exports.FeedChannel=x,exports.FeedChannelHandler=P,exports.FeedChannelListQuery=D,exports.FeedChannelModule=F,exports.NotificationCategory=o,exports.NotificationCollection=R; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),t=require("./lib/__bundle-165fd6e1.cjs"),n=require("./lib/__bundle-dcf4d0c3.cjs"),s=require("./lib/__bundle-ca16c7ed.cjs"),i=require("./lib/__bundle-2ad218ff.cjs"),a=require("./lib/__bundle-d3673ecc.cjs");require("./lib/__bundle-bfe2e997.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class o{constructor(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}static payloadify(t){return e.deundefined(e.undefineNullProps({id:t.id,name:t.name,is_default:t.isDefault}))}get customType(){return this.isDefault?"*":String(this.id)}}class r extends e.InstancedObject{constructor(e,{sdkState:t,cacheContext:n,channelManager:s}){super(e),this._channels=new Map,this._sdkState=t,this._cacheContext=n,this._channelManager=s}get collection(){const{nestdb:n}=this._cacheContext;return e.unless(!!n).throw(e.SendbirdError.databaseError),n.collection(t.NESTDB_FEEDCHANNEL_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 this._channelManager.buildFeedChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}get(t){return e.__awaiter(this,void 0,void 0,(function*(){if(this._channels.has(t))return this._channels.get(t);if(this.localCacheEnabled){const e=yield this.collection.getByKey(t);if(e)return this._channels.set(t,this._deserialize(e)),this._channels.get(t)}}))}fetch({token:n,limit:i=t.DEFAULT_FEED_LIMIT,backward:a=!1,order:o="latest_last_message",borderlineChannelUrl:r}){return e.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const e={where:e=>{if(n&&"latest_last_message"===o)if(!a&&e.lastMessageUpdatedAt>n||a&&e.lastMessageUpdatedAtthis._deserialize(e)));return l.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),l}return[]}))}upsert(t){return e.__awaiter(this,void 0,void 0,(function*(){const n=[];if(t.forEach((t=>{if(this._channels.has(t.url)){const s=this._channels.get(t.url),i=e.deundefined(t);Object.assign(s,i,{_iid:this._iid}),n.push(s)}else this._channels.set(t.url,t),n.push(t)})),this.localCacheEnabled){const e=[];for(let t=0;te.__awaiter(this,void 0,void 0,(function*(){if(s instanceof l){const{channels:e,context:i,isWebSocketEventComing:a}=s,o=e.filter((e=>e instanceof x)),r=yield t.upsert(o);yield Promise.all(o.map((e=>n.markAsReadByTimestamp(e.url,e.myLastRead)))),a||this._broadcastUpdateEvent(r,i)}else if(s instanceof d){const{channelUrls:i,context:a,isWebSocketEventComing:o}=s;yield t.remove(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of i)yield n.removeMessagesOfChannel(e)})))),o||this._broadcastRemoveEvent(i,a)}else s instanceof i.DatabaseOpenCommand&&(yield t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const n of this._observers.values())n.onUpdate&&n.onUpdate(e,t)}_broadcastRemoveEvent(e,t){for(const n of this._observers.values())n.onRemove&&n.onRemove(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const h=!1;class u extends e.APIRequestCommand{constructor(t){super();const{userId:n,token:s,limit:i,includeEmpty:a}=t;this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(n)}/my_group_channels`,this.params=e.deundefined({token:s,limit:i,show_empty:null!=a?a:h,show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0,is_feed_channel:!0,order:"latest_last_message"})}}class _ extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:n,channels:s,ts:i}=t;this.token=n,this.ts=null!=i?i:0,this.channels=(null!=s?s:[]).map((t=>(t.ts=i,new x(e,t))))}}class g extends e.APIRequestCommand{constructor({channelUrl:t,isInternalCall:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${n?e.API_PATH_GROUP_CHANNELS_INTERNAL:e.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,is_feed_channel:!0}}}class f extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new x(e,t)}}const C={includeEmpty:!0},m=t=>e.isTypeOf("boolean",t.includeEmpty);class p extends e.APIRequestCommand{constructor({userId:t,ts:n,token:s,params:i}){super();const{includeEmpty:a}=Object.assign(Object.assign({},C),i);this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels/changelogs`,this.params=e.deundefined(e.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,is_feed_channel:!0,show_empty:a,change_ts:n||null,token:s}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((t=>new x(e,t))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next}}class E extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/settings`}}class y extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}const b=20;class M extends e.APIRequestCommand{constructor(t){const{reverse:n=!1,keys:s,limit:i=b,token:a}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates`,this.params=e.deundefined({token:a,keys:s,limit:i,reverse:n,order:"updated_at",show_ui_template:!0,show_color_variables:!0})}}class w extends e.APIResponseCommand{constructor(t,n){super(t,n);const{next:s,has_more:i=!1}=n,a=e.__rest(n,["next","has_more"]);this.nextToken=s,this.hasMore=i,this.notificationTemplateList={jsonString:JSON.stringify(a)}}}const T={reverse:!1,keys:void 0,limit:20};class S extends e.APIRequestCommand{constructor(t){const{key:n}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates/${n}`,this.params=e.deundefined({key:n})}}class I extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}class N extends e.WebSocketEventCommand{constructor(n,s,i){var a,o,r;super(n,"ADMM",i),this.message=new t.NotificationMessage(n,i);const{sdkState:l}=e.Vault.of(n);this.isMentioned=e.checkIfMentioned(this.message.mentionType,null!==(r=null!==(a=this.message.mentionedUserIds)&&void 0!==a?a:null===(o=this.message.mentionedUsers)||void 0===o?void 0:o.map((e=>e.userId)))&&void 0!==r?r:[],l.userId)}}class A extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS_USERS}/${encodeURIComponent(t)}/unread_message_count`}}const O={};class k extends a.BaseChannelManager{get _notificationMessageCache(){return t.NotificationMessageCache.of(this._iid)}constructor(n,s){super(n,Object.assign(Object.assign({},s),{channelType:e.ChannelType.FEED})),this._feedChannelHandlers=new Map,this._feedChannelCache=new r(this._iid,{sdkState:this._sdkState,cacheContext:this._cacheContext,channelManager:this}),this._feedChannelBroadcast=new c({feedChannelCache:this._feedChannelCache,dispatcher:this._dispatcher,notificationMessageCache:t.NotificationMessageCache.of(n)}),this._dispatcher.on((t=>{t instanceof e.WebSocketEventCommand&&this._handleEvent(t).catch((t=>{if(e.isThrowingOutside(t))throw t}))})),O[n]||(O[n]=this)}static of(t){return O[t]||(O[t]=new k(t,e.Vault.of(t))),O[t]}static clear(e){O[e]&&delete O[e]}get handlers(){return[...this._feedChannelHandlers.values()]}buildFeedChannelFromSerializedData(t){const n=e.deserialize(t);return new x(this._iid,x.payloadify(n))}addHandler(e,t){this._feedChannelHandlers.set(e,t)}removeHandler(e){this._feedChannelHandlers.delete(e)}clearHandler(){this._feedChannelHandlers.clear()}getMyFeedChannels(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){const e=new u(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:s})),i=yield this._requestQueue.send(e),{channels:a,token:o}=i.as(_);return{channels:a,token:o}}))}getChannel(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(t);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(t,n)}))}getChannelFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),null!==(n=yield this._feedChannelCache.get(t))&&void 0!==n?n:null}))}getChannelWithoutCache(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const s=new g({channelUrl:t,isInternalCall:n}),i=yield this._requestQueue.send(s),{channel:a}=i.as(f),[o]=yield this.upsertChannelsToCache([a]);return o}))}getMyFeedChannelChangeLogs(t,n,s=e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},C),n);e.unless((e.isTypeOf("string",t)||e.isTypeOf("number",t))&&m(i)).throw(e.SendbirdError.invalidParameters);const a=new p(e.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,params:i})),o=yield this._requestQueue.send(a),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}=o.as(v);return r.length>0&&this._dispatcher.dispatch(new l({channels:r,context:{source:s}})),c.length>0&&this._dispatcher.dispatch(new d({channelUrls:c,context:{source:s}})),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}}))}getTotalUnreadMessageCount(t){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},n.TotalUnreadMessageCountParamsDefault),t);e.unless(n.validateTotalUnreadMessageCountParams(s)).throw(e.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:a}=e.Vault.of(this._iid),o=new n.GetTotalUnreadMessageCountRequestCommand({userId:i.userId,filter:s,includeFeedChannel:!0}),r=yield a.send(o),{unreadFeedCount:l=0}=r.as(n.GetTotalUnreadMessageCountResponseCommand);return l}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),i=new A({userId:t.userId}),a=yield s.send(i),{unreadFeedCount:o=0}=a.as(n.GetTotalUnreadMessageCountResponseCommand);return o}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){const e=new E,t=yield this._requestQueue.send(e),{jsonString:n}=t.as(y);return{jsonString:n}}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},T),n);e.unless(e.isTypeOf("string",t)&&(t=>e.isTypeOf("boolean",t.reverse,!0)&&e.isArrayOf("string",t.keys,!0)&&e.isTypeOf("number",t.limit,!0))(s)).throw(e.SendbirdError.invalidParameters);const i=new M({token:t,keys:s.keys,reverse:s.reverse,limit:s.limit}),a=yield this._requestQueue.send(i),{hasMore:o,nextToken:r,notificationTemplateList:l}=a.as(w);return{hasMore:o,token:r,notificationTemplateList:l}}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=new S({key:t}),s=yield this._requestQueue.send(n),{jsonString:i}=s.as(I);return{jsonString:i}}))}upsertChannelsToCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._feedChannelCache.upsert(t)}))}removeChannelsFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this._feedChannelCache.remove(t)}))}getNotificationMessageFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.get(t)}))}refreshChannel(t,s=!0,i=e.CollectionEventSource.REFRESH_CHANNEL){return e.__awaiter(this,void 0,void 0,(function*(){try{const e=new g({channelUrl:t,isInternalCall:s}),a=yield this._requestQueue.send(e),{channel:o}=a.as(f);if(o.myMemberState===n.MemberState.NONE)this._dispatcher.dispatch(new d({channelUrls:[o.url],context:{source:i}}));else{const e=yield this.upsertChannelsToCache([o]);this._dispatcher.dispatch(new l({channels:e,context:{source:i}}))}}catch(n){n.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&n.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new d({channelUrls:[t],context:{source:i}}))}}))}refreshNotificationCollections(){this._dispatcher.dispatch(new s.NotificationCollectionRefreshCommand)}subscribeChannelEvent(e,t){this._feedChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._feedChannelBroadcast.unsubscribe(e)}_handleEvent(n){return e.__awaiter(this,void 0,void 0,(function*(){switch(n.code){case"ADMM":case"BRDM":{const s="ADMM"===n.code||"BRDM"===n.code?n.as(N):null;if(s&&s.message.channelType===this._channelType){const{message:n,isMentioned:i}=s,a=yield this.getChannel(n.channelUrl,!0);a._runIfHandleableWithGroupChannel((s=>{var o;n instanceof t.NotificationMessage&&i&&(null===(o=n.mentionedUsers)||void 0===o||o.forEach((e=>{for(const t of s.members)if(e.userId===t.userId){e.nickname=t.nickname,e.plainProfileUrl=t.plainProfileUrl,e.metaData=t.metaData;break}}))),this._dispatcher.dispatch(new l({channels:[a],context:{source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),this._dispatcher.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageReceived&&e.onMessageReceived(a,n),i&&e.onMentionReceived&&e.onMentionReceived(a,n)}))))}))}break}case"READ":{const s="READ"===n.code?n.as(t.ReadEventCommand):null;if(s&&s.readStatus.channelType===this._channelType){const{readStatus:t}=s,n=this._feedChannelCache.isCachedInMemory(t.channelUrl),i=yield this.getChannel(t.channelUrl,!0);i._runIfHandleableWithGroupChannel((s=>{n&&s._updateUnreadMemberState(t.reader.userId,t.readAt),t.reader.userId===this._sdkState.userId&&(n?(s.unreadMessageCount>0||s.unreadMentionCount>0)&&(s._updateUnreadCount(0,0),this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))):0!==s.unreadMessageCount&&0!==s.unreadMentionCount||(this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))))}))}break}case"SYEV":{const t="SYEV"===n.code?n.as(a.ChannelEventCommand):null;if(t&&t.event.channelType===this._channelType){const{event:n}=t;switch(n.category){case a.ChannelEventCategory.CHANNEL_DELETED:{const t=yield this.getChannel(n.channelUrl,!0);this._dispatcher.dispatch(new d({channelUrls:[n.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(t.url,t.channelType)}))}))));break}case a.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const t=yield this.getChannelWithoutCache(n.channelUrl,!0);this._dispatcher.dispatch(new l({channels:[t],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(t)}))}))));break}}}break}}}))}getMessageFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(n=yield this._notificationMessageCache.get(t))&&void 0!==n?n:null}))}getExactlyMatchingMessagesForTokenFromCache(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:t,token:n,filter:s,exactMatch:!0})}))}getMessagesFromCache(n,s,i,a,o=t.DEFAULT_NOTIFICATION_LIMIT,r=!0){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:n,token:s,limit:o,filter:a,backward:"next"===i,inclusive:r})}))}}class R extends n.BaseMessageCollection{keyOf(e){return e.notificationId}get changelogIncludeParams(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}constructor(t,n){super(t,Object.assign(Object.assign({},n),{channelManager:k.of(t)}));const{connectionManager:i,dispatcher:a}=e.Vault.of(this._iid);this._notificationCollectionEventContext=a.on((t=>{t instanceof s.NotificationCollectionRefreshCommand&&e.sleep(10).then((()=>{i.isConnected||i.isConnecting||this.refresh()}))}))}dispose(){super.dispose(),this._notificationCollectionEventContext.close()}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_postprocessChannelUpdateEvent(e,n){const s=this._messages.filter((n=>n.messageStatus===t.NotificationMessageStatus.SENT&&n.createdAt<=e.myLastRead));if(s.length>0){for(const e of s)e.messageStatus=t.NotificationMessageStatus.READ;this._updateMessagesToView(s,n)}}_postprocessMessageUpdateEvent(n,s){switch(s){case e.CollectionEventSource.EVENT_CHANNEL_READ:{const e=[],i=this._messages.map((e=>e.notificationId));for(const{notificationId:s}of n){const n=i.indexOf(s);n>=0&&(this._messages[n].messageStatus=t.NotificationMessageStatus.READ,e.push(this._messages[n]))}e.length>0&&this._updateMessagesToView(e,s);break}}}_addMessagesToView(t,s){const i=this._filterUnderOffsetMessage(t),a=[],o=[];for(const t of i)if(s===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(n.indexOfMessage(this._messages,t)<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}}else{const e=n.indexOfMessage(this._messages,t);if(e<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}else this._messages[e]=t,o.push(t)}e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n,i;const r={source:s};a.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===t||t.call(e,r,this.channel,a)),o.length>0&&(null===(i=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===i||i.call(n,r,this.channel,o))}))))}_updateMessagesToView(t,s){const i=[];for(const e of t){const t=n.indexOfMessage(this._messages,e);t>=0&&(i.push(e),this._messages[t]=e)}return e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t;const n={source:s};i.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===t||t.call(e,n,this.channel,i))})))),i}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._activate()}))}}class x extends t.BaseChannel{static payloadify(e){var s;return Object.assign(Object.assign({},n.GroupChannel.payloadify(null!==(s=e._groupChannel)&&void 0!==s?s:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((e=>o.payloadify(e))),last_message:e.lastMessage?t.NotificationMessage.payloadify(e.lastMessage):null})}constructor(s,i){var a,r;super(s,i),this.channelType=e.ChannelType.FEED,this._groupChannel=new n.GroupChannel(s,i),this.isCategoryFilterEnabled=null!==(a=i.is_category_filter_enabled)&&void 0!==a&&a,this.isTemplateLabelEnabled=null===(r=i.is_template_label_enabled)||void 0===r||r,this.notificationCategories=i.categories?i.categories.map((e=>new o(e))):[],this.lastMessage=i.last_message?t.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},i.last_message)):null}get groupChannel(){return this._groupChannel}get url(){return this._groupChannel.url}get name(){return this._groupChannel.name}set name(e){this._groupChannel.name=e}get createdAt(){return this._groupChannel.createdAt}get members(){return this._groupChannel.members}get memberCount(){return this._groupChannel.memberCount}get myMemberState(){return this._groupChannel.myMemberState}get myLastRead(){return this._groupChannel.myLastRead}get unreadMessageCount(){return this._groupChannel.unreadMessageCount}serialize(){var t,n;return Object.assign(Object.assign({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((t=>e.serialize(t))),lastMessage:null!==(n=null===(t=this.lastMessage)||void 0===t?void 0:t.serialize())&&void 0!==n?n:null})}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannel._refresh(!0),this}))}markAsRead(n){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,dispatcher:i,requestQueue:a}=e.Vault.of(this._iid),o=null==n?void 0:n.filter((e=>!e||e.messageStatus===t.NotificationMessageStatus.SENT)).map((e=>e.notificationId));if(!o||o.length>0){const r=new t.ReadAPIRequestCommand({userId:s.userId,channelUrl:this.url,channelType:e.ChannelType.FEED,notificationIds:o}),d=yield a.send(r),{unreadMessageCount:c,readAt:h}=d.as(t.ReadAPIResponseCommand);if(n){if("number"==typeof c){this._groupChannel._updateUnreadCount(c,this._groupChannel.unreadMentionCount);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}n.forEach((e=>{e.messageStatus=t.NotificationMessageStatus.READ})),i.dispatch(new e.MessageUpdateEventCommand({messages:n,source:e.CollectionEventSource.EVENT_CHANNEL_READ}))}else if(this._groupChannel._updateUnreadMemberState(s.userId,h),this._groupChannel.unreadMessageCount!==c){this._groupChannel._updateUnreadCount(c,0);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}i.dispatch(new l({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}))}}))}markAsClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this.logClicked(t)}))}logClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30)for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}))}))}logImpression(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.logViewed(t)}))}logViewed(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30){for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}));return!0}return!1}))}logCustom(t,n){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:s}=e.Vault.of(this._iid);if(0{Object.prototype.hasOwnProperty.call(this,t)&&(this[t]=e[t])}))}}class D extends e.BaseListQuery{constructor(e,t){var n;super(e,t),this.includeEmpty=h,this.includeEmpty=null!==(n=t.includeEmpty)&&void 0!==n?n:h}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)}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 t=k.of(this._iid),n=e.undefineNullProps(Object.assign({},this)),{channels:s,token:i}=yield t.getMyFeedChannels(this._token,n,this.limit);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class F extends e.Module{constructor(){super(...arguments),this.name="feedChannel"}init(e,t){super.init(e,t),this._manager=new k(e,t)}buildFeedChannelFromSerializedData(e){return this._manager.buildFeedChannelFromSerializedData(e)}createMyFeedChannelListQuery(e={}){return new D(this._iid,e)}addFeedChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof P).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeFeedChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}removeAllFeedChannelHandlers(){this._manager.clearHandler()}getChannel(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getMyFeedChannelChangeLogsByTimestamp(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("number",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getMyFeedChannelChangeLogsByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("string",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.getTotalUnreadNotificationCount()}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadNotificationCount()}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getGlobalNotificationChannelSetting()}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplateListByToken(t,n)}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplate(t)}))}refreshNotificationCollections(){this._manager.refreshNotificationCollections()}}exports.NotificationMessage=t.NotificationMessage,Object.defineProperty(exports,"NotificationMessageStatus",{enumerable:!0,get:function(){return t.NotificationMessageStatus}}),exports.FeedChannel=x,exports.FeedChannelHandler=P,exports.FeedChannelListQuery=D,exports.FeedChannelModule=F,exports.NotificationCategory=o,exports.NotificationCollection=R; diff --git a/cjs/groupChannel.cjs b/cjs/groupChannel.cjs index ba696c0..a9f559c 100644 --- a/cjs/groupChannel.cjs +++ b/cjs/groupChannel.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-ad182031.cjs"),t=require("./lib/__bundle-980f5f44.cjs"),n=require("./lib/__bundle-9d371926.cjs"),i=require("./lib/__bundle-290a02c3.cjs"),s=require("./lib/__bundle-441c4e66.cjs");require("./lib/__bundle-5374ca23.cjs"),require("./lib/__bundle-dae7bdf2.cjs"),require("./lib/__bundle-e8b53f2f.cjs");const r={};class a{constructor({_iid:n,limit:s=100}){this.ref=0,this._iid=n,this._limit=s;const{sdkState:r,dispatcher:a,logger:o,cacheContext:l,statManager:d}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${r.userId}@groupchannel/sync.meta`;const h=(e=>`sendbird:${e}@groupchannel/sync`)(r.userId);this._sync=new t.Sync(h,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,s,a,h,u,c,p,_;const g={hasNext:!0,nextToken:""};if(yield this.loadMetadata(),o.debug("channel background sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),null===(s=this._metadata)||void 0===s?void 0:s.completed)g.hasNext=!1,g.nextToken="";else{const n={includeEmpty:!0,includeMetaData:!0,order:i.GroupChannelListOrder.CHRONOLOGICAL};try{if(n.order===i.GroupChannelListOrder.LATEST_LAST_MESSAGE)try{const t=yield l.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(r.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const s=t.GroupChannelManager.of(this._iid),{channels:d,token:u}=yield s.getMyGroupChannels(null!==(h=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==h?h:"",n,this._limit,e.CollectionEventSource.SYNC_CHANNEL_BACKGROUND);g.hasNext=d.length>=this._limit&&!!u,g.nextToken=u,this._metadata&&(this._metadata.token=u,this._metadata.range.extends(...d.map((e=>e.createdAt))),this._metadata.completed=!g.hasNext),o.debug("channel background sync progress",g),yield this.saveMetadata()}catch(t){throw o.debug("channel background sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetaData()),t}finally{d.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=l.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:null!==(_=null===(p=n.order)||void 0===p?void 0:p.toString())&&void 0!==_?_:"",collection_id:r.userId}}))}}return g})))),this._connectionEventContext=a.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return r[e]||(r[e]=new a({_iid:e})),r[e].ref++,r[e]}static clear(e){r[e]&&(r[e].close(),delete r[e])}get range(){var e,n;return null!==(n=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==n?n:new t.TimeRange({})}get completed(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:n}=e.Vault.of(this._iid),i=yield n.preference.get(this._metadataKey);this._metadata={token:i?i.token:"",range:new t.TimeRange(i?i.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!i&&i.completed}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetaData(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){var t,n;const{logger:i,sessionManager:s}=e.Vault.of(this._iid);s.session.hasSession&&(i.debug("channel background sync resume()"),this._sync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.token)&&void 0!==n?n:""))}pause(){const{logger:t}=e.Vault.of(this._iid);t.debug("channel background sync stop()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete r[this._iid])}}const o={};class l{constructor({_iid:n}){this.ref=0,this._iid=n;const{logger:i,sdkState:s,dispatcher:r,cacheContext:a,statManager:o}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${s.userId}@groupchannel/changelogs.meta`,this._subscribers=new e.EventDispatcher;const l=(e=>`sendbird:${e}@groupchannel/changelogs`)(s.userId);this._sync=new t.Sync(l,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,r,l;const d={hasNext:!0,nextToken:0};yield this.loadMetadata(),i.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token);try{const n={includeEmpty:!0,includeMetaData:!0};try{const t=yield a.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(s.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const h=t.GroupChannelManager.of(this._iid),{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}=yield h.getMyGroupChannelChangeLogs(null!==(l=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==l?l:"",n,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);this._subscribers.dispatch("progress",{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}),d.hasNext=p,d.nextToken=_,this._metadata&&(this._metadata.token=_),i.debug("channel changelog sync progress",d),yield this.saveMetadata(),a.localCacheEnabled&&o.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:u.length>0||c.length>0?"cache_miss":"cache_hit",max_db_size:u.length,use_local_cache:a.localCacheEnabled,starting_point:0,message_init_policy:c.length.toString(),collection_id:s.userId}}))}catch(t){throw i.debug("channel changelog sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetadata()),t}return d})))),this._sync.on("stop",(()=>{this._subscribers.dispatch("pause")})),this._connectionEventContext=r.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return o[e]||(o[e]=new l({_iid:e})),o[e].ref++,o[e]}static clear(e){o[e]&&(o[e].close(),delete o[e])}get isRunning(){return this._sync.isRunning}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t,firstConnectedAt:n}=e.Vault.of(this._iid),i=yield t.preference.get(this._metadataKey);this._metadata={token:i?i.token:n}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}on(e,t){return this._subscribers.on(e,t)}resume(){const{sessionManager:t}=e.Vault.of(this._iid);t.session.hasSession&&this._sync.start(0)}pause(){this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete o[this._iid])}}const d=(e,t)=>e.findIndex((e=>e.isIdentical(t))),h=(e,t,n)=>{if(e.length>0){const i=d(e,t);let s=0,r=e.length-1,a=Math.floor((s+r)/2);for(;s0)r=a,a=Math.floor((s+r)/2);else{if(!(o<0))return{place:a,oldPosition:i};s=a+1,a=Math.floor((s+r)/2)}}return{place:u(e[a],t,n)>=0?a:a+1,oldPosition:i}}return{place:e.length,oldPosition:-1}},u=(e,t,n)=>{switch(n){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(e.lastMessage&&t.lastMessage){const n=t.lastMessage.createdAt-e.lastMessage.createdAt;return 0===n?t.createdAt-e.createdAt:n}return e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:{const n=e.name.localeCompare(t.name);return 0===n?e.createdAt-t.createdAt:n}default:return 0}};class c{constructor(s,{filter:r=new t.GroupChannelFilter,order:o=i.GroupChannelListOrder.LATEST_LAST_MESSAGE,limit:d=n.DEFAULT_GROUPCHANNEL_LIMIT,includeChangesOnInitialLoad:h=!1}){this.channels=[],this._isInitialized=!1,this._iid=s,this._key=`gcc-${e.uuid()}`,this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=h,this.filter=r,this.order=o,this._hasMore=!0,this._token="",this._limit=d;const{sdkState:u,cacheContext:c,dispatcher:p}=e.Vault.of(this._iid);c.localCacheEnabled&&(this._backgroundSync=a.of(s),this._backgroundSync.resume()),this._changelogSync=l.of(s),this._changelogSync.resume();t.GroupChannelManager.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:(e,n)=>{const{source:i}=n;if(t.shouldGiveEvent(i)){const t=e.filter((e=>this.filter.match(e,u.userId))),i=e.filter((e=>!this.filter.match(e,u.userId))).map((e=>e.url));t.length>0&&this._addChannelsToView(t,n),i.length>0&&this._removeChannelsFromView(i,n)}},onRemove:(e,t)=>{this._removeChannelsFromView(e,t)}}),p.on((t=>{t instanceof e.ConnectionStateChangeCommand&&(t.stateType===e.ConnectionStateType.CONNECTED?this._isGetRemoteChannelsSucceeded||(()=>{e.__awaiter(this,void 0,void 0,(function*(){yield this._revokeLoadMore()}))})():t.stateType===e.ConnectionStateType.LOGOUT&&this.dispose())}))}get hasMore(){return!this._isDisposed&&this._hasMore}setGroupChannelCollectionHandler(e){this._handler=e}_addChannelsToView(n,s,r=!1){const a=[],o=[],l=[];for(const t of n){const n=d(this.channels,t);n>=0&&this.channels.splice(n,1);const{place:u}=h(this.channels,t,this.order);if(n<0)u===this.channels.length?!r&&this._hasMore||(a.push(t),this.channels.push(t)):(a.push(t),this.channels.splice(u,0,t));else switch(s.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&u===this.channels.length?l.push(t):(this.channels.splice(u,0,t),o.push(t));break;default:this.channels.splice(u,0,t),o.push(t)}}if(l.length>0)for(const e of l){const t=d(this.channels,e);-1!==t&&this.channels.splice(t,1)}t.shouldGiveEvent(s.source)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n;a.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(s,a),o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(s,o),l.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(s,l.map((e=>e.url)))}))))}_removeChannelsFromView(n,i){const s=[];for(const e of n){const t=this.channels.findIndex((t=>t.url===e));t>=0&&(s.push(this.channels[t].url),this.channels.splice(t,1))}return t.shouldGiveEvent(i.source)&&s.length>0&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,s)})))),s}_getLocalChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.GroupChannelManager.of(this._iid),n=this.channels.length>0?((e,t)=>{var n,s,r,a;switch(t){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(s=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==s?s:e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(a=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:e.createdAt}})(this.channels[this.channels.length-1],this.order):null;return yield e.getChannelsFromCache(n,this.filter,this.order,this._limit,n?this.channels[this.channels.length-1].url:void 0)}))}_getRemoteChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const n=t.GroupChannelManager.of(this._iid),{channels:i,token:s}=yield n.getMyGroupChannels(this._token,e.undefineNullProps(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);return this._token=s,this._hasMore=!!s,i}))}_revokeLoadMore(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._isDisposed)try{const t=yield this._getRemoteChannels();this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(t,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}catch(e){this._isGetRemoteChannelsSucceeded=!1}}))}loadMore(){var t;return e.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new e.SendbirdError({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});let n=null;this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning&&(n=yield new Promise((e=>{this._changelogSyncSubscriberContext=this._changelogSync.on("progress",(t=>e(t))).on("pause",(()=>e(null)))})),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close());const{cacheContext:i,connectionManager:s,statManager:r}=e.Vault.of(this._iid);this._isInitialized||(this._isInitialized=!0,i.localCacheEnabled&&(yield this._backgroundSync.loadMetadata()),r.put(new e.DailyRecordStatLog({type:e.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}})));let a=[];if(this._hasMore){if(!i.localCacheEnabled||s.isConnected&&!this._backgroundSync.completed)try{a=yield this._getRemoteChannels(),this._isGetRemoteChannelsSucceeded=!0}catch(e){this._isGetRemoteChannelsSucceeded=!1}else yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){a=yield this._getLocalChannels()})))),this._hasMore=a.length>=this._limit;this._addChannelsToView(a,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}if(n){for(const e of n.updatedChannels){const t=d(a,e);if(t>=0)a[t]=e;else{const{place:t}=h(a,e,this.order);a.splice(t,0,e)}}const e=a.map((e=>e.url));for(const t of n.deletedChannelUrls){const n=e.indexOf(t);n>=0&&(a.splice(n,1),e.splice(n,1))}}return a}))}dispose(){var e,n,i;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===(n=this._changelogSync)||void 0===n||n.close(),null===(i=this._changelogSyncSubscriberContext)||void 0===i||i.close();t.GroupChannelManager.of(this._iid).unsubscribeChannelEvent(this._key)}}class p extends e.APIRequestCommand{constructor(n){const{token:i,limit:s,order:r,includeEmpty:a,membershipFilter:o,channelNameContainsFilter:l,channelUrlsFilter:d,customTypesFilter:h,customTypeStartsWithFilter:u,superChannelFilter:c,metadataOrderKeyFilter:p,metadataKey:_,metadataValues:g,metadataValueStartsWith:m,includeFrozen:C,includeMetaData:f}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_GROUP_CHANNELS,this.params=e.deundefined(e.undefineNullProps({token:i,limit:s,order:r,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:a,public_mode:t.PublicChannelFilter.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:d,custom_types:h,custom_type_startswith:u,super_mode:c,metadata_order_key:p,metadata_key:_,metadata_values:g,metadata_value_startswith:m,show_frozen:C,show_metadata:f}))}}class _ extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:i,channels:s,ts:r}=n;this.token=i,s&&s.length>0&&(this.channels=s.map((n=>(n.ts=r,new t.GroupChannel(e,n))))),this.ts="number"==typeof r?r:0}}var g;exports.MembershipFilter=void 0,(g=exports.MembershipFilter||(exports.MembershipFilter={})).ALL="all",g.JOINED="joined";class m extends e.BaseListQuery{constructor(e,n){var s,r,a,o,l,d,h,u,c,p,_,g,m,C;super(e,n),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=t.SuperChannelFilter.ALL,this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=i.PublicGroupChannelListOrder.CHRONOLOGICAL,this.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,this.customTypesFilter=null!==(l=n.customTypesFilter)&&void 0!==l?l:null,this.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,this.channelNameContainsFilter=null!==(h=n.channelNameContainsFilter)&&void 0!==h?h:null,this.membershipFilter=null!==(u=n.membershipFilter)&&void 0!==u?u:exports.MembershipFilter.ALL,this.superChannelFilter=null!==(c=n.superChannelFilter)&&void 0!==c?c:t.SuperChannelFilter.ALL,this.metadataKey=null!==(p=n.metadataKey)&&void 0!==p?p:null,this.metadataValues=null!==(_=n.metadataValues)&&void 0!==_?_:null,this.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,this.metadataValueStartsWith=null!==(m=n.metadataValueStartsWith)&&void 0!==m?m:null,this.order=null!==(C=n.order)&&void 0!==C?C:i.PublicGroupChannelListOrder.CHRONOLOGICAL}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.channelNameContainsFilter,!0)&&e.isArrayOf("string",this.channelUrlsFilter,!0)&&e.isArrayOf("string",this.customTypesFilter,!0)&&e.isTypeOf("string",this.customTypeStartsWithFilter,!0)&&e.isEnumOf(exports.MembershipFilter,this.membershipFilter)&&e.isEnumOf(t.SuperChannelFilter,this.superChannelFilter)&&e.isEnumOf(i.PublicGroupChannelListOrder,this.order)&&e.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&e.isTypeOf("string",this.metadataKey,!0)&&e.isArrayOf("string",this.metadataValues,!0)&&e.isTypeOf("string",this.metadataValueStartsWith,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;{const t=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),n=new p(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{channels:s,token:r}=i.as(_);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return t}}throw e.SendbirdError.invalidParameters}))}}class C extends s.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserJoined=e.noop,this.onUserLeft=e.noop,this.onUserReceivedInvitation=e.noop,this.onUserDeclinedInvitation=e.noop,this.onChannelHidden=e.noop,this.onUnreadMemberStatusUpdated=e.noop,this.onUndeliveredMemberStatusUpdated=e.noop,this.onTypingStatusUpdated=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop,this.onPinnedMessageUpdated=e.noop}}class f extends C{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class y extends e.APIRequestCommand{constructor(t){const{token:n,limit:i,order:s,reverse:r,channelUrl:a,messageTypeFilter:o,scheduledStatus:l}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_SCHEDULED_MESSAGES}`,this.params=e.deundefined(e.undefineNullProps({token:n,limit:i,reverse:r,channel_url:a,order:s,message_type:o,status:l}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.scheduledMessages=[];const{next:i,scheduled_messages:s}=t;this.token=i,this.scheduledMessages=s.map((t=>n.parseMessagePayload(e,t)))}}class b extends e.BaseListQuery{constructor(t,n){var i,s,r,a,o;super(t,n),this.channelUrl=null,this.order=null,this.reverse=!1,this.scheduledStatus=null,this.messageTypeFilter=e.MessageTypeFilter.ALL,this.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,this.order=null!==(s=n.order)&&void 0!==s?s:null,this.reverse=null!==(r=n.reverse)&&void 0!==r&&r,this.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,this.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:e.MessageTypeFilter.ALL}_validate(){return super._validate()&&e.isTypeOf("string",this.channelUrl,!0)&&(e.isEnumOf(i.ScheduledMessageListOrder,this.order)||null===this.order)&&e.isTypeOf("boolean",this.reverse)&&(e.isArrayOf(n.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&e.isEnumOf(e.MessageTypeFilter,this.messageTypeFilter)}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),n=new y(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{scheduledMessages:s,token:r}=i.as(v);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class S extends e.Module{constructor(){super(...arguments),this.name="groupChannel"}init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}){super.init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}),this._manager=new t.GroupChannelManager(e,{sdkState:n,cacheContext:l,dispatcher:i,sessionManager:s,requestQueue:r,logger:a})}createGroupChannelCollection(e={}){return new c(this._iid,e)}createMyGroupChannelListQuery(e={}){return new t.GroupChannelListQuery(this._iid,e)}createPublicGroupChannelListQuery(e={}){return new m(this._iid,e)}createScheduledMessageListQuery(e={}){return new b(this._iid,e)}addGroupChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof f).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeGroupChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}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(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getChannelWithoutCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannelWithoutCache(t)}))}getMyGroupChannelChangeLogsByToken(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("string",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getMyGroupChannelChangeLogsByTimestamp(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("number",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getGroupChannelCount(n){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCountParamsDefault),n);return e.unless(t.validateGroupChannelCountParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.getGroupChannelCount(i)}))}getUnreadItemCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getUnreadItemCount(t)}))}getTotalUnreadChannelCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadChannelCount()}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadMessageCount(t)}))}getTotalScheduledMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalScheduledMessageCount(t)}))}getSubscribedTotalUnreadMessageCount(){return this._manager.getSubscribedTotalUnreadMessageCount()}getSubscribedCustomTypeTotalUnreadMessageCount(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}getSubscribedCustomTypeUnreadMessageCount(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.createChannel(i)}))}createDistinctChannelIfNotExist(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),i&&(i.isDistinct=!0),this.createChannel(i)}))}createChannelWithUserIds(n,i=!1,s,r,a="",o=""){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),{invitedUserIds:n,isDistinct:i,name:s,data:a,customType:o});return"string"==typeof r?e.coverUrl=r:e.coverImage=r,this.createChannel(e)}))}markAsReadAll(){return e.__awaiter(this,void 0,void 0,(function*(){this._manager.markAsReadAll()}))}markAsReadWithChannelUrls(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.markAsReadWithChannelUrls(t)}))}markAsDelivered(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=yield this.getChannel(t);yield n.markAsDelivered()}))}}exports.MessageEventSource=e.MessageEventSource,Object.defineProperty(exports,"MutedState",{enumerable:!0,get:function(){return e.MutedState}}),Object.defineProperty(exports,"CountPreference",{enumerable:!0,get:function(){return t.CountPreference}}),exports.DeliveryStatus=t.DeliveryStatus,exports.GroupChannel=t.GroupChannel,exports.GroupChannelEventSource=t.GroupChannelEventSource,exports.GroupChannelFilter=t.GroupChannelFilter,exports.GroupChannelListQuery=t.GroupChannelListQuery,Object.defineProperty(exports,"GroupChannelSearchField",{enumerable:!0,get:function(){return t.GroupChannelSearchField}}),Object.defineProperty(exports,"HiddenChannelFilter",{enumerable:!0,get:function(){return t.HiddenChannelFilter}}),Object.defineProperty(exports,"HiddenState",{enumerable:!0,get:function(){return t.HiddenState}}),exports.Member=t.Member,Object.defineProperty(exports,"MemberListOrder",{enumerable:!0,get:function(){return t.MemberListOrder}}),exports.MemberListQuery=t.MemberListQuery,Object.defineProperty(exports,"MemberState",{enumerable:!0,get:function(){return t.MemberState}}),Object.defineProperty(exports,"MemberStateFilter",{enumerable:!0,get:function(){return t.MemberStateFilter}}),exports.MessageCollection=t.MessageCollection,exports.MessageCollectionInitHandler=t.MessageCollectionInitHandler,Object.defineProperty(exports,"MessageCollectionInitPolicy",{enumerable:!0,get:function(){return t.MessageCollectionInitPolicy}}),Object.defineProperty(exports,"MutedMemberFilter",{enumerable:!0,get:function(){return t.MutedMemberFilter}}),Object.defineProperty(exports,"MyMemberStateFilter",{enumerable:!0,get:function(){return t.MyMemberStateFilter}}),Object.defineProperty(exports,"OperatorFilter",{enumerable:!0,get:function(){return t.OperatorFilter}}),Object.defineProperty(exports,"PublicChannelFilter",{enumerable:!0,get:function(){return t.PublicChannelFilter}}),Object.defineProperty(exports,"QueryType",{enumerable:!0,get:function(){return t.QueryType}}),Object.defineProperty(exports,"SuperChannelFilter",{enumerable:!0,get:function(){return t.SuperChannelFilter}}),Object.defineProperty(exports,"UnreadChannelFilter",{enumerable:!0,get:function(){return t.UnreadChannelFilter}}),Object.defineProperty(exports,"UnreadItemKey",{enumerable:!0,get:function(){return t.UnreadItemKey}}),exports.MessageFilter=n.MessageFilter,exports.PinnedMessage=n.PinnedMessage,exports.PinnedMessageListQuery=n.PinnedMessageListQuery,exports.ReadStatus=n.ReadStatus,Object.defineProperty(exports,"ScheduledStatus",{enumerable:!0,get:function(){return n.ScheduledStatus}}),Object.defineProperty(exports,"GroupChannelListOrder",{enumerable:!0,get:function(){return i.GroupChannelListOrder}}),Object.defineProperty(exports,"PublicGroupChannelListOrder",{enumerable:!0,get:function(){return i.PublicGroupChannelListOrder}}),Object.defineProperty(exports,"ScheduledMessageListOrder",{enumerable:!0,get:function(){return i.ScheduledMessageListOrder}}),exports.GroupChannelCollection=c,exports.GroupChannelHandler=f,exports.GroupChannelModule=S,exports.PublicGroupChannelListQuery=m,exports.ScheduledMessageListQuery=b; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),t=require("./lib/__bundle-dcf4d0c3.cjs"),n=require("./lib/__bundle-165fd6e1.cjs"),i=require("./lib/__bundle-2ad218ff.cjs"),s=require("./lib/__bundle-611abb88.cjs");require("./lib/__bundle-d3673ecc.cjs"),require("./lib/__bundle-dae7bdf2.cjs"),require("./lib/__bundle-bfe2e997.cjs");const r={};class a{constructor({_iid:n,limit:s=100}){this.ref=0,this._iid=n,this._limit=s;const{sdkState:r,dispatcher:a,logger:o,cacheContext:l,statManager:d}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${r.userId}@groupchannel/sync.meta`;const h=(e=>`sendbird:${e}@groupchannel/sync`)(r.userId);this._sync=new t.Sync(h,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,s,a,h,u,c,p,_;const g={hasNext:!0,nextToken:""};if(yield this.loadMetadata(),o.debug("channel background sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),null===(s=this._metadata)||void 0===s?void 0:s.completed)g.hasNext=!1,g.nextToken="";else{const n={includeEmpty:!0,includeMetaData:!0,order:i.GroupChannelListOrder.CHRONOLOGICAL};try{if(n.order===i.GroupChannelListOrder.LATEST_LAST_MESSAGE)try{const t=yield l.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(r.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const s=t.GroupChannelManager.of(this._iid),{channels:d,token:u}=yield s.getMyGroupChannels(null!==(h=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==h?h:"",n,this._limit,e.CollectionEventSource.SYNC_CHANNEL_BACKGROUND);g.hasNext=d.length>=this._limit&&!!u,g.nextToken=u,this._metadata&&(this._metadata.token=u,this._metadata.range.extends(...d.map((e=>e.createdAt))),this._metadata.completed=!g.hasNext),o.debug("channel background sync progress",g),yield this.saveMetadata()}catch(t){throw o.debug("channel background sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetaData()),t}finally{d.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=l.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:null!==(_=null===(p=n.order)||void 0===p?void 0:p.toString())&&void 0!==_?_:"",collection_id:r.userId}}))}}return g})))),this._connectionEventContext=a.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return r[e]||(r[e]=new a({_iid:e})),r[e].ref++,r[e]}static clear(e){r[e]&&(r[e].close(),delete r[e])}get range(){var e,n;return null!==(n=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==n?n:new t.TimeRange({})}get completed(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:n}=e.Vault.of(this._iid),i=yield n.preference.get(this._metadataKey);this._metadata={token:i?i.token:"",range:new t.TimeRange(i?i.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!i&&i.completed}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetaData(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){var t,n;const{logger:i,sessionManager:s}=e.Vault.of(this._iid);s.session.hasSession&&(i.debug("channel background sync resume()"),this._sync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.token)&&void 0!==n?n:""))}pause(){const{logger:t}=e.Vault.of(this._iid);t.debug("channel background sync stop()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete r[this._iid])}}const o={};class l{constructor({_iid:n}){this.ref=0,this._iid=n;const{logger:i,sdkState:s,dispatcher:r,cacheContext:a,statManager:o}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${s.userId}@groupchannel/changelogs.meta`,this._subscribers=new e.EventDispatcher;const l=(e=>`sendbird:${e}@groupchannel/changelogs`)(s.userId);this._sync=new t.Sync(l,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,r,l;const d={hasNext:!0,nextToken:0};yield this.loadMetadata(),i.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token);try{const n={includeEmpty:!0,includeMetaData:!0};try{const t=yield a.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(s.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const h=t.GroupChannelManager.of(this._iid),{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}=yield h.getMyGroupChannelChangeLogs(null!==(l=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==l?l:"",n,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);this._subscribers.dispatch("progress",{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}),d.hasNext=p,d.nextToken=_,this._metadata&&(this._metadata.token=_),i.debug("channel changelog sync progress",d),yield this.saveMetadata(),a.localCacheEnabled&&o.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:u.length>0||c.length>0?"cache_miss":"cache_hit",max_db_size:u.length,use_local_cache:a.localCacheEnabled,starting_point:0,message_init_policy:c.length.toString(),collection_id:s.userId}}))}catch(t){throw i.debug("channel changelog sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetadata()),t}return d})))),this._sync.on("stop",(()=>{this._subscribers.dispatch("pause")})),this._connectionEventContext=r.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return o[e]||(o[e]=new l({_iid:e})),o[e].ref++,o[e]}static clear(e){o[e]&&(o[e].close(),delete o[e])}get isRunning(){return this._sync.isRunning}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t,firstConnectedAt:n}=e.Vault.of(this._iid),i=yield t.preference.get(this._metadataKey);this._metadata={token:i?i.token:n}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}on(e,t){return this._subscribers.on(e,t)}resume(){const{sessionManager:t}=e.Vault.of(this._iid);t.session.hasSession&&this._sync.start(0)}pause(){this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete o[this._iid])}}const d=(e,t)=>e.findIndex((e=>e.isIdentical(t))),h=(e,t,n)=>{if(e.length>0){const i=d(e,t);let s=0,r=e.length-1,a=Math.floor((s+r)/2);for(;s0)r=a,a=Math.floor((s+r)/2);else{if(!(o<0))return{place:a,oldPosition:i};s=a+1,a=Math.floor((s+r)/2)}}return{place:u(e[a],t,n)>=0?a:a+1,oldPosition:i}}return{place:e.length,oldPosition:-1}},u=(e,t,n)=>{switch(n){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(e.lastMessage&&t.lastMessage){const n=t.lastMessage.createdAt-e.lastMessage.createdAt;return 0===n?t.createdAt-e.createdAt:n}return e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:{const n=e.name.localeCompare(t.name);return 0===n?e.createdAt-t.createdAt:n}default:return 0}};class c{constructor(s,{filter:r=new t.GroupChannelFilter,order:o=i.GroupChannelListOrder.LATEST_LAST_MESSAGE,limit:d=n.DEFAULT_GROUPCHANNEL_LIMIT,includeChangesOnInitialLoad:h=!1}){this.channels=[],this._isInitialized=!1,this._iid=s,this._key=`gcc-${e.uuid()}`,this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=h,this.filter=r,this.order=o,this._hasMore=!0,this._token="",this._limit=d;const{sdkState:u,cacheContext:c,dispatcher:p}=e.Vault.of(this._iid);c.localCacheEnabled&&(this._backgroundSync=a.of(s),this._backgroundSync.resume()),this._changelogSync=l.of(s),this._changelogSync.resume();t.GroupChannelManager.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:(e,n)=>{const{source:i}=n;if(t.shouldGiveEvent(i)){const t=e.filter((e=>this.filter.match(e,u.userId))),i=e.filter((e=>!this.filter.match(e,u.userId))).map((e=>e.url));t.length>0&&this._addChannelsToView(t,n),i.length>0&&this._removeChannelsFromView(i,n)}},onRemove:(e,t)=>{this._removeChannelsFromView(e,t)}}),p.on((t=>{t instanceof e.ConnectionStateChangeCommand&&(t.stateType===e.ConnectionStateType.CONNECTED?this._isGetRemoteChannelsSucceeded||(()=>{e.__awaiter(this,void 0,void 0,(function*(){yield this._revokeLoadMore()}))})():t.stateType===e.ConnectionStateType.LOGOUT&&this.dispose())}))}get hasMore(){return!this._isDisposed&&this._hasMore}setGroupChannelCollectionHandler(e){this._handler=e}_addChannelsToView(n,s,r=!1){const a=[],o=[],l=[];for(const t of n){const n=d(this.channels,t);n>=0&&this.channels.splice(n,1);const{place:u}=h(this.channels,t,this.order);if(n<0)u===this.channels.length?!r&&this._hasMore||(a.push(t),this.channels.push(t)):(a.push(t),this.channels.splice(u,0,t));else switch(s.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&u===this.channels.length?l.push(t):(this.channels.splice(u,0,t),o.push(t));break;default:this.channels.splice(u,0,t),o.push(t)}}if(l.length>0)for(const e of l){const t=d(this.channels,e);-1!==t&&this.channels.splice(t,1)}t.shouldGiveEvent(s.source)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n;a.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(s,a),o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(s,o),l.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(s,l.map((e=>e.url)))}))))}_removeChannelsFromView(n,i){const s=[];for(const e of n){const t=this.channels.findIndex((t=>t.url===e));t>=0&&(s.push(this.channels[t].url),this.channels.splice(t,1))}return t.shouldGiveEvent(i.source)&&s.length>0&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,s)})))),s}_getLocalChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.GroupChannelManager.of(this._iid),n=this.channels.length>0?((e,t)=>{var n,s,r,a;switch(t){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(s=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==s?s:e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(a=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:e.createdAt}})(this.channels[this.channels.length-1],this.order):null;return yield e.getChannelsFromCache(n,this.filter,this.order,this._limit,n?this.channels[this.channels.length-1].url:void 0)}))}_getRemoteChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const n=t.GroupChannelManager.of(this._iid),{channels:i,token:s}=yield n.getMyGroupChannels(this._token,e.undefineNullProps(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);return this._token=s,this._hasMore=!!s,i}))}_revokeLoadMore(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._isDisposed)try{const t=yield this._getRemoteChannels();this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(t,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}catch(e){this._isGetRemoteChannelsSucceeded=!1}}))}loadMore(){var t;return e.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new e.SendbirdError({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});let n=null;this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning&&(n=yield new Promise((e=>{this._changelogSyncSubscriberContext=this._changelogSync.on("progress",(t=>e(t))).on("pause",(()=>e(null)))})),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close());const{cacheContext:i,connectionManager:s,statManager:r}=e.Vault.of(this._iid);this._isInitialized||(this._isInitialized=!0,i.localCacheEnabled&&(yield this._backgroundSync.loadMetadata()),r.put(new e.DailyRecordStatLog({type:e.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}})));let a=[];if(this._hasMore){if(!i.localCacheEnabled||s.isConnected&&!this._backgroundSync.completed)try{a=yield this._getRemoteChannels(),this._isGetRemoteChannelsSucceeded=!0}catch(e){this._isGetRemoteChannelsSucceeded=!1}else yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){a=yield this._getLocalChannels()})))),this._hasMore=a.length>=this._limit;this._addChannelsToView(a,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}if(n){for(const e of n.updatedChannels){const t=d(a,e);if(t>=0)a[t]=e;else{const{place:t}=h(a,e,this.order);a.splice(t,0,e)}}const e=a.map((e=>e.url));for(const t of n.deletedChannelUrls){const n=e.indexOf(t);n>=0&&(a.splice(n,1),e.splice(n,1))}}return a}))}dispose(){var e,n,i;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===(n=this._changelogSync)||void 0===n||n.close(),null===(i=this._changelogSyncSubscriberContext)||void 0===i||i.close();t.GroupChannelManager.of(this._iid).unsubscribeChannelEvent(this._key)}}class p extends e.APIRequestCommand{constructor(n){const{token:i,limit:s,order:r,includeEmpty:a,membershipFilter:o,channelNameContainsFilter:l,channelUrlsFilter:d,customTypesFilter:h,customTypeStartsWithFilter:u,superChannelFilter:c,metadataOrderKeyFilter:p,metadataKey:_,metadataValues:g,metadataValueStartsWith:m,includeFrozen:C,includeMetaData:f}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_GROUP_CHANNELS,this.params=e.deundefined(e.undefineNullProps({token:i,limit:s,order:r,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:a,public_mode:t.PublicChannelFilter.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:d,custom_types:h,custom_type_startswith:u,super_mode:c,metadata_order_key:p,metadata_key:_,metadata_values:g,metadata_value_startswith:m,show_frozen:C,show_metadata:f}))}}class _ extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:i,channels:s,ts:r}=n;this.token=i,s&&s.length>0&&(this.channels=s.map((n=>(n.ts=r,new t.GroupChannel(e,n))))),this.ts="number"==typeof r?r:0}}var g;exports.MembershipFilter=void 0,(g=exports.MembershipFilter||(exports.MembershipFilter={})).ALL="all",g.JOINED="joined";class m extends e.BaseListQuery{constructor(e,n){var s,r,a,o,l,d,h,u,c,p,_,g,m,C;super(e,n),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=t.SuperChannelFilter.ALL,this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=i.PublicGroupChannelListOrder.CHRONOLOGICAL,this.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,this.customTypesFilter=null!==(l=n.customTypesFilter)&&void 0!==l?l:null,this.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,this.channelNameContainsFilter=null!==(h=n.channelNameContainsFilter)&&void 0!==h?h:null,this.membershipFilter=null!==(u=n.membershipFilter)&&void 0!==u?u:exports.MembershipFilter.ALL,this.superChannelFilter=null!==(c=n.superChannelFilter)&&void 0!==c?c:t.SuperChannelFilter.ALL,this.metadataKey=null!==(p=n.metadataKey)&&void 0!==p?p:null,this.metadataValues=null!==(_=n.metadataValues)&&void 0!==_?_:null,this.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,this.metadataValueStartsWith=null!==(m=n.metadataValueStartsWith)&&void 0!==m?m:null,this.order=null!==(C=n.order)&&void 0!==C?C:i.PublicGroupChannelListOrder.CHRONOLOGICAL}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.channelNameContainsFilter,!0)&&e.isArrayOf("string",this.channelUrlsFilter,!0)&&e.isArrayOf("string",this.customTypesFilter,!0)&&e.isTypeOf("string",this.customTypeStartsWithFilter,!0)&&e.isEnumOf(exports.MembershipFilter,this.membershipFilter)&&e.isEnumOf(t.SuperChannelFilter,this.superChannelFilter)&&e.isEnumOf(i.PublicGroupChannelListOrder,this.order)&&e.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&e.isTypeOf("string",this.metadataKey,!0)&&e.isArrayOf("string",this.metadataValues,!0)&&e.isTypeOf("string",this.metadataValueStartsWith,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;{const t=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),n=new p(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{channels:s,token:r}=i.as(_);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return t}}throw e.SendbirdError.invalidParameters}))}}class C extends s.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserJoined=e.noop,this.onUserLeft=e.noop,this.onUserReceivedInvitation=e.noop,this.onUserDeclinedInvitation=e.noop,this.onChannelHidden=e.noop,this.onUnreadMemberStatusUpdated=e.noop,this.onUndeliveredMemberStatusUpdated=e.noop,this.onTypingStatusUpdated=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop,this.onPinnedMessageUpdated=e.noop}}class f extends C{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class y extends e.APIRequestCommand{constructor(t){const{token:n,limit:i,order:s,reverse:r,channelUrl:a,messageTypeFilter:o,scheduledStatus:l}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_SCHEDULED_MESSAGES}`,this.params=e.deundefined(e.undefineNullProps({token:n,limit:i,reverse:r,channel_url:a,order:s,message_type:o,status:l}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.scheduledMessages=[];const{next:i,scheduled_messages:s}=t;this.token=i,this.scheduledMessages=s.map((t=>n.parseMessagePayload(e,t)))}}class b extends e.BaseListQuery{constructor(t,n){var i,s,r,a,o;super(t,n),this.channelUrl=null,this.order=null,this.reverse=!1,this.scheduledStatus=null,this.messageTypeFilter=e.MessageTypeFilter.ALL,this.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,this.order=null!==(s=n.order)&&void 0!==s?s:null,this.reverse=null!==(r=n.reverse)&&void 0!==r&&r,this.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,this.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:e.MessageTypeFilter.ALL}_validate(){return super._validate()&&e.isTypeOf("string",this.channelUrl,!0)&&(e.isEnumOf(i.ScheduledMessageListOrder,this.order)||null===this.order)&&e.isTypeOf("boolean",this.reverse)&&(e.isArrayOf(n.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&e.isEnumOf(e.MessageTypeFilter,this.messageTypeFilter)}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),n=new y(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{scheduledMessages:s,token:r}=i.as(v);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class S extends e.Module{constructor(){super(...arguments),this.name="groupChannel"}init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}){super.init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}),this._manager=new t.GroupChannelManager(e,{sdkState:n,cacheContext:l,dispatcher:i,sessionManager:s,requestQueue:r,logger:a})}createGroupChannelCollection(e={}){return new c(this._iid,e)}createMyGroupChannelListQuery(e={}){return new t.GroupChannelListQuery(this._iid,e)}createPublicGroupChannelListQuery(e={}){return new m(this._iid,e)}createScheduledMessageListQuery(e={}){return new b(this._iid,e)}addGroupChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof f).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeGroupChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}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(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getChannelWithoutCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannelWithoutCache(t)}))}getMyGroupChannelChangeLogsByToken(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("string",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getMyGroupChannelChangeLogsByTimestamp(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("number",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getGroupChannelCount(n){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCountParamsDefault),n);return e.unless(t.validateGroupChannelCountParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.getGroupChannelCount(i)}))}getUnreadItemCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getUnreadItemCount(t)}))}getTotalUnreadChannelCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadChannelCount()}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadMessageCount(t)}))}getTotalScheduledMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalScheduledMessageCount(t)}))}getSubscribedTotalUnreadMessageCount(){return this._manager.getSubscribedTotalUnreadMessageCount()}getSubscribedCustomTypeTotalUnreadMessageCount(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}getSubscribedCustomTypeUnreadMessageCount(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.createChannel(i)}))}createDistinctChannelIfNotExist(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),i&&(i.isDistinct=!0),this.createChannel(i)}))}createChannelWithUserIds(n,i=!1,s,r,a="",o=""){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),{invitedUserIds:n,isDistinct:i,name:s,data:a,customType:o});return"string"==typeof r?e.coverUrl=r:e.coverImage=r,this.createChannel(e)}))}markAsReadAll(){return e.__awaiter(this,void 0,void 0,(function*(){this._manager.markAsReadAll()}))}markAsReadWithChannelUrls(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.markAsReadWithChannelUrls(t)}))}markAsDelivered(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=yield this.getChannel(t);yield n.markAsDelivered()}))}}exports.MessageEventSource=e.MessageEventSource,Object.defineProperty(exports,"MutedState",{enumerable:!0,get:function(){return e.MutedState}}),Object.defineProperty(exports,"CountPreference",{enumerable:!0,get:function(){return t.CountPreference}}),exports.DeliveryStatus=t.DeliveryStatus,exports.GroupChannel=t.GroupChannel,exports.GroupChannelEventSource=t.GroupChannelEventSource,exports.GroupChannelFilter=t.GroupChannelFilter,exports.GroupChannelListQuery=t.GroupChannelListQuery,Object.defineProperty(exports,"GroupChannelSearchField",{enumerable:!0,get:function(){return t.GroupChannelSearchField}}),Object.defineProperty(exports,"HiddenChannelFilter",{enumerable:!0,get:function(){return t.HiddenChannelFilter}}),Object.defineProperty(exports,"HiddenState",{enumerable:!0,get:function(){return t.HiddenState}}),exports.Member=t.Member,Object.defineProperty(exports,"MemberListOrder",{enumerable:!0,get:function(){return t.MemberListOrder}}),exports.MemberListQuery=t.MemberListQuery,Object.defineProperty(exports,"MemberState",{enumerable:!0,get:function(){return t.MemberState}}),Object.defineProperty(exports,"MemberStateFilter",{enumerable:!0,get:function(){return t.MemberStateFilter}}),exports.MessageCollection=t.MessageCollection,exports.MessageCollectionInitHandler=t.MessageCollectionInitHandler,Object.defineProperty(exports,"MessageCollectionInitPolicy",{enumerable:!0,get:function(){return t.MessageCollectionInitPolicy}}),Object.defineProperty(exports,"MutedMemberFilter",{enumerable:!0,get:function(){return t.MutedMemberFilter}}),Object.defineProperty(exports,"MyMemberStateFilter",{enumerable:!0,get:function(){return t.MyMemberStateFilter}}),Object.defineProperty(exports,"OperatorFilter",{enumerable:!0,get:function(){return t.OperatorFilter}}),Object.defineProperty(exports,"PublicChannelFilter",{enumerable:!0,get:function(){return t.PublicChannelFilter}}),Object.defineProperty(exports,"QueryType",{enumerable:!0,get:function(){return t.QueryType}}),Object.defineProperty(exports,"SuperChannelFilter",{enumerable:!0,get:function(){return t.SuperChannelFilter}}),Object.defineProperty(exports,"UnreadChannelFilter",{enumerable:!0,get:function(){return t.UnreadChannelFilter}}),Object.defineProperty(exports,"UnreadItemKey",{enumerable:!0,get:function(){return t.UnreadItemKey}}),exports.MessageFilter=n.MessageFilter,exports.PinnedMessage=n.PinnedMessage,exports.PinnedMessageListQuery=n.PinnedMessageListQuery,exports.ReadStatus=n.ReadStatus,Object.defineProperty(exports,"ScheduledStatus",{enumerable:!0,get:function(){return n.ScheduledStatus}}),Object.defineProperty(exports,"GroupChannelListOrder",{enumerable:!0,get:function(){return i.GroupChannelListOrder}}),Object.defineProperty(exports,"PublicGroupChannelListOrder",{enumerable:!0,get:function(){return i.PublicGroupChannelListOrder}}),Object.defineProperty(exports,"ScheduledMessageListOrder",{enumerable:!0,get:function(){return i.ScheduledMessageListOrder}}),exports.GroupChannelCollection=c,exports.GroupChannelHandler=f,exports.GroupChannelModule=S,exports.PublicGroupChannelListQuery=m,exports.ScheduledMessageListQuery=b; diff --git a/cjs/index.cjs b/cjs/index.cjs index 4d1756e..005fe9e 100644 --- a/cjs/index.cjs +++ b/cjs/index.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-ad182031.cjs"),t=require("./message.cjs"),s=require("./poll.cjs"),n=require("./lib/__bundle-9d371926.cjs"),i=require("./lib/__bundle-290a02c3.cjs"),r=require("./lib/__bundle-39ca4e91.cjs"),o=require("./lib/__bundle-a5185d74.cjs");require("./lib/__bundle-e8b53f2f.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class a{constructor(e){this.key=e.key,this.url=e.url}}class d{constructor(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((e=>new a(e))):[]}}class u{constructor(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((e=>new d(e))):[]}}class c{constructor(){this.onConnected=e.noop,this.onReconnectStarted=e.noop,this.onReconnectSucceeded=e.noop,this.onReconnectFailed=e.noop,this.onDisconnected=e.noop}}class l extends c{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class h{constructor(){this.onSessionExpired=e.noop,this.onSessionTokenRequired=e=>e(null),this.onSessionError=e.noop,this.onSessionRefreshed=e.noop,this.onSessionClosed=e.noop}}class _ extends h{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class p{constructor(){this.onFriendsDiscovered=e.noop,this.onTotalUnreadMessageCountChanged=e.noop,this.onTotalUnreadMessageCountUpdated=e.noop}}class f extends p{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class m extends e.APIRequestCommand{constructor({limit:t,token:s,userIdsFilter:n,metaDataKeyFilter:i,metaDataValuesFilter:r,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:i,metadatavalues_in:r,nickname_startswith:o})}}class g 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 v extends e.BaseListQuery{constructor(e,t){var s,n,i;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!==(i=t.metaDataValuesFilter)&&void 0!==i?i: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.nicknameStartsWithFilter,!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 m(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),n=yield t.send(s),{users:i,next:r}=n.as(g);return this._token=r,this._hasNext=!!r,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}class y extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n,userIdsFilter:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/block`,this.params=e.deundefined({limit:s,token:n,user_ids:i})}}class S 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 I 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 y(e.undefineNullProps(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token}))),i=yield s.send(n),{users:r,next:o}=i.as(S);return this._token=o,this._hasNext=!!o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}class P 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 C 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 E 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 P(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token})),i=yield s.send(n),{users:r,hasMore:o,next:a}=i.as(C);return this._token=a,this._hasNext=o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}const b=2097152;class T extends n.BaseStore{constructor(t){var{AsyncStorage:s,itemSizeLimit:n=b}=t,i=e.__rest(t,["AsyncStorage","itemSizeLimit"]);super(Object.assign(Object.assign({},i),{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 n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getAllKeys();yield this.removeMany(e)}))}}class A extends n.BaseStore{constructor(e){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:6291456})),this._mmkv=e.MMKV}_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._mmkv.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._mmkv.getString(this._getActualKey(t));return e?JSON.parse(e):null}))}_setRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t){const{key:t,data:s}=e;s.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(t),JSON.stringify(e))}}))}_removeRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t)this._mmkv.delete(this._getActualKey(e))}))}checkAvailability(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._mmkv)throw n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getAllKeys();yield this.removeMany(e)}))}}const w={profileImage:void 0,profileUrl:void 0,nickname:void 0},k=t=>(s,o)=>e.__awaiter(void 0,void 0,void 0,(function*(){switch(s){case 1:case 2:case 3:case 4:default:o();break;case 5:yield t.store.clear(),o();break;case 6:try{const{v2:s,v3:o,v4:a}=(t=>({v2:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_GROUPCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_GROUPCHANNEL_COLLECTION_KEY,index:[i.getGroupChannelIndexBy(i.GroupChannelListOrder.LATEST_LAST_MESSAGE),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHRONOLOGICAL),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:n.NESTDB_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_POLL_COLLECTION_NAME,keyName:n.NESTDB_POLL_COLLECTION_KEY}])})),v3:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_FEEDCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_FEEDCHANNEL_COLLECTION_KEY,index:[r.getFeedChannelIndexBy("latest_last_message")]}])})),v4:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_NOTIFICATION_COLLECTION_NAME,keyName:n.NESTDB_NOTIFICATION_COLLECTION_KEY,index:[n.getNotificationMessageIndexBy()]}])}))}))(t);yield s(),yield o(),yield a();const d=t.collection(n.NESTDB_MESSAGE_COLLECTION_NAME);yield d.removeIf({where:{channelType:e.ChannelType.OPEN}})}catch(e){}o()}})),O=()=>"undefined"!=typeof document?document.visibilityState:"visible";class R extends e.EventDispatcher{constructor({getVisibilityState:e=O,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 U{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 D extends e.APIRequestCommand{constructor({userId:t,nickname:s,profileUrl:n,profileImage:i,preferredLanguages:r}){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:i,preferred_languages:r}))}}class M extends e.APIResponseCommand{constructor(t,s){super(t,s),this.user=new e.User(t,Object.assign({},s))}}class x extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`,this.params=e.deundefined({apns_device_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class N extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`,this.params=e.deundefined({gcm_reg_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class L 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 q 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 V extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`}}class $ extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`}}class H extends e.APIRequestCommand{constructor({userId:t,type:s,token:n,ts:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/${encodeURIComponent(s)}/device_tokens`,this.params={created_ts:i,token:n}}}class F 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 j extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`}}class K extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class z 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 Q extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class B extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class G 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 W extends e.APIRequestCommand{constructor({userId:t,doNotDisturbOn:s,startHour:n,startMin:i,endHour:r,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:i,end_hour:r,end_min:o,timezone:a}}}class J 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 Y extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class X 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 Z extends e.APIRequestCommand{constructor({userId:t,snoozeOn:s,startTs:n,endTs:i}){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:i}}}class ee 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 te 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 se 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 ne extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class ie extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class re 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 oe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class ae extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`}}class de extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class ue 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 ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class le 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 he 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 _e 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 pe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.friendDiscoveryRequestId=t.friend_discovery_request_id}}class fe 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 me 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 ge extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s)))}}class ve 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 ye 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 Se extends e.APIResponseCommand{constructor(e,t){super(e,t),this.allowFriendDiscovery=t.allow_friend_discovery}}class Ie 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 Pe extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_EMOJI_CATEGORIES}}class Ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiContainer=new u(t)}}class Ee extends e.APIRequestCommand{constructor({categoryId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJI_CATEGORIES}/${t}`}}class be extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiCategory=new d(t)}}class Te extends e.APIRequestCommand{constructor({key:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJIS}/${t}`}}class Ae extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emoji=new a(t)}}class we extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_UIKIT_CONFIGURATION}`}}class ke 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}}var Oe;!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(Oe||(Oe={}));class Re extends e.APIRequestCommand{constructor({deviceToken:t,pushTrackingId:s,messageId:n,allowedPushNotification:i,channelKey:r,templateKey:o,eventType:a,notificationEventDeadline:d}){super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_PUSH_DELIVERY,this.params=e.deundefined({device_token:t,push_tracking_id:s,message_id:n,allowed_push_notification:i,channel_key:r,template_key:o,event_type:a,notification_event_deadline:d})}}let Ue;class De{constructor(t,s,n){this._storeInitialized=!1,this._iid=t,this.options=s;const{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,userEventHandlers:h,appStateToggleEnabled:_}=e.Vault.of(t);this._onlineDetector=new U({logger:l,connectionDelegate:{reconnect:()=>e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,connectionManager:n,sessionManager:i}=e.Vault.of(t);if(i.session.hasSession){if("foreground"===s.appState)try{yield n.resetAndReconnect()}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("resetAndReconnect failed by reconnect event = ",t)}}else try{yield n.connect(i.session.authToken)}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("connect failed by reconnect event = ",t)}d.dispatch(new r.NotificationCollectionRefreshCommand)})),disconnect:()=>{e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s}=e.Vault.of(t);yield s.disconnect()}))))}}});const p=new i.AutoResendManager(t,{localCacheEnabled:a.localCacheEnabled,enableAutoResend:a.localCacheConfig.enableAutoResend,dispatcher:d,sdkState:o,logger:l});n.forEach((e=>{e.init(t,{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,onlineDetector:this._onlineDetector}),this[e.name]=e})),this._appStateChangeDetector=new R({isEnabled:_}),this._appStateChangeDetector.on("resume",(()=>{l.debug("the page resumes from freeze"),this.setForegroundState()})).on("pause",(()=>{l.debug("the page freezes"),this.setBackgroundState()})),d.on((s=>{var n;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(i.UserEventCommand);switch(n.category){case i.UserEventCategory.FRIEND_DISCOVERED:{const{friendDiscoveries:s}=i.UserEvent.getDataAsFriendDiscoveredEvent(t,n);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.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 i=s.ts;"number"==typeof i&&i>t.ts&&(t.all!==s.all&&(n=!0),t.all=s.all>=0?s.all:0,s.customTypes&&Object.keys(s.customTypes).forEach((e=>{t.customTypes[e]!==s.customTypes[e]&&(n=!0),t.customTypes[e]=s.customTypes[e]})),n=n&&t.ts>0,t.ts=i),n&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.forEach((e=>{e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:t.all,feedChannelCount:t.feed,customTypeUnreadCount:t.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(t.all,t.customTypes)}))}))))}else s instanceof e.UserProfileUpdateCommand?(a.preference.set(this._getUserProfileCacheKey(o.userId),e.UserProfile.payloadify(s.userProfile)),(null===(n=s.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&a.preference.set(e.createChangelogIncludeChatNotificationsCacheKey(this.appId),{value:!0})):s instanceof e.SessionExpiredCommand&&s.error&&s.error.isSessionInvalidatedError&&(l.debug("session revoked."),this._internalDisconnect(s.error))}))}static init(i){const{appId:r,appVersion:o,modules:a=[],options:d=new e.SendbirdChatOptions,debugMode:u=!1,customApiHost:c,customWebSocketHost:l,newInstance:h=!1,logLevel:_,localCacheEnabled:p=!1,localCacheConfig:f=new e.LocalCacheConfig,localCacheEncryption:m,useAsyncStorageStore:g=null,useMMKVStorageStore:v=null,appStateToggleEnabled:y=!0}=i;if(!Ue||h){const i=`su-${e.uuid()}`,h=null!=m?m:{encrypt:e=>e,decrypt:e=>e},S=new n.Logger;S.level=null!=_?_:n.LogLevel.WARN;let I=new n.MemoryStore({encryption:h});u||(e.isReactNative()?v?I=new A({MMKV:v,encryption:h}):g&&(I=new T({AsyncStorage:g,encryption:h}),S.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):I=new n.IndexedDbStore({encryption:h})),new e.Vault(i,{appId:r,appVersion:o,options:d,apiHost:null!=c?c:`https://api-${r}.sendbird.com`,websocketHost:null!=l?l:`wss://ws-${r}.sendbird.com`,store:I,encryption:h,logger:S,localCacheEnabled:p,localCacheConfig:f,debugMode:u,appStateToggleEnabled:y});const P=[new t.MessageModule,new s.PollModule],C=new De(i,d,[...a,...P]);return Ue||(Ue=C),C}return Ue}static get instance(){return Ue}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}_getNestDBVersion(){return 7}_getPreferenceCacheKey(e){return`sendbird@${this.appId}/${e}.pref`}_getUserProfileCacheKey(e){return`sendbird@${this.appId}/${e}.profile`}_internalDisconnect(t){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),yield s.logout(t),yield this.clearCachedData(),n.appState="foreground"}))}getMemoryStoreForDebugging(){const{debugMode:t,cacheContext:s}=e.Vault.of(this._iid);if(t)return s.store instanceof n.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)}addSendbirdExtensions(t,s,n){const{logger:i,sdkState:r}=e.Vault.of(this._iid),o=new RegExp(e.SEMVER_REGEX_STRING);if(0===t.length)return i.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(t.find((e=>!o.test(e.version))))return i.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(const[e,t]of Object.entries(n))if(/&|=/.test(e)||/&|=/.test(t))return i.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1;return r.sendbirdRuntimeEnvironment={sendbirdExtensions:t,deviceOS:s,customData:n},!0}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 n.MemoryStore),yield this._safeInitializeStore(t)}}))}setLocaleForChatbot(t){const{sdkState:s}=e.Vault.of(this._iid),n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(t.trim());n&&(s.localeForChatbot=n)}initializeCache(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:r,dispatcher:o,logger:a}=e.Vault.of(this._iid);if(!s.userId||s.userId!==t){const d=`sendbird@${s.appId}/${t}.db`;if(r.localCacheEnabled)try{if(r.nestdb&&r.nestdb.state!==n.NestDBState.CLOSED&&r.nestdb.name===d)yield this._safeInitializeStore(d);else{const e=`sendbird@${s.appId}/${t}.db`,a=r.nestdb=new n.NestDB({name:e,version:this._getNestDBVersion(),store:r.store,config:new n.Config({dbname:e,itemSizeLimit:61440})});a.on("upgrade",k(a)),a.on("storeReplaced",(e=>{r.replaceStore(e),r.localCacheEnabled=!1,a.on("upgrade",k(a))})),yield a.open(),this._storeInitialized=!0,o.dispatch(new i.DatabaseOpenCommand(this._iid,{userId:t}))}s.userId=t}catch(i){throw a.warn("Nest DB Open Failed. ",i),r.store instanceof n.MemoryStore||(r.replaceStore(new n.MemoryStore),r.localCacheEnabled=!1),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=n.MessageCache.of(this._iid),i=n.UnsentMessageCache.of(this._iid);s&&i&&(yield Promise.all(t.map((t=>e.__awaiter(this,void 0,void 0,(function*(){yield s.removeMessagesOfChannel(t),yield i.removeMessagesOfChannel(t)}))))))}))}_setupPreference(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:n,statManager:i}=e.Vault.of(this._iid);yield n.preference.init(this._getPreferenceCacheKey(t),this._getNestDBVersion());const r=yield n.preference.get(this._getUserProfileCacheKey(t));if(r){new e.UserProfile(this._iid,r).apply()}yield i.init(`sendbird@${s.appId}/${t}.statlog`)}))}_ready(t,s,n={}){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:r,cacheContext:o,connectionManager:a}=e.Vault.of(this._iid),{errorForOtherUser:d}=n;if(r.userId&&r.userId!==t){if(d)throw d;yield a.logout()}try{yield this.initializeCache(t);const{dispatcher:s}=e.Vault.of(this._iid);s.dispatch(new i.ReduceDBSizeEventCommand)}catch(t){const{logger:s}=e.Vault.of(this._iid);o.localCacheEnabled=!1,s.warn("Cache initialization failed - cache is not available.")}finally{yield this._setupPreference(t)}}))}authenticateFeed(t,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.authenticate(t,s)}))}authenticate(t,s){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{sessionManager:i,connectionManager:r}=e.Vault.of(this._iid);if(yield this._ready(t,s,{errorForOtherUser:r.isConnected?e.SendbirdError.alreadyConnectedAsAnotherUser:void 0}),!(null===(n=i.session.services)||void 0===n?void 0:n.includes(e.SessionService.CHAT))){if(!s&&!i.handler){const e=new _;this.setSessionHandler(e)}yield i.authenticate(t,s)}return this.currentUser}))}connect(t,s){return e.__awaiter(this,void 0,void 0,(function*(){yield this._ready(t,s);try{const{connectionManager:t}=e.Vault.of(this._iid);yield t.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),i=n.session.hasSession;return i&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((()=>{s.appState="foreground"})).catch((()=>{}))),i}disconnect(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._internalDisconnect()}))}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(!0)}))}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().catch((e=>{n.debug("setBackgroundState error = ",e)})))}setForegroundState(){const{connectionManager:t,sdkState:s,dispatcher:n,logger:i}=e.Vault.of(this._iid);"background"===s.appState&&(s.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((e=>{i.debug("setForgroundState error = ",e)})),n.dispatch(new r.NotificationCollectionRefreshCommand))}setSessionHandler(t){e.unless(t instanceof _).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 f).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 l).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 v(this._iid,e)}createBlockedUserListQuery(e={}){return new I(this._iid,e)}createFriendListQuery(e={}){return new E(this._iid,e)}createMessageSearchQuery(e){return new n.MessageSearchQuery(this._iid,e)}createPollListQuery(t){return new e.PollListQuery(this._iid,Object.assign({},t))}createPollVoterListQuery(t){return new e.PollVoterListQuery(this._iid,Object.assign({},t))}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({},w),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),i=new D(Object.assign({userId:t.userId},s)),r=yield n.send(i),{user:o}=r.as(M);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),i=new D({userId:s.userId,preferredLanguages:t}),r=yield n.send(i),{user:o}=r.as(M);return this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),o}throw e.SendbirdError.connectionRequired}))}registerFCMPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.ANDROID}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.FCM,t))return e.PushTokenRegistrationState.SUCCESS;const o=new N({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.FCM,t,r),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:i}=e.Vault.of(this._iid),r=new q({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new $({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.FCM),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}registerAPNSPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.IOS}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.APNS,t))return e.PushTokenRegistrationState.SUCCESS;const o=new x({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.APNS,t,r),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:i}=e.Vault.of(this._iid),r=new L({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new V({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.APNS),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}markPushNotificationAsDelivered(t,s=!0){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:i,sessionManager:r,requestQueue:o,pushNotificationAckManager:a}=e.Vault.of(this._iid);i.debug("markPushNotificationAsDelivered:",t);const d=Oe.DELIVERED,{pushTrackingId:u,sessionTopics:c,sessionKey:l,messageId:h,channelKey:_,templateKey:p,notificationEventDeadline:f}=a.parseData(t);if(!l)throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(!c.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(a.isAcked(u,d))return void i.info("already delivered push notification:",u);const m=Boolean(_),g=s&&m,v=null===(n=r.deviceTokens[0])||void 0===n?void 0:n.token,y=new Re({deviceToken:null!=v?v:"",pushTrackingId:u,eventType:d,messageId:h,channelKey:_,templateKey:p,notificationEventDeadline:f,allowedPushNotification:g});l&&(y.headers["Session-Key"]=l);try{yield o.send(y),a.markAsAcked(u,d)}catch(e){throw i.debug(`failed to mark push notification as delivered. push tracking id: ${u}. error: ${e}`),e}}))}markPushNotificationAsClicked(t){var s;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:n,sessionManager:i,requestQueue:r,pushNotificationAckManager:o}=e.Vault.of(this._iid);n.debug("markPushNotificationAsClicked:",t);const a=Oe.CLICKED,{pushTrackingId:d,sessionTopics:u,sessionKey:c,messageId:l,channelKey:h,templateKey:_,notificationEventDeadline:p}=o.parseData(t);if(!c)throw n.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(!u.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw n.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(o.isAcked(d,a))return void n.info("already clicked push notification:",d);const f=null===(s=i.deviceTokens[0])||void 0===s?void 0:s.token,m=new Re({deviceToken:null!=f?f:"",pushTrackingId:d,eventType:a,messageId:l,channelKey:h,templateKey:_,notificationEventDeadline:p});c&&(m.headers["Session-Key"]=c);try{yield r.send(m),o.markAsAcked(d,a)}catch(e){throw n.debug(`failed to mark push notification as clicked. push tracking id: ${d}. error: ${e}`),e}}))}getChannelInvitationPreference(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new j({userId:t.userId}),i=yield s.send(n),{autoAccept:r}=i.as(K);return{autoAccept:r}}))}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),i=new z({userId:s.userId,willAutoAccept:t}),r=yield n.send(i),{autoAccept:o}=r.as(Q);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 B({userId:t.userId}),i=yield s.send(n),{preference:r}=i.as(G);return r}))}setDoNotDisturb(t,s=0,n=0,i=0,r=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",i)&&e.isTypeOf("number",r)&&e.isTypeOf("string",o)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:d}=e.Vault.of(this._iid),u=new W({userId:a.userId,doNotDisturbOn:t,startHour:s,startMin:n,endHour:i,endMin:r,timezone:o}),c=yield d.send(u),{preference:l}=c.as(J);return l}))}getSnoozePeriod(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new Y({userId:t.userId}),i=yield s.send(n),{snoozePeriod:r}=i.as(X);return r}))}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:i,requestQueue:r}=e.Vault.of(this._iid),o=new Z({userId:i.userId,snoozeOn:t,startTs:s,endTs:n}),a=yield r.send(o),{snoozePeriod:d}=a.as(ee);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:i,sessionManager:r}=e.Vault.of(this._iid),o=new H({userId:n.userId,type:s,token:t}),a=yield i.send(o),{pushTokens:d}=a.as(F);for(const e of d.deviceTokens)r.setDeviceToken(d.type,e);return yield r.saveDeviceToken(),d}))}getPushTriggerOption(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ne({userId:t.userId});return(yield s.send(n)).as(ie).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),i=new re({userId:s.userId,pushTriggerOption:t});return(yield n.send(i)).as(oe).pushTriggerOption}))}getPushTemplate(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ae({userId:t.userId});return(yield s.send(n)).as(de).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),i=new ue({userId:s.userId,templateName:t});return(yield n.send(i)).as(ce).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),i=new te({userId:s.userId,blockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new se({userId:s.userId,unblockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new le({userId:s.userId,token:t}),r=yield n.send(i),{changelogs:o}=r.as(he);return o}))}getAllowFriendDiscovery(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ye({userId:t.userId}),i=yield s.send(n),{allowFriendDiscovery:r}=i.as(Se);return r}))}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),i=new Ie({userId:s.userId,allowFriendDiscovery:t});return yield n.send(i),t}))}uploadFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),i=new _e({userId:s.userId,discoveries:t}),r=yield n.send(i),{friendDiscoveryRequestId:o}=r.as(pe);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),i=new fe({userId:s.userId,discoveryKeys:t});yield n.send(i)}))}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),i=new me({userId:s.userId,userIds:t}),r=yield n.send(i),{users:o}=r.as(ge);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),i=new ve({userId:s.userId,userIds:t});yield n.send(i)}))}getAllEmoji(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),s=new Pe,n=yield t.send(s),{emojiContainer:i}=n.as(Ce);return i}))}getEmojiCategory(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Ee({categoryId:t}),i=yield s.send(n),{emojiCategory:r}=i.as(be);return r}))}getEmoji(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Te({key:t}),i=yield s.send(n),{emoji:r}=i.as(Ae);return r}))}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 we,i=yield s.send(n),{uikitConfiguration:r}=i.as(ke);return r}))}}exports.AppInfo=e.AppInfo,exports.CachedChannelInfo=e.CachedChannelInfo,Object.defineProperty(exports,"CachedDataClearOrder",{enumerable:!0,get:function(){return e.CachedDataClearOrder}}),Object.defineProperty(exports,"ChannelType",{enumerable:!0,get:function(){return e.ChannelType}}),Object.defineProperty(exports,"CollectionEventSource",{enumerable:!0,get:function(){return e.CollectionEventSource}}),Object.defineProperty(exports,"ConnectionState",{enumerable:!0,get:function(){return e.ConnectionState}}),Object.defineProperty(exports,"DeviceOsPlatform",{enumerable:!0,get:function(){return e.DeviceOsPlatform}}),Object.defineProperty(exports,"LastMessageThreadingPolicy",{enumerable:!0,get:function(){return e.LastMessageThreadingPolicy}}),exports.LocalCacheConfig=e.LocalCacheConfig,exports.NotificationInfo=e.NotificationInfo,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,Object.defineProperty(exports,"SendbirdErrorCode",{enumerable:!0,get:function(){return e.SendbirdErrorCode}}),Object.defineProperty(exports,"SendbirdPlatform",{enumerable:!0,get:function(){return e.SendbirdPlatform}}),Object.defineProperty(exports,"SendbirdProduct",{enumerable:!0,get:function(){return e.SendbirdProduct}}),exports.UIKitConfigInfo=e.UIKitConfigInfo,Object.defineProperty(exports,"UnreadCountThreadingPolicy",{enumerable:!0,get:function(){return e.UnreadCountThreadingPolicy}}),exports.User=e.User,Object.defineProperty(exports,"UserOnlineState",{enumerable:!0,get:function(){return e.UserOnlineState}}),exports.BannedUserListQuery=n.BannedUserListQuery,exports.BaseChannel=n.BaseChannel,Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return n.LogLevel}}),exports.MemoryStore=n.MemoryStore,exports.MutedUserListQuery=n.MutedUserListQuery,exports.OperatorListQuery=n.OperatorListQuery,exports.Plugin=n.Plugin,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.Participant=o.Participant,exports.ApplicationUserListQuery=v,exports.BlockedUserListQuery=I,exports.ConnectionHandler=l,exports.Emoji=a,exports.EmojiCategory=d,exports.EmojiContainer=u,exports.FriendListQuery=E,exports.SessionHandler=_,exports.UserEventHandler=f,exports.default=De; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),t=require("./message.cjs"),s=require("./poll.cjs"),n=require("./lib/__bundle-165fd6e1.cjs"),i=require("./lib/__bundle-2ad218ff.cjs"),r=require("./lib/__bundle-ca16c7ed.cjs"),o=require("./lib/__bundle-c127c886.cjs");require("./lib/__bundle-bfe2e997.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class a{constructor(e){this.key=e.key,this.url=e.url}}class d{constructor(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((e=>new a(e))):[]}}class u{constructor(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((e=>new d(e))):[]}}class c{constructor(){this.onConnected=e.noop,this.onReconnectStarted=e.noop,this.onReconnectSucceeded=e.noop,this.onReconnectFailed=e.noop,this.onDisconnected=e.noop}}class l extends c{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class h{constructor(){this.onSessionExpired=e.noop,this.onSessionTokenRequired=e=>e(null),this.onSessionError=e.noop,this.onSessionRefreshed=e.noop,this.onSessionClosed=e.noop}}class p extends h{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class _{constructor(){this.onFriendsDiscovered=e.noop,this.onTotalUnreadMessageCountChanged=e.noop,this.onTotalUnreadMessageCountUpdated=e.noop}}class f extends _{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class m extends e.APIRequestCommand{constructor({limit:t,token:s,userIdsFilter:n,metaDataKeyFilter:i,metaDataValuesFilter:r,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:i,metadatavalues_in:r,nickname_startswith:o})}}class g 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 v extends e.BaseListQuery{constructor(e,t){var s,n,i;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!==(i=t.metaDataValuesFilter)&&void 0!==i?i: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.nicknameStartsWithFilter,!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 m(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),n=yield t.send(s),{users:i,next:r}=n.as(g);return this._token=r,this._hasNext=!!r,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}class y extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n,userIdsFilter:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/block`,this.params=e.deundefined({limit:s,token:n,user_ids:i})}}class S 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 I 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 y(e.undefineNullProps(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token}))),i=yield s.send(n),{users:r,next:o}=i.as(S);return this._token=o,this._hasNext=!!o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}class P 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 C 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 E 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 P(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token})),i=yield s.send(n),{users:r,hasMore:o,next:a}=i.as(C);return this._token=a,this._hasNext=o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}const b=2097152;class T extends n.BaseStore{constructor(t){var{AsyncStorage:s,itemSizeLimit:n=b}=t,i=e.__rest(t,["AsyncStorage","itemSizeLimit"]);super(Object.assign(Object.assign({},i),{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 n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){const t=Object.create(null,{clear:{get:()=>super.clear}});return e.__awaiter(this,void 0,void 0,(function*(){yield t.clear.call(this);const e=yield this.getAllKeys();yield this.removeMany(e)}))}}class A extends n.BaseStore{constructor(e){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:6291456})),this._mmkv=e.MMKV}_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._mmkv.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._mmkv.getString(this._getActualKey(t));return e?JSON.parse(e):null}))}_setRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t){const{key:t,data:s}=e;s.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(t),JSON.stringify(e))}}))}_removeRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t)this._mmkv.delete(this._getActualKey(e))}))}checkAvailability(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._mmkv)throw n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){const t=Object.create(null,{clear:{get:()=>super.clear}});return e.__awaiter(this,void 0,void 0,(function*(){yield t.clear.call(this);const e=yield this.getAllKeys();yield this.removeMany(e)}))}}const w={profileImage:void 0,profileUrl:void 0,nickname:void 0},k=t=>(s,o)=>e.__awaiter(void 0,void 0,void 0,(function*(){switch(s){case 1:case 2:case 3:case 4:default:o();break;case 5:yield t.reset(),o();break;case 6:try{const{v2:s,v3:o,v4:a}=(t=>({v2:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_GROUPCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_GROUPCHANNEL_COLLECTION_KEY,index:[i.getGroupChannelIndexBy(i.GroupChannelListOrder.LATEST_LAST_MESSAGE),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHRONOLOGICAL),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:n.NESTDB_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_POLL_COLLECTION_NAME,keyName:n.NESTDB_POLL_COLLECTION_KEY}])})),v3:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_FEEDCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_FEEDCHANNEL_COLLECTION_KEY,index:[r.getFeedChannelIndexBy("latest_last_message")]}])})),v4:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_NOTIFICATION_COLLECTION_NAME,keyName:n.NESTDB_NOTIFICATION_COLLECTION_KEY,index:[n.getNotificationMessageIndexBy()]}])}))}))(t);yield s(),yield o(),yield a();const d=t.collection(n.NESTDB_MESSAGE_COLLECTION_NAME);yield d.removeIf({where:{channelType:e.ChannelType.OPEN}})}catch(e){}o()}})),O=()=>"undefined"!=typeof document?document.visibilityState:"visible";class R extends e.EventDispatcher{constructor({getVisibilityState:e=O,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 U{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 D extends e.APIRequestCommand{constructor({userId:t,nickname:s,profileUrl:n,profileImage:i,preferredLanguages:r}){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:i,preferred_languages:r}))}}class M extends e.APIResponseCommand{constructor(t,s){super(t,s),this.user=new e.User(t,Object.assign({},s))}}class x extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`,this.params=e.deundefined({apns_device_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class N extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`,this.params=e.deundefined({gcm_reg_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class L 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 q 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 V extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`}}class $ extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`}}class H extends e.APIRequestCommand{constructor({userId:t,type:s,token:n,ts:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/${encodeURIComponent(s)}/device_tokens`,this.params={created_ts:i,token:n}}}class F 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 j extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`}}class K extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class z 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 Q extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class B extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class G 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 W extends e.APIRequestCommand{constructor({userId:t,doNotDisturbOn:s,startHour:n,startMin:i,endHour:r,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:i,end_hour:r,end_min:o,timezone:a}}}class J 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 Y extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class X 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 Z extends e.APIRequestCommand{constructor({userId:t,snoozeOn:s,startTs:n,endTs:i}){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:i}}}class ee 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 te 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 se 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 ne extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class ie extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class re 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 oe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class ae extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`}}class de extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class ue 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 ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class le 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 he 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 pe 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 _e extends e.APIResponseCommand{constructor(e,t){super(e,t),this.friendDiscoveryRequestId=t.friend_discovery_request_id}}class fe 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 me 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 ge extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s)))}}class ve 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 ye 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 Se extends e.APIResponseCommand{constructor(e,t){super(e,t),this.allowFriendDiscovery=t.allow_friend_discovery}}class Ie 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 Pe extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_EMOJI_CATEGORIES}}class Ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiContainer=new u(t)}}class Ee extends e.APIRequestCommand{constructor({categoryId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJI_CATEGORIES}/${t}`}}class be extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiCategory=new d(t)}}class Te extends e.APIRequestCommand{constructor({key:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJIS}/${t}`}}class Ae extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emoji=new a(t)}}class we extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_UIKIT_CONFIGURATION}`}}class ke 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}}var Oe;!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(Oe||(Oe={}));class Re extends e.APIRequestCommand{constructor({deviceToken:t,pushTrackingId:s,messageId:n,allowedPushNotification:i,channelKey:r,templateKey:o,eventType:a,notificationEventDeadline:d}){super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_PUSH_DELIVERY,this.params=e.deundefined({device_token:t,push_tracking_id:s,message_id:n,allowed_push_notification:i,channel_key:r,template_key:o,event_type:a,notification_event_deadline:d})}}let Ue;class De{constructor(t,s,n){this._storeInitialized=!1,this._iid=t,this.options=s;const{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,userEventHandlers:h,appStateToggleEnabled:p}=e.Vault.of(t);this._onlineDetector=new U({logger:l,connectionDelegate:{reconnect:()=>e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,connectionManager:n,sessionManager:i}=e.Vault.of(t);if(i.session.hasSession){if("foreground"===s.appState)try{yield n.resetAndReconnect()}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("resetAndReconnect failed by reconnect event = ",t)}}else try{yield n.connect(i.session.authToken)}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("connect failed by reconnect event = ",t)}d.dispatch(new r.NotificationCollectionRefreshCommand)})),disconnect:()=>{e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s}=e.Vault.of(t);yield s.disconnect()}))))}}});const _=new i.AutoResendManager(t,{localCacheEnabled:a.localCacheEnabled,enableAutoResend:a.localCacheConfig.enableAutoResend,dispatcher:d,sdkState:o,logger:l});n.forEach((e=>{e.init(t,{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,onlineDetector:this._onlineDetector}),this[e.name]=e})),this._appStateChangeDetector=new R({isEnabled:p}),this._appStateChangeDetector.on("resume",(()=>{l.debug("the page resumes from freeze"),this.setForegroundState()})).on("pause",(()=>{l.debug("the page freezes"),this.setBackgroundState()})),d.on((s=>{var n;if(s instanceof e.ConnectionStateChangeCommand){if(s.stateType===e.ConnectionStateType.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(s instanceof e.WebSocketEventCommand)switch(s.code){case"USEV":{const{event:n}=s.as(i.UserEventCommand);switch(n.category){case i.UserEventCategory.FRIEND_DISCOVERED:{const{friendDiscoveries:s}=i.UserEvent.getDataAsFriendDiscoveredEvent(t,n);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.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 i=s.ts;"number"==typeof i&&i>t.ts&&(t.all!==s.all&&(n=!0),t.all=s.all>=0?s.all:0,s.customTypes&&Object.keys(s.customTypes).forEach((e=>{t.customTypes[e]!==s.customTypes[e]&&(n=!0),t.customTypes[e]=s.customTypes[e]})),n=n&&t.ts>0,t.ts=i),n&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.forEach((e=>{e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:t.all,feedChannelCount:t.feed,customTypeUnreadCount:t.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(t.all,t.customTypes)}))}))))}else s instanceof e.UserProfileUpdateCommand?(a.preference.set(this._getUserProfileCacheKey(o.userId),e.UserProfile.payloadify(s.userProfile)),(null===(n=s.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&a.preference.set(e.createChangelogIncludeChatNotificationsCacheKey(this.appId),{value:!0})):s instanceof e.SessionExpiredCommand&&s.error&&s.error.isSessionInvalidatedError&&(l.debug("session revoked."),this._internalDisconnect(s.error))}))}static init(i){const{appId:r,appVersion:o,modules:a=[],options:d=new e.SendbirdChatOptions,debugMode:u=!1,customApiHost:c,customWebSocketHost:l,newInstance:h=!1,logLevel:p,localCacheEnabled:_=!1,localCacheConfig:f=new e.LocalCacheConfig,localCacheEncryption:m,useAsyncStorageStore:g=null,useMMKVStorageStore:v=null,appStateToggleEnabled:y=!0}=i;if(!Ue||h){const i=`su-${e.uuid()}`,h=null!=m?m:{encrypt:e=>e,decrypt:e=>e},S=new n.Logger;S.level=null!=p?p:n.LogLevel.WARN;let I=new n.MemoryStore({encryption:h});u||(e.isReactNative()?v?I=new A({MMKV:v,encryption:h}):g&&(I=new T({AsyncStorage:g,encryption:h}),S.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):I=new n.IndexedDbStore({encryption:h})),new e.Vault(i,{appId:r,appVersion:o,options:d,apiHost:null!=c?c:`https://api-${r}.sendbird.com`,websocketHost:null!=l?l:`wss://ws-${r}.sendbird.com`,store:I,encryption:h,logger:S,localCacheEnabled:_,localCacheConfig:f,debugMode:u,appStateToggleEnabled:y});const P=[new t.MessageModule,new s.PollModule],C=new De(i,d,[...a,...P]);return Ue||(Ue=C),C}return Ue}static get instance(){return Ue}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}_getNestDBVersion(){return 7}_getPreferenceCacheKey(e){return`sendbird@${this.appId}/${e}.pref`}_getUserProfileCacheKey(e){return`sendbird@${this.appId}/${e}.profile`}_internalDisconnect(t){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),yield s.logout(t),yield this.clearCachedData(),n.appState="foreground"}))}getMemoryStoreForDebugging(){const{debugMode:t,cacheContext:s}=e.Vault.of(this._iid);if(t)return s.store instanceof n.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)}addSendbirdExtensions(t,s,n){const{logger:i,sdkState:r}=e.Vault.of(this._iid),o=new RegExp(e.SEMVER_REGEX_STRING);if(0===t.length)return i.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(t.find((e=>!o.test(e.version))))return i.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(const[e,t]of Object.entries(n))if(/&|=/.test(e)||/&|=/.test(t))return i.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1;return r.sendbirdRuntimeEnvironment={sendbirdExtensions:t,deviceOS:s,customData:n},!0}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 n.MemoryStore),yield this._safeInitializeStore(t)}}))}setLocaleForChatbot(t){const{sdkState:s}=e.Vault.of(this._iid),n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(t.trim());n&&(s.localeForChatbot=n)}initializeCache(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:r,dispatcher:o,logger:a}=e.Vault.of(this._iid);if(!s.userId||s.userId!==t){const d=`sendbird@${s.appId}/${t}.db`;try{if(r.localCacheEnabled){if(r.nestdb&&r.nestdb.state!==n.NestDBState.CLOSED&&r.nestdb.name===d)yield this._safeInitializeStore(d);else{const e=`sendbird@${s.appId}/${t}.db`,a=r.nestdb=new n.NestDB({name:e,version:this._getNestDBVersion(),store:r.store,config:new n.Config({dbname:e,itemSizeLimit:61440})});a.on("upgrade",k(a)),a.on("storeReplaced",(e=>{r.replaceStore(e),r.localCacheEnabled=!1,a.on("upgrade",k(a))})),yield a.open(),this._storeInitialized=!0,o.dispatch(new i.DatabaseOpenCommand(this._iid,{userId:t}))}s.userId=t}else yield this._safeInitializeStore(d),s.userId=t}catch(i){throw a.warn("Nest DB Open Failed. ",i),r.store instanceof n.MemoryStore||(r.replaceStore(new n.MemoryStore),r.localCacheEnabled=!1),yield this._safeInitializeStore(d),s.userId=t,e.SendbirdError.databaseError}finally{yield this._setupPreference(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=n.MessageCache.of(this._iid),i=n.UnsentMessageCache.of(this._iid);s&&i&&(yield Promise.all(t.map((t=>e.__awaiter(this,void 0,void 0,(function*(){yield s.removeMessagesOfChannel(t),yield i.removeMessagesOfChannel(t)}))))))}))}_setupPreference(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:n,statManager:i}=e.Vault.of(this._iid);yield n.preference.init(this._getPreferenceCacheKey(t),this._getNestDBVersion());const r=yield n.preference.get(this._getUserProfileCacheKey(t));if(r){new e.UserProfile(this._iid,r).apply()}yield i.init(`sendbird@${s.appId}/${t}.statlog`)}))}_ready(t,s,n={}){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:r,cacheContext:o,connectionManager:a}=e.Vault.of(this._iid),{errorForOtherUser:d}=n;if(r.userId&&r.userId!==t){if(d)throw d;yield a.logout()}try{yield this.initializeCache(t);const{dispatcher:s}=e.Vault.of(this._iid);s.dispatch(new i.ReduceDBSizeEventCommand)}catch(t){const{logger:s}=e.Vault.of(this._iid);o.localCacheEnabled=!1,s.warn("Cache initialization failed - cache is not available.")}}))}authenticateFeed(t,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.authenticate(t,s)}))}authenticate(t,s){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{sessionManager:i,connectionManager:r}=e.Vault.of(this._iid);if(yield this._ready(t,s,{errorForOtherUser:r.isConnected?e.SendbirdError.alreadyConnectedAsAnotherUser:void 0}),!(null===(n=i.session.services)||void 0===n?void 0:n.includes(e.SessionService.CHAT))){if(!s&&!i.handler){const e=new p;this.setSessionHandler(e)}yield i.authenticate(t,s)}return this.currentUser}))}connect(t,s){return e.__awaiter(this,void 0,void 0,(function*(){yield this._ready(t,s);try{const{connectionManager:t}=e.Vault.of(this._iid);yield t.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),i=n.session.hasSession;return i&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((()=>{s.appState="foreground"})).catch((()=>{}))),i}disconnect(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._internalDisconnect()}))}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(!0)}))}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().catch((e=>{n.debug("setBackgroundState error = ",e)})))}setForegroundState(){const{connectionManager:t,sdkState:s,dispatcher:n,logger:i}=e.Vault.of(this._iid);"background"===s.appState&&(s.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((e=>{i.debug("setForgroundState error = ",e)})),n.dispatch(new r.NotificationCollectionRefreshCommand))}setSessionHandler(t){e.unless(t instanceof p).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 f).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 l).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 v(this._iid,e)}createBlockedUserListQuery(e={}){return new I(this._iid,e)}createFriendListQuery(e={}){return new E(this._iid,e)}createMessageSearchQuery(e){return new n.MessageSearchQuery(this._iid,e)}createPollListQuery(t){return new e.PollListQuery(this._iid,Object.assign({},t))}createPollVoterListQuery(t){return new e.PollVoterListQuery(this._iid,Object.assign({},t))}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({},w),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),i=new D(Object.assign({userId:t.userId},s)),r=yield n.send(i),{user:o}=r.as(M);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),i=new D({userId:s.userId,preferredLanguages:t}),r=yield n.send(i),{user:o}=r.as(M);return this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),o}throw e.SendbirdError.connectionRequired}))}registerFCMPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.ANDROID}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.FCM,t))return e.PushTokenRegistrationState.SUCCESS;const o=new N({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.FCM,t,r),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:i}=e.Vault.of(this._iid),r=new q({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new $({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.FCM),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}registerAPNSPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.IOS}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.APNS,t))return e.PushTokenRegistrationState.SUCCESS;const o=new x({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.APNS,t,r),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:i}=e.Vault.of(this._iid),r=new L({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new V({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.APNS),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}markPushNotificationAsDelivered(t,s=!0){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:i,sessionManager:r,requestQueue:o,pushNotificationAckManager:a}=e.Vault.of(this._iid);i.debug("markPushNotificationAsDelivered:",t);const d=Oe.DELIVERED,{pushTrackingId:u,sessionTopics:c,sessionKey:l,messageId:h,channelKey:p,templateKey:_,notificationEventDeadline:f}=a.parseData(t);if(!l)throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(!c.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(a.isAcked(u,d))return void i.info("already delivered push notification:",u);const m=Boolean(p),g=s&&m,v=null===(n=r.deviceTokens[0])||void 0===n?void 0:n.token,y=new Re({deviceToken:null!=v?v:"",pushTrackingId:u,eventType:d,messageId:h,channelKey:p,templateKey:_,notificationEventDeadline:f,allowedPushNotification:g});l&&(y.headers["Session-Key"]=l);try{yield o.send(y),a.markAsAcked(u,d)}catch(e){throw i.debug(`failed to mark push notification as delivered. push tracking id: ${u}. error: ${e}`),e}}))}markPushNotificationAsClicked(t){var s;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:n,sessionManager:i,requestQueue:r,pushNotificationAckManager:o}=e.Vault.of(this._iid);n.debug("markPushNotificationAsClicked:",t);const a=Oe.CLICKED,{pushTrackingId:d,sessionTopics:u,sessionKey:c,messageId:l,channelKey:h,templateKey:p,notificationEventDeadline:_}=o.parseData(t);if(!c)throw n.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(!u.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw n.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(o.isAcked(d,a))return void n.info("already clicked push notification:",d);const f=null===(s=i.deviceTokens[0])||void 0===s?void 0:s.token,m=new Re({deviceToken:null!=f?f:"",pushTrackingId:d,eventType:a,messageId:l,channelKey:h,templateKey:p,notificationEventDeadline:_});c&&(m.headers["Session-Key"]=c);try{yield r.send(m),o.markAsAcked(d,a)}catch(e){throw n.debug(`failed to mark push notification as clicked. push tracking id: ${d}. error: ${e}`),e}}))}getChannelInvitationPreference(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new j({userId:t.userId}),i=yield s.send(n),{autoAccept:r}=i.as(K);return{autoAccept:r}}))}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),i=new z({userId:s.userId,willAutoAccept:t}),r=yield n.send(i),{autoAccept:o}=r.as(Q);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 B({userId:t.userId}),i=yield s.send(n),{preference:r}=i.as(G);return r}))}setDoNotDisturb(t,s=0,n=0,i=0,r=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",i)&&e.isTypeOf("number",r)&&e.isTypeOf("string",o)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:d}=e.Vault.of(this._iid),u=new W({userId:a.userId,doNotDisturbOn:t,startHour:s,startMin:n,endHour:i,endMin:r,timezone:o}),c=yield d.send(u),{preference:l}=c.as(J);return l}))}getSnoozePeriod(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new Y({userId:t.userId}),i=yield s.send(n),{snoozePeriod:r}=i.as(X);return r}))}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:i,requestQueue:r}=e.Vault.of(this._iid),o=new Z({userId:i.userId,snoozeOn:t,startTs:s,endTs:n}),a=yield r.send(o),{snoozePeriod:d}=a.as(ee);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:i,sessionManager:r}=e.Vault.of(this._iid),o=new H({userId:n.userId,type:s,token:t}),a=yield i.send(o),{pushTokens:d}=a.as(F);for(const e of d.deviceTokens)r.setDeviceToken(d.type,e);return yield r.saveDeviceToken(),d}))}getPushTriggerOption(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ne({userId:t.userId});return(yield s.send(n)).as(ie).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),i=new re({userId:s.userId,pushTriggerOption:t});return(yield n.send(i)).as(oe).pushTriggerOption}))}getPushTemplate(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ae({userId:t.userId});return(yield s.send(n)).as(de).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),i=new ue({userId:s.userId,templateName:t});return(yield n.send(i)).as(ce).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),i=new te({userId:s.userId,blockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new se({userId:s.userId,unblockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new le({userId:s.userId,token:t}),r=yield n.send(i),{changelogs:o}=r.as(he);return o}))}getAllowFriendDiscovery(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ye({userId:t.userId}),i=yield s.send(n),{allowFriendDiscovery:r}=i.as(Se);return r}))}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),i=new Ie({userId:s.userId,allowFriendDiscovery:t});return yield n.send(i),t}))}uploadFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),i=new pe({userId:s.userId,discoveries:t}),r=yield n.send(i),{friendDiscoveryRequestId:o}=r.as(_e);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),i=new fe({userId:s.userId,discoveryKeys:t});yield n.send(i)}))}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),i=new me({userId:s.userId,userIds:t}),r=yield n.send(i),{users:o}=r.as(ge);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),i=new ve({userId:s.userId,userIds:t});yield n.send(i)}))}getAllEmoji(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),s=new Pe,n=yield t.send(s),{emojiContainer:i}=n.as(Ce);return i}))}getEmojiCategory(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Ee({categoryId:t}),i=yield s.send(n),{emojiCategory:r}=i.as(be);return r}))}getEmoji(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Te({key:t}),i=yield s.send(n),{emoji:r}=i.as(Ae);return r}))}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 we,i=yield s.send(n),{uikitConfiguration:r}=i.as(ke);return r}))}}exports.AppInfo=e.AppInfo,exports.CachedChannelInfo=e.CachedChannelInfo,Object.defineProperty(exports,"CachedDataClearOrder",{enumerable:!0,get:function(){return e.CachedDataClearOrder}}),Object.defineProperty(exports,"ChannelType",{enumerable:!0,get:function(){return e.ChannelType}}),Object.defineProperty(exports,"CollectionEventSource",{enumerable:!0,get:function(){return e.CollectionEventSource}}),Object.defineProperty(exports,"ConnectionState",{enumerable:!0,get:function(){return e.ConnectionState}}),Object.defineProperty(exports,"DeviceOsPlatform",{enumerable:!0,get:function(){return e.DeviceOsPlatform}}),Object.defineProperty(exports,"LastMessageThreadingPolicy",{enumerable:!0,get:function(){return e.LastMessageThreadingPolicy}}),exports.LocalCacheConfig=e.LocalCacheConfig,exports.NotificationInfo=e.NotificationInfo,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,Object.defineProperty(exports,"SendbirdErrorCode",{enumerable:!0,get:function(){return e.SendbirdErrorCode}}),Object.defineProperty(exports,"SendbirdPlatform",{enumerable:!0,get:function(){return e.SendbirdPlatform}}),Object.defineProperty(exports,"SendbirdProduct",{enumerable:!0,get:function(){return e.SendbirdProduct}}),exports.UIKitConfigInfo=e.UIKitConfigInfo,Object.defineProperty(exports,"UnreadCountThreadingPolicy",{enumerable:!0,get:function(){return e.UnreadCountThreadingPolicy}}),exports.User=e.User,Object.defineProperty(exports,"UserOnlineState",{enumerable:!0,get:function(){return e.UserOnlineState}}),exports.BannedUserListQuery=n.BannedUserListQuery,exports.BaseChannel=n.BaseChannel,Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return n.LogLevel}}),exports.MemoryStore=n.MemoryStore,exports.MutedUserListQuery=n.MutedUserListQuery,exports.OperatorListQuery=n.OperatorListQuery,exports.Plugin=n.Plugin,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.Participant=o.Participant,exports.ApplicationUserListQuery=v,exports.BlockedUserListQuery=I,exports.ConnectionHandler=l,exports.Emoji=a,exports.EmojiCategory=d,exports.EmojiContainer=u,exports.FriendListQuery=E,exports.SessionHandler=p,exports.UserEventHandler=f,exports.default=De; diff --git a/cjs/lib/__bundle-9d371926.cjs b/cjs/lib/__bundle-165fd6e1.cjs similarity index 63% rename from cjs/lib/__bundle-9d371926.cjs rename to cjs/lib/__bundle-165fd6e1.cjs index 6288736..722b90e 100644 --- a/cjs/lib/__bundle-9d371926.cjs +++ b/cjs/lib/__bundle-165fd6e1.cjs @@ -1 +1 @@ -var e,t=require("./__bundle-ad182031.cjs");class s{constructor(e,t,s){var i,n;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(i=t.real_width)&&void 0!==i?i:t.width,this.realHeight=null!==(n=t.real_height)&&void 0!==n?n:t.height,this._requireAuth=s}static payloadify(e){return e instanceof s?t.deundefined(t.undefineNullProps({url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight})):t.deundefined(t.undefineNullProps({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class i extends t.APIRequestCommand{constructor(e){if(super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_UPLOAD}`,this.params=t.deundefined({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(let t=0;tnew s(e,t,!1))))&&void 0!==a?a:[],this.requireAuth=null!==(r=t.require_auth)&&void 0!==r&&r}}class a extends t.InstancedObject{constructor(e,s){var i,n,a,r,o;super(e),this.replyCount=0,this.memberCount=0,this.lastRepliedAt=0,this.updatedAt=0,this.replyCount=null!==(i=s.reply_count)&&void 0!==i?i:0,this.memberCount=null!==(n=s.member_count)&&void 0!==n?n:0,this.mostRepliedUsers=s.most_replies&&t.isArrayOf("object",s.most_replies)?s.most_replies.map((e=>new t.User(this._iid,e))):[],this.unreadReplyCount=null!==(a=s.unread_message_count)&&void 0!==a?a:0,this.isPushNotificationEnabled="number"==typeof s.push_enabled?s.push_enabled>0:void 0,this.lastRepliedAt=null!==(r=s.last_replied_at)&&void 0!==r?r:0,this.updatedAt=null!==(o=s.updated_at)&&void 0!==o?o:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((e=>t.User.payloadify(e))):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}get _isUpdateRequired(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}_updateFrom(e){var t,s;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(s=e.isPushNotificationEnabled)&&void 0!==s?s:this.isPushNotificationEnabled}}exports.ReactionEventOperation=void 0,(e=exports.ReactionEventOperation||(exports.ReactionEventOperation={})).ADD="add",e.DELETE="delete";class r{constructor(e){this.messageId=0,this.operation=null,this.updatedAt=0;const s=t.isTypeOf("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,n=e.operation?e.operation.toLowerCase():null,a=e.reaction,r=e.updated_at;s&&t.isTypeOf("string",i)&&t.isTypeOf("string",n)&&t.isEnumOf(exports.ReactionEventOperation,n)&&t.isTypeOf("string",a)&&a&&t.isTypeOf("number",r)&&(this.messageId=s,this.userId=i,this.key=a,this.operation=n,this.updatedAt=r)}}class o{constructor(e){var s;const i=e.key,n=null!==(s=[...e.user_ids])&&void 0!==s?s:[],a=e.updated_at;t.isTypeOf("string",i)&&i&&t.isArrayOf("string",n)&&n.length>0&&t.isTypeOf("number",a)&&(this.key=i,this.userIds=n,this.updatedAt=a);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 t.deundefined(t.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 t=this.userIds.indexOf(e.userId);switch(e.operation){case exports.ReactionEventOperation.ADD:t<0&&this.userIds.push(e.userId);break;case exports.ReactionEventOperation.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}}}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 s,i;return t.deundefined(t.undefineNullProps({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(s=e.width)&&void 0!==s?s: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 t.deundefined(t.undefineNullProps({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?l.payloadify(e.defaultImage):null}))}}class u{constructor(e){var t,s;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(s=e.volume)&&void 0!==s?s:1}serialize(){return{name:this.name,volume:this.volume}}static payloadify(e){return t.deundefined(t.undefineNullProps({name:e.name,volume:e.volume}))}}var c;exports.FeedbackRating=void 0,(c=exports.FeedbackRating||(exports.FeedbackRating={})).GOOD="good",c.BAD="bad";class h{constructor(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}static _getStatus(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}static _isSubmitted(e){return"SUBMITTED"===h._getStatus(e)}static _getPayloadByStatus(e){return"NO_FEEDBACK"===e?{}:null}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,rating:e.rating,comment:e.comment}))}}class p extends t.User{constructor(e,s){var i;super(e,s),this.isBlockedByMe=!1,this.role=t.isEnumOf(t.Role,s.role)?s.role:t.Role.NONE,this.isBlockedByMe=null!==(i=s.is_blocked_by_me)&&void 0!==i&&i}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}class m{constructor(e){this.key=e.key,this.value=t.isArrayOf("string",e.value)?[...e.value]:[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:e.key,value:null!==(s=e.value)&&void 0!==s?s:[]}))}}const _=e=>{switch(e){case t.MessageType.BASE:return"";case t.MessageType.USER:return"MESG";case t.MessageType.FILE:return"FILE";case t.MessageType.ADMIN:return"ADMM"}};class g extends t.InstancedObject{constructor(e,s){var i,n,a,r,o,l,d,u,c;super(e),this.channelType=t.ChannelType.BASE,this.messageType=t.MessageType.BASE,this.mentionType=null,this.mentionedUsers=null,this.mentionedUserIds=null,this.mentionedMessageTemplate=void 0,this.metaArrays=[],this.extendedMessage={},this.createdAt=0,this.updatedAt=0,this.channelUrl=s.channel_url,this.channelType=t.isEnumOf(t.ChannelType,s.channel_type)?s.channel_type:t.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(this.channelUrl=s.channel.channel_url),s.channel.channel_type&&(this.channelType=s.channel.channel_type)),this.data=null!==(i=s.data)&&void 0!==i?i:"",this.customType=null!==(n=s.custom_type)&&void 0!==n?n:"",this.mentionType=t.isEnumOf(t.MentionType,s.mention_type)?s.mention_type:null,this.mentionedUsers=s.mentioned_users?s.mentioned_users.map((e=>new t.User(this._iid,e))):null,this.mentionedUserIds=null!==(a=s.mentioned_user_ids)&&void 0!==a?a:null,this.mentionedUsers&&!this.mentionedUserIds&&(this.mentionedUserIds=this.mentionedUsers.map((e=>e.userId))),this.mentionedMessageTemplate=s.mentioned_message_template;const h=null!==(r=s.metaarray)&&void 0!==r?r:{},p=null!==(o=s.metaarray_key_order)&&void 0!==o?o:Object.keys(h).sort(((e,t)=>e.localeCompare(t)));this.metaArrays=[];for(let e=0;enew m(e)))),this.extendedMessage=null!==(l=s.extended_message)&&void 0!==l?l:{},this.extendedMessagePayload=s.extended_message_payload,this.createdAt=null!==(u=null!==(d=s.created_at)&&void 0!==d?d:s.ts)&&void 0!==u?u:0,this.updatedAt=null!==(c=s.updated_at)&&void 0!==c?c:0}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.channelUrl,channel_type:e.channelType,type:_(e.messageType),data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(s=e.mentionedUsers)||void 0===s?void 0:s.map((e=>t.User.payloadify(e))),mentioned_message_template:e.mentionedMessageTemplate,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>m.payloadify(e))),extended_message:e.extendedMessage,extended_message_payload:e.extendedMessagePayload,created_at:e.createdAt,updated_at:e.updatedAt})))}isIdentical(e){return!0}isEqual(e){return t.deepEqual(this,e)}isUserMessage(){return this.messageType===t.MessageType.USER}isFileMessage(){return this.messageType===t.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isMultipleFilesMessage(){return this.messageType===t.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isAdminMessage(){return this.messageType===t.MessageType.ADMIN}serialize(){return t.serialize(this)}getMetaArraysByKeys(e){return this.metaArrays.filter((t=>e.includes(t.key)))}}class y extends t.InstancedObject{constructor(e,s){var i,n;super(e),this.channelUrl=null!==(i=s.channel_url)&&void 0!==i?i:"",this.channelType=null!==(n=s.channel_type)&&void 0!==n?n:t.ChannelType.GROUP,this.reader=new t.User(this._iid,s.user),this.readAt=s.ts}}class f extends t.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class v extends t.APIRequestCommand{constructor(e){super();const{channelUrl:s,channelType:i,userId:n,notificationIds:a}=e;this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/messages/mark_as_read`,this.params=t.deundefined(t.undefineNullProps({user_id:n,message_ids:a}))}}class I extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new y(e,s)}}class E extends t.APIResponseCommand{constructor(e,t){super(e,t),this.readAt=t.ts,this.unreadMessageCount=t.unread_message_count}}class T extends t.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"READ",ackRequired:!0,payload:{channel_url:e,parent_message_id:t}})}}class b extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,pushEnabled:n}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/thread_push`,this.params={push_enabled:n}}}class M extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,rating:n,comment:a}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks`,this.params={rating:n,comment:a}}}class S extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class A extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n,rating:a,comment:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`,this.params={rating:a,comment:r}}}class O extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class C extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`}}class w extends t.InstancedObject{constructor(e,t){var i,n,a,r,o;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!==(n=t.file_name)&&void 0!==n?n:null,this.mimeType=null!==(a=t.file_type)&&void 0!==a?a:null,this.fileSize=null!==(r=t.file_size)&&void 0!==r?r:0,this._requireAuth=null!==(o=t.require_auth)&&void 0!==o&&o,this.thumbnails=t.thumbnails?t.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this._requireAuth)})):[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>{var t;return{url:(null!==(t=e.plainUrl)&&void 0!==t?t:"").split("auth=")[0],width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class N{constructor({channelUrl:e,channelType:t,parentMessage:s}){this.channelUrl=e,this.channelType=t,this.parentMessage=s}}var P,U,R,x;!function(e){e.NUMBER="number",e.ENUM="enum",e.TEXT="text",e.REGEX="regex",e.DECIMAL_PLACE="decimal_place"}(P||(P={})),exports.MessageFormItemLayout=void 0,(U=exports.MessageFormItemLayout||(exports.MessageFormItemLayout={})).TEXT="text",U.TEXTAREA="textarea",U.NUMBER="number",U.PHONE="phone",U.EMAIL="email",U.CHIP="chip";class k{constructor(e,t){const{id:s,name:i,items:n,version:a,is_submitted:r}=t;this.messageId=e,this.id=s,this.name=i,this.items=n.map((e=>new L(e))).sort(((e,t)=>e.sortOrder-t.sortOrder)),this.version=null!=a?a:1,this._isSubmitted=r}get isSubmitted(){var e;return null!==(e=this._isSubmitted)&&void 0!==e?e:this.items.some((e=>Array.isArray(e.submittedValues)))}get isSubmittable(){return this.items.every((e=>e.required?!!(Array.isArray(e.draftValues)&&e.draftValues.length>0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,items:e.items.map((e=>L.payloadify(e))),version:e.version,is_submitted:e._isSubmitted}))}static isMessageFormPayload(e){return Boolean(null==e?void 0:e.message_form)}}class L{constructor(e){const{id:s,name:i,required:n,sort_order:a,placeholder:r,style:o,item_type:l,validators:d,value:u,values:c}=e;this.id=s,this.name=i,this.required=n,this.sortOrder=a,this.placeholder=r,0===Object.keys(o).length?this.style={layout:l}:this.style=t.deundefined({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),c?this.submittedValues=c:u&&(this.submittedValues=[u]),this._validators=d}isValid(e){return e.every((e=>{const t=function(e,t){return t.every((t=>{switch(t.key){case P.NUMBER:{const s=Number(e);return!(isNaN(s)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&st.max)}case P.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case P.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case P.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case P.DECIMAL_PLACE:{if(0===e.length)return!1;const s=Number(e);return!(isNaN(s)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){const s=e.toString(),i=s.indexOf(".");return-1===i||s.slice(i+1).length<=t}(s,t.max_decimal_place))}default:return!0}}))}(e,this._validators);return t}))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:t.deundefined({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}class D extends t.APIRequestCommand{constructor(e){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_FORMS}/${e.formId}/submit`,this.params=t.deundefined({message_id:e.messageId,items:e.items})}}exports.ScheduledStatus=void 0,(R=exports.ScheduledStatus||(exports.ScheduledStatus={})).PENDING="pending",R.SENT="sent",R.FAILED="failed",R.CANCELED="canceled",exports.InternalScheduledStatus=void 0,(x=exports.InternalScheduledStatus||(exports.InternalScheduledStatus={})).PENDING="pending",x.IN_QUEUE="in_queue",x.SENT="sent",x.FAILED="failed",x.CANCELED="canceled",x.REMOVED="removed";class q extends g{constructor(e,t){var s,i,n,r,l,c,p,m;super(e,t),this.parentMessage=null,this.silent=!1,this.isOperatorMessage=!1,this.threadInfo=null,this.reactions=[],this.appleCriticalAlertOptions=null,this.scheduledInfo=null,this.suggestedReplies=null,this.myFeedback=null,this.myFeedbackStatus="NOT_APPLICABLE",this.messageForm=null,this._isContinuousMessages=!1,this._scheduledStatus=null,this.messageId=null!==(i=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==i?i:0,this.parentMessageId=null!==(n="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==n?n:0,this.threadInfo=t.thread_info?new a(this._iid,t.thread_info):null,this.reactions=t.reactions?t.reactions.map((e=>new o(e))):[],this.ogMetaData=t.og_tag?new d(t.og_tag):null,this.silent=null!==(r=t.silent)&&void 0!==r&&r,this.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,this.appleCriticalAlertOptions=t.apple_critical_alert_options?new u(t.apple_critical_alert_options):null,"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._isContinuousMessages=null!==(c=t.is_continuous_messages)&&void 0!==c&&c,this.myFeedback=h._isSubmitted(t.feedback)?new h(t.feedback):null,this.myFeedbackStatus=h._getStatus(t.feedback),this.suggestedReplies=null!==(m=null===(p=t.extended_message_payload)||void 0===p?void 0:p.suggested_replies)&&void 0!==m?m:null,this.messageForm=k.isMessageFormPayload(t.extended_message_payload)?new k(this.messageId,t.extended_message_payload.message_form):null}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?a.payloadify(e.threadInfo):null,reactions:e.reactions.map((e=>o.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?u.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledMessageId,scheduled_at:null===(i=e.scheduledInfo)||void 0===i?void 0:i.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?h.payloadify(e.myFeedback):h._getPayloadByStatus(e.myFeedbackStatus)})))}static _getParentMessageInfoPayload(e){return t.deundefined(t.undefineNullProps({type:_(e.messageType),ts:e.createdAt,user:e.sender?p.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null}))}isIdentical(e){return this.messageId===e.messageId}applyThreadInfoUpdateEvent(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}applyReactionEvent(e){if(this.messageId===e.messageId){let t=!1;for(let s=0;s=t)return this.parentMessage=e,!0}return!1}_triggerThreadInfoUpdatedEvent(){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e}=t.Vault.of(this._iid);e.dispatch(new N({channelType:t.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))}))}markThreadAsRead(){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=t.Vault.of(this._iid),s=new T({channelUrl:this.channelUrl,messageId:this.messageId});yield e.send(s),this.threadInfo&&0!==this.threadInfo.unreadReplyCount&&(this.threadInfo.unreadReplyCount=0,yield this._triggerThreadInfoUpdatedEvent())}))}setPushNotificationEnabled(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),i=new b({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e});yield s.send(i),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e)}))}submitMessageForm(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid);let i=null,n=null;const a=this.messageForm;if(!e&&a){if(!a.isSubmittable)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(a.isSubmitted)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});i=a.id,n=a.items.reduce(((e,t)=>(e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e)),[])}else e&&(i=e.formId,n=Object.entries(e.answers).reduce(((e,[s,i])=>{const n=Number(s);if(Number.isNaN(n))throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:n,value:i}),e}),[]));if(!i||!n)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});const r=new D({messageId:this.messageId,formId:i,items:n});yield s.send(r)}))}submitFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new M({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(S);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}))}))}updateFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new A({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(O);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}))}))}deleteFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new C({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e});yield s.send(n),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}))}))}}class F extends q{constructor(e,s){var i,n,a,r;if(super(e,s),this.reqId="",this.replyToChannel=!1,this.errorCode=0,this.sender=s.user?new p(this._iid,s.user):s.sender_id,this.reqId=null!==(n=null!==(i=s.req_id)&&void 0!==i?i:s.request_id)&&void 0!==n?n:"",this.replyToChannel=null!==(a=s.is_reply_to_channel)&&void 0!==a&&a,s.request_state&&t.isEnumOf(t.SendingStatus,s.request_state)&&(this.sendingStatus=s.request_state),!this.sendingStatus)if(this.messageId>0)this.sendingStatus=t.SendingStatus.SUCCEEDED;else if(this.scheduledInfo)switch(s.scheduled_status&&(this._scheduledStatus=s.scheduled_status),s.scheduled_status){case exports.InternalScheduledStatus.SENT:case exports.InternalScheduledStatus.IN_QUEUE:this.sendingStatus=t.SendingStatus.SUCCEEDED;break;case exports.InternalScheduledStatus.PENDING:this.sendingStatus=t.SendingStatus.SCHEDULED;break;case exports.InternalScheduledStatus.FAILED:case exports.InternalScheduledStatus.REMOVED:this.sendingStatus=t.SendingStatus.FAILED;break;case exports.InternalScheduledStatus.CANCELED:this.sendingStatus=t.SendingStatus.CANCELED}else this.sendingStatus=t.SendingStatus.PENDING;this.errorCode=null!==(r=s.error_code)&&void 0!==r?r:0,this._messageToken=s.mesg_token}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{user:p.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}get isResendable(){return(this.sendingStatus===t.SendingStatus.FAILED||this.sendingStatus===t.SendingStatus.CANCELED)&&t.isResendableError(this.errorCode)}isIdentical(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}const B={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},j=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo);class V extends q{constructor(e,s){var i,n,a,r;if(super(e,s),this.translations={},this.message=null!==(i=s.message)&&void 0!==i?i:"",this.messageType=t.MessageType.ADMIN,this.translations=null!==(n=s.translations)&&void 0!==n?n:{},s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(a=i.file)||void 0===a?void 0:a.url,require_auth:null===(r=i.file)||void 0===r?void 0:r.require_auth}))))}}static payloadify(e){return t.deundefined(t.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,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class z{constructor(e){var s,i;this.detail={},this.type=null!==(s=e.type)&&void 0!==s?s:"",this.vendor=null!==(i=e.vendor)&&void 0!==i?i:"",e.detail&&t.isTypeOf("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}static payloadify(e){return t.deundefined(t.undefineNullProps({type:e.type,vendor:e.vendor,detail:e.detail}))}}class ${constructor(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}static payloadify(e){return t.deundefined({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}class Q extends F{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.message="",this.messageParams=null,this.translations={},this.translationTargetLanguages=[],this.messageSurvivalSeconds=-1,this.plugins=[],this._poll=null,this.message=s.message,this.messageType=t.MessageType.USER,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},this.translationTargetLanguages=null!==(n=s.target_langs)&&void 0!==n?n:[],0===Object.keys(this.translations).length&&this.translationTargetLanguages.length>0)for(const e of this.translationTargetLanguages)this.translations[e]="";if(this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,this.plugins=s.plugins?s.plugins.map((e=>new z(e))):[],this._poll=s.poll?new t.Poll(this._iid,s.poll):null,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(o=i.file)||void 0===o?void 0:o.require_auth}))))}s.review_info&&(this.messageReviewInfo=new $(s.review_info))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((e=>z.payloadify(e))),poll:e._poll?t.Poll.payloadify(e._poll):null,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null,review_info:e.messageReviewInfo?$.payloadify(e.messageReviewInfo):void 0})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.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 G extends F{constructor(e,s){var i,n,a,r,o,l,d,u;if(super(e,s),this.messageParams=null,this.fileInfoList=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE,this.data=null!==(a=null!==(n=null===(i=s.file)||void 0===i?void 0:i.data)&&void 0!==n?n:s.custom)&&void 0!==a?a:"",this.fileInfoList=null!==(o=null===(r=s.files)||void 0===r?void 0:r.map((t=>new w(e,t))))&&void 0!==o?o:[],this.messageSurvivalSeconds=null!==(l=s.message_survival_seconds)&&void 0!==l?l:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(d=i.file)||void 0===d?void 0:d.url,require_auth:null===(u=i.file)||void 0===u?void 0:u.require_auth}))))}}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}static payloadify(e){var s,i,n,a,r,o;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{file:{name:null!==(i=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.fileName)&&void 0!==i?i:"",size:null!==(a=null===(n=e.fileInfoList[0])||void 0===n?void 0:n.fileSize)&&void 0!==a?a:0,type:null!==(o=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}static _isMultipleFilesMessagePayload(e){const t=e.files;return Array.isArray(t)&&t.length>=2}static _isMultipleFilesMessageSerializedData(e){const t=e.fileInfoList;return Array.isArray(t)}}var K;exports.NotificationMessageStatus=void 0,(K=exports.NotificationMessageStatus||(exports.NotificationMessageStatus={})).SENT="SENT",K.READ="READ";class H extends g{constructor(e,s){var i,n;if(super(e,s),this.notificationData=null,this.notificationId=s.notification_message_id,this.messageType=t.MessageType.ADMIN,this.messageStatus=null!==(i=s.message_status)&&void 0!==i?i:exports.NotificationMessageStatus.SENT,this.priority=null!==(n=s.priority)&&void 0!==n?n:t.NotificationPriority.NORMAL,this.notificationEventDeadline=s.notification_event_deadline,0===this.extendedMessage.sub_type)try{const{label:e,tags:t=[],template_key:s,template_variables:i}=JSON.parse(this.extendedMessage.sub_data);this.notificationData={label:e,tags:t,templateKey:s,templateVariables:i}}catch(e){}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}isIdentical(e){return this.notificationId===e.notificationId}}const W=(e,t)=>{if(t.notification_message_id)return new H(e,t);switch(t.type){case"MESG":return new Q(e,t);case"FILE":return G._isMultipleFilesMessagePayload(t)?new G(e,t):new Y(e,t);case"ADMM":case"BRDM":return new V(e,t);default:return null}};class Y extends F{constructor(e,i){var n,a,r,o,l,d,u,c,h,p,m,_,g,y;super(e,i),this.messageParams=null,this.plainUrl="",this.requireAuth=!1,this.thumbnails=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE;const f=i.file;if(this.plainUrl=(null!==(a=null!==(n=null==f?void 0:f.url)&&void 0!==n?n:i.url)&&void 0!==a?a:"").split("?auth=")[0],this.name=null!==(o=null!==(r=null==f?void 0:f.name)&&void 0!==r?r:i.name)&&void 0!==o?o:"File",this.size=null!==(d=null!==(l=null==f?void 0:f.size)&&void 0!==l?l:i.size)&&void 0!==d?d:0,this.data=null!==(c=null!==(u=null==f?void 0:f.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",this.type=f?null!==(h=f.type)&&void 0!==h?h:"":null!==(p=i.type)&&void 0!==p?p:"",this.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,this.thumbnails=i.thumbnails?i.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this.requireAuth)})):[],this.messageSurvivalSeconds=null!==(_=i.message_survival_seconds)&&void 0!==_?_:-1,i.parent_message_info){const s=i.parent_message_info;this.parentMessage=W(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},s),{created_at:s.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:s.file,url:null===(g=s.file)||void 0===g?void 0:g.url,require_auth:null===(y=s.file)||void 0===y?void 0:y.require_auth}))))}}static payloadify(e){var s;return t.deundefined(t.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===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.plainUrl,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}=t.Vault.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class J extends t.InstancedObject{static getPlainUrl(e){return e instanceof J?e._plainUrl:e.fileUrl}constructor(e,{file:t,fileUrl:s,fileName:i,fileSize:n,mimeType:a,thumbnailSizes:r,_uploadedMetaData:o,_thumbnails:l}){super(e),this._plainUrl=s,this.file=t,this.fileName=i,this.fileSize=n,this.mimeType=a,this.thumbnailSizes=r,this._uploadedMetaData=o,this._thumbnails=l}get fileUrl(){var e;const{sessionManager:s}=t.Vault.of(this._iid);return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&s.ekey?`${this._plainUrl}?auth=${s.ekey}`:this._plainUrl}set fileUrl(e){this._plainUrl=e}toJSON(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}class X extends t.WebSocketRequestCommand{constructor(e){var i,n,a,r;let o=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((e=>e.userId)))),super({code:"FILE",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,files:e.files?se(e.files):null,url:e.url,name:null!==(i=e.fileName)&&void 0!==i?i:"",type:null!==(n=e.mimeType)&&void 0!==n?n:"",size:null!==(a=e.fileSize)&&void 0!==a?a:0,custom:e.data,custom_type:e.customType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((e=>s.payloadify(e))),require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:o,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?u.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 Z extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId)))),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e.channelType)}/${encodeURIComponent(e.channelUrl)}/messages`,this.params=t.deundefined(t.undefineNullProps({message_type:t.MessageType.FILE,user_id:e.userId,files:e.files?se(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===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:e.requireAuth,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((e=>m.payloadify(e))),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}))}}class ee extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"FILE",i),this.message=i.files&&i.files.length>=2?new G(e,i):new Y(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class te extends t.APIResponseCommand{constructor(e,s){var i,n,a,r;super(e,s),this.message=s.files&&s.files.length>=2?new G(e,s):new Y(e,s);const{sdkState:o}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(a=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(n=this.message.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)))&&void 0!==a?a:[],o.userId),this.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r}}function se(e){return e.map((e=>{var i,n;return t.deundefined(t.undefineNullProps({url:J.getPlainUrl(e),file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var ie;!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"}(ie||(ie={}));class ne{constructor(e,{sdkState:s,dispatcher:i,requestQueue:n,onlineDetector:a,cacheContext:r}){this._queueMap=new Map,this._iid=e,this._sdkState=s,this._requestQueue=n,this._cacheContext=r,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof t.ConnectionStateChangeCommand&&(this._connectionState=e.stateType)})),this._onlineDetector=a}get _shouldSendThroughWebSocket(){return this._connectionState===t.ConnectionStateType.CONNECTED||this._connectionState===t.ConnectionStateType.CONNECTING||this._connectionState===t.ConnectionStateType.RECONNECTING}_sendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._createSendFileMessageRequestParams(e,s);if(this._shouldSendThroughWebSocket){const e=new X(t),s=yield this._requestQueue.send(e),{message:i}=s.as(ee);return i}{const e=new Z(Object.assign(Object.assign({},t),{userId:this._sdkState.userId})),s=yield this._requestQueue.send(e),{message:i}=s.as(te);return i}}))}_createSendFileMessageRequestParams(e,t){const s=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){const e=t.params;s.files=e.fileInfoList}else{const e=t.params;s.url=e.fileUrl,s.requireAuth=e.requireAuth}return s}_resolveMessageQueue(e){var s;return t.__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 n=[];let a=!0;for(const r of i.messageQueue)switch(r.state){case ie.PENDING:case ie.UPLOADING:a=!1,n.push(r);break;case ie.UPLOADED:if(a)try{r.state=ie.SENDING;const s=yield this._sendFileMessage(e,r);r.deferred.resolve(s),yield t.sleep(100)}catch(e){r.deferred.reject(e)}else n.push(r);break;case ie.FAILED:{const e=null!==(s=r.error)&&void 0!==s?s:t.SendbirdError.unknown;r.deferred.reject(e.code===t.SendbirdErrorCode.REQUEST_CANCELED?t.SendbirdError.fileUploadCanceled:e);break}}const r=i.isResolveRequestPending;i.messageQueue=n,i.isResolving=!1,i.isResolveRequestPending=!1,r&&(yield this._resolveMessageQueue(e))}}))}_uploadNextPendingItem(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i){const n=i.messageQueue.find((e=>e.state===ie.PENDING));if(n){if(n.multipleFileUploadInfo){const{uploadIndex:a,uploadCount:r,requestHandler:o}=n.multipleFileUploadInfo,l=n.params,d=l.fileInfoList[a];t.isFile(d.file)&&!(null===(s=d._uploadedMetaData)||void 0===s?void 0:s.isUploaded)?yield this._tryUploadNextItemAndUpdateItemState(e,i,n):n.state=ae.requestId===t.requestId));s>=0&&e.uploadQueue.splice(s,1)}_uploadNextFileForSingleFileItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const t=new i({file:a.file,channelUrl:e.url,thumbnailSizes:a.thumbnailSizes,requestId:s.requestId}),d=yield this._requestQueue.send(t),{url:u,fileSize:c=a.fileSize,thumbnails:h=[],requireAuth:p=!1}=d.as(n);a.fileName=null!==(r=a.fileName)&&void 0!==r?r:a.file.name,a.mimeType=null!==(o=a.mimeType)&&void 0!==o?o:a.file.type,a.fileSize=null!==(l=a.fileSize)&&void 0!==l?l:a.file.size,a.fileUrl=u,a.fileSize=c,a.requireAuth=p,a._thumbnails=h}))}_uploadNextFileForMultipleFilesItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const{uploadIndex:t}=s.multipleFileUploadInfo,d=a.fileInfoList[t],u=new i({file:d.file,channelUrl:e.url,thumbnailSizes:d.thumbnailSizes,requestId:s.requestId}),c=yield this._requestQueue.send(u),{url:h,fileSize:p=d.fileSize,thumbnails:m,requireAuth:_=!1}=c.as(n);d.fileName=null!==(r=d.fileName)&&void 0!==r?r:d.file.name,d.mimeType=null!==(o=d.mimeType)&&void 0!==o?o:d.file.type,d.fileSize=null!==(l=d.fileSize)&&void 0!==l?l:d.file.size,d.file=void 0,d.fileUrl=h,d.fileSize=p,d._thumbnails=m,d._uploadedMetaData=Object.assign(Object.assign({},d._uploadedMetaData),{requireAuth:_,isUploaded:!0}),d instanceof J||(a.fileInfoList[t]=new J(this._iid,d))}))}request(e,s,i,n={}){return t.__awaiter(this,void 0,void 0,(function*(){if(!this._queueMap.has(e.url)){const t={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1};this._queueMap.set(e.url,t)}const a=this._queueMap.get(e.url),r=new t.Deferred,o={requestId:s,params:i,state:ie.PENDING,deferred:r};if(function(e){return"fileInfoList"in e}(i)){const e=i,t=Object.assign({uploadIndex:0,uploadCount:e.fileInfoList.length},n);o.multipleFileUploadInfo=t}return a.messageQueue.push(o),this._uploadNextPendingItem(e),r.promise}))}cancel(e,s){const i=this._queueMap.get(e.url);if(i){const n=s?[i.messageQueue.find((e=>e.requestId===s))]:[...i.messageQueue];for(const s of n)if(s)switch(s.state){case ie.PENDING:if(s.state=ie.FAILED,s.error=t.SendbirdError.requestCanceled,s.multipleFileUploadInfo&&!s.multipleFileUploadInfo.isCopy){const{uploadIndex:e,requestHandler:i}=s.multipleFileUploadInfo,n=s.params.fileInfoList[e];null==i||i._triggerOnFileUploaded(s.requestId,e,n,t.SendbirdError.fileUploadCanceled)}this._resolveMessageQueue(e);break;case ie.UPLOADING:this._requestQueue.cancel(s.requestId),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s.requestId}))}}else s&&(this._requestQueue.cancel(s),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s})))}}const ae={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:t.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},re=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo)&&t.isTypeOf("boolean",e.showSubchannelMessagesOnly),oe={replyType:t.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},le=e=>t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo);class de extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,includeMetaArray:n,includeReactions:a,includeThreadInfo:r,includeParentMessageInfo:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}`,this.params={is_sdk:!0,with_sorted_meta_array:n,include_reactions:a,include_thread_info:r,include_parent_message_info:o,include_poll_details:!0}}}class ue extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}class ce extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,prevResultSize:a,nextResultSize:r,isInclusive:o,reverse:l,messageTypeFilter:d,customTypesFilter:u,senderUserIdsFilter:c,replyType:h,includeMetaArray:p,includeReactions:m,parentMessageId:_,includeThreadInfo:g,includeParentMessageInfo:y,showSubchannelMessagesOnly:f,checkingHasNext:v,checkingContinuousMessages:I}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages`,this.params=t.deundefined(t.undefineNullProps({is_sdk:!0,prev_limit:a,next_limit:r,include:o,reverse:l,message_ts:i,message_id:n,message_type:null!=d?d:null,custom_types:u,sender_ids:c,include_reply_type:h,with_sorted_meta_array:p,include_reactions:m,parent_message_id:_,include_thread_info:g,include_parent_message_info:y,show_subchannel_message_only:f,include_poll_details:!0,checking_has_next:v,checking_continuous_messages:I}))}}class he extends t.APIResponseCommand{constructor(e,t){super(e,t),void 0!==t.is_continuous_messages&&(this.isContinuousMessages=t.is_continuous_messages),void 0!==t.has_next&&(this.hasNext=t.has_next),this.messages=t.messages.map((t=>W(e,t)))}}class pe extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,replyType:a,includeMetaArray:r,includeReactions:o,includeThreadInfo:l,includeParentMessageInfo:d}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/changelogs`,this.params={change_ts:i,token:n,with_sorted_meta_array:r,include_reactions:o,include_thread_info:l,include_reply_type:a,include_parent_message_info:d,include_poll_details:!0}}}class me extends t.APIResponseCommand{constructor(e,t){super(e,t),this.updatedMessages=t.updated.map((t=>W(e,t))),this.deletedMessagesInfo=t.deleted.map((e=>({messageId:e.message_id,deletedAt:e.deleted_at}))),this.hasMore=t.has_more,this.nextToken=t.next}}class _e extends t.APIRequestCommand{constructor({channelUrl:e,scheduledMessageId:s}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/scheduled_messages/${encodeURIComponent(s)}`,this.params={}}}class ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}var ye;exports.RestrictionType=void 0,(ye=exports.RestrictionType||(exports.RestrictionType={})).MUTED="muted",ye.BANNED="banned";class fe{constructor(e){var s,i,n,a;this.restrictionType=null,t.isEnumOf(exports.RestrictionType,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(s=e.description)&&void 0!==s?s:null,this.endAt=null!==(n=null!==(i=e.end_at)&&void 0!==i?i:e.muted_end_at)&&void 0!==n?n:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}static payloadify(e){return t.deundefined(t.undefineNullProps({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}class ve extends t.User{constructor(e,t){super(e,t),this.restrictionInfo=new fe(t)}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),fe.payloadify(e.restrictionInfo))))}}class Ie{constructor(){this._onPending=t.noop,this._onFailed=t.noop,this._onSucceeded=t.noop}_trigger(e){switch(null==e?void 0:e.sendingStatus){case t.SendingStatus.PENDING:0===e.errorCode&&this._onPending(e);break;case t.SendingStatus.SCHEDULED:case t.SendingStatus.SUCCEEDED:this._onSucceeded(e)}}_triggerFailed(e,s){switch(null==s?void 0:s.sendingStatus){case t.SendingStatus.FAILED:case t.SendingStatus.CANCELED:this._onFailed(e,s.scheduledInfo?null:s)}}onPending(e){return this._onPending=e,this}onFailed(e){return this._onFailed=e,this}onSucceeded(e){return this._onSucceeded=e,this}}const Ee={data:void 0,customType:void 0,mentionType:t.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},Te=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isTypeOf("number",e.parentMessageId,!0)&&t.isTypeOf("boolean",e.isReplyToChannel)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0)&&t.isTypeOf("boolean",e.isPinnedMessage,!0),be=e=>({isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}),Me=Object.assign(Object.assign({},Ee),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function Se(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}const Ae=e=>{var s;return t.deundefined(t.undefineNullProps({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(s=e.poll)||void 0===s?void 0:s.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations),extendedMessagePayload:e.extendedMessagePayload}))},Oe=e=>Te(e)&&t.isTypeOf("string",e.message)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0)&&t.isTypeOf("object",e.extendedMessagePayload,!0);var Ce;!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Ce||(Ce={}));const we=e=>"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob,Ne=e=>e===Ce.BLOB||e===Ce.FILE,Pe=e=>({file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}),Ue=Object.assign(Object.assign({},Ee),{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});function Re(e){var s,i,n,a;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=e.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails}))}const xe=(e,s)=>{var i;return e.messageParams?(!e.url&&t.isFile(s)&&(e.messageParams.file=s),e.messageParams):t.deundefined(t.undefineNullProps({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:s,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height})))}))},ke=e=>Te(e)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),Le={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},De=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0),qe=Object.assign(Object.assign({},Le),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Fe=e=>De(e)&&t.isTypeOf("string",e.message,!0)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0),Be=Object.assign({},Le);class je extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,token:i,limit:n}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(e)}/operators`,this.params={token:i,limit:n}}}class Ve extends t.APIResponseCommand{constructor(e,s){super(e,s),this.operators=s.operators.map((s=>new t.User(e,s))),this.token=s.next}}class ze extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;{const e=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new je(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),i=yield e.send(s),{operators:n,token:a}=i.as(Ve);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return e}}throw t.SendbirdError.invalidParameters}))}}class $e extends t.ChannelDataListQuery{constructor(e,s,i,n){var a,r,o,l,d,u,c,h,p,m;super(e,s,i,n),this.reverse=!1,this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.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!==(a=n.reverse)&&void 0!==a&&a,this.messageTypeFilter=null!==(r=n.messageTypeFilter)&&void 0!==r?r:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,this.senderUserIdsFilter=null!==(l=n.senderUserIdsFilter)&&void 0!==l?l:null,this.replyType=null!==(d=n.replyType)&&void 0!==d?d:t.ReplyType.NONE,this.includeMetaArray=null!==(u=n.includeMetaArray)&&void 0!==u&&u,this.includeReactions=null!==(c=n.includeReactions)&&void 0!==c&&c,this.includeParentMessageInfo=null!==(h=n.includeParentMessageInfo)&&void 0!==h&&h,this.includeThreadInfo=null!==(p=n.includeThreadInfo)&&void 0!==p&&p,this.showSubchannelMessagesOnly=null!==(m=n.showSubchannelMessagesOnly)&&void 0!==m&&m}_validate(){return super._validate()&&t.isTypeOf("boolean",this.reverse)&&t.isEnumOf(t.MessageTypeFilter,this.messageTypeFilter)&&t.isEnumOf(t.ReplyType,this.replyType)&&t.isArrayOf("string",this.customTypesFilter,!0)&&t.isArrayOf("string",this.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",this.includeMetaArray)&&t.isTypeOf("boolean",this.includeReactions)&&t.isTypeOf("boolean",this.includeParentMessageInfo)&&t.isTypeOf("boolean",this.includeThreadInfo)&&t.isTypeOf("boolean",this.showSubchannelMessagesOnly)}load(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=$i.of(this._iid),s=yield e.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t.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,...s.map((e=>e.createdAt))),this._hasNext=s.length>=this.limit,this._isLoading=!1,s}return[]}throw t.SendbirdError.invalidParameters}))}}class Qe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={limit:n,token:a}}}class Ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.mutedUsers=[];const{next:s,muted_list:i}=t;this.token=s,i&&i.length>0&&(this.mutedUsers=i.map((t=>new ve(e,t))))}}class Ke extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Qe(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{mutedUsers:n,token:a}=i.as(Ge);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class He extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({limit:n,token:a})}}class We extends t.APIResponseCommand{constructor(e,t){super(e,t),this.bannedUsers=[];const{next:s,banned_list:i}=t;this.token=s,i&&i.length>0&&(this.bannedUsers=i.map((t=>new ve(e,t.user))))}}class Ye extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new He(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{bannedUsers:n,token:a}=i.as(We);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}var Je;exports.ReportCategory=void 0,(Je=exports.ReportCategory||(exports.ReportCategory={})).SPAM="spam",Je.HARASSING="harassing",Je.SUSPICIOUS="suspicious",Je.INAPPROPRIATE="inappropriate";class Xe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class Ze extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${n}`}}class tt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.isMuted=!1,this.startAt=0,this.endAt=0;const{is_muted:s,start_at:i,end_at:n,remaining_duration:a,description:r}=t;this.isMuted=s,this.startAt=i,this.endAt=n,this.remainingDuration=a,this.description=r}}class st extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={keys:n,include_ts:!0}}}class it extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0}}}class at extends t.APIResponseCommand{constructor(e,t){var s,i;super(e,t),this.metaData=null!==(s=t.metadata)&&void 0!==s?s:{},this.ts=null!==(i=t.ts)&&void 0!==i?i:null}}class rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n,upsert:a}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0,upsert:null!=a&&a}}}class ot extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class lt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class dt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata/${n}`,this.params={include_ts:!0}}}class ut extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={include_ts:!0}}}class ht extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class pt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={keys:n}}}class mt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class _t extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n}}}class gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class yt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n,upsert:a=!1,mode:r="set"}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n,upsert:a,mode:r}}}class ft extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class vt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class It extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter/${n}`,this.params={}}}class Et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={}}}class Tt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={user_id:n,seconds:a,description:r}}}class bt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Mt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${encodeURIComponent(n)}`}}class St extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class At extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({user_id:n,seconds:a,description:r})}}class Ot extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data),s.data.member_count&&(this.memberCount=s.data.member_count),s.data.joined_member_count&&(this.joinedMemberCount=s.data.joined_member_count)}}class Ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban/${encodeURIComponent(n)}`}}class wt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,freezing:n}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/freeze`,this.params={freeze:n}}}class Pt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.freeze=s.data.freeze}}class Ut extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}`,this.params={report_category:n,reporting_user_id:a,report_description:r}}}class Rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,description:o}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_REPORT}/users/${r}`,this.params={channel_url:s,channel_type:i===t.ChannelType.OPEN?"open_channels":"group_channels",report_category:n,reporting_user_id:a,report_description:o}}}class xt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,messageId:o,description:l,messageToken:d}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}/messages/${o}`,this.params=t.deundefined({report_category:n,reporting_user_id:a,report_description:l,offending_user_id:r,mesg_token:d})}}class kt extends t.WebSocketRequestCommand{constructor(e){let s=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MESG",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage,extended_message_payload:e.extendedMessagePayload}))})}}class Lt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"MESG",i),this.message=new Q(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class Dt extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,poll_id:e.pollId}))})}}class qt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"MEDI",i),this.message=new Q(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class Ft extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"FEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,apple_critical_alert_options:e.appleCriticalAlertOptions}))})}}class Bt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"FEDI",i),this.message=new Y(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class jt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class Vt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(t)}}class zt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class $t extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(Object.assign({},t))}}class Qt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,translationTargetLanguages:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}/translation`,this.params={target_langs:n}}}class Gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Kt extends t.APIRequestCommand{constructor(e){var s;super();let i=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:a}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(n)}/${encodeURIComponent(a)}/scheduled_messages`,this.params=t.deundefined(t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class Ht extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Wt extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId))));const{channelType:r,channelUrl:o}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(r)}/${encodeURIComponent(o)}/scheduled_messages`,this.params=t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.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((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})}}class Yt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Y(e,t)}}class Jt extends t.APIRequestCommand{constructor({pollId:e,title:s,data:i,allowUserSuggestion:n,allowMultipleVotes:a,closeAt:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`,this.params={title:s,data:i,allow_user_suggestion:n,allow_multiple_votes:a,close_at:r}}}class Xt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Zt extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`}}class es extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/close`}}class ts extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ss extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,pollId:i,optionText:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(i)}/options`,this.params={channel_url:e,channel_type:s,text:n}}}class is extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ns extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s,optionText:i}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`,this.params={text:i}}}class as extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class rs extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`}}class os extends t.WebSocketRequestCommand{constructor({reqId:e,channelType:s,channelUrl:i,pollId:n,pollOptionIds:a}){super({code:"VOTE",ackRequired:!0,payload:t.deundefined({req_id:e,channel_type:s===t.ChannelType.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:n,option_ids:a})})}}class ls extends t.WebSocketEventCommand{constructor(e,s,i){super(e,"VOTE",i),this.event=new t.PollVoteEvent(i),this.channelUrl=i.channel_url,this.channelType=i.channel_type}}const ds="Message",us="NotificationMessage";const cs=Object.assign(Object.assign({},Ee),{fileInfoList:[]}),hs=e=>(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>e.maxWidth>0&&e.maxHeight>0)));class ps extends Ie{constructor(){super(...arguments),this._onFileUploaded=t.noop}_triggerOnFileUploaded(e,t,s,i){this._onFileUploaded(e,t,s,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}}class ms extends t.InstancedObject{constructor(e,t){super(e),this.message=null,this.message=W(e,t.message)}}class _s extends t.APIRequestCommand{constructor(e){const{channelType:s,channelUrl:i,limit:n,token:a,includeReactions:r,includeMetaArray:o,includeParentMessageInfo:l,includeThreadInfo:d,includePollDetails:u}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(i)}/pinned_messages`,this.params=t.deundefined({limit:n,token:a,include_reactions:r,with_sorted_meta_array:o,include_thread_info:d,include_parent_message_info:l,include_poll_details:u})}}class gs extends t.APIResponseCommand{constructor(e,t){super(e,t);const{pinned_messages:s,has_more:i,next:n}=t;this.pinnedMessages=s.map((t=>new ms(e,t))),this.hasMore=i,this.token=n}}class ys extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i),this.includeMetaArray=i.includeMetaArray,this.includeReactions=i.includeReactions,this.includeParentMessageInfo=i.includeParentMessageInfo,this.includeThreadInfo=i.includeThreadInfo,this.includePollDetails=i.includePollDetails}_validate(){return super._validate()&&t.isTypeOf("boolean",this.includeMetaArray,!0)&&t.isTypeOf("boolean",this.includeReactions,!0)&&t.isTypeOf("boolean",this.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",this.includeThreadInfo,!0)&&t.isTypeOf("boolean",this.includePollDetails,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new _s(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{pinnedMessages:n,hasMore:a,token:r}=i.as(gs);return this._token=r,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class fs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}class vs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}var Is;exports.SendMessageRequestType=void 0,(Is=exports.SendMessageRequestType||(exports.SendMessageRequestType={})).SEND="send",Is.RESEND="resend",Is.COPY="copy";class Es extends t.InstancedObject{get url(){return this._url}get name(){return this._name}set name(e){this._name=e}get createdAt(){return this._createdAt}toJSON(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}constructor(e,s){var i,n,a,r,o,l,d;super(e),this._name="",this._createdAt=0,this.pinnedMessageIds=[],this.channelType=t.ChannelType.BASE,this.coverUrl="",this.customType="",this.data="",this.isFrozen=!1,this.isEphemeral=!1,this.creator=null,this._messageCollectionLastAccessedAt=0,this._url=s.channel_url,this._name=null!==(i=s.name)&&void 0!==i?i:"",this._createdAt=1e3*s.created_at,this.coverUrl=null!==(n=s.cover_url)&&void 0!==n?n:"",this.customType=null!==(a=s.custom_type)&&void 0!==a?a:"",this.data=null!==(r=s.data)&&void 0!==r?r:"",this.isFrozen=null!==(o=s.freeze)&&void 0!==o&&o,this.isEphemeral=null!==(l=s.is_ephemeral)&&void 0!==l&&l,this.creator=s.created_by?new t.User(this._iid,s.created_by):null,s.metadata&&Object.keys(s.metadata).length>0&&s.ts?(this._cachedMetaData=new Map,Object.keys(s.metadata).forEach((e=>{this._cachedMetaData.set(e,{value:s.metadata[e],isRemoved:!1,updatedAt:s.ts})}))):"string"==typeof s.metadata&&(this._cachedMetaData=new Map(Object.entries(JSON.parse(s.metadata)))),this.pinnedMessageIds=null!==(d=s.pinned_message_ids)&&void 0!==d?d:[]}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(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?t.User.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}isGroupChannel(){return this.channelType===t.ChannelType.GROUP}isOpenChannel(){return this.channelType===t.ChannelType.OPEN}isFeedChannel(){return this.channelType===t.ChannelType.FEED}get cachedMetaData(){const e={};return this._cachedMetaData?(this._cachedMetaData.forEach(((t,s)=>{t.isRemoved||(e[s]=t.value)})),e):e}get messageCollectionLastAccessedAt(){return this._messageCollectionLastAccessedAt}_serializeCachedMetaData(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}_updateMessageCollectionLastAccessedAt(){this._messageCollectionLastAccessedAt=Date.now()}_update(e){const s=t.deundefined(e);Object.assign(this,s)}_upsertCachedMetaData(e,t){Object.keys(e).forEach((s=>{this._cachedMetaData||(this._cachedMetaData=new Map);const i=this._cachedMetaData.get(s);(!i||i.updatedAt<=t)&&this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})}))}_updateCachedMetaData(e,t){let s=!1;return this._cachedMetaData?this._cachedMetaData.forEach(((i,n)=>{var a;i.updatedAt<=t&&(this._cachedMetaData.set(n,{value:null!==(a=e[n])&&void 0!==a?a:i.value,isRemoved:!e[n],updatedAt:t}),s=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((s=>{this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})})),s=!0),{isUpdated:s}}_removeFromCachedMetaData(e,t){this._cachedMetaData&&e.forEach((e=>{const s=this._cachedMetaData.get(e);s&&s.updatedAtm.payloadify(e))):null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,created_at:i,user:a.currentUser?p.payloadify(a.currentUser):null,req_id:s,request_state:t.SendingStatus.PENDING,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>t.User.payloadify(e)))}))}_createPendingUserMessage(e,s,i){const n={};if(e.translationTargetLanguages)for(const t of e.translationTargetLanguages)n[t]="";const a=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.USER,message:e.message,translations:n,extended_message_payload:e.extendedMessagePayload})),r=new Q(this._iid,a);return r.messageParams=e,r}_createPendingScheduledUserMessage(e,t,s){const i=this._createPendingUserMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_createPendingFileMessage(e,i,n){var a,r,o,l,d,u,c;const h=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,i,n)),{type:t.MessageType.FILE,url:e.fileUrl,file:{name:null!==(a=e.fileName)&&void 0!==a?a:null===(r=e.file)||void 0===r?void 0:r.name,size:null!==(o=e.fileSize)&&void 0!==o?o:null===(l=e.file)||void 0===l?void 0:l.size,type:null!==(d=e.mimeType)&&void 0!==d?d:null===(u=e.file)||void 0===u?void 0:u.type,data:e.data},thumbnails:null===(c=e._thumbnails)||void 0===c?void 0:c.map((e=>s.payloadify(e)))})),p=new Y(this._iid,h);return p.messageParams=e,p}_createPendingMultipleFilesMessage(e,s,i){const n=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.FILE,file:e.fileInfoList.length>0?{name:e.fileInfoList[0].fileName,size:e.fileInfoList[0].fileSize,type:e.fileInfoList[0].mimeType,data:e.data}:void 0})),a=new G(this._iid,n);return a.messageParams=e,a}_validateFailedFileMessageHasFile(e,s){var i;return Boolean(e.url)||t.isFile(s)||t.isFile(null===(i=e.messageParams)||void 0===i?void 0:i.file)}_createPendingScheduledFileMessage(e,t,s){const i=this._createPendingFileMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_markMessageAsFailed(e,s,i=!1){e.errorCode=s.code,s.code===t.SendbirdErrorCode.REQUEST_CANCELED||s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=t.SendingStatus.CANCELED:i||(e.sendingStatus=t.SendingStatus.FAILED)}sendUserMessage(e){const s=Object.assign(Object.assign({},Me),e);return t.unless(Oe(s)).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(s)}_sendUserMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n,requestQueue:a}=t.Vault.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)}))));const d=new kt(Object.assign(Object.assign({},e),{channelUrl:this.url,channelType:this.channelType,reqId:r}));a.send(d).then((e=>{const{message:s}=e.as(Lt);n.dispatch(new t.MessageUpdateEventCommand({messages:[s],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(s)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendUserMessage(e){return t.unless(e instanceof Q&&!!e.messageParams).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId)}resendUserMessage(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=new t.Deferred,n=null!==(s=e.messageParams)&&void 0!==s?s:Ae(e);return this._sendUserMessage(n,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>i.reject(e))).onSucceeded((e=>i.resolve(e))),i.promise}))}updateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},qe),s);t.unless(t.isTypeOf("number",e)&&Fe(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Dt(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(qt);return o}))}copyUserMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Q&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters),t.unless(!s.poll).throw(t.SendbirdError.notSupportedError);const r=new t.Deferred,o=null!==(i=s.messageParams)&&void 0!==i?i:t.undefineNullProps(Object.assign(Object.assign({},s),{mentionType:s.mentionType,mentionedUserIds:null!==(n=s.mentionedUserIds)&&void 0!==n?n:null===(a=s.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)),translationTargetLanguages:Object.keys(s.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}));return e._sendUserMessage(o).onSucceeded((e=>{r.resolve(e)})).onFailed((e=>r.reject(e))),r.promise}))}translateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Qt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:s}),a=yield i.send(n),{message:r}=a.as(Gt);return r}))}_createScheduledUserMessage(e,s){const{requestQueue:i}=t.Vault.of(this._iid),n=Date.now(),a=this._generateRequestId();t.sleep(2).then((()=>{const i=this._createPendingScheduledUserMessage(e,a,n);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))}));const r=new Kt(Object.assign({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(r).then((e=>{const{message:i}=e.as(Ht);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((i=>{if(t.isThrowingOutside(i))throw i;t.sleep(2).then((()=>{const r=this._createPendingScheduledUserMessage(e,a,n);this._markMessageAsFailed(r,i),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(i,r)}))))}))}))}sendFileMessage(e){const s=Object.assign(Object.assign({},Ue),e);return t.unless(ke(s)).throw(t.SendbirdError.invalidParameters),this._sendFileMessage(s)}sendMultipleFilesMessage(e){var s;const i=Object.assign(Object.assign({},cs),e),n=t.Vault.of(this._iid);t.unless(((e,s=t.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT)=>Te(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=s&&e.fileInfoList.every((e=>hs(e))))(i,null===(s=n.appInfo)||void 0===s?void 0:s.multipleFilesMessageFileCountLimit)).throw(t.SendbirdError.invalidParameters);const a=!!e.fileInfoList.find((e=>{const t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return t.unless(!a).throw(t.SendbirdError.fileSizeLimitExceededError),this._sendMultipleFilesMessage(i)}_sendFileMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=$i.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?t.CollectionEventSource.LOCAL_MESSAGE_CANCELED:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendFileMessage(e){t.unless(e instanceof Y&&!!e.messageParams).throw(t.SendbirdError.invalidParameters);const{logger:s}=t.Vault.of(this._iid);return s.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId).onFailed((e=>{s.debug("autoResendFileMessage failed",e)})).onSucceeded((e=>{s.debug("autoResendFileMessage success",e)}))}_sendMultipleFilesMessage(e,s,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=$i.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new ps;return t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e,{requestHandler:l,isCopy:s===exports.SendMessageRequestType.COPY}).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);this._markMessageAsFailed(i,s),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_createScheduledFileMessage(e,s,i,n){const{requestQueue:a}=t.Vault.of(this._iid),r=new Wt(Object.assign(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(r).then((e=>{const{message:i}=e.as(Yt);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((a=>{if(t.isThrowingOutside(a))throw a;t.sleep(2).then((()=>{const r=this._createPendingScheduledFileMessage(e,i,n);this._markMessageAsFailed(r,a),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(a,r)}))))}))}))}sendFileMessages(e){t.unless(e.every((e=>ke(Object.assign(Object.assign({},Ue),e))))).throw(t.SendbirdError.invalidParameters);const s=new Ie;for(const t of e)this.sendFileMessage(t).onPending((e=>s._trigger(e))).onFailed(((e,t)=>s._triggerFailed(e,t))).onSucceeded((e=>s._trigger(e)));return s}resendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(e instanceof Y&&i&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const n=new t.Deferred,a=xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>n.reject(e))).onSucceeded((e=>n.resolve(e))),n.promise}))}resendMessage(e,s){var i,n;if(t.unless(e instanceof F&&!e.scheduledInfo&&e.isResendable).throw(t.SendbirdError.invalidParameters),e.isUserMessage()){const t=null!==(i=e.messageParams)&&void 0!==i?i:Ae(e);return this._sendUserMessage(t,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isFileMessage()){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(i).throw(t.SendbirdError.invalidParameters);const a=null!==(n=e.messageParams)&&void 0!==n?n:xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}updateFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},Be),s);t.unless(t.isTypeOf("number",e)&&(e=>De(e))(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Ft(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(Bt);return o}))}uploadFile(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),a=t.uuid(),r=new i({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a});r.uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a);const o=yield s.send(r),{url:l,thumbnails:d}=o.as(n);return{requestId:a,url:l,thumbnails:d}}))}cancelUploadingFileMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e)).throw(t.SendbirdError.invalidParameters);const{fileMessageQueue:s}=$i.of(this._iid);return s.cancel(this,e),!0}))}copyFileMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Y&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const r=new t.Deferred,o=t.undefineNullProps(Object.assign(Object.assign({},s),{fileUrl:s.url,fileName:s.name,fileSize:s.size,mimeType:s.type,mentionType:s.mentionType,mentionedUserIds:null!==(i=s.mentionedUserIds)&&void 0!==i?i:null===(n=s.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=s.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:s.requireAuth,isPinnedMessage:!1}));return e._sendFileMessage(o).onSucceeded((e=>r.resolve(e))).onFailed((e=>r.reject(e))),r.promise}))}copyMessage(e,s){t.unless(e instanceof Es&&s instanceof F&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=s,n=e;if(i.isUserMessage()){t.unless(!i.poll).throw(t.SendbirdError.notSupportedError);const e=Se(i);return n._sendUserMessage(e)}if(i.isFileMessage()){const e=Re(i);return n._sendFileMessage(e)}if(s.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}deleteMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){if(t.unless(e instanceof q).throw(t.SendbirdError.invalidParameters),e.messageId>0){const{requestQueue:s}=t.Vault.of(this._iid),i=new t.DeleteMessageRequestCommand({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof F?e._messageToken:void 0});yield s.send(i)}}))}addReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new jt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as(Vt);return r}))}deleteReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new zt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as($t);return r}))}_updateUserMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Dt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(qt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}_updateFileMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Ft({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(Bt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}createMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"add",!0):this._updateUserMessageMetaArray(e.messageId,i,"add",!0)}))}deleteMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"remove",!0):this._updateUserMessageMetaArray(e.messageId,i,"remove",!0)}))}addMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"add",!0):this._updateUserMessageMetaArray(e.messageId,s,"add",!0)}))}removeMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"remove",!0):this._updateUserMessageMetaArray(e.messageId,s,"remove",!0)}))}report(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isEnumOf(exports.ReportCategory,e)&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:n}=t.Vault.of(this._iid),a=new Ut({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:s});yield n.send(a)}))}reportUser(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof t.User&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new Rt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.userId,category:s,description:i});yield a.send(r)}))}reportMessage(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof F&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new xt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:s,description:i,messageToken:e._messageToken});yield a.send(r)}))}updatePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&(e=>t.isTypeOf("string",e.title,!0)&&t.validatePollData(e.data)&&t.isTypeOf("boolean",e.allowUserSuggestion,!0)&&t.isTypeOf("boolean",e.allowMultipleVotes,!0)&&t.isTypeOf("number",e.closeAt,!0))(s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Jt(Object.assign({pollId:e},s)),a=yield i.send(n),{poll:r}=a.as(Xt);return r}))}deletePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Zt({pollId:e});yield i.send(n)}))}closePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new es({pollId:e}),a=yield i.send(n),{poll:r}=a.as(ts);return r}))}addPollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("string",s)&&""!==s.trim();t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new ss({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:s}),r=yield n.send(a),{poll:o}=r.as(is);return o}))}updatePollOption(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const n=t.isTypeOf("number",e)&&t.isTypeOf("number",s)&&t.isTypeOf("string",i)&&""!==i.trim();t.unless(n).throw(t.SendbirdError.invalidParameters);const{requestQueue:a}=t.Vault.of(this._iid),r=new ns({pollId:e,pollOptionId:s,optionText:i}),o=yield a.send(r),{poll:l}=o.as(as);return l}))}deletePollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new rs({pollId:e,pollOptionId:s});yield n.send(a)}))}votePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isArrayOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n,dispatcher:a}=t.Vault.of(this._iid),r=new os({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:s}),o=yield n.send(r),{event:l}=o.as(ls);return a.dispatch(new t.PollVoteInternalEventCommand({event:l,source:t.CollectionEventSource.EVENT_POLL_VOTED})),l}))}getPollChangeLogsSinceTimestamp(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)).throw(t.SendbirdError.invalidParameters);const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}getPollChangeLogsSinceToken(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e,!0));const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}createPollListQuery(e=10){return new t.PollListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}createPollVoterListQuery(e,s,i=20){return new t.PollVoterListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:s,limit:i})}pinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new fs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}unpinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new vs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}}const Ts={};class bs{constructor({dbname:e,itemSizeLimit:t=1048576,cacheLimit:s=256,blockHashBase:i=2,blockHashMultiplier:n=10,blockHashConstant:a=11,transactionApplyDelay:r=200,disableLogger:o=!1}){return Ts[e]||(this.itemSizeLimit=t,this.cacheLimit=s,this.blockHashBase=i,this.blockHashMultiplier=n,this.blockHashConstant=a,this.transactionApplyDelay=r,this.disableLogger=o,Ts[e]=this),Ts[e]}static get(e){return Ts[e]}}var Ms,Ss;!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"}(Ms||(Ms={}));class As extends Error{constructor({code:e=Ms.UNKNOWN_ERROR,message:t="Unknown error occurred."}){super(t),this.code=e,Object.setPrototypeOf(this,As.prototype)}static get storeNotDefined(){return new As({code:Ms.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}static get storeNotAvailable(){return new As({code:Ms.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}static get storeNotAvailableInPrivateBrowsing(){return new As({code:Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}static get storeIsFull(){return new As({code:Ms.STORE_IS_FULL,message:"Store is full."})}static get storeNotInitialized(){return new As({code:Ms.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}static get storeKeyTypeIsInvalid(){return new As({code:Ms.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}static get storeBrokenIntegrity(){return new As({code:Ms.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}static get storeBrokenBlob(){return new As({code:Ms.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}static get storeEncryptionInvalid(){return new As({code:Ms.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}static get storeItemSizeExceeded(){return new As({code:Ms.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}static get storeReadFailed(){return new As({code:Ms.STORE_READ_FAILED,message:"Failed to read from store."})}static get storeWriteFailed(){return new As({code:Ms.STORE_WRITE_FAILED,message:"Failed to write to store."})}static get databaseSchemaNotOnUpgrade(){return new As({code:Ms.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}static get collectionNotReady(){return new As({code:Ms.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}static get collectionKeyNotMatch(){return new As({code:Ms.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}static get collectionQueryNotValid(){return new As({code:Ms.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}static get collectionInsertDuplicate(){return new As({code:Ms.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}static get collectionKeyNotFound(){return new As({code:Ms.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}static get collectionKeyNotGiven(){return new As({code:Ms.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}static get collectionWriteFailed(){return new As({code:Ms.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}static get collectionItemSizeExceeded(){return new As({code:Ms.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}static get indexTableIsRequired(){return new As({code:Ms.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}static get indexTypesNotMatch(){return new As({code:Ms.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}static get compareTypesNotMatch(){return new As({code:Ms.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}static get circularReferenceFound(){return new As({code:Ms.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ss||(Ss={}));const Os=(e,t=new WeakMap)=>{if("object"==typeof e&&null!==e){if(t.has(e))throw As.circularReferenceFound;{let s;if(t.set(e,!0),Array.isArray(e))s=e.map((e=>Os(e,t)));else if(e instanceof RegExp)s=e;else if(e instanceof Date)s=e;else{s={};for(const i in e)s[i]=Os(e[i],t)}return t.delete(e),s}}return e},Cs=(e,t)=>{if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw As.compareTypesNotMatch;let s=0;switch(typeof e){case"boolean":case"number":s=e-t;break;case"string":s=e.localeCompare(t)}return s},ws=(e,t)=>{let s=0;for(let t=0;t>>0)%t},Ns=e=>new Promise((t=>{setTimeout((()=>t()),e)})),Ps=(e,t)=>{if(!t)return!1;if("function"!=typeof e){for(const s in e)if(["/and","&&"].includes(s)){if(e[s].some((e=>!Ps(e,t))))return!1}else if(["/or","||"].includes(s)){if(e[s].every((e=>!Ps(e,t))))return!1}else if("/where"===s){if(!(0,e[s])(t))return!1}else{const i=s;if("object"==typeof e[i]){const s=e[i];for(const e in s)switch(e){case"/eq":case"=":if(t[i]!==s[e])return!1;break;case"/neq":case"!=":if(t[i]===s[e])return!1;break;case"/gt":case">":{const n=t[i],a=s[e];if(!(Cs(n,a)>0))return!1;break}case"/gte":case">=":{const n=t[i],a=s[e];if(!(Cs(n,a)>=0))return!1;break}case"/lt":case"<":{const n=t[i],a=s[e];if(!(Cs(n,a)<0))return!1;break}case"/lte":case"<=":{const n=t[i],a=s[e];if(!(Cs(n,a)<=0))return!1;break}case"/in":{const n=t[i];if(!s[e].includes(n))return!1;break}case"/nin":{const n=t[i];if(s[e].includes(n))return!1;break}case"/contain":{const n=t[i],a=s[e];if(!n.includes(a))return!1;break}case"/regex":{const n=t[i];if(!s[e].test(n))return!1;break}case"/where":{const n=t[i];if(!(0,s[e])(n))return!1;break}}}else if("function"==typeof e[i]){if(!e[i](t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}return e(t)},Us=()=>{},Rs=()=>Promise.resolve(),xs=e=>e,ks=(e,t)=>{t()};var Ls;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Ls||(Ls={}));class Ds{constructor({initialPrevValue:e=null,initialNextValue:t=null,iterator:s,map:i=xs,backward:n=Rs,forward:a=Rs,complete:r=Us}){this._prevValue=e,this._nextValue=t,this._error=null,this._map=i,this._backward=n,this._forward=a,this._iterator=s,this._complete=r}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 t.__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 t.__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 qs{constructor({condition:e={},backward:t=!1,blockManager:s,indexer:i}){this.condition=e,this.backward=t,this._blockManager=s,this._indexer=i}findOptimizedStartPosition(){const e=["=","/eq",">",">=","/gt","/gte"],t=["=","/eq","<","<=","/lt","/lte"];if(this.backward){let s=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(const i in this._indexer.fields){let n=this._indexer.fields[i],a=1;if("-"===n[0]&&(n=n.slice(1),a=-1),this.condition[n])if("object"==typeof this.condition[n]){const r=a>0?t:e;for(const e in this.condition[n])if(r.includes(e))for(let t=s;t>=0;t--)if(a*Cs(this._indexer.origin[t].columnValues[i],this.condition[n][e])<=0){s=t;break}}else for(let e=s;e>=0;e--)if(a*Cs(this._indexer.origin[e].columnValues[i],this.condition[n])<=0){s=e;break}}return Math.min(s+1,this._indexer.origin.length-1)}{let s=0;if("function"!=typeof this.condition)for(let i=0;i{if((a>0?e:t).includes(r))for(let e=s;e=0){s=e;break}}));else for(let e=s;e=0){s=e;break}}return Math.max(s-1,0)}}each(e){return t.__awaiter(this,void 0,void 0,(function*(){let s=this.findOptimizedStartPosition(),i=0;this.backward&&this._indexer.origin[s]&&(i=this._indexer.origin[s].keys.length-1);const n=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[++i]){if(!this._indexer.origin[++s])return!1;i=0}return!0}return!1},a=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[--i]){if(!this._indexer.origin[--s])return!1;i=this._indexer.origin[s].keys.length-1}return!0}return!1};let r=null;if(this._indexer.origin[s]){const e=this.backward?a:n;do{const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e)){r=e;break}}while(e())}return yield new Promise((o=>{const l=new Ds({initialNextValue:Os(r),iterator:e,forward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?a:n;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return Os(e)}return null})),backward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?n:a;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return Os(e)}return null})),complete:o});e(l)}))}))}}class Fs{constructor({condition:e={},backward:t=!1,mutex:s,blockManager:i,indexer:n}){this._mutex=s,this._iterator=new qs({condition:e,backward:t,blockManager:i,indexer:n})}fetch(e={}){return t.__awaiter(this,void 0,void 0,(function*(){let s=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 As.collectionQueryNotValid;try{const e=[];return yield this._mutex.lock(),yield this._iterator.each((n=>t.__awaiter(this,void 0,void 0,(function*(){n.error?n.stop():n.hasNext?0===s?(e.push(n.nextValue),0t.__awaiter(this,void 0,void 0,(function*(){s.error?s.stop():s.hasNext?(e++,s.next()):s.stop()})))),this._mutex.unlock(),e}catch(e){throw this._mutex.unlock(),e}}))}}const Bs=e=>`nest@${e}`,js=(e,t)=>`${Bs(e)}/${t}`,Vs=(e,t)=>`${js(e,t)}.metadata`,zs=(e,t)=>`${js(e,t)}/block.`,$s=(e,t)=>`${js(e,t)}/blob.`;class Qs{constructor({dbname:e,collectionName:t,store:s}){this.dbname=e,this.collectionName=t,this.store=s}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.store.get(e);if(t){const{data:e,type:s}=t;if("undefined"!=typeof fetch){const t=yield fetch(e);return yield t.blob()}{const t=512,i=[],n=atob(e.split(",")[1]);for(let e=0;e{const i=((e,t,s,i=0)=>`${$s(e,t)}${s}.${i}`)(this.dbname,this.collectionName,s),n=new FileReader;n.onload=()=>{t({blobId:i,data:n.result,type:e.type})},n.readAsDataURL(e)}));return yield this.store.set({key:t,value:{data:i,type:n}}),t}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this.store.remove(e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=$s(this.dbname,this.collectionName),s=yield this.store.getAllKeys();yield Promise.all(s.filter((t=>t.startsWith(e))).map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this.store.remove(e)})))))}))}}var Gs,Ks,Hs;!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Gs||(Gs={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Ks||(Ks={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Hs||(Hs={}));const Ws=[Ks.PENDING,Ks.VOLATILE],Ys={};class Js{constructor({dbname:e,limit:t=256}){return Ys[e]||(this.dbname=e,this._items=[],this._limit=t,Ys[e]=this),Ys[e]}static get(e){return Ys[e]}get items(){return this._items}find(e,s,i=Hs.DEFAULT){return t.__awaiter(this,void 0,void 0,(function*(){let t=this.get(s);if(t)i===Hs.PERSISTENT&&(t.state=Ks.PERSISTENT);else{const n=yield e.get(s);n&&(t={key:s,value:n,state:i===Hs.PERSISTENT?Ks.PERSISTENT:Ks.VOLATILE},this.put(t))}return t}))}get(e,t=Hs.DEFAULT){const s=this._items.map((e=>e.key)).indexOf(e);if(s>-1){const e=this._items[s];return t===Hs.PERSISTENT&&(e.state=Ks.PERSISTENT),t!==Hs.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)Ws.includes(this._items[t].state)&&Ws.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===Ks.VOLATILE));let s=t.length-this._limit;if(s>0){const e=[];for(const t of this._items)t.state===Ks.VOLATILE&&s>0?s--: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!==Ks.VOLATILE))}}class Xs{constructor({dbname:e,collectionName:t,store:s}){this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=e,this.collectionName=t,this.metadataKey=((e,t)=>`${js(e,t)}/trans.metadata`)(e,t),this.recordsetKey=((e,t)=>`${js(e,t)}/trans.recordset`)(e,t),this._store=s}get generation(){return this._metadata?this._metadata.generation:0}get requestCount(){return this._requests.length}_getReducedRecordset(e=[]){return t.__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=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=[];for(let e=n.requests.length-1;e>=0;e--){const t=n.requests[e],i=t.data;s[i.key]||(a.unshift(t),s[i.key]=!0)}a.length>0&&(n.requests=a,t.unshift(n))}return t}_applyRecord(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname),{generation:i,requests:n}=s;let a=null;try{const e=yield this._store.setMany(n.map((e=>Object.assign(Object.assign({},e.data),{generation:i}))));for(let s=0;s{a&&e(a)}));else{const t=e.filter((e=>e.generation!==i));yield this._store.set({key:this.recordsetKey,value:t}),this._onWrite.forEach((e=>{e(n.map((e=>e.data)))}))}}))}init(){return t.__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,s){switch(e){case Gs.COMMIT:this._onCommit.set(t,s);break;case Gs.WRITE:this._onWrite.set(t,s);break;case Gs.ERROR:this._onError.set(t,s)}}requestWrite(e,t){this._requests.push({data:e,options:t});Js.get(this.dbname).put(Object.assign({state:Ks.PENDING},e))}requestMultipleWrite(e,t){const s=Js.get(this.dbname);for(const i of e)this._requests.push({data:i,options:t}),s.put(Object.assign({state:Ks.PENDING},i))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).clearByCondition((e=>e.state===Ks.PENDING)),this._requests=[]}))}commit(){return t.__awaiter(this,void 0,void 0,(function*(){const e=this._requests;if(e.length>0){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=n.data;s[a.key]||(s[a.key]=!0,t.unshift(n))}const i={generation:this.generation,requests:t},n=yield this._getReducedRecordset([i]);yield this._store.set({key:this.recordsetKey,value:n}),this._metadata.generation++,yield this._store.set({key:this.metadataKey,value:this._metadata});const a=Js.get(this.dbname);for(let e=0;e{t(e.map((e=>e.data)))}));const r=bs.get(this.dbname);setTimeout((()=>{try{this._applyRecord(n,i)}catch(e){this._onError.forEach((t=>t(e)))}}),r.transactionApplyDelay)}}))}}class Zs{constructor({blockId:e,keyName:t,items:s=[],limit:i}){this.blockId=e,this.keyName=t,this.limit=i,this._items=[...s]}static createFromCacheItem(e){return e?new Zs(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 s=t[this.keyName];return e===s}));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 i=s.base*Math.pow(s.multiplier,t)+s.constant;return(s.hashFunction||ws)(e,i)})(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})}`,`${zs(s,i)}${n}.${a}`;var s,i,n,a}_findBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname);for(let s=this.metadata.blockLevel;s>0;s--){const i=this.createBlockId(e,s),n=yield t.find(this._store,i);if(n){const t=Zs.createFromCacheItem(n);if(null==t?void 0:t.getItemByKey(e))return t}}return null}))}getFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return t?t.getItemByKey(e):null}))}putToBlock(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=bs.get(this.dbname),i=this.createBlockId(e),n=Math.floor(this._store.itemSizeLimit/t.itemSizeLimit),a=Js.get(this.dbname),r=yield a.find(this._store,i),o=r?Zs.createFromCacheItem(r):new Zs({blockId:i,keyName:this.keyName,items:[],limit:n});return!!(null==o?void 0:o.add(s))&&(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),!0)}))}removeFromBlock(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const e=zs(this.dbname,this.collectionName),t=(yield this._store.getAllKeys()).filter((t=>t.startsWith(e)));yield this._store.removeMany(t),yield this._transaction.clear();Js.get(this.dbname).clearByCondition((t=>t.key.startsWith(e)))}))}}const ti=e=>{const t=typeof e;return null===e||"undefined"===t||"boolean"===t||"number"===t||"string"===t},si={};class ii{constructor({dbname:e,collectionName:t,keyName:s,fields:i,transaction:n,store:a}){this._origin=[],this._table=[];const r=((e,t,s)=>`${js(e,t)}/index.${s}`)(e,t,i.join(">"));return si[r]||(this.dbname=e,this.collectionName=t,this.keyName=s,this.fields=i,this.indexerKey=r,this._transaction=n,this._store=a,this._transaction.on(Gs.COMMIT,this.indexerKey,(()=>this.commit())),this._transaction.on(Gs.ERROR,this.indexerKey,(()=>this.abort()))),si[r]}static createKey(e){return e.join(">")}static parseKey(e){return e.split(">")}static clearIndexerMap(){for(const e in si)delete si[e]}_addItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);return n?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:s,keys:[t]}),!0)}_removeItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);if(n){const e=this._table[i].keys.indexOf(t);if(e>-1)return this._table[i].keys.splice(e,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1}get origin(){return this._origin}get table(){return this._table}getColumnValues(e){const t=[];for(let s of this.fields){if("-"===s[0]&&(s=s.slice(1)),!ti(e[s]))throw As.indexTypesNotMatch;t.push(e[s])}return t}diff(e,t){for(const s in this.fields){const i="-"===this.fields[s][0]?-1:1,n=Cs(e[s],t[s]);if(0!==n)return i*n}return 0}indexOf(e){if(this._table.length>0){let t=0,s=this._table.length-1;for(;t<=s;){const i=Math.floor((t+s)/2),n=this.diff(e,this._table[i].columnValues);if(n>0)t=i+1;else{if(!(n<0))return[i,!0];s=i-1}}return[t,!1]}return[0,!1]}ensure(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.dbname),t=yield e.find(this._store,this.indexerKey,Hs.PERSISTENT);if(t)this._origin=t.value,this._table=Os(this._origin);else{const t=zs(this.dbname,this.collectionName),s=yield this._store.getAllKeys();for(const i of s)if(i.startsWith(t)){const t=yield e.find(this._store,i,Hs.NO_CACHE),s=Zs.createFromCacheItem(t);if(s)for(const e of s.items)this._addItem(e)}this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}si[this.indexerKey]=this}))}drop(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).remove(this.indexerKey),yield this._store.remove(this.indexerKey),delete si[this.indexerKey]}))}addItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}removeItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}clear(){return t.__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=Os(this._origin)}abort(){this._table=Os(this._origin)}}const ni=()=>"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product,ai=()=>{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)}))};var ri,oi;!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(ri||(ri={})),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"}(oi||(oi={}));const li={};class di{constructor(e,t={}){return this._state=ri.PROCESSING,this._queue=[],this._activationQueue=[],li[e]&&!t.forceCreate||(this.nodeId=ai(),this.key=e,ni()&&(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;if(!(null==t?void 0:t.isNestDbMessage))return;const{nodeId:s,requestId:i,key:n,op:a,data:r}=t;if(s!==this.nodeId&&n===this.key)switch(a){case oi.NEWNODE:this._sendSync();break;case oi.CLAIM_HOST:this._sendSync(),this._hostId=s;break;case oi.SYNC_HOST:if(!this.isInSync){this._activationTimeout&&clearTimeout(this._activationTimeout);const{currentItemRequestId:e,queue:t}=r;for(const e of t){this._queue.findIndex((t=>t.requestId===e.requestId))<0&&this._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:this.key,op:oi.REQUEST_LOCK,ts:e.ts})}this._currentItem=this._queue.find((t=>t.requestId===e)),this._completeSync()}break;case oi.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 oi.REQUEST_LOCK:this._requestLock(t);break;case oi.ACQUIRE_LOCK:{const e=this._queue.find((e=>e.requestId===i));this._acquire(e);break}case oi.RELEASE_LOCK:this._release(i)}})),window.addEventListener("beforeunload",(()=>{this._send(oi.REMOVENODE)}))),li[e]=this),li[e]}get locked(){return!!this._currentItem}get isHost(){return this._hostId===this.nodeId}get isInSync(){return this._state==ri.DONE}_send(e,t={}){var s;const i={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(s=null==t?void 0:t.requestId)&&void 0!==s?s:ai(),key:this.key,op:e,data:t.data,ts:Date.now()};return ni()&&window.postMessage(i,"*"),i}_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(oi.RELEASE_LOCK,{requestId:t.requestId});const s=this._queue.findIndex((t=>t.requestId===e));s>-1&&this._queue.splice(s,1),t.onReleased&&t.onReleased(e)}}_requestLock(e){return new Promise((t=>{const s={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:e=>{this.isHost&&this._send(oi.ACQUIRE_LOCK,{requestId:e}),t()},onReleased:()=>{this._acquire(this._queue[0])}};let i=!1;for(const e in this._queue)if(this._queue[e].ts>s.ts){this._queue.splice(parseInt(e),0,s),i=!0;break}i||this._queue.push(s),this._currentItem||this._acquire(this._queue[0])}))}_sendSync(){var e;this.isHost&&this._send(oi.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 t.__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=ri.DONE,this._activationQueue.forEach((e=>e())),this._activationQueue=[])}registerNode(){this._send(oi.NEWNODE),this._waitSync()}claimHost(){this._hostId=this.nodeId,this._send(oi.CLAIM_HOST),this._waitSync()}lock(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._waitUntilSyncCompleted();const e=this._send(oi.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)}}class ui{constructor({dbname:e,collectionName:t,keyName:s,keyHash:i,indexes:n,store:a}){this._state=Ss.INIT,this._indexers=[],this.dbname=e,this.name=t,this.keyName=s,this.indexes=[[s],...n.filter((e=>ii.createKey(e)!==this.keyName))],this._keyHash=i,this._store=a,this._mutex=new di(((e,t)=>`${js(e,t)}.lock`)(e,t)),this._blobContainer=new Qs({dbname:e,collectionName:t,store:a}),this._transaction=new Xs({dbname:e,collectionName:t,store:a})}static metadataOf(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const t=Vs(e,s);return yield i.get(t)}))}get state(){return this._state}get isReady(){return this._state===Ss.READY}init(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._mutex.lock();try{const e=bs.get(this.dbname),t=yield ui.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 ei({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store});const s=[...this.indexes],i=[],n=s.map((e=>ii.createKey(e))),a=t?t.indexes.map((e=>ii.createKey(e))):[];for(const e of a)n.includes(e)||i.push(ii.parseKey(e));const r=[];if(r.push(...s.map((e=>{const t=new ii({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store});return this._indexers.push(t),t.ensure()}))),r.push(...i.map((e=>new ii({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store}).drop()))),yield Promise.all(r),yield this._transaction.commit(),n.sort().join(",")!==a.sort().join(",")){const e=Vs(this.dbname,this.name);this._metadata.indexes=s,yield this._store.set({key:e,value:this._metadata})}this._state=Ss.READY,this._mutex.unlock()}catch(e){throw this._mutex.unlock(),e}}))}close(){this._state=Ss.CLOSED}_hasPropertyOfKeyName(e){const t=e[this.keyName];return"string"==typeof t&&!!t}_getIndexerBy(e=null){e||(e=[this.keyName]);const t=ii.createKey(e);for(const e of this._indexers)if(t===ii.createKey(e.fields))return e;throw As.indexTableIsRequired}_upgradeBlockLevel(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Vs(this.dbname,this.name);this._metadata.blockLevel++,yield this._store.set({key:e,value:this._metadata})}))}_requestInsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName];if(yield this._blockManager.getFromBlock(t))throw As.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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}}))}_requestRemove(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){yield this._blockManager.clearAllBlocks();for(const e of this._indexers)yield e.clear()}))}getByKey(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw As.collectionNotReady;yield this._mutex.lock();try{const t=yield this._blockManager.getFromBlock(e);return this._mutex.unlock(),Os(t)}catch(e){throw this._mutex.unlock(),e}}))}query(e={}){if(this.isReady)return new Fs({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw As.collectionNotReady}insertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw As.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw As.collectionKeyNotGiven;return yield this._requestInsert(Os(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}insertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw As.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw As.collectionKeyNotGiven;for(const t of e)yield this._requestInsert(Os(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw As.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw As.collectionKeyNotGiven;return yield this._requestUpsert(Os(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw As.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw As.collectionKeyNotGiven;for(const t of e)yield this._requestUpsert(Os(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}update(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw As.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw As.collectionKeyNotGiven;return yield this._requestUpdate(Os(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}updateIf(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),As.collectionNotReady;yield this._mutex.lock();try{const{where:i={},index:n=null,backward:a=!1}=e,r=[],o=new qs({condition:i,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(n)});yield o.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(Ps(i,t)&&s.set){if("function"!=typeof s.set)for(const e in s.set)t[e]=s.set[e];else s.set(t);r.push(t)}e.next()}else e.stop()}))));for(const e of r)yield this._requestUpdate(Os(e));return yield this._transaction.commit(),this._mutex.unlock(),r}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw As.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 t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),As.collectionNotReady;yield this._mutex.lock();try{const{where:s={},index:i=null,backward:n=!1}=e,a=[],r=new qs({condition:s,blockManager:this._blockManager,backward:n,indexer:this._getIndexerBy(i)});yield r.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(Ps(s,t)){const e=t[this.keyName];a.push(e)}e.next()}else e.stop()}))));for(const e of a)yield this._requestRemove(e);return yield this._transaction.commit(),this._mutex.unlock(),a}catch(e){throw this._mutex.unlock(),e}}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw As.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 t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.get(e)}))}saveBlob(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.save(e,s)}))}removeBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.remove(e)}))}removeAllBlobs(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.clear()}))}}const ci="[NESTDB]";let hi=!0;class pi{static off(){hi=!1}static log(...e){hi&&console.log(`${ci}[LOG]`,...e)}static warning(...e){hi&&console.warn(`${ci}[WARNING]`,...e)}static error(...e){hi&&console.error(`${ci}[ERROR]`,...e)}}const mi=[{},{a:700400,n:"error"}];class _i{constructor(e){var s,i,n;this.encryption=null!==(s=e.encryption)&&void 0!==s?s:t.DEFAULT_ENCRYPTION,this.itemSizeLimit=null!==(i=e.itemSizeLimit)&&void 0!==i?i:4194304,this.metadataBuffer=null!==(n=e.metadataBuffer)&&void 0!==n?n:256}get _encryptionCheckKey(){return`${this.dbname}.encrypt`}get _reservedKeys(){return[this._encryptionCheckKey]}_getRawKey(e,t=""){return`${e}${t}`}_generateShardPostfixArray(e=1){return[...Array(e).keys()]}_shardify(e){const{key:t,value:s}=e,i=JSON.stringify(this.encryption.encrypt(s)),n=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(n).map((e=>{const s={key:this._getRawKey(t,`.${e}`),data:i.substring(e*this.adjustedItemSizeLimit,(e+1)*this.adjustedItemSizeLimit)};return 0===e&&(s.metadata={shards:n}),s}))}_resetIfEncryptionChanged(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.get(this._encryptionCheckKey),t={encrypted:mi.map((e=>{var t;return null===(t=this.encryption)||void 0===t?void 0:t.encrypt(e)}))};if(e)if(e.encrypted&&Array.isArray(e.encrypted))for(const s in e.encrypted){if(JSON.stringify(e.encrypted[s])!==JSON.stringify(t.encrypted[s])){pi.warning("Encryption algorithm has changed. Stored data would be cleared."),yield this.clear();break}}else yield this.clear();yield this.set({key:this._encryptionCheckKey,value:t})}))}get adjustedItemSizeLimit(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}usage(){return t.__awaiter(this,void 0,void 0,(function*(){let e=0;const t=yield this._getAllRawKeys();for(const s of t){const t=yield this._getRaw(s);t&&(e+=JSON.stringify(t).length)}return e}))}getAllKeys(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this._getAllRawKeys()).filter((e=>e.endsWith(".0"))).map((e=>e.replace(/\.0$/,""))).filter((e=>!this._reservedKeys.includes(e)))}))}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=this._getRawKey(e,".0"),i=yield this._getRaw(s);if(i)try{const{data:s,metadata:n}=i,a=(null==n?void 0:n.shards)&&n.shards>1?yield Promise.all(this._generateShardPostfixArray(null==n?void 0:n.shards).map((i=>t.__awaiter(this,void 0,void 0,(function*(){if(i>0){const t=this._getRawKey(e,`.${i}`),s=yield this._getRaw(t);if(!s)throw As.storeBrokenIntegrity;return s.data}return s}))))):[s];return this.encryption.decrypt(JSON.parse(a.join("")))}catch(e){return null}return null}))}set(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._shardify(e);return yield this._setRaw(t),Object.assign({},e.value)}))}setMany(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const t=this._getRawKey(e,".0"),s=yield this._getRaw(t);if(s){const{metadata:t}=s;return yield this._removeRaw(this._generateShardPostfixArray(null==t?void 0:t.shards).map((t=>this._getRawKey(e,`.${t}`)))),!0}return!1}))}removeMany(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=[];for(const s of e){const e=this._getRawKey(s,".0"),i=yield this._getRaw(e);if(i){const{metadata:e}=i;t.push(...this._generateShardPostfixArray(null==e?void 0:e.shards).map((e=>this._getRawKey(s,`.${e}`))))}}return t.length>0&&(yield this._removeRaw(t)),e}))}}const gi=1,yi={};class fi extends _i{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:4194304}));const{delay:s=gi}=e;this.delay=s,this.observer={}}get rawData(){return yi[this.dbname]}set rawData(e){yi[this.dbname]=e}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){if(yi[this.dbname])return Object.keys(yi[this.dbname]);throw As.storeNotAvailable}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(yi[this.dbname])return yield Ns(this.delay),yi[this.dbname][e]?Object.assign({key:e},yi[this.dbname][e]):null;throw As.storeNotAvailable}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!yi[this.dbname])throw As.storeNotAvailable;yield Ns(this.delay);for(const t of e){const{key:e,data:s,metadata:i}=t;yi[this.dbname][e]=Object.freeze({data:s,metadata:i})}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!yi[this.dbname])throw As.storeNotAvailable;yield Ns(this.delay);for(const t of e)yi[this.dbname][t]&&delete yi[this.dbname][t]}))}observe(e,t,s){this.observer[e]||(this.observer[e]={}),t.forEach((t=>this.observer[e][t]=s))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yi[this.dbname]||(yi[this.dbname]={}),yield this._resetIfEncryptionChanged()}))}set(e){const s=Object.create(null,{set:{get:()=>super.set}});return t.__awaiter(this,void 0,void 0,(function*(){const t=this.observer[e.key];if(t&&"function"==typeof t.set){const e=t.set();if(e)throw e}return s.set.call(this,e)}))}setMany(e){const s=Object.create(null,{setMany:{get:()=>super.setMany}});return t.__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 s.setMany.call(this,e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield Ns(this.delay),yi[this.dbname]={}}))}}const vi="NestDBStore";var Ii;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Ii||(Ii={}));var Ei,Ti,bi;exports.NestDBState=void 0,(Ei=exports.NestDBState||(exports.NestDBState={})).INIT="INIT",Ei.OPENING="OPENING",Ei.OPENED="OPENED",Ei.CLOSED="CLOSED";exports.LogLevel=void 0,(Ti=exports.LogLevel||(exports.LogLevel={}))[Ti.VERBOSE=0]="VERBOSE",Ti[Ti.DEBUG=1]="DEBUG",Ti[Ti.INFO=2]="INFO",Ti[Ti.WARN=3]="WARN",Ti[Ti.ERROR=4]="ERROR",Ti[Ti.NONE=5]="NONE";class Mi{constructor(e){var s,i,n,a;this.messageTypeFilter=null!==(s=null==e?void 0:e.messageTypeFilter)&&void 0!==s?s:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(i=null==e?void 0:e.customTypesFilter)&&void 0!==i?i:null,this.senderUserIdsFilter=null!==(n=null==e?void 0:e.senderUserIdsFilter)&&void 0!==n?n:null,this.replyType=null!==(a=null==e?void 0:e.replyType)&&void 0!==a?a:t.ReplyType.NONE}clone(){const e=new Mi,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((s=>{e[s]=t[s]})),e}match(e){switch(this.messageTypeFilter){case t.MessageTypeFilter.USER:if(e.messageType!==t.MessageType.USER)return!1;break;case t.MessageTypeFilter.FILE:if(e.messageType!==t.MessageType.FILE)return!1;break;case t.MessageTypeFilter.ADMIN:if(e.messageType!==t.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof F))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof q)switch(this.replyType){case t.ReplyType.NONE:if(e.parentMessageId>0)return!1;break;case t.ReplyType.ONLY_REPLY_TO_CHANNEL:if(e instanceof F&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}}exports.MessageListOrder=void 0,(bi=exports.MessageListOrder||(exports.MessageListOrder={})).CHANNEL_LATEST="channel_latest",bi.NEWEST_CHILD_MESSAGE="newest_child_message";const Si=e=>{switch(e){case exports.MessageListOrder.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Ai=()=>["channelUrl","-createdAt","-notificationId"],Oi=Object.assign(Object.assign({},Me),{scheduledAt:void 0}),Ci=Object.assign(Object.assign({},Ee),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),wi="UnsentMessage",Ni={};class Pi extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),this._mutex=new di("unsendmessagecache.lock"),Ni[e]=this}static of(e,t=!1){return Ni[e]&&!t||(Ni[e]=new Pi(e)),Ni[e]}get collection(){const{nestdb:e}=this._cacheContext,s=null==e?void 0:e.collection(wi);if(!s)throw t.SendbirdError.databaseError;return s}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){if(e.messageId>0)throw t.SendbirdError.invalidParameters;const s=Object.assign({},e.serialize());var i;return e instanceof Q?(e.messageParams&&(s.messageParams=be(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(i=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},be(i)),{scheduledAt:i.scheduledAt})))):e instanceof Y?(e.messageParams&&(s.messageParams=Pe(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(e=>Object.assign(Object.assign({},Pe(e)),{scheduledAt:e.scheduledAt}))(e.scheduledInfo.scheduledMessageParams))):e instanceof G&&e.messageParams&&(s.messageParams=(e=>t.deundefined({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}))(e.messageParams)),s}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return $i.of(this._iid).buildMessageFromSerializedData(e)}_deserializeWithMessageCreateParams(e){var s,i,n;return t.__awaiter(this,void 0,void 0,(function*(){const a=$i.of(this._iid),r=this._deserialize(e);if(e.messageParams)if(r instanceof Q){const t=e.messageParams;r.messageParams=a.buildUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.messageParams;t.fileKey&&"string"==typeof t.fileKey&&Ne(null!==(s=t.fileType)&&void 0!==s?s:"")&&(t.file=null!==(i=yield this.collection.getBlob(t.fileKey))&&void 0!==i?i:void 0),r.messageParams=a.buildFileMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof G){const s=e.messageParams;s&&s.fileInfoList&&(r.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(s,r),yield Promise.all(r.messageParams.fileInfoList.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t,s,i,n;"string"==typeof(null===(t=e._uploadedMetaData)||void 0===t?void 0:t.fileKey)&&Ne(null!==(i=null===(s=e._uploadedMetaData)||void 0===s?void 0:s.fileType)&&void 0!==i?i:"")&&(e.file=null!==(n=yield this.collection.getBlob(e._uploadedMetaData.fileKey))&&void 0!==n?n:void 0)}))))))}if(r.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)if(r instanceof Q){const t=e.scheduledInfo.scheduledMessageParams;r.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.scheduledInfo.scheduledMessageParams;t.fileKey&&"string"==typeof t.fileKey&&"string"==typeof t.fileType&&Ne(t.fileType)&&(t.file=null!==(n=yield this.collection.getBlob(t.fileKey))&&void 0!==n?n:void 0),r.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(t,r)}return r}))}_getFileInfoBlobKey(e,t){return`${e}.${t}`}get(e){return t.__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:s=new Mi,order:i=exports.MessageListOrder.CHANNEL_LATEST,sendingStatus:n,backward:a=!1,parentMessageId:r}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const o=Si(i),l={"/where":e=>!!(i!==exports.MessageListOrder.NEWEST_CHILD_MESSAGE||r&&0!==e.parentMessageId&&e.parentMessageId===r)&&s.match(this._deserialize(e))};e&&(l.channelUrl=e),n&&(l.sendingStatus=n);const d={where:l,index:o,backward:a},u=yield this.collection.query(d),c=yield u.fetch({});return Promise.all(c.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._deserializeWithMessageCreateParams(e)})))))}return[]}))}getAllChildMessages(e,s=new Mi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){(e instanceof Y||e instanceof G)&&(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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__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 t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e}}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}saveBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y){if(e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}if(e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams){const t=e.scheduledInfo.scheduledMessageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}}else if(e instanceof G){const s=e.messageParams;s&&s.fileInfoList&&Array.isArray(s.fileInfoList)&&(yield Promise.all(s.fileInfoList.map(((s,i)=>t.__awaiter(this,void 0,void 0,(function*(){if(s.file&&we(s.file)){const t=yield this.collection.saveBlob(s.file,this._getFileInfoBlobKey(e.reqId,i));s._uploadedMetaData||(s._uploadedMetaData={}),s._uploadedMetaData.fileKey=t,s._uploadedMetaData.fileType=Ce.BLOB}}))))))}}))}}const Ui={};class Ri extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _unsentMessageCache(){return Pi.of(this._iid)}constructor(e){super(e),Ui[e]=this}static of(e,t=!1){return Ui[e]&&!t||(Ui[e]=new Ri(e)),Ui[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(ds)}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 $i.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new Mi,order:a=exports.MessageListOrder.CHANNEL_LATEST,backward:r=!1,parentMessageId:o,isPollOnly:l=!1,exactMatch:d=!1,inclusive:u=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const c=Si(a),h={where:{channelUrl:e,"/where":e=>{if(null!=s&&""!==s)switch(a){case exports.MessageListOrder.CHANNEL_LATEST:if(d&&e.createdAt!==s)return!1;if(r){if(u&&e.createdAts||!u&&e.createdAt>=s)return!1;break;case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:if(!o||0===e.parentMessageId||e.parentMessageId!==o)return!1}return!(l&&!e._poll)&&n.match(this._deserialize(e))}},index:c,backward:r},p=yield this.collection.query(h),m=yield p.fetch({limit:null!=i?i:void 0});return Promise.all(m.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return this._deserialize(e)})))))}return[]}))}getAllChildMessages(e,s=new Mi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})}))}upsert(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.saveBlobs(e);for(const t of e)if(null===(s=t.threadInfo)||void 0===s?void 0:s._isUpdateRequired){const e=yield this.get(t.messageId);(null==e?void 0:e.threadInfo)&&t.threadInfo._updateFrom(e.threadInfo)}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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t;let s=[];(null===(t=e.threadInfo)||void 0===t?void 0:t.replyCount)&&e.threadInfo.replyCount>0&&(s=yield this.getAllChildMessages(e)),s.length>0&&(s.forEach((t=>t.applyParentMessage(e))),yield this.upsert(s))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(`${t}`)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:Si(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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Si(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=Si(exports.MessageListOrder.CHANNEL_LATEST),n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}saveBlobs(e){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y&&e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s}}})))))}))}_getGroupChannelPreferenceSize(e){return t.__awaiter(this,void 0,void 0,(function*(){let t=0;const{preference:s}=this._cacheContext,i=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),n=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),a=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),r=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`);return i&&(t+=JSON.stringify(i).length),n&&(t+=JSON.stringify(n).length),a&&(t+=JSON.stringify(a).length),r&&(t+=JSON.stringify(r).length),t}))}}const xi={};class ki extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),xi[e]=this}static of(e,t=!1){return xi[e]&&!t||(xi[e]=new ki(e)),xi[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(us)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){return Object.assign({},e.serialize())}_deserialize(e){return $i.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new Mi,backward:a=!1,exactMatch:r=!1,inclusive:o=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t={where:{channelUrl:e,"/where":e=>{if(s){if(r&&e.createdAt!==s)return!1;if(a){if(o&&e.createdAts||!o&&e.createdAt>=s)return!1}return n.match(this._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:a},l=yield this.collection.query(t);return(yield l.fetch({limit:null!=i?i:void 0})).map((e=>this._deserialize(e)))}return[]}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=e.map((e=>this._serialize(e)));yield this.collection.upsertMany(t)}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}markAsReadByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.updateIf({where:{channelUrl:e,messageStatus:exports.NotificationMessageStatus.SENT,createdAt:{"<":s}}},{set:{messageStatus:exports.NotificationMessageStatus.READ}}))}))}markAsReadByMessageIds(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){return(yield this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":s},messageStatus:exports.NotificationMessageStatus.SENT}},{set:{messageStatus:exports.NotificationMessageStatus.READ}})).length}return 0}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]});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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Si(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=["channelUrl","-createdAt","-notificationId"],n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}}const Li={};class Di extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _dispatcher(){return t.Vault.of(this._iid).dispatcher}get _messageCache(){return Ri.of(this._iid)}get _unsentMessageCache(){return Pi.of(this._iid)}get _notificationCache(){return ki.of(this._iid)}constructor(e){super(e),this._observers=new Map,this._dispatcherContext=this._dispatcher.on((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof t.MessageUpdateEventCommand){const{messages:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&e.messageId>0)),r=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&0===e.messageId)),o=s.filter((e=>e instanceof H));a.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.upsert(a),yield this._unsentMessageCache.remove(a.map((e=>e instanceof F?e.reqId:null)).filter((e=>null!==e)))})))),n||this._broadcastUpdateEvent(a,i)),r.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.upsert(r)})))),n||this._broadcastUpdateEvent(r,i)),o.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._notificationCache.upsert(o)})))),n||this._broadcastUpdateEvent(o,i))}else if(e instanceof t.MessageRemoveEventCommand){const{messageIds:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>"number"==typeof e)),r=s.filter((e=>"string"==typeof e));yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){a.length>0&&(yield this._messageCache.remove(a)),r.length>0&&(yield this._notificationCache.remove(r))})))),n||this._broadcastRemoveEvent(s,i)}else if(e instanceof t.UnsentMessageRemoveEventCommand){const{reqId:s,source:i}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([s])})))),this._broadcastRemoveUnsentEvent(s,i)}else if(e instanceof t.PollChangeLogEventCommand){const{polls:s,source:i}=e;if(this._cacheContext.localCacheEnabled){const e=s.map((e=>e.messageId)),i=(yield Promise.all(e.map((e=>this._messageCache.get(e))))).filter((e=>e));i.length>0&&s.forEach((e=>{const t=i.find((t=>t.messageId===e.messageId));t&&t.applyPoll(e)})),yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert(i)}))))}this._broadcastPollChangeLogEvent(s,i)}else if(e instanceof t.PollUpdateInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollUpdateEvent(s,i)}else if(e instanceof t.PollVoteInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollVoteEvent(s,i)}else if(e instanceof t.ReactionUpdateEventCommand){const{event:t,source:s}=e;t.messageId>0&&this._broadcastReactionUpdateEvent(t,s)}else if(e instanceof t.ThreadUpdateEventCommand){const{event:t,source:s}=e;this._broadcastThreadUpdateEvent(t,s)}}))))}static of(e,t=!1){var s;return Li[e]&&!t||(Li[e]&&(null===(s=Li[e]._dispatcherContext)||void 0===s||s.close()),Li[e]=new Di(e)),Li[e]}_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)}_broadcastReactionUpdateEvent(e,t){for(const s of this._observers.values())s.onReactionUpdate&&s.onReactionUpdate(e,t)}_broadcastThreadUpdateEvent(e,t){for(const s of this._observers.values())s.onThreadInfoUpdate&&s.onThreadInfoUpdate(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const qi=20;class Fi extends t.APIRequestCommand{constructor(e){const{reverse:s=!1,limit:i=qi,keys:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}`,this.params=t.deundefined({token:a,limit:i,reverse:s,order:t.MessageTemplateListOrder.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:n})}}class Bi extends t.APIResponseCommand{constructor(e,t){super(e,t);const{next:s,has_more:i=!1,templates:n}=t;this.nextToken=s,this.hasMore=i,this.templates=n.map((e=>({template:JSON.stringify(e)})))}}class ji extends t.APIRequestCommand{constructor(e){const{key:s}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}/${s}`}}class Vi extends t.APIResponseCommand{constructor(e,t){super(e,t),this.template=JSON.stringify(t)}}const zi={};class $i{constructor(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}){this._iid=e,this._sdkState=t,this._requestQueue=i,this._dispatcher=s,this._cacheContext=a,Ri.of(e),Pi.of(e),Di.of(e),this.fileMessageQueue=new ne(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}),zi[e]=this}static of(e){return zi[e]}buildMessageFromSerializedData(e){const s=t.deserialize(e);if(s.notificationId)return new H(this._iid,H.payloadify(s));switch(s.messageType){case t.MessageType.USER:return new Q(this._iid,Q.payloadify(s));case t.MessageType.FILE:return G._isMultipleFilesMessageSerializedData(s)?new G(this._iid,G.payloadify(s)):new Y(this._iid,Y.payloadify(s));case t.MessageType.ADMIN:return new V(this._iid,V.payloadify(s))}throw t.SendbirdError.invalidParameters}buildUserMessageCreateParamsFromSerializedData(e,s){return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,message:s.message,translationTargetLanguages:Object.keys(s.translations),pollId:e.pollId}))}buildFileMessageCreateParamsFromSerializedData(e,s){var i;return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,file:e.file,fileKey:e.fileKey,fileUrl:s.plainUrl,fileName:s.name,fileSize:s.size,mimeType:s.type,thumbnailSizes:null===(i=s.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),fileType:e.fileType,requireAuth:s.requireAuth}))}buildMultipleFilesMessageCreateParamsFromSerializedData(e,s){return t.deundefined({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,fileInfoList:e.fileInfoList.map((e=>new J(this._iid,e)))})}buildScheduledUserMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildScheduledFileMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildSenderFromSerializedData(e){const s=t.deserialize(e);return new p(this._iid,p.payloadify(s))}getMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new de(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ue);return i}))}getScheduledMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new _e(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ge);return i}))}getMessagesByMessageId(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,token:String(i)},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}getMessagesByTimestamp(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}_getMessagesByTimestampForCollection(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE,r,o){return t.__awaiter(this,void 0,void 0,(function*(){const l=new ce(Object.assign(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n),{checkingHasNext:r,checkingContinuousMessages:o})),d=yield this._requestQueue.send(l),{messages:u,isContinuousMessages:c,hasNext:h}=d.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:u,source:a})),{messages:u,isContinuousMessages:c,hasNext:h}}))}getThreadedMessagesByTimestamp(e,s,i,n=t.CollectionEventSource.REQUEST_THREADED_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const a=new ce(Object.assign(Object.assign(Object.assign({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:s},B),i),{replyType:t.ReplyType.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),r=yield this._requestQueue.send(a),{messages:o}=r.as(he),l=o.slice(1);return l.forEach((t=>{t.parentMessage=e})),this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:n})),{parentMessage:o[0],threadedMessages:l}}))}getMessageTemplatesByToken(e,s={}){return t.__awaiter(this,void 0,void 0,(function*(){const t=new Fi(Object.assign({token:e},s)),i=yield this._requestQueue.send(t),{hasMore:n,nextToken:a,templates:r}=i.as(Bi);return{hasMore:n,token:a,templates:r}}))}getMessageTemplate(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new ji({key:e}),s=yield this._requestQueue.send(t),{template:i}=s.as(Vi);return{template:i}}))}getMessageChangelogs(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS){return t.__awaiter(this,void 0,void 0,(function*(){const r=new pe(t.deundefined(t.undefineNullProps(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},oe),n)))),o=yield this._requestQueue.send(r),{updatedMessages:l,deletedMessagesInfo:d,hasMore:u,nextToken:c}=o.as(me),h=d.map((e=>e.messageId));return l.length>0&&this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),h.length>0&&this._dispatcher.dispatch(new t.MessageRemoveEventCommand({messageIds:h,source:a})),{updatedMessages:l,deletedMessageIds:h,hasMore:u,token:c}}))}}class Qi extends t.InstancedObject{constructor(e,s){super(e),this.targetMessageId=0;const i=s.thread_info,n=s.parent_message_id,r=s.channel_url,o=s.channel_type;i&&t.isTypeOf("object",i)&&t.isTypeOf("number",n)&&t.isTypeOf("string",r)&&t.isTypeOf("string",o)&&(this.threadInfo=new a(e,i),this.targetMessageId=n,this.channelUrl=r,this.channelType=o)}}const Gi={channelUrl:"",channelType:t.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1};class Ki extends t.APIRequestCommand{constructor({channelCustomType:e,keyword:s,limit:i,reverse:n,exactMatch:a,channelUrl:r,order:o,messageTimestampFrom:l,messageTimestampTo:d,advancedQuery:u,targetFields:c,nextToken:h}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_SEARCH}/messages`,this.params={custom_type:e,query:s,limit:i,reverse:n,exact_match:a,channel_url:r,message_ts_from:l,message_ts_to:d,sort_field:o,advanced_query:u,target_fields:c,after:h}}}class Hi extends t.APIResponseCommand{constructor(e,t){super(e,t),this.messages=t.results.map((t=>W(e,t))),this.hasNext=t.has_next,this.nextToken=t.end_cursor,this.totalCount=t.total_count}}var Wi;exports.MessageSearchOrder=void 0,(Wi=exports.MessageSearchOrder||(exports.MessageSearchOrder={})).SCORE="score",Wi.TIMESTAMP="ts";class Yi extends t.BaseListQuery{constructor(e,t){var s,i,n,a,r,o,l,d,u;super(e,t),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=t.keyword,this.reverse=null!==(s=t.reverse)&&void 0!==s&&s,this.exactMatch=null!==(i=t.exactMatch)&&void 0!==i&&i,this.channelUrl=null!==(n=t.channelUrl)&&void 0!==n?n:"",this.channelCustomType=null!==(a=t.channelCustomType)&&void 0!==a?a:"",this.messageTimestampFrom=null!==(r=t.messageTimestampFrom)&&void 0!==r?r:null,this.messageTimestampTo=null!==(o=t.messageTimestampTo)&&void 0!==o?o:null,this.order=null!==(l=t.order)&&void 0!==l?l:exports.MessageSearchOrder.SCORE,this.advancedQuery=null!==(d=t.advancedQuery)&&void 0!==d&&d,this.targetFields=null!==(u=t.targetFields)&&void 0!==u?u:null}_validate(){return super._validate()&&t.isTypeOf("string",this.keyword)&&this.keyword.length>0&&t.isTypeOf("boolean",this.reverse)&&t.isTypeOf("boolean",this.exactMatch)&&t.isTypeOf("string",this.channelUrl)&&t.isTypeOf("string",this.channelCustomType)&&(t.isTypeOf("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(t.isTypeOf("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&t.isEnumOf(exports.MessageSearchOrder,this.order)&&t.isTypeOf("boolean",this.advancedQuery)&&t.isArrayOf("string",this.targetFields,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Ki(t.undefineNullProps(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),i=yield e.send(s),{messages:n,hasNext:a,nextToken:r,totalCount:o}=i.as(Hi);return this._nextToken=r,this._hasNext=a,this._isLoading=!1,this.totalCount=o,n}return[]}throw t.SendbirdError.invalidParameters}))}}exports.AdminMessage=V,exports.AppleCriticalAlertOptions=u,exports.BanUserEventCommand=Ot,exports.BannedUserListQuery=Ye,exports.BaseChannel=Es,exports.BaseMessage=q,exports.BaseMessageUpdateParamsDefault=Le,exports.BaseStore=_i,exports.Config=bs,exports.CreateScheduledUserMessageResponseCommand=Ht,exports.DEFAULT_FEED_LIMIT=100,exports.DEFAULT_GROUPCHANNEL_LIMIT=100,exports.DEFAULT_MESSAGE_LIMIT=100,exports.DEFAULT_NOTIFICATION_LIMIT=100,exports.Feedback=h,exports.FileMessage=Y,exports.FileMessageEventCommand=ee,exports.FreezeEventCommand=Pt,exports.IndexedDbStore=class extends _i{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:104857600})),this._storeName=vi,this._state=Ii.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}isTransactionInactiveError(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}_putToObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.put(s);n.addEventListener("success",(e=>{t(e.target.result)})),n.addEventListener("error",(()=>{i("Failed to write.")}))}))}))}_deleteFromObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.delete(s);n.addEventListener("success",(()=>t(s))),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_openDatabase(e){return new Promise(((t,s)=>{if(this._indexedDb){this._state=Ii.OPENING;const i=this._indexedDb.open(e);i.addEventListener("upgradeneeded",(e=>{e.target.result.createObjectStore(vi,{keyPath:"key"})})),i.addEventListener("success",(s=>{this._state=Ii.OPEN,this._database=s.target.result,this._openJobQueue.forEach((e=>e())),this._openJobQueue=[],this._database.onclose=()=>{this._database=void 0,this._state=Ii.OPENING,setTimeout((()=>{this._openDatabase(e)}),5)},t(this._database)})),i.addEventListener("error",(e=>{this._state=Ii.UNINITIALIZED,s(e.target.error)}))}else s(As.storeNotAvailable)}))}_getObjectStore(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);switch(this._state){case Ii.UNINITIALIZED:case Ii.OPEN:throw As.storeNotInitialized;case Ii.OPENING:case Ii.CLOSED:return new Promise((t=>{this._openJobQueue.push((()=>t(this._getObjectStore(e))))}));default:return yield this._getObjectStore(e)}}))}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readonly");return yield new Promise(((t,s)=>{const i=e.getAllKeys();i.addEventListener("success",(e=>{t(e.target.result)})),i.addEventListener("error",(e=>s(e.target.error)))}))}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readonly");return yield new Promise(((s,i)=>{const n=t.get(e);n.addEventListener("success",(e=>{var t;s(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._putToObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._putToObjectStore(t,s)}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._deleteFromObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._deleteFromObjectStore(t,s)}}))}_triggerDatabaseClose(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}checkAvailability(){return t.__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 As.storeNotAvailable;if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!ni())throw As.storeNotAvailable;if(ni()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")){if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw As.storeNotAvailableInPrivateBrowsing}else yield new Promise(((e,t)=>{if(this._indexedDb)try{const s=this._indexedDb.open("_testMozilla");s.onerror=()=>t(As.storeNotAvailableInPrivateBrowsing),s.onsuccess=s=>{if(s.target.result.close(),this._indexedDb){const t=this._indexedDb.deleteDatabase("_testMozilla");t.onerror=()=>e(),t.onsuccess=()=>e()}else t(As.storeNotAvailable)}}catch(e){t(As.storeNotAvailableInPrivateBrowsing)}else t(As.storeNotAvailable)}))}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yield this.checkAvailability(),yield this._openDatabase(e),yield this._resetIfEncryptionChanged()}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readwrite");return yield new Promise(((t,s)=>{const i=e.clear();i.addEventListener("success",(()=>t())),i.addEventListener("error",(e=>s(e.target.error)))}))}))}},exports.Logger=class{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)}},exports.MemoryStore=fi,exports.MessageBroadcast=Di,exports.MessageCache=Ri,exports.MessageFilter=Mi,exports.MessageForm=k,exports.MessageFormItem=L,exports.MessageManager=$i,exports.MessageMetaArray=m,exports.MessageRequestHandler=Ie,exports.MessageRetrievalParamsDefault=Gi,exports.MessageReviewInfo=$,exports.MessageSearchQuery=Yi,exports.MessageThreadInfoUpdatedEventCommand=N,exports.MultipleFilesMessage=G,exports.MultipleFilesMessageRequestHandler=ps,exports.MuteUserEventCommand=bt,exports.MutedUserListQuery=Ke,exports.NESTDB_FEEDCHANNEL_COLLECTION_KEY="url",exports.NESTDB_FEEDCHANNEL_COLLECTION_NAME="FeedChannel",exports.NESTDB_GROUPCHANNEL_COLLECTION_KEY="url",exports.NESTDB_GROUPCHANNEL_COLLECTION_NAME="GroupChannel",exports.NESTDB_MESSAGE_COLLECTION_KEY="messageId",exports.NESTDB_MESSAGE_COLLECTION_NAME=ds,exports.NESTDB_NOTIFICATION_COLLECTION_KEY="notificationId",exports.NESTDB_NOTIFICATION_COLLECTION_NAME=us,exports.NESTDB_POLL_COLLECTION_KEY="pollId",exports.NESTDB_POLL_COLLECTION_NAME="Poll",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY="reqId",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME=wi,exports.NestDB=class{constructor({name:e,version:t,store:s,config:i}){this.name=e,this._version=t,this._state=exports.NestDBState.INIT,this._config=i||new bs({dbname:e}),this._store=s,this._event={success:Us,error:Us,storeReplaced:Us,upgrade:ks},this._collections=new Map,this._globalMutex=new di(`${this.name}.lock`),this._config.disableLogger&&pi.off(),new Js({dbname:e,limit:this._config.cacheLimit})}get version(){return this._version}get state(){return this._state}get store(){return this._store}estimateUsage(){return t.__awaiter(this,void 0,void 0,(function*(){return yield(e=this._store,t.__awaiter(void 0,void 0,void 0,(function*(){return yield e.usage()})));var e}))}commitSchema(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._state!==exports.NestDBState.OPENING)throw As.databaseSchemaNotOnUpgrade;yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){const{collectionName:t,keyName:s,index:i=[]}=e;this._collections.has(t)||this._collections.set(t,new ui({dbname:this.name,collectionName:t,keyName:s,indexes:i,store:this._store}));const n=this._collections.get(t);n&&(yield n.init())})))))}))}open(){var e;return t.__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=(s=this.name,`${Bs(s)}.metadata`),n={version:0,collectionNames:[]},a=null!==(e=yield this._store.get(i))&&void 0!==e?e:n;return new Promise(((e,s)=>{const n=e=>{a.versiont.__awaiter(this,void 0,void 0,(function*(){if(s)e({continued:!1,err:s});else{a.version++,a.collectionNames=Array.from(this._collections.keys());try{yield this._store.set({key:i,value:a}),e({continued:!0})}catch(t){e({continued:!1,err:t})}}})))):e({continued:!1})},r=i=>{const{continued:o=!1,err:l=null}=i;if(o)setTimeout((()=>n(r)),10);else if(l)pi.error(l.message),this._globalMutex.unlock(),this._event.error(l),s(l);else{const i=[];a.collectionNames.forEach((e=>{const s=this._collections.get(e);s&&s.state===Ss.READY||i.push((()=>t.__awaiter(this,void 0,void 0,(function*(){const t=yield ui.metadataOf(this.name,e,this._store);if(t){const s=new ui({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:t.indexes,store:this._store});this._collections.set(e,s),yield s.init()}})))())})),Promise.all(i).then((()=>{this._state=exports.NestDBState.OPENED,this._globalMutex.unlock(),this._event.success(),e()})).catch((e=>{pi.error(e.message),this._globalMutex.unlock(),this._event.error(e),s(e)}))}};n(r)}))}catch(e){switch(e.code){case Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:pi.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new fi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;case Ms.STORE_NOT_AVAILABLE:pi.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 fi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;default:throw pi.error(e.message),this._globalMutex.unlock(),this._event.error(e),e}}}var s}))}close(){this._collections.forEach((e=>e.close())),this._state=exports.NestDBState.CLOSED}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this._collections.values()).map((e=>e.clear())))}))}reset(){return t.__awaiter(this,void 0,void 0,(function*(){this.close();const e=Js.get(this.name);e&&e.clearByCondition((e=>e.key.startsWith(Bs(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]=ks;else this._event[e]=Us}collection(e){const t=this._collections.get(e);if(t)return t;throw As.collectionNotReady}},exports.NestDBError=As,exports.NotificationMessage=H,exports.NotificationMessageCache=ki,exports.OGImage=l,exports.OGMetaData=d,exports.OperatorListQuery=ze,exports.PENDING_MESSAGE_DELAY=2,exports.PinnedMessage=ms,exports.PinnedMessageListQuery=ys,exports.Plugin=z,exports.PollVoteEventCommand=ls,exports.PreviousMessageListQuery=$e,exports.Reaction=o,exports.ReactionEvent=r,exports.ReadAPIRequestCommand=v,exports.ReadAPIResponseCommand=E,exports.ReadEventCommand=I,exports.ReadRequestCommand=f,exports.ReadStatus=y,exports.RestrictedUser=ve,exports.RestrictionInfo=fe,exports.ScheduledFileMessageCreateParamsDefault=Ci,exports.ScheduledUserMessageCreateParamsDefault=Oi,exports.SendableMessage=F,exports.Sender=p,exports.ThreadInfo=a,exports.ThreadInfoUpdateEvent=Qi,exports.Thumbnail=s,exports.UnbanUserEventCommand=wt,exports.UnmuteUserEventCommand=St,exports.UnsentMessageCache=Pi,exports.UpdateFileMessageEventCommand=Bt,exports.UpdateMetaCounterEventCommand=vt,exports.UpdateMetaDataEventCommand=lt,exports.UpdateUserMessageEventCommand=qt,exports.UploadFileRequestCommand=i,exports.UploadFileResponseCommand=n,exports.UploadedFileInfo=w,exports.UserMessage=Q,exports.UserMessageEventCommand=Lt,exports.UserMessageUpdateParamsDefault=qe,exports.createFileMessageCreateParams=Re,exports.createFileMessageCreateParamsFromFailedFileMessage=xe,exports.createMultipleFilesMessageCreateParams=function(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((e=>{var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((e=>({maxWidth:e.width,maxHeight:e.height}))),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))},exports.createUserMessageCreateParams=Se,exports.createUserMessageCreateParamsFromFailedUserMessage=Ae,exports.getMessageIndexBy=Si,exports.getNotificationMessageIndexBy=Ai,exports.parseMessagePayload=W,exports.payloadifyMessage=e=>{if(e.notificationId)return H.payloadify(e);switch(e.messageType){case t.MessageType.USER:return Q.payloadify(e);case t.MessageType.FILE:return e.fileInfoList?G.payloadify(e):Y.payloadify(e);case t.MessageType.ADMIN:return V.payloadify(e);default:throw t.SendbirdError.unknown}},exports.validateBaseMessageUpdateParams=De,exports.validateMessageRetrievalParams=e=>t.isTypeOf("string",e.channelUrl)&&t.isEnumOf(t.ChannelType,e.channelType)&&t.isTypeOf("number",e.messageId)&&t.isTypeOf("boolean",e.includeReactions,!0)&&t.isTypeOf("boolean",e.includeMetaArray,!0)&&t.isTypeOf("boolean",e.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",e.includeThreadInfo,!0),exports.validateScheduledFileMessageCreateParams=e=>Te(e)&&t.isTypeOf("number",e.scheduledAt)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),exports.validateScheduledUserMessageCreateParams=e=>Oe(e)&&t.isTypeOf("number",e.scheduledAt,!0),exports.validateUserMessageUpdateParams=Fe; +var e,t=require("./__bundle-1a495950.cjs");class s{constructor(e,t,s){var i,n;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(i=t.real_width)&&void 0!==i?i:t.width,this.realHeight=null!==(n=t.real_height)&&void 0!==n?n:t.height,this._requireAuth=s}static payloadify(e){return e instanceof s?t.deundefined(t.undefineNullProps({url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight})):t.deundefined(t.undefineNullProps({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class i extends t.APIRequestCommand{constructor(e){if(super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_UPLOAD}`,this.params=t.deundefined({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(let t=0;tnew s(e,t,!1))))&&void 0!==a?a:[],this.requireAuth=null!==(r=t.require_auth)&&void 0!==r&&r}}class a extends t.InstancedObject{constructor(e,s){var i,n,a,r,o;super(e),this.replyCount=0,this.memberCount=0,this.lastRepliedAt=0,this.updatedAt=0,this.replyCount=null!==(i=s.reply_count)&&void 0!==i?i:0,this.memberCount=null!==(n=s.member_count)&&void 0!==n?n:0,this.mostRepliedUsers=s.most_replies&&t.isArrayOf("object",s.most_replies)?s.most_replies.map((e=>new t.User(this._iid,e))):[],this.unreadReplyCount=null!==(a=s.unread_message_count)&&void 0!==a?a:0,this.isPushNotificationEnabled="number"==typeof s.push_enabled?s.push_enabled>0:void 0,this.lastRepliedAt=null!==(r=s.last_replied_at)&&void 0!==r?r:0,this.updatedAt=null!==(o=s.updated_at)&&void 0!==o?o:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((e=>t.User.payloadify(e))):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}get _isUpdateRequired(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}_updateFrom(e){var t,s;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(s=e.isPushNotificationEnabled)&&void 0!==s?s:this.isPushNotificationEnabled}}exports.ReactionEventOperation=void 0,(e=exports.ReactionEventOperation||(exports.ReactionEventOperation={})).ADD="add",e.DELETE="delete";class r{constructor(e){this.messageId=0,this.operation=null,this.updatedAt=0;const s=t.isTypeOf("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,n=e.operation?e.operation.toLowerCase():null,a=e.reaction,r=e.updated_at;s&&t.isTypeOf("string",i)&&t.isTypeOf("string",n)&&t.isEnumOf(exports.ReactionEventOperation,n)&&t.isTypeOf("string",a)&&a&&t.isTypeOf("number",r)&&(this.messageId=s,this.userId=i,this.key=a,this.operation=n,this.updatedAt=r)}}class o{constructor(e){var s;const i=e.key,n=null!==(s=[...e.user_ids])&&void 0!==s?s:[],a=e.updated_at;t.isTypeOf("string",i)&&i&&t.isArrayOf("string",n)&&n.length>0&&t.isTypeOf("number",a)&&(this.key=i,this.userIds=n,this.updatedAt=a);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 t.deundefined(t.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 t=this.userIds.indexOf(e.userId);switch(e.operation){case exports.ReactionEventOperation.ADD:t<0&&this.userIds.push(e.userId);break;case exports.ReactionEventOperation.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}}}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 s,i;return t.deundefined(t.undefineNullProps({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(s=e.width)&&void 0!==s?s: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 t.deundefined(t.undefineNullProps({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?l.payloadify(e.defaultImage):null}))}}class u{constructor(e){var t,s;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(s=e.volume)&&void 0!==s?s:1}serialize(){return{name:this.name,volume:this.volume}}static payloadify(e){return t.deundefined(t.undefineNullProps({name:e.name,volume:e.volume}))}}var c;exports.FeedbackRating=void 0,(c=exports.FeedbackRating||(exports.FeedbackRating={})).GOOD="good",c.BAD="bad";class h{constructor(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}static _getStatus(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}static _isSubmitted(e){return"SUBMITTED"===h._getStatus(e)}static _getPayloadByStatus(e){return"NO_FEEDBACK"===e?{}:null}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,rating:e.rating,comment:e.comment}))}}class p extends t.User{constructor(e,s){var i;super(e,s),this.isBlockedByMe=!1,this.role=t.isEnumOf(t.Role,s.role)?s.role:t.Role.NONE,this.isBlockedByMe=null!==(i=s.is_blocked_by_me)&&void 0!==i&&i}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}class m{constructor(e){this.key=e.key,this.value=t.isArrayOf("string",e.value)?[...e.value]:[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:e.key,value:null!==(s=e.value)&&void 0!==s?s:[]}))}}const _=e=>{switch(e){case t.MessageType.BASE:return"";case t.MessageType.USER:return"MESG";case t.MessageType.FILE:return"FILE";case t.MessageType.ADMIN:return"ADMM"}};class g extends t.InstancedObject{constructor(e,s){var i,n,a,r,o,l,d,u,c;super(e),this.channelType=t.ChannelType.BASE,this.messageType=t.MessageType.BASE,this.mentionType=null,this.mentionedUsers=null,this.mentionedUserIds=null,this.mentionedMessageTemplate=void 0,this.metaArrays=[],this.extendedMessage={},this.createdAt=0,this.updatedAt=0,this.channelUrl=s.channel_url,this.channelType=t.isEnumOf(t.ChannelType,s.channel_type)?s.channel_type:t.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(this.channelUrl=s.channel.channel_url),s.channel.channel_type&&(this.channelType=s.channel.channel_type)),this.data=null!==(i=s.data)&&void 0!==i?i:"",this.customType=null!==(n=s.custom_type)&&void 0!==n?n:"",this.mentionType=t.isEnumOf(t.MentionType,s.mention_type)?s.mention_type:null,this.mentionedUsers=s.mentioned_users?s.mentioned_users.map((e=>new t.User(this._iid,e))):null,this.mentionedUserIds=null!==(a=s.mentioned_user_ids)&&void 0!==a?a:null,this.mentionedUsers&&!this.mentionedUserIds&&(this.mentionedUserIds=this.mentionedUsers.map((e=>e.userId))),this.mentionedMessageTemplate=s.mentioned_message_template;const h=null!==(r=s.metaarray)&&void 0!==r?r:{},p=null!==(o=s.metaarray_key_order)&&void 0!==o?o:Object.keys(h).sort(((e,t)=>e.localeCompare(t)));this.metaArrays=[];for(let e=0;enew m(e)))),this.extendedMessage=null!==(l=s.extended_message)&&void 0!==l?l:{},this.extendedMessagePayload=s.extended_message_payload,this.createdAt=null!==(u=null!==(d=s.created_at)&&void 0!==d?d:s.ts)&&void 0!==u?u:0,this.updatedAt=null!==(c=s.updated_at)&&void 0!==c?c:0}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.channelUrl,channel_type:e.channelType,type:_(e.messageType),data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(s=e.mentionedUsers)||void 0===s?void 0:s.map((e=>t.User.payloadify(e))),mentioned_message_template:e.mentionedMessageTemplate,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>m.payloadify(e))),extended_message:e.extendedMessage,extended_message_payload:e.extendedMessagePayload,created_at:e.createdAt,updated_at:e.updatedAt})))}isIdentical(e){return!0}isEqual(e){return t.deepEqual(this,e)}isUserMessage(){return this.messageType===t.MessageType.USER}isFileMessage(){return this.messageType===t.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isMultipleFilesMessage(){return this.messageType===t.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isAdminMessage(){return this.messageType===t.MessageType.ADMIN}serialize(){return t.serialize(this)}getMetaArraysByKeys(e){return this.metaArrays.filter((t=>e.includes(t.key)))}}class y extends t.InstancedObject{constructor(e,s){var i,n;super(e),this.channelUrl=null!==(i=s.channel_url)&&void 0!==i?i:"",this.channelType=null!==(n=s.channel_type)&&void 0!==n?n:t.ChannelType.GROUP,this.reader=new t.User(this._iid,s.user),this.readAt=s.ts}}class f extends t.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class v extends t.APIRequestCommand{constructor(e){super();const{channelUrl:s,channelType:i,userId:n,notificationIds:a}=e;this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/messages/mark_as_read`,this.params=t.deundefined(t.undefineNullProps({user_id:n,message_ids:a}))}}class I extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new y(e,s)}}class E extends t.APIResponseCommand{constructor(e,t){super(e,t),this.readAt=t.ts,this.unreadMessageCount=t.unread_message_count}}class T extends t.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"READ",ackRequired:!0,payload:{channel_url:e,parent_message_id:t}})}}class b extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,pushEnabled:n}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/thread_push`,this.params={push_enabled:n}}}class M extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,rating:n,comment:a}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks`,this.params={rating:n,comment:a}}}class S extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class O extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n,rating:a,comment:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`,this.params={rating:a,comment:r}}}class A extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class C extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`}}class w extends t.InstancedObject{constructor(e,t){var i,n,a,r,o;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!==(n=t.file_name)&&void 0!==n?n:null,this.mimeType=null!==(a=t.file_type)&&void 0!==a?a:null,this.fileSize=null!==(r=t.file_size)&&void 0!==r?r:0,this._requireAuth=null!==(o=t.require_auth)&&void 0!==o&&o,this.thumbnails=t.thumbnails?t.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this._requireAuth)})):[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>{var t;return{url:(null!==(t=e.plainUrl)&&void 0!==t?t:"").split("auth=")[0],width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class N{constructor({channelUrl:e,channelType:t,parentMessage:s}){this.channelUrl=e,this.channelType=t,this.parentMessage=s}}var P,U,R,x;!function(e){e.NUMBER="number",e.ENUM="enum",e.TEXT="text",e.REGEX="regex",e.DECIMAL_PLACE="decimal_place"}(P||(P={})),exports.MessageFormItemLayout=void 0,(U=exports.MessageFormItemLayout||(exports.MessageFormItemLayout={})).TEXT="text",U.TEXTAREA="textarea",U.NUMBER="number",U.PHONE="phone",U.EMAIL="email",U.CHIP="chip";class k{constructor(e,t){const{id:s,name:i,items:n,version:a,is_submitted:r}=t;this.messageId=e,this.id=s,this.name=i,this.items=n.map((e=>new L(e))).sort(((e,t)=>e.sortOrder-t.sortOrder)),this.version=null!=a?a:1,this._isSubmitted=r}get isSubmitted(){var e;return null!==(e=this._isSubmitted)&&void 0!==e?e:this.items.some((e=>Array.isArray(e.submittedValues)))}get isSubmittable(){return this.items.every((e=>e.required?!!(Array.isArray(e.draftValues)&&e.draftValues.length>0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,items:e.items.map((e=>L.payloadify(e))),version:e.version,is_submitted:e._isSubmitted}))}static isMessageFormPayload(e){return Boolean(null==e?void 0:e.message_form)}}class L{constructor(e){const{id:s,name:i,required:n,sort_order:a,placeholder:r,style:o,item_type:l,validators:d,value:u,values:c}=e;this.id=s,this.name=i,this.required=n,this.sortOrder=a,this.placeholder=r,0===Object.keys(o).length?this.style={layout:l}:this.style=t.deundefined({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),c?this.submittedValues=c:u&&(this.submittedValues=[u]),this._validators=d}isValid(e){return e.every((e=>{const t=function(e,t){return t.every((t=>{switch(t.key){case P.NUMBER:{const s=Number(e);return!(isNaN(s)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&st.max)}case P.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case P.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case P.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case P.DECIMAL_PLACE:{if(0===e.length)return!1;const s=Number(e);return!(isNaN(s)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){const s=e.toString(),i=s.indexOf(".");return-1===i||s.slice(i+1).length<=t}(s,t.max_decimal_place))}default:return!0}}))}(e,this._validators);return t}))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:t.deundefined({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}class D extends t.APIRequestCommand{constructor(e){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_FORMS}/${e.formId}/submit`,this.params=t.deundefined({message_id:e.messageId,items:e.items})}}exports.ScheduledStatus=void 0,(R=exports.ScheduledStatus||(exports.ScheduledStatus={})).PENDING="pending",R.SENT="sent",R.FAILED="failed",R.CANCELED="canceled",exports.InternalScheduledStatus=void 0,(x=exports.InternalScheduledStatus||(exports.InternalScheduledStatus={})).PENDING="pending",x.IN_QUEUE="in_queue",x.SENT="sent",x.FAILED="failed",x.CANCELED="canceled",x.REMOVED="removed";class q extends g{constructor(e,t){var s,i,n,r,l,c,p,m;super(e,t),this.parentMessage=null,this.silent=!1,this.isOperatorMessage=!1,this.threadInfo=null,this.reactions=[],this.appleCriticalAlertOptions=null,this.scheduledInfo=null,this.suggestedReplies=null,this.myFeedback=null,this.myFeedbackStatus="NOT_APPLICABLE",this.messageForm=null,this._isContinuousMessages=!1,this._scheduledStatus=null,this.messageId=null!==(i=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==i?i:0,this.parentMessageId=null!==(n="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==n?n:0,this.threadInfo=t.thread_info?new a(this._iid,t.thread_info):null,this.reactions=t.reactions?t.reactions.map((e=>new o(e))):[],this.ogMetaData=t.og_tag?new d(t.og_tag):null,this.silent=null!==(r=t.silent)&&void 0!==r&&r,this.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,this.appleCriticalAlertOptions=t.apple_critical_alert_options?new u(t.apple_critical_alert_options):null,"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._isContinuousMessages=null!==(c=t.is_continuous_messages)&&void 0!==c&&c,this.myFeedback=h._isSubmitted(t.feedback)?new h(t.feedback):null,this.myFeedbackStatus=h._getStatus(t.feedback),this.suggestedReplies=null!==(m=null===(p=t.extended_message_payload)||void 0===p?void 0:p.suggested_replies)&&void 0!==m?m:null,this.messageForm=k.isMessageFormPayload(t.extended_message_payload)?new k(this.messageId,t.extended_message_payload.message_form):null}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?a.payloadify(e.threadInfo):null,reactions:e.reactions.map((e=>o.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?u.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledMessageId,scheduled_at:null===(i=e.scheduledInfo)||void 0===i?void 0:i.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?h.payloadify(e.myFeedback):h._getPayloadByStatus(e.myFeedbackStatus)})))}static _getParentMessageInfoPayload(e){return t.deundefined(t.undefineNullProps({type:_(e.messageType),ts:e.createdAt,user:e.sender?p.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null}))}isIdentical(e){return this.messageId===e.messageId}applyThreadInfoUpdateEvent(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}applyReactionEvent(e){if(this.messageId===e.messageId){let t=!1;for(let s=0;s=t)return this.parentMessage=e,!0}return!1}_triggerThreadInfoUpdatedEvent(){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e}=t.Vault.of(this._iid);e.dispatch(new N({channelType:t.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))}))}markThreadAsRead(){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=t.Vault.of(this._iid),s=new T({channelUrl:this.channelUrl,messageId:this.messageId});yield e.send(s),this.threadInfo&&0!==this.threadInfo.unreadReplyCount&&(this.threadInfo.unreadReplyCount=0,yield this._triggerThreadInfoUpdatedEvent())}))}setPushNotificationEnabled(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),i=new b({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e});yield s.send(i),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e)}))}submitMessageForm(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid);let i=null,n=null;const a=this.messageForm;if(!e&&a){if(!a.isSubmittable)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(a.isSubmitted)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});i=a.id,n=a.items.reduce(((e,t)=>(e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e)),[])}else e&&(i=e.formId,n=Object.entries(e.answers).reduce(((e,[s,i])=>{const n=Number(s);if(Number.isNaN(n))throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:n,value:i}),e}),[]));if(!i||!n)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});const r=new D({messageId:this.messageId,formId:i,items:n});yield s.send(r)}))}submitFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new M({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(S);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}))}))}updateFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new O({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(A);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}))}))}deleteFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new C({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e});yield s.send(n),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}))}))}}class F extends q{constructor(e,s){var i,n,a,r;if(super(e,s),this.reqId="",this.replyToChannel=!1,this.errorCode=0,this.sender=s.user?new p(this._iid,s.user):s.sender_id,this.reqId=null!==(n=null!==(i=s.req_id)&&void 0!==i?i:s.request_id)&&void 0!==n?n:"",this.replyToChannel=null!==(a=s.is_reply_to_channel)&&void 0!==a&&a,s.request_state&&t.isEnumOf(t.SendingStatus,s.request_state)&&(this.sendingStatus=s.request_state),!this.sendingStatus)if(this.messageId>0)this.sendingStatus=t.SendingStatus.SUCCEEDED;else if(this.scheduledInfo)switch(s.scheduled_status&&(this._scheduledStatus=s.scheduled_status),s.scheduled_status){case exports.InternalScheduledStatus.SENT:case exports.InternalScheduledStatus.IN_QUEUE:this.sendingStatus=t.SendingStatus.SUCCEEDED;break;case exports.InternalScheduledStatus.PENDING:this.sendingStatus=t.SendingStatus.SCHEDULED;break;case exports.InternalScheduledStatus.FAILED:case exports.InternalScheduledStatus.REMOVED:this.sendingStatus=t.SendingStatus.FAILED;break;case exports.InternalScheduledStatus.CANCELED:this.sendingStatus=t.SendingStatus.CANCELED}else this.sendingStatus=t.SendingStatus.PENDING;this.errorCode=null!==(r=s.error_code)&&void 0!==r?r:0,this._messageToken=s.mesg_token}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{user:p.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}get isResendable(){return(this.sendingStatus===t.SendingStatus.FAILED||this.sendingStatus===t.SendingStatus.CANCELED)&&t.isResendableError(this.errorCode)}isIdentical(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}const B={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},j=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo);class V extends q{constructor(e,s){var i,n,a,r;if(super(e,s),this.translations={},this.message=null!==(i=s.message)&&void 0!==i?i:"",this.messageType=t.MessageType.ADMIN,this.translations=null!==(n=s.translations)&&void 0!==n?n:{},s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(a=i.file)||void 0===a?void 0:a.url,require_auth:null===(r=i.file)||void 0===r?void 0:r.require_auth}))))}}static payloadify(e){return t.deundefined(t.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,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class z{constructor(e){var s,i;this.detail={},this.type=null!==(s=e.type)&&void 0!==s?s:"",this.vendor=null!==(i=e.vendor)&&void 0!==i?i:"",e.detail&&t.isTypeOf("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}static payloadify(e){return t.deundefined(t.undefineNullProps({type:e.type,vendor:e.vendor,detail:e.detail}))}}class ${constructor(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}static payloadify(e){return t.deundefined({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}class Q extends F{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.message="",this.messageParams=null,this.translations={},this.translationTargetLanguages=[],this.messageSurvivalSeconds=-1,this.plugins=[],this._poll=null,this.message=s.message,this.messageType=t.MessageType.USER,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},this.translationTargetLanguages=null!==(n=s.target_langs)&&void 0!==n?n:[],0===Object.keys(this.translations).length&&this.translationTargetLanguages.length>0)for(const e of this.translationTargetLanguages)this.translations[e]="";if(this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,this.plugins=s.plugins?s.plugins.map((e=>new z(e))):[],this._poll=s.poll?new t.Poll(this._iid,s.poll):null,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(o=i.file)||void 0===o?void 0:o.require_auth}))))}s.review_info&&(this.messageReviewInfo=new $(s.review_info))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((e=>z.payloadify(e))),poll:e._poll?t.Poll.payloadify(e._poll):null,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null,review_info:e.messageReviewInfo?$.payloadify(e.messageReviewInfo):void 0})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.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 G extends F{constructor(e,s){var i,n,a,r,o,l,d,u;if(super(e,s),this.messageParams=null,this.fileInfoList=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE,this.data=null!==(a=null!==(n=null===(i=s.file)||void 0===i?void 0:i.data)&&void 0!==n?n:s.custom)&&void 0!==a?a:"",this.fileInfoList=null!==(o=null===(r=s.files)||void 0===r?void 0:r.map((t=>new w(e,t))))&&void 0!==o?o:[],this.messageSurvivalSeconds=null!==(l=s.message_survival_seconds)&&void 0!==l?l:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(d=i.file)||void 0===d?void 0:d.url,require_auth:null===(u=i.file)||void 0===u?void 0:u.require_auth}))))}}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}static payloadify(e){var s,i,n,a,r,o;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{file:{name:null!==(i=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.fileName)&&void 0!==i?i:"",size:null!==(a=null===(n=e.fileInfoList[0])||void 0===n?void 0:n.fileSize)&&void 0!==a?a:0,type:null!==(o=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}static _isMultipleFilesMessagePayload(e){const t=e.files;return Array.isArray(t)&&t.length>=2}static _isMultipleFilesMessageSerializedData(e){const t=e.fileInfoList;return Array.isArray(t)}}var K;exports.NotificationMessageStatus=void 0,(K=exports.NotificationMessageStatus||(exports.NotificationMessageStatus={})).SENT="SENT",K.READ="READ";class H extends g{constructor(e,s){var i,n;if(super(e,s),this.notificationData=null,this.notificationId=s.notification_message_id,this.messageType=t.MessageType.ADMIN,this.messageStatus=null!==(i=s.message_status)&&void 0!==i?i:exports.NotificationMessageStatus.SENT,this.priority=null!==(n=s.priority)&&void 0!==n?n:t.NotificationPriority.NORMAL,this.notificationEventDeadline=s.notification_event_deadline,0===this.extendedMessage.sub_type)try{const{label:e,tags:t=[],template_key:s,template_variables:i}=JSON.parse(this.extendedMessage.sub_data);this.notificationData={label:e,tags:t,templateKey:s,templateVariables:i}}catch(e){}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}isIdentical(e){return this.notificationId===e.notificationId}}const W=(e,t)=>{if(t.notification_message_id)return new H(e,t);switch(t.type){case"MESG":return new Q(e,t);case"FILE":return G._isMultipleFilesMessagePayload(t)?new G(e,t):new Y(e,t);case"ADMM":case"BRDM":return new V(e,t);default:return null}};class Y extends F{constructor(e,i){var n,a,r,o,l,d,u,c,h,p,m,_,g,y;super(e,i),this.messageParams=null,this.plainUrl="",this.requireAuth=!1,this.thumbnails=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE;const f=i.file;if(this.plainUrl=(null!==(a=null!==(n=null==f?void 0:f.url)&&void 0!==n?n:i.url)&&void 0!==a?a:"").split("?auth=")[0],this.name=null!==(o=null!==(r=null==f?void 0:f.name)&&void 0!==r?r:i.name)&&void 0!==o?o:"File",this.size=null!==(d=null!==(l=null==f?void 0:f.size)&&void 0!==l?l:i.size)&&void 0!==d?d:0,this.data=null!==(c=null!==(u=null==f?void 0:f.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",this.type=f?null!==(h=f.type)&&void 0!==h?h:"":null!==(p=i.type)&&void 0!==p?p:"",this.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,this.thumbnails=i.thumbnails?i.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this.requireAuth)})):[],this.messageSurvivalSeconds=null!==(_=i.message_survival_seconds)&&void 0!==_?_:-1,i.parent_message_info){const s=i.parent_message_info;this.parentMessage=W(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},s),{created_at:s.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:s.file,url:null===(g=s.file)||void 0===g?void 0:g.url,require_auth:null===(y=s.file)||void 0===y?void 0:y.require_auth}))))}}static payloadify(e){var s;return t.deundefined(t.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===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.plainUrl,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}=t.Vault.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class J extends t.InstancedObject{static getPlainUrl(e){return e instanceof J?e._plainUrl:e.fileUrl}constructor(e,{file:t,fileUrl:s,fileName:i,fileSize:n,mimeType:a,thumbnailSizes:r,_uploadedMetaData:o,_thumbnails:l}){super(e),this._plainUrl=s,this.file=t,this.fileName=i,this.fileSize=n,this.mimeType=a,this.thumbnailSizes=r,this._uploadedMetaData=o,this._thumbnails=l}get fileUrl(){var e;const{sessionManager:s}=t.Vault.of(this._iid);return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&s.ekey?`${this._plainUrl}?auth=${s.ekey}`:this._plainUrl}set fileUrl(e){this._plainUrl=e}toJSON(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}class X extends t.WebSocketRequestCommand{constructor(e){var i,n,a,r;let o=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((e=>e.userId)))),super({code:"FILE",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,files:e.files?se(e.files):null,url:e.url,name:null!==(i=e.fileName)&&void 0!==i?i:"",type:null!==(n=e.mimeType)&&void 0!==n?n:"",size:null!==(a=e.fileSize)&&void 0!==a?a:0,custom:e.data,custom_type:e.customType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((e=>s.payloadify(e))),require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:o,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?u.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 Z extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId)))),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e.channelType)}/${encodeURIComponent(e.channelUrl)}/messages`,this.params=t.deundefined(t.undefineNullProps({message_type:t.MessageType.FILE,user_id:e.userId,files:e.files?se(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===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:e.requireAuth,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((e=>m.payloadify(e))),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}))}}class ee extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"FILE",i),this.message=i.files&&i.files.length>=2?new G(e,i):new Y(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class te extends t.APIResponseCommand{constructor(e,s){var i,n,a,r;super(e,s),this.message=s.files&&s.files.length>=2?new G(e,s):new Y(e,s);const{sdkState:o}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(a=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(n=this.message.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)))&&void 0!==a?a:[],o.userId),this.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r}}function se(e){return e.map((e=>{var i,n;return t.deundefined(t.undefineNullProps({url:J.getPlainUrl(e),file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var ie;!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"}(ie||(ie={}));class ne{constructor(e,{sdkState:s,dispatcher:i,requestQueue:n,onlineDetector:a,cacheContext:r}){this._queueMap=new Map,this._iid=e,this._sdkState=s,this._requestQueue=n,this._cacheContext=r,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof t.ConnectionStateChangeCommand&&(this._connectionState=e.stateType)})),this._onlineDetector=a}get _shouldSendThroughWebSocket(){return this._connectionState===t.ConnectionStateType.CONNECTED||this._connectionState===t.ConnectionStateType.CONNECTING||this._connectionState===t.ConnectionStateType.RECONNECTING}_sendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._createSendFileMessageRequestParams(e,s);if(this._shouldSendThroughWebSocket){const e=new X(t),s=yield this._requestQueue.send(e),{message:i}=s.as(ee);return i}{const e=new Z(Object.assign(Object.assign({},t),{userId:this._sdkState.userId})),s=yield this._requestQueue.send(e),{message:i}=s.as(te);return i}}))}_createSendFileMessageRequestParams(e,t){const s=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){const e=t.params;s.files=e.fileInfoList}else{const e=t.params;s.url=e.fileUrl,s.requireAuth=e.requireAuth}return s}_resolveMessageQueue(e){var s;return t.__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 n=[];let a=!0;for(const r of i.messageQueue)switch(r.state){case ie.PENDING:case ie.UPLOADING:a=!1,n.push(r);break;case ie.UPLOADED:if(a)try{r.state=ie.SENDING;const s=yield this._sendFileMessage(e,r);r.deferred.resolve(s),yield t.sleep(100)}catch(e){r.deferred.reject(e)}else n.push(r);break;case ie.FAILED:{const e=null!==(s=r.error)&&void 0!==s?s:t.SendbirdError.unknown;r.deferred.reject(e.code===t.SendbirdErrorCode.REQUEST_CANCELED?t.SendbirdError.fileUploadCanceled:e);break}}const r=i.isResolveRequestPending;i.messageQueue=n,i.isResolving=!1,i.isResolveRequestPending=!1,r&&(yield this._resolveMessageQueue(e))}}))}_uploadNextPendingItem(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i){const n=i.messageQueue.find((e=>e.state===ie.PENDING));if(n){if(n.multipleFileUploadInfo){const{uploadIndex:a,uploadCount:r,requestHandler:o}=n.multipleFileUploadInfo,l=n.params,d=l.fileInfoList[a];t.isFile(d.file)&&!(null===(s=d._uploadedMetaData)||void 0===s?void 0:s.isUploaded)?yield this._tryUploadNextItemAndUpdateItemState(e,i,n):n.state=ae.requestId===t.requestId));s>=0&&e.uploadQueue.splice(s,1)}_uploadNextFileForSingleFileItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const t=new i({file:a.file,channelUrl:e.url,thumbnailSizes:a.thumbnailSizes,requestId:s.requestId}),d=yield this._requestQueue.send(t),{url:u,fileSize:c=a.fileSize,thumbnails:h=[],requireAuth:p=!1}=d.as(n);a.fileName=null!==(r=a.fileName)&&void 0!==r?r:a.file.name,a.mimeType=null!==(o=a.mimeType)&&void 0!==o?o:a.file.type,a.fileSize=null!==(l=a.fileSize)&&void 0!==l?l:a.file.size,a.fileUrl=u,a.fileSize=c,a.requireAuth=p,a._thumbnails=h}))}_uploadNextFileForMultipleFilesItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const{uploadIndex:t}=s.multipleFileUploadInfo,d=a.fileInfoList[t],u=new i({file:d.file,channelUrl:e.url,thumbnailSizes:d.thumbnailSizes,requestId:s.requestId}),c=yield this._requestQueue.send(u),{url:h,fileSize:p=d.fileSize,thumbnails:m,requireAuth:_=!1}=c.as(n);d.fileName=null!==(r=d.fileName)&&void 0!==r?r:d.file.name,d.mimeType=null!==(o=d.mimeType)&&void 0!==o?o:d.file.type,d.fileSize=null!==(l=d.fileSize)&&void 0!==l?l:d.file.size,d.file=void 0,d.fileUrl=h,d.fileSize=p,d._thumbnails=m,d._uploadedMetaData=Object.assign(Object.assign({},d._uploadedMetaData),{requireAuth:_,isUploaded:!0}),d instanceof J||(a.fileInfoList[t]=new J(this._iid,d))}))}request(e,s,i,n={}){return t.__awaiter(this,void 0,void 0,(function*(){if(!this._queueMap.has(e.url)){const t={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1};this._queueMap.set(e.url,t)}const a=this._queueMap.get(e.url),r=new t.Deferred,o={requestId:s,params:i,state:ie.PENDING,deferred:r};if(function(e){return"fileInfoList"in e}(i)){const e=i,t=Object.assign({uploadIndex:0,uploadCount:e.fileInfoList.length},n);o.multipleFileUploadInfo=t}return a.messageQueue.push(o),this._uploadNextPendingItem(e),r.promise}))}cancel(e,s){const i=this._queueMap.get(e.url);if(i){const n=s?[i.messageQueue.find((e=>e.requestId===s))]:[...i.messageQueue];for(const s of n)if(s)switch(s.state){case ie.PENDING:if(s.state=ie.FAILED,s.error=t.SendbirdError.requestCanceled,s.multipleFileUploadInfo&&!s.multipleFileUploadInfo.isCopy){const{uploadIndex:e,requestHandler:i}=s.multipleFileUploadInfo,n=s.params.fileInfoList[e];null==i||i._triggerOnFileUploaded(s.requestId,e,n,t.SendbirdError.fileUploadCanceled)}this._resolveMessageQueue(e);break;case ie.UPLOADING:this._requestQueue.cancel(s.requestId),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s.requestId}))}}else s&&(this._requestQueue.cancel(s),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s})))}}const ae={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:t.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},re=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo)&&t.isTypeOf("boolean",e.showSubchannelMessagesOnly),oe={replyType:t.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},le=e=>t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo);class de extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,includeMetaArray:n,includeReactions:a,includeThreadInfo:r,includeParentMessageInfo:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}`,this.params={is_sdk:!0,with_sorted_meta_array:n,include_reactions:a,include_thread_info:r,include_parent_message_info:o,include_poll_details:!0}}}class ue extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}class ce extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,prevResultSize:a,nextResultSize:r,isInclusive:o,reverse:l,messageTypeFilter:d,customTypesFilter:u,senderUserIdsFilter:c,replyType:h,includeMetaArray:p,includeReactions:m,parentMessageId:_,includeThreadInfo:g,includeParentMessageInfo:y,showSubchannelMessagesOnly:f,checkingHasNext:v,checkingContinuousMessages:I}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages`,this.params=t.deundefined(t.undefineNullProps({is_sdk:!0,prev_limit:a,next_limit:r,include:o,reverse:l,message_ts:i,message_id:n,message_type:null!=d?d:null,custom_types:u,sender_ids:c,include_reply_type:h,with_sorted_meta_array:p,include_reactions:m,parent_message_id:_,include_thread_info:g,include_parent_message_info:y,show_subchannel_message_only:f,include_poll_details:!0,checking_has_next:v,checking_continuous_messages:I}))}}class he extends t.APIResponseCommand{constructor(e,t){super(e,t),void 0!==t.is_continuous_messages&&(this.isContinuousMessages=t.is_continuous_messages),void 0!==t.has_next&&(this.hasNext=t.has_next),this.messages=t.messages.map((t=>W(e,t)))}}class pe extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,replyType:a,includeMetaArray:r,includeReactions:o,includeThreadInfo:l,includeParentMessageInfo:d}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/changelogs`,this.params={change_ts:i,token:n,with_sorted_meta_array:r,include_reactions:o,include_thread_info:l,include_reply_type:a,include_parent_message_info:d,include_poll_details:!0}}}class me extends t.APIResponseCommand{constructor(e,t){super(e,t),this.updatedMessages=t.updated.map((t=>W(e,t))),this.deletedMessagesInfo=t.deleted.map((e=>({messageId:e.message_id,deletedAt:e.deleted_at}))),this.hasMore=t.has_more,this.nextToken=t.next}}class _e extends t.APIRequestCommand{constructor({channelUrl:e,scheduledMessageId:s}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/scheduled_messages/${encodeURIComponent(s)}`,this.params={}}}class ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}var ye;exports.RestrictionType=void 0,(ye=exports.RestrictionType||(exports.RestrictionType={})).MUTED="muted",ye.BANNED="banned";class fe{constructor(e){var s,i,n,a;this.restrictionType=null,t.isEnumOf(exports.RestrictionType,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(s=e.description)&&void 0!==s?s:null,this.endAt=null!==(n=null!==(i=e.end_at)&&void 0!==i?i:e.muted_end_at)&&void 0!==n?n:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}static payloadify(e){return t.deundefined(t.undefineNullProps({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}class ve extends t.User{constructor(e,t){super(e,t),this.restrictionInfo=new fe(t)}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),fe.payloadify(e.restrictionInfo))))}}class Ie{constructor(){this._onPending=t.noop,this._onFailed=t.noop,this._onSucceeded=t.noop}_trigger(e){switch(null==e?void 0:e.sendingStatus){case t.SendingStatus.PENDING:0===e.errorCode&&this._onPending(e);break;case t.SendingStatus.SCHEDULED:case t.SendingStatus.SUCCEEDED:this._onSucceeded(e)}}_triggerFailed(e,s){switch(null==s?void 0:s.sendingStatus){case t.SendingStatus.FAILED:case t.SendingStatus.CANCELED:this._onFailed(e,s.scheduledInfo?null:s)}}onPending(e){return this._onPending=e,this}onFailed(e){return this._onFailed=e,this}onSucceeded(e){return this._onSucceeded=e,this}}const Ee={data:void 0,customType:void 0,mentionType:t.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},Te=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isTypeOf("number",e.parentMessageId,!0)&&t.isTypeOf("boolean",e.isReplyToChannel)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0)&&t.isTypeOf("boolean",e.isPinnedMessage,!0),be=e=>({isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}),Me=Object.assign(Object.assign({},Ee),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function Se(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}const Oe=e=>{var s;return t.deundefined(t.undefineNullProps({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(s=e.poll)||void 0===s?void 0:s.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations),extendedMessagePayload:e.extendedMessagePayload}))},Ae=e=>Te(e)&&t.isTypeOf("string",e.message)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0)&&t.isTypeOf("object",e.extendedMessagePayload,!0);var Ce;!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Ce||(Ce={}));const we=e=>"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob,Ne=e=>e===Ce.BLOB||e===Ce.FILE,Pe=e=>({file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}),Ue=Object.assign(Object.assign({},Ee),{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});function Re(e){var s,i,n,a;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=e.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails}))}const xe=(e,s)=>{var i;return e.messageParams?(!e.url&&t.isFile(s)&&(e.messageParams.file=s),e.messageParams):t.deundefined(t.undefineNullProps({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:s,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height})))}))},ke=e=>Te(e)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),Le={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},De=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0),qe=Object.assign(Object.assign({},Le),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Fe=e=>De(e)&&t.isTypeOf("string",e.message,!0)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0),Be=Object.assign({},Le);class je extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,token:i,limit:n}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(e)}/operators`,this.params={token:i,limit:n}}}class Ve extends t.APIResponseCommand{constructor(e,s){super(e,s),this.operators=s.operators.map((s=>new t.User(e,s))),this.token=s.next}}class ze extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;{const e=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new je(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),i=yield e.send(s),{operators:n,token:a}=i.as(Ve);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return e}}throw t.SendbirdError.invalidParameters}))}}class $e extends t.ChannelDataListQuery{constructor(e,s,i,n){var a,r,o,l,d,u,c,h,p,m;super(e,s,i,n),this.reverse=!1,this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.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!==(a=n.reverse)&&void 0!==a&&a,this.messageTypeFilter=null!==(r=n.messageTypeFilter)&&void 0!==r?r:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,this.senderUserIdsFilter=null!==(l=n.senderUserIdsFilter)&&void 0!==l?l:null,this.replyType=null!==(d=n.replyType)&&void 0!==d?d:t.ReplyType.NONE,this.includeMetaArray=null!==(u=n.includeMetaArray)&&void 0!==u&&u,this.includeReactions=null!==(c=n.includeReactions)&&void 0!==c&&c,this.includeParentMessageInfo=null!==(h=n.includeParentMessageInfo)&&void 0!==h&&h,this.includeThreadInfo=null!==(p=n.includeThreadInfo)&&void 0!==p&&p,this.showSubchannelMessagesOnly=null!==(m=n.showSubchannelMessagesOnly)&&void 0!==m&&m}_validate(){return super._validate()&&t.isTypeOf("boolean",this.reverse)&&t.isEnumOf(t.MessageTypeFilter,this.messageTypeFilter)&&t.isEnumOf(t.ReplyType,this.replyType)&&t.isArrayOf("string",this.customTypesFilter,!0)&&t.isArrayOf("string",this.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",this.includeMetaArray)&&t.isTypeOf("boolean",this.includeReactions)&&t.isTypeOf("boolean",this.includeParentMessageInfo)&&t.isTypeOf("boolean",this.includeThreadInfo)&&t.isTypeOf("boolean",this.showSubchannelMessagesOnly)}load(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=$i.of(this._iid),s=yield e.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t.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,...s.map((e=>e.createdAt))),this._hasNext=s.length>=this.limit,this._isLoading=!1,s}return[]}throw t.SendbirdError.invalidParameters}))}}class Qe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={limit:n,token:a}}}class Ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.mutedUsers=[];const{next:s,muted_list:i}=t;this.token=s,i&&i.length>0&&(this.mutedUsers=i.map((t=>new ve(e,t))))}}class Ke extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Qe(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{mutedUsers:n,token:a}=i.as(Ge);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class He extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({limit:n,token:a})}}class We extends t.APIResponseCommand{constructor(e,t){super(e,t),this.bannedUsers=[];const{next:s,banned_list:i}=t;this.token=s,i&&i.length>0&&(this.bannedUsers=i.map((t=>new ve(e,t.user))))}}class Ye extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new He(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{bannedUsers:n,token:a}=i.as(We);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}var Je;exports.ReportCategory=void 0,(Je=exports.ReportCategory||(exports.ReportCategory={})).SPAM="spam",Je.HARASSING="harassing",Je.SUSPICIOUS="suspicious",Je.INAPPROPRIATE="inappropriate";class Xe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class Ze extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${n}`}}class tt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.isMuted=!1,this.startAt=0,this.endAt=0;const{is_muted:s,start_at:i,end_at:n,remaining_duration:a,description:r}=t;this.isMuted=s,this.startAt=i,this.endAt=n,this.remainingDuration=a,this.description=r}}class st extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={keys:n,include_ts:!0}}}class it extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0}}}class at extends t.APIResponseCommand{constructor(e,t){var s,i;super(e,t),this.metaData=null!==(s=t.metadata)&&void 0!==s?s:{},this.ts=null!==(i=t.ts)&&void 0!==i?i:null}}class rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n,upsert:a}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0,upsert:null!=a&&a}}}class ot extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class lt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class dt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata/${n}`,this.params={include_ts:!0}}}class ut extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={include_ts:!0}}}class ht extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class pt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={keys:n}}}class mt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class _t extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n}}}class gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class yt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n,upsert:a=!1,mode:r="set"}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n,upsert:a,mode:r}}}class ft extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class vt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class It extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter/${n}`,this.params={}}}class Et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={}}}class Tt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={user_id:n,seconds:a,description:r}}}class bt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Mt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${encodeURIComponent(n)}`}}class St extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Ot extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({user_id:n,seconds:a,description:r})}}class At extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data),s.data.member_count&&(this.memberCount=s.data.member_count),s.data.joined_member_count&&(this.joinedMemberCount=s.data.joined_member_count)}}class Ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban/${encodeURIComponent(n)}`}}class wt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,freezing:n}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/freeze`,this.params={freeze:n}}}class Pt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.freeze=s.data.freeze}}class Ut extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}`,this.params={report_category:n,reporting_user_id:a,report_description:r}}}class Rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,description:o}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_REPORT}/users/${r}`,this.params={channel_url:s,channel_type:i===t.ChannelType.OPEN?"open_channels":"group_channels",report_category:n,reporting_user_id:a,report_description:o}}}class xt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,messageId:o,description:l,messageToken:d}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}/messages/${o}`,this.params=t.deundefined({report_category:n,reporting_user_id:a,report_description:l,offending_user_id:r,mesg_token:d})}}class kt extends t.WebSocketRequestCommand{constructor(e){let s=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MESG",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage,extended_message_payload:e.extendedMessagePayload}))})}}class Lt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"MESG",i),this.message=new Q(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class Dt extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,poll_id:e.pollId}))})}}class qt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"MEDI",i),this.message=new Q(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class Ft extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"FEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,apple_critical_alert_options:e.appleCriticalAlertOptions}))})}}class Bt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"FEDI",i),this.message=new Y(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class jt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class Vt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(t)}}class zt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class $t extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(Object.assign({},t))}}class Qt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,translationTargetLanguages:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}/translation`,this.params={target_langs:n}}}class Gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Kt extends t.APIRequestCommand{constructor(e){var s;super();let i=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:a}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(n)}/${encodeURIComponent(a)}/scheduled_messages`,this.params=t.deundefined(t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class Ht extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Wt extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId))));const{channelType:r,channelUrl:o}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(r)}/${encodeURIComponent(o)}/scheduled_messages`,this.params=t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.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((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})}}class Yt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Y(e,t)}}class Jt extends t.APIRequestCommand{constructor({pollId:e,title:s,data:i,allowUserSuggestion:n,allowMultipleVotes:a,closeAt:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`,this.params={title:s,data:i,allow_user_suggestion:n,allow_multiple_votes:a,close_at:r}}}class Xt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Zt extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`}}class es extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/close`}}class ts extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ss extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,pollId:i,optionText:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(i)}/options`,this.params={channel_url:e,channel_type:s,text:n}}}class is extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ns extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s,optionText:i}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`,this.params={text:i}}}class as extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class rs extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`}}class os extends t.WebSocketRequestCommand{constructor({reqId:e,channelType:s,channelUrl:i,pollId:n,pollOptionIds:a}){super({code:"VOTE",ackRequired:!0,payload:t.deundefined({req_id:e,channel_type:s===t.ChannelType.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:n,option_ids:a})})}}class ls extends t.WebSocketEventCommand{constructor(e,s,i){super(e,"VOTE",i),this.event=new t.PollVoteEvent(i),this.channelUrl=i.channel_url,this.channelType=i.channel_type}}const ds="Message",us="NotificationMessage";const cs=Object.assign(Object.assign({},Ee),{fileInfoList:[]}),hs=e=>(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>e.maxWidth>0&&e.maxHeight>0)));class ps extends Ie{constructor(){super(...arguments),this._onFileUploaded=t.noop}_triggerOnFileUploaded(e,t,s,i){this._onFileUploaded(e,t,s,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}}class ms extends t.InstancedObject{constructor(e,t){super(e),this.message=null,this.message=W(e,t.message)}}class _s extends t.APIRequestCommand{constructor(e){const{channelType:s,channelUrl:i,limit:n,token:a,includeReactions:r,includeMetaArray:o,includeParentMessageInfo:l,includeThreadInfo:d,includePollDetails:u}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(i)}/pinned_messages`,this.params=t.deundefined({limit:n,token:a,include_reactions:r,with_sorted_meta_array:o,include_thread_info:d,include_parent_message_info:l,include_poll_details:u})}}class gs extends t.APIResponseCommand{constructor(e,t){super(e,t);const{pinned_messages:s,has_more:i,next:n}=t;this.pinnedMessages=s.map((t=>new ms(e,t))),this.hasMore=i,this.token=n}}class ys extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i),this.includeMetaArray=i.includeMetaArray,this.includeReactions=i.includeReactions,this.includeParentMessageInfo=i.includeParentMessageInfo,this.includeThreadInfo=i.includeThreadInfo,this.includePollDetails=i.includePollDetails}_validate(){return super._validate()&&t.isTypeOf("boolean",this.includeMetaArray,!0)&&t.isTypeOf("boolean",this.includeReactions,!0)&&t.isTypeOf("boolean",this.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",this.includeThreadInfo,!0)&&t.isTypeOf("boolean",this.includePollDetails,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new _s(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{pinnedMessages:n,hasMore:a,token:r}=i.as(gs);return this._token=r,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class fs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}class vs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}var Is;exports.SendMessageRequestType=void 0,(Is=exports.SendMessageRequestType||(exports.SendMessageRequestType={})).SEND="send",Is.RESEND="resend",Is.COPY="copy";class Es extends t.InstancedObject{get url(){return this._url}get name(){return this._name}set name(e){this._name=e}get createdAt(){return this._createdAt}toJSON(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}constructor(e,s){var i,n,a,r,o,l,d;super(e),this._name="",this._createdAt=0,this.pinnedMessageIds=[],this.channelType=t.ChannelType.BASE,this.coverUrl="",this.customType="",this.data="",this.isFrozen=!1,this.isEphemeral=!1,this.creator=null,this._messageCollectionLastAccessedAt=0,this._url=s.channel_url,this._name=null!==(i=s.name)&&void 0!==i?i:"",this._createdAt=1e3*s.created_at,this.coverUrl=null!==(n=s.cover_url)&&void 0!==n?n:"",this.customType=null!==(a=s.custom_type)&&void 0!==a?a:"",this.data=null!==(r=s.data)&&void 0!==r?r:"",this.isFrozen=null!==(o=s.freeze)&&void 0!==o&&o,this.isEphemeral=null!==(l=s.is_ephemeral)&&void 0!==l&&l,this.creator=s.created_by?new t.User(this._iid,s.created_by):null,s.metadata&&Object.keys(s.metadata).length>0&&s.ts?(this._cachedMetaData=new Map,Object.keys(s.metadata).forEach((e=>{this._cachedMetaData.set(e,{value:s.metadata[e],isRemoved:!1,updatedAt:s.ts})}))):"string"==typeof s.metadata&&(this._cachedMetaData=new Map(Object.entries(JSON.parse(s.metadata)))),this.pinnedMessageIds=null!==(d=s.pinned_message_ids)&&void 0!==d?d:[]}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(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?t.User.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}isGroupChannel(){return this.channelType===t.ChannelType.GROUP}isOpenChannel(){return this.channelType===t.ChannelType.OPEN}isFeedChannel(){return this.channelType===t.ChannelType.FEED}get cachedMetaData(){const e={};return this._cachedMetaData?(this._cachedMetaData.forEach(((t,s)=>{t.isRemoved||(e[s]=t.value)})),e):e}get messageCollectionLastAccessedAt(){return this._messageCollectionLastAccessedAt}_serializeCachedMetaData(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}_updateMessageCollectionLastAccessedAt(){this._messageCollectionLastAccessedAt=Date.now()}_update(e){const s=t.deundefined(e);Object.assign(this,s)}_upsertCachedMetaData(e,t){Object.keys(e).forEach((s=>{this._cachedMetaData||(this._cachedMetaData=new Map);const i=this._cachedMetaData.get(s);(!i||i.updatedAt<=t)&&this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})}))}_updateCachedMetaData(e,t){let s=!1;return this._cachedMetaData?this._cachedMetaData.forEach(((i,n)=>{var a;i.updatedAt<=t&&(this._cachedMetaData.set(n,{value:null!==(a=e[n])&&void 0!==a?a:i.value,isRemoved:!e[n],updatedAt:t}),s=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((s=>{this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})})),s=!0),{isUpdated:s}}_removeFromCachedMetaData(e,t){this._cachedMetaData&&e.forEach((e=>{const s=this._cachedMetaData.get(e);s&&s.updatedAtm.payloadify(e))):null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,created_at:i,user:a.currentUser?p.payloadify(a.currentUser):null,req_id:s,request_state:t.SendingStatus.PENDING,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>t.User.payloadify(e)))}))}_createPendingUserMessage(e,s,i){const n={};if(e.translationTargetLanguages)for(const t of e.translationTargetLanguages)n[t]="";const a=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.USER,message:e.message,translations:n,extended_message_payload:e.extendedMessagePayload})),r=new Q(this._iid,a);return r.messageParams=e,r}_createPendingScheduledUserMessage(e,t,s){const i=this._createPendingUserMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_createPendingFileMessage(e,i,n){var a,r,o,l,d,u,c;const h=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,i,n)),{type:t.MessageType.FILE,url:e.fileUrl,file:{name:null!==(a=e.fileName)&&void 0!==a?a:null===(r=e.file)||void 0===r?void 0:r.name,size:null!==(o=e.fileSize)&&void 0!==o?o:null===(l=e.file)||void 0===l?void 0:l.size,type:null!==(d=e.mimeType)&&void 0!==d?d:null===(u=e.file)||void 0===u?void 0:u.type,data:e.data},thumbnails:null===(c=e._thumbnails)||void 0===c?void 0:c.map((e=>s.payloadify(e)))})),p=new Y(this._iid,h);return p.messageParams=e,p}_createPendingMultipleFilesMessage(e,s,i){const n=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.FILE,file:e.fileInfoList.length>0?{name:e.fileInfoList[0].fileName,size:e.fileInfoList[0].fileSize,type:e.fileInfoList[0].mimeType,data:e.data}:void 0})),a=new G(this._iid,n);return a.messageParams=e,a}_validateFailedFileMessageHasFile(e,s){var i;return Boolean(e.url)||t.isFile(s)||t.isFile(null===(i=e.messageParams)||void 0===i?void 0:i.file)}_createPendingScheduledFileMessage(e,t,s){const i=this._createPendingFileMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_markMessageAsFailed(e,s,i=!1){e.errorCode=s.code,s.code===t.SendbirdErrorCode.REQUEST_CANCELED||s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=t.SendingStatus.CANCELED:i||(e.sendingStatus=t.SendingStatus.FAILED)}sendUserMessage(e){const s=Object.assign(Object.assign({},Me),e);return t.unless(Ae(s)).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(s)}_sendUserMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n,requestQueue:a}=t.Vault.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)}))));const d=new kt(Object.assign(Object.assign({},e),{channelUrl:this.url,channelType:this.channelType,reqId:r}));a.send(d).then((e=>{const{message:s}=e.as(Lt);n.dispatch(new t.MessageUpdateEventCommand({messages:[s],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(s)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendUserMessage(e){return t.unless(e instanceof Q&&!!e.messageParams).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId)}resendUserMessage(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=new t.Deferred,n=null!==(s=e.messageParams)&&void 0!==s?s:Oe(e);return this._sendUserMessage(n,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>i.reject(e))).onSucceeded((e=>i.resolve(e))),i.promise}))}updateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},qe),s);t.unless(t.isTypeOf("number",e)&&Fe(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Dt(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(qt);return o}))}copyUserMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Q&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters),t.unless(!s.poll).throw(t.SendbirdError.notSupportedError);const r=new t.Deferred,o=null!==(i=s.messageParams)&&void 0!==i?i:t.undefineNullProps(Object.assign(Object.assign({},s),{mentionType:s.mentionType,mentionedUserIds:null!==(n=s.mentionedUserIds)&&void 0!==n?n:null===(a=s.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)),translationTargetLanguages:Object.keys(s.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}));return e._sendUserMessage(o).onSucceeded((e=>{r.resolve(e)})).onFailed((e=>r.reject(e))),r.promise}))}translateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Qt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:s}),a=yield i.send(n),{message:r}=a.as(Gt);return r}))}_createScheduledUserMessage(e,s){const{requestQueue:i}=t.Vault.of(this._iid),n=Date.now(),a=this._generateRequestId();t.sleep(2).then((()=>{const i=this._createPendingScheduledUserMessage(e,a,n);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))}));const r=new Kt(Object.assign({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(r).then((e=>{const{message:i}=e.as(Ht);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((i=>{if(t.isThrowingOutside(i))throw i;t.sleep(2).then((()=>{const r=this._createPendingScheduledUserMessage(e,a,n);this._markMessageAsFailed(r,i),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(i,r)}))))}))}))}sendFileMessage(e){const s=Object.assign(Object.assign({},Ue),e);return t.unless(ke(s)).throw(t.SendbirdError.invalidParameters),this._sendFileMessage(s)}sendMultipleFilesMessage(e){var s;const i=Object.assign(Object.assign({},cs),e),n=t.Vault.of(this._iid);t.unless(((e,s=t.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT)=>Te(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=s&&e.fileInfoList.every((e=>hs(e))))(i,null===(s=n.appInfo)||void 0===s?void 0:s.multipleFilesMessageFileCountLimit)).throw(t.SendbirdError.invalidParameters);const a=!!e.fileInfoList.find((e=>{const t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return t.unless(!a).throw(t.SendbirdError.fileSizeLimitExceededError),this._sendMultipleFilesMessage(i)}_sendFileMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=$i.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?t.CollectionEventSource.LOCAL_MESSAGE_CANCELED:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendFileMessage(e){t.unless(e instanceof Y&&!!e.messageParams).throw(t.SendbirdError.invalidParameters);const{logger:s}=t.Vault.of(this._iid);return s.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId).onFailed((e=>{s.debug("autoResendFileMessage failed",e)})).onSucceeded((e=>{s.debug("autoResendFileMessage success",e)}))}_sendMultipleFilesMessage(e,s,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=$i.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new ps;return t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e,{requestHandler:l,isCopy:s===exports.SendMessageRequestType.COPY}).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);this._markMessageAsFailed(i,s),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_createScheduledFileMessage(e,s,i,n){const{requestQueue:a}=t.Vault.of(this._iid),r=new Wt(Object.assign(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(r).then((e=>{const{message:i}=e.as(Yt);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((a=>{if(t.isThrowingOutside(a))throw a;t.sleep(2).then((()=>{const r=this._createPendingScheduledFileMessage(e,i,n);this._markMessageAsFailed(r,a),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(a,r)}))))}))}))}sendFileMessages(e){t.unless(e.every((e=>ke(Object.assign(Object.assign({},Ue),e))))).throw(t.SendbirdError.invalidParameters);const s=new Ie;for(const t of e)this.sendFileMessage(t).onPending((e=>s._trigger(e))).onFailed(((e,t)=>s._triggerFailed(e,t))).onSucceeded((e=>s._trigger(e)));return s}resendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(e instanceof Y&&i&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const n=new t.Deferred,a=xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>n.reject(e))).onSucceeded((e=>n.resolve(e))),n.promise}))}resendMessage(e,s){var i,n;if(t.unless(e instanceof F&&!e.scheduledInfo&&e.isResendable).throw(t.SendbirdError.invalidParameters),e.isUserMessage()){const t=null!==(i=e.messageParams)&&void 0!==i?i:Oe(e);return this._sendUserMessage(t,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isFileMessage()){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(i).throw(t.SendbirdError.invalidParameters);const a=null!==(n=e.messageParams)&&void 0!==n?n:xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}updateFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},Be),s);t.unless(t.isTypeOf("number",e)&&(e=>De(e))(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Ft(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(Bt);return o}))}uploadFile(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),a=t.uuid(),r=new i({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a});r.uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a);const o=yield s.send(r),{url:l,thumbnails:d}=o.as(n);return{requestId:a,url:l,thumbnails:d}}))}cancelUploadingFileMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e)).throw(t.SendbirdError.invalidParameters);const{fileMessageQueue:s}=$i.of(this._iid);return s.cancel(this,e),!0}))}copyFileMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Y&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const r=new t.Deferred,o=t.undefineNullProps(Object.assign(Object.assign({},s),{fileUrl:s.url,fileName:s.name,fileSize:s.size,mimeType:s.type,mentionType:s.mentionType,mentionedUserIds:null!==(i=s.mentionedUserIds)&&void 0!==i?i:null===(n=s.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=s.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:s.requireAuth,isPinnedMessage:!1}));return e._sendFileMessage(o).onSucceeded((e=>r.resolve(e))).onFailed((e=>r.reject(e))),r.promise}))}copyMessage(e,s){t.unless(e instanceof Es&&s instanceof F&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=s,n=e;if(i.isUserMessage()){t.unless(!i.poll).throw(t.SendbirdError.notSupportedError);const e=Se(i);return n._sendUserMessage(e)}if(i.isFileMessage()){const e=Re(i);return n._sendFileMessage(e)}if(s.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}deleteMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){if(t.unless(e instanceof q).throw(t.SendbirdError.invalidParameters),e.messageId>0){const{requestQueue:s}=t.Vault.of(this._iid),i=new t.DeleteMessageRequestCommand({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof F?e._messageToken:void 0});yield s.send(i)}}))}addReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new jt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as(Vt);return r}))}deleteReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new zt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as($t);return r}))}_updateUserMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Dt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(qt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}_updateFileMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Ft({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(Bt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}createMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"add",!0):this._updateUserMessageMetaArray(e.messageId,i,"add",!0)}))}deleteMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"remove",!0):this._updateUserMessageMetaArray(e.messageId,i,"remove",!0)}))}addMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"add",!0):this._updateUserMessageMetaArray(e.messageId,s,"add",!0)}))}removeMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"remove",!0):this._updateUserMessageMetaArray(e.messageId,s,"remove",!0)}))}report(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isEnumOf(exports.ReportCategory,e)&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:n}=t.Vault.of(this._iid),a=new Ut({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:s});yield n.send(a)}))}reportUser(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof t.User&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new Rt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.userId,category:s,description:i});yield a.send(r)}))}reportMessage(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof F&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new xt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:s,description:i,messageToken:e._messageToken});yield a.send(r)}))}updatePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&(e=>t.isTypeOf("string",e.title,!0)&&t.validatePollData(e.data)&&t.isTypeOf("boolean",e.allowUserSuggestion,!0)&&t.isTypeOf("boolean",e.allowMultipleVotes,!0)&&t.isTypeOf("number",e.closeAt,!0))(s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Jt(Object.assign({pollId:e},s)),a=yield i.send(n),{poll:r}=a.as(Xt);return r}))}deletePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Zt({pollId:e});yield i.send(n)}))}closePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new es({pollId:e}),a=yield i.send(n),{poll:r}=a.as(ts);return r}))}addPollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("string",s)&&""!==s.trim();t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new ss({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:s}),r=yield n.send(a),{poll:o}=r.as(is);return o}))}updatePollOption(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const n=t.isTypeOf("number",e)&&t.isTypeOf("number",s)&&t.isTypeOf("string",i)&&""!==i.trim();t.unless(n).throw(t.SendbirdError.invalidParameters);const{requestQueue:a}=t.Vault.of(this._iid),r=new ns({pollId:e,pollOptionId:s,optionText:i}),o=yield a.send(r),{poll:l}=o.as(as);return l}))}deletePollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new rs({pollId:e,pollOptionId:s});yield n.send(a)}))}votePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isArrayOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n,dispatcher:a}=t.Vault.of(this._iid),r=new os({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:s}),o=yield n.send(r),{event:l}=o.as(ls);return a.dispatch(new t.PollVoteInternalEventCommand({event:l,source:t.CollectionEventSource.EVENT_POLL_VOTED})),l}))}getPollChangeLogsSinceTimestamp(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)).throw(t.SendbirdError.invalidParameters);const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}getPollChangeLogsSinceToken(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e,!0));const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}createPollListQuery(e=10){return new t.PollListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}createPollVoterListQuery(e,s,i=20){return new t.PollVoterListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:s,limit:i})}pinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new fs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}unpinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new vs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}}const Ts={};class bs{constructor({dbname:e,itemSizeLimit:t=1048576,cacheLimit:s=256,blockHashBase:i=2,blockHashMultiplier:n=10,blockHashConstant:a=11,transactionApplyDelay:r=200,disableLogger:o=!1}){return Ts[e]||(this.itemSizeLimit=t,this.cacheLimit=s,this.blockHashBase=i,this.blockHashMultiplier=n,this.blockHashConstant=a,this.transactionApplyDelay=r,this.disableLogger=o,Ts[e]=this),Ts[e]}static get(e){return Ts[e]}}var Ms,Ss;!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"}(Ms||(Ms={}));class Os extends Error{constructor({code:e=Ms.UNKNOWN_ERROR,message:t="Unknown error occurred."}){super(t),this.code=e,Object.setPrototypeOf(this,Os.prototype)}static get storeNotDefined(){return new Os({code:Ms.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}static get storeNotAvailable(){return new Os({code:Ms.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}static get storeNotAvailableInPrivateBrowsing(){return new Os({code:Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}static get storeIsFull(){return new Os({code:Ms.STORE_IS_FULL,message:"Store is full."})}static get storeNotInitialized(){return new Os({code:Ms.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}static get storeKeyTypeIsInvalid(){return new Os({code:Ms.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}static get storeBrokenIntegrity(){return new Os({code:Ms.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}static get storeBrokenBlob(){return new Os({code:Ms.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}static get storeEncryptionInvalid(){return new Os({code:Ms.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}static get storeItemSizeExceeded(){return new Os({code:Ms.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}static get storeReadFailed(){return new Os({code:Ms.STORE_READ_FAILED,message:"Failed to read from store."})}static get storeWriteFailed(){return new Os({code:Ms.STORE_WRITE_FAILED,message:"Failed to write to store."})}static get databaseSchemaNotOnUpgrade(){return new Os({code:Ms.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}static get collectionNotReady(){return new Os({code:Ms.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}static get collectionKeyNotMatch(){return new Os({code:Ms.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}static get collectionQueryNotValid(){return new Os({code:Ms.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}static get collectionInsertDuplicate(){return new Os({code:Ms.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}static get collectionKeyNotFound(){return new Os({code:Ms.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}static get collectionKeyNotGiven(){return new Os({code:Ms.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}static get collectionWriteFailed(){return new Os({code:Ms.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}static get collectionItemSizeExceeded(){return new Os({code:Ms.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}static get indexTableIsRequired(){return new Os({code:Ms.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}static get indexTypesNotMatch(){return new Os({code:Ms.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}static get compareTypesNotMatch(){return new Os({code:Ms.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}static get circularReferenceFound(){return new Os({code:Ms.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ss||(Ss={}));const As=(e,t=new WeakMap)=>{if("object"==typeof e&&null!==e){if(t.has(e))throw Os.circularReferenceFound;{let s;if(t.set(e,!0),Array.isArray(e))s=e.map((e=>As(e,t)));else if(e instanceof RegExp)s=e;else if(e instanceof Date)s=e;else{s={};for(const i in e)s[i]=As(e[i],t)}return t.delete(e),s}}return e},Cs=(e,t)=>{if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Os.compareTypesNotMatch;let s=0;switch(typeof e){case"boolean":case"number":s=e-t;break;case"string":s=e.localeCompare(t)}return s},ws=(e,t)=>{let s=0;for(let t=0;t>>0)%t},Ns=e=>new Promise((t=>{setTimeout((()=>t()),e)})),Ps=(e,t)=>{if(!t)return!1;if("function"!=typeof e){for(const s in e)if(["/and","&&"].includes(s)){if(e[s].some((e=>!Ps(e,t))))return!1}else if(["/or","||"].includes(s)){if(e[s].every((e=>!Ps(e,t))))return!1}else if("/where"===s){if(!(0,e[s])(t))return!1}else{const i=s;if("object"==typeof e[i]){const s=e[i];for(const e in s)switch(e){case"/eq":case"=":if(t[i]!==s[e])return!1;break;case"/neq":case"!=":if(t[i]===s[e])return!1;break;case"/gt":case">":{const n=t[i],a=s[e];if(!(Cs(n,a)>0))return!1;break}case"/gte":case">=":{const n=t[i],a=s[e];if(!(Cs(n,a)>=0))return!1;break}case"/lt":case"<":{const n=t[i],a=s[e];if(!(Cs(n,a)<0))return!1;break}case"/lte":case"<=":{const n=t[i],a=s[e];if(!(Cs(n,a)<=0))return!1;break}case"/in":{const n=t[i];if(!s[e].includes(n))return!1;break}case"/nin":{const n=t[i];if(s[e].includes(n))return!1;break}case"/contain":{const n=t[i],a=s[e];if(!n.includes(a))return!1;break}case"/regex":{const n=t[i];if(!s[e].test(n))return!1;break}case"/where":{const n=t[i];if(!(0,s[e])(n))return!1;break}}}else if("function"==typeof e[i]){if(!e[i](t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}return e(t)},Us=()=>{},Rs=()=>Promise.resolve(),xs=e=>e,ks=(e,t)=>{t()};var Ls;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Ls||(Ls={}));class Ds{constructor({initialPrevValue:e=null,initialNextValue:t=null,iterator:s,map:i=xs,backward:n=Rs,forward:a=Rs,complete:r=Us}){this._prevValue=e,this._nextValue=t,this._error=null,this._map=i,this._backward=n,this._forward=a,this._iterator=s,this._complete=r}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 t.__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 t.__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 qs{constructor({condition:e={},backward:t=!1,blockManager:s,indexer:i}){this.condition=e,this.backward=t,this._blockManager=s,this._indexer=i}findOptimizedStartPosition(){const e=["=","/eq",">",">=","/gt","/gte"],t=["=","/eq","<","<=","/lt","/lte"];if(this.backward){let s=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(const i in this._indexer.fields){let n=this._indexer.fields[i],a=1;if("-"===n[0]&&(n=n.slice(1),a=-1),this.condition[n])if("object"==typeof this.condition[n]){const r=a>0?t:e;for(const e in this.condition[n])if(r.includes(e))for(let t=s;t>=0;t--)if(a*Cs(this._indexer.origin[t].columnValues[i],this.condition[n][e])<=0){s=t;break}}else for(let e=s;e>=0;e--)if(a*Cs(this._indexer.origin[e].columnValues[i],this.condition[n])<=0){s=e;break}}return Math.min(s+1,this._indexer.origin.length-1)}{let s=0;if("function"!=typeof this.condition)for(let i=0;i{if((a>0?e:t).includes(r))for(let e=s;e=0){s=e;break}}));else for(let e=s;e=0){s=e;break}}return Math.max(s-1,0)}}each(e){return t.__awaiter(this,void 0,void 0,(function*(){let s=this.findOptimizedStartPosition(),i=0;this.backward&&this._indexer.origin[s]&&(i=this._indexer.origin[s].keys.length-1);const n=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[++i]){if(!this._indexer.origin[++s])return!1;i=0}return!0}return!1},a=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[--i]){if(!this._indexer.origin[--s])return!1;i=this._indexer.origin[s].keys.length-1}return!0}return!1};let r=null;if(this._indexer.origin[s]){const e=this.backward?a:n;do{const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e)){r=e;break}}while(e())}return yield new Promise((o=>{const l=new Ds({initialNextValue:As(r),iterator:e,forward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?a:n;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return As(e)}return null})),backward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?n:a;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return As(e)}return null})),complete:o});e(l)}))}))}}class Fs{constructor({condition:e={},backward:t=!1,mutex:s,blockManager:i,indexer:n}){this._mutex=s,this._iterator=new qs({condition:e,backward:t,blockManager:i,indexer:n})}fetch(e={}){return t.__awaiter(this,void 0,void 0,(function*(){let s=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 Os.collectionQueryNotValid;try{const e=[];return yield this._mutex.lock(),yield this._iterator.each((n=>t.__awaiter(this,void 0,void 0,(function*(){n.error?n.stop():n.hasNext?0===s?(e.push(n.nextValue),0t.__awaiter(this,void 0,void 0,(function*(){s.error?s.stop():s.hasNext?(e++,s.next()):s.stop()})))),this._mutex.unlock(),e}catch(e){throw this._mutex.unlock(),e}}))}}const Bs=e=>`nest@${e}`,js=(e,t)=>`${Bs(e)}/${t}`,Vs=(e,t)=>`${js(e,t)}.metadata`,zs=(e,t)=>`${js(e,t)}/block.`,$s=(e,t)=>`${js(e,t)}/blob.`;class Qs{constructor({dbname:e,collectionName:t,store:s}){this.dbname=e,this.collectionName=t,this.store=s}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.store.get(e);if(t){const{data:e,type:s}=t;if("undefined"!=typeof fetch){const t=yield fetch(e);return yield t.blob()}{const t=512,i=[],n=atob(e.split(",")[1]);for(let e=0;e{const i=((e,t,s,i=0)=>`${$s(e,t)}${s}.${i}`)(this.dbname,this.collectionName,s),n=new FileReader;n.onload=()=>{t({blobId:i,data:n.result,type:e.type})},n.readAsDataURL(e)}));return yield this.store.set({key:t,value:{data:i,type:n}}),t}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this.store.remove(e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=$s(this.dbname,this.collectionName),s=yield this.store.getAllKeys();yield Promise.all(s.filter((t=>t.startsWith(e))).map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this.store.remove(e)})))))}))}}var Gs,Ks,Hs;!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Gs||(Gs={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Ks||(Ks={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Hs||(Hs={}));const Ws=[Ks.PENDING,Ks.VOLATILE],Ys={};class Js{constructor({dbname:e,limit:t=256}){return Ys[e]||(this.dbname=e,this._items=[],this._limit=t,Ys[e]=this),Ys[e]}static get(e){return Ys[e]}get items(){return this._items}find(e,s,i=Hs.DEFAULT){return t.__awaiter(this,void 0,void 0,(function*(){let t=this.get(s);if(t)i===Hs.PERSISTENT&&(t.state=Ks.PERSISTENT);else{const n=yield e.get(s);n&&(t={key:s,value:n,state:i===Hs.PERSISTENT?Ks.PERSISTENT:Ks.VOLATILE},this.put(t))}return t}))}get(e,t=Hs.DEFAULT){const s=this._items.map((e=>e.key)).indexOf(e);if(s>-1){const e=this._items[s];return t===Hs.PERSISTENT&&(e.state=Ks.PERSISTENT),t!==Hs.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)Ws.includes(this._items[t].state)&&Ws.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===Ks.VOLATILE));let s=t.length-this._limit;if(s>0){const e=[];for(const t of this._items)t.state===Ks.VOLATILE&&s>0?s--: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)))}clearForDatabase(e){this.clearByCondition((t=>t.key.startsWith(Bs(e))))}clear(e=!1){this._items=e?[]:this._items.filter((e=>e.state!==Ks.VOLATILE))}}class Xs{constructor({dbname:e,collectionName:t,store:s}){this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=e,this.collectionName=t,this.metadataKey=((e,t)=>`${js(e,t)}/trans.metadata`)(e,t),this.recordsetKey=((e,t)=>`${js(e,t)}/trans.recordset`)(e,t),this._store=s}get generation(){return this._metadata?this._metadata.generation:0}get requestCount(){return this._requests.length}_getReducedRecordset(e=[]){return t.__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=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=[];for(let e=n.requests.length-1;e>=0;e--){const t=n.requests[e],i=t.data;s[i.key]||(a.unshift(t),s[i.key]=!0)}a.length>0&&(n.requests=a,t.unshift(n))}return t}_applyRecord(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname),{generation:i,requests:n}=s;let a=null;try{const e=yield this._store.setMany(n.map((e=>Object.assign(Object.assign({},e.data),{generation:i}))));for(let s=0;s{a&&e(a)}));else{const t=e.filter((e=>e.generation!==i));yield this._store.set({key:this.recordsetKey,value:t}),this._onWrite.forEach((e=>{e(n.map((e=>e.data)))}))}}))}init(){return t.__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,s){switch(e){case Gs.COMMIT:this._onCommit.set(t,s);break;case Gs.WRITE:this._onWrite.set(t,s);break;case Gs.ERROR:this._onError.set(t,s)}}requestWrite(e,t){this._requests.push({data:e,options:t});Js.get(this.dbname).put(Object.assign({state:Ks.PENDING},e))}requestMultipleWrite(e,t){const s=Js.get(this.dbname);for(const i of e)this._requests.push({data:i,options:t}),s.put(Object.assign({state:Ks.PENDING},i))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).clearByCondition((e=>e.state===Ks.PENDING)),this._requests=[]}))}commit(){return t.__awaiter(this,void 0,void 0,(function*(){const e=this._requests;if(e.length>0){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=n.data;s[a.key]||(s[a.key]=!0,t.unshift(n))}const i={generation:this.generation,requests:t},n=yield this._getReducedRecordset([i]);yield this._store.set({key:this.recordsetKey,value:n}),this._metadata.generation++,yield this._store.set({key:this.metadataKey,value:this._metadata});const a=Js.get(this.dbname);for(let e=0;e{t(e.map((e=>e.data)))}));const r=bs.get(this.dbname);setTimeout((()=>{try{this._applyRecord(n,i)}catch(e){this._onError.forEach((t=>t(e)))}}),r.transactionApplyDelay)}}))}}class Zs{constructor({blockId:e,keyName:t,items:s=[],limit:i}){this.blockId=e,this.keyName=t,this.limit=i,this._items=[...s]}static createFromCacheItem(e){return e?new Zs(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 s=t[this.keyName];return e===s}));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 i=s.base*Math.pow(s.multiplier,t)+s.constant;return(s.hashFunction||ws)(e,i)})(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})}`,`${zs(s,i)}${n}.${a}`;var s,i,n,a}_findBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname);for(let s=this.metadata.blockLevel;s>0;s--){const i=this.createBlockId(e,s),n=yield t.find(this._store,i);if(n){const t=Zs.createFromCacheItem(n);if(null==t?void 0:t.getItemByKey(e))return t}}return null}))}getFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return t?t.getItemByKey(e):null}))}putToBlock(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=bs.get(this.dbname),i=this.createBlockId(e),n=Math.floor(this._store.itemSizeLimit/t.itemSizeLimit),a=Js.get(this.dbname),r=yield a.find(this._store,i),o=r?Zs.createFromCacheItem(r):new Zs({blockId:i,keyName:this.keyName,items:[],limit:n});return!!(null==o?void 0:o.add(s))&&(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),!0)}))}removeFromBlock(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const e=zs(this.dbname,this.collectionName),t=(yield this._store.getAllKeys()).filter((t=>t.startsWith(e)));yield this._store.removeMany(t),yield this._transaction.clear();Js.get(this.dbname).clearByCondition((t=>t.key.startsWith(e)))}))}}const ti=e=>{const t=typeof e;return null===e||"undefined"===t||"boolean"===t||"number"===t||"string"===t},si={};class ii{constructor({dbname:e,collectionName:t,keyName:s,fields:i,transaction:n,store:a}){this._origin=[],this._table=[];const r=((e,t,s)=>`${js(e,t)}/index.${s}`)(e,t,i.join(">"));return si[r]||(this.dbname=e,this.collectionName=t,this.keyName=s,this.fields=i,this.indexerKey=r,this._transaction=n,this._store=a,this._transaction.on(Gs.COMMIT,this.indexerKey,(()=>this.commit())),this._transaction.on(Gs.ERROR,this.indexerKey,(()=>this.abort()))),si[r]}static createKey(e){return e.join(">")}static parseKey(e){return e.split(">")}static clearIndexerMap(){for(const e in si)delete si[e]}_addItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);return n?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:s,keys:[t]}),!0)}_removeItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);if(n){const e=this._table[i].keys.indexOf(t);if(e>-1)return this._table[i].keys.splice(e,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1}get origin(){return this._origin}get table(){return this._table}getColumnValues(e){const t=[];for(let s of this.fields){if("-"===s[0]&&(s=s.slice(1)),!ti(e[s]))throw Os.indexTypesNotMatch;t.push(e[s])}return t}diff(e,t){for(const s in this.fields){const i="-"===this.fields[s][0]?-1:1,n=Cs(e[s],t[s]);if(0!==n)return i*n}return 0}indexOf(e){if(this._table.length>0){let t=0,s=this._table.length-1;for(;t<=s;){const i=Math.floor((t+s)/2),n=this.diff(e,this._table[i].columnValues);if(n>0)t=i+1;else{if(!(n<0))return[i,!0];s=i-1}}return[t,!1]}return[0,!1]}ensure(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.dbname),t=yield e.find(this._store,this.indexerKey,Hs.PERSISTENT);if(t)this._origin=t.value,this._table=As(this._origin);else{const t=zs(this.dbname,this.collectionName),s=yield this._store.getAllKeys();for(const i of s)if(i.startsWith(t)){const t=yield e.find(this._store,i,Hs.NO_CACHE),s=Zs.createFromCacheItem(t);if(s)for(const e of s.items)this._addItem(e)}this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}si[this.indexerKey]=this}))}drop(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).remove(this.indexerKey),yield this._store.remove(this.indexerKey),delete si[this.indexerKey]}))}addItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}removeItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}clear(){return t.__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=As(this._origin)}abort(){this._table=As(this._origin)}}const ni=()=>"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product,ai=()=>{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)}))};var ri,oi;!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(ri||(ri={})),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"}(oi||(oi={}));const li={};class di{constructor(e,t={}){return this._state=ri.PROCESSING,this._queue=[],this._activationQueue=[],li[e]&&!t.forceCreate||(this.nodeId=ai(),this.key=e,ni()&&(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;if(!(null==t?void 0:t.isNestDbMessage))return;const{nodeId:s,requestId:i,key:n,op:a,data:r}=t;if(s!==this.nodeId&&n===this.key)switch(a){case oi.NEWNODE:this._sendSync();break;case oi.CLAIM_HOST:this._sendSync(),this._hostId=s;break;case oi.SYNC_HOST:if(!this.isInSync){this._activationTimeout&&clearTimeout(this._activationTimeout);const{currentItemRequestId:e,queue:t}=r;for(const e of t){this._queue.findIndex((t=>t.requestId===e.requestId))<0&&this._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:this.key,op:oi.REQUEST_LOCK,ts:e.ts})}this._currentItem=this._queue.find((t=>t.requestId===e)),this._completeSync()}break;case oi.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 oi.REQUEST_LOCK:this._requestLock(t);break;case oi.ACQUIRE_LOCK:{const e=this._queue.find((e=>e.requestId===i));this._acquire(e);break}case oi.RELEASE_LOCK:this._release(i)}})),window.addEventListener("beforeunload",(()=>{this._send(oi.REMOVENODE)}))),li[e]=this),li[e]}get locked(){return!!this._currentItem}get isHost(){return this._hostId===this.nodeId}get isInSync(){return this._state==ri.DONE}_send(e,t={}){var s;const i={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(s=null==t?void 0:t.requestId)&&void 0!==s?s:ai(),key:this.key,op:e,data:t.data,ts:Date.now()};return ni()&&window.postMessage(i,"*"),i}_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(oi.RELEASE_LOCK,{requestId:t.requestId});const s=this._queue.findIndex((t=>t.requestId===e));s>-1&&this._queue.splice(s,1),t.onReleased&&t.onReleased(e)}}_requestLock(e){return new Promise((t=>{const s={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:e=>{this.isHost&&this._send(oi.ACQUIRE_LOCK,{requestId:e}),t()},onReleased:()=>{this._acquire(this._queue[0])}};let i=!1;for(const e in this._queue)if(this._queue[e].ts>s.ts){this._queue.splice(parseInt(e),0,s),i=!0;break}i||this._queue.push(s),this._currentItem||this._acquire(this._queue[0])}))}_sendSync(){var e;this.isHost&&this._send(oi.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 t.__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=ri.DONE,this._activationQueue.forEach((e=>e())),this._activationQueue=[])}registerNode(){this._send(oi.NEWNODE),this._waitSync()}claimHost(){this._hostId=this.nodeId,this._send(oi.CLAIM_HOST),this._waitSync()}lock(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._waitUntilSyncCompleted();const e=this._send(oi.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)}}class ui{constructor({dbname:e,collectionName:t,keyName:s,keyHash:i,indexes:n,store:a}){this._state=Ss.INIT,this._indexers=[],this.dbname=e,this.name=t,this.keyName=s,this.indexes=[[s],...n.filter((e=>ii.createKey(e)!==this.keyName))],this._keyHash=i,this._store=a,this._mutex=new di(((e,t)=>`${js(e,t)}.lock`)(e,t)),this._blobContainer=new Qs({dbname:e,collectionName:t,store:a}),this._transaction=new Xs({dbname:e,collectionName:t,store:a})}static metadataOf(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const t=Vs(e,s);return yield i.get(t)}))}get state(){return this._state}get isReady(){return this._state===Ss.READY}init(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._mutex.lock();try{const e=bs.get(this.dbname),t=yield ui.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 ei({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store});const s=[...this.indexes],i=[],n=s.map((e=>ii.createKey(e))),a=t?t.indexes.map((e=>ii.createKey(e))):[];for(const e of a)n.includes(e)||i.push(ii.parseKey(e));const r=[];if(r.push(...s.map((e=>{const t=new ii({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store});return this._indexers.push(t),t.ensure()}))),r.push(...i.map((e=>new ii({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store}).drop()))),yield Promise.all(r),yield this._transaction.commit(),n.sort().join(",")!==a.sort().join(",")){const e=Vs(this.dbname,this.name);this._metadata.indexes=s,yield this._store.set({key:e,value:this._metadata})}this._state=Ss.READY,this._mutex.unlock()}catch(e){throw this._mutex.unlock(),e}}))}close(){this._state=Ss.CLOSED}_hasPropertyOfKeyName(e){const t=e[this.keyName];return"string"==typeof t&&!!t}_getIndexerBy(e=null){e||(e=[this.keyName]);const t=ii.createKey(e);for(const e of this._indexers)if(t===ii.createKey(e.fields))return e;throw Os.indexTableIsRequired}_upgradeBlockLevel(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Vs(this.dbname,this.name);this._metadata.blockLevel++,yield this._store.set({key:e,value:this._metadata})}))}_requestInsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName];if(yield this._blockManager.getFromBlock(t))throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}}))}_requestRemove(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){yield this._blockManager.clearAllBlocks();for(const e of this._indexers)yield e.clear()}))}getByKey(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{const t=yield this._blockManager.getFromBlock(e);return this._mutex.unlock(),As(t)}catch(e){throw this._mutex.unlock(),e}}))}query(e={}){if(this.isReady)return new Fs({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Os.collectionNotReady}insertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestInsert(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}insertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Os.collectionKeyNotGiven;for(const t of e)yield this._requestInsert(As(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestUpsert(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Os.collectionKeyNotGiven;for(const t of e)yield this._requestUpsert(As(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}update(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestUpdate(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}updateIf(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Os.collectionNotReady;yield this._mutex.lock();try{const{where:i={},index:n=null,backward:a=!1}=e,r=[],o=new qs({condition:i,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(n)});yield o.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(Ps(i,t)&&s.set){if("function"!=typeof s.set)for(const e in s.set)t[e]=s.set[e];else s.set(t);r.push(t)}e.next()}else e.stop()}))));for(const e of r)yield this._requestUpdate(As(e));return yield this._transaction.commit(),this._mutex.unlock(),r}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Os.collectionNotReady;yield this._mutex.lock();try{const{where:s={},index:i=null,backward:n=!1}=e,a=[],r=new qs({condition:s,blockManager:this._blockManager,backward:n,indexer:this._getIndexerBy(i)});yield r.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(Ps(s,t)){const e=t[this.keyName];a.push(e)}e.next()}else e.stop()}))));for(const e of a)yield this._requestRemove(e);return yield this._transaction.commit(),this._mutex.unlock(),a}catch(e){throw this._mutex.unlock(),e}}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.get(e)}))}saveBlob(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.save(e,s)}))}removeBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.remove(e)}))}removeAllBlobs(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.clear()}))}}const ci="[NESTDB]";let hi=!0;class pi{static off(){hi=!1}static log(...e){hi&&console.log(`${ci}[LOG]`,...e)}static warning(...e){hi&&console.warn(`${ci}[WARNING]`,...e)}static error(...e){hi&&console.error(`${ci}[ERROR]`,...e)}}const mi=[{},{a:700400,n:"error"}];class _i{constructor(e){var s,i,n;this.encryption=null!==(s=e.encryption)&&void 0!==s?s:t.DEFAULT_ENCRYPTION,this.itemSizeLimit=null!==(i=e.itemSizeLimit)&&void 0!==i?i:4194304,this.metadataBuffer=null!==(n=e.metadataBuffer)&&void 0!==n?n:256}get _encryptionCheckKey(){return`${this.dbname}.encrypt`}get _reservedKeys(){return[this._encryptionCheckKey]}_getRawKey(e,t=""){return`${e}${t}`}_generateShardPostfixArray(e=1){return[...Array(e).keys()]}_shardify(e){const{key:t,value:s}=e,i=JSON.stringify(this.encryption.encrypt(s)),n=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(n).map((e=>{const s={key:this._getRawKey(t,`.${e}`),data:i.substring(e*this.adjustedItemSizeLimit,(e+1)*this.adjustedItemSizeLimit)};return 0===e&&(s.metadata={shards:n}),s}))}_resetIfEncryptionChanged(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.get(this._encryptionCheckKey),t={encrypted:mi.map((e=>{var t;return null===(t=this.encryption)||void 0===t?void 0:t.encrypt(e)}))};if(e)if(e.encrypted&&Array.isArray(e.encrypted))for(const s in e.encrypted){if(JSON.stringify(e.encrypted[s])!==JSON.stringify(t.encrypted[s])){pi.warning("Encryption algorithm has changed. Stored data would be cleared."),yield this.clear();break}}else yield this.clear();yield this.set({key:this._encryptionCheckKey,value:t})}))}get adjustedItemSizeLimit(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}usage(){return t.__awaiter(this,void 0,void 0,(function*(){let e=0;const t=yield this._getAllRawKeys();for(const s of t){const t=yield this._getRaw(s);t&&(e+=JSON.stringify(t).length)}return e}))}getAllKeys(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this._getAllRawKeys()).filter((e=>e.endsWith(".0"))).map((e=>e.replace(/\.0$/,""))).filter((e=>!this._reservedKeys.includes(e)))}))}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=this._getRawKey(e,".0"),i=yield this._getRaw(s);if(i)try{const{data:s,metadata:n}=i,a=(null==n?void 0:n.shards)&&n.shards>1?yield Promise.all(this._generateShardPostfixArray(null==n?void 0:n.shards).map((i=>t.__awaiter(this,void 0,void 0,(function*(){if(i>0){const t=this._getRawKey(e,`.${i}`),s=yield this._getRaw(t);if(!s)throw Os.storeBrokenIntegrity;return s.data}return s}))))):[s];return this.encryption.decrypt(JSON.parse(a.join("")))}catch(e){return null}return null}))}set(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._shardify(e);return yield this._setRaw(t),Object.assign({},e.value)}))}setMany(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const t=this._getRawKey(e,".0"),s=yield this._getRaw(t);if(s){const{metadata:t}=s,i=this._generateShardPostfixArray(null==t?void 0:t.shards).map((t=>this._getRawKey(e,`.${t}`)));yield this._removeRaw(i);const n=Js.get(this.dbname);return null==n||n.remove(e),!0}return!1}))}removeMany(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname),s=[];for(const i of e){const e=this._getRawKey(i,".0"),n=yield this._getRaw(e);if(n){const{metadata:e}=n;s.push(...this._generateShardPostfixArray(null==e?void 0:e.shards).map((e=>this._getRawKey(i,`.${e}`))))}null==t||t.remove(i)}return s.length>0&&(yield this._removeRaw(s)),e}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.dbname);null==e||e.clearForDatabase(this.dbname)}))}}const gi=1,yi={};class fi extends _i{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:4194304}));const{delay:s=gi}=e;this.delay=s,this.observer={}}get rawData(){return yi[this.dbname]}set rawData(e){yi[this.dbname]=e}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){if(yi[this.dbname])return Object.keys(yi[this.dbname]);throw Os.storeNotAvailable}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(yi[this.dbname])return yield Ns(this.delay),yi[this.dbname][e]?Object.assign({key:e},yi[this.dbname][e]):null;throw Os.storeNotAvailable}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!yi[this.dbname])throw Os.storeNotAvailable;yield Ns(this.delay);for(const t of e){const{key:e,data:s,metadata:i}=t;yi[this.dbname][e]=Object.freeze({data:s,metadata:i})}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!yi[this.dbname])throw Os.storeNotAvailable;yield Ns(this.delay);for(const t of e)yi[this.dbname][t]&&delete yi[this.dbname][t]}))}observe(e,t,s){this.observer[e]||(this.observer[e]={}),t.forEach((t=>this.observer[e][t]=s))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yi[this.dbname]||(yi[this.dbname]={}),yield this._resetIfEncryptionChanged()}))}set(e){const s=Object.create(null,{set:{get:()=>super.set}});return t.__awaiter(this,void 0,void 0,(function*(){const t=this.observer[e.key];if(t&&"function"==typeof t.set){const e=t.set();if(e)throw e}return s.set.call(this,e)}))}setMany(e){const s=Object.create(null,{setMany:{get:()=>super.setMany}});return t.__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 s.setMany.call(this,e)}))}clear(){const e=Object.create(null,{clear:{get:()=>super.clear}});return t.__awaiter(this,void 0,void 0,(function*(){yield e.clear.call(this),yield Ns(this.delay),yi[this.dbname]={}}))}}const vi="NestDBStore";var Ii;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Ii||(Ii={}));var Ei,Ti,bi;exports.NestDBState=void 0,(Ei=exports.NestDBState||(exports.NestDBState={})).INIT="INIT",Ei.OPENING="OPENING",Ei.OPENED="OPENED",Ei.CLOSED="CLOSED";exports.LogLevel=void 0,(Ti=exports.LogLevel||(exports.LogLevel={}))[Ti.VERBOSE=0]="VERBOSE",Ti[Ti.DEBUG=1]="DEBUG",Ti[Ti.INFO=2]="INFO",Ti[Ti.WARN=3]="WARN",Ti[Ti.ERROR=4]="ERROR",Ti[Ti.NONE=5]="NONE";class Mi{constructor(e){var s,i,n,a;this.messageTypeFilter=null!==(s=null==e?void 0:e.messageTypeFilter)&&void 0!==s?s:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(i=null==e?void 0:e.customTypesFilter)&&void 0!==i?i:null,this.senderUserIdsFilter=null!==(n=null==e?void 0:e.senderUserIdsFilter)&&void 0!==n?n:null,this.replyType=null!==(a=null==e?void 0:e.replyType)&&void 0!==a?a:t.ReplyType.NONE}clone(){const e=new Mi,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((s=>{e[s]=t[s]})),e}match(e){switch(this.messageTypeFilter){case t.MessageTypeFilter.USER:if(e.messageType!==t.MessageType.USER)return!1;break;case t.MessageTypeFilter.FILE:if(e.messageType!==t.MessageType.FILE)return!1;break;case t.MessageTypeFilter.ADMIN:if(e.messageType!==t.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof F))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof q)switch(this.replyType){case t.ReplyType.NONE:if(e.parentMessageId>0)return!1;break;case t.ReplyType.ONLY_REPLY_TO_CHANNEL:if(e instanceof F&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}}exports.MessageListOrder=void 0,(bi=exports.MessageListOrder||(exports.MessageListOrder={})).CHANNEL_LATEST="channel_latest",bi.NEWEST_CHILD_MESSAGE="newest_child_message";const Si=e=>{switch(e){case exports.MessageListOrder.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Oi=()=>["channelUrl","-createdAt","-notificationId"],Ai=Object.assign(Object.assign({},Me),{scheduledAt:void 0}),Ci=Object.assign(Object.assign({},Ee),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),wi="UnsentMessage",Ni={};class Pi extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),this._mutex=new di("unsendmessagecache.lock"),Ni[e]=this}static of(e,t=!1){return Ni[e]&&!t||(Ni[e]=new Pi(e)),Ni[e]}get collection(){const{nestdb:e}=this._cacheContext,s=null==e?void 0:e.collection(wi);if(!s)throw t.SendbirdError.databaseError;return s}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){if(e.messageId>0)throw t.SendbirdError.invalidParameters;const s=Object.assign({},e.serialize());var i;return e instanceof Q?(e.messageParams&&(s.messageParams=be(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(i=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},be(i)),{scheduledAt:i.scheduledAt})))):e instanceof Y?(e.messageParams&&(s.messageParams=Pe(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(e=>Object.assign(Object.assign({},Pe(e)),{scheduledAt:e.scheduledAt}))(e.scheduledInfo.scheduledMessageParams))):e instanceof G&&e.messageParams&&(s.messageParams=(e=>t.deundefined({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}))(e.messageParams)),s}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return $i.of(this._iid).buildMessageFromSerializedData(e)}_deserializeWithMessageCreateParams(e){var s,i,n;return t.__awaiter(this,void 0,void 0,(function*(){const a=$i.of(this._iid),r=this._deserialize(e);if(e.messageParams)if(r instanceof Q){const t=e.messageParams;r.messageParams=a.buildUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.messageParams;t.fileKey&&"string"==typeof t.fileKey&&Ne(null!==(s=t.fileType)&&void 0!==s?s:"")&&(t.file=null!==(i=yield this.collection.getBlob(t.fileKey))&&void 0!==i?i:void 0),r.messageParams=a.buildFileMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof G){const s=e.messageParams;s&&s.fileInfoList&&(r.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(s,r),yield Promise.all(r.messageParams.fileInfoList.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t,s,i,n;"string"==typeof(null===(t=e._uploadedMetaData)||void 0===t?void 0:t.fileKey)&&Ne(null!==(i=null===(s=e._uploadedMetaData)||void 0===s?void 0:s.fileType)&&void 0!==i?i:"")&&(e.file=null!==(n=yield this.collection.getBlob(e._uploadedMetaData.fileKey))&&void 0!==n?n:void 0)}))))))}if(r.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)if(r instanceof Q){const t=e.scheduledInfo.scheduledMessageParams;r.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.scheduledInfo.scheduledMessageParams;t.fileKey&&"string"==typeof t.fileKey&&"string"==typeof t.fileType&&Ne(t.fileType)&&(t.file=null!==(n=yield this.collection.getBlob(t.fileKey))&&void 0!==n?n:void 0),r.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(t,r)}return r}))}_getFileInfoBlobKey(e,t){return`${e}.${t}`}get(e){return t.__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:s=new Mi,order:i=exports.MessageListOrder.CHANNEL_LATEST,sendingStatus:n,backward:a=!1,parentMessageId:r}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const o=Si(i),l={"/where":e=>!!(i!==exports.MessageListOrder.NEWEST_CHILD_MESSAGE||r&&0!==e.parentMessageId&&e.parentMessageId===r)&&s.match(this._deserialize(e))};e&&(l.channelUrl=e),n&&(l.sendingStatus=n);const d={where:l,index:o,backward:a},u=yield this.collection.query(d),c=yield u.fetch({});return Promise.all(c.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._deserializeWithMessageCreateParams(e)})))))}return[]}))}getAllChildMessages(e,s=new Mi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){(e instanceof Y||e instanceof G)&&(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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__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 t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e}}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}saveBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y){if(e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}if(e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams){const t=e.scheduledInfo.scheduledMessageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}}else if(e instanceof G){const s=e.messageParams;s&&s.fileInfoList&&Array.isArray(s.fileInfoList)&&(yield Promise.all(s.fileInfoList.map(((s,i)=>t.__awaiter(this,void 0,void 0,(function*(){if(s.file&&we(s.file)){const t=yield this.collection.saveBlob(s.file,this._getFileInfoBlobKey(e.reqId,i));s._uploadedMetaData||(s._uploadedMetaData={}),s._uploadedMetaData.fileKey=t,s._uploadedMetaData.fileType=Ce.BLOB}}))))))}}))}}const Ui={};class Ri extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _unsentMessageCache(){return Pi.of(this._iid)}constructor(e){super(e),Ui[e]=this}static of(e,t=!1){return Ui[e]&&!t||(Ui[e]=new Ri(e)),Ui[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(ds)}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 $i.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new Mi,order:a=exports.MessageListOrder.CHANNEL_LATEST,backward:r=!1,parentMessageId:o,isPollOnly:l=!1,exactMatch:d=!1,inclusive:u=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const c=Si(a),h={where:{channelUrl:e,"/where":e=>{if(null!=s&&""!==s)switch(a){case exports.MessageListOrder.CHANNEL_LATEST:if(d&&e.createdAt!==s)return!1;if(r){if(u&&e.createdAts||!u&&e.createdAt>=s)return!1;break;case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:if(!o||0===e.parentMessageId||e.parentMessageId!==o)return!1}return!(l&&!e._poll)&&n.match(this._deserialize(e))}},index:c,backward:r},p=yield this.collection.query(h),m=yield p.fetch({limit:null!=i?i:void 0});return Promise.all(m.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return this._deserialize(e)})))))}return[]}))}getAllChildMessages(e,s=new Mi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})}))}upsert(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.saveBlobs(e);for(const t of e)if(null===(s=t.threadInfo)||void 0===s?void 0:s._isUpdateRequired){const e=yield this.get(t.messageId);(null==e?void 0:e.threadInfo)&&t.threadInfo._updateFrom(e.threadInfo)}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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t;let s=[];(null===(t=e.threadInfo)||void 0===t?void 0:t.replyCount)&&e.threadInfo.replyCount>0&&(s=yield this.getAllChildMessages(e)),s.length>0&&(s.forEach((t=>t.applyParentMessage(e))),yield this.upsert(s))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(`${t}`)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:Si(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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Si(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=Si(exports.MessageListOrder.CHANNEL_LATEST),n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}saveBlobs(e){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y&&e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s}}})))))}))}_getGroupChannelPreferenceSize(e){return t.__awaiter(this,void 0,void 0,(function*(){let t=0;const{preference:s}=this._cacheContext,i=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),n=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),a=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),r=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`);return i&&(t+=JSON.stringify(i).length),n&&(t+=JSON.stringify(n).length),a&&(t+=JSON.stringify(a).length),r&&(t+=JSON.stringify(r).length),t}))}}const xi={};class ki extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),xi[e]=this}static of(e,t=!1){return xi[e]&&!t||(xi[e]=new ki(e)),xi[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(us)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){return Object.assign({},e.serialize())}_deserialize(e){return $i.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new Mi,backward:a=!1,exactMatch:r=!1,inclusive:o=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t={where:{channelUrl:e,"/where":e=>{if(s){if(r&&e.createdAt!==s)return!1;if(a){if(o&&e.createdAts||!o&&e.createdAt>=s)return!1}return n.match(this._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:a},l=yield this.collection.query(t);return(yield l.fetch({limit:null!=i?i:void 0})).map((e=>this._deserialize(e)))}return[]}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=e.map((e=>this._serialize(e)));yield this.collection.upsertMany(t)}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}markAsReadByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.updateIf({where:{channelUrl:e,messageStatus:exports.NotificationMessageStatus.SENT,createdAt:{"<":s}}},{set:{messageStatus:exports.NotificationMessageStatus.READ}}))}))}markAsReadByMessageIds(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){return(yield this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":s},messageStatus:exports.NotificationMessageStatus.SENT}},{set:{messageStatus:exports.NotificationMessageStatus.READ}})).length}return 0}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]});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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Si(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=["channelUrl","-createdAt","-notificationId"],n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}}const Li={};class Di extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _dispatcher(){return t.Vault.of(this._iid).dispatcher}get _messageCache(){return Ri.of(this._iid)}get _unsentMessageCache(){return Pi.of(this._iid)}get _notificationCache(){return ki.of(this._iid)}constructor(e){super(e),this._observers=new Map,this._dispatcherContext=this._dispatcher.on((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof t.MessageUpdateEventCommand){const{messages:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&e.messageId>0)),r=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&0===e.messageId)),o=s.filter((e=>e instanceof H));a.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.upsert(a),yield this._unsentMessageCache.remove(a.map((e=>e instanceof F?e.reqId:null)).filter((e=>null!==e)))})))),n||this._broadcastUpdateEvent(a,i)),r.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.upsert(r)})))),n||this._broadcastUpdateEvent(r,i)),o.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._notificationCache.upsert(o)})))),n||this._broadcastUpdateEvent(o,i))}else if(e instanceof t.MessageRemoveEventCommand){const{messageIds:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>"number"==typeof e)),r=s.filter((e=>"string"==typeof e));yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){a.length>0&&(yield this._messageCache.remove(a)),r.length>0&&(yield this._notificationCache.remove(r))})))),n||this._broadcastRemoveEvent(s,i)}else if(e instanceof t.UnsentMessageRemoveEventCommand){const{reqId:s,source:i}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([s])})))),this._broadcastRemoveUnsentEvent(s,i)}else if(e instanceof t.PollChangeLogEventCommand){const{polls:s,source:i}=e;if(this._cacheContext.localCacheEnabled){const e=s.map((e=>e.messageId)),i=(yield Promise.all(e.map((e=>this._messageCache.get(e))))).filter((e=>e));i.length>0&&s.forEach((e=>{const t=i.find((t=>t.messageId===e.messageId));t&&t.applyPoll(e)})),yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert(i)}))))}this._broadcastPollChangeLogEvent(s,i)}else if(e instanceof t.PollUpdateInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollUpdateEvent(s,i)}else if(e instanceof t.PollVoteInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollVoteEvent(s,i)}else if(e instanceof t.ReactionUpdateEventCommand){const{event:t,source:s}=e;t.messageId>0&&this._broadcastReactionUpdateEvent(t,s)}else if(e instanceof t.ThreadUpdateEventCommand){const{event:t,source:s}=e;this._broadcastThreadUpdateEvent(t,s)}}))))}static of(e,t=!1){var s;return Li[e]&&!t||(Li[e]&&(null===(s=Li[e]._dispatcherContext)||void 0===s||s.close()),Li[e]=new Di(e)),Li[e]}_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)}_broadcastReactionUpdateEvent(e,t){for(const s of this._observers.values())s.onReactionUpdate&&s.onReactionUpdate(e,t)}_broadcastThreadUpdateEvent(e,t){for(const s of this._observers.values())s.onThreadInfoUpdate&&s.onThreadInfoUpdate(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const qi=20;class Fi extends t.APIRequestCommand{constructor(e){const{reverse:s=!1,limit:i=qi,keys:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}`,this.params=t.deundefined({token:a,limit:i,reverse:s,order:t.MessageTemplateListOrder.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:n})}}class Bi extends t.APIResponseCommand{constructor(e,t){super(e,t);const{next:s,has_more:i=!1,templates:n}=t;this.nextToken=s,this.hasMore=i,this.templates=n.map((e=>({template:JSON.stringify(e)})))}}class ji extends t.APIRequestCommand{constructor(e){const{key:s}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}/${s}`}}class Vi extends t.APIResponseCommand{constructor(e,t){super(e,t),this.template=JSON.stringify(t)}}const zi={};class $i{constructor(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}){this._iid=e,this._sdkState=t,this._requestQueue=i,this._dispatcher=s,this._cacheContext=a,Ri.of(e),Pi.of(e),Di.of(e),this.fileMessageQueue=new ne(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}),zi[e]=this}static of(e){return zi[e]}buildMessageFromSerializedData(e){const s=t.deserialize(e);if(s.notificationId)return new H(this._iid,H.payloadify(s));switch(s.messageType){case t.MessageType.USER:return new Q(this._iid,Q.payloadify(s));case t.MessageType.FILE:return G._isMultipleFilesMessageSerializedData(s)?new G(this._iid,G.payloadify(s)):new Y(this._iid,Y.payloadify(s));case t.MessageType.ADMIN:return new V(this._iid,V.payloadify(s))}throw t.SendbirdError.invalidParameters}buildUserMessageCreateParamsFromSerializedData(e,s){return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,message:s.message,translationTargetLanguages:Object.keys(s.translations),pollId:e.pollId}))}buildFileMessageCreateParamsFromSerializedData(e,s){var i;return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,file:e.file,fileKey:e.fileKey,fileUrl:s.plainUrl,fileName:s.name,fileSize:s.size,mimeType:s.type,thumbnailSizes:null===(i=s.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),fileType:e.fileType,requireAuth:s.requireAuth}))}buildMultipleFilesMessageCreateParamsFromSerializedData(e,s){return t.deundefined({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,fileInfoList:e.fileInfoList.map((e=>new J(this._iid,e)))})}buildScheduledUserMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildScheduledFileMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildSenderFromSerializedData(e){const s=t.deserialize(e);return new p(this._iid,p.payloadify(s))}getMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new de(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ue);return i}))}getScheduledMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new _e(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ge);return i}))}getMessagesByMessageId(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,token:String(i)},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}getMessagesByTimestamp(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}_getMessagesByTimestampForCollection(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE,r,o){return t.__awaiter(this,void 0,void 0,(function*(){const l=new ce(Object.assign(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n),{checkingHasNext:r,checkingContinuousMessages:o})),d=yield this._requestQueue.send(l),{messages:u,isContinuousMessages:c,hasNext:h}=d.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:u,source:a})),{messages:u,isContinuousMessages:c,hasNext:h}}))}getThreadedMessagesByTimestamp(e,s,i,n=t.CollectionEventSource.REQUEST_THREADED_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const a=new ce(Object.assign(Object.assign(Object.assign({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:s},B),i),{replyType:t.ReplyType.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),r=yield this._requestQueue.send(a),{messages:o}=r.as(he),l=o.slice(1);return l.forEach((t=>{t.parentMessage=e})),this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:n})),{parentMessage:o[0],threadedMessages:l}}))}getMessageTemplatesByToken(e,s={}){return t.__awaiter(this,void 0,void 0,(function*(){const t=new Fi(Object.assign({token:e},s)),i=yield this._requestQueue.send(t),{hasMore:n,nextToken:a,templates:r}=i.as(Bi);return{hasMore:n,token:a,templates:r}}))}getMessageTemplate(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new ji({key:e}),s=yield this._requestQueue.send(t),{template:i}=s.as(Vi);return{template:i}}))}getMessageChangelogs(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS){return t.__awaiter(this,void 0,void 0,(function*(){const r=new pe(t.deundefined(t.undefineNullProps(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},oe),n)))),o=yield this._requestQueue.send(r),{updatedMessages:l,deletedMessagesInfo:d,hasMore:u,nextToken:c}=o.as(me),h=d.map((e=>e.messageId));return l.length>0&&this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),h.length>0&&this._dispatcher.dispatch(new t.MessageRemoveEventCommand({messageIds:h,source:a})),{updatedMessages:l,deletedMessageIds:h,hasMore:u,token:c}}))}}class Qi extends t.InstancedObject{constructor(e,s){super(e),this.targetMessageId=0;const i=s.thread_info,n=s.parent_message_id,r=s.channel_url,o=s.channel_type;i&&t.isTypeOf("object",i)&&t.isTypeOf("number",n)&&t.isTypeOf("string",r)&&t.isTypeOf("string",o)&&(this.threadInfo=new a(e,i),this.targetMessageId=n,this.channelUrl=r,this.channelType=o)}}const Gi={channelUrl:"",channelType:t.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1};class Ki extends t.APIRequestCommand{constructor({channelCustomType:e,keyword:s,limit:i,reverse:n,exactMatch:a,channelUrl:r,order:o,messageTimestampFrom:l,messageTimestampTo:d,advancedQuery:u,targetFields:c,nextToken:h}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_SEARCH}/messages`,this.params={custom_type:e,query:s,limit:i,reverse:n,exact_match:a,channel_url:r,message_ts_from:l,message_ts_to:d,sort_field:o,advanced_query:u,target_fields:c,after:h}}}class Hi extends t.APIResponseCommand{constructor(e,t){super(e,t),this.messages=t.results.map((t=>W(e,t))),this.hasNext=t.has_next,this.nextToken=t.end_cursor,this.totalCount=t.total_count}}var Wi;exports.MessageSearchOrder=void 0,(Wi=exports.MessageSearchOrder||(exports.MessageSearchOrder={})).SCORE="score",Wi.TIMESTAMP="ts";class Yi extends t.BaseListQuery{constructor(e,t){var s,i,n,a,r,o,l,d,u;super(e,t),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=t.keyword,this.reverse=null!==(s=t.reverse)&&void 0!==s&&s,this.exactMatch=null!==(i=t.exactMatch)&&void 0!==i&&i,this.channelUrl=null!==(n=t.channelUrl)&&void 0!==n?n:"",this.channelCustomType=null!==(a=t.channelCustomType)&&void 0!==a?a:"",this.messageTimestampFrom=null!==(r=t.messageTimestampFrom)&&void 0!==r?r:null,this.messageTimestampTo=null!==(o=t.messageTimestampTo)&&void 0!==o?o:null,this.order=null!==(l=t.order)&&void 0!==l?l:exports.MessageSearchOrder.SCORE,this.advancedQuery=null!==(d=t.advancedQuery)&&void 0!==d&&d,this.targetFields=null!==(u=t.targetFields)&&void 0!==u?u:null}_validate(){return super._validate()&&t.isTypeOf("string",this.keyword)&&this.keyword.length>0&&t.isTypeOf("boolean",this.reverse)&&t.isTypeOf("boolean",this.exactMatch)&&t.isTypeOf("string",this.channelUrl)&&t.isTypeOf("string",this.channelCustomType)&&(t.isTypeOf("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(t.isTypeOf("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&t.isEnumOf(exports.MessageSearchOrder,this.order)&&t.isTypeOf("boolean",this.advancedQuery)&&t.isArrayOf("string",this.targetFields,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Ki(t.undefineNullProps(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),i=yield e.send(s),{messages:n,hasNext:a,nextToken:r,totalCount:o}=i.as(Hi);return this._nextToken=r,this._hasNext=a,this._isLoading=!1,this.totalCount=o,n}return[]}throw t.SendbirdError.invalidParameters}))}}exports.AdminMessage=V,exports.AppleCriticalAlertOptions=u,exports.BanUserEventCommand=At,exports.BannedUserListQuery=Ye,exports.BaseChannel=Es,exports.BaseMessage=q,exports.BaseMessageUpdateParamsDefault=Le,exports.BaseStore=_i,exports.Config=bs,exports.CreateScheduledUserMessageResponseCommand=Ht,exports.DEFAULT_FEED_LIMIT=100,exports.DEFAULT_GROUPCHANNEL_LIMIT=100,exports.DEFAULT_MESSAGE_LIMIT=100,exports.DEFAULT_NOTIFICATION_LIMIT=100,exports.Feedback=h,exports.FileMessage=Y,exports.FileMessageEventCommand=ee,exports.FreezeEventCommand=Pt,exports.IndexedDbStore=class extends _i{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:104857600})),this._storeName=vi,this._state=Ii.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}isTransactionInactiveError(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}_putToObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.put(s);n.addEventListener("success",(e=>{t(e.target.result)})),n.addEventListener("error",(()=>{i("Failed to write.")}))}))}))}_deleteFromObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.delete(s);n.addEventListener("success",(()=>t(s))),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_openDatabase(e){return new Promise(((t,s)=>{if(this._indexedDb){this._state=Ii.OPENING;const i=this._indexedDb.open(e);i.addEventListener("upgradeneeded",(e=>{e.target.result.createObjectStore(vi,{keyPath:"key"})})),i.addEventListener("success",(s=>{this._state=Ii.OPEN,this._database=s.target.result,this._openJobQueue.forEach((e=>e())),this._openJobQueue=[],this._database.onclose=()=>{this._database=void 0,this._state=Ii.OPENING,setTimeout((()=>{this._openDatabase(e)}),5)},t(this._database)})),i.addEventListener("error",(e=>{this._state=Ii.UNINITIALIZED,s(e.target.error)}))}else s(Os.storeNotAvailable)}))}_getObjectStore(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);switch(this._state){case Ii.UNINITIALIZED:case Ii.OPEN:throw Os.storeNotInitialized;case Ii.OPENING:case Ii.CLOSED:return new Promise((t=>{this._openJobQueue.push((()=>t(this._getObjectStore(e))))}));default:return yield this._getObjectStore(e)}}))}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readonly");return yield new Promise(((t,s)=>{const i=e.getAllKeys();i.addEventListener("success",(e=>{t(e.target.result)})),i.addEventListener("error",(e=>s(e.target.error)))}))}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readonly");return yield new Promise(((s,i)=>{const n=t.get(e);n.addEventListener("success",(e=>{var t;s(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._putToObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._putToObjectStore(t,s)}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._deleteFromObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._deleteFromObjectStore(t,s)}}))}_triggerDatabaseClose(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}checkAvailability(){return t.__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 Os.storeNotAvailable;if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!ni())throw Os.storeNotAvailable;if(ni()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")){if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Os.storeNotAvailableInPrivateBrowsing}else yield new Promise(((e,t)=>{if(this._indexedDb)try{const s=this._indexedDb.open("_testMozilla");s.onerror=()=>t(Os.storeNotAvailableInPrivateBrowsing),s.onsuccess=s=>{if(s.target.result.close(),this._indexedDb){const t=this._indexedDb.deleteDatabase("_testMozilla");t.onerror=()=>e(),t.onsuccess=()=>e()}else t(Os.storeNotAvailable)}}catch(e){t(Os.storeNotAvailableInPrivateBrowsing)}else t(Os.storeNotAvailable)}))}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yield this.checkAvailability(),yield this._openDatabase(e),yield this._resetIfEncryptionChanged()}))}clear(){const e=Object.create(null,{clear:{get:()=>super.clear}});return t.__awaiter(this,void 0,void 0,(function*(){yield e.clear.call(this);const t=yield this._getObjectStore("readwrite");return yield new Promise(((e,s)=>{const i=t.clear();i.addEventListener("success",(()=>e())),i.addEventListener("error",(e=>s(e.target.error)))}))}))}},exports.Logger=class{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)}},exports.MemoryStore=fi,exports.MessageBroadcast=Di,exports.MessageCache=Ri,exports.MessageFilter=Mi,exports.MessageForm=k,exports.MessageFormItem=L,exports.MessageManager=$i,exports.MessageMetaArray=m,exports.MessageRequestHandler=Ie,exports.MessageRetrievalParamsDefault=Gi,exports.MessageReviewInfo=$,exports.MessageSearchQuery=Yi,exports.MessageThreadInfoUpdatedEventCommand=N,exports.MultipleFilesMessage=G,exports.MultipleFilesMessageRequestHandler=ps,exports.MuteUserEventCommand=bt,exports.MutedUserListQuery=Ke,exports.NESTDB_FEEDCHANNEL_COLLECTION_KEY="url",exports.NESTDB_FEEDCHANNEL_COLLECTION_NAME="FeedChannel",exports.NESTDB_GROUPCHANNEL_COLLECTION_KEY="url",exports.NESTDB_GROUPCHANNEL_COLLECTION_NAME="GroupChannel",exports.NESTDB_MESSAGE_COLLECTION_KEY="messageId",exports.NESTDB_MESSAGE_COLLECTION_NAME=ds,exports.NESTDB_NOTIFICATION_COLLECTION_KEY="notificationId",exports.NESTDB_NOTIFICATION_COLLECTION_NAME=us,exports.NESTDB_POLL_COLLECTION_KEY="pollId",exports.NESTDB_POLL_COLLECTION_NAME="Poll",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY="reqId",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME=wi,exports.NestDB=class{constructor({name:e,version:t,store:s,config:i}){this.name=e,this._version=t,this._state=exports.NestDBState.INIT,this._config=i||new bs({dbname:e}),this._store=s,this._event={success:Us,error:Us,storeReplaced:Us,upgrade:ks},this._collections=new Map,this._globalMutex=new di(`${this.name}.lock`),this._config.disableLogger&&pi.off(),new Js({dbname:e,limit:this._config.cacheLimit})}get version(){return this._version}get state(){return this._state}get store(){return this._store}estimateUsage(){return t.__awaiter(this,void 0,void 0,(function*(){return yield(e=this._store,t.__awaiter(void 0,void 0,void 0,(function*(){return yield e.usage()})));var e}))}commitSchema(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._state!==exports.NestDBState.OPENING)throw Os.databaseSchemaNotOnUpgrade;yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){const{collectionName:t,keyName:s,index:i=[]}=e;this._collections.has(t)||this._collections.set(t,new ui({dbname:this.name,collectionName:t,keyName:s,indexes:i,store:this._store}));const n=this._collections.get(t);n&&(yield n.init())})))))}))}open(){var e;return t.__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=(s=this.name,`${Bs(s)}.metadata`),n={version:0,collectionNames:[]},a=null!==(e=yield this._store.get(i))&&void 0!==e?e:n;return new Promise(((e,s)=>{const n=e=>{a.versiont.__awaiter(this,void 0,void 0,(function*(){if(s)e({continued:!1,err:s});else{a.version++,a.collectionNames=Array.from(this._collections.keys());try{yield this._store.set({key:i,value:a}),e({continued:!0})}catch(t){e({continued:!1,err:t})}}})))):e({continued:!1})},r=i=>{const{continued:o=!1,err:l=null}=i;if(o)setTimeout((()=>n(r)),10);else if(l)pi.error(l.message),this._globalMutex.unlock(),this._event.error(l),s(l);else{const i=[];a.collectionNames.forEach((e=>{const s=this._collections.get(e);s&&s.state===Ss.READY||i.push((()=>t.__awaiter(this,void 0,void 0,(function*(){const t=yield ui.metadataOf(this.name,e,this._store);if(t){const s=new ui({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:t.indexes,store:this._store});this._collections.set(e,s),yield s.init()}})))())})),Promise.all(i).then((()=>{this._state=exports.NestDBState.OPENED,this._globalMutex.unlock(),this._event.success(),e()})).catch((e=>{pi.error(e.message),this._globalMutex.unlock(),this._event.error(e),s(e)}))}};n(r)}))}catch(e){switch(e.code){case Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:pi.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new fi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;case Ms.STORE_NOT_AVAILABLE:pi.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 fi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;default:throw pi.error(e.message),this._globalMutex.unlock(),this._event.error(e),e}}}var s}))}close(){this._collections.forEach((e=>e.close())),this._state=exports.NestDBState.CLOSED}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this._collections.values()).map((e=>e.clear())))}))}reset(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.name);e&&e.clearForDatabase(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]=ks;else this._event[e]=Us}collection(e){const t=this._collections.get(e);if(t)return t;throw Os.collectionNotReady}},exports.NestDBError=Os,exports.NotificationMessage=H,exports.NotificationMessageCache=ki,exports.OGImage=l,exports.OGMetaData=d,exports.OperatorListQuery=ze,exports.PENDING_MESSAGE_DELAY=2,exports.PinnedMessage=ms,exports.PinnedMessageListQuery=ys,exports.Plugin=z,exports.PollVoteEventCommand=ls,exports.PreviousMessageListQuery=$e,exports.Reaction=o,exports.ReactionEvent=r,exports.ReadAPIRequestCommand=v,exports.ReadAPIResponseCommand=E,exports.ReadEventCommand=I,exports.ReadRequestCommand=f,exports.ReadStatus=y,exports.RestrictedUser=ve,exports.RestrictionInfo=fe,exports.ScheduledFileMessageCreateParamsDefault=Ci,exports.ScheduledUserMessageCreateParamsDefault=Ai,exports.SendableMessage=F,exports.Sender=p,exports.ThreadInfo=a,exports.ThreadInfoUpdateEvent=Qi,exports.Thumbnail=s,exports.UnbanUserEventCommand=wt,exports.UnmuteUserEventCommand=St,exports.UnsentMessageCache=Pi,exports.UpdateFileMessageEventCommand=Bt,exports.UpdateMetaCounterEventCommand=vt,exports.UpdateMetaDataEventCommand=lt,exports.UpdateUserMessageEventCommand=qt,exports.UploadFileRequestCommand=i,exports.UploadFileResponseCommand=n,exports.UploadedFileInfo=w,exports.UserMessage=Q,exports.UserMessageEventCommand=Lt,exports.UserMessageUpdateParamsDefault=qe,exports.createFileMessageCreateParams=Re,exports.createFileMessageCreateParamsFromFailedFileMessage=xe,exports.createMultipleFilesMessageCreateParams=function(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((e=>{var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((e=>({maxWidth:e.width,maxHeight:e.height}))),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))},exports.createUserMessageCreateParams=Se,exports.createUserMessageCreateParamsFromFailedUserMessage=Oe,exports.getMessageIndexBy=Si,exports.getNotificationMessageIndexBy=Oi,exports.parseMessagePayload=W,exports.payloadifyMessage=e=>{if(e.notificationId)return H.payloadify(e);switch(e.messageType){case t.MessageType.USER:return Q.payloadify(e);case t.MessageType.FILE:return e.fileInfoList?G.payloadify(e):Y.payloadify(e);case t.MessageType.ADMIN:return V.payloadify(e);default:throw t.SendbirdError.unknown}},exports.validateBaseMessageUpdateParams=De,exports.validateMessageRetrievalParams=e=>t.isTypeOf("string",e.channelUrl)&&t.isEnumOf(t.ChannelType,e.channelType)&&t.isTypeOf("number",e.messageId)&&t.isTypeOf("boolean",e.includeReactions,!0)&&t.isTypeOf("boolean",e.includeMetaArray,!0)&&t.isTypeOf("boolean",e.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",e.includeThreadInfo,!0),exports.validateScheduledFileMessageCreateParams=e=>Te(e)&&t.isTypeOf("number",e.scheduledAt)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),exports.validateScheduledUserMessageCreateParams=e=>Ae(e)&&t.isTypeOf("number",e.scheduledAt,!0),exports.validateUserMessageUpdateParams=Fe; diff --git a/cjs/lib/__bundle-1a495950.cjs b/cjs/lib/__bundle-1a495950.cjs new file mode 100644 index 0000000..e2b3c16 --- /dev/null +++ b/cjs/lib/__bundle-1a495950.cjs @@ -0,0 +1,2 @@ +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.14.4";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.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.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",t[t.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",t[t.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",t[t.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",t[t.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",t[t.SESSION_REVOKED=400310]="SESSION_REVOKED",t[t.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",t[t.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",t[t.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",t[t.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",t[t.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",t[t.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",t[t.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",t[t.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",t[t.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",t[t.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",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.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",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.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_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",t[t.USER_DEACTIVATED=900021]="USER_DEACTIVATED",t[t.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";const n=e=>!(e instanceof o&&!e.shouldThrowOutside);class o extends Error{constructor({code:e=0,message:t=""}){super(t),this.shouldThrowOutside=!1,this._detail="",this.name="SendbirdError",this.code=e,Object.setPrototypeOf(this,o.prototype)}get detail(){return this._detail}setDetail(e){this._detail=e}get isInvalidTokenError(){return this.code===exports.SendbirdErrorCode.INVALID_TOKEN}get isSessionExpiredError(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}get isSessionTokenExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}get isSessionKeyExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}get isSessionInvalidatedError(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}get isSessionRevokedError(){return this.code===exports.SendbirdErrorCode.SESSION_REVOKED}get isUserAuthDeactivedError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED}get isUserAuthDeletedOrNotFoundError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}get isNetworkError(){return this.code===exports.SendbirdErrorCode.NETWORK_ERROR||this.code===exports.SendbirdErrorCode.NETWORK_ROUTING_ERROR}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 xmlHttpRequestNotSupported(){return new o({code:exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}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 channelTypeNotSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}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 tooManyRequests(){return new o({code:exports.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}static get alreadyConnectedAsAnotherUser(){return new o({code:exports.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}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."})}static get statLogUploadLimitExceededError(){return new o({code:exports.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}static get malformedDataError(){return new o({code:exports.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}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,exports.SendbirdErrorCode.USER_DEACTIVATED,exports.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],a=[exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.CONNECTION_REQUIRED],l=(e,t,s=!1)=>!(!s||!_(t))||("string"!=typeof e?"object"==typeof e?d(e,t):c(e,t):typeof t===e),d=(e,t,s=!1)=>!(!s||!_(t))||Object.values(e).includes(t),c=(e,t)=>t instanceof e,h=(e,t,s=!1)=>!(!s||!_(t))||Array.isArray(t)&&t.every((t=>l(e,t))),u=(e,t=!1)=>{if(t&&_(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},_=e=>null==e;class p{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 E={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=exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=i}get maxSize(){return this._maxSize}get clearOrder(){return this._clearOrder}get clearOrderComparator(){var e;return this._clearOrder===exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}get enableAutoResend(){return this._enableAutoResend}}var A;exports.SessionService=void 0,(A=exports.SessionService||(exports.SessionService={})).FEED="feed",A.CHAT="chat",A.CHAT_API="chat_api";class N{constructor(){this.isRefreshing=!1}get hasSession(){return!!this.sessionKey}get hasChatServicePermission(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(exports.SessionService.CHAT))}clear(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}const w=()=>{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 b{constructor({container:e}){this._container={},this._container=e,this.key=w()}_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(){Object.keys(this._container).forEach((e=>{var t;null===(t=this._container[e])||void 0===t||t.delete(this.key)}))}}class I{constructor(){this._container={}}on(e,t){return new b({container:this._container}).on(e,t)}once(e,t){return new b({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 I}on(e){return this._dispatcher.on("event",e)}once(e){return this._dispatcher.once("event",e)}dispatch(e){this._dispatcher.dispatch("event",e)}}class R{}const k=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},O=e=>{if(null!=e){if("object"==typeof e){if(Array.isArray(e)){const t=[...e];for(let e=0;e{null===e[t]&&delete e[t]})),e}return e}};var D,L,U,P,M,q,F,H,V,z,G,K,B;exports.ChannelType=void 0,(D=exports.ChannelType||(exports.ChannelType={})).BASE="base",D.GROUP="group",D.OPEN="open",D.FEED="feed",exports.Role=void 0,(L=exports.Role||(exports.Role={})).OPERATOR="operator",L.NONE="none",exports.MutedState=void 0,(U=exports.MutedState||(exports.MutedState={})).MUTED="muted",U.UNMUTED="unmuted",exports.MessageType=void 0,(P=exports.MessageType||(exports.MessageType={})).BASE="base",P.USER="user",P.FILE="file",P.ADMIN="admin",exports.MessageTypeFilter=void 0,(M=exports.MessageTypeFilter||(exports.MessageTypeFilter={})).ALL="",M.USER="MESG",M.FILE="FILE",M.ADMIN="ADMM",exports.ServerSideMessageType=void 0,(q=exports.ServerSideMessageType||(exports.ServerSideMessageType={})).USER="MESG",q.FILE="FILE",q.ADMIN="ADMM",exports.MentionType=void 0,(F=exports.MentionType||(exports.MentionType={})).USERS="users",F.CHANNEL="channel",exports.ReplyType=void 0,(H=exports.ReplyType||(exports.ReplyType={})).ALL="all",H.NONE="none",H.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",exports.PushNotificationDeliveryOption=void 0,(V=exports.PushNotificationDeliveryOption||(exports.PushNotificationDeliveryOption={})).DEFAULT="default",V.SUPPRESS="suppress",exports.SendingStatus=void 0,(z=exports.SendingStatus||(exports.SendingStatus={})).PENDING="pending",z.SCHEDULED="scheduled",z.SUCCEEDED="succeeded",z.FAILED="failed",z.CANCELED="canceled",exports.MessageReviewStatus=void 0,(G=exports.MessageReviewStatus||(exports.MessageReviewStatus={})).INREVIEW="InReview",G.APPROVED="Approved",exports.NotificationPriority=void 0,(K=exports.NotificationPriority||(exports.NotificationPriority={})).HIGH="high",K.NORMAL="normal",K.LOW="low",exports.MessageTemplateListOrder=void 0,(B=exports.MessageTemplateListOrder||(exports.MessageTemplateListOrder={})).CREATED_AT="created_at",B.UPDATED_AT="updated_at";const Q="v3",j=`/${Q}/users`,$=`/${Q}/sdk/users`,W=`/${Q}/storage/file`,Z=`/${Q}/group_channels`,Y=`/${Q}/sdk/group_channels`,X=`/${Q}/open_channels`,J=`/${Q}/sdk/open_channels`,ee=`/${Q}/search`,te=`/${Q}/report`,se=`/${Q}/emojis`,ie=`/${Q}/emoji_categories`,ne=`/${Q}/polls`,oe=`/${Q}/scheduled_messages`,re=`/${Q}/sdk/ui_kit/configuration`,ae=`/${Q}/sdk/statistics`,le=`/${Q}/notifications`,de=`/${Q}/notifications/users`,ce=`/${Q}/message_templates`,he=`/${Q}/sdk/push_delivery`,ue=`/${Q}/forms`,_e=e=>{switch(e){case exports.ChannelType.FEED:case exports.ChannelType.GROUP:return Z;case exports.ChannelType.OPEN:return X;default:return null}},pe=(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},Ee=(e,t,s)=>{var i;let n=t||new FormData;for(const t in e){if(!e.hasOwnProperty(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=Ee(o,n,r)}return n};var ge;exports.APIRequestMethod=void 0,(ge=exports.APIRequestMethod||(exports.APIRequestMethod={})).GET="GET",ge.POST="POST",ge.PUT="PUT",ge.DELETE="DELETE";class fe extends R{constructor(){super(...arguments),this.params={},this.requireAuth=!0,this.headers={},this.requestId=w()}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=k(this.params);return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${this.encodeParams(e[t])}`)).join("&")}`}get payload(){const e=k(this.params);return Object.keys(e).some((t=>u(e[t])))?Ee(e):JSON.stringify(e)}get hasSessionKey(){return void 0!==this.headers["Session-Key"]}}class ve extends R{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 Se extends R{constructor(e){super(),this.requestId=e}}class me extends R{constructor({expires_in:e,reason:t=exports.SendbirdErrorCode.SESSION_KEY_EXPIRED,message:s=""}){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:case exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED:case exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND:this.error=new o({code:t,message:s})}}get invalidateSessionToken(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}class Ce extends R{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 Ce(e,s,i)}}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}as(e){return new e(this._iid,this.code,this.payload)}}class Te extends R{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:w(),this.ackRequired=t,this.payload.req_id=this.requestId}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}}class ye extends fe{constructor({userId:e,authToken:t,services:s,expiringSession:i=!0}){super(),this.path=`${j}/${e}/session_key`,this.method=exports.APIRequestMethod.POST,this.params=k({token:t,services:s,expiring_session:!!i}),this.requireAuth=!1}}class Ae extends Te{constructor({authToken:e,expiringSession:t=!0,requestId:s}){super({code:"LOGI",payload:k({token:e,expiring_session:t?1:0,req_id:s}),ackRequired:!0})}}class Ne extends ve{constructor(e,t){super(e,t);const{key:s,expires_at:i,services:n}=t;this.key=s,this.expiresAt=i,this.services=n}}class we extends Ce{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):null}}class be extends R{constructor(e){super(),this.statLog=e}}class Ie extends R{constructor({request:e,deferred:t,error:s=o.requestFailed}){super(),this.request=e,this.deferred=t,this.error=s}}var xe;exports.StatType=void 0,(xe=exports.StatType||(exports.StatType={})).FEATURE_LOCALCACHE="feature:local_cache",xe.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",xe.NOTIFICATION="noti:stats",xe.WEBSOCKET_CONNECT="ws:connect",xe.API_RESULT="api:result";class Re{constructor({type:e,data:t,ts:s=Date.now()}){this.type=e,this.createdAt=s,this.data=t}static payloadify(e){return k({stat_type:e.type,ts:e.createdAt,data:k(e.data)})}}const ke=()=>"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product,Oe=()=>!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent));var De,Le,Ue;exports.SendbirdProduct=void 0,(De=exports.SendbirdProduct||(exports.SendbirdProduct={})).CHAT="chat",De.CALLS="calls",De.DESK="desk",De.LIVE="live",De.UIKIT_CHAT="uikit-chat",De.UIKIT_LIVE="uikit-live",exports.SendbirdPlatform=void 0,(Le=exports.SendbirdPlatform||(exports.SendbirdPlatform={})).ANDROID="android",Le.IOS="ios",Le.JS="js",Le.UNREAL="unreal",Le.UNITY="unity",Le.REACT_NATIVE="react-native",Le.FLUTTER="flutter",exports.DeviceOsPlatform=void 0,(Ue=exports.DeviceOsPlatform||(exports.DeviceOsPlatform={})).ANDROID="android",Ue.IOS="ios",Ue.WEB="web",Ue.MOBILE_WEB="mobile_web",Ue.WINDOWS="windows";class Pe{}Pe.sendbirdSdkUserAgentWithExtension=e=>{let t={main_sdk_info:`chat/${ke()?exports.SendbirdPlatform.REACT_NATIVE:exports.SendbirdPlatform.JS}/${i.SDK_VERSION}`,device_os_platform:Oe()?"mobile-web":"web",os_version:i.OS_VERSION};if(e){const{sendbirdExtensions:s,deviceOS:i,customData:n={}}=e;i.version&&(t.os_version=i.version),i.platform&&(t.device_os_platform=i.platform),s.length>0&&(t.extension_sdk_info=s.map((({product:e,platform:t,version:s})=>`${e}/${t}/${s}`)).join(",")),Object.keys(t).forEach((e=>delete n[e])),Object.keys(n).length>0&&(t=Object.assign(Object.assign({},t),n))}return Object.entries(t).map((([e,t])=>`${e}=${t}`)).join("&")},Pe.userAgentWithExtension=e=>{const t=ke()?"reactnative":"JS",s=e.sb_syncmanager?`s${e.sb_syncmanager}`:"",n=e.sb_uikit?`u${e.sb_uikit}`:"",o=e["device-os-platform"]?`o${e["device-os-platform"]}`:Oe()?"omobile-web":"oweb";return`${t}/c${i.SDK_VERSION}/${s}/${n}/${o}`};class Me{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=e=>{t(e)}}))}}class qe extends R{constructor(e){super(),this.requestId=e.requestId}}class Fe extends fe{constructor(e){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${_e(e.channelType)}/${e.channelUrl}/messages/${e.messageId}`,e.messageToken&&(this.params=k({mesg_token:e.messageToken}))}}class He{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:o=!1}){this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=t,this._sdkState=s,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof Se&&this.cancel(e.requestId)})),this._logger=n,this._shouldImportFetchCompat=o}_createHeader(e,t){const{appId:s,appVersion:n,sendbirdRuntimeEnvironment:o}=this._sdkState,r=Object.assign(Object.assign({},e.headers),{SendBird:`JS,${i.OS_VERSION},${i.SDK_VERSION},${s}${n?`,${n}`:""}`,"SB-User-Agent":Pe.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":Pe.sendbirdSdkUserAgentWithExtension(o)});return t||(r["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(r["Session-Key"]=this._session.sessionKey),r["App-Id"]=s,this._session&&this._session.authToken&&(r["Access-Token"]=this._session.authToken),r}_statLogApiResult(e,t,s){this._dispatcher.dispatch(new be(new Re({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}})))}_isBodyRequired(e){const{method:t}=e;return t!==exports.APIRequestMethod.GET&&(t!==exports.APIRequestMethod.DELETE||e instanceof Fe)}send(t){return e(this,void 0,void 0,(function*(){const{path:e,method:s,uploadProgressHandler:i}=t,n=this._isBodyRequired(t),{api:r}=this._sdkState,a=`${r.host}${e}${n?"":t.query}`,l=n?t.payload:null,d=this._createHeader(t,l instanceof FormData?l:void 0),c=new AbortController,{signal:h}=c;this._abortControl.set(t.requestId,c);const u=Date.now();try{if(i){const{xmlHttpRequest:e}=yield Promise.resolve().then((function(){return require("./__bundle-552fe22f.cjs")}));try{const s=yield e(this._iid,{requestId:t.requestId,method:t.method,url:a,headers:d,data:null!=l?l:void 0,uploadProgressHandler:i});return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),s}catch(e){if(!(e instanceof o&&e.code===exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED))throw e;this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored.")}}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-6301b3ce.cjs")}))),"function"!=typeof fetch&&(yield Promise.resolve().then((function(){return require("./__bundle-38c66c0d.cjs")})));const e=yield fetch(a,{method:s,body:l,headers:d,signal:h}),n=yield e.json();if(e.ok||e.redirected)return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),new ve(this._iid,n);if(n){const e=new o(n);if(e.isSessionExpiredError){if(this._dispatcher.dispatch(new me({reason:e.code,message:e.message})),!(t instanceof ye)){const s=new Me;return this._dispatcher.dispatch(new Ie({request:t,deferred:s,error:e})),s.promise}throw e}throw e.isSessionInvalidatedError?(this._dispatcher.dispatch(new me({reason:e.code,message:e.message})),e):e}throw o.requestFailed}catch(e){throw this._statLogApiResult(t,u,e),e instanceof o?(this._logger.debug("fail api request",e),e):"AbortError"===(null==e?void 0:e.name)?o.requestCanceled:(this._logger.debug("fail api request",e),o.networkError)}}))}cancel(e){if(this._abortControl.has(e)){this._abortControl.get(e).abort(),this._abortControl.delete(e)}this._dispatcher.dispatch(new qe({requestId:e}))}cancelAll(){for(const e of this._abortControl.values())e.abort();this._abortControl.clear(),this._dispatcher.dispatch(new qe({}))}}const Ve=()=>{}; +/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function ze(e){let t=e.length;for(;--t>=0;)e[t]=0}const Ge=256,Ke=286,Be=30,Qe=15,je=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]),$e=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]),Ze=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ye=new Array(576);ze(Ye);const Xe=new Array(60);ze(Xe);const Je=new Array(512);ze(Je);const et=new Array(256);ze(et);const tt=new Array(29);ze(tt);const st=new Array(Be);function it(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 nt,ot,rt;function at(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ze(st);const lt=e=>e<256?Je[e]:Je[256+(e>>>7)],dt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ct=(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<{ct(e,s[2*t],s[2*t+1])},ut=(e,t)=>{let s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1},_t=(e,t,s)=>{const i=new Array(16);let n,o,r=0;for(n=1;n<=Qe;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]=ut(i[t]++,t))}},pt=e=>{let t;for(t=0;t{e.bi_valid>8?dt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},gt=(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?ht(e,n,t):(o=et[n],ht(e,o+Ge+1,t),r=je[o],0!==r&&(n-=tt[o],ct(e,n,r)),i--,o=lt(i),ht(e,o,s),r=$e[o],0!==r&&(i-=st[o],ct(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--)ft(e,s,r);l=o;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ft(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++,ft(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,E=0;for(u=0;u<=Qe;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,E++),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!==E){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]--,E-=2}while(E>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),_t(s,d,e.bl_count)},mt=(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{ct(e,0+(i?1:0),3),Et(e),dt(e,s),dt(e,~s),s&&e.pending_buf.set(e.window.subarray(t,t+s),e.pending),e.pending+=s};var At=(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(mt(e,e.dyn_ltree,e.l_desc.max_code),mt(e,e.dyn_dtree,e.d_desc.max_code),St(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),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?yt(e,t,s,i):4===e.strategy||o===n?(ct(e,2+(i?1:0),3),vt(e,Ye,Xe)):(ct(e,4+(i?1:0),3),((e,t,s,i)=>{let n;for(ct(e,t-257,5),ct(e,s-1,5),ct(e,i-4,4),n=0;n{Tt||((()=>{let e,t,s,i,n;const o=new Array(16);for(s=0,i=0;i<28;i++)for(tt[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*(et[s]+Ge+1)]++,e.dyn_dtree[2*lt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ct(e,2,3),ht(e,256,Ye),(e=>{16===e.bi_valid?(dt(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 wt=(e,t,s,i)=>{let n=65535&e,o=e>>>16&65535,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};const bt=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 It=(e,t,s,i)=>{const n=bt,o=i+s;e^=-1;for(let s=i;s>>8^n[255&(e^t[s])];return~e},xt={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"},Rt={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:kt,_tr_stored_block:Ot,_tr_flush_block:Dt,_tr_tally:Lt,_tr_align:Ut}=Nt,{Z_NO_FLUSH:Pt,Z_PARTIAL_FLUSH:Mt,Z_FULL_FLUSH:qt,Z_FINISH:Ft,Z_BLOCK:Ht,Z_OK:Vt,Z_STREAM_END:zt,Z_STREAM_ERROR:Gt,Z_DATA_ERROR:Kt,Z_BUF_ERROR:Bt,Z_DEFAULT_COMPRESSION:Qt,Z_FILTERED:jt,Z_HUFFMAN_ONLY:$t,Z_RLE:Wt,Z_FIXED:Zt,Z_DEFAULT_STRATEGY:Yt,Z_UNKNOWN:Xt,Z_DEFLATED:Jt}=Rt,es=258,ts=262,ss=42,is=113,ns=666,os=(e,t)=>(e.msg=xt[t],t),rs=e=>2*e-(e>4?9:0),as=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ls=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 ds=(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))},hs=(e,t)=>{Dt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,cs(e.strm)},us=(e,t)=>{e.pending_buf[e.pending++]=t},_s=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ps=(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=wt(e.adler,t,n,s):2===e.state.wrap&&(e.adler=It(e.adler,t,n,s)),e.next_in+=n,e.total_in+=n,n)},Es=(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-ts?e.strstart-(e.w_size-ts):0,d=e.window,c=e.w_mask,h=e.prev,u=e.strstart+es;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},gs=e=>{const t=e.w_size;let s,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ts)&&(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),ls(e),i+=t),0===e.strm.avail_in)break;if(s=ps(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=ds(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=ds(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,cs(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&&(ps(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&&(ps(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===Ft)&&t!==Pt&&0===e.strm.avail_in&&i<=n)&&(s=i>n?n:i,r=t===Ft&&0===e.strm.avail_in&&s===i?1:0,Ot(e,e.block_start,s,r),e.block_start+=s,cs(e.strm)),r?3:1)},vs=(e,t)=>{let s,i;for(;;){if(e.lookahead=3&&(e.ins_h=ds(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-ts&&(e.match_length=Es(e,s)),e.match_length>=3)if(i=Lt(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=ds(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=ds(e,e.ins_h,e.window[e.strstart+1]);else i=Lt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(hs(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(e,!1),0===e.strm.avail_out)?1:2},Ss=(e,t)=>{let s,i,n;for(;;){if(e.lookahead=3&&(e.ins_h=ds(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=Lt(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=ds(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&&(hs(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Lt(e,0,e.window[e.strstart-1]),i&&hs(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=Lt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(e,!1),0===e.strm.avail_out)?1:2};function ms(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 Cs=[new ms(0,0,0,0,fs),new ms(4,4,8,4,vs),new ms(4,5,16,8,vs),new ms(4,6,32,32,vs),new ms(4,4,16,16,Ss),new ms(8,16,32,32,Ss),new ms(8,16,128,128,Ss),new ms(8,32,128,256,Ss),new ms(32,128,258,1024,Ss),new ms(32,258,258,4096,Ss)];function Ts(){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),as(this.dyn_ltree),as(this.dyn_dtree),as(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),as(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),as(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 ys=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==ss&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==is&&t.status!==ns?1:0},As=e=>{if(ys(e))return os(e,Gt);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?ss:is,e.adler=2===t.wrap?0:1,t.last_flush=-2,kt(t),Vt},Ns=e=>{const t=As(e);var s;return t===Vt&&((s=e.state).window_size=2*s.w_size,as(s.head),s.max_lazy_match=Cs[s.level].max_lazy,s.good_match=Cs[s.level].good_length,s.nice_match=Cs[s.level].nice_length,s.max_chain_length=Cs[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},ws=(e,t,s,i,n,o)=>{if(!e)return Gt;let r=1;if(t===Qt&&(t=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||s!==Jt||i<8||i>15||t<0||t>9||o<0||o>Zt||8===i&&1!==r)return os(e,Gt);8===i&&(i=9);const a=new Ts;return e.state=a,a.strm=e,a.status=ss,a.wrap=r,a.gzhead=null,a.w_bits=i,a.w_size=1<ws(e,t,Jt,15,8,Yt),deflateInit2:ws,deflateReset:Ns,deflateResetKeep:As,deflateSetHeader:(e,t)=>ys(e)||2!==e.state.wrap?Gt:(e.state.gzhead=t,Vt),deflate:(e,t)=>{if(ys(e)||t>Ht||t<0)return e?os(e,Gt):Gt;const s=e.state;if(!e.output||0!==e.avail_in&&!e.input||s.status===ns&&t!==Ft)return os(e,0===e.avail_out?Bt:Gt);const i=s.last_flush;if(s.last_flush=t,0!==s.pending){if(cs(e),0===e.avail_out)return s.last_flush=-1,Vt}else if(0===e.avail_in&&rs(t)<=rs(i)&&t!==Ft)return os(e,Bt);if(s.status===ns&&0!==e.avail_in)return os(e,Bt);if(s.status===ss&&0===s.wrap&&(s.status=is),s.status===ss){let t=Jt+(s.w_bits-8<<4)<<8,i=-1;if(i=s.strategy>=$t||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,_s(s,t),0!==s.strstart&&(_s(s,e.adler>>>16),_s(s,65535&e.adler)),e.adler=1,s.status=is,cs(e),0!==s.pending)return s.last_flush=-1,Vt}if(57===s.status)if(e.adler=0,us(s,31),us(s,139),us(s,8),s.gzhead)us(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)),us(s,255&s.gzhead.time),us(s,s.gzhead.time>>8&255),us(s,s.gzhead.time>>16&255),us(s,s.gzhead.time>>24&255),us(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),us(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(us(s,255&s.gzhead.extra.length),us(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=It(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69;else if(us(s,0),us(s,0),us(s,0),us(s,0),us(s,0),us(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),us(s,3),s.status=is,cs(e),0!==s.pending)return s.last_flush=-1,Vt;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=It(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex+=n,cs(e),0!==s.pending)return s.last_flush=-1,Vt;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=It(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=It(e.adler,s.pending_buf,s.pending-i,i)),cs(e),0!==s.pending)return s.last_flush=-1,Vt;i=0}t=s.gzindexi&&(e.adler=It(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=It(e.adler,s.pending_buf,s.pending-i,i)),cs(e),0!==s.pending)return s.last_flush=-1,Vt;i=0}t=s.gzindexi&&(e.adler=It(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&&(cs(e),0!==s.pending))return s.last_flush=-1,Vt;us(s,255&e.adler),us(s,e.adler>>8&255),e.adler=0}if(s.status=is,cs(e),0!==s.pending)return s.last_flush=-1,Vt}if(0!==e.avail_in||0!==s.lookahead||t!==Pt&&s.status!==ns){let i=0===s.level?fs(s,t):s.strategy===$t?((e,t)=>{let s;for(;;){if(0===e.lookahead&&(gs(e),0===e.lookahead)){if(t===Pt)return 1;break}if(e.match_length=0,s=Lt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(hs(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(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<=es){if(gs(e),e.lookahead<=es&&t===Pt)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+es;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=Lt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=Lt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(hs(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(e,!1),0===e.strm.avail_out)?1:2})(s,t):Cs[s.level].func(s,t);if(3!==i&&4!==i||(s.status=ns),1===i||3===i)return 0===e.avail_out&&(s.last_flush=-1),Vt;if(2===i&&(t===Mt?Ut(s):t!==Ht&&(Ot(s,0,0,!1),t===qt&&(as(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),cs(e),0===e.avail_out))return s.last_flush=-1,Vt}return t!==Ft?Vt:s.wrap<=0?zt:(2===s.wrap?(us(s,255&e.adler),us(s,e.adler>>8&255),us(s,e.adler>>16&255),us(s,e.adler>>24&255),us(s,255&e.total_in),us(s,e.total_in>>8&255),us(s,e.total_in>>16&255),us(s,e.total_in>>24&255)):(_s(s,e.adler>>>16),_s(s,65535&e.adler)),cs(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?Vt:zt)},deflateEnd:e=>{if(ys(e))return Gt;const t=e.state.status;return e.state=null,t===is?os(e,Kt):Vt},deflateSetDictionary:(e,t)=>{let s=t.length;if(ys(e))return Gt;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==ss||i.lookahead)return Gt;if(1===n&&(e.adler=wt(e.adler,t,s,0)),i.wrap=0,s>=i.w_size){0===n&&(as(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,gs(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=ds(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,gs(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,Vt},deflateInfo:"pako deflate (from Nodeca project)"};const Is=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var xs={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)Is(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;ks[254]=ks[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&&Rs)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+ks[e[s]]>t?s:t}};var Ds=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 Ls=Object.prototype.toString,{Z_NO_FLUSH:Us,Z_SYNC_FLUSH:Ps,Z_FULL_FLUSH:Ms,Z_FINISH:qs,Z_OK:Fs,Z_STREAM_END:Hs,Z_DEFAULT_COMPRESSION:Vs,Z_DEFAULT_STRATEGY:zs,Z_DEFLATED:Gs}=Rt;function Ks(e){this.options=xs.assign({level:Vs,method:Gs,chunkSize:16384,windowBits:15,memLevel:8,strategy:zs},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 Ds,this.strm.avail_out=0;let s=bs.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(s!==Fs)throw new Error(xt[s]);if(t.header&&bs.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Os.string2buf(t.dictionary):"[object ArrayBuffer]"===Ls.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,s=bs.deflateSetDictionary(this.strm,e),s!==Fs)throw new Error(xt[s]);this._dict_set=!0}}function Bs(e,t){const s=new Ks(t);if(s.push(e,!0),s.err)throw s.msg||xt[s.err];return s.result}Ks.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?qs:Us,"string"==typeof e?s.input=Os.string2buf(e):"[object ArrayBuffer]"===Ls.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===Ps||o===Ms)&&s.avail_out<=6)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else{if(n=bs.deflate(s,o),n===Hs)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),n=bs.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Fs;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},Ks.prototype.onData=function(e){this.chunks.push(e)},Ks.prototype.onEnd=function(e){e===Fs&&(this.result=xs.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qs={Deflate:Ks,deflate:Bs,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Bs(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Bs(e,t)},constants:Rt};const js=16209;var $s=function(e,t){let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A,N;const w=e.state;s=e.next_in,A=e.input,i=s+(e.avail_in-5),n=e.next_out,N=e.output,o=n-(t-e.avail_out),r=n+(e.avail_out-257),a=w.dmax,l=w.wsize,d=w.whave,c=w.wnext,h=w.window,u=w.hold,_=w.bits,p=w.lencode,E=w.distcode,g=(1<>>24,u>>>=S,_-=S,S=v>>>16&255,0===S)N[n++]=65535&v;else{if(!(16&S)){if(64&S){if(32&S){w.mode=16191;break e}e.msg="invalid literal/length code",w.mode=js;break e}v=p[(65535&v)+(u&(1<>>=S,_-=S),_<15&&(u+=A[s++]<<_,_+=8,u+=A[s++]<<_,_+=8),v=E[u&f];;){if(S=v>>>24,u>>>=S,_-=S,S=v>>>16&255,16&S){if(C=65535&v,S&=15,_a){e.msg="invalid distance too far back",w.mode=js;break e}if(u>>>=S,_-=S,S=n-o,C>S){if(S=C-S,S>d&&w.sane){e.msg="invalid distance too far back",w.mode=js;break e}if(T=0,y=h,0===c){if(T+=l-S,S2;)N[n++]=y[T++],N[n++]=y[T++],N[n++]=y[T++],m-=3;m&&(N[n++]=y[T++],m>1&&(N[n++]=y[T++]))}else{T=n-C;do{N[n++]=N[T++],N[n++]=N[T++],N[n++]=N[T++],m-=3}while(m>2);m&&(N[n++]=N[T++],m>1&&(N[n++]=N[T++]))}break}if(64&S){e.msg="invalid distance code",w.mode=js;break e}v=E[(65535&v)+(u&(1<>3,s-=m,_-=m<<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,E=0,g=0,f=0,v=0,S=0,m=0,C=0,T=0,y=0,A=0,N=null;const w=new Uint16Array(16),b=new Uint16Array(16);let I,x,R,k=null;for(E=0;E<=Ws;E++)w[E]=0;for(g=0;g=1&&0===w[v];v--);if(S>v&&(S=v),0===v)return n[o++]=20971520,n[o++]=20971520,a.bits=1,0;for(f=1;f0&&(0===e||1!==v))return-1;for(b[1]=0,E=1;E852||2===e&&y>592)return 1;for(;;){I=E-C,r[g]+1=p?(x=k[r[g]-p],R=N[r[g]-p]):(x=96,R=0),d=1<>C)+c]=I<<24|x<<16|R}while(0!==c);for(d=1<>=1;if(0!==d?(A&=d-1,A+=d):A=0,g++,0==--w[E]){if(E===v)break;E=t[s+r[g]]}if(E>S&&(A&u)!==h){for(0===C&&(C=S),_+=f,m=E-C,T=1<852||2===e&&y>592)return 1;h=A&u,n[h]=S<<24|m<<16|_-o}}return 0!==A&&(n[_+A]=E-C<<24|64<<16),a.bits=S,0};const{Z_FINISH:ti,Z_BLOCK:si,Z_TREES:ii,Z_OK:ni,Z_STREAM_END:oi,Z_NEED_DICT:ri,Z_STREAM_ERROR:ai,Z_DATA_ERROR:li,Z_MEM_ERROR:di,Z_BUF_ERROR:ci,Z_DEFLATED:hi}=Rt,ui=16180,_i=16190,pi=16191,Ei=16192,gi=16194,fi=16199,vi=16200,Si=16206,mi=16209,Ci=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ti(){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 yi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Ai=e=>{if(yi(e))return ai;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=ui,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,ni},Ni=e=>{if(yi(e))return ai;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ai(e)},wi=(e,t)=>{let s;if(yi(e))return ai;const i=e.state;return t<0?(s=0,t=-t):(s=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ai:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=s,i.wbits=t,Ni(e))},bi=(e,t)=>{if(!e)return ai;const s=new Ti;e.state=s,s.strm=e,s.window=null,s.mode=ui;const i=wi(e,t);return i!==ni&&(e.state=null),i};let Ii,xi,Ri=!0;const ki=e=>{if(Ri){Ii=new Int32Array(512),xi=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(ei(1,e.lens,0,288,Ii,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ei(2,e.lens,0,32,xi,0,e.work,{bits:5}),Ri=!1}e.lencode=Ii,e.lenbits=9,e.distcode=xi,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.whavebi(e,15),inflateInit2:bi,inflate:(e,t)=>{let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A=0;const N=new Uint8Array(4);let w,b;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(yi(e)||!e.output||!e.input&&0!==e.avail_in)return ai;s=e.state,s.mode===pi&&(s.mode=Ei),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,y=ni;e:for(;;)switch(s.mode){case ui:if(0===s.wrap){s.mode=Ei;break}for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>>8&255,s.check=It(s.check,N,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=mi;break}if((15&d)!==hi){e.msg="unknown compression method",s.mode=mi;break}if(d>>>=4,c-=4,T=8+(15&d),0===s.wbits&&(s.wbits=T),T>15||T>s.wbits){e.msg="invalid window size",s.mode=mi;break}s.dmax=1<>8&1),512&s.flags&&4&s.wrap&&(N[0]=255&d,N[1]=d>>>8&255,s.check=It(s.check,N,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,N[2]=d>>>16&255,N[3]=d>>>24&255,s.check=It(s.check,N,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&&(N[0]=255&d,N[1]=d>>>8&255,s.check=It(s.check,N,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=It(s.check,N,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&&(T=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+_),T)),512&s.flags&&4&s.wrap&&(s.check=It(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{T=i[o+_++],s.head&&T&&s.length<65536&&(s.head.name+=String.fromCharCode(T))}while(T&&_>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=pi;break;case 16189:for(;c<32;){if(0===a)break e;a--,d+=i[o++]<>>=7&c,c-=7&c,s.mode=Si;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(ki(s),s.mode=fi,t===ii){d>>>=2,c-=2;break e}break;case 2:s.mode=16196;break;case 3:e.msg="invalid block type",s.mode=mi}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=mi;break}if(s.length=65535&d,d=0,c=0,s.mode=gi,t===ii)break e;case gi: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=pi;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=mi;break}s.have=0,s.mode=16197;case 16197:for(;s.have>>=3,c-=3}for(;s.have<19;)s.lens[I[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,w={bits:s.lenbits},y=ei(0,s.lens,0,19,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid code lengths set",s.mode=mi;break}s.have=0,s.mode=16198;case 16198:for(;s.have>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=g,c-=g,s.lens[s.have++]=v;else{if(16===v){for(b=g+2;c>>=g,c-=g,0===s.have){e.msg="invalid bit length repeat",s.mode=mi;break}T=s.lens[s.have-1],_=3+(3&d),d>>>=2,c-=2}else if(17===v){for(b=g+3;c>>=g,c-=g,T=0,_=3+(7&d),d>>>=3,c-=3}else{for(b=g+7;c>>=g,c-=g,T=0,_=11+(127&d),d>>>=7,c-=7}if(s.have+_>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=mi;break}for(;_--;)s.lens[s.have++]=T}}if(s.mode===mi)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=mi;break}if(s.lenbits=9,w={bits:s.lenbits},y=ei(1,s.lens,0,s.nlen,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid literal/lengths set",s.mode=mi;break}if(s.distbits=6,s.distcode=s.distdyn,w={bits:s.distbits},y=ei(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,w),s.distbits=w.bits,y){e.msg="invalid distances set",s.mode=mi;break}if(s.mode=fi,t===ii)break e;case fi:s.mode=vi;case vi: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,$s(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===pi&&(s.back=-1);break}for(s.back=0;A=s.lencode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,s.length=v,0===f){s.mode=16205;break}if(32&f){s.back=-1,s.mode=pi;break}if(64&f){e.msg="invalid literal/length code",s.mode=mi;break}s.extra=15&f,s.mode=16201;case 16201:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=16202;case 16202:for(;A=s.distcode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,64&f){e.msg="invalid distance code",s.mode=mi;break}s.offset=v,s.extra=15&f,s.mode=16203;case 16203:if(s.extra){for(b=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=mi;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=mi;break}_>s.wnext?(_-=s.wnext,p=s.wsize-_):p=s.wnext-_,_>s.length&&(_=s.length),E=s.window}else E=n,p=r-s.offset,_=s.length;_>l&&(_=l),l-=_,s.length-=_;do{n[r++]=E[p++]}while(--_);0===s.length&&(s.mode=vi);break;case 16205:if(0===l)break e;n[r++]=s.length,l--,s.mode=vi;break;case Si:if(s.wrap){for(;c<32;){if(0===a)break e;a--,d|=i[o++]<{if(yi(e))return ai;let t=e.state;return t.window&&(t.window=null),e.state=null,ni},inflateGetHeader:(e,t)=>{if(yi(e))return ai;const s=e.state;return 2&s.wrap?(s.head=t,t.done=!1,ni):ai},inflateSetDictionary:(e,t)=>{const s=t.length;let i,n,o;return yi(e)?ai:(i=e.state,0!==i.wrap&&i.mode!==_i?ai:i.mode===_i&&(n=1,n=wt(n,t,s,0),n!==i.check)?li:(o=Oi(e,t,s,s),o?(i.mode=16210,di):(i.havedict=1,ni)))},inflateInfo:"pako inflate (from Nodeca project)"};var Li=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 Ui=Object.prototype.toString,{Z_NO_FLUSH:Pi,Z_FINISH:Mi,Z_OK:qi,Z_STREAM_END:Fi,Z_NEED_DICT:Hi,Z_STREAM_ERROR:Vi,Z_DATA_ERROR:zi,Z_MEM_ERROR:Gi}=Rt;function Ki(e){this.options=xs.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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ds,this.strm.avail_out=0;let s=Di.inflateInit2(this.strm,t.windowBits);if(s!==qi)throw new Error(xt[s]);if(this.header=new Li,Di.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Os.string2buf(t.dictionary):"[object ArrayBuffer]"===Ui.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=Di.inflateSetDictionary(this.strm,t.dictionary),s!==qi)))throw new Error(xt[s])}function Bi(e,t){const s=new Ki(t);if(s.push(e),s.err)throw s.msg||xt[s.err];return s.result}Ki.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?Mi:Pi,"[object ArrayBuffer]"===Ui.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=Di.inflate(s,r),o===Hi&&n&&(o=Di.inflateSetDictionary(s,n),o===qi?o=Di.inflate(s,r):o===zi&&(o=Hi));s.avail_in>0&&o===Fi&&s.state.wrap>0&&0!==e[s.next_in];)Di.inflateReset(s),o=Di.inflate(s,r);switch(o){case Vi:case zi:case Hi:case Gi:return this.onEnd(o),this.ended=!0,!1}if(a=s.avail_out,s.next_out&&(0===s.avail_out||o===Fi))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!==qi||0!==a){if(o===Fi)return o=Di.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},Ki.prototype.onData=function(e){this.chunks.push(e)},Ki.prototype.onEnd=function(e){e===qi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=xs.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qi={Inflate:Ki,inflate:Bi,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Bi(e,t)},ungzip:Bi,constants:Rt};const{Deflate:ji,deflate:$i,deflateRaw:Wi,gzip:Zi}=Qs,{Inflate:Yi,inflate:Xi,inflateRaw:Ji,ungzip:en}=Qi;var tn={Deflate:ji,deflate:$i,deflateRaw:Wi,gzip:Zi,Inflate:Yi,inflate:Xi,inflateRaw:Ji,ungzip:en,constants:Rt};const sn=t=>e(void 0,void 0,void 0,(function*(){const e=tn.ungzip(t);return String.fromCharCode.apply(null,e)}));var nn,on;exports.ConnectionState=void 0,(nn=exports.ConnectionState||(exports.ConnectionState={})).CONNECTING="CONNECTING",nn.OPEN="OPEN",nn.CLOSED="CLOSED";class rn extends I{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}get ws(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}_handleMessage(e){e.split("\n").forEach((e=>{if(e){const t=Ce.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 me(t.payload);e.expiresIn>=0&&this._dispatcher.dispatch(e)}}else"NOOP"===t.code||this.dispatch("message",t)}}))}connect(t,s=""){return e(this,void 0,void 0,(function*(){this._ws=new WebSocket(t,encodeURIComponent(s)),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*(){try{const e=yield sn(s.result);this._handleMessage(e)}catch(e){this.error(e)}}))}else if(t.data instanceof ArrayBuffer)try{const e=yield sn(new Uint8Array(t.data));this._handleMessage(e)}catch(e){this.error(e)}else if("undefined"!=typeof Buffer&&t.data instanceof Buffer)try{const e=t.data,s=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),i=yield sn(s);this._handleMessage(i)}catch(e){this.error(e)}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._ws.onopen=Ve,this._ws.onmessage=Ve,this._ws.onerror=Ve,this.connectionState!==exports.ConnectionState.CLOSED?(this._ws.onclose=()=>{this.dispatch("close"),e()},this._ws.close(),this._ws=void 0):e()):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 an extends R{constructor({all:e,feed:t,custom_types:s,ts:i}){super(),this.all=e,this.feed=t,this.customTypes=s,this.ts=i}}class ln{constructor(e,{session: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 He(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this.websocketClient=new rn(e,{sdkState:s,dispatcher:i,logger:n}),this.websocketClient.on("message",(e=>{if(e.payload.unread_cnt&&this._dispatcher.dispatch(new an(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 Me;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",t.requestId,i),e.reject(i)):(this._logger.debug("receive websocket ack",t.requestId,t),this._logger.debug("receive websocket ack",n),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 fe)return yield this._sendApiRequest(t);if(t instanceof Te)return yield this._sendWebsocketRequest(t);throw o.invalidParameters}))}cancel(e){this.apiClient.cancel(e)}cancelAll(){this.apiClient.cancelAll()}}exports.ConnectionStateType=void 0,(on=exports.ConnectionStateType||(exports.ConnectionStateType={}))[on.NONE=0]="NONE",on[on.INITIALIZED=1]="INITIALIZED",on[on.CONNECTING=2]="CONNECTING",on[on.CONNECTED=3]="CONNECTED",on[on.RECONNECTING=4]="RECONNECTING",on[on.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",on[on.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",on[on.LOGOUT=7]="LOGOUT";class dn extends R{constructor({stateType:e}){super(),this.stateType=e}}class cn extends R{}class hn extends R{}class un extends R{}class _n{constructor(e){var t,s,i,n;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(s=e.feed_channels)&&void 0!==s?s:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(n=e.settings_updated_at)&&void 0!==n?n:0}static payloadify(e){return k(O({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}class pn{constructor(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}static payloadify(e){return k(O({last_updated_at:e.lastUpdatedAt}))}}class En{constructor(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}static payloadify(e){return k(O({template_list_token:e.token}))}}class gn{constructor(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}){this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}static payloadify(e){return k(O({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}class fn{constructor(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}){this.default=new gn(e.default),this.realTime=new gn(e.realtime)}static payloadify(e){return k(O({default:gn.payloadify(e.default),realtime:gn.payloadify(e.realTime)}))}}const vn=1048576;var Sn,mn;exports.UnreadCountThreadingPolicy=void 0,(Sn=exports.UnreadCountThreadingPolicy||(exports.UnreadCountThreadingPolicy={}))[Sn.NONE=0]="NONE",Sn[Sn.INCLUDE_REPLY=1]="INCLUDE_REPLY",Sn[Sn.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Sn[Sn.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",exports.LastMessageThreadingPolicy=void 0,(mn=exports.LastMessageThreadingPolicy||(exports.LastMessageThreadingPolicy={}))[mn.NONE=0]="NONE",mn[mn.INCLUDE_REPLY=1]="INCLUDE_REPLY",mn[mn.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",mn[mn.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";class Cn{constructor(e={}){var t,s,i,n,o,r,a;this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*vn: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.unreadCountThreadingPolicy=null!==(o=e.unread_cnt_threading_policy)&&void 0!==o?o:exports.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(r=e.last_msg_threading_policy)&&void 0!==r?r:exports.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new pn(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new _n(e.notifications):null,this.messageTemplateInfo=e.message_template?new En(e.message_template):null,this.statConfigInfo=e.log_publish_config?new fn(e.log_publish_config):new fn}static payloadify(e){return k(O({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/vn,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?pn.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?_n.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?En.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?fn.payloadify(e.statConfigInfo):null}))}}class Tn{constructor(e){this._iid="",this._iid=e}static payloadify(e){return{}}}class yn extends fe{constructor({userId:e,metadata:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${j}/${e}/metadata`,this.params={metadata:t}}}class An extends ve{constructor(e,t){super(e,t),this.metaData=t}}class Nn extends fe{constructor({userId:e,metadata:t,upsert:s}){super(),this.method=exports.APIRequestMethod.PUT,this.path=`${j}/${e}/metadata`,this.params={metadata:t,upsert:s}}}class wn extends ve{constructor(e,t){super(e,t),this.metadata=t}}class bn extends fe{constructor({userId:e,metadataKey:t}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${j}/${e}/metadata/${t}`}}class In extends fe{constructor({userId:e}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${j}/${e}/metadata`}}const xn=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return s._iid&&delete s._iid,t&&t(s),s},Rn=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return t&&t(s),s},kn=e=>({do:t=>{e||t()},throw:t=>{if(!e)throw t}});var On;exports.UserOnlineState=void 0,(On=exports.UserOnlineState||(exports.UserOnlineState={})).ONLINE="online",On.OFFLINE="offline",On.NON_AVAILABLE="nonavailable";class Dn extends Tn{constructor(e,t){var s,i,n,o,r,a,c,h,u,_,p,E;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!==(E=t.friend_name)&&void 0!==E?E:null}static payloadify(e){return k(O(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}=Io.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainProfileUrl}?auth=${e.ekey}`:this.plainProfileUrl}serialize(){return xn(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*(){kn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Io.of(this._iid),i=new yn({userId:e.userId,metadata:t}),n=yield s.send(i),{metaData:r}=n.as(An);return this._applyMetaData(r),this.metaData}))}updateMetaData(t,s=!1){return e(this,void 0,void 0,(function*(){kn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:i}=Io.of(this._iid),n=new Nn({userId:e.userId,metadata:t,upsert:s}),r=yield i.send(n),{metadata:a}=r.as(wn);return this._applyMetaData(a),this.metaData}))}deleteMetaData(t){return e(this,void 0,void 0,(function*(){kn(l("string",t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Io.of(this._iid),i=new bn({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}=Io.of(this._iid),s=new In({userId:e.userId});yield t.send(s),this.metaData={}}))}}class Ln extends R{constructor({userProfile:e}){super(),this.userProfile=e}}class Un{constructor(e,t){var s,i,n,o,r,a,l,d,c,h,u,_,p,E;this._iid=e,this.appInfo=new Cn(t),this.user=new Dn(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!==(E=t.back_off_delay)&&void 0!==E?E:100}static payloadify(e){return k(O(Object.assign(Object.assign(Object.assign({},Dn.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=Io.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 Ln({userProfile:this}))}}class Pn extends R{constructor({request:e=!0,features:t={},options:s={},statConfigInfo:i}){super(),this.request=e,this.features=Object.assign({localCache:!0,notification:!0},t),this.options=Object.assign({ingestion:!0},s),this.statConfigInfo=i}}class Mn extends Ce{constructor(e,t,s){var i,n,r,a;super(e,t,s),this.error=null,this.services=[],this.userProfile=new Un(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,this.services=null!==(a=s.services)&&void 0!==a?a:[]}static asError(e){return new Mn("","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=Io.of(t);if(!e)throw o.lostInstance;{const{sessionManager:t,dispatcher:s}=e;yield t.login(this),this.userProfile.apply(),s.dispatch(new Pn({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo}))}}}))}}class qn{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,cause:n=null}){return e(this,void 0,void 0,(function*(){}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){}))}}const Fn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){if(!(e instanceof o))throw e;e.throwOutside()}})),Hn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){}}));class Vn extends qn{constructor(e={}){var t;super(),this.type=exports.ConnectionStateType.LOGOUT,this.name="logout",this._wasPreviouslyConnected=null===(t=e.wasPreviouslyConnected)||void 0===t||t}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 Jn,s),this._wasPreviouslyConnected&&Fn((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onDisconnected&&e.onDisconnected(i)}))}))))}))}}class zn extends qn{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 Yn({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new jn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn,e)}))}}class Gn extends qn{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 jn,e))}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new Yn({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new jn,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new zn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn,e)}))}}const Kn=t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}));class Bn{calcTimeout(){return 0}}const Qn=(t,s,i=new Bn)=>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||et(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=new Me;this._callbacks.push((e=>e?i.reject(e):i.resolve())),Fn((()=>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 Qn(((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){if(e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);if(e.isSessionExpiredError||e.isSessionInvalidatedError)return void s(e)}throw e}}))),i,n),yield t.changeState(new $n,s),this._flushCallbacks(),Fn((()=>e(this,void 0,void 0,(function*(){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 Gn({autoReconnect:!1}),s)),this._flushCallbacks(i),Fn((()=>e(this,void 0,void 0,(function*(){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 Me;return this._halt(o.connectionCanceled),t.cancelConnectForRetry(),this._callbacks.push((()=>{const i=Date.now();t.changeState(new Yn({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 Me;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 Gn({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 zn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Vn,e)}))}}class $n extends qn{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 jn,e)}))}onDisconnect(t,{autoReconnect:s}){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Gn({autoReconnect:s}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new zn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn,e)}))}}var Wn;!function(e){e.ExternalSetBackground="ExternalSetBackground",e.ExternalDisconnectWebSocket="ExternalDisconnectWebSocket"}(Wn||(Wn={}));class Zn{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:o,dispatcher:r,logger:a,disableWebSocketCloseEventHandling:l=!1}){this._disableWebSocketCloseEventHandling=!1,this._webSocketClosedCause=null,this._logger=a,this._disableWebSocketCloseEventHandling=l,this._context=new io(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",(()=>{this.isConnecting||this.isConnected||(this._logger.debug("try reconnect by session key refresh"),Hn((()=>e(this,void 0,void 0,(function*(){yield this.reconnect()})))))})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(()=>{"foreground"!==this._sdkState.appState||this._webSocketClosedCause||Hn((()=>e(this,void 0,void 0,(function*(){this._sessionManager.isSessionKeyRefreshing?yield this.disconnectWebSocket():(this._logger.debug("try reconnect by websocket connection closed"),yield 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}get websocketClient(){return this._websocketClient}connect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onConnect(this._context,t),this._registerEventDispatcher()}))}reconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{})}))}resetAndReconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{resetReconnectCount:!0})}))}background(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=Wn.ExternalSetBackground,yield e.onDisconnect(this._context,{autoReconnect:!1,cause:this._webSocketClosedCause})}))}disconnect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;yield e.onDisconnect(this._context,{error:t,autoReconnect:!0,cause:this._webSocketClosedCause})}))}disconnectWebSocket(t=!1){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;t&&(this._webSocketClosedCause=Wn.ExternalDisconnectWebSocket),yield e.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause})}))}logout(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._clearEventDispatcher(),yield e.onLogout(this._context,t)}))}}class Yn extends qn{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 Me;this._callbacks.push((e=>e?i.reject(e):i.resolve()));try{yield Qn((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 $n,s),Fn((()=>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 Jn,s)),Fn((()=>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 Me;return this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:i=!1,cause:n=null}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:Xn(n)),t.hasSession?yield t.changeState(new Gn({autoReconnect:i}),e):yield t.changeState(new Vn,e)}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){this._halt(Xn((null==s?void 0:s.cause)||null));const e=Date.now();t.hasSession?yield t.changeState(new zn,e):yield t.changeState(new Vn,e)}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:o.connectionCanceled),yield t.changeState(new Vn,e)}))}}function Xn(e){const t=o.connectionCanceled;if(e){let s=null;switch(e){case Wn.ExternalSetBackground:s="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case Wn.ExternalDisconnectWebSocket:s="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}s&&t.setDetail(s)}return t}class Jn extends qn{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 Yn({authToken:s}),e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn({wasPreviouslyConnected:!1}),e)}))}}class eo extends Te{constructor(){super({code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}}class to{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 eo;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)}}const so=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"];class io extends I{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:r,dispatcher:a,logger:l,entryState:d=new Jn}){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 to({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(Mn))})).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 Mn&&(this._unresolvedLogi=e,this._tryResolveConnectionRequest())}))}get currentState(){return this._currentState}get hasSession(){return this._sessionManager.session.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 dn({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;this._websocketClient.isOpen&&e&&(this._unresolvedLogi=void 0,e.error?(this._sessionManager.session.authToken=void 0,e.error.isSessionExpiredError||e.error.isSessionInvalidatedError?this._dispatcher.dispatch(new me({reason:e.error.code,message:e.error.message})):this._logger.warn(`login failed: ${e.error}`),this._rejectConnectionRequest(e.error)):(yield e.applyTo(this._iid),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(){var e;const{appId:t,appVersion:s,userId:n,extensions:o,sendbirdRuntimeEnvironment:r}=this.sdkState,{localCacheEnabled:a}=this.cacheContext,{session:l}=this._sessionManager,d=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,c=!!(null!=o?o:{}).sb_uikit,h=Pe.userAgentWithExtension(o);return`${this.sdkState.websocket.host}/?p=JS&pv=${encodeURIComponent(i.OS_VERSION)}&sv=${encodeURIComponent(i.SDK_VERSION)}&ai=${t}${s?`&av=${s}`:""}${l.hasSession?"":`&user_id=${encodeURIComponent(n)}`}&pmce=${d?1:0}&active=1&device_token_types=${encodeURIComponent(["gcm","huawei","apns"].join(","))}&SB-User-Agent=${h}&SB-SDK-User-Agent=${encodeURIComponent(Pe.sendbirdSdkUserAgentWithExtension(r))}&Request-Sent-Timestamp=${Date.now().toString()}&include_extra_data=${encodeURIComponent(String(so))}${this._sessionManager.handler?"&expiring_session=1":""}&use_local_cache=${a?1:0}&include_poll_details=1${c?"&uikit_config=1":""}`}_statLogConnection(e){var t;this._dispatcher.dispatch(new be(new Re({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=new Me;if(this._connectionRequestQueue.push(e),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);const{session:e}=this._sessionManager;t&&(e.authToken=t,e.sessionKey=void 0);const i=this._url();e.sessionKey||e.authToken?this._websocketClient.connect(i,JSON.stringify(e.hasSession?{auth:e.sessionKey}:{token:e.authToken})):this._websocketClient.connect(i,JSON.stringify({}))}return e.promise}))}cancelConnectForRetry(){this._dispatcher.dispatch(Mn.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.disconnect(),yield this._sessionManager.clear()}))}clearLoginTimer(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}class no extends fe{constructor({appId:e,userId:t,includeUIKitConfig:s=!1,localCacheEnabled:i=!0,expiringSession:n=!0}){super(),this.path=`${$}/${t}/authentication`,this.method=exports.APIRequestMethod.POST,this.params=k({expiring_session:!!n,include_logi:!0,include_extra_data:String(so),uikit_config:s,use_local_cache:i,app_id:e}),this.requireAuth=!1}}class oo extends ve{constructor(e,t){super(e,t),this.logi=new Mn(e,"LOGI",t)}}var ro;!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(ro||(ro={}));const ao=[ye,no];class lo{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r=!1}){this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new ln(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this._session=t,this._logger=n,this._dispatcher=i,this._dispatcher.on((e=>{var t;if(e instanceof dn){const{stateType:s}=e;switch(this._currentConnectionStateType=s,s){case exports.ConnectionStateType.CONNECTED:this._resolveLazyCallQueue();break;case exports.ConnectionStateType.INITIALIZED:case exports.ConnectionStateType.INTERNAL_DISCONNECTED:case exports.ConnectionStateType.EXTERNAL_DISCONNECTED:case exports.ConnectionStateType.LOGOUT:this._rejectLazyCallQueue((null===(t=this._session)||void 0===t?void 0:t.hasSession)?o.connectionClosed:o.connectionRequired)}}else if(e instanceof cn)this._session.hasChatServicePermission||this._resolveLazyCallQueue(ro.API);else if(e instanceof hn||e instanceof un)this._rejectLazyCallQueue(o.connectionClosed);else if(e instanceof Ie){const{request:t,deferred:s,error:i}=e;for(const e of ao)if(t instanceof e)return void s.reject(i);this._lazyCallQueue.push({command:t,deferred:s})}}))}get isReady(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED}get isLazyCallActivated(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING||this._currentConnectionStateType===exports.ConnectionStateType.RECONNECTING||this._session.isRefreshing}_classifyLazyCallQueueByScope(e){const t=[],s=[];let i;switch(e){case ro.ALL:i=null;break;case ro.WEBSOCKET:i=Te;break;case ro.API:i=fe}let n=!1;return this._lazyCallQueue.forEach((e=>{!i||e.command instanceof i||(n=!0),n?s.push(e):t.push(e)})),[t,s]}_resolveLazyCallQueue(t=ro.ALL){const[s,i]=this._classifyLazyCallQueueByScope(t);this._lazyCallQueue=i,s.forEach((t=>e(this,void 0,void 0,(function*(){const{command:e,deferred:s,timeout:i}=t;i&&clearTimeout(i);try{const t=yield this.send(e);s.resolve(t)}catch(e){s.reject(e)}}))))}_rejectLazyCallQueue(t,s=ro.ALL){const[i,n]=this._classifyLazyCallQueueByScope(s);this._lazyCallQueue=n,i.forEach((s=>e(this,void 0,void 0,(function*(){const{deferred:e,timeout:i}=s;clearTimeout(i),e.reject(t)}))))}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof Te){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 Me;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 fe){if(this._session.hasSession)return this._logger.debug("send api request",t),yield this.commandRouter.send(t);if(t.hasSessionKey)return this._logger.debug("send api request with tmp session key",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait api request",t);const e=new Me;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*(){if(this._logger.debug("send forced request",t),t instanceof Te||t instanceof fe)return yield this.commandRouter.send(t);throw o.invalidCommand}))}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 co="sendbird@devicetokens";class ho{constructor({type:e,token:t,device_os:s,device_manufacturer:i,system_push_enabled:n}){this.type=e,this.token=t,this.deviceOS=s,this.deviceManufacturer=i,this.systemPushEnabled=n}static payloadify(e){return k(O({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}const uo=new WeakMap;class _o extends I{constructor({_iid:e,session:t,cacheContext:s,sdkState:i,dispatcher:o,requestQueue:r,logger:a,pushNotificationAckManager:l}){super(),this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._isRefreshingAuthToken=!1,this.currentUser=null,this.session=t,this._iid=e,this._cacheContext=s,this._sdkState=i,this._dispatcher=o,this._requestQueue=r,this._logger=a,this._pushNotificationAckManager=l,this._deviceTokens=[],this._dispatcher.on((e=>{var t,s,i;if(e instanceof dn){const{stateType:t}=e;this._currentConnectionStateType=t}else if(e instanceof me&&this.handler&&!this.isSessionKeyRefreshing){if(this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?this.close():((null===(s=e.error)||void 0===s?void 0:s.isSessionTokenExpiredError)&&this.refreshAuthToken().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(this._logger.debug("session expired"),this.handler.onSessionExpired&&this.handler.onSessionExpired(),this.refreshSessionKey().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e}))))}}))}get ekey(){return uo.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 Ae({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(we);if(n)throw n;this.session.sessionKey=null!=i?i:this.session.sessionKey}))}_refreshSessionKeyByApi(t){return e(this,void 0,void 0,(function*(){const s=new ye({userId:this._sdkState.userId,authToken:t,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0});yield Qn((t=>e(this,void 0,void 0,(function*(){try{const e=yield this._requestQueue.forceSend(s),{key:t,services:i}=e.as(Ne);this.session.sessionKey=t,this.session.services=i}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){try{return void(yield this._handleSessionRefreshError(e,s))}catch(e){}}try{yield this._refreshSessionKeyByApi(t),this.complete()}catch(e){yield this._handleSessionRefreshError(e,s)}}))}_receiveNewAuthToken(){var t;const s=new Me;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired){let t=null;const i=()=>{t&&(clearTimeout(t),t=null)},n=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.resolve(e))},o=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.reject(e))};t=setTimeout((()=>o()),1e3*this._sdkState.sessionTokenRefreshTimeout),Fn((()=>e(this,void 0,void 0,(function*(){var e;(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(n,o)}))))}else s.resolve(null);return s.promise}_handleSessionRefreshError(t,s=!1){return e(this,void 0,void 0,(function*(){if(!(t instanceof o&&(t.isSessionTokenExpiredError||t.code===exports.SendbirdErrorCode.APPLICATION_NOT_FOUND)&&(this.session.authToken=void 0,s)))throw t;{const e=yield this._receiveNewAuthToken();e?(this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken,!1)):yield this.clear()}}))}_isSessionRelatedError(e){return e instanceof o&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}get isSessionKeyRefreshing(){return this.session.isRefreshing}get isRefreshingAuthToken(){return this._isRefreshingAuthToken}get isSessionExpiring(){return!!this.handler}authenticate(t,s){var i;return e(this,void 0,void 0,(function*(){this.session.authToken=s;const e=new no({appId:this._sdkState.appId,userId:t,includeUIKitConfig:!!(null!==(i=this._sdkState.extensions)&&void 0!==i?i:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!s||this.isSessionExpiring}),n=yield this._requestQueue.commandRouter.send(e),{logi:o}=n.as(oo);if(o.error)throw o.error;this.session.hasChatServicePermission||(yield o.applyTo(this._iid))}))}login(t){var s;return e(this,void 0,void 0,(function*(){const{key:e,ekey:i,services:n,userProfile:o,deviceTokenLastDeletedAt:r=0}=t;this.session.sessionKey=e,this.session.services=n,uo.set(this,i),this._deviceTokenCacheEnabled=null===(s=null==o?void 0:o.appInfo)||void 0===s?void 0:s.deviceTokenCache;const{preference:a}=this._cacheContext;if(this._deviceTokenCacheEnabled){const e=yield a.get(co);!e||e.lastDeletedAtnew ho(ho.payloadify(e)))),this._deviceTokenLastDeletedAt=e.lastDeletedAt)}else yield a.remove(co)}))}complete(){this.dispatch("refresh"),this._dispatcher.dispatch(new cn),Fn((()=>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){Fn((()=>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"),this._dispatcher.dispatch(new un),Fn((()=>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()}))))}refreshAuthToken(){return e(this,void 0,void 0,(function*(){let e=null;if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{e=yield this._receiveNewAuthToken(),e?(this._logger.debug("session refreshing.."),this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken)):yield this.clear()}catch(t){const s=e?o.sessionTokenRefreshFailed:o.sessionTokenRequestFailed;throw this._dispatcher.dispatch(new hn),this.error(s),this._logger.debug("refresh auth token error = ",s),s}finally{this.session.isRefreshing=!1}}}))}refreshSessionKey(){return e(this,void 0,void 0,(function*(){if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{yield this._refreshSessionKey(this.session.authToken)}catch(e){const t=o.sessionTokenRefreshFailed;throw this._dispatcher.dispatch(new hn),this.error(t),t}finally{this.session.isRefreshing=!1}}}))}setDeviceToken(e,t,s){if(this._deviceTokenCacheEnabled){if(this.indexOfDeviceToken(e,t)<0){const i=new ho({type:e,token:t,device_os:null==s?void 0:s.deviceOS,device_manufacturer:null==s?void 0:s.deviceManufacturer,system_push_enabled:null==s?void 0:s.systemPushEnabled});return this._deviceTokens.push(i),!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(co,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})}}))}clear(){return e(this,void 0,void 0,(function*(){this.currentUser=null,this.session.clear(),this.close(),uo.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,yield this.saveDeviceToken(),this._pushNotificationAckManager.clear()}))}}const po=(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]=po(e[s],t[s]):o[s]=t[s]}return o}return t};var Eo,go;!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Eo||(Eo={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(go||(go={}));class fo extends fe{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${ae}`,this.params={device_id:e,log_entries:t.map((e=>Re.payloadify(e)))}}}class vo{constructor({deviceId:e,cacheContext:t,requestQueue:s}){this.queue=[],this.flushWaitQueue=[],this.enabledState=Eo.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=e,this.cacheContext=t,this.requestQueue=s,this.logInfo={deviceId:e,statLogs:[],generation:1,lastFlushedAt:0},this.limit=100}get isEnabled(){return this.enabledState===Eo.ENABLED}init(t){return e(this,void 0,void 0,(function*(){this.key=t;const e=yield this.cacheContext.preference.get(this.key);e&&(this.logInfo=e)}))}_mergeQueue(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}_isDuplicateStat(e){const t=this._sentLogStats.find((t=>{var s;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(s=e.data.notificationId)&&void 0!==s?s:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}_flush(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t.length>0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new fo({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=Eo.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Eo.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}_save(){return e(this,void 0,void 0,(function*(){const e=[...this.queue,...this.flushWaitQueue];yield this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((e=>Re.payloadify(e))),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})}))}clear(){return e(this,void 0,void 0,(function*(){this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save()}))}}class So extends Re{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 mo extends vo{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".daily"),this.queue=this.logInfo.statLogs.map((e=>new Re({type:e.stat_type,ts:e.ts,data:e.data})))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this.statConfig.minInterval=864e5,this._mergeQueue(),s.localCacheStat?this.enabledState=s.enabledStat?Eo.ENABLED:Eo.COLLECT_ONLY:(this.enabledState=Eo.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=yield this._getUploadStats(),t=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);for(let s=0;se instanceof So&&e.key===t.key));if(s?s.data=po(s.data,t.data):e.push(t),this.enabledState!==Eo.PENDING&&(yield this._save()),this.isEnabled&&(this._mergeQueue(),this._isSendable)){const e=yield this._getUploadStats();return yield this._flush(e)}return!0}))}_getUploadStats(){return e(this,void 0,void 0,(function*(){return this.queue.filter((e=>{if(e instanceof So){const t=new Date,[s,i]=[e.date.getFullYear(),t.getFullYear()];if(se.type!==exports.StatType.FEATURE_LOCALCACHE_EVENT)):t.filter((e=>e.type===exports.StatType.FEATURE_LOCALCACHE_EVENT))}))}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".default"),this.queue=this.logInfo.statLogs.map((e=>(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data),new Re({type:e.stat_type,ts:e.ts,data:e.data}))))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.requestStat||s.localCacheStat){let e;this.enabledState=s.enabledStat?Eo.ENABLED:Eo.COLLECT_ONLY,s.requestStat||(e=!1),s.localCacheStat||(e=!0),void 0!==e&&(this.queue=yield this._filterQueueByType(this.queue,e),this.flushWaitQueue=yield this._filterQueueByType(this.flushWaitQueue,e),this._save())}else this.enabledState=Eo.DISABLED,yield this.clear();if(this.isEnabled&&this._isSendable(!0)){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield Kn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===Eo.DISABLED)return!0;const e=this.enabledState===Eo.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return e.push(t),this.enabledState!==Eo.PENDING&&(yield this._save()),!this.isEnabled||(this._mergeQueue(),!this._isSendable())||(yield this._flush(e))}))}}class To extends vo{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".realtime"),this.queue=this.logInfo.statLogs.map((e=>{var t;return e.data=k(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Re({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((e=>{var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.notificationStat?this.enabledState=s.enabledStat?Eo.ENABLED:Eo.COLLECT_ONLY:(this.enabledState=Eo.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield Kn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===Eo.DISABLED)return!0;const e=this.enabledState===Eo.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return!!this._isDuplicateStat(t)||(e.push(t),this.enabledState!==Eo.PENDING&&(yield this._save()),!(this.isEnabled&&(this._mergeQueue(),this.isEnabled&&this._isSendable))||(yield this._flush(e)))}))}}class yo{constructor({cacheContext:e,requestQueue:t,dispatcher:s,logger:i}){this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=w(),this.cacheContext=e,this.requestQueue=t,this.dispatcher=s,this.logger=i,this._dailyStatCollector=new mo({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Co({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._realTimeStatCollector=new To({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}_migration(){return e(this,void 0,void 0,(function*(){const e=yield this.cacheContext.preference.get(this.key);if(e){const t=[];e.statLogs.forEach((e=>{e.stat_type===exports.StatType.FEATURE_LOCALCACHE&&t.push(new Re({type:e.stat_type,ts:e.ts,data:e.data}))})),yield this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((e=>Re.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const s=[];e.statLogs.forEach((e=>{e.stat_type!==exports.StatType.FEATURE_LOCALCACHE&&e.stat_type!==exports.StatType.NOTIFICATION&&(e.stat_type===exports.StatType.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),s.push(new Re({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:s.map((e=>Re.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const i=[];e.statLogs.forEach((e=>{var t;e.stat_type===exports.StatType.NOTIFICATION&&(e.data=k(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),i.push(new Re({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:i.map((e=>Re.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt}),yield this.cacheContext.preference.remove(this.key)}}))}init(t){return e(this,void 0,void 0,(function*(){this.key=t,yield this._migration(),yield this._dailyStatCollector.init(this.key),yield this._defaultStatCollector.init(this.key),yield this._realTimeStatCollector.init(this.key),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((t=>e(this,void 0,void 0,(function*(){var e;if(t instanceof be){const{statLog:e}=t;this.put(e)}else if(t instanceof Pn){const{request:s,features:i,options:n,statConfigInfo:o}=t;this._retryCount=0,this._collectRequestStat=s,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._realTimeStatCollector.setConfig(null!==(e=this._statConfig.realTime)&&void 0!==e?e:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:n.ingestion})}})))))}))}put(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t instanceof So)this._collectFeatureLocalCacheStat&&(e=yield this._dailyStatCollector.put(t));else switch(t.type){case exports.StatType.API_RESULT:case exports.StatType.WEBSOCKET_CONNECT:this._collectRequestStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.FEATURE_LOCALCACHE:case exports.StatType.FEATURE_LOCALCACHE_EVENT:this._collectFeatureLocalCacheStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.NOTIFICATION:this._collectionNotificationStat&&(e=yield this._realTimeStatCollector.put(t))}e?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Eo.COLLECT_ONLY,this._defaultStatCollector.enabledState=Eo.COLLECT_ONLY,this._realTimeStatCollector.enabledState=Eo.COLLECT_ONLY,this.logger.debug(o.statLogUploadLimitExceededError)))}))}close(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}class Ao{constructor({limit:e=5}){this.workersByKey={},this.limit=e}run(t,s){return e(this,void 0,void 0,(function*(){if(this.workersByKey[t]||(this.workersByKey[t]=[]),this.workersByKey[t].length{switch(e){case"open":return exports.PollStatus.OPEN;case"closed":return exports.PollStatus.CLOSED;default:return null}},Lo=e=>!e||!!e.text&&l("string",e.text);class Uo extends Tn{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 k(O(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})))}}class Po extends Tn{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=Do(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 Uo(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=Do(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 Uo(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 k(O(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=>Uo.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 xn(this)}}class Mo{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}}class qo extends Mo{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)}}class Fo extends fe{constructor({title:e,optionTexts:t,data:s,allowUserSuggestion:i,allowMultipleVotes:n,closeAt:o}){super(),this.method=exports.APIRequestMethod.POST,this.path=ne,this.params={title:e,options:t,data:s,allow_user_suggestion:i,allow_multiple_votes:n,close_at:o}}}class Ho extends ve{constructor(e,t){super(e,t),this.poll=new Po(e,t)}}class Vo extends fe{constructor({channelUrl:e,channelType:t,pollId:s}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}`,this.params={channel_url:e,channel_type:t}}}class zo extends ve{constructor(e,t){super(e,t),this.poll=new Po(e,t)}}class Go extends fe{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}`,this.params={channel_url:e,channel_type:t}}}class Ko extends ve{constructor(e,t){super(e,t),this.pollOption=new Uo(e,t)}}class Bo extends fe{constructor({channelType:e,channelUrl:t,timestamp:s,token:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${_e(e)}/${encodeURIComponent(t)}/polls/changelogs`,this.params=k({change_ts:s,token:i})}}class Qo extends ve{constructor(e,t){super(e,t),this.updatedPolls=t.updated.map((t=>((e,t)=>new Po(e,t))(e,t))),this.deletedPollIds=t.deleted.map((e=>e)),this.hasMore=t.has_more,this.nextToken=t.next}}const jo={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},$o=e=>{return l("string",e.title)&&(t=e.optionTexts,h("string",t)&&t.every((e=>""!==e.trim())))&&Lo(e.data)&&l("boolean",e.allowUserSuggestion,!0)&&l("boolean",e.allowMultipleVotes,!0)&&l("number",e.closeAt,!0);var t},Wo={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0,pollOptionId:0},Zo=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId)&&e.pollId>0&&l("number",e.pollOptionId)&&e.pollOptionId>0,Yo={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0},Xo=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId),Jo={};class er extends fe{constructor({channelUrl:e,channelType:t,token:s,limit:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=ne,this.params={channel_url:e,channel_type:t,token:s,limit:i}}}class tr extends ve{constructor(e,t){var s;super(e,t),this.polls=(null!==(s=t.polls)&&void 0!==s?s:[]).map((t=>new Po(e,t))),this.token=t.next}}class sr extends fe{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i,token:n,limit:o}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}/voters`,this.params={channel_url:e,channel_type:t,token:n,limit:o}}}class ir extends ve{constructor(e,t){var s;super(e,t),this.voters=(null!==(s=t.voters)&&void 0!==s?s:[]).map((t=>new Dn(e,t))),this.token=t.next}}exports.APIRequestCommand=fe,exports.APIResponseCommand=ve,exports.API_PATH_EMOJIS=se,exports.API_PATH_EMOJI_CATEGORIES=ie,exports.API_PATH_FORMS=ue,exports.API_PATH_GROUP_CHANNELS=Z,exports.API_PATH_GROUP_CHANNELS_INTERNAL=Y,exports.API_PATH_MESSAGE_TEMPLATE=ce,exports.API_PATH_NOTIFICATIONS=le,exports.API_PATH_NOTIFICATIONS_USERS=de,exports.API_PATH_OPEN_CHANNELS=X,exports.API_PATH_OPEN_CHANNELS_INTERNAL=J,exports.API_PATH_POLLS=ne,exports.API_PATH_PUSH_DELIVERY=he,exports.API_PATH_REPORT=te,exports.API_PATH_SCHEDULED_MESSAGES=oe,exports.API_PATH_SEARCH=ee,exports.API_PATH_UIKIT_CONFIGURATION=re,exports.API_PATH_UPLOAD=W,exports.API_PATH_USERS=j,exports.AppInfo=Cn,exports.BaseCommand=R,exports.BaseListQuery=Mo,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.CancelXMLHttpRequestCommand=qe,exports.ChannelDataListQuery=qo,exports.ConnectionStateChangeCommand=dn,exports.DEFAULT_ENCRYPTION=E,exports.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT=5,exports.DailyRecordStatLog=So,exports.Deferred=Me,exports.DeleteMessageEventCommand=class extends Ce{constructor(e,t,s){var i;super(e,"DELM",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.messageId=Number(s.msg_id),this.silent=s.silent,this.messageCreatedAt=s.message_created_at?Number(s.message_created_at):-1,this.senderId=null!==(i=s.sender_id)&&void 0!==i?i:void 0}},exports.DeleteMessageRequestCommand=Fe,exports.EventDispatcher=I,exports.InstancedObject=Tn,exports.LocalCacheConfig=y,exports.MessageEventSource=Ro,exports.MessageRemoveEventCommand=class extends R{constructor({messageIds:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messageIds=e,this.source=t,this.isWebSocketEventComing=s}},exports.MessageUpdateEventCommand=class extends R{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.NotificationInfo=_n,exports.POLL_REMOVED_STATUS="removed",exports.Poll=Po,exports.PollChangeLogEventCommand=ko,exports.PollCreateParamsDefault=jo,exports.PollListQuery=class extends qo{constructor(e,t){super(e,t.channelUrl,t.channelType,t)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Io.of(this._iid),t=new er(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{polls:i,token:n}=s.as(tr);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.PollManager=class{constructor(e,{sdkState:t,dispatcher:s,sessionManager:i,requestQueue:n,logger:o}){this._iid=e,this._sdkState=t,this._sessionManager=i,this._requestQueue=n,this._dispatcher=s,this._logger=o,Jo[e]=this}static of(e){return Jo[e]}buildPollFromSerializedData(e){const t=Rn(e);return new Po(this._iid,Po.payloadify(t))}get(t){return e(this,void 0,void 0,(function*(){kn(Xo(t)).throw(o.invalidParameters);const e=new Vo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(zo);return i}))}create(t){return e(this,void 0,void 0,(function*(){kn($o(t)).throw(o.invalidParameters);const e=new Fo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(Ho);return i}))}getOption(t){return e(this,void 0,void 0,(function*(){kn(Zo(t)).throw(o.invalidParameters);const e=new Go(Object.assign({},t)),s=yield this._requestQueue.send(e),{pollOption:i}=s.as(Ko);return i}))}getPollChangeLogs(t,s,i,n=exports.CollectionEventSource.SYNC_POLL_CHANGELOGS){return e(this,void 0,void 0,(function*(){const e=new Bo(O({channelType:s,channelUrl:t,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null})),o=yield this._requestQueue.send(e),{updatedPolls:r,deletedPollIds:a,hasMore:l,nextToken:d}=o.as(Qo);return r.length>0&&this._dispatcher.dispatch(new ko({polls:r,source:n})),{updatedPolls:r,deletedPollIds:a,hasMore:l,token:d}}))}},exports.PollOption=Uo,exports.PollOptionRetrievalParamsDefault=Wo,exports.PollRetrievalParamsDefault=Yo,exports.PollUpdateInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=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.PollVoteInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoterListQuery=class extends qo{constructor(e,t){super(e,t.channelUrl,t.channelType,t),this.pollId=t.pollId,this.pollOptionId=t.pollOptionId}_validate(){return super._validate()&&l("number",this.pollId)&&l("number",this.pollOptionId)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Io.of(this._iid),t=new sr(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),s=yield e.send(t),{voters:i,token:n}=s.as(ir);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.ReactionUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.RequestResendCommand=Ie,exports.SEMVER_REGEX_STRING="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",exports.SendbirdChatOptions=p,exports.SendbirdError=o,exports.SessionExpiredCommand=me,exports.SessionRefreshAPICommand=ye,exports.StatLog=Re,exports.SubscribedUnreadMessageCountUpdateCommand=an,exports.ThreadUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.UIKitConfigInfo=pn,exports.UnsentMessageRemoveEventCommand=class extends R{constructor({reqId:e,source:t}){super(),this.reqId=e,this.source=t}},exports.User=Dn,exports.UserProfile=Un,exports.UserProfileUpdateCommand=Ln,exports.Vault=Io,exports.WebSocketEventCommand=Ce,exports.WebSocketRequestCommand=Te,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=pe(null!==(i=e.mentionType)&&void 0!==i?i:null,null!==(n=e.mentionedUserIds)&&void 0!==n?n:[],s),l=pe(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=pe,exports.createChangelogIncludeChatNotificationsCacheKey=e=>`sendbird@${e}/changelog_include_chat_notifications`,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=Rn,exports.deundefined=k,exports.getChannelApiPathByType=_e,exports.getReportApiPathByType=e=>{switch(e){case exports.ChannelType.GROUP:return`${te}/group_channels`;case exports.ChannelType.OPEN:return`${te}/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.isMilliSecondOf=(e,t=!1)=>!(!t||!_(e))||"number"==typeof e&&13===e.toString().length,exports.isReactNative=ke,exports.isResendableError=e=>e>0&&r.indexOf(e)>=0,exports.isThrowingOutside=n,exports.isTypeOf=l,exports.noop=Ve,exports.parsePollStatusPayload=Do,exports.runAsCallback=Fn,exports.runOrNothing=Hn,exports.serialize=xn,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===exports.CollectionEventSource.SYNC_MESSAGE_FILL||e===exports.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||e===exports.CollectionEventSource.SYNC_POLL_CHANGELOGS,exports.sleep=Kn,exports.undefineNullProps=O,exports.unless=kn,exports.uuid=w,exports.validatePollCreateParams=$o,exports.validatePollData=Lo,exports.validatePollOptionRetrievalParams=Zo,exports.validatePollRetrievalParams=Xo,exports.version=s; diff --git a/cjs/lib/__bundle-290a02c3.cjs b/cjs/lib/__bundle-2ad218ff.cjs similarity index 97% rename from cjs/lib/__bundle-290a02c3.cjs rename to cjs/lib/__bundle-2ad218ff.cjs index 8f51ccc..24dd903 100644 --- a/cjs/lib/__bundle-290a02c3.cjs +++ b/cjs/lib/__bundle-2ad218ff.cjs @@ -1 +1 @@ -var e,s,t,n=require("./__bundle-ad182031.cjs"),r=require("./__bundle-9d371926.cjs");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,(s=exports.PublicGroupChannelListOrder||(exports.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",s.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",s.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.ScheduledMessageListOrder=void 0,(t=exports.ScheduledMessageListOrder||(exports.ScheduledMessageListOrder={})).CREATED_AT="created_at",t.SCHEDULED_AT="scheduled_at";class a extends n.BaseCommand{constructor({message:e}){super(),this.message=e}}const o={};var i;exports.UserEventCategory=void 0,(i=exports.UserEventCategory||(exports.UserEventCategory={}))[i.USER_BLOCK=20001]="USER_BLOCK",i[i.USER_UNBLOCK=2e4]="USER_UNBLOCK",i[i.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED";class d{constructor(e){this.category=e.cat,this.data=e.data}static getDataAsUserBlockEvent(e,s){const{blocker:t,blockee:r}=s.data;return{blocker:new n.User(e,t),blockee:new n.User(e,r)}}static getDataAsFriendDiscoveredEvent(e,s){const{friend_discoveries:t}=s.data;return{friendDiscoveries:Array.isArray(t)?t.map((s=>new n.User(e,s))):[]}}}class c extends n.BaseCommand{constructor(e,{userId:s}){super(),this._iid=e,this.userId=s}}class u extends n.BaseCommand{constructor(){super()}}class h extends n.WebSocketEventCommand{constructor(e,s,t){super(e,"USEV",t),this.event=new d(t)}}exports.AutoResendManager=class{constructor(e,{localCacheEnabled:s,enableAutoResend:t,dispatcher:r,sdkState:a,logger:i}){this._iid=e,o[e]=this,this._localCacheEnabled=s,this._enableAutoResend=t,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=i,this._sdkState=a,this._localCacheEnabled&&r.on((e=>{if(e instanceof n.ConnectionStateChangeCommand)switch(e.stateType){case n.ConnectionStateType.CONNECTED:this._isProcessingAutoResend||this.processAutoResendRegisteredPendingMessages().then((()=>this._processNextAutoResend()));break;case n.ConnectionStateType.INTERNAL_DISCONNECTED:case n.ConnectionStateType.EXTERNAL_DISCONNECTED:this._isProcessingAutoResend=!1}}))}static of(e){return o[e]}processNonAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){if(!this._enableAutoResend)return;const e=yield this._fetchAllCachedPendingMessages();for(const s of e)0===s.errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=n.SendingStatus.FAILED,s.errorCode=n.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}))}processAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const s of e)if(this._enableAutoResend&&s.errorCode&&n.isAutoResendableError(s.errorCode)){const e=(new Date).getTime(),t=s.createdAt+2592e5;this._enableAutoResend&&e<=t?this._autoResendQueue.map((e=>e.reqId)).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(t).toLocaleString()),s.sendingStatus=n.SendingStatus.FAILED,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}}))}completeCurrentAndProcessNextAutoResend(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===n.SendingStatus.SUCCEEDED||e.sendingStatus===n.SendingStatus.FAILED&&!n.isAutoResendableError(e.errorCode))){const s=this.indexOf(e);s>=0&&this._autoResendQueue.splice(s,1),0===s&&this._processNextAutoResend()}}_fetchAllCachedPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=r.UnsentMessageCache.of(this._iid),s=new r.MessageFilter;return s.replyType=n.ReplyType.ALL,yield e.fetch({sendingStatus:n.SendingStatus.PENDING,backward:!0,filter:s})}))}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 n.__awaiter(this,void 0,void 0,(function*(){if(this._localCacheEnabled&&this._enableAutoResend&&"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 a({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=a,exports.DatabaseOpenCommand=c,exports.ReduceDBSizeEventCommand=u,exports.UserEvent=d,exports.UserEventCommand=h,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"]}}; +var e,s,t,n=require("./__bundle-1a495950.cjs"),r=require("./__bundle-165fd6e1.cjs");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,(s=exports.PublicGroupChannelListOrder||(exports.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",s.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",s.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.ScheduledMessageListOrder=void 0,(t=exports.ScheduledMessageListOrder||(exports.ScheduledMessageListOrder={})).CREATED_AT="created_at",t.SCHEDULED_AT="scheduled_at";class a extends n.BaseCommand{constructor({message:e}){super(),this.message=e}}const o={};var i;exports.UserEventCategory=void 0,(i=exports.UserEventCategory||(exports.UserEventCategory={}))[i.USER_BLOCK=20001]="USER_BLOCK",i[i.USER_UNBLOCK=2e4]="USER_UNBLOCK",i[i.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED";class d{constructor(e){this.category=e.cat,this.data=e.data}static getDataAsUserBlockEvent(e,s){const{blocker:t,blockee:r}=s.data;return{blocker:new n.User(e,t),blockee:new n.User(e,r)}}static getDataAsFriendDiscoveredEvent(e,s){const{friend_discoveries:t}=s.data;return{friendDiscoveries:Array.isArray(t)?t.map((s=>new n.User(e,s))):[]}}}class c extends n.BaseCommand{constructor(e,{userId:s}){super(),this._iid=e,this.userId=s}}class u extends n.BaseCommand{constructor(){super()}}class h extends n.WebSocketEventCommand{constructor(e,s,t){super(e,"USEV",t),this.event=new d(t)}}exports.AutoResendManager=class{constructor(e,{localCacheEnabled:s,enableAutoResend:t,dispatcher:r,sdkState:a,logger:i}){this._iid=e,o[e]=this,this._localCacheEnabled=s,this._enableAutoResend=t,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=i,this._sdkState=a,this._localCacheEnabled&&r.on((e=>{if(e instanceof n.ConnectionStateChangeCommand)switch(e.stateType){case n.ConnectionStateType.CONNECTED:this._isProcessingAutoResend||this.processAutoResendRegisteredPendingMessages().then((()=>this._processNextAutoResend()));break;case n.ConnectionStateType.INTERNAL_DISCONNECTED:case n.ConnectionStateType.EXTERNAL_DISCONNECTED:this._isProcessingAutoResend=!1}}))}static of(e){return o[e]}processNonAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){if(!this._enableAutoResend)return;const e=yield this._fetchAllCachedPendingMessages();for(const s of e)0===s.errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=n.SendingStatus.FAILED,s.errorCode=n.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}))}processAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const s of e)if(this._enableAutoResend&&s.errorCode&&n.isAutoResendableError(s.errorCode)){const e=(new Date).getTime(),t=s.createdAt+2592e5;this._enableAutoResend&&e<=t?this._autoResendQueue.map((e=>e.reqId)).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(t).toLocaleString()),s.sendingStatus=n.SendingStatus.FAILED,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}}))}completeCurrentAndProcessNextAutoResend(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===n.SendingStatus.SUCCEEDED||e.sendingStatus===n.SendingStatus.FAILED&&!n.isAutoResendableError(e.errorCode))){const s=this.indexOf(e);s>=0&&this._autoResendQueue.splice(s,1),0===s&&this._processNextAutoResend()}}_fetchAllCachedPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=r.UnsentMessageCache.of(this._iid),s=new r.MessageFilter;return s.replyType=n.ReplyType.ALL,yield e.fetch({sendingStatus:n.SendingStatus.PENDING,backward:!0,filter:s})}))}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 n.__awaiter(this,void 0,void 0,(function*(){if(this._localCacheEnabled&&this._enableAutoResend&&"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 a({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=a,exports.DatabaseOpenCommand=c,exports.ReduceDBSizeEventCommand=u,exports.UserEvent=d,exports.UserEventCommand=h,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"]}}; diff --git a/cjs/lib/__bundle-32f62cd2.cjs b/cjs/lib/__bundle-552fe22f.cjs similarity index 95% rename from cjs/lib/__bundle-32f62cd2.cjs rename to cjs/lib/__bundle-552fe22f.cjs index e6a0b5f..2d731d7 100644 --- a/cjs/lib/__bundle-32f62cd2.cjs +++ b/cjs/lib/__bundle-552fe22f.cjs @@ -1 +1 @@ -var e=require("./__bundle-ad182031.cjs");exports.xmlHttpRequest=(r,s)=>new Promise(((t,o)=>{if("undefined"!=typeof XMLHttpRequest){const{dispatcher:n,logger:d}=e.Vault.of(r),{requestId:a,method:i,url:u,headers:p={},data:c="",uploadProgressHandler:l}=s;let m=!1;const E=new XMLHttpRequest;E.open(i,u),Object.keys(p).forEach((e=>{E.setRequestHeader(e,p[e])})),l&&E.upload.addEventListener("progress",(e=>{e.lengthComputable?l(a,e.loaded,e.total):d.debug("Progress computing failed: `Content-Length` header is not given.")})),E.onabort=()=>{o(e.SendbirdError.requestCanceled)},E.onerror=r=>{o(e.SendbirdError.networkError)},E.onreadystatechange=()=>{if(E.readyState===XMLHttpRequest.DONE&&!m)if(0===E.status||E.status>=200&&E.status<400)try{const s=JSON.parse(E.responseText);t(new e.APIResponseCommand(r,s))}catch(r){o(e.SendbirdError.networkError)}else try{const r=JSON.parse(E.responseText);if(r){const s=new e.SendbirdError(r);if(s.isSessionExpiredError){if(n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message})),!(E instanceof e.SessionRefreshAPICommand)){const r=new e.Deferred;return n.dispatch(new e.RequestResendCommand({request:E,deferred:r,error:s})),r.promise}}else s.isSessionInvalidatedError&&n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message}));o(s)}else o(e.SendbirdError.requestFailed)}catch(r){o(e.SendbirdError.requestFailed)}},n.on((r=>{r instanceof e.CancelXMLHttpRequestCommand&&(r.requestId&&r.requestId!==a||(m=!0,E.abort()))})),E.send(c)}else o(e.SendbirdError.xmlHttpRequestNotSupported)})); +var e=require("./__bundle-1a495950.cjs");exports.xmlHttpRequest=(r,s)=>new Promise(((t,o)=>{if("undefined"!=typeof XMLHttpRequest){const{dispatcher:n,logger:d}=e.Vault.of(r),{requestId:a,method:i,url:u,headers:p={},data:c="",uploadProgressHandler:l}=s;let m=!1;const E=new XMLHttpRequest;E.open(i,u),Object.keys(p).forEach((e=>{E.setRequestHeader(e,p[e])})),l&&E.upload.addEventListener("progress",(e=>{e.lengthComputable?l(a,e.loaded,e.total):d.debug("Progress computing failed: `Content-Length` header is not given.")})),E.onabort=()=>{o(e.SendbirdError.requestCanceled)},E.onerror=r=>{o(e.SendbirdError.networkError)},E.onreadystatechange=()=>{if(E.readyState===XMLHttpRequest.DONE&&!m)if(0===E.status||E.status>=200&&E.status<400)try{const s=JSON.parse(E.responseText);t(new e.APIResponseCommand(r,s))}catch(r){o(e.SendbirdError.networkError)}else try{const r=JSON.parse(E.responseText);if(r){const s=new e.SendbirdError(r);if(s.isSessionExpiredError){if(n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message})),!(E instanceof e.SessionRefreshAPICommand)){const r=new e.Deferred;return n.dispatch(new e.RequestResendCommand({request:E,deferred:r,error:s})),r.promise}}else s.isSessionInvalidatedError&&n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message}));o(s)}else o(e.SendbirdError.requestFailed)}catch(r){o(e.SendbirdError.requestFailed)}},n.on((r=>{r instanceof e.CancelXMLHttpRequestCommand&&(r.requestId&&r.requestId!==a||(m=!0,E.abort()))})),E.send(c)}else o(e.SendbirdError.xmlHttpRequestNotSupported)})); diff --git a/cjs/lib/__bundle-441c4e66.cjs b/cjs/lib/__bundle-611abb88.cjs similarity index 91% rename from cjs/lib/__bundle-441c4e66.cjs rename to cjs/lib/__bundle-611abb88.cjs index c87366b..794f4d0 100644 --- a/cjs/lib/__bundle-441c4e66.cjs +++ b/cjs/lib/__bundle-611abb88.cjs @@ -1 +1 @@ -var o=require("./__bundle-ad182031.cjs");exports.BaseChannelHandlerParams=class{constructor(){this.onUserMuted=o.noop,this.onUserUnmuted=o.noop,this.onUserBanned=o.noop,this.onUserUnbanned=o.noop,this.onChannelChanged=o.noop,this.onChannelDeleted=o.noop,this.onChannelFrozen=o.noop,this.onChannelUnfrozen=o.noop,this.onOperatorUpdated=o.noop,this.onChannelMemberCountChanged=o.noop,this.onMetaDataCreated=o.noop,this.onMetaDataUpdated=o.noop,this.onMetaDataDeleted=o.noop,this.onMetaCounterCreated=o.noop,this.onMetaCounterUpdated=o.noop,this.onMetaCounterDeleted=o.noop,this.onMessageReceived=o.noop,this.onMessageUpdated=o.noop,this.onMessageDeleted=o.noop,this.onMentionReceived=o.noop,this.onReactionUpdated=o.noop,this.onThreadInfoUpdated=o.noop}}; +var o=require("./__bundle-1a495950.cjs");exports.BaseChannelHandlerParams=class{constructor(){this.onUserMuted=o.noop,this.onUserUnmuted=o.noop,this.onUserBanned=o.noop,this.onUserUnbanned=o.noop,this.onChannelChanged=o.noop,this.onChannelDeleted=o.noop,this.onChannelFrozen=o.noop,this.onChannelUnfrozen=o.noop,this.onOperatorUpdated=o.noop,this.onChannelMemberCountChanged=o.noop,this.onMetaDataCreated=o.noop,this.onMetaDataUpdated=o.noop,this.onMetaDataDeleted=o.noop,this.onMetaCounterCreated=o.noop,this.onMetaCounterUpdated=o.noop,this.onMetaCounterDeleted=o.noop,this.onMessageReceived=o.noop,this.onMessageUpdated=o.noop,this.onMessageDeleted=o.noop,this.onMentionReceived=o.noop,this.onReactionUpdated=o.noop,this.onThreadInfoUpdated=o.noop}}; diff --git a/cjs/lib/__bundle-ad182031.cjs b/cjs/lib/__bundle-ad182031.cjs deleted file mode 100644 index 0c73c1d..0000000 --- a/cjs/lib/__bundle-ad182031.cjs +++ /dev/null @@ -1,2 +0,0 @@ -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.14.3";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.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.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",t[t.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",t[t.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",t[t.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",t[t.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",t[t.SESSION_REVOKED=400310]="SESSION_REVOKED",t[t.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",t[t.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",t[t.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",t[t.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",t[t.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",t[t.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",t[t.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",t[t.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",t[t.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",t[t.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",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.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",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.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_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",t[t.USER_DEACTIVATED=900021]="USER_DEACTIVATED",t[t.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";const n=e=>!(e instanceof o&&!e.shouldThrowOutside);class o extends Error{constructor({code:e=0,message:t=""}){super(t),this.shouldThrowOutside=!1,this._detail="",this.name="SendbirdError",this.code=e,Object.setPrototypeOf(this,o.prototype)}get detail(){return this._detail}setDetail(e){this._detail=e}get isInvalidTokenError(){return this.code===exports.SendbirdErrorCode.INVALID_TOKEN}get isSessionExpiredError(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}get isSessionTokenExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}get isSessionKeyExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}get isSessionInvalidatedError(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}get isSessionRevokedError(){return this.code===exports.SendbirdErrorCode.SESSION_REVOKED}get isUserAuthDeactivedError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED}get isUserAuthDeletedOrNotFoundError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}get isNetworkError(){return this.code===exports.SendbirdErrorCode.NETWORK_ERROR||this.code===exports.SendbirdErrorCode.NETWORK_ROUTING_ERROR}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 xmlHttpRequestNotSupported(){return new o({code:exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}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 channelTypeNotSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}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 tooManyRequests(){return new o({code:exports.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}static get alreadyConnectedAsAnotherUser(){return new o({code:exports.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}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."})}static get statLogUploadLimitExceededError(){return new o({code:exports.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}static get malformedDataError(){return new o({code:exports.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}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,exports.SendbirdErrorCode.USER_DEACTIVATED,exports.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],a=[exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.CONNECTION_REQUIRED],l=(e,t,s=!1)=>!(!s||!_(t))||("string"!=typeof e?"object"==typeof e?d(e,t):c(e,t):typeof t===e),d=(e,t,s=!1)=>!(!s||!_(t))||Object.values(e).includes(t),c=(e,t)=>t instanceof e,h=(e,t,s=!1)=>!(!s||!_(t))||Array.isArray(t)&&t.every((t=>l(e,t))),u=(e,t=!1)=>{if(t&&_(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},_=e=>null==e;class p{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 E={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=exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=i}get maxSize(){return this._maxSize}get clearOrder(){return this._clearOrder}get clearOrderComparator(){var e;return this._clearOrder===exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}get enableAutoResend(){return this._enableAutoResend}}var A;exports.SessionService=void 0,(A=exports.SessionService||(exports.SessionService={})).FEED="feed",A.CHAT="chat",A.CHAT_API="chat_api";class N{constructor(){this.isRefreshing=!1}get hasSession(){return!!this.sessionKey}get hasChatServicePermission(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(exports.SessionService.CHAT))}clear(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}const w=()=>{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 b{constructor({container:e}){this._container={},this._container=e,this.key=w()}_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(){Object.keys(this._container).forEach((e=>{var t;null===(t=this._container[e])||void 0===t||t.delete(this.key)}))}}class I{constructor(){this._container={}}on(e,t){return new b({container:this._container}).on(e,t)}once(e,t){return new b({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 I}on(e){return this._dispatcher.on("event",e)}once(e){return this._dispatcher.once("event",e)}dispatch(e){this._dispatcher.dispatch("event",e)}}class R{}const k=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},D=e=>{if(null!=e){if("object"==typeof e){if(Array.isArray(e)){const t=[...e];for(let e=0;e{null===e[t]&&delete e[t]})),e}return e}};var O,L,U,P,M,q,F,H,V,z,G,K,B;exports.ChannelType=void 0,(O=exports.ChannelType||(exports.ChannelType={})).BASE="base",O.GROUP="group",O.OPEN="open",O.FEED="feed",exports.Role=void 0,(L=exports.Role||(exports.Role={})).OPERATOR="operator",L.NONE="none",exports.MutedState=void 0,(U=exports.MutedState||(exports.MutedState={})).MUTED="muted",U.UNMUTED="unmuted",exports.MessageType=void 0,(P=exports.MessageType||(exports.MessageType={})).BASE="base",P.USER="user",P.FILE="file",P.ADMIN="admin",exports.MessageTypeFilter=void 0,(M=exports.MessageTypeFilter||(exports.MessageTypeFilter={})).ALL="",M.USER="MESG",M.FILE="FILE",M.ADMIN="ADMM",exports.ServerSideMessageType=void 0,(q=exports.ServerSideMessageType||(exports.ServerSideMessageType={})).USER="MESG",q.FILE="FILE",q.ADMIN="ADMM",exports.MentionType=void 0,(F=exports.MentionType||(exports.MentionType={})).USERS="users",F.CHANNEL="channel",exports.ReplyType=void 0,(H=exports.ReplyType||(exports.ReplyType={})).ALL="all",H.NONE="none",H.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",exports.PushNotificationDeliveryOption=void 0,(V=exports.PushNotificationDeliveryOption||(exports.PushNotificationDeliveryOption={})).DEFAULT="default",V.SUPPRESS="suppress",exports.SendingStatus=void 0,(z=exports.SendingStatus||(exports.SendingStatus={})).PENDING="pending",z.SCHEDULED="scheduled",z.SUCCEEDED="succeeded",z.FAILED="failed",z.CANCELED="canceled",exports.MessageReviewStatus=void 0,(G=exports.MessageReviewStatus||(exports.MessageReviewStatus={})).INREVIEW="InReview",G.APPROVED="Approved",exports.NotificationPriority=void 0,(K=exports.NotificationPriority||(exports.NotificationPriority={})).HIGH="high",K.NORMAL="normal",K.LOW="low",exports.MessageTemplateListOrder=void 0,(B=exports.MessageTemplateListOrder||(exports.MessageTemplateListOrder={})).CREATED_AT="created_at",B.UPDATED_AT="updated_at";const Q="v3",j=`/${Q}/users`,$=`/${Q}/sdk/users`,W=`/${Q}/storage/file`,Z=`/${Q}/group_channels`,Y=`/${Q}/sdk/group_channels`,X=`/${Q}/open_channels`,J=`/${Q}/sdk/open_channels`,ee=`/${Q}/search`,te=`/${Q}/report`,se=`/${Q}/emojis`,ie=`/${Q}/emoji_categories`,ne=`/${Q}/polls`,oe=`/${Q}/scheduled_messages`,re=`/${Q}/sdk/ui_kit/configuration`,ae=`/${Q}/sdk/statistics`,le=`/${Q}/notifications`,de=`/${Q}/notifications/users`,ce=`/${Q}/message_templates`,he=`/${Q}/sdk/push_delivery`,ue=`/${Q}/forms`,_e=e=>{switch(e){case exports.ChannelType.FEED:case exports.ChannelType.GROUP:return Z;case exports.ChannelType.OPEN:return X;default:return null}},pe=(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},Ee=(e,t,s)=>{var i;let n=t||new FormData;for(const t in e){if(!e.hasOwnProperty(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=Ee(o,n,r)}return n};var ge;exports.APIRequestMethod=void 0,(ge=exports.APIRequestMethod||(exports.APIRequestMethod={})).GET="GET",ge.POST="POST",ge.PUT="PUT",ge.DELETE="DELETE";class fe extends R{constructor(){super(...arguments),this.params={},this.requireAuth=!0,this.headers={},this.requestId=w()}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=k(this.params);return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${this.encodeParams(e[t])}`)).join("&")}`}get payload(){const e=k(this.params);return Object.keys(e).some((t=>u(e[t])))?Ee(e):JSON.stringify(e)}get hasSessionKey(){return void 0!==this.headers["Session-Key"]}}class ve extends R{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 Se extends R{constructor(e){super(),this.requestId=e}}class me extends R{constructor({expires_in:e,reason:t=exports.SendbirdErrorCode.SESSION_KEY_EXPIRED,message:s=""}){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:case exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED:case exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND:this.error=new o({code:t,message:s})}}get invalidateSessionToken(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}class Ce extends R{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 Ce(e,s,i)}}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}as(e){return new e(this._iid,this.code,this.payload)}}class Te extends R{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:w(),this.ackRequired=t,this.payload.req_id=this.requestId}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}}class ye extends fe{constructor({userId:e,authToken:t,services:s,expiringSession:i=!0}){super(),this.path=`${j}/${e}/session_key`,this.method=exports.APIRequestMethod.POST,this.params=k({token:t,services:s,expiring_session:!!i}),this.requireAuth=!1}}class Ae extends Te{constructor({authToken:e,expiringSession:t=!0,requestId:s}){super({code:"LOGI",payload:k({token:e,expiring_session:t?1:0,req_id:s}),ackRequired:!0})}}class Ne extends ve{constructor(e,t){super(e,t);const{key:s,expires_at:i,services:n}=t;this.key=s,this.expiresAt=i,this.services=n}}class we extends Ce{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):null}}class be extends R{constructor(e){super(),this.statLog=e}}class Ie extends R{constructor({request:e,deferred:t,error:s=o.requestFailed}){super(),this.request=e,this.deferred=t,this.error=s}}var xe;exports.StatType=void 0,(xe=exports.StatType||(exports.StatType={})).FEATURE_LOCALCACHE="feature:local_cache",xe.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",xe.NOTIFICATION="noti:stats",xe.WEBSOCKET_CONNECT="ws:connect",xe.API_RESULT="api:result";class Re{constructor({type:e,data:t,ts:s=Date.now()}){this.type=e,this.createdAt=s,this.data=t}static payloadify(e){return k({stat_type:e.type,ts:e.createdAt,data:k(e.data)})}}const ke=()=>"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product,De=()=>!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent));var Oe,Le,Ue;exports.SendbirdProduct=void 0,(Oe=exports.SendbirdProduct||(exports.SendbirdProduct={})).CHAT="chat",Oe.CALLS="calls",Oe.DESK="desk",Oe.LIVE="live",Oe.UIKIT_CHAT="uikit-chat",Oe.UIKIT_LIVE="uikit-live",exports.SendbirdPlatform=void 0,(Le=exports.SendbirdPlatform||(exports.SendbirdPlatform={})).ANDROID="android",Le.IOS="ios",Le.JS="js",Le.UNREAL="unreal",Le.UNITY="unity",Le.REACT_NATIVE="react-native",Le.FLUTTER="flutter",exports.DeviceOsPlatform=void 0,(Ue=exports.DeviceOsPlatform||(exports.DeviceOsPlatform={})).ANDROID="android",Ue.IOS="ios",Ue.WEB="web",Ue.MOBILE_WEB="mobile_web",Ue.WINDOWS="windows";class Pe{}Pe.sendbirdSdkUserAgentWithExtension=e=>{let t={main_sdk_info:`chat/${ke()?exports.SendbirdPlatform.REACT_NATIVE:exports.SendbirdPlatform.JS}/${i.SDK_VERSION}`,device_os_platform:De()?"mobile-web":"web",os_version:i.OS_VERSION};if(e){const{sendbirdExtensions:s,deviceOS:i,customData:n={}}=e;i.version&&(t.os_version=i.version),i.platform&&(t.device_os_platform=i.platform),s.length>0&&(t.extension_sdk_info=s.map((({product:e,platform:t,version:s})=>`${e}/${t}/${s}`)).join(",")),Object.keys(t).forEach((e=>delete n[e])),Object.keys(n).length>0&&(t=Object.assign(Object.assign({},t),n))}return Object.entries(t).map((([e,t])=>`${e}=${t}`)).join("&")},Pe.userAgentWithExtension=e=>{const t=ke()?"reactnative":"JS",s=e.sb_syncmanager?`s${e.sb_syncmanager}`:"",n=e.sb_uikit?`u${e.sb_uikit}`:"",o=e["device-os-platform"]?`o${e["device-os-platform"]}`:De()?"omobile-web":"oweb";return`${t}/c${i.SDK_VERSION}/${s}/${n}/${o}`};class Me{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=e=>{t(e)}}))}}class qe extends R{constructor(e){super(),this.requestId=e.requestId}}class Fe extends fe{constructor(e){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${_e(e.channelType)}/${e.channelUrl}/messages/${e.messageId}`,e.messageToken&&(this.params=k({mesg_token:e.messageToken}))}}class He{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:o=!1}){this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=t,this._sdkState=s,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof Se&&this.cancel(e.requestId)})),this._logger=n,this._shouldImportFetchCompat=o}_createHeader(e,t){const{appId:s,appVersion:n,sendbirdRuntimeEnvironment:o}=this._sdkState,r=Object.assign(Object.assign({},e.headers),{SendBird:`JS,${i.OS_VERSION},${i.SDK_VERSION},${s}${n?`,${n}`:""}`,"SB-User-Agent":Pe.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":Pe.sendbirdSdkUserAgentWithExtension(o)});return t||(r["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(r["Session-Key"]=this._session.sessionKey),r["App-Id"]=s,this._session&&this._session.authToken&&(r["Access-Token"]=this._session.authToken),r}_statLogApiResult(e,t,s){this._dispatcher.dispatch(new be(new Re({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}})))}_isBodyRequired(e){const{method:t}=e;return t!==exports.APIRequestMethod.GET&&(t!==exports.APIRequestMethod.DELETE||e instanceof Fe)}send(t){return e(this,void 0,void 0,(function*(){const{path:e,method:s,uploadProgressHandler:i}=t,n=this._isBodyRequired(t),{api:r}=this._sdkState,a=`${r.host}${e}${n?"":t.query}`,l=n?t.payload:null,d=this._createHeader(t,l instanceof FormData?l:void 0),c=new AbortController,{signal:h}=c;this._abortControl.set(t.requestId,c);const u=Date.now();try{if(i){const{xmlHttpRequest:e}=yield Promise.resolve().then((function(){return require("./__bundle-32f62cd2.cjs")}));try{const s=yield e(this._iid,{requestId:t.requestId,method:t.method,url:a,headers:d,data:null!=l?l:void 0,uploadProgressHandler:i});return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),s}catch(e){if(!(e instanceof o&&e.code===exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED))throw e;this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored.")}}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-6301b3ce.cjs")}))),"function"!=typeof fetch&&(yield Promise.resolve().then((function(){return require("./__bundle-38c66c0d.cjs")})));const e=yield fetch(a,{method:s,body:l,headers:d,signal:h}),n=yield e.json();if(e.ok||e.redirected)return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),new ve(this._iid,n);if(n){const e=new o(n);if(e.isSessionExpiredError){if(this._dispatcher.dispatch(new me({reason:e.code,message:e.message})),!(t instanceof ye)){const s=new Me;return this._dispatcher.dispatch(new Ie({request:t,deferred:s,error:e})),s.promise}throw e}throw e.isSessionInvalidatedError?(this._dispatcher.dispatch(new me({reason:e.code,message:e.message})),e):e}throw o.requestFailed}catch(e){throw this._statLogApiResult(t,u,e),e instanceof o?(this._logger.debug("fail api request",e),e):"AbortError"===(null==e?void 0:e.name)?o.requestCanceled:(this._logger.debug("fail api request",e),o.networkError)}}))}cancel(e){if(this._abortControl.has(e)){this._abortControl.get(e).abort(),this._abortControl.delete(e)}this._dispatcher.dispatch(new qe({requestId:e}))}cancelAll(){for(const e of this._abortControl.values())e.abort();this._abortControl.clear(),this._dispatcher.dispatch(new qe({}))}}const Ve=()=>{}; -/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function ze(e){let t=e.length;for(;--t>=0;)e[t]=0}const Ge=256,Ke=286,Be=30,Qe=15,je=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]),$e=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]),Ze=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ye=new Array(576);ze(Ye);const Xe=new Array(60);ze(Xe);const Je=new Array(512);ze(Je);const et=new Array(256);ze(et);const tt=new Array(29);ze(tt);const st=new Array(Be);function it(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 nt,ot,rt;function at(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ze(st);const lt=e=>e<256?Je[e]:Je[256+(e>>>7)],dt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ct=(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<{ct(e,s[2*t],s[2*t+1])},ut=(e,t)=>{let s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1},_t=(e,t,s)=>{const i=new Array(16);let n,o,r=0;for(n=1;n<=Qe;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]=ut(i[t]++,t))}},pt=e=>{let t;for(t=0;t{e.bi_valid>8?dt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},gt=(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?ht(e,n,t):(o=et[n],ht(e,o+Ge+1,t),r=je[o],0!==r&&(n-=tt[o],ct(e,n,r)),i--,o=lt(i),ht(e,o,s),r=$e[o],0!==r&&(i-=st[o],ct(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--)ft(e,s,r);l=o;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ft(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++,ft(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,E=0;for(u=0;u<=Qe;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,E++),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!==E){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]--,E-=2}while(E>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),_t(s,d,e.bl_count)},mt=(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{ct(e,0+(i?1:0),3),Et(e),dt(e,s),dt(e,~s),s&&e.pending_buf.set(e.window.subarray(t,t+s),e.pending),e.pending+=s};var At=(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(mt(e,e.dyn_ltree,e.l_desc.max_code),mt(e,e.dyn_dtree,e.d_desc.max_code),St(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),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?yt(e,t,s,i):4===e.strategy||o===n?(ct(e,2+(i?1:0),3),vt(e,Ye,Xe)):(ct(e,4+(i?1:0),3),((e,t,s,i)=>{let n;for(ct(e,t-257,5),ct(e,s-1,5),ct(e,i-4,4),n=0;n{Tt||((()=>{let e,t,s,i,n;const o=new Array(16);for(s=0,i=0;i<28;i++)for(tt[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*(et[s]+Ge+1)]++,e.dyn_dtree[2*lt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ct(e,2,3),ht(e,256,Ye),(e=>{16===e.bi_valid?(dt(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 wt=(e,t,s,i)=>{let n=65535&e,o=e>>>16&65535,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};const bt=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 It=(e,t,s,i)=>{const n=bt,o=i+s;e^=-1;for(let s=i;s>>8^n[255&(e^t[s])];return~e},xt={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"},Rt={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:kt,_tr_stored_block:Dt,_tr_flush_block:Ot,_tr_tally:Lt,_tr_align:Ut}=Nt,{Z_NO_FLUSH:Pt,Z_PARTIAL_FLUSH:Mt,Z_FULL_FLUSH:qt,Z_FINISH:Ft,Z_BLOCK:Ht,Z_OK:Vt,Z_STREAM_END:zt,Z_STREAM_ERROR:Gt,Z_DATA_ERROR:Kt,Z_BUF_ERROR:Bt,Z_DEFAULT_COMPRESSION:Qt,Z_FILTERED:jt,Z_HUFFMAN_ONLY:$t,Z_RLE:Wt,Z_FIXED:Zt,Z_DEFAULT_STRATEGY:Yt,Z_UNKNOWN:Xt,Z_DEFLATED:Jt}=Rt,es=258,ts=262,ss=42,is=113,ns=666,os=(e,t)=>(e.msg=xt[t],t),rs=e=>2*e-(e>4?9:0),as=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ls=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 ds=(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))},hs=(e,t)=>{Ot(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,cs(e.strm)},us=(e,t)=>{e.pending_buf[e.pending++]=t},_s=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ps=(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=wt(e.adler,t,n,s):2===e.state.wrap&&(e.adler=It(e.adler,t,n,s)),e.next_in+=n,e.total_in+=n,n)},Es=(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-ts?e.strstart-(e.w_size-ts):0,d=e.window,c=e.w_mask,h=e.prev,u=e.strstart+es;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},gs=e=>{const t=e.w_size;let s,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ts)&&(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),ls(e),i+=t),0===e.strm.avail_in)break;if(s=ps(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=ds(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=ds(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,cs(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&&(ps(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&&(ps(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===Ft)&&t!==Pt&&0===e.strm.avail_in&&i<=n)&&(s=i>n?n:i,r=t===Ft&&0===e.strm.avail_in&&s===i?1:0,Dt(e,e.block_start,s,r),e.block_start+=s,cs(e.strm)),r?3:1)},vs=(e,t)=>{let s,i;for(;;){if(e.lookahead=3&&(e.ins_h=ds(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-ts&&(e.match_length=Es(e,s)),e.match_length>=3)if(i=Lt(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=ds(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=ds(e,e.ins_h,e.window[e.strstart+1]);else i=Lt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(hs(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(e,!1),0===e.strm.avail_out)?1:2},Ss=(e,t)=>{let s,i,n;for(;;){if(e.lookahead=3&&(e.ins_h=ds(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=Lt(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=ds(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&&(hs(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Lt(e,0,e.window[e.strstart-1]),i&&hs(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=Lt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(e,!1),0===e.strm.avail_out)?1:2};function ms(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 Cs=[new ms(0,0,0,0,fs),new ms(4,4,8,4,vs),new ms(4,5,16,8,vs),new ms(4,6,32,32,vs),new ms(4,4,16,16,Ss),new ms(8,16,32,32,Ss),new ms(8,16,128,128,Ss),new ms(8,32,128,256,Ss),new ms(32,128,258,1024,Ss),new ms(32,258,258,4096,Ss)];function Ts(){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),as(this.dyn_ltree),as(this.dyn_dtree),as(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),as(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),as(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 ys=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==ss&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==is&&t.status!==ns?1:0},As=e=>{if(ys(e))return os(e,Gt);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?ss:is,e.adler=2===t.wrap?0:1,t.last_flush=-2,kt(t),Vt},Ns=e=>{const t=As(e);var s;return t===Vt&&((s=e.state).window_size=2*s.w_size,as(s.head),s.max_lazy_match=Cs[s.level].max_lazy,s.good_match=Cs[s.level].good_length,s.nice_match=Cs[s.level].nice_length,s.max_chain_length=Cs[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},ws=(e,t,s,i,n,o)=>{if(!e)return Gt;let r=1;if(t===Qt&&(t=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||s!==Jt||i<8||i>15||t<0||t>9||o<0||o>Zt||8===i&&1!==r)return os(e,Gt);8===i&&(i=9);const a=new Ts;return e.state=a,a.strm=e,a.status=ss,a.wrap=r,a.gzhead=null,a.w_bits=i,a.w_size=1<ws(e,t,Jt,15,8,Yt),deflateInit2:ws,deflateReset:Ns,deflateResetKeep:As,deflateSetHeader:(e,t)=>ys(e)||2!==e.state.wrap?Gt:(e.state.gzhead=t,Vt),deflate:(e,t)=>{if(ys(e)||t>Ht||t<0)return e?os(e,Gt):Gt;const s=e.state;if(!e.output||0!==e.avail_in&&!e.input||s.status===ns&&t!==Ft)return os(e,0===e.avail_out?Bt:Gt);const i=s.last_flush;if(s.last_flush=t,0!==s.pending){if(cs(e),0===e.avail_out)return s.last_flush=-1,Vt}else if(0===e.avail_in&&rs(t)<=rs(i)&&t!==Ft)return os(e,Bt);if(s.status===ns&&0!==e.avail_in)return os(e,Bt);if(s.status===ss&&0===s.wrap&&(s.status=is),s.status===ss){let t=Jt+(s.w_bits-8<<4)<<8,i=-1;if(i=s.strategy>=$t||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,_s(s,t),0!==s.strstart&&(_s(s,e.adler>>>16),_s(s,65535&e.adler)),e.adler=1,s.status=is,cs(e),0!==s.pending)return s.last_flush=-1,Vt}if(57===s.status)if(e.adler=0,us(s,31),us(s,139),us(s,8),s.gzhead)us(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)),us(s,255&s.gzhead.time),us(s,s.gzhead.time>>8&255),us(s,s.gzhead.time>>16&255),us(s,s.gzhead.time>>24&255),us(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),us(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(us(s,255&s.gzhead.extra.length),us(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=It(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69;else if(us(s,0),us(s,0),us(s,0),us(s,0),us(s,0),us(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),us(s,3),s.status=is,cs(e),0!==s.pending)return s.last_flush=-1,Vt;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=It(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex+=n,cs(e),0!==s.pending)return s.last_flush=-1,Vt;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=It(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=It(e.adler,s.pending_buf,s.pending-i,i)),cs(e),0!==s.pending)return s.last_flush=-1,Vt;i=0}t=s.gzindexi&&(e.adler=It(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=It(e.adler,s.pending_buf,s.pending-i,i)),cs(e),0!==s.pending)return s.last_flush=-1,Vt;i=0}t=s.gzindexi&&(e.adler=It(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&&(cs(e),0!==s.pending))return s.last_flush=-1,Vt;us(s,255&e.adler),us(s,e.adler>>8&255),e.adler=0}if(s.status=is,cs(e),0!==s.pending)return s.last_flush=-1,Vt}if(0!==e.avail_in||0!==s.lookahead||t!==Pt&&s.status!==ns){let i=0===s.level?fs(s,t):s.strategy===$t?((e,t)=>{let s;for(;;){if(0===e.lookahead&&(gs(e),0===e.lookahead)){if(t===Pt)return 1;break}if(e.match_length=0,s=Lt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(hs(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(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<=es){if(gs(e),e.lookahead<=es&&t===Pt)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+es;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=Lt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=Lt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(hs(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(e,!1),0===e.strm.avail_out)?1:2})(s,t):Cs[s.level].func(s,t);if(3!==i&&4!==i||(s.status=ns),1===i||3===i)return 0===e.avail_out&&(s.last_flush=-1),Vt;if(2===i&&(t===Mt?Ut(s):t!==Ht&&(Dt(s,0,0,!1),t===qt&&(as(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),cs(e),0===e.avail_out))return s.last_flush=-1,Vt}return t!==Ft?Vt:s.wrap<=0?zt:(2===s.wrap?(us(s,255&e.adler),us(s,e.adler>>8&255),us(s,e.adler>>16&255),us(s,e.adler>>24&255),us(s,255&e.total_in),us(s,e.total_in>>8&255),us(s,e.total_in>>16&255),us(s,e.total_in>>24&255)):(_s(s,e.adler>>>16),_s(s,65535&e.adler)),cs(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?Vt:zt)},deflateEnd:e=>{if(ys(e))return Gt;const t=e.state.status;return e.state=null,t===is?os(e,Kt):Vt},deflateSetDictionary:(e,t)=>{let s=t.length;if(ys(e))return Gt;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==ss||i.lookahead)return Gt;if(1===n&&(e.adler=wt(e.adler,t,s,0)),i.wrap=0,s>=i.w_size){0===n&&(as(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,gs(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=ds(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,gs(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,Vt},deflateInfo:"pako deflate (from Nodeca project)"};const Is=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var xs={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)Is(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;ks[254]=ks[254]=1;var Ds={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&&Rs)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+ks[e[s]]>t?s:t}};var Os=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 Ls=Object.prototype.toString,{Z_NO_FLUSH:Us,Z_SYNC_FLUSH:Ps,Z_FULL_FLUSH:Ms,Z_FINISH:qs,Z_OK:Fs,Z_STREAM_END:Hs,Z_DEFAULT_COMPRESSION:Vs,Z_DEFAULT_STRATEGY:zs,Z_DEFLATED:Gs}=Rt;function Ks(e){this.options=xs.assign({level:Vs,method:Gs,chunkSize:16384,windowBits:15,memLevel:8,strategy:zs},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 Os,this.strm.avail_out=0;let s=bs.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(s!==Fs)throw new Error(xt[s]);if(t.header&&bs.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Ds.string2buf(t.dictionary):"[object ArrayBuffer]"===Ls.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,s=bs.deflateSetDictionary(this.strm,e),s!==Fs)throw new Error(xt[s]);this._dict_set=!0}}function Bs(e,t){const s=new Ks(t);if(s.push(e,!0),s.err)throw s.msg||xt[s.err];return s.result}Ks.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?qs:Us,"string"==typeof e?s.input=Ds.string2buf(e):"[object ArrayBuffer]"===Ls.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===Ps||o===Ms)&&s.avail_out<=6)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else{if(n=bs.deflate(s,o),n===Hs)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),n=bs.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Fs;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},Ks.prototype.onData=function(e){this.chunks.push(e)},Ks.prototype.onEnd=function(e){e===Fs&&(this.result=xs.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qs={Deflate:Ks,deflate:Bs,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Bs(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Bs(e,t)},constants:Rt};const js=16209;var $s=function(e,t){let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A,N;const w=e.state;s=e.next_in,A=e.input,i=s+(e.avail_in-5),n=e.next_out,N=e.output,o=n-(t-e.avail_out),r=n+(e.avail_out-257),a=w.dmax,l=w.wsize,d=w.whave,c=w.wnext,h=w.window,u=w.hold,_=w.bits,p=w.lencode,E=w.distcode,g=(1<>>24,u>>>=S,_-=S,S=v>>>16&255,0===S)N[n++]=65535&v;else{if(!(16&S)){if(64&S){if(32&S){w.mode=16191;break e}e.msg="invalid literal/length code",w.mode=js;break e}v=p[(65535&v)+(u&(1<>>=S,_-=S),_<15&&(u+=A[s++]<<_,_+=8,u+=A[s++]<<_,_+=8),v=E[u&f];;){if(S=v>>>24,u>>>=S,_-=S,S=v>>>16&255,16&S){if(C=65535&v,S&=15,_a){e.msg="invalid distance too far back",w.mode=js;break e}if(u>>>=S,_-=S,S=n-o,C>S){if(S=C-S,S>d&&w.sane){e.msg="invalid distance too far back",w.mode=js;break e}if(T=0,y=h,0===c){if(T+=l-S,S2;)N[n++]=y[T++],N[n++]=y[T++],N[n++]=y[T++],m-=3;m&&(N[n++]=y[T++],m>1&&(N[n++]=y[T++]))}else{T=n-C;do{N[n++]=N[T++],N[n++]=N[T++],N[n++]=N[T++],m-=3}while(m>2);m&&(N[n++]=N[T++],m>1&&(N[n++]=N[T++]))}break}if(64&S){e.msg="invalid distance code",w.mode=js;break e}v=E[(65535&v)+(u&(1<>3,s-=m,_-=m<<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,E=0,g=0,f=0,v=0,S=0,m=0,C=0,T=0,y=0,A=0,N=null;const w=new Uint16Array(16),b=new Uint16Array(16);let I,x,R,k=null;for(E=0;E<=Ws;E++)w[E]=0;for(g=0;g=1&&0===w[v];v--);if(S>v&&(S=v),0===v)return n[o++]=20971520,n[o++]=20971520,a.bits=1,0;for(f=1;f0&&(0===e||1!==v))return-1;for(b[1]=0,E=1;E852||2===e&&y>592)return 1;for(;;){I=E-C,r[g]+1=p?(x=k[r[g]-p],R=N[r[g]-p]):(x=96,R=0),d=1<>C)+c]=I<<24|x<<16|R}while(0!==c);for(d=1<>=1;if(0!==d?(A&=d-1,A+=d):A=0,g++,0==--w[E]){if(E===v)break;E=t[s+r[g]]}if(E>S&&(A&u)!==h){for(0===C&&(C=S),_+=f,m=E-C,T=1<852||2===e&&y>592)return 1;h=A&u,n[h]=S<<24|m<<16|_-o}}return 0!==A&&(n[_+A]=E-C<<24|64<<16),a.bits=S,0};const{Z_FINISH:ti,Z_BLOCK:si,Z_TREES:ii,Z_OK:ni,Z_STREAM_END:oi,Z_NEED_DICT:ri,Z_STREAM_ERROR:ai,Z_DATA_ERROR:li,Z_MEM_ERROR:di,Z_BUF_ERROR:ci,Z_DEFLATED:hi}=Rt,ui=16180,_i=16190,pi=16191,Ei=16192,gi=16194,fi=16199,vi=16200,Si=16206,mi=16209,Ci=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ti(){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 yi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Ai=e=>{if(yi(e))return ai;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=ui,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,ni},Ni=e=>{if(yi(e))return ai;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ai(e)},wi=(e,t)=>{let s;if(yi(e))return ai;const i=e.state;return t<0?(s=0,t=-t):(s=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ai:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=s,i.wbits=t,Ni(e))},bi=(e,t)=>{if(!e)return ai;const s=new Ti;e.state=s,s.strm=e,s.window=null,s.mode=ui;const i=wi(e,t);return i!==ni&&(e.state=null),i};let Ii,xi,Ri=!0;const ki=e=>{if(Ri){Ii=new Int32Array(512),xi=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(ei(1,e.lens,0,288,Ii,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ei(2,e.lens,0,32,xi,0,e.work,{bits:5}),Ri=!1}e.lencode=Ii,e.lenbits=9,e.distcode=xi,e.distbits=5},Di=(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.whavebi(e,15),inflateInit2:bi,inflate:(e,t)=>{let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A=0;const N=new Uint8Array(4);let w,b;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(yi(e)||!e.output||!e.input&&0!==e.avail_in)return ai;s=e.state,s.mode===pi&&(s.mode=Ei),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,y=ni;e:for(;;)switch(s.mode){case ui:if(0===s.wrap){s.mode=Ei;break}for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>>8&255,s.check=It(s.check,N,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=mi;break}if((15&d)!==hi){e.msg="unknown compression method",s.mode=mi;break}if(d>>>=4,c-=4,T=8+(15&d),0===s.wbits&&(s.wbits=T),T>15||T>s.wbits){e.msg="invalid window size",s.mode=mi;break}s.dmax=1<>8&1),512&s.flags&&4&s.wrap&&(N[0]=255&d,N[1]=d>>>8&255,s.check=It(s.check,N,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,N[2]=d>>>16&255,N[3]=d>>>24&255,s.check=It(s.check,N,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&&(N[0]=255&d,N[1]=d>>>8&255,s.check=It(s.check,N,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=It(s.check,N,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&&(T=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+_),T)),512&s.flags&&4&s.wrap&&(s.check=It(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{T=i[o+_++],s.head&&T&&s.length<65536&&(s.head.name+=String.fromCharCode(T))}while(T&&_>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=pi;break;case 16189:for(;c<32;){if(0===a)break e;a--,d+=i[o++]<>>=7&c,c-=7&c,s.mode=Si;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(ki(s),s.mode=fi,t===ii){d>>>=2,c-=2;break e}break;case 2:s.mode=16196;break;case 3:e.msg="invalid block type",s.mode=mi}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=mi;break}if(s.length=65535&d,d=0,c=0,s.mode=gi,t===ii)break e;case gi: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=pi;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=mi;break}s.have=0,s.mode=16197;case 16197:for(;s.have>>=3,c-=3}for(;s.have<19;)s.lens[I[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,w={bits:s.lenbits},y=ei(0,s.lens,0,19,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid code lengths set",s.mode=mi;break}s.have=0,s.mode=16198;case 16198:for(;s.have>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=g,c-=g,s.lens[s.have++]=v;else{if(16===v){for(b=g+2;c>>=g,c-=g,0===s.have){e.msg="invalid bit length repeat",s.mode=mi;break}T=s.lens[s.have-1],_=3+(3&d),d>>>=2,c-=2}else if(17===v){for(b=g+3;c>>=g,c-=g,T=0,_=3+(7&d),d>>>=3,c-=3}else{for(b=g+7;c>>=g,c-=g,T=0,_=11+(127&d),d>>>=7,c-=7}if(s.have+_>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=mi;break}for(;_--;)s.lens[s.have++]=T}}if(s.mode===mi)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=mi;break}if(s.lenbits=9,w={bits:s.lenbits},y=ei(1,s.lens,0,s.nlen,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid literal/lengths set",s.mode=mi;break}if(s.distbits=6,s.distcode=s.distdyn,w={bits:s.distbits},y=ei(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,w),s.distbits=w.bits,y){e.msg="invalid distances set",s.mode=mi;break}if(s.mode=fi,t===ii)break e;case fi:s.mode=vi;case vi: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,$s(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===pi&&(s.back=-1);break}for(s.back=0;A=s.lencode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,s.length=v,0===f){s.mode=16205;break}if(32&f){s.back=-1,s.mode=pi;break}if(64&f){e.msg="invalid literal/length code",s.mode=mi;break}s.extra=15&f,s.mode=16201;case 16201:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=16202;case 16202:for(;A=s.distcode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,64&f){e.msg="invalid distance code",s.mode=mi;break}s.offset=v,s.extra=15&f,s.mode=16203;case 16203:if(s.extra){for(b=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=mi;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=mi;break}_>s.wnext?(_-=s.wnext,p=s.wsize-_):p=s.wnext-_,_>s.length&&(_=s.length),E=s.window}else E=n,p=r-s.offset,_=s.length;_>l&&(_=l),l-=_,s.length-=_;do{n[r++]=E[p++]}while(--_);0===s.length&&(s.mode=vi);break;case 16205:if(0===l)break e;n[r++]=s.length,l--,s.mode=vi;break;case Si:if(s.wrap){for(;c<32;){if(0===a)break e;a--,d|=i[o++]<{if(yi(e))return ai;let t=e.state;return t.window&&(t.window=null),e.state=null,ni},inflateGetHeader:(e,t)=>{if(yi(e))return ai;const s=e.state;return 2&s.wrap?(s.head=t,t.done=!1,ni):ai},inflateSetDictionary:(e,t)=>{const s=t.length;let i,n,o;return yi(e)?ai:(i=e.state,0!==i.wrap&&i.mode!==_i?ai:i.mode===_i&&(n=1,n=wt(n,t,s,0),n!==i.check)?li:(o=Di(e,t,s,s),o?(i.mode=16210,di):(i.havedict=1,ni)))},inflateInfo:"pako inflate (from Nodeca project)"};var Li=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 Ui=Object.prototype.toString,{Z_NO_FLUSH:Pi,Z_FINISH:Mi,Z_OK:qi,Z_STREAM_END:Fi,Z_NEED_DICT:Hi,Z_STREAM_ERROR:Vi,Z_DATA_ERROR:zi,Z_MEM_ERROR:Gi}=Rt;function Ki(e){this.options=xs.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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Os,this.strm.avail_out=0;let s=Oi.inflateInit2(this.strm,t.windowBits);if(s!==qi)throw new Error(xt[s]);if(this.header=new Li,Oi.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Ds.string2buf(t.dictionary):"[object ArrayBuffer]"===Ui.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=Oi.inflateSetDictionary(this.strm,t.dictionary),s!==qi)))throw new Error(xt[s])}function Bi(e,t){const s=new Ki(t);if(s.push(e),s.err)throw s.msg||xt[s.err];return s.result}Ki.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?Mi:Pi,"[object ArrayBuffer]"===Ui.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=Oi.inflate(s,r),o===Hi&&n&&(o=Oi.inflateSetDictionary(s,n),o===qi?o=Oi.inflate(s,r):o===zi&&(o=Hi));s.avail_in>0&&o===Fi&&s.state.wrap>0&&0!==e[s.next_in];)Oi.inflateReset(s),o=Oi.inflate(s,r);switch(o){case Vi:case zi:case Hi:case Gi:return this.onEnd(o),this.ended=!0,!1}if(a=s.avail_out,s.next_out&&(0===s.avail_out||o===Fi))if("string"===this.options.to){let e=Ds.utf8border(s.output,s.next_out),t=s.next_out-e,n=Ds.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!==qi||0!==a){if(o===Fi)return o=Oi.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},Ki.prototype.onData=function(e){this.chunks.push(e)},Ki.prototype.onEnd=function(e){e===qi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=xs.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qi={Inflate:Ki,inflate:Bi,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Bi(e,t)},ungzip:Bi,constants:Rt};const{Deflate:ji,deflate:$i,deflateRaw:Wi,gzip:Zi}=Qs,{Inflate:Yi,inflate:Xi,inflateRaw:Ji,ungzip:en}=Qi;var tn={Deflate:ji,deflate:$i,deflateRaw:Wi,gzip:Zi,Inflate:Yi,inflate:Xi,inflateRaw:Ji,ungzip:en,constants:Rt};const sn=t=>e(void 0,void 0,void 0,(function*(){const e=tn.ungzip(t);return String.fromCharCode.apply(null,e)}));var nn,on;exports.ConnectionState=void 0,(nn=exports.ConnectionState||(exports.ConnectionState={})).CONNECTING="CONNECTING",nn.OPEN="OPEN",nn.CLOSED="CLOSED";class rn extends I{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}get ws(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}_handleMessage(e){e.split("\n").forEach((e=>{if(e){const t=Ce.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 me(t.payload);e.expiresIn>=0&&this._dispatcher.dispatch(e)}}else"NOOP"===t.code||this.dispatch("message",t)}}))}connect(t,s=""){return e(this,void 0,void 0,(function*(){this._ws=new WebSocket(t,encodeURIComponent(s)),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*(){try{const e=yield sn(s.result);this._handleMessage(e)}catch(e){this.error(e)}}))}else if(t.data instanceof ArrayBuffer)try{const e=yield sn(new Uint8Array(t.data));this._handleMessage(e)}catch(e){this.error(e)}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._ws.onopen=Ve,this._ws.onmessage=Ve,this._ws.onerror=Ve,this.connectionState!==exports.ConnectionState.CLOSED?(this._ws.onclose=()=>{this.dispatch("close"),e()},this._ws.close(),this._ws=void 0):e()):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 an extends R{constructor({all:e,feed:t,custom_types:s,ts:i}){super(),this.all=e,this.feed=t,this.customTypes=s,this.ts=i}}class ln{constructor(e,{session: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 He(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this.websocketClient=new rn(e,{sdkState:s,dispatcher:i,logger:n}),this.websocketClient.on("message",(e=>{if(e.payload.unread_cnt&&this._dispatcher.dispatch(new an(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 Me;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",t.requestId,i),e.reject(i)):(this._logger.debug("receive websocket ack",t.requestId,t),this._logger.debug("receive websocket ack",n),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 fe)return yield this._sendApiRequest(t);if(t instanceof Te)return yield this._sendWebsocketRequest(t);throw o.invalidParameters}))}cancel(e){this.apiClient.cancel(e)}cancelAll(){this.apiClient.cancelAll()}}exports.ConnectionStateType=void 0,(on=exports.ConnectionStateType||(exports.ConnectionStateType={}))[on.NONE=0]="NONE",on[on.INITIALIZED=1]="INITIALIZED",on[on.CONNECTING=2]="CONNECTING",on[on.CONNECTED=3]="CONNECTED",on[on.RECONNECTING=4]="RECONNECTING",on[on.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",on[on.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",on[on.LOGOUT=7]="LOGOUT";class dn extends R{constructor({stateType:e}){super(),this.stateType=e}}class cn extends R{}class hn extends R{}class un extends R{}class _n{constructor(e){var t,s,i,n;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(s=e.feed_channels)&&void 0!==s?s:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(n=e.settings_updated_at)&&void 0!==n?n:0}static payloadify(e){return k(D({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}class pn{constructor(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}static payloadify(e){return k(D({last_updated_at:e.lastUpdatedAt}))}}class En{constructor(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}static payloadify(e){return k(D({template_list_token:e.token}))}}class gn{constructor(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}){this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}static payloadify(e){return k(D({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}class fn{constructor(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}){this.default=new gn(e.default),this.realTime=new gn(e.realtime)}static payloadify(e){return k(D({default:gn.payloadify(e.default),realtime:gn.payloadify(e.realTime)}))}}const vn=1048576;var Sn,mn;exports.UnreadCountThreadingPolicy=void 0,(Sn=exports.UnreadCountThreadingPolicy||(exports.UnreadCountThreadingPolicy={}))[Sn.NONE=0]="NONE",Sn[Sn.INCLUDE_REPLY=1]="INCLUDE_REPLY",Sn[Sn.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Sn[Sn.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",exports.LastMessageThreadingPolicy=void 0,(mn=exports.LastMessageThreadingPolicy||(exports.LastMessageThreadingPolicy={}))[mn.NONE=0]="NONE",mn[mn.INCLUDE_REPLY=1]="INCLUDE_REPLY",mn[mn.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",mn[mn.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";class Cn{constructor(e={}){var t,s,i,n,o,r,a;this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*vn: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.unreadCountThreadingPolicy=null!==(o=e.unread_cnt_threading_policy)&&void 0!==o?o:exports.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(r=e.last_msg_threading_policy)&&void 0!==r?r:exports.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new pn(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new _n(e.notifications):null,this.messageTemplateInfo=e.message_template?new En(e.message_template):null,this.statConfigInfo=e.log_publish_config?new fn(e.log_publish_config):new fn}static payloadify(e){return k(D({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/vn,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?pn.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?_n.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?En.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?fn.payloadify(e.statConfigInfo):null}))}}class Tn{constructor(e){this._iid="",this._iid=e}static payloadify(e){return{}}}class yn extends fe{constructor({userId:e,metadata:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${j}/${e}/metadata`,this.params={metadata:t}}}class An extends ve{constructor(e,t){super(e,t),this.metaData=t}}class Nn extends fe{constructor({userId:e,metadata:t,upsert:s}){super(),this.method=exports.APIRequestMethod.PUT,this.path=`${j}/${e}/metadata`,this.params={metadata:t,upsert:s}}}class wn extends ve{constructor(e,t){super(e,t),this.metadata=t}}class bn extends fe{constructor({userId:e,metadataKey:t}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${j}/${e}/metadata/${t}`}}class In extends fe{constructor({userId:e}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${j}/${e}/metadata`}}const xn=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return s._iid&&delete s._iid,t&&t(s),s},Rn=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return t&&t(s),s},kn=e=>({do:t=>{e||t()},throw:t=>{if(!e)throw t}});var Dn;exports.UserOnlineState=void 0,(Dn=exports.UserOnlineState||(exports.UserOnlineState={})).ONLINE="online",Dn.OFFLINE="offline",Dn.NON_AVAILABLE="nonavailable";class On extends Tn{constructor(e,t){var s,i,n,o,r,a,c,h,u,_,p,E;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!==(E=t.friend_name)&&void 0!==E?E:null}static payloadify(e){return k(D(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}=Io.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainProfileUrl}?auth=${e.ekey}`:this.plainProfileUrl}serialize(){return xn(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*(){kn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Io.of(this._iid),i=new yn({userId:e.userId,metadata:t}),n=yield s.send(i),{metaData:r}=n.as(An);return this._applyMetaData(r),this.metaData}))}updateMetaData(t,s=!1){return e(this,void 0,void 0,(function*(){kn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:i}=Io.of(this._iid),n=new Nn({userId:e.userId,metadata:t,upsert:s}),r=yield i.send(n),{metadata:a}=r.as(wn);return this._applyMetaData(a),this.metaData}))}deleteMetaData(t){return e(this,void 0,void 0,(function*(){kn(l("string",t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Io.of(this._iid),i=new bn({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}=Io.of(this._iid),s=new In({userId:e.userId});yield t.send(s),this.metaData={}}))}}class Ln extends R{constructor({userProfile:e}){super(),this.userProfile=e}}class Un{constructor(e,t){var s,i,n,o,r,a,l,d,c,h,u,_,p,E;this._iid=e,this.appInfo=new Cn(t),this.user=new On(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!==(E=t.back_off_delay)&&void 0!==E?E:100}static payloadify(e){return k(D(Object.assign(Object.assign(Object.assign({},On.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=Io.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 Ln({userProfile:this}))}}class Pn extends R{constructor({request:e=!0,features:t={},options:s={},statConfigInfo:i}){super(),this.request=e,this.features=Object.assign({localCache:!0,notification:!0},t),this.options=Object.assign({ingestion:!0},s),this.statConfigInfo=i}}class Mn extends Ce{constructor(e,t,s){var i,n,r,a;super(e,t,s),this.error=null,this.services=[],this.userProfile=new Un(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,this.services=null!==(a=s.services)&&void 0!==a?a:[]}static asError(e){return new Mn("","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=Io.of(t);if(!e)throw o.lostInstance;{const{sessionManager:t,dispatcher:s}=e;yield t.login(this),this.userProfile.apply(),s.dispatch(new Pn({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo}))}}}))}}class qn{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,cause:n=null}){return e(this,void 0,void 0,(function*(){}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){}))}}const Fn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){if(!(e instanceof o))throw e;e.throwOutside()}})),Hn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){}}));class Vn extends qn{constructor(e={}){var t;super(),this.type=exports.ConnectionStateType.LOGOUT,this.name="logout",this._wasPreviouslyConnected=null===(t=e.wasPreviouslyConnected)||void 0===t||t}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 Jn,s),this._wasPreviouslyConnected&&Fn((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onDisconnected&&e.onDisconnected(i)}))}))))}))}}class zn extends qn{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 Yn({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new jn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn,e)}))}}class Gn extends qn{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 jn,e))}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new Yn({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new jn,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new zn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn,e)}))}}const Kn=t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}));class Bn{calcTimeout(){return 0}}const Qn=(t,s,i=new Bn)=>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||et(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=new Me;this._callbacks.push((e=>e?i.reject(e):i.resolve())),Fn((()=>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 Qn(((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){if(e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);if(e.isSessionExpiredError||e.isSessionInvalidatedError)return void s(e)}throw e}}))),i,n),yield t.changeState(new $n,s),this._flushCallbacks(),Fn((()=>e(this,void 0,void 0,(function*(){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 Gn({autoReconnect:!1}),s)),this._flushCallbacks(i),Fn((()=>e(this,void 0,void 0,(function*(){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 Me;return this._halt(o.connectionCanceled),t.cancelConnectForRetry(),this._callbacks.push((()=>{const i=Date.now();t.changeState(new Yn({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 Me;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 Gn({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 zn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Vn,e)}))}}class $n extends qn{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 jn,e)}))}onDisconnect(t,{autoReconnect:s}){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Gn({autoReconnect:s}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new zn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn,e)}))}}var Wn;!function(e){e.ExternalSetBackground="ExternalSetBackground",e.ExternalDisconnectWebSocket="ExternalDisconnectWebSocket"}(Wn||(Wn={}));class Zn{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:o,dispatcher:r,logger:a,disableWebSocketCloseEventHandling:l=!1}){this._disableWebSocketCloseEventHandling=!1,this._webSocketClosedCause=null,this._logger=a,this._disableWebSocketCloseEventHandling=l,this._context=new io(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",(()=>{this.isConnecting||this.isConnected||(this._logger.debug("try reconnect by session key refresh"),Hn((()=>e(this,void 0,void 0,(function*(){yield this.reconnect()})))))})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(()=>{"foreground"!==this._sdkState.appState||this._webSocketClosedCause||Hn((()=>e(this,void 0,void 0,(function*(){this._sessionManager.isSessionKeyRefreshing?yield this.disconnectWebSocket():(this._logger.debug("try reconnect by websocket connection closed"),yield 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}get websocketClient(){return this._websocketClient}connect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onConnect(this._context,t),this._registerEventDispatcher()}))}reconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{})}))}resetAndReconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{resetReconnectCount:!0})}))}background(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=Wn.ExternalSetBackground,yield e.onDisconnect(this._context,{autoReconnect:!1,cause:this._webSocketClosedCause})}))}disconnect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;yield e.onDisconnect(this._context,{error:t,autoReconnect:!0,cause:this._webSocketClosedCause})}))}disconnectWebSocket(t=!1){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;t&&(this._webSocketClosedCause=Wn.ExternalDisconnectWebSocket),yield e.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause})}))}logout(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._clearEventDispatcher(),yield e.onLogout(this._context,t)}))}}class Yn extends qn{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 Me;this._callbacks.push((e=>e?i.reject(e):i.resolve()));try{yield Qn((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 $n,s),Fn((()=>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 Jn,s)),Fn((()=>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 Me;return this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:i=!1,cause:n=null}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:Xn(n)),t.hasSession?yield t.changeState(new Gn({autoReconnect:i}),e):yield t.changeState(new Vn,e)}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){this._halt(Xn((null==s?void 0:s.cause)||null));const e=Date.now();t.hasSession?yield t.changeState(new zn,e):yield t.changeState(new Vn,e)}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:o.connectionCanceled),yield t.changeState(new Vn,e)}))}}function Xn(e){const t=o.connectionCanceled;if(e){let s=null;switch(e){case Wn.ExternalSetBackground:s="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case Wn.ExternalDisconnectWebSocket:s="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}s&&t.setDetail(s)}return t}class Jn extends qn{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 Yn({authToken:s}),e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn({wasPreviouslyConnected:!1}),e)}))}}class eo extends Te{constructor(){super({code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}}class to{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 eo;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)}}const so=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"];class io extends I{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:r,dispatcher:a,logger:l,entryState:d=new Jn}){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 to({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(Mn))})).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 Mn&&(this._unresolvedLogi=e,this._tryResolveConnectionRequest())}))}get currentState(){return this._currentState}get hasSession(){return this._sessionManager.session.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 dn({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;this._websocketClient.isOpen&&e&&(this._unresolvedLogi=void 0,e.error?(this._sessionManager.session.authToken=void 0,e.error.isSessionExpiredError||e.error.isSessionInvalidatedError?this._dispatcher.dispatch(new me({reason:e.error.code,message:e.error.message})):this._logger.warn(`login failed: ${e.error}`),this._rejectConnectionRequest(e.error)):(yield e.applyTo(this._iid),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(){var e;const{appId:t,appVersion:s,userId:n,extensions:o,sendbirdRuntimeEnvironment:r}=this.sdkState,{localCacheEnabled:a}=this.cacheContext,{session:l}=this._sessionManager,d=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,c=!!(null!=o?o:{}).sb_uikit,h=Pe.userAgentWithExtension(o);return`${this.sdkState.websocket.host}/?p=JS&pv=${encodeURIComponent(i.OS_VERSION)}&sv=${encodeURIComponent(i.SDK_VERSION)}&ai=${t}${s?`&av=${s}`:""}${l.hasSession?"":`&user_id=${encodeURIComponent(n)}`}&pmce=${d?1:0}&active=1&device_token_types=${encodeURIComponent(["gcm","huawei","apns"].join(","))}&SB-User-Agent=${h}&SB-SDK-User-Agent=${encodeURIComponent(Pe.sendbirdSdkUserAgentWithExtension(r))}&Request-Sent-Timestamp=${Date.now().toString()}&include_extra_data=${encodeURIComponent(String(so))}${this._sessionManager.handler?"&expiring_session=1":""}&use_local_cache=${a?1:0}&include_poll_details=1${c?"&uikit_config=1":""}`}_statLogConnection(e){var t;this._dispatcher.dispatch(new be(new Re({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=new Me;if(this._connectionRequestQueue.push(e),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);const{session:e}=this._sessionManager;t&&(e.authToken=t,e.sessionKey=void 0);const i=this._url();e.sessionKey||e.authToken?this._websocketClient.connect(i,JSON.stringify(e.hasSession?{auth:e.sessionKey}:{token:e.authToken})):this._websocketClient.connect(i,JSON.stringify({}))}return e.promise}))}cancelConnectForRetry(){this._dispatcher.dispatch(Mn.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.disconnect(),yield this._sessionManager.clear()}))}clearLoginTimer(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}class no extends fe{constructor({appId:e,userId:t,includeUIKitConfig:s=!1,localCacheEnabled:i=!0,expiringSession:n=!0}){super(),this.path=`${$}/${t}/authentication`,this.method=exports.APIRequestMethod.POST,this.params=k({expiring_session:!!n,include_logi:!0,include_extra_data:String(so),uikit_config:s,use_local_cache:i,app_id:e}),this.requireAuth=!1}}class oo extends ve{constructor(e,t){super(e,t),this.logi=new Mn(e,"LOGI",t)}}var ro;!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(ro||(ro={}));const ao=[ye,no];class lo{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r=!1}){this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new ln(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this._session=t,this._logger=n,this._dispatcher=i,this._dispatcher.on((e=>{var t;if(e instanceof dn){const{stateType:s}=e;switch(this._currentConnectionStateType=s,s){case exports.ConnectionStateType.CONNECTED:this._resolveLazyCallQueue();break;case exports.ConnectionStateType.INITIALIZED:case exports.ConnectionStateType.INTERNAL_DISCONNECTED:case exports.ConnectionStateType.EXTERNAL_DISCONNECTED:case exports.ConnectionStateType.LOGOUT:this._rejectLazyCallQueue((null===(t=this._session)||void 0===t?void 0:t.hasSession)?o.connectionClosed:o.connectionRequired)}}else if(e instanceof cn)this._session.hasChatServicePermission||this._resolveLazyCallQueue(ro.API);else if(e instanceof hn||e instanceof un)this._rejectLazyCallQueue(o.connectionClosed);else if(e instanceof Ie){const{request:t,deferred:s,error:i}=e;for(const e of ao)if(t instanceof e)return void s.reject(i);this._lazyCallQueue.push({command:t,deferred:s})}}))}get isReady(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED}get isLazyCallActivated(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING||this._currentConnectionStateType===exports.ConnectionStateType.RECONNECTING||this._session.isRefreshing}_classifyLazyCallQueueByScope(e){const t=[],s=[];let i;switch(e){case ro.ALL:i=null;break;case ro.WEBSOCKET:i=Te;break;case ro.API:i=fe}let n=!1;return this._lazyCallQueue.forEach((e=>{!i||e.command instanceof i||(n=!0),n?s.push(e):t.push(e)})),[t,s]}_resolveLazyCallQueue(t=ro.ALL){const[s,i]=this._classifyLazyCallQueueByScope(t);this._lazyCallQueue=i,s.forEach((t=>e(this,void 0,void 0,(function*(){const{command:e,deferred:s,timeout:i}=t;i&&clearTimeout(i);try{const t=yield this.send(e);s.resolve(t)}catch(e){s.reject(e)}}))))}_rejectLazyCallQueue(t,s=ro.ALL){const[i,n]=this._classifyLazyCallQueueByScope(s);this._lazyCallQueue=n,i.forEach((s=>e(this,void 0,void 0,(function*(){const{deferred:e,timeout:i}=s;clearTimeout(i),e.reject(t)}))))}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof Te){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 Me;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 fe){if(this._session.hasSession)return this._logger.debug("send api request",t),yield this.commandRouter.send(t);if(t.hasSessionKey)return this._logger.debug("send api request with tmp session key",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait api request",t);const e=new Me;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*(){if(this._logger.debug("send forced request",t),t instanceof Te||t instanceof fe)return yield this.commandRouter.send(t);throw o.invalidCommand}))}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 co="sendbird@devicetokens";class ho{constructor({type:e,token:t,device_os:s,device_manufacturer:i,system_push_enabled:n}){this.type=e,this.token=t,this.deviceOS=s,this.deviceManufacturer=i,this.systemPushEnabled=n}static payloadify(e){return k(D({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}const uo=new WeakMap;class _o extends I{constructor({_iid:e,session:t,cacheContext:s,sdkState:i,dispatcher:o,requestQueue:r,logger:a,pushNotificationAckManager:l}){super(),this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._isRefreshingAuthToken=!1,this.currentUser=null,this.session=t,this._iid=e,this._cacheContext=s,this._sdkState=i,this._dispatcher=o,this._requestQueue=r,this._logger=a,this._pushNotificationAckManager=l,this._deviceTokens=[],this._dispatcher.on((e=>{var t,s,i;if(e instanceof dn){const{stateType:t}=e;this._currentConnectionStateType=t}else if(e instanceof me&&this.handler&&!this.isSessionKeyRefreshing){if(this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?this.close():((null===(s=e.error)||void 0===s?void 0:s.isSessionTokenExpiredError)&&this.refreshAuthToken().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(this._logger.debug("session expired"),this.handler.onSessionExpired&&this.handler.onSessionExpired(),this.refreshSessionKey().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e}))))}}))}get ekey(){return uo.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 Ae({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(we);if(n)throw n;this.session.sessionKey=null!=i?i:this.session.sessionKey}))}_refreshSessionKeyByApi(t){return e(this,void 0,void 0,(function*(){const s=new ye({userId:this._sdkState.userId,authToken:t,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0});yield Qn((t=>e(this,void 0,void 0,(function*(){try{const e=yield this._requestQueue.forceSend(s),{key:t,services:i}=e.as(Ne);this.session.sessionKey=t,this.session.services=i}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){try{return void(yield this._handleSessionRefreshError(e,s))}catch(e){}}try{yield this._refreshSessionKeyByApi(t),this.complete()}catch(e){yield this._handleSessionRefreshError(e,s)}}))}_receiveNewAuthToken(){var t;const s=new Me;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired){let t=null;const i=()=>{t&&(clearTimeout(t),t=null)},n=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.resolve(e))},o=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.reject(e))};t=setTimeout((()=>o()),1e3*this._sdkState.sessionTokenRefreshTimeout),Fn((()=>e(this,void 0,void 0,(function*(){var e;(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(n,o)}))))}else s.resolve(null);return s.promise}_handleSessionRefreshError(t,s=!1){return e(this,void 0,void 0,(function*(){if(!(t instanceof o&&(t.isSessionTokenExpiredError||t.code===exports.SendbirdErrorCode.APPLICATION_NOT_FOUND)&&(this.session.authToken=void 0,s)))throw t;{const e=yield this._receiveNewAuthToken();e?(this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken,!1)):yield this.clear()}}))}_isSessionRelatedError(e){return e instanceof o&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}get isSessionKeyRefreshing(){return this.session.isRefreshing}get isRefreshingAuthToken(){return this._isRefreshingAuthToken}get isSessionExpiring(){return!!this.handler}authenticate(t,s){var i;return e(this,void 0,void 0,(function*(){this.session.authToken=s;const e=new no({appId:this._sdkState.appId,userId:t,includeUIKitConfig:!!(null!==(i=this._sdkState.extensions)&&void 0!==i?i:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!s||this.isSessionExpiring}),n=yield this._requestQueue.commandRouter.send(e),{logi:o}=n.as(oo);if(o.error)throw o.error;this.session.hasChatServicePermission||(yield o.applyTo(this._iid))}))}login(t){var s;return e(this,void 0,void 0,(function*(){const{key:e,ekey:i,services:n,userProfile:o,deviceTokenLastDeletedAt:r=0}=t;this.session.sessionKey=e,this.session.services=n,uo.set(this,i),this._deviceTokenCacheEnabled=null===(s=null==o?void 0:o.appInfo)||void 0===s?void 0:s.deviceTokenCache;const{preference:a}=this._cacheContext;if(this._deviceTokenCacheEnabled){const e=yield a.get(co);!e||e.lastDeletedAtnew ho(ho.payloadify(e)))),this._deviceTokenLastDeletedAt=e.lastDeletedAt)}else yield a.remove(co)}))}complete(){this.dispatch("refresh"),this._dispatcher.dispatch(new cn),Fn((()=>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){Fn((()=>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"),this._dispatcher.dispatch(new un),Fn((()=>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()}))))}refreshAuthToken(){return e(this,void 0,void 0,(function*(){let e=null;if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{e=yield this._receiveNewAuthToken(),e?(this._logger.debug("session refreshing.."),this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken)):yield this.clear()}catch(t){const s=e?o.sessionTokenRefreshFailed:o.sessionTokenRequestFailed;throw this._dispatcher.dispatch(new hn),this.error(s),this._logger.debug("refresh auth token error = ",s),s}finally{this.session.isRefreshing=!1}}}))}refreshSessionKey(){return e(this,void 0,void 0,(function*(){if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{yield this._refreshSessionKey(this.session.authToken)}catch(e){const t=o.sessionTokenRefreshFailed;throw this._dispatcher.dispatch(new hn),this.error(t),t}finally{this.session.isRefreshing=!1}}}))}setDeviceToken(e,t,s){if(this._deviceTokenCacheEnabled){if(this.indexOfDeviceToken(e,t)<0){const i=new ho({type:e,token:t,device_os:null==s?void 0:s.deviceOS,device_manufacturer:null==s?void 0:s.deviceManufacturer,system_push_enabled:null==s?void 0:s.systemPushEnabled});return this._deviceTokens.push(i),!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(co,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})}}))}clear(){return e(this,void 0,void 0,(function*(){this.currentUser=null,this.session.clear(),this.close(),uo.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,yield this.saveDeviceToken(),this._pushNotificationAckManager.clear()}))}}const po=(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]=po(e[s],t[s]):o[s]=t[s]}return o}return t};var Eo,go;!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Eo||(Eo={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(go||(go={}));class fo extends fe{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${ae}`,this.params={device_id:e,log_entries:t.map((e=>Re.payloadify(e)))}}}class vo{constructor({deviceId:e,cacheContext:t,requestQueue:s}){this.queue=[],this.flushWaitQueue=[],this.enabledState=Eo.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=e,this.cacheContext=t,this.requestQueue=s,this.logInfo={deviceId:e,statLogs:[],generation:1,lastFlushedAt:0},this.limit=100}get isEnabled(){return this.enabledState===Eo.ENABLED}init(t){return e(this,void 0,void 0,(function*(){this.key=t;const e=yield this.cacheContext.preference.get(this.key);e&&(this.logInfo=e)}))}_mergeQueue(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}_isDuplicateStat(e){const t=this._sentLogStats.find((t=>{var s;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(s=e.data.notificationId)&&void 0!==s?s:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}_flush(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t.length>0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new fo({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=Eo.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Eo.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}_save(){return e(this,void 0,void 0,(function*(){const e=[...this.queue,...this.flushWaitQueue];yield this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((e=>Re.payloadify(e))),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})}))}clear(){return e(this,void 0,void 0,(function*(){this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save()}))}}class So extends Re{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 mo extends vo{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".daily"),this.queue=this.logInfo.statLogs.map((e=>new Re({type:e.stat_type,ts:e.ts,data:e.data})))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this.statConfig.minInterval=864e5,this._mergeQueue(),s.localCacheStat?this.enabledState=s.enabledStat?Eo.ENABLED:Eo.COLLECT_ONLY:(this.enabledState=Eo.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=yield this._getUploadStats(),t=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);for(let s=0;se instanceof So&&e.key===t.key));if(s?s.data=po(s.data,t.data):e.push(t),this.enabledState!==Eo.PENDING&&(yield this._save()),this.isEnabled&&(this._mergeQueue(),this._isSendable)){const e=yield this._getUploadStats();return yield this._flush(e)}return!0}))}_getUploadStats(){return e(this,void 0,void 0,(function*(){return this.queue.filter((e=>{if(e instanceof So){const t=new Date,[s,i]=[e.date.getFullYear(),t.getFullYear()];if(se.type!==exports.StatType.FEATURE_LOCALCACHE_EVENT)):t.filter((e=>e.type===exports.StatType.FEATURE_LOCALCACHE_EVENT))}))}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".default"),this.queue=this.logInfo.statLogs.map((e=>(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data),new Re({type:e.stat_type,ts:e.ts,data:e.data}))))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.requestStat||s.localCacheStat){let e;this.enabledState=s.enabledStat?Eo.ENABLED:Eo.COLLECT_ONLY,s.requestStat||(e=!1),s.localCacheStat||(e=!0),void 0!==e&&(this.queue=yield this._filterQueueByType(this.queue,e),this.flushWaitQueue=yield this._filterQueueByType(this.flushWaitQueue,e),this._save())}else this.enabledState=Eo.DISABLED,yield this.clear();if(this.isEnabled&&this._isSendable(!0)){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield Kn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===Eo.DISABLED)return!0;const e=this.enabledState===Eo.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return e.push(t),this.enabledState!==Eo.PENDING&&(yield this._save()),!this.isEnabled||(this._mergeQueue(),!this._isSendable())||(yield this._flush(e))}))}}class To extends vo{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".realtime"),this.queue=this.logInfo.statLogs.map((e=>{var t;return e.data=k(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Re({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((e=>{var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.notificationStat?this.enabledState=s.enabledStat?Eo.ENABLED:Eo.COLLECT_ONLY:(this.enabledState=Eo.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield Kn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===Eo.DISABLED)return!0;const e=this.enabledState===Eo.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return!!this._isDuplicateStat(t)||(e.push(t),this.enabledState!==Eo.PENDING&&(yield this._save()),!(this.isEnabled&&(this._mergeQueue(),this.isEnabled&&this._isSendable))||(yield this._flush(e)))}))}}class yo{constructor({cacheContext:e,requestQueue:t,dispatcher:s,logger:i}){this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=w(),this.cacheContext=e,this.requestQueue=t,this.dispatcher=s,this.logger=i,this._dailyStatCollector=new mo({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Co({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._realTimeStatCollector=new To({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}_migration(){return e(this,void 0,void 0,(function*(){const e=yield this.cacheContext.preference.get(this.key);if(e){const t=[];e.statLogs.forEach((e=>{e.stat_type===exports.StatType.FEATURE_LOCALCACHE&&t.push(new Re({type:e.stat_type,ts:e.ts,data:e.data}))})),yield this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((e=>Re.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const s=[];e.statLogs.forEach((e=>{e.stat_type!==exports.StatType.FEATURE_LOCALCACHE&&e.stat_type!==exports.StatType.NOTIFICATION&&(e.stat_type===exports.StatType.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),s.push(new Re({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:s.map((e=>Re.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const i=[];e.statLogs.forEach((e=>{var t;e.stat_type===exports.StatType.NOTIFICATION&&(e.data=k(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),i.push(new Re({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:i.map((e=>Re.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt}),yield this.cacheContext.preference.remove(this.key)}}))}init(t){return e(this,void 0,void 0,(function*(){this.key=t,yield this._migration(),yield this._dailyStatCollector.init(this.key),yield this._defaultStatCollector.init(this.key),yield this._realTimeStatCollector.init(this.key),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((t=>e(this,void 0,void 0,(function*(){var e;if(t instanceof be){const{statLog:e}=t;this.put(e)}else if(t instanceof Pn){const{request:s,features:i,options:n,statConfigInfo:o}=t;this._retryCount=0,this._collectRequestStat=s,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._realTimeStatCollector.setConfig(null!==(e=this._statConfig.realTime)&&void 0!==e?e:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:n.ingestion})}})))))}))}put(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t instanceof So)this._collectFeatureLocalCacheStat&&(e=yield this._dailyStatCollector.put(t));else switch(t.type){case exports.StatType.API_RESULT:case exports.StatType.WEBSOCKET_CONNECT:this._collectRequestStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.FEATURE_LOCALCACHE:case exports.StatType.FEATURE_LOCALCACHE_EVENT:this._collectFeatureLocalCacheStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.NOTIFICATION:this._collectionNotificationStat&&(e=yield this._realTimeStatCollector.put(t))}e?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Eo.COLLECT_ONLY,this._defaultStatCollector.enabledState=Eo.COLLECT_ONLY,this._realTimeStatCollector.enabledState=Eo.COLLECT_ONLY,this.logger.debug(o.statLogUploadLimitExceededError)))}))}close(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}class Ao{constructor({limit:e=5}){this.workersByKey={},this.limit=e}run(t,s){return e(this,void 0,void 0,(function*(){if(this.workersByKey[t]||(this.workersByKey[t]=[]),this.workersByKey[t].length{switch(e){case"open":return exports.PollStatus.OPEN;case"closed":return exports.PollStatus.CLOSED;default:return null}},Lo=e=>!e||!!e.text&&l("string",e.text);class Uo extends Tn{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 k(D(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})))}}class Po extends Tn{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=Oo(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 Uo(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=Oo(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 Uo(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 k(D(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=>Uo.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 xn(this)}}class Mo{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}}class qo extends Mo{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)}}class Fo extends fe{constructor({title:e,optionTexts:t,data:s,allowUserSuggestion:i,allowMultipleVotes:n,closeAt:o}){super(),this.method=exports.APIRequestMethod.POST,this.path=ne,this.params={title:e,options:t,data:s,allow_user_suggestion:i,allow_multiple_votes:n,close_at:o}}}class Ho extends ve{constructor(e,t){super(e,t),this.poll=new Po(e,t)}}class Vo extends fe{constructor({channelUrl:e,channelType:t,pollId:s}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}`,this.params={channel_url:e,channel_type:t}}}class zo extends ve{constructor(e,t){super(e,t),this.poll=new Po(e,t)}}class Go extends fe{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}`,this.params={channel_url:e,channel_type:t}}}class Ko extends ve{constructor(e,t){super(e,t),this.pollOption=new Uo(e,t)}}class Bo extends fe{constructor({channelType:e,channelUrl:t,timestamp:s,token:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${_e(e)}/${encodeURIComponent(t)}/polls/changelogs`,this.params=k({change_ts:s,token:i})}}class Qo extends ve{constructor(e,t){super(e,t),this.updatedPolls=t.updated.map((t=>((e,t)=>new Po(e,t))(e,t))),this.deletedPollIds=t.deleted.map((e=>e)),this.hasMore=t.has_more,this.nextToken=t.next}}const jo={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},$o=e=>{return l("string",e.title)&&(t=e.optionTexts,h("string",t)&&t.every((e=>""!==e.trim())))&&Lo(e.data)&&l("boolean",e.allowUserSuggestion,!0)&&l("boolean",e.allowMultipleVotes,!0)&&l("number",e.closeAt,!0);var t},Wo={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0,pollOptionId:0},Zo=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId)&&e.pollId>0&&l("number",e.pollOptionId)&&e.pollOptionId>0,Yo={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0},Xo=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId),Jo={};class er extends fe{constructor({channelUrl:e,channelType:t,token:s,limit:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=ne,this.params={channel_url:e,channel_type:t,token:s,limit:i}}}class tr extends ve{constructor(e,t){var s;super(e,t),this.polls=(null!==(s=t.polls)&&void 0!==s?s:[]).map((t=>new Po(e,t))),this.token=t.next}}class sr extends fe{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i,token:n,limit:o}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}/voters`,this.params={channel_url:e,channel_type:t,token:n,limit:o}}}class ir extends ve{constructor(e,t){var s;super(e,t),this.voters=(null!==(s=t.voters)&&void 0!==s?s:[]).map((t=>new On(e,t))),this.token=t.next}}exports.APIRequestCommand=fe,exports.APIResponseCommand=ve,exports.API_PATH_EMOJIS=se,exports.API_PATH_EMOJI_CATEGORIES=ie,exports.API_PATH_FORMS=ue,exports.API_PATH_GROUP_CHANNELS=Z,exports.API_PATH_GROUP_CHANNELS_INTERNAL=Y,exports.API_PATH_MESSAGE_TEMPLATE=ce,exports.API_PATH_NOTIFICATIONS=le,exports.API_PATH_NOTIFICATIONS_USERS=de,exports.API_PATH_OPEN_CHANNELS=X,exports.API_PATH_OPEN_CHANNELS_INTERNAL=J,exports.API_PATH_POLLS=ne,exports.API_PATH_PUSH_DELIVERY=he,exports.API_PATH_REPORT=te,exports.API_PATH_SCHEDULED_MESSAGES=oe,exports.API_PATH_SEARCH=ee,exports.API_PATH_UIKIT_CONFIGURATION=re,exports.API_PATH_UPLOAD=W,exports.API_PATH_USERS=j,exports.AppInfo=Cn,exports.BaseCommand=R,exports.BaseListQuery=Mo,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.CancelXMLHttpRequestCommand=qe,exports.ChannelDataListQuery=qo,exports.ConnectionStateChangeCommand=dn,exports.DEFAULT_ENCRYPTION=E,exports.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT=5,exports.DailyRecordStatLog=So,exports.Deferred=Me,exports.DeleteMessageEventCommand=class extends Ce{constructor(e,t,s){var i;super(e,"DELM",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.messageId=Number(s.msg_id),this.silent=s.silent,this.messageCreatedAt=s.message_created_at?Number(s.message_created_at):-1,this.senderId=null!==(i=s.sender_id)&&void 0!==i?i:void 0}},exports.DeleteMessageRequestCommand=Fe,exports.EventDispatcher=I,exports.InstancedObject=Tn,exports.LocalCacheConfig=y,exports.MessageEventSource=Ro,exports.MessageRemoveEventCommand=class extends R{constructor({messageIds:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messageIds=e,this.source=t,this.isWebSocketEventComing=s}},exports.MessageUpdateEventCommand=class extends R{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.NotificationInfo=_n,exports.POLL_REMOVED_STATUS="removed",exports.Poll=Po,exports.PollChangeLogEventCommand=ko,exports.PollCreateParamsDefault=jo,exports.PollListQuery=class extends qo{constructor(e,t){super(e,t.channelUrl,t.channelType,t)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Io.of(this._iid),t=new er(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{polls:i,token:n}=s.as(tr);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.PollManager=class{constructor(e,{sdkState:t,dispatcher:s,sessionManager:i,requestQueue:n,logger:o}){this._iid=e,this._sdkState=t,this._sessionManager=i,this._requestQueue=n,this._dispatcher=s,this._logger=o,Jo[e]=this}static of(e){return Jo[e]}buildPollFromSerializedData(e){const t=Rn(e);return new Po(this._iid,Po.payloadify(t))}get(t){return e(this,void 0,void 0,(function*(){kn(Xo(t)).throw(o.invalidParameters);const e=new Vo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(zo);return i}))}create(t){return e(this,void 0,void 0,(function*(){kn($o(t)).throw(o.invalidParameters);const e=new Fo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(Ho);return i}))}getOption(t){return e(this,void 0,void 0,(function*(){kn(Zo(t)).throw(o.invalidParameters);const e=new Go(Object.assign({},t)),s=yield this._requestQueue.send(e),{pollOption:i}=s.as(Ko);return i}))}getPollChangeLogs(t,s,i,n=exports.CollectionEventSource.SYNC_POLL_CHANGELOGS){return e(this,void 0,void 0,(function*(){const e=new Bo(D({channelType:s,channelUrl:t,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null})),o=yield this._requestQueue.send(e),{updatedPolls:r,deletedPollIds:a,hasMore:l,nextToken:d}=o.as(Qo);return r.length>0&&this._dispatcher.dispatch(new ko({polls:r,source:n})),{updatedPolls:r,deletedPollIds:a,hasMore:l,token:d}}))}},exports.PollOption=Uo,exports.PollOptionRetrievalParamsDefault=Wo,exports.PollRetrievalParamsDefault=Yo,exports.PollUpdateInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=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.PollVoteInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoterListQuery=class extends qo{constructor(e,t){super(e,t.channelUrl,t.channelType,t),this.pollId=t.pollId,this.pollOptionId=t.pollOptionId}_validate(){return super._validate()&&l("number",this.pollId)&&l("number",this.pollOptionId)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Io.of(this._iid),t=new sr(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),s=yield e.send(t),{voters:i,token:n}=s.as(ir);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.ReactionUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.RequestResendCommand=Ie,exports.SEMVER_REGEX_STRING="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",exports.SendbirdChatOptions=p,exports.SendbirdError=o,exports.SessionExpiredCommand=me,exports.SessionRefreshAPICommand=ye,exports.StatLog=Re,exports.SubscribedUnreadMessageCountUpdateCommand=an,exports.ThreadUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.UIKitConfigInfo=pn,exports.UnsentMessageRemoveEventCommand=class extends R{constructor({reqId:e,source:t}){super(),this.reqId=e,this.source=t}},exports.User=On,exports.UserProfile=Un,exports.UserProfileUpdateCommand=Ln,exports.Vault=Io,exports.WebSocketEventCommand=Ce,exports.WebSocketRequestCommand=Te,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=pe(null!==(i=e.mentionType)&&void 0!==i?i:null,null!==(n=e.mentionedUserIds)&&void 0!==n?n:[],s),l=pe(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=pe,exports.createChangelogIncludeChatNotificationsCacheKey=e=>`sendbird@${e}/changelog_include_chat_notifications`,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=Rn,exports.deundefined=k,exports.getChannelApiPathByType=_e,exports.getReportApiPathByType=e=>{switch(e){case exports.ChannelType.GROUP:return`${te}/group_channels`;case exports.ChannelType.OPEN:return`${te}/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.isMilliSecondOf=(e,t=!1)=>!(!t||!_(e))||"number"==typeof e&&13===e.toString().length,exports.isReactNative=ke,exports.isResendableError=e=>e>0&&r.indexOf(e)>=0,exports.isThrowingOutside=n,exports.isTypeOf=l,exports.noop=Ve,exports.parsePollStatusPayload=Oo,exports.runAsCallback=Fn,exports.runOrNothing=Hn,exports.serialize=xn,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===exports.CollectionEventSource.SYNC_MESSAGE_FILL||e===exports.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||e===exports.CollectionEventSource.SYNC_POLL_CHANGELOGS,exports.sleep=Kn,exports.undefineNullProps=D,exports.unless=kn,exports.uuid=w,exports.validatePollCreateParams=$o,exports.validatePollData=Lo,exports.validatePollOptionRetrievalParams=Zo,exports.validatePollRetrievalParams=Xo,exports.version=s; diff --git a/cjs/lib/__bundle-e8b53f2f.cjs b/cjs/lib/__bundle-bfe2e997.cjs similarity index 89% rename from cjs/lib/__bundle-e8b53f2f.cjs rename to cjs/lib/__bundle-bfe2e997.cjs index 66571fd..3605e54 100644 --- a/cjs/lib/__bundle-e8b53f2f.cjs +++ b/cjs/lib/__bundle-bfe2e997.cjs @@ -1 +1 @@ -var e=require("./__bundle-ad182031.cjs"),s=require("./__bundle-9d371926.cjs");class t extends e.APIRequestCommand{constructor({channelType:s,channelUrl:t,limit:n,token:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(s)}/${encodeURIComponent(t)}/messages/parent_thread_message`,this.params=e.deundefined(e.undefineNullProps({limit:n,token:i}))}}class n extends e.APIResponseCommand{constructor(e,t){super(e,t),this.token=t.next,this.messages=t.messages.map((t=>s.parseMessagePayload(e,t)))}}class i extends e.ChannelDataListQuery{constructor(e,s,t,n){super(e,s,t,n),this._edge=""}_validate(){return super._validate()}load(){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),i=new t({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),a=yield s.send(i),{messages:r,token:d}=a.as(n);return this._edge=d,this._hasNext=!!d,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}exports.ThreadedParentMessageListQuery=i; +var e=require("./__bundle-1a495950.cjs"),s=require("./__bundle-165fd6e1.cjs");class t extends e.APIRequestCommand{constructor({channelType:s,channelUrl:t,limit:n,token:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(s)}/${encodeURIComponent(t)}/messages/parent_thread_message`,this.params=e.deundefined(e.undefineNullProps({limit:n,token:i}))}}class n extends e.APIResponseCommand{constructor(e,t){super(e,t),this.token=t.next,this.messages=t.messages.map((t=>s.parseMessagePayload(e,t)))}}class i extends e.ChannelDataListQuery{constructor(e,s,t,n){super(e,s,t,n),this._edge=""}_validate(){return super._validate()}load(){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),i=new t({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),a=yield s.send(i),{messages:r,token:d}=a.as(n);return this._edge=d,this._hasNext=!!d,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}exports.ThreadedParentMessageListQuery=i; diff --git a/cjs/lib/__bundle-a5185d74.cjs b/cjs/lib/__bundle-c127c886.cjs similarity index 65% rename from cjs/lib/__bundle-a5185d74.cjs rename to cjs/lib/__bundle-c127c886.cjs index 65fa306..a08ea8f 100644 --- a/cjs/lib/__bundle-a5185d74.cjs +++ b/cjs/lib/__bundle-c127c886.cjs @@ -1 +1 @@ -var s=require("./__bundle-ad182031.cjs");class e extends s.User{constructor(s,e){var t;super(s,e),this.isMuted=!1,this.isMuted=null!==(t=e.is_muted)&&void 0!==t&&t}}exports.Participant=e; +var s=require("./__bundle-1a495950.cjs");class e extends s.User{constructor(s,e){var t;super(s,e),this.isMuted=!1,this.isMuted=null!==(t=e.is_muted)&&void 0!==t&&t}}exports.Participant=e; diff --git a/cjs/lib/__bundle-39ca4e91.cjs b/cjs/lib/__bundle-ca16c7ed.cjs similarity index 68% rename from cjs/lib/__bundle-39ca4e91.cjs rename to cjs/lib/__bundle-ca16c7ed.cjs index 8a4ebb0..93aa9cf 100644 --- a/cjs/lib/__bundle-39ca4e91.cjs +++ b/cjs/lib/__bundle-ca16c7ed.cjs @@ -1 +1 @@ -var e=require("./__bundle-ad182031.cjs");class a extends e.BaseCommand{}exports.NotificationCollectionRefreshCommand=a,exports.getFeedChannelIndexBy=e=>["-lastMessageUpdatedAt","-createdAt","syncIndex"]; +var e=require("./__bundle-1a495950.cjs");class a extends e.BaseCommand{}exports.NotificationCollectionRefreshCommand=a,exports.getFeedChannelIndexBy=e=>["-lastMessageUpdatedAt","-createdAt","syncIndex"]; diff --git a/cjs/lib/__bundle-5374ca23.cjs b/cjs/lib/__bundle-d3673ecc.cjs similarity index 97% rename from cjs/lib/__bundle-5374ca23.cjs rename to cjs/lib/__bundle-d3673ecc.cjs index 856db48..49708aa 100644 --- a/cjs/lib/__bundle-5374ca23.cjs +++ b/cjs/lib/__bundle-d3673ecc.cjs @@ -1 +1 @@ -var e,t=require("./__bundle-ad182031.cjs"),s=require("./__bundle-9d371926.cjs"),n=require("./__bundle-dae7bdf2.cjs");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 a{constructor(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===t.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===t.ChannelType.OPEN}}class o extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.event=new a(s)}}class r extends t.WebSocketEventCommand{constructor(e,t,n){var a;super(e,"SYEV",n),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,n.data&&(this.pinnedMessageIds=null!==(a=n.data.pinned_message_ids)&&void 0!==a?a:[],this.latestPinnedMessage=n.data.latest_pinned_message?s.parseMessagePayload(e,Object.assign({},n.data.latest_pinned_message)):null),this.ts=n.ts}}class i extends t.InstancedObject{get _messageBroadcast(){return s.MessageBroadcast.of(this._iid)}constructor(e,t){super(e),this._logger=t.logger,this._sdkState=t.sdkState,this._sessionManager=t.sessionManager,this._requestQueue=t.requestQueue,this._dispatcher=t.dispatcher,this._cacheContext=t.cacheContext,this._channelType=t.channelType}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}getMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){return null}))}getExactlyMatchingMessagesForTokenFromCache(e,s,n){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getMessagesFromCache(e,s,n,a,o,r){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getPollMessagesFromCache(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getCachedMessageCountBetween(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return 0}))}getUnsentMessagesFromCache(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}removeFailedMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){}))}}class E extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E;super(e,"ADMM",a),this.message=new s.AdminMessage(e,a);const{sdkState:d}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(i=null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(r=this.message.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)))&&void 0!==i?i:[],d.userId),this.forceUpdateLastMessage=null!==(E=a.force_update_last_message)&&void 0!==E&&E}}class d extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E,d;super(e,"AEDI",a),this.message=new s.AdminMessage(e,a);const{sdkState:_}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(o=a.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(i=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==i?i:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(E=this.message.mentionedUserIds)&&void 0!==E?E:null===(d=this.message.mentionedUsers)||void 0===d?void 0:d.map((e=>e.userId))}),_.userId)}}class _ extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MRCT",n),this.channelUrl=n.channel_url,this.channelType=n.channel_type,this.event=new s.ReactionEvent(n)}}class N extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MTHD",n),this.event=new s.ThreadInfoUpdateEvent(e,n)}}class l extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MCNT",s),this.groupChannelMemberCounts=s.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=s.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class c extends t.WebSocketEventCommand{constructor(e,s,a){super(e,"PEDI",a),this.event=new n.PollUpdateEvent(e,a),this.status=t.parsePollStatusPayload(a.poll.status)||a.poll.status,this.channelUrl=a.channel_url,this.channelType=a.channel_type}}exports.AdminMessageEventCommand=E,exports.BaseChannelManager=i,exports.ChannelEventCommand=o,exports.MemberCountUpdateEventCommand=l,exports.OperatorUpdateEventCommand=class extends o{constructor(e,s,n){super(e,s,n);const{operators:a=[]}=n.data;this.operators=a.map((e=>new t.User(this._iid,e)))}},exports.PollUpdateEventCommand=c,exports.ReactionEventCommand=_,exports.ThreadInfoUpdateEventCommand=N,exports.UpdateAdminMessageEventCommand=d,exports.UpdatePinnedMessageEventCommand=r; +var e,t=require("./__bundle-1a495950.cjs"),s=require("./__bundle-165fd6e1.cjs"),n=require("./__bundle-dae7bdf2.cjs");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 a{constructor(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===t.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===t.ChannelType.OPEN}}class o extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.event=new a(s)}}class r extends t.WebSocketEventCommand{constructor(e,t,n){var a;super(e,"SYEV",n),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,n.data&&(this.pinnedMessageIds=null!==(a=n.data.pinned_message_ids)&&void 0!==a?a:[],this.latestPinnedMessage=n.data.latest_pinned_message?s.parseMessagePayload(e,Object.assign({},n.data.latest_pinned_message)):null),this.ts=n.ts}}class i extends t.InstancedObject{get _messageBroadcast(){return s.MessageBroadcast.of(this._iid)}constructor(e,t){super(e),this._logger=t.logger,this._sdkState=t.sdkState,this._sessionManager=t.sessionManager,this._requestQueue=t.requestQueue,this._dispatcher=t.dispatcher,this._cacheContext=t.cacheContext,this._channelType=t.channelType}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}getMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){return null}))}getExactlyMatchingMessagesForTokenFromCache(e,s,n){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getMessagesFromCache(e,s,n,a,o,r){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getPollMessagesFromCache(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getCachedMessageCountBetween(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return 0}))}getUnsentMessagesFromCache(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}removeFailedMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){}))}}class E extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E;super(e,"ADMM",a),this.message=new s.AdminMessage(e,a);const{sdkState:d}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(i=null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(r=this.message.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)))&&void 0!==i?i:[],d.userId),this.forceUpdateLastMessage=null!==(E=a.force_update_last_message)&&void 0!==E&&E}}class d extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E,d;super(e,"AEDI",a),this.message=new s.AdminMessage(e,a);const{sdkState:_}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(o=a.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(i=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==i?i:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(E=this.message.mentionedUserIds)&&void 0!==E?E:null===(d=this.message.mentionedUsers)||void 0===d?void 0:d.map((e=>e.userId))}),_.userId)}}class _ extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MRCT",n),this.channelUrl=n.channel_url,this.channelType=n.channel_type,this.event=new s.ReactionEvent(n)}}class N extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MTHD",n),this.event=new s.ThreadInfoUpdateEvent(e,n)}}class l extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MCNT",s),this.groupChannelMemberCounts=s.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=s.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class c extends t.WebSocketEventCommand{constructor(e,s,a){super(e,"PEDI",a),this.event=new n.PollUpdateEvent(e,a),this.status=t.parsePollStatusPayload(a.poll.status)||a.poll.status,this.channelUrl=a.channel_url,this.channelType=a.channel_type}}exports.AdminMessageEventCommand=E,exports.BaseChannelManager=i,exports.ChannelEventCommand=o,exports.MemberCountUpdateEventCommand=l,exports.OperatorUpdateEventCommand=class extends o{constructor(e,s,n){super(e,s,n);const{operators:a=[]}=n.data;this.operators=a.map((e=>new t.User(this._iid,e)))}},exports.PollUpdateEventCommand=c,exports.ReactionEventCommand=_,exports.ThreadInfoUpdateEventCommand=N,exports.UpdateAdminMessageEventCommand=d,exports.UpdatePinnedMessageEventCommand=r; diff --git a/cjs/lib/__bundle-980f5f44.cjs b/cjs/lib/__bundle-dcf4d0c3.cjs similarity index 99% rename from cjs/lib/__bundle-980f5f44.cjs rename to cjs/lib/__bundle-dcf4d0c3.cjs index 7895138..435594b 100644 --- a/cjs/lib/__bundle-980f5f44.cjs +++ b/cjs/lib/__bundle-dcf4d0c3.cjs @@ -1 +1 @@ -var e,t,s,n,i,a,r,o,l,d=require("./__bundle-ad182031.cjs"),h=require("./__bundle-9d371926.cjs"),c=require("./__bundle-290a02c3.cjs"),u=require("./__bundle-5374ca23.cjs"),_=require("./__bundle-e8b53f2f.cjs");exports.MemberState=void 0,(e=exports.MemberState||(exports.MemberState={})).NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left";class p 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 m 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.member=new d.User(this._iid,t.user),this.deliveryAt=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 g{constructor(e){var t,s,n,i,a,r,o,l,d,h,c,u,_,p,m;this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(t=null==e?void 0:e.includeEmpty)&&void 0!==t&&t,this.nicknameContainsFilter=null!==(s=null==e?void 0:e.nicknameContainsFilter)&&void 0!==s?s:null,this.nicknameStartsWithFilter=null!==(n=null==e?void 0:e.nicknameStartsWithFilter)&&void 0!==n?n:null,this.nicknameExactMatchFilter=null!==(i=null==e?void 0:e.nicknameExactMatchFilter)&&void 0!==i?i:null,this.channelNameContainsFilter=null!==(a=null==e?void 0:e.channelNameContainsFilter)&&void 0!==a?a:"",this.myMemberStateFilter=null!==(r=null==e?void 0:e.myMemberStateFilter)&&void 0!==r?r:exports.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(o=null==e?void 0:e.customTypesFilter)&&void 0!==o?o:null,this.channelUrlsFilter=null!==(l=null==e?void 0:e.channelUrlsFilter)&&void 0!==l?l:null,this.superChannelFilter=null!==(d=null==e?void 0:e.superChannelFilter)&&void 0!==d?d:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(h=null==e?void 0:e.publicChannelFilter)&&void 0!==h?h:exports.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(c=null==e?void 0:e.customTypeStartsWithFilter)&&void 0!==c?c:null,this.unreadChannelFilter=null!==(u=null==e?void 0:e.unreadChannelFilter)&&void 0!==u?u:exports.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==e?void 0:e.hiddenChannelFilter)&&void 0!==_?_:exports.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(p=null==e?void 0:e.includeFrozen)||void 0===p||p,(null==e?void 0:e.createdAfter)&&(this.createdAfter=e.createdAfter),(null==e?void 0:e.createdBefore)&&(this.createdBefore=e.createdBefore),this.includeMetaData=null===(m=null==e?void 0:e.includeMetaData)||void 0===m||m}_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 g;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("*")&&!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.ALL:if("none"===e.myMemberState)return!1;break;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!(this.createdAfter&&e.createdAtthis.createdBefore)}}class C 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 be.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 c.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!s&&t.name.localeCompare(e)<0||s&&t.name.localeCompare(e)>0)return!1;break;case c.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>e||s&&t.createdAte||s&&t.lastMessageUpdatedAtthis._deserialize(e)));return d.forEach((e=>{!n.includeMetaData&&e.cachedMetaData&&e._clearCachedMetaData(),this._channels.has(e.url)||this._channels.set(e.url,e)})),d}return[]}))}upsert(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];if(e.forEach((e=>{if(this._channels.has(e.url)){const n=this._channels.get(e.url);if(n._pinnedMessagesUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t){const{isUpdated:s}=n._updateCachedMetaData(e.cachedMetaData,t);s||Object.assign(e,{_cachedMetaData:void 0})}n._update(e),s.push(n)}else this._channels.set(e.url,e),s.push(e)})),this.localCacheEnabled){const e=[];for(let t=0;t0&&(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},v=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),f={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},M=e=>d.isArrayOf("string",e.customTypes,!0)&&d.isTypeOf("boolean",e.includeEmpty,!0)&&d.isTypeOf("boolean",e.includeFrozen,!0)&&d.isTypeOf("boolean",e.includeMetaData,!0)&&d.isTypeOf("boolean",e.includeChatNotification,!0),y={myMemberStateFilter:exports.MyMemberStateFilter.ALL},S=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 b={keys:[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,exports.UnreadItemKey.NONSUPER_INVITATION_COUNT,exports.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},N={channelCustomTypesFilter:void 0,superChannelFilter:exports.SuperChannelFilter.ALL},T=e=>d.isArrayOf("string",e.channelCustomTypesFilter,!0)&&d.isEnumOf(exports.SuperChannelFilter,e.superChannelFilter),U={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:d.MessageTypeFilter.ALL},I=Object.assign({},d.CollectionEventSource),x=e=>e.startsWith("EVENT_")||e===d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||e===d.CollectionEventSource.REFRESH_CHANNEL;class P extends d.BaseCommand{constructor({channels:e,context:t,isWebSocketEventComing:s=!1,ts:n}){super(),this.channels=e,this.context=t,this.isWebSocketEventComing=s,this.ts=n}}class R extends d.BaseCommand{constructor({channelUrls:e,context:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.context=t,this.isWebSocketEventComing=s}}class O{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 P){const{channels:s,context:i,isWebSocketEventComing:a}=n,r=s.filter((e=>e instanceof vt));if(i.source===d.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY||i.source===d.CollectionEventSource.EVENT_CHANNEL_HIDDEN)for(const e of r)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp);else{const s=e.filterOffsetChanged(r);for(const e of s)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp)}const o=yield e.upsert(r,n.ts);a||this._broadcastUpdateEvent(o,i)}else if(n instanceof R){const{channelUrls:i,context: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 c.DatabaseOpenCommand&&(yield e.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,t)}_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 w extends d.APIRequestCommand{constructor({userId:e,ts:t,token:s,filter:n,includeChatNotification:i=!1}){super();const{customTypes:a,includeEmpty:r,includeFrozen:o}=Object.assign(Object.assign({},f),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:a,show_empty:r,show_frozen:o,include_chat_notification:i}))}}class L extends d.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((s=>new vt(e,Object.assign(s,{ts:t.ts})))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next,this.ts=t.ts}}class F extends d.APIRequestCommand{constructor({channelUrl:e,isInternalCall:t,showLatestMessage:s}){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,show_latest_message:null!=s&&s}}}class D extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}const k={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0};class H 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:c,nicknameStartsWithFilter:u,nicknameExactMatchFilter:_,channelNameContainsFilter:p,channelUrlsFilter:m,customTypesFilter:g,customTypeStartsWithFilter:C,hiddenChannelFilter:E,metadataOrderKeyFilter:v,metadataKey:f,metadataValues:M,metadataValueStartsWith:y,includeFrozen:S,includeMetaData:A,searchFilter:b,userIdsFilter:N,includeChatNotification:T=!1,includeLeftChannel:U=!1,createdAfter:I,createdBefore:x}=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:k.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=a?a:k.includeEmpty,member_state_filter:null!=r?r:k.myMemberStateFilter,super_mode:null!=o?o:k.superChannelFilter,public_mode:null!=l?l:k.publicChannelFilter,unread_filter:null!=h?h:k.unreadChannelFilter,members_nickname_contains:c,members_nickname_startswith:u,members_nickname:_,name_contains:p,channel_urls:m,custom_types:g,custom_type_startswith:C,hidden_mode:E,metadata_order_key:v,metadata_key:f,metadata_values:M,metadata_value_startswith:y,show_frozen:S,show_metadata:A,include_chat_notification:T,include_left_channel:U,created_after:I,created_before:x}),b&&b.query&&b.fields&&(this.params.search_query=b.query,this.params.search_fields=b.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(this.params.members_include_in=N.userIds,this.params.query_type=N.queryType.toUpperCase()):this.params.members_exactly_in=N.userIds)}}class V 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 vt(e,t))))),this.ts=null!=i?i:0}}class G 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 q extends d.APIResponseCommand{constructor(e,t){super(e,t),this.groupChannelCount=t.group_channel_count}}class B extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{keys:s,customTypeFilters:n,customTypesFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_item_count`,this.params=d.deundefined({item_keys:s,custom_types:null!=i?i:n})}}class j 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 z extends d.APIRequestCommand{constructor({userId:e}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_channel_count`}}class W extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class $ extends d.APIRequestCommand{constructor({userId:e,filter:t,includeFeedChannel:s=!1}){super();const{channelCustomTypesFilter:n,superChannelFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_message_count`,this.params={super_mode:null!=i?i:exports.SuperChannelFilter.ALL,custom_types:n,include_feed_channel:s}}}class K extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count,this.unreadFeedCount=t.unread_feed_count}}class Q 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:J(t)},s&&(this.params.message_type=s)}}class Y extends d.APIResponseCommand{constructor(e,t){super(e,t),this.count=t.count}}const J=e=>{if(!e)return[];const t=[];return e.forEach((e=>{switch(e){case h.ScheduledStatus.PENDING:t.push(h.InternalScheduledStatus.PENDING);break;case h.ScheduledStatus.SENT:t.push(h.InternalScheduledStatus.IN_QUEUE),t.push(h.InternalScheduledStatus.SENT);break;case h.ScheduledStatus.CANCELED:t.push(h.InternalScheduledStatus.CANCELED);break;case h.ScheduledStatus.FAILED:t.push(h.InternalScheduledStatus.FAILED)}})),t};class X 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:c,isStrict:u,isEphemeral:_,accessCode:p,name:m,data:g,customType:C,messageSurvivalSeconds:E,invitedUserIds:v,operatorUserIds:f}=e;super(),this.method=d.APIRequestMethod.POST,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined({user_ids:[t,...null!=v?v:[]].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:c,strict:u,is_ephemeral:_,access_code:p,name:m,data:g,custom_type:C,operator_ids:f,message_survival_seconds:E})}}class Z extends d.APIResponseCommand{constructor(e,t){var s;super(e,t),this.channel=new vt(e,t),this.isCreated=null===(s=t.is_created)||void 0===s||s}}class ee 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 te 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 se extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class ne extends u.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 p(e,t))):[new p(e,s.data)]}}class ie 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 ae extends u.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 p(this._iid,s.data)}}class re 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 oe extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class le extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s),this.inviter=null;const{member_count:n=0,joined_member_count:i=0,inviter:a,invitees:r=[]}=s.data;this.memberCount=n,this.joinedMemberCount=i,a&&Object.keys(a).length>0&&(this.inviter=new d.User(e,a)),this.invitees=r.map((t=>new p(e,t)))}}class de 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 he extends u.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 p(e,r)}}const ce={hidePreviousMessages:!1,allowAutoUnhide:!0};class ue 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 _e extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}class pe 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 me extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPST",ackRequired:!1,payload:{channel_url:e,time:t}})}}class ge extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class Ce 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 ve extends d.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"MACK",ackRequired:!1,payload:{channel_url:e,msg_id:t}})}}class fe extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,u,_,p,m,g,C,E,v,f,M,y,S,A,b;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.includeChatNotification=!1,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=c.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.includeChatNotification=null!==(a=t.includeChatNotification)&&void 0!==a&&a,this.channelUrlsFilter=null!==(r=t.channelUrlsFilter)&&void 0!==r?r:null,this.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,this.customTypeStartsWithFilter=null!==(l=t.customTypeStartsWithFilter)&&void 0!==l?l:"",this.nicknameContainsFilter=null!==(d=t.nicknameContainsFilter)&&void 0!==d?d:null,this.nicknameStartsWithFilter=null!==(h=t.nicknameStartsWithFilter)&&void 0!==h?h:null,this.nicknameExactMatchFilter=null!==(u=t.nicknameExactMatchFilter)&&void 0!==u?u:null,this.channelNameContainsFilter=null!==(_=t.channelNameContainsFilter)&&void 0!==_?_:"",this.myMemberStateFilter=null!==(p=t.myMemberStateFilter)&&void 0!==p?p:exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=null!==(m=t.unreadChannelFilter)&&void 0!==m?m:exports.UnreadChannelFilter.ALL,this.superChannelFilter=null!==(g=t.superChannelFilter)&&void 0!==g?g:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(C=t.publicChannelFilter)&&void 0!==C?C:exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=null!==(E=t.hiddenChannelFilter)&&void 0!==E?E:exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter=null!==(v=t.searchFilter)&&void 0!==v?v:{fields:[],query:null},this.userIdsFilter=null!==(f=t.userIdsFilter)&&void 0!==f?f:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null!==(M=t.metadataKey)&&void 0!==M?M:null,this.metadataValues=null!==(y=t.metadataValues)&&void 0!==y?y:null,this.metadataOrderKeyFilter=null!==(S=t.metadataOrderKeyFilter)&&void 0!==S?S:null,this.metadataValueStartsWith=null!==(A=t.metadataValueStartsWith)&&void 0!==A?A:null,this.order=null!==(b=t.order)&&void 0!==b?b:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,t.createdAfter&&(this.createdAfter=t.createdAfter),t.createdBefore&&(this.createdBefore=t.createdBefore)}_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(c.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)&&d.isMilliSecondOf(this.createdAfter,!0)&&d.isMilliSecondOf(this.createdBefore,!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=be.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign({},this)),this.limit,d.CollectionEventSource.REQUEST_CHANNEL,!0);return this._token=s,this._hasNext=!!s,this._isLoading=!1,t}return[]}throw d.SendbirdError.invalidParameters}))}}class Me extends d.APIRequestCommand{constructor({channelUrl:e,userId:t}){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 ye extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"DLVR",s),this.channelUrl=s.channel_url,this.deliveredStateUpdate=s.updated}}class Se{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)}}const Ae={};class be extends u.BaseChannelManager{get _messageCache(){return h.MessageCache.of(this._iid)}get _unsentMessageCache(){return h.UnsentMessageCache.of(this._iid)}constructor(e,t){var s;super(e,Object.assign(Object.assign({},t),{channelType:d.ChannelType.GROUP})),this._leftChannels=new Map,this._disableMack=!1,this._markAsReadAllLastSentAt=0,this._disableMack=null!==(s=t.disableMack)&&void 0!==s&&s,this._groupChannelHandlers=new Map,this._groupChannelCache=new C(this._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),this._groupChannelBroadcast=new O({dispatcher:t.dispatcher,groupChannelCache:this._groupChannelCache,messageCache:h.MessageCache.of(this._iid),unsentMessageCache:h.UnsentMessageCache.of(this._iid)}),setInterval((()=>{for(const e of this._groupChannelCache.channels)e.invalidateTypingStatus()&&(this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.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).catch((e=>{if(d.isThrowingOutside(e)&&"foreground"===this._sdkState.appState)throw e})):e instanceof c.AutoResendRequestCommand?(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{message:t}=e,s=yield this.getChannel(t.channelUrl,!0);t instanceof h.UserMessage?s._autoResendUserMessage(t):t instanceof h.FileMessage&&s._autoResendFileMessage(t)}))})():e instanceof c.ReduceDBSizeEventCommand?this.reduceDBSize():e instanceof h.MessageThreadInfoUpdatedEventCommand&&(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{channelUrl:t,channelType:s,parentMessage:n}=e,i=new h.ThreadInfoUpdateEvent(this._iid,{channel_type:d.ChannelType.GROUP,channel_url:t,parent_message_id:n.messageId,thread_info:h.ThreadInfo.payloadify(n.threadInfo)});if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onThreadInfoUpdated&&t.onThreadInfoUpdated(e,i)}))))}}))})()})),Ae[e]||(Ae[e]=this)}static of(e){return Ae[e]||(Ae[e]=new be(e,d.Vault.of(e))),Ae[e]}static clear(e){Ae[e]&&delete Ae[e]}get handlers(){return[...this._groupChannelHandlers.values()]}buildGroupChannelFromSerializedData(e){const t=d.deserialize(e);return new vt(this._iid,vt.payloadify(t))}buildGroupChannelListQueryFromSerializedData(e){const t=d.deserialize(e);return new fe(this._iid,t)}buildMemberFromSerializedData(e){const t=d.deserialize(e);return new p(this._iid,p.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 e=h.MessageCache.of(this._iid),{cacheContext:t}=d.Vault.of(this._iid),{localCacheConfig:s,nestdb:n}=t;if(!t.localCacheEnabled||!n||n.state!=h.NestDBState.OPENED)return;const i=1024*s.maxSize*1024;let a=yield n.estimateUsage();if(ad.__awaiter(this,void 0,void 0,(function*(){const t=new ve(e);this._requestQueue.send(t)}))));const s=this._groupChannelCache.isCachedInMemory(e.channelUrl),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId,r=yield this.getChannel(e.channelUrl,!0),{useMemberInfoInMessage:o}=d.Vault.of(this._iid);if(e instanceof h.SendableMessage){for(const t of r.members)if(t.userId===e.sender.userId){o||(e.sender.nickname=t.nickname,e.sender.plainProfileUrl=t.plainProfileUrl,e.sender.metaData=t.metaData,e.sender.isBlockedByMe=t.isBlockedByMe);break}if(!o&&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._updateLastMessage(e),a||r._shouldUpdateUnreadCountWith(e)&&r._updateUnreadCount(r.unreadMessageCount+1,r.unreadMentionCount+(n?1:0))),i&&r._updateLastMessage(e),this._dispatcher.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),e.silent&&!a||d.runAsCallback((()=>d.__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.CollectionEventSource.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(u.UpdateAdminMessageEventCommand)),t){const{message:e,mentionCountChange:n}=t;if(e.threadInfo&&(e.threadInfo.unreadReplyCount=void 0),e.channelType===d.ChannelType.GROUP){const t=this._groupChannelCache.isCachedInMemory(e.channelUrl),i=yield this.getChannel(e.channelUrl,!0),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId;let r=!1;if(a){const t=e.sender,{currentUser:s}=this._sessionManager;s&&(s.nickname=t.nickname,s.plainProfileUrl=t.plainProfileUrl,s.metaData=t.metaData)}else i.isReadMessage(e)||0!==n&&!e.silent&&t&&(i._updateUnreadCount(i.unreadMessageCount,i.unreadMentionCount+n),r=!0);i._updateLastMessage(e)?r=!0:(null===(s=i.lastMessage)||void 0===s?void 0:s.isIdentical(e))&&(t?i._updateLastMessage(e)&&(r=!0):r=!0);let o=!1;i.lastPinnedMessage&&i.lastPinnedMessage.messageId===e.messageId&&(i.lastPinnedMessage=e,r=!0,o=!0),r&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:o?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}})),e.silent&&!a||d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)})))),o&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)}))))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageUpdated&&t.onMessageUpdated(i,e),n>0&&t.onMentionReceived&&t.onMentionReceived(i,e)}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:n,silent:i,messageCreatedAt:a,senderId:r}=e.as(d.DeleteMessageEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=r===this._sdkState.userId;i||s||a>0&&e.myLastRead0&&e._updateUnreadCount(e.unreadMessageCount-1,0),this._dispatcher.dispatch(new d.MessageRemoveEventCommand({messageIds:[n],source:d.CollectionEventSource.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(h.ReadEventCommand);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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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(ye),n=this._groupChannelCache.isCachedInMemory(t),i=yield this.getChannel(t,!0);n&&Object.keys(s).forEach((e=>{i._updateUndeliveredMemberState(e,s[e])})),Object.keys(s).some((e=>e!==this._sdkState.userId))&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:d.CollectionEventSource.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(u.ReactionEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=yield this.getMessageFromCache(n.messageId);s?s instanceof h.BaseMessage&&(s.applyReactionEvent(n),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new d.ReactionUpdateEventCommand({event:n,source:d.CollectionEventSource.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(u.ThreadInfoUpdateEventCommand);if(t.channelType===d.ChannelType.GROUP){const e=yield this.getChannel(t.channelUrl,!0),s=yield this.getMessageFromCache(t.targetMessageId);s?s instanceof h.BaseMessage&&(s.applyThreadInfoUpdateEvent(t),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new d.ThreadUpdateEventCommand({event:t,source:d.CollectionEventSource.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(u.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 P({channels:s,context:{source:d.CollectionEventSource.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(u.PollUpdateEventCommand);if(n&&i===d.ChannelType.GROUP){const e=yield this.getChannel(n,!0);this._dispatcher.dispatch(new d.PollUpdateInternalEventCommand({event:t,source:d.CollectionEventSource.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.CollectionEventSource.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(u.ChannelEventCommand);if(t.isGroupChannelEvent)switch(t.category){case u.ChannelEventCategory.CHANNEL_JOIN:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,members:a}=e.as(ne);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:a}})),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 u.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(ae);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((e=>e.userId===r.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 P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})):(this._markAsLeave(n),this._dispatcher.dispatch(new R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})))):this._dispatcher.dispatch(new P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})),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 u.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const s=yield this.getChannel(t.channelUrl,!0),{operators:n}=e.as(u.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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitees:r}=e.as(le);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:a,invitees:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserReceivedInvitation&&e.onUserReceivedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitee:r}=e.as(he);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})):this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}}))):this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.TYPING_START:case u.ChannelEventCategory.TYPING_END:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.TYPING_START,{user:i}=e.as(n?ge:Ee);s._updateTypingStatus(i,n?t.ts:0),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.USER_CHANNEL_MUTE:case u.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.USER_CHANNEL_MUTE,{user:i}=e.as(n?h.MuteUserEventCommand:h.UnmuteUserEventCommand);i.userId===this._sdkState.userId&&(s.myMutedState=n?d.MutedState.MUTED:d.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 P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_MUTED:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i}})),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 u.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 R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_BANNED,user:i}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserBanned&&e.onUserBanned(n,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_UNBAN:{const s=yield this.getChannel(t.channelUrl,!0),{user:n}=e.as(h.UnbanUserEventCommand);n.userId===this._sdkState.userId&&this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserUnbanned&&e.onUserUnbanned(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_FREEZE:case u.ChannelEventCategory.CHANNEL_UNFREEZE:{const s=yield this.getChannel(t.channelUrl,!0),{freeze:n}=e.as(h.FreezeEventCommand);s.isFrozen=n,this._dispatcher.dispatch(new P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_FROZEN:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_HIDE:{const s=yield this.getChannel(t.channelUrl,!0),{allowAutoUnhide:n,hidePreviousMessages:i,messageOffsetTimestamp:a}=e.as(pe);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onChannelHidden&&e.onChannelHidden(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_UNHIDE:{const e=yield this.getChannel(t.channelUrl,!0);e.hiddenState=exports.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_DELETED:{const e=yield this.getChannel(t.channelUrl,!0);this._dispatcher.dispatch(new R({channelUrls:[t.channelUrl],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const e=yield this.getChannelWithoutCache(t.channelUrl,!0);this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.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),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:n},ts:t.ts}))),i&&(s._upsertCachedMetaData(i,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:i},ts:t.ts}))),a&&(s._removeFromCachedMetaData(a,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:a},ts: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 u.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaCounterEventCommand);n&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:n}})),i&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:i}})),a&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:a}})),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 u.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:n,latestPinnedMessage:i,ts:a}=e.as(u.UpdatePinnedMessageEventCommand);a>s._pinnedMessagesUpdatedAt&&(s.pinnedMessageIds=null!=n?n:[],s.lastPinnedMessage=i,s._pinnedMessagesUpdatedAt=a,this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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(c.UserEventCommand);switch(t.category){case c.UserEventCategory.USER_BLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.block(e.userId,s.userId);break}case c.UserEventCategory.USER_UNBLOCK:{const{blocker:e,blockee:s}=c.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()}subscribeChannelEvent(e,t){this._groupChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._groupChannelBroadcast.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 F({channelUrl:e,isInternalCall:t}),n=yield this._requestQueue.send(s),{channel:i}=n.as(D);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=d.CollectionEventSource.REFRESH_CHANNEL,n=!1){return d.__awaiter(this,void 0,void 0,(function*(){try{const i=new F({channelUrl:e,isInternalCall:t,showLatestMessage:n}),a=yield this._requestQueue.send(i),{channel:r}=a.as(D);if(r.myMemberState===exports.MemberState.NONE)this._dispatcher.dispatch(new R({channelUrls:[r.url],context:{source:s}}));else{const e=yield this.upsertChannelsToCache([r]);this._dispatcher.dispatch(new P({channels:e,context:{source:s}}))}}catch(t){t.code!==d.SendbirdErrorCode.NON_AUTHORIZED&&t.code!==d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new R({channelUrls:[e],context:{source:s}}))}}))}getMyGroupChannels(e,t,s,n=d.CollectionEventSource.REQUEST_CHANNEL,i=!1){return d.__awaiter(this,void 0,void 0,(function*(){t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3));let a=!1;if(i){const{appInfo:e,cacheContext:t}=d.Vault.of(this._iid);t&&!t.localCacheEnabled&&(null==e?void 0:e.enabledChannelMemberShipHistory)&&(null==e?void 0:e.applicationAttributes.includes("left_user_view_support"))&&(a=!0)}const r=new H(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:e,limit:s,includeLeftChannel:i&&a})),o=yield this._requestQueue.send(r),{channels:l,token:h}=o.as(V);return this._dispatcher.dispatch(new P({channels:l,context:{source:n}})),{channels:l,token:h}}))}getMyGroupChannelChangeLogs(e,t,s=d.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return d.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},f),t);d.unless((d.isTypeOf("string",e)||d.isTypeOf("number",e))&&M(n)).throw(d.SendbirdError.invalidParameters);const i=new w(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(L),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,ts:h}=a;return r.length>0&&this._dispatcher.dispatch(new P({channels:r,context:{source:s},ts:h})),o.length>0&&this._dispatcher.dispatch(new R({channelUrls:o,context:{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({},y),e);d.unless(S(t)).throw(d.SendbirdError.invalidParameters);const s=new G({userId:this._sdkState.userId,filter:t}),n=yield this._requestQueue.send(s),{groupChannelCount:i}=n.as(q);return i}))}getUnreadItemCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},b),e);d.unless((e=>d.isArrayOf(exports.UnreadItemKey,e.keys)&&d.isArrayOf("string",e.customTypeFilters,!0)&&d.isArrayOf("string",e.customTypesFilter,!0))(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),{groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m}=a.as(j);return d.deundefined({groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,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 z({userId:e.userId}),n=yield t.send(s),{unreadCount:i}=n.as(W);return i}))}getTotalUnreadMessageCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},N),e);d.unless(T(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new $({userId:s.userId,filter:t}),a=yield n.send(i),{unreadCount:r}=a.as(K);return r}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},U),e);d.unless((e=>d.isTypeOf("string",e.channelUrl,!0)&&d.isArrayOf(h.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 Q(t),i=yield s.send(n),{count:a}=i.as(Y);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);return Object.keys(t.customTypes).forEach((s=>{e+=t.customTypes[s]})),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(v(t)).throw(d.SendbirdError.invalidParameters),t.isPublic||(t.accessCode=void 0);const s=new X(Object.assign({userId:this._sdkState.userId},t)),n=yield this._requestQueue.send(s),{channel:i}=n.as(Z);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 ee({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 ee({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()}))}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){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})}))}getCachedMessageCountBetween(e,t,s,n){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.countBetween(e,t,new Se({top:s,bottom:n}))}))}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])}))}}const Ne=(e,t)=>t instanceof h.SendableMessage?e.findIndex((e=>e instanceof h.SendableMessage&&t.isIdentical(e))):e.findIndex((e=>e.isIdentical(t))),Te=(e,t)=>e.findIndex((e=>e instanceof h.BaseMessage?e.messageId===t:e instanceof h.NotificationMessage?e.notificationId===t:void 0)),Ue=(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};var Ie;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Ie||(Ie={}));class xe extends d.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=Ie.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===Ie.IDLE}get isRunning(){return this._state===Ie.RUNNING}get isDone(){return this._state===Ie.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 xe(_,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u,_;const p={hasNext:!0,nextToken:0};if(this._prevSyncLoopCount++,yield this.loadMetadata(),r.debug("message background prev sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.top),null===(n=this._metadata)||void 0===n?void 0:n.previousComplete)p.hasNext=!1;else try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(l=null===(a=this._metadata)||void 0===a?void 0:a.range)||void 0===l?void 0:l.top)?this._metadata.range.top:e,{prevResultSize:this._limit,nextResultSize:0,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(c=this._metadata)||void 0===c?void 0:c.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}p.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(p.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.lengthd.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u;const _={hasNext:!0,nextToken:0};yield this.loadMetadata(),r.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom);try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(a=null===(n=this._metadata)||void 0===n?void 0:n.range)||void 0===a?void 0:a.bottom)?this._metadata.range.bottom:e,{prevResultSize:0,nextResultSize:this._limit,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(l=this._metadata)||void 0===l?void 0:l.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}_.hasNext=s.length>=this._limit,this._metadata&&(_.nextToken=this._metadata.range.bottom),r.debug("message background next sync progress",_),yield this.saveMetadata()}catch(e){throw r.debug("message background next sync error",e),e}finally{o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:t.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(u=null===(c=i.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==u?u:0,use_local_cache:i.localCacheEnabled,starting_point:0,message_init_policy:""}}))}return _}))))})))),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){return Pe[e]||(Pe[e]={}),Pe[e][t.url]||(Pe[e][t.url]=new Re({_iid:e,channel:t})),Pe[e][t.url].ref++,Pe[e][t.url]}static clear(e,t){Pe[e]&&Pe[e][t]&&(Pe[e][t].close(),delete Pe[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 Se({})}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(){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?{range:new Se(t.range),previousComplete:t.previousComplete}:{range:new Se({}),previousComplete:!1}}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(e=Date.now()){var t,s,n,i;const{logger:a,sessionManager:r,cacheContext:o}=d.Vault.of(this._iid);o.localCacheEnabled&&r.session.hasSession&&(a.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(s=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==s?s:e),this._nextSync.start(null!==(i=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==i?i:e))}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid][this._channel.url])}}const Oe={};class we{constructor({_iid:e,channel:t,includeParams:s}){this.ref=0,this._iid=e,this._channel=t,this._includeParams=s;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}/message/changelogs.meta`);const l=((e,t)=>`sendbird:${e}@groupchannel/${t}/message/changelogs`)(i.userId,this._channel.url);this._sync=new xe(l,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};yield this.loadMetadata(),n.debug("message changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=h.MessageManager.of(this._iid),{updatedMessages:s,deletedMessageIds:i,hasMore:a,token:r}=yield e.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:d.ReplyType.ALL},this._includeParams),d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);t.hasNext=a,t.nextToken=r,(s.length>0||i.length>0)&&this._metadata&&(this._metadata.token=r),n.debug("message changelog sync progress",t),yield this.saveMetadata()}catch(e){throw n.debug("message 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 Oe[e]||(Oe[e]={}),Oe[e][t.url]||(Oe[e][t.url]=new we({_iid:e,channel:t,includeParams:s})),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])}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,sessionManager:t}=d.Vault.of(this._iid);t.session.hasSession&&(e.debug("message changelog sync resume()"),this._sync.start(0))}pause(){const{logger:e}=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 Oe[this._iid][this._channel.url])}}const Le={};class Fe{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 xe(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=d.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 Le[e]||(Le[e]={}),Le[e][t.url]||(Le[e][t.url]=new Fe({_iid:e,channel:t,hasPollMessage:s})),Le[e][t.url].ref++,Le[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 Le[this._iid][this._channel.url])}}class De extends d.APIRequestCommand{constructor(e){var t,s,n,i,a,r,o,l,h,c;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_reply_type:null!==(i=e.replyType)&&void 0!==i?i:d.ReplyType.NONE,include_reactions:null===(a=e.includeReactions)||void 0===a||a,include_meta_array:null===(r=e.includeMetaArray)||void 0===r||r,include_thread_info:null===(o=e.includeThreadInfo)||void 0===o||o,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(c=e.showSubchannelMessagesOnly)&&void 0!==c&&c,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=>h.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=>h.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 He={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};exports.MessageCollectionInitPolicy=void 0,(exports.MessageCollectionInitPolicy||(exports.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";class Ve{constructor(){this._onCacheResult=d.noop,this._onApiResult=d.noop}_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 Ge{keyOf(e){return 0}get changelogIncludeParams(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}_postprocessChannelUpdateEvent(e,t){}_postprocessChannelRemoveEvent(e){}_postprocessMessageUpdateEvent(e,t){}_postprocessMessageRemoveEvent(e){}constructor(e,{filter:t,startingPoint:s,limit:n,prevResultLimit:i,nextResultLimit:a,channel:r,channelManager:o,disableBackgroundSync:l=!1}){this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key=`mc-${d.uuid()}`,this._isDisposed=!1,this.filter=null!=t?t:new h.MessageFilter,this._channel=r,this._syncRange=new Se({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=n||h.DEFAULT_MESSAGE_LIMIT,this._prevResultLimit=null!=i?i:Math.floor(this._limit/2),this._nextResultLimit=null!=a?a:Math.floor(this._limit/2),this._channelManager=o;const{statManager:c}=d.Vault.of(this._iid);this._channelManager.subscribeChannelEvent(this._key,{onUpdate:(e,t)=>{const{source:s}=t,n=e.findIndex((e=>e.isIdentical(this.channel)));n>=0&&(this._replaceChannelOfCollection(e[n]),this.channel._runIfHandleableWithGroupChannel((e=>{switch(s){case d.CollectionEventSource.EVENT_CHANNEL_UPDATED:{let t=!1;for(let s=0;s=e.messageOffsetTimestamp){t=!0;const e=s;if(e>0){const t=this._messages.splice(0,e);this._removeMessagesFromView(t.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!t&&this._messages.length>0&&this._removeMessagesFromView(this._messages.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break}case d.CollectionEventSource.EVENT_CHANNEL_UNMUTED:{const{sdkState:e}=d.Vault.of(this._iid),{user:s}=t;e.userId===s.userId&&this._clearCheckMyMutedTimer();break}case d.CollectionEventSource.EVENT_CHANNEL_MUTED:{const{sdkState:s}=d.Vault.of(this._iid),{user:n}=t;s.userId===n.userId&&-1!==e._myMutedRemainingTime&&this._startCheckMyMutedTimer(e._myMutedRemainingTime);break}case d.CollectionEventSource.EVENT_CHANNEL_LEFT:e.isPublic&&this._clearCheckMyMutedTimer()}d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;x(s)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel)}))))})),this._postprocessChannelUpdateEvent(e[n],s))},onRemove:(e,t)=>{const s=e.indexOf(this.channel.url);s>=0&&(this._clearCheckMyMutedTimer(),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url)})))),this._postprocessChannelRemoveEvent(e[s]))}}),this._channelManager.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(this.keyOf(t)));if(d.shouldGiveEvent(t)){if(s.length>0)switch(t){case d.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case d.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case d.CollectionEventSource.EVENT_MESSAGE_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:this._updateMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:this._addMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_RECEIVED:this.hasNext||this._addMessagesToView(s,t);break;case d.CollectionEventSource.SYNC_MESSAGE_FILL:this._addMessagesToView(s,t)}n.length>0&&this._removeMessagesFromView(n,t)}this._postprocessMessageUpdateEvent(e,t)},onRemove:(e,t)=>{this._removeMessagesFromView(e,t),this._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:(e,t)=>{this._applyReactionEventToView(e,t)},onThreadInfoUpdate:(e,t)=>{this._applyThreadInfoEventToView(e,t)}});const{cacheContext:u,dispatcher:_,messageBackgroundSyncThrottleController:p}=d.Vault.of(this._iid);this._channel._updateMessageCollectionLastAccessedAt(),_.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Re.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=we.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Fe.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new xe(this._key,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.min(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:i.length>=this._prevResultLimit&&this.viewTopd.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.max(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:!(i.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>e,nextToken:this._syncRange.bottom}}return u.localCacheEnabled&&c.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(s=u.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==n?n:0,use_local_cache:u.localCacheEnabled,starting_point:0,message_init_policy:""}})),{hasNext:!1,nextToken:0}}))))})))),this._connectionEventContext=_.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)switch(e.stateType){case d.ConnectionStateType.CONNECTED:d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){this._activate()}))));break;case d.ConnectionStateType.LOGOUT:this.dispose();break;default:this._clearCheckMyMutedTimer(),this._prevFill.stop(),this._nextFill.stop()}}))}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)}_activate(){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:e}=d.Vault.of(this._iid);e.debug("check huge gap"),this._checkHugeGap(),yield this._refreshChannel(d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS)}))}_replaceChannelOfCollection(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}_shouldStartBackgroundSync(){const{cacheContext:e}=d.Vault.of(this._iid);return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}_setBaseMessageCollectionHandler(e){this._handler=e}_filterUnderOffsetMessage(e){return e}_updateChildMessagesInView(e){const t=[];return this._messages.forEach((s=>{s instanceof h.BaseMessage&&s.parentMessageId===e.messageId&&s.applyParentMessage(e)&&t.push(s)})),t}_updatePollsToView(e,t){const s=[];for(const t of e){const e=Te(this._messages,t.messageId);if(e>=0){const n=this._messages[e];n.isUserMessage()&&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,n;const i={source:t};s.length>0&&(null===(n=(e=this._handler).onMessagesUpdated)||void 0===n||n.call(e,i,this.channel,s))})))),s}_applyPollUpdateEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyPollVoteEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyReactionEventToView(e,t){const s=Te(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyReactionEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_applyThreadInfoEventToView(e,t){const s=Te(this._messages,e.targetMessageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyThreadInfoUpdateEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_removeMessagesFromView(e,t){const s=[],n=[];for(const t of e){const e=this._messages.findIndex((e=>this.keyOf(e)===t));if(e>=0){const t=this._messages[e];s.push(this.keyOf(t)),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,i;const a={source:t};null===(i=null===(e=this._handler)||void 0===e?void 0:e.onMessagesDeleted)||void 0===i||i.call(e,a,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*(){let i=[];n&&(i=yield this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter));const a=t>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,t,!1):[],r=s>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1):[];return{messages:[...i,...a,...r].sort(((e,t)=>t.createdAt-e.createdAt)),prevMessagesCount:a.length,nextMessagesCount:r.length}}))}_getRemoteMessages(e,{prevLimit:t=0,nextLimit:s=0,source:n=d.CollectionEventSource.REQUEST_MESSAGE,reverse:i=!1,checkingHasNext:a=!1,checkingContinuousMessages:r=!1}){return d.__awaiter(this,void 0,void 0,(function*(){const o=h.MessageManager.of(this._iid);return t>0||s>0?yield o._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,d.undefineNullProps(Object.assign(Object.assign(Object.assign({},this.filter),He),{isInclusive:!0,reverse:i,prevResultSize:t,nextResultSize:s})),n,a,r):{messages:[],isContinuousMessages:!1}}))}_checkHugeGap(){var e,t,s,n,i;return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r,cacheContext:o,statManager:l,logger:h}=d.Vault.of(this._iid);if(this._messages.length>0){const s=this._syncRange.top,n=this.viewTop,i=this._syncRange.bottom,c=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,n,s),_=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,i,c);try{yield d.asyncRetry((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t=new De(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:s,prevCount:u,nextStart:i,nextEnd:c,nextCount:_,checkingContinuousMessages:o.localCacheEnabled},this.filter),He)),l=yield r.send(t),{isHugeGap:h,prevMessages:p=[],prevHasMore:m,isContinuousPrevMessages:g,nextMessages:C=[],nextHasmore:E,isContinuousNextMessages:v}=l.as(ke);if(h)d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected()}))));else{const t=this.viewTop,s=this.viewBottom,n=Math.min(Number.MAX_SAFE_INTEGER,t,...p.map((e=>e.createdAt))),i=Math.max(0,s,...C.map((e=>e.createdAt)));a.dispatch(new d.MessageUpdateEventCommand({messages:p,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),a.dispatch(new d.MessageUpdateEventCommand({messages:C,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(n,i),(g||v)&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(n,i)),m&&this._prevFill.start(n),E&&this._nextFill.start(i)}}))),1)}catch(e){h.debug("Failed HugeGap Check ",e)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}else{const e=Date.now();try{const{messages:t,isContinuousMessages:n,hasNext:i}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:o.localCacheEnabled});if(t.length>0){const a=t.map((e=>e.createdAt));let r=0,o=0;for(let t=0;t=e&&o++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=i?i:o>=this._nextResultLimit,this._syncRange.extends(...a),n&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(t,d.CollectionEventSource.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)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(n=o.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==i?i:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}}))}_loadUnsentMessages(){return d.__awaiter(this,void 0,void 0,(function*(){this._unsentMessages=yield this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)}))}_hasPollMessage(){return d.__awaiter(this,void 0,void 0,(function*(){return(yield this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)).length>0}))}_refreshChannel(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:s}=d.Vault.of(this._iid);try{yield this._channelManager.refreshChannel(this.channel.url,!0,e,t)}catch(e){s.warn("Failed to refresh channel",e)}}))}_startCheckMyMutedTimer(e){this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((()=>d.__awaiter(this,void 0,void 0,(function*(){this._checkMyMutedStateTimer=void 0;let e=!0;try{e=!(yield this._channel.getMyMutedInfo()).isMuted}catch(t){e=!0}finally{if(e){const{sessionManager:e}=d.Vault.of(this._iid);this.channel._runIfHandleableWithGroupChannel((t=>{var s,n;t.myMutedState=d.MutedState.UNMUTED;const i={source:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:e.currentUser};null===(n=null===(s=this._handler)||void 0===s?void 0:s.onChannelUpdated)||void 0===n||n.call(s,i,this.channel)}))}}}))),e+1e3)}_clearCheckMyMutedTimer(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}_setHasNextAndHaePrevious(e,t){const s=e.map((e=>e.createdAt));let n=0,i=0;for(let e=0;ethis._startingPoint&&i++}this._hasPrevious=n>=this._prevResultLimit,this._hasNext=null!=t?t:i>=this._nextResultLimit}initialize(e){const t=new Ve;this._messages=[],this._unsentMessages=[],this._syncRange=new Se({}),this._hasNext=!0,this._hasPrevious=!0;let s=[],n={messages:[],prevMessagesCount:0,nextMessagesCount:0};return d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var i;const a=yield null===(i=this._backgroundSync)||void 0===i?void 0:i.loadMetadata(),{cacheContext:r,statManager:o}=d.Vault.of(this._iid);if(e===exports.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((e=>d.__awaiter(this,void 0,void 0,(function*(){n=e,s=this._filterUnderOffsetMessage(n.messages),this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE),yield this._loadUnsentMessages(),t._invokeResponse("local",null,s)})))).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("local",e,null)})).finally((()=>d.__awaiter(this,void 0,void 0,(function*(){var i,r;const{cacheContext:l}=d.Vault.of(this._iid);let h=!0,c=!0,u=!1;l.localCacheEnabled&&s.length>0&&a.range.includes(...s.map((e=>e.createdAt)))&&(!a.previousComplete&&n.prevMessagesCounta.range.bottom||n.nextMessagesCount{const t=Math.max(...s.map((e=>e.createdAt)));e._latestMessageInfo&&t>=e._latestMessageInfo.createdAt&&(c=!1)})),c?(h=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled}).then((({messages:e,isContinuousMessages:s,hasNext:n})=>{var i,a;const r=this._filterUnderOffsetMessage(e);this._messages=[],r.length>0?(this._setHasNextAndHaePrevious(r,n),this._syncRange.extends(...r.map((e=>e.createdAt))),s&&(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(r,d.CollectionEventSource.REQUEST_MESSAGE)):(this._hasPrevious=!1,this._hasNext=!1),t._invokeResponse("remote",null,r)})).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("remote",e,null)}))):(this._setHasNextAndHaePrevious(s),t._invokeResponse("remote",null,s)),l.localCacheEnabled&&o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:h?"cache_hit":"cache_miss",max_db_size:null!==(r=null===(i=l.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==r?r:0,message_init_policy:e,use_local_cache:l.localCacheEnabled,collection_id:this._key}}))}))));o.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}}))})))),t}loadPrevious(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasPrevious)return[];if(this._isLoadingPrevious)return a.warn("Messages are already fetching."),[];this._isLoadingPrevious=!0;const r=this.viewTop;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{prevLimit:this._prevResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._prevResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasPrevious=o.length>=this._prevResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a;const{cacheContext:l}=d.Vault.of(this._iid),h=yield this._getRemoteMessages(r,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:l.localCacheEnabled});o=this._filterUnderOffsetMessage(h.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasPrevious=o.length>=this._prevResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(n=l.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==a?a:0,use_local_cache:l.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingPrevious=!1,o}))}loadNext(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasNext)return[];if(this._isLoadingNext)return a.warn("Messages are already fetching."),[];this._isLoadingNext=!0;const r=this.viewBottom;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{nextLimit:this._nextResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._nextResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasNext=o.length>=this._nextResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a,l;const{cacheContext:h}=d.Vault.of(this._iid),c=yield this._getRemoteMessages(r,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled});o=this._filterUnderOffsetMessage(c.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&c.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.bottom))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasNext=null!==(n=c.hasNext)&&void 0!==n?n:o.length>=this._nextResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(l=null===(a=h.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==l?l:0,use_local_cache:h.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingNext=!1,o}))}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."});yield this._channelManager.removeFailedMessageFromCache(e);const t=this._unsentMessages.findIndex((t=>t.reqId===e));t>-1&&this._unsentMessages.splice(t,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._runIfHandleableWithGroupChannel((e=>{e.myMemberState!==exports.MemberState.NONE&&(this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}class qe extends Ge{keyOf(e){return e.messageId}constructor(e,t){super(e,Object.assign(Object.assign({},t),{channelManager:be.of(e)}))}initialize(e){return 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)})))),super.initialize(e)}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_activate(){const e=Object.create(null,{_activate:{get:()=>super._activate}});return d.__awaiter(this,void 0,void 0,(function*(){yield e._activate.call(this),yield 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)}))))}))}_addMessagesToView(e,t){const s=this._filterUnderOffsetMessage(e),n=[],i=[];for(const e of s)if(t===d.CollectionEventSource.SYNC_MESSAGE_FILL){if(e.messageId>0){if(Ne(this._messages,e)<0){Ne(this._unsentMessages,e)<0&&n.push(e);const t=Ue(this._messages,e);this._messages.splice(t,0,e)}}else if(e instanceof h.SendableMessage){Ne(this._unsentMessages,e)<0&&Ne(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e))}}else if(e.messageId>0){const t=Ne(this._messages,e);if(t<0){const t=Ne(this._unsentMessages,e);t<0?n.push(e):(this._unsentMessages.splice(t,1),i.push(e));const s=Ue(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 h.SendableMessage){const t=Ne(this._unsentMessages,e);t<0?Ne(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,a,r;const o={source:t};n.length>0&&(null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===s||s.call(e,o,this.channel,n)),i.length>0&&(null===(r=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===r||r.call(a,o,this.channel,i))}))))}_updateMessagesToView(e,t){const s=[],n=[],i=[];for(const t of e)if(t.messageId>0){const e=Ne(this._messages,t);if(e>=0)n.push(t),this._messages[e]=t;else{const e=Ne(this._unsentMessages,t);if(e>=0){const[s]=this._unsentMessages.splice(e,1);if(this.hasNext&&s)i.push(s);else{n.push(t);const e=Ue(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 h.SendableMessage){const e=Ne(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,r,o;const l={source:t};n.length>0?null===(a=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===a||a.call(e,l,this.channel,n):i.length>0?null===(o=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===o||o.call(r,l,this.channel,[],i):s.length>0&&this._addMessagesToView(s,t)})))),n}}const Be={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 je 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 ze 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 p(e,t))))}}var We,$e,Ke;exports.MutedMemberFilter=void 0,(We=exports.MutedMemberFilter||(exports.MutedMemberFilter={})).ALL="all",We.MUTED="muted",We.UNMUTED="unmuted",exports.MemberListOrder=void 0,($e=exports.MemberListOrder||(exports.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",$e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",exports.MemberStateFilter=void 0,(Ke=exports.MemberStateFilter||(exports.MemberStateFilter={})).ALL="all",Ke.JOINED="joined_only",Ke.INVITED="invited_only",Ke.INVITED_BY_FRIEND="invited_by_friend",Ke.INVITED_BY_NON_FRIEND="invited_by_non_friend";class Qe 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 je(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{members:n,token:i}=s.as(ze);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class Ye 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 Je extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t),this.channel.myMemberState=exports.MemberState.JOINED}}class Xe 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:c,operatorUserIds:u,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:c,cover_url:a,cover_file:r,access_code:o,operator_ids:u,message_survival_seconds:_})}}class Ze extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class et 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 tt 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 st 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 nt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.countPreference=t.count_preference}}class it extends d.APIRequestCommand{constructor(e){const{channelUrl:t,locale:s}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/reset_user_history`,this.params=d.deundefined({locale:s})}}class at extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}const rt=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}),ot=Object.assign(Object.assign({},h.UserMessageUpdateParamsDefault),{scheduledAt:void 0});class lt extends d.APIRequestCommand{constructor(e){var t,s;super();let n=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((e=>e.userId))));const{channelType:i,channelUrl:a,scheduledMessageId:r}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(i)}/${encodeURIComponent(a)}/scheduled_messages/${encodeURIComponent(r)}`,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:null===(t=e._thumbnails)||void 0===t?void 0:t.map((e=>h.Thumbnail.payloadify(e))),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:n,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}))}}class dt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.message=new h.FileMessage(e,t)}}class ht 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=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class ct 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 ut 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 _t 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 pt 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({userId:e,channelUrl:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`}}class gt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}var Ct,Et;exports.CountPreference=void 0,(Ct=exports.CountPreference||(exports.CountPreference={})).ALL="all",Ct.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Ct.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Ct.OFF="off",exports.HiddenState=void 0,(Et=exports.HiddenState||(exports.HiddenState={})).UNHIDDEN="unhidden",Et.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Et.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";class vt extends h.BaseChannel{constructor(e,t){var s,n,i,a,r,o,l,c,u,_,m,g,C,E,v,f,M,y,S;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._hasBotInfo={general:!1,ai:!1},this.isDistinct=!1,this.isSuper=!1,this.isBroadcast=!1,this.isExclusive=!1,this.isPublic=!1,this.isDiscoverable=!0,this.isChatNotification=!1,this.isAccessCodeRequired=!1,this.isPushEnabled=!1,this.unreadMessageCount=0,this.unreadMentionCount=0,this.totalUnreadReplyCount=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=d.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.lastPinnedMessage=null,this._latestMessageInfo=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.isChatNotification=null!==(l=t.is_chat_notification)&&void 0!==l&&l,this.isAccessCodeRequired=null!==(c=t.is_access_code_required)&&void 0!==c&&c,this.isPushEnabled=null!==(u=t.is_push_enabled)&&void 0!==u&&u,Array.isArray(t.members)&&this.members.push(...t.members.map((e=>new p(this._iid,e)))),this.memberCount=null!==(_=t.member_count)&&void 0!==_?_:0,this.joinedMemberCount=null!==(m=t.joined_member_count)&&void 0!==m?m:0,this.hiddenState=d.isEnumOf(exports.HiddenState,t.hidden_state)?t.hidden_state:exports.HiddenState.UNHIDDEN,this.messageOffsetTimestamp=null!==(g=t.ts_message_offset)&&void 0!==g?g:0,this.messageSurvivalSeconds=null!==(C=t.message_survival_seconds)&&void 0!==C?C:-1,this.lastMessage=t.last_message?h.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(d.MutedState,t.is_muted)?this.myMutedState=t.is_muted:d.isTypeOf("boolean",t.is_muted)?this.myMutedState=t.is_muted?d.MutedState.MUTED:d.MutedState.UNMUTED:this.myMutedState=d.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!==(E=t.user_last_read)&&void 0!==E?E: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!==(f=t.joined_ts)&&void 0!==f?f:0,this._updateUnreadCount(null!==(M=t.unread_message_count)&&void 0!==M?M:0,null!==(y=t.unread_mention_count)&&void 0!==y?y:0),this.totalUnreadReplyCount=null!==(S=t.total_unread_thread_message_count)&&void 0!==S?S:0,this.lastPinnedMessage=t.latest_pinned_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.latest_pinned_message)):null,t.latest_message&&(this._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),this._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot}}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}get hasBot(){return this._hasBotInfo.general}get hasAiBot(){return this._hasBotInfo.ai}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,total_unread_thread_message_count:e.totalUnreadReplyCount,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=>p.payloadify(e))),last_message:e.lastMessage?h.payloadifyMessage(e.lastMessage):null,inviter:e.inviter?d.User.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?h.payloadifyMessage(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))}_shouldUpdateLastMessageWith(e){if(e.silent)return!1;const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.lastMessageThreadingPolicy){case d.LastMessageThreadingPolicy.NONE:case d.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case d.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt{t.onChannelChanged&&t.onChannelChanged(e)})),s.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}}))}_shouldUpdateUnreadCountWith(e){const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.unreadCountThreadingPolicy){case d.UnreadCountThreadingPolicy.NONE:case d.UnreadCountThreadingPolicy.INCLUDE_REPLY:break;case d.UnreadCountThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}_updateLastMessage(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}_updateUnreadCount(e,t){if("number"==typeof e&&e>=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,Object.assign(e,this._serializeCachedMetaData())}))}createMessageCollection(e={}){return new qe(this._iid,Object.assign(Object.assign({},e),{channel:this}))}createMemberListQuery(e={}){return new Qe(this._iid,this.url,e)}createThreadedParentMessageListQuery(e={}){return new _.ThreadedParentMessageListQuery(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 p?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 h.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 h.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 h.ReadStatus(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.payloadify(n),ts:null!=e?e:0})}})),s}getDeliveryStatus(e=!0){const{sdkState:t}=d.Vault.of(this._iid);if(!t.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;const s={};return this.members.forEach((n=>{if(e||n.userId!==t.userId){const e=this._undeliveredMemberStateMap.get(n.userId);s[n.userId]=new m(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.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*(){return this._refresh()}))}_refresh(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t,dispatcher:s}=d.Vault.of(this._iid),n=new F({channelUrl:this.url}),i=yield t.send(n),{channel:a}=i.as(D);return this._update(a),e||s.dispatch(new P({channels:[a],context:{source:d.CollectionEventSource.REFRESH_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 P({channels:[this],context:{source:d.CollectionEventSource.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 P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}))}))}updateChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},Be),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 Xe(Object.assign({channelUrl:this.url},t)),a=yield n.send(i),{channel:r}=a.as(Ze);return this._update(r),s.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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,sessionManager:n}=d.Vault.of(this._iid),i=new re({channelUrl:this.url,userIds:e}),a=yield s.send(i),{channel:r}=a.as(oe);return this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:n.currentUser,invitees:[]},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 te({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(se);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},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 ie({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 Ye({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(Je);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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 de({channelUrl:this.url,userId:e.userId});return yield t.send(s),this.myMemberState=exports.MemberState.NONE,this}))}sendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=>{n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendMultipleFilesMessage(e){const t=new h.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=be.of(this._iid);this._updateLastMessage(e),n.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 h.SendableMessage){const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new d.UnsentMessageRemoveEventCommand({reqId:e.reqId,source:d.CollectionEventSource.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 ue(Object.assign({channelUrl:this.url,userId:n.userId},t)),r=yield i.send(a),{messageOffsetTimestamp:o}=r.as(_e);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 P({channels:[this],context:{source:d.CollectionEventSource.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 tt({channelUrl:this.url});return yield t.send(s),this.hiddenState=exports.HiddenState.UNHIDDEN,e.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 et({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 h.ReadRequestCommand({channelUrl:this.url}),i=yield s.send(n),{readStatus:a}=i.as(h.ReadEventCommand);if(this._updateUnreadMemberState(e.userId,a.readAt),this.unreadMessageCount>0||this.unreadMentionCount>0){this._updateUnreadCount(0,0);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 Me({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 me({channelUrl:this.url,time:this._typingStarted});yield 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 Ce({channelUrl:this.url,time:this._typingStarted});yield e.send(t)}}))}createScheduledUserMessage(e){e=Object.assign(Object.assign({},h.ScheduledUserMessageCreateParamsDefault),e),d.unless(h.validateScheduledUserMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=new h.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({},ot),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 ht(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({},h.ScheduledFileMessageCreateParamsDefault),e),d.unless(h.validateScheduledFileMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=Date.now(),s=this._generateRequestId(),n=new h.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({},rt),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 lt(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(dt);return r}))}cancelScheduledMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new ct({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 ut({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 mt({userId:e.userId,channelUrl:this.url}),n=yield t.send(s),{pushTriggerOption:i}=n.as(gt);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 _t({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),a=yield n.send(i),{pushTriggerOption:r}=a.as(pt);return this.myPushTriggerOption=r,t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 st({channelUrl:this.url,userId:s.userId,countPreference:e}),a=yield n.send(i),{countPreference:r}=a.as(nt);return this.myCountPreference=r,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),r}))}resetMyHistory(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t,sdkState:s}=d.Vault.of(this._iid),n=new it({channelUrl:this.url,locale:s.localeForChatbot}),i=yield t.send(n),{messageOffsetTimestamp:a}=i.as(at);return this.messageOffsetTimestamp=a,this.lastMessage&&this.lastMessage.createdAt{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),n._trigger(e)})),n}if(e.isFileMessage()){const s=this._validateFailedFileMessageHasFile(e,t);d.unless(s).throw(d.SendbirdError.invalidParameters);const n=h.createFileMessageCreateParamsFromFailedFileMessage(e,t),i=new h.MessageRequestHandler;return this._sendFileMessage(n,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{i._trigger(e)})).onFailed(((e,t)=>{i._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),i._trigger(e)})),i}if(e.isMultipleFilesMessage()){const t=e.messageParams,s=new h.MultipleFilesMessageRequestHandler;return this._sendMultipleFilesMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{s._trigger(e)})).onFailed(((e,t)=>{s._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),s._trigger(e)})).onFileUploaded(((e,t,n,i)=>{s._triggerOnFileUploaded(e,t,n,i)})),s}}copyMessage(e,t){if(d.unless(e instanceof h.BaseChannel&&t instanceof h.SendableMessage&&t.sendingStatus===d.SendingStatus.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(d.SendbirdError.invalidParameters),t.isUserMessage()){d.unless(!t.poll).throw(d.SendbirdError.notSupportedError);const s=h.createUserMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendUserMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isFileMessage()){const s=h.createFileMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendFileMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isMultipleFilesMessage()){if(e.isGroupChannel()){const s=h.createMultipleFilesMessageCreateParams(t),n=new h.MultipleFilesMessageRequestHandler;return e._sendMultipleFilesMessage(s,h.SendMessageRequestType.COPY).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})).onFileUploaded(((e,t,s,i)=>{n._triggerOnFileUploaded(e,t,s,i)})),n}throw d.SendbirdError.channelTypeNotSupportedError}}}exports.BaseMessageCollection=Ge,exports.DeliveryStatus=m,exports.GetTotalUnreadMessageCountRequestCommand=$,exports.GetTotalUnreadMessageCountResponseCommand=K,exports.GroupChannel=vt,exports.GroupChannelChangeLogsParamsDefault=f,exports.GroupChannelCountParamsDefault=y,exports.GroupChannelCreateParamsDefault=E,exports.GroupChannelEventSource=I,exports.GroupChannelFilter=g,exports.GroupChannelListQuery=fe,exports.GroupChannelManager=be,exports.Member=p,exports.MemberListQuery=Qe,exports.MessageCollection=qe,exports.MessageCollectionInitHandler=Ve,exports.Sync=xe,exports.TimeRange=Se,exports.TotalUnreadMessageCountParamsDefault=N,exports.indexOfMessage=Ne,exports.placeOfMessage=Ue,exports.shouldGiveEvent=x,exports.validateGroupChannelChangeLogsParams=M,exports.validateGroupChannelCountParams=S,exports.validateGroupChannelCreateParams=v,exports.validateTotalUnreadMessageCountParams=T; +var e,t,s,n,i,a,r,o,l,d=require("./__bundle-1a495950.cjs"),h=require("./__bundle-165fd6e1.cjs"),c=require("./__bundle-2ad218ff.cjs"),u=require("./__bundle-d3673ecc.cjs"),_=require("./__bundle-bfe2e997.cjs");exports.MemberState=void 0,(e=exports.MemberState||(exports.MemberState={})).NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left";class p 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 m 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.member=new d.User(this._iid,t.user),this.deliveryAt=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 g{constructor(e){var t,s,n,i,a,r,o,l,d,h,c,u,_,p,m;this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(t=null==e?void 0:e.includeEmpty)&&void 0!==t&&t,this.nicknameContainsFilter=null!==(s=null==e?void 0:e.nicknameContainsFilter)&&void 0!==s?s:null,this.nicknameStartsWithFilter=null!==(n=null==e?void 0:e.nicknameStartsWithFilter)&&void 0!==n?n:null,this.nicknameExactMatchFilter=null!==(i=null==e?void 0:e.nicknameExactMatchFilter)&&void 0!==i?i:null,this.channelNameContainsFilter=null!==(a=null==e?void 0:e.channelNameContainsFilter)&&void 0!==a?a:"",this.myMemberStateFilter=null!==(r=null==e?void 0:e.myMemberStateFilter)&&void 0!==r?r:exports.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(o=null==e?void 0:e.customTypesFilter)&&void 0!==o?o:null,this.channelUrlsFilter=null!==(l=null==e?void 0:e.channelUrlsFilter)&&void 0!==l?l:null,this.superChannelFilter=null!==(d=null==e?void 0:e.superChannelFilter)&&void 0!==d?d:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(h=null==e?void 0:e.publicChannelFilter)&&void 0!==h?h:exports.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(c=null==e?void 0:e.customTypeStartsWithFilter)&&void 0!==c?c:null,this.unreadChannelFilter=null!==(u=null==e?void 0:e.unreadChannelFilter)&&void 0!==u?u:exports.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==e?void 0:e.hiddenChannelFilter)&&void 0!==_?_:exports.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(p=null==e?void 0:e.includeFrozen)||void 0===p||p,(null==e?void 0:e.createdAfter)&&(this.createdAfter=e.createdAfter),(null==e?void 0:e.createdBefore)&&(this.createdBefore=e.createdBefore),this.includeMetaData=null===(m=null==e?void 0:e.includeMetaData)||void 0===m||m}_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 g;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("*")&&!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.ALL:if("none"===e.myMemberState)return!1;break;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!(this.createdAfter&&e.createdAtthis.createdBefore)}}class C 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 be.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 c.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!s&&t.name.localeCompare(e)<0||s&&t.name.localeCompare(e)>0)return!1;break;case c.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>e||s&&t.createdAte||s&&t.lastMessageUpdatedAtthis._deserialize(e)));return d.forEach((e=>{!n.includeMetaData&&e.cachedMetaData&&e._clearCachedMetaData(),this._channels.has(e.url)||this._channels.set(e.url,e)})),d}return[]}))}upsert(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];if(e.forEach((e=>{if(this._channels.has(e.url)){const n=this._channels.get(e.url);if(n._pinnedMessagesUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t){const{isUpdated:s}=n._updateCachedMetaData(e.cachedMetaData,t);s||Object.assign(e,{_cachedMetaData:void 0})}n._update(e),s.push(n)}else this._channels.set(e.url,e),s.push(e)})),this.localCacheEnabled){const e=[];for(let t=0;t0&&(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},v=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),f={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},M=e=>d.isArrayOf("string",e.customTypes,!0)&&d.isTypeOf("boolean",e.includeEmpty,!0)&&d.isTypeOf("boolean",e.includeFrozen,!0)&&d.isTypeOf("boolean",e.includeMetaData,!0)&&d.isTypeOf("boolean",e.includeChatNotification,!0),y={myMemberStateFilter:exports.MyMemberStateFilter.ALL},S=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 b={keys:[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,exports.UnreadItemKey.NONSUPER_INVITATION_COUNT,exports.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},N={channelCustomTypesFilter:void 0,superChannelFilter:exports.SuperChannelFilter.ALL},T=e=>d.isArrayOf("string",e.channelCustomTypesFilter,!0)&&d.isEnumOf(exports.SuperChannelFilter,e.superChannelFilter),U={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:d.MessageTypeFilter.ALL},I=Object.assign({},d.CollectionEventSource),x=e=>e.startsWith("EVENT_")||e===d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||e===d.CollectionEventSource.REFRESH_CHANNEL;class P extends d.BaseCommand{constructor({channels:e,context:t,isWebSocketEventComing:s=!1,ts:n}){super(),this.channels=e,this.context=t,this.isWebSocketEventComing=s,this.ts=n}}class R extends d.BaseCommand{constructor({channelUrls:e,context:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.context=t,this.isWebSocketEventComing=s}}class O{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 P){const{channels:s,context:i,isWebSocketEventComing:a}=n,r=s.filter((e=>e instanceof vt));if(i.source===d.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY||i.source===d.CollectionEventSource.EVENT_CHANNEL_HIDDEN)for(const e of r)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp);else{const s=e.filterOffsetChanged(r);for(const e of s)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp)}const o=yield e.upsert(r,n.ts);a||this._broadcastUpdateEvent(o,i)}else if(n instanceof R){const{channelUrls:i,context: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 c.DatabaseOpenCommand&&(yield e.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,t)}_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 w extends d.APIRequestCommand{constructor({userId:e,ts:t,token:s,filter:n,includeChatNotification:i=!1}){super();const{customTypes:a,includeEmpty:r,includeFrozen:o}=Object.assign(Object.assign({},f),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:a,show_empty:r,show_frozen:o,include_chat_notification:i}))}}class L extends d.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((s=>new vt(e,Object.assign(s,{ts:t.ts})))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next,this.ts=t.ts}}class F extends d.APIRequestCommand{constructor({channelUrl:e,isInternalCall:t,showLatestMessage:s}){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,show_latest_message:null!=s&&s}}}class D extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}const k={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0};class H 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:c,nicknameStartsWithFilter:u,nicknameExactMatchFilter:_,channelNameContainsFilter:p,channelUrlsFilter:m,customTypesFilter:g,customTypeStartsWithFilter:C,hiddenChannelFilter:E,metadataOrderKeyFilter:v,metadataKey:f,metadataValues:M,metadataValueStartsWith:y,includeFrozen:S,includeMetaData:A,searchFilter:b,userIdsFilter:N,includeChatNotification:T=!1,includeLeftChannel:U=!1,createdAfter:I,createdBefore:x}=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:k.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=a?a:k.includeEmpty,member_state_filter:null!=r?r:k.myMemberStateFilter,super_mode:null!=o?o:k.superChannelFilter,public_mode:null!=l?l:k.publicChannelFilter,unread_filter:null!=h?h:k.unreadChannelFilter,members_nickname_contains:c,members_nickname_startswith:u,members_nickname:_,name_contains:p,channel_urls:m,custom_types:g,custom_type_startswith:C,hidden_mode:E,metadata_order_key:v,metadata_key:f,metadata_values:M,metadata_value_startswith:y,show_frozen:S,show_metadata:A,include_chat_notification:T,include_left_channel:U,created_after:I,created_before:x}),b&&b.query&&b.fields&&(this.params.search_query=b.query,this.params.search_fields=b.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(this.params.members_include_in=N.userIds,this.params.query_type=N.queryType.toUpperCase()):this.params.members_exactly_in=N.userIds)}}class V 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 vt(e,t))))),this.ts=null!=i?i:0}}class G 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 q extends d.APIResponseCommand{constructor(e,t){super(e,t),this.groupChannelCount=t.group_channel_count}}class B extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{keys:s,customTypeFilters:n,customTypesFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_item_count`,this.params=d.deundefined({item_keys:s,custom_types:null!=i?i:n})}}class j 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 z extends d.APIRequestCommand{constructor({userId:e}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_channel_count`}}class W extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class $ extends d.APIRequestCommand{constructor({userId:e,filter:t,includeFeedChannel:s=!1}){super();const{channelCustomTypesFilter:n,superChannelFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_message_count`,this.params={super_mode:null!=i?i:exports.SuperChannelFilter.ALL,custom_types:n,include_feed_channel:s}}}class K extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count,this.unreadFeedCount=t.unread_feed_count}}class Q 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:J(t)},s&&(this.params.message_type=s)}}class Y extends d.APIResponseCommand{constructor(e,t){super(e,t),this.count=t.count}}const J=e=>{if(!e)return[];const t=[];return e.forEach((e=>{switch(e){case h.ScheduledStatus.PENDING:t.push(h.InternalScheduledStatus.PENDING);break;case h.ScheduledStatus.SENT:t.push(h.InternalScheduledStatus.IN_QUEUE),t.push(h.InternalScheduledStatus.SENT);break;case h.ScheduledStatus.CANCELED:t.push(h.InternalScheduledStatus.CANCELED);break;case h.ScheduledStatus.FAILED:t.push(h.InternalScheduledStatus.FAILED)}})),t};class X 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:c,isStrict:u,isEphemeral:_,accessCode:p,name:m,data:g,customType:C,messageSurvivalSeconds:E,invitedUserIds:v,operatorUserIds:f}=e;super(),this.method=d.APIRequestMethod.POST,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined({user_ids:[t,...null!=v?v:[]].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:c,strict:u,is_ephemeral:_,access_code:p,name:m,data:g,custom_type:C,operator_ids:f,message_survival_seconds:E})}}class Z extends d.APIResponseCommand{constructor(e,t){var s;super(e,t),this.channel=new vt(e,t),this.isCreated=null===(s=t.is_created)||void 0===s||s}}class ee 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 te 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 se extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class ne extends u.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 p(e,t))):[new p(e,s.data)]}}class ie 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 ae extends u.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 p(this._iid,s.data)}}class re 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 oe extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class le extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s),this.inviter=null;const{member_count:n=0,joined_member_count:i=0,inviter:a,invitees:r=[]}=s.data;this.memberCount=n,this.joinedMemberCount=i,a&&Object.keys(a).length>0&&(this.inviter=new d.User(e,a)),this.invitees=r.map((t=>new p(e,t)))}}class de 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 he extends u.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 p(e,r)}}const ce={hidePreviousMessages:!1,allowAutoUnhide:!0};class ue 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 _e extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}class pe 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 me extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPST",ackRequired:!1,payload:{channel_url:e,time:t}})}}class ge extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class Ce 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 ve extends d.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"MACK",ackRequired:!1,payload:{channel_url:e,msg_id:t}})}}class fe extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,u,_,p,m,g,C,E,v,f,M,y,S,A,b;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.includeChatNotification=!1,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=c.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.includeChatNotification=null!==(a=t.includeChatNotification)&&void 0!==a&&a,this.channelUrlsFilter=null!==(r=t.channelUrlsFilter)&&void 0!==r?r:null,this.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,this.customTypeStartsWithFilter=null!==(l=t.customTypeStartsWithFilter)&&void 0!==l?l:"",this.nicknameContainsFilter=null!==(d=t.nicknameContainsFilter)&&void 0!==d?d:null,this.nicknameStartsWithFilter=null!==(h=t.nicknameStartsWithFilter)&&void 0!==h?h:null,this.nicknameExactMatchFilter=null!==(u=t.nicknameExactMatchFilter)&&void 0!==u?u:null,this.channelNameContainsFilter=null!==(_=t.channelNameContainsFilter)&&void 0!==_?_:"",this.myMemberStateFilter=null!==(p=t.myMemberStateFilter)&&void 0!==p?p:exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=null!==(m=t.unreadChannelFilter)&&void 0!==m?m:exports.UnreadChannelFilter.ALL,this.superChannelFilter=null!==(g=t.superChannelFilter)&&void 0!==g?g:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(C=t.publicChannelFilter)&&void 0!==C?C:exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=null!==(E=t.hiddenChannelFilter)&&void 0!==E?E:exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter=null!==(v=t.searchFilter)&&void 0!==v?v:{fields:[],query:null},this.userIdsFilter=null!==(f=t.userIdsFilter)&&void 0!==f?f:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null!==(M=t.metadataKey)&&void 0!==M?M:null,this.metadataValues=null!==(y=t.metadataValues)&&void 0!==y?y:null,this.metadataOrderKeyFilter=null!==(S=t.metadataOrderKeyFilter)&&void 0!==S?S:null,this.metadataValueStartsWith=null!==(A=t.metadataValueStartsWith)&&void 0!==A?A:null,this.order=null!==(b=t.order)&&void 0!==b?b:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,t.createdAfter&&(this.createdAfter=t.createdAfter),t.createdBefore&&(this.createdBefore=t.createdBefore)}_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(c.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)&&d.isMilliSecondOf(this.createdAfter,!0)&&d.isMilliSecondOf(this.createdBefore,!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=be.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign({},this)),this.limit,d.CollectionEventSource.REQUEST_CHANNEL,!0);return this._token=s,this._hasNext=!!s,this._isLoading=!1,t}return[]}throw d.SendbirdError.invalidParameters}))}}class Me extends d.APIRequestCommand{constructor({channelUrl:e,userId:t}){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 ye extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"DLVR",s),this.channelUrl=s.channel_url,this.deliveredStateUpdate=s.updated}}class Se{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)}}const Ae={};class be extends u.BaseChannelManager{get _messageCache(){return h.MessageCache.of(this._iid)}get _unsentMessageCache(){return h.UnsentMessageCache.of(this._iid)}constructor(e,t){var s;super(e,Object.assign(Object.assign({},t),{channelType:d.ChannelType.GROUP})),this._leftChannels=new Map,this._disableMack=!1,this._markAsReadAllLastSentAt=0,this._disableMack=null!==(s=t.disableMack)&&void 0!==s&&s,this._groupChannelHandlers=new Map,this._groupChannelCache=new C(this._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),this._groupChannelBroadcast=new O({dispatcher:t.dispatcher,groupChannelCache:this._groupChannelCache,messageCache:h.MessageCache.of(this._iid),unsentMessageCache:h.UnsentMessageCache.of(this._iid)}),setInterval((()=>{for(const e of this._groupChannelCache.channels)e.invalidateTypingStatus()&&(this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.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).catch((e=>{if(d.isThrowingOutside(e)&&"foreground"===this._sdkState.appState)throw e})):e instanceof c.AutoResendRequestCommand?(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{message:t}=e,s=yield this.getChannel(t.channelUrl,!0);t instanceof h.UserMessage?s._autoResendUserMessage(t):t instanceof h.FileMessage&&s._autoResendFileMessage(t)}))})():e instanceof c.ReduceDBSizeEventCommand?this.reduceDBSize():e instanceof h.MessageThreadInfoUpdatedEventCommand&&(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{channelUrl:t,channelType:s,parentMessage:n}=e,i=new h.ThreadInfoUpdateEvent(this._iid,{channel_type:d.ChannelType.GROUP,channel_url:t,parent_message_id:n.messageId,thread_info:h.ThreadInfo.payloadify(n.threadInfo)});if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onThreadInfoUpdated&&t.onThreadInfoUpdated(e,i)}))))}}))})()})),Ae[e]||(Ae[e]=this)}static of(e){return Ae[e]||(Ae[e]=new be(e,d.Vault.of(e))),Ae[e]}static clear(e){Ae[e]&&delete Ae[e]}get handlers(){return[...this._groupChannelHandlers.values()]}buildGroupChannelFromSerializedData(e){const t=d.deserialize(e);return new vt(this._iid,vt.payloadify(t))}buildGroupChannelListQueryFromSerializedData(e){const t=d.deserialize(e);return new fe(this._iid,t)}buildMemberFromSerializedData(e){const t=d.deserialize(e);return new p(this._iid,p.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 e=h.MessageCache.of(this._iid),{cacheContext:t}=d.Vault.of(this._iid),{localCacheConfig:s,nestdb:n}=t;if(!t.localCacheEnabled||!n||n.state!=h.NestDBState.OPENED)return;const i=1024*s.maxSize*1024;let a=yield n.estimateUsage();if(ad.__awaiter(this,void 0,void 0,(function*(){const t=new ve(e);this._requestQueue.send(t)}))));const s=this._groupChannelCache.isCachedInMemory(e.channelUrl),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId,r=yield this.getChannel(e.channelUrl,!0),{useMemberInfoInMessage:o}=d.Vault.of(this._iid);if(e instanceof h.SendableMessage){for(const t of r.members)if(t.userId===e.sender.userId){o||(e.sender.nickname=t.nickname,e.sender.plainProfileUrl=t.plainProfileUrl,e.sender.metaData=t.metaData,e.sender.isBlockedByMe=t.isBlockedByMe);break}if(!o&&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._updateLastMessage(e),a||r._shouldUpdateUnreadCountWith(e)&&r._updateUnreadCount(r.unreadMessageCount+1,r.unreadMentionCount+(n?1:0))),i&&r._updateLastMessage(e),this._dispatcher.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),e.silent&&!a||d.runAsCallback((()=>d.__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.CollectionEventSource.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(u.UpdateAdminMessageEventCommand)),t){const{message:e,mentionCountChange:n}=t;if(e.threadInfo&&(e.threadInfo.unreadReplyCount=void 0),e.channelType===d.ChannelType.GROUP){const t=this._groupChannelCache.isCachedInMemory(e.channelUrl),i=yield this.getChannel(e.channelUrl,!0),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId;let r=!1;if(a){const t=e.sender,{currentUser:s}=this._sessionManager;s&&(s.nickname=t.nickname,s.plainProfileUrl=t.plainProfileUrl,s.metaData=t.metaData)}else i.isReadMessage(e)||0!==n&&!e.silent&&t&&(i._updateUnreadCount(i.unreadMessageCount,i.unreadMentionCount+n),r=!0);i._updateLastMessage(e)?r=!0:(null===(s=i.lastMessage)||void 0===s?void 0:s.isIdentical(e))&&(t?i._updateLastMessage(e)&&(r=!0):r=!0);let o=!1;i.lastPinnedMessage&&i.lastPinnedMessage.messageId===e.messageId&&(i.lastPinnedMessage=e,r=!0,o=!0),r&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:o?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}})),e.silent&&!a||d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)})))),o&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)}))))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageUpdated&&t.onMessageUpdated(i,e),n>0&&t.onMentionReceived&&t.onMentionReceived(i,e)}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:n,silent:i,messageCreatedAt:a,senderId:r}=e.as(d.DeleteMessageEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=r===this._sdkState.userId;i||s||a>0&&e.myLastRead0&&e._updateUnreadCount(e.unreadMessageCount-1,0),this._dispatcher.dispatch(new d.MessageRemoveEventCommand({messageIds:[n],source:d.CollectionEventSource.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(h.ReadEventCommand);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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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(ye),n=this._groupChannelCache.isCachedInMemory(t),i=yield this.getChannel(t,!0);n&&Object.keys(s).forEach((e=>{i._updateUndeliveredMemberState(e,s[e])})),Object.keys(s).some((e=>e!==this._sdkState.userId))&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:d.CollectionEventSource.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(u.ReactionEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=yield this.getMessageFromCache(n.messageId);s?s instanceof h.BaseMessage&&(s.applyReactionEvent(n),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new d.ReactionUpdateEventCommand({event:n,source:d.CollectionEventSource.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(u.ThreadInfoUpdateEventCommand);if(t.channelType===d.ChannelType.GROUP){const e=yield this.getChannel(t.channelUrl,!0),s=yield this.getMessageFromCache(t.targetMessageId);s?s instanceof h.BaseMessage&&(s.applyThreadInfoUpdateEvent(t),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new d.ThreadUpdateEventCommand({event:t,source:d.CollectionEventSource.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(u.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 P({channels:s,context:{source:d.CollectionEventSource.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(u.PollUpdateEventCommand);if(n&&i===d.ChannelType.GROUP){const e=yield this.getChannel(n,!0);this._dispatcher.dispatch(new d.PollUpdateInternalEventCommand({event:t,source:d.CollectionEventSource.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.CollectionEventSource.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(u.ChannelEventCommand);if(t.isGroupChannelEvent)switch(t.category){case u.ChannelEventCategory.CHANNEL_JOIN:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,members:a}=e.as(ne);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:a}})),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 u.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(ae);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((e=>e.userId===r.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 P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})):(this._markAsLeave(n),this._dispatcher.dispatch(new R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})))):this._dispatcher.dispatch(new P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})),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 u.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const s=yield this.getChannel(t.channelUrl,!0),{operators:n}=e.as(u.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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitees:r}=e.as(le);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:a,invitees:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserReceivedInvitation&&e.onUserReceivedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitee:r}=e.as(he);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})):this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}}))):this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.TYPING_START:case u.ChannelEventCategory.TYPING_END:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.TYPING_START,{user:i}=e.as(n?ge:Ee);s._updateTypingStatus(i,n?t.ts:0),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.USER_CHANNEL_MUTE:case u.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.USER_CHANNEL_MUTE,{user:i}=e.as(n?h.MuteUserEventCommand:h.UnmuteUserEventCommand);i.userId===this._sdkState.userId&&(s.myMutedState=n?d.MutedState.MUTED:d.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 P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_MUTED:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i}})),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 u.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 R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_BANNED,user:i}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserBanned&&e.onUserBanned(n,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_UNBAN:{const s=yield this.getChannel(t.channelUrl,!0),{user:n}=e.as(h.UnbanUserEventCommand);n.userId===this._sdkState.userId&&this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserUnbanned&&e.onUserUnbanned(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_FREEZE:case u.ChannelEventCategory.CHANNEL_UNFREEZE:{const s=yield this.getChannel(t.channelUrl,!0),{freeze:n}=e.as(h.FreezeEventCommand);s.isFrozen=n,this._dispatcher.dispatch(new P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_FROZEN:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_HIDE:{const s=yield this.getChannel(t.channelUrl,!0),{allowAutoUnhide:n,hidePreviousMessages:i,messageOffsetTimestamp:a}=e.as(pe);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onChannelHidden&&e.onChannelHidden(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_UNHIDE:{const e=yield this.getChannel(t.channelUrl,!0);e.hiddenState=exports.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_DELETED:{const e=yield this.getChannel(t.channelUrl,!0);this._dispatcher.dispatch(new R({channelUrls:[t.channelUrl],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const e=yield this.getChannelWithoutCache(t.channelUrl,!0);this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.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),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:n},ts:t.ts}))),i&&(s._upsertCachedMetaData(i,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:i},ts:t.ts}))),a&&(s._removeFromCachedMetaData(a,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:a},ts: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 u.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaCounterEventCommand);n&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:n}})),i&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:i}})),a&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:a}})),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 u.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:n,latestPinnedMessage:i,ts:a}=e.as(u.UpdatePinnedMessageEventCommand);a>s._pinnedMessagesUpdatedAt&&(s.pinnedMessageIds=null!=n?n:[],s.lastPinnedMessage=i,s._pinnedMessagesUpdatedAt=a,this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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(c.UserEventCommand);switch(t.category){case c.UserEventCategory.USER_BLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.block(e.userId,s.userId);break}case c.UserEventCategory.USER_UNBLOCK:{const{blocker:e,blockee:s}=c.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()}subscribeChannelEvent(e,t){this._groupChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._groupChannelBroadcast.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 F({channelUrl:e,isInternalCall:t}),n=yield this._requestQueue.send(s),{channel:i}=n.as(D);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=d.CollectionEventSource.REFRESH_CHANNEL,n=!1){return d.__awaiter(this,void 0,void 0,(function*(){try{const i=new F({channelUrl:e,isInternalCall:t,showLatestMessage:n}),a=yield this._requestQueue.send(i),{channel:r}=a.as(D);if(r.myMemberState===exports.MemberState.NONE)this._dispatcher.dispatch(new R({channelUrls:[r.url],context:{source:s}}));else{const e=yield this.upsertChannelsToCache([r]);this._dispatcher.dispatch(new P({channels:e,context:{source:s}}))}}catch(t){t.code!==d.SendbirdErrorCode.NON_AUTHORIZED&&t.code!==d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new R({channelUrls:[e],context:{source:s}}))}}))}getMyGroupChannels(e,t,s,n=d.CollectionEventSource.REQUEST_CHANNEL,i=!1){return d.__awaiter(this,void 0,void 0,(function*(){t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3));let a=!1;if(i){const{appInfo:e,cacheContext:t}=d.Vault.of(this._iid);t&&!t.localCacheEnabled&&(null==e?void 0:e.enabledChannelMemberShipHistory)&&(null==e?void 0:e.applicationAttributes.includes("left_user_view_support"))&&(a=!0)}const r=new H(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:e,limit:s,includeLeftChannel:i&&a})),o=yield this._requestQueue.send(r),{channels:l,token:h}=o.as(V);return this._dispatcher.dispatch(new P({channels:l,context:{source:n}})),{channels:l,token:h}}))}getMyGroupChannelChangeLogs(e,t,s=d.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return d.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},f),t);d.unless((d.isTypeOf("string",e)||d.isTypeOf("number",e))&&M(n)).throw(d.SendbirdError.invalidParameters);const i=new w(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(L),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,ts:h}=a;return r.length>0&&this._dispatcher.dispatch(new P({channels:r,context:{source:s},ts:h})),o.length>0&&this._dispatcher.dispatch(new R({channelUrls:o,context:{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({},y),e);d.unless(S(t)).throw(d.SendbirdError.invalidParameters);const s=new G({userId:this._sdkState.userId,filter:t}),n=yield this._requestQueue.send(s),{groupChannelCount:i}=n.as(q);return i}))}getUnreadItemCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},b),e);d.unless((e=>d.isArrayOf(exports.UnreadItemKey,e.keys)&&d.isArrayOf("string",e.customTypeFilters,!0)&&d.isArrayOf("string",e.customTypesFilter,!0))(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),{groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m}=a.as(j);return d.deundefined({groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,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 z({userId:e.userId}),n=yield t.send(s),{unreadCount:i}=n.as(W);return i}))}getTotalUnreadMessageCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},N),e);d.unless(T(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new $({userId:s.userId,filter:t}),a=yield n.send(i),{unreadCount:r}=a.as(K);return r}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},U),e);d.unless((e=>d.isTypeOf("string",e.channelUrl,!0)&&d.isArrayOf(h.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 Q(t),i=yield s.send(n),{count:a}=i.as(Y);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);return Object.keys(t.customTypes).forEach((s=>{e+=t.customTypes[s]})),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(v(t)).throw(d.SendbirdError.invalidParameters),t.isPublic||(t.accessCode=void 0);const s=new X(Object.assign({userId:this._sdkState.userId},t)),n=yield this._requestQueue.send(s),{channel:i}=n.as(Z);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 ee({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 ee({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()}))}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){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})}))}getCachedMessageCountBetween(e,t,s,n){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.countBetween(e,t,new Se({top:s,bottom:n}))}))}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])}))}}const Ne=(e,t)=>t instanceof h.SendableMessage?e.findIndex((e=>e instanceof h.SendableMessage&&t.isIdentical(e))):e.findIndex((e=>e.isIdentical(t))),Te=(e,t)=>e.findIndex((e=>e instanceof h.BaseMessage?e.messageId===t:e instanceof h.NotificationMessage?e.notificationId===t:void 0)),Ue=(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};var Ie;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Ie||(Ie={}));class xe extends d.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=Ie.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===Ie.IDLE}get isRunning(){return this._state===Ie.RUNNING}get isDone(){return this._state===Ie.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 xe(_,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u,_;const p={hasNext:!0,nextToken:0};if(this._prevSyncLoopCount++,yield this.loadMetadata(),r.debug("message background prev sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.top),null===(n=this._metadata)||void 0===n?void 0:n.previousComplete)p.hasNext=!1;else try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(l=null===(a=this._metadata)||void 0===a?void 0:a.range)||void 0===l?void 0:l.top)?this._metadata.range.top:e,{prevResultSize:this._limit,nextResultSize:0,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(c=this._metadata)||void 0===c?void 0:c.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}p.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(p.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.lengthd.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u;const _={hasNext:!0,nextToken:0};yield this.loadMetadata(),r.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom);try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(a=null===(n=this._metadata)||void 0===n?void 0:n.range)||void 0===a?void 0:a.bottom)?this._metadata.range.bottom:e,{prevResultSize:0,nextResultSize:this._limit,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(l=this._metadata)||void 0===l?void 0:l.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}_.hasNext=s.length>=this._limit,this._metadata&&(_.nextToken=this._metadata.range.bottom),r.debug("message background next sync progress",_),yield this.saveMetadata()}catch(e){throw r.debug("message background next sync error",e),e}finally{o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:t.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(u=null===(c=i.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==u?u:0,use_local_cache:i.localCacheEnabled,starting_point:0,message_init_policy:""}}))}return _}))))})))),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){return Pe[e]||(Pe[e]={}),Pe[e][t.url]||(Pe[e][t.url]=new Re({_iid:e,channel:t})),Pe[e][t.url].ref++,Pe[e][t.url]}static clear(e,t){Pe[e]&&Pe[e][t]&&(Pe[e][t].close(),delete Pe[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 Se({})}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(){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?{range:new Se(t.range),previousComplete:t.previousComplete}:{range:new Se({}),previousComplete:!1}}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(e=Date.now()){var t,s,n,i;const{logger:a,sessionManager:r,cacheContext:o}=d.Vault.of(this._iid);o.localCacheEnabled&&r.session.hasSession&&(a.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(s=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==s?s:e),this._nextSync.start(null!==(i=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==i?i:e))}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid][this._channel.url])}}const Oe={};class we{constructor({_iid:e,channel:t,includeParams:s}){this.ref=0,this._iid=e,this._channel=t,this._includeParams=s;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}/message/changelogs.meta`);const l=((e,t)=>`sendbird:${e}@groupchannel/${t}/message/changelogs`)(i.userId,this._channel.url);this._sync=new xe(l,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};yield this.loadMetadata(),n.debug("message changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=h.MessageManager.of(this._iid),{updatedMessages:s,deletedMessageIds:i,hasMore:a,token:r}=yield e.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:d.ReplyType.ALL},this._includeParams),d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);t.hasNext=a,t.nextToken=r,(s.length>0||i.length>0)&&this._metadata&&(this._metadata.token=r),n.debug("message changelog sync progress",t),yield this.saveMetadata()}catch(e){throw n.debug("message 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 Oe[e]||(Oe[e]={}),Oe[e][t.url]||(Oe[e][t.url]=new we({_iid:e,channel:t,includeParams:s})),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])}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,sessionManager:t}=d.Vault.of(this._iid);t.session.hasSession&&(e.debug("message changelog sync resume()"),this._sync.start(0))}pause(){const{logger:e}=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 Oe[this._iid][this._channel.url])}}const Le={};class Fe{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 xe(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=d.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 Le[e]||(Le[e]={}),Le[e][t.url]||(Le[e][t.url]=new Fe({_iid:e,channel:t,hasPollMessage:s})),Le[e][t.url].ref++,Le[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 Le[this._iid][this._channel.url])}}class De extends d.APIRequestCommand{constructor(e){var t,s,n,i,a,r,o,l,h,c;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_reply_type:null!==(i=e.replyType)&&void 0!==i?i:d.ReplyType.NONE,include_reactions:null===(a=e.includeReactions)||void 0===a||a,include_meta_array:null===(r=e.includeMetaArray)||void 0===r||r,include_thread_info:null===(o=e.includeThreadInfo)||void 0===o||o,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(c=e.showSubchannelMessagesOnly)&&void 0!==c&&c,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=>h.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=>h.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 He={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};exports.MessageCollectionInitPolicy=void 0,(exports.MessageCollectionInitPolicy||(exports.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";class Ve{constructor(){this._onCacheResult=d.noop,this._onApiResult=d.noop}_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 Ge{keyOf(e){return 0}get changelogIncludeParams(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}_postprocessChannelUpdateEvent(e,t){}_postprocessChannelRemoveEvent(e){}_postprocessMessageUpdateEvent(e,t){}_postprocessMessageRemoveEvent(e){}constructor(e,{filter:t,startingPoint:s,limit:n,prevResultLimit:i,nextResultLimit:a,channel:r,channelManager:o,disableBackgroundSync:l=!1}){this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key=`mc-${d.uuid()}`,this._isDisposed=!1,this.filter=null!=t?t:new h.MessageFilter,this._channel=r,this._syncRange=new Se({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=n||h.DEFAULT_MESSAGE_LIMIT,this._prevResultLimit=null!=i?i:Math.floor(this._limit/2),this._nextResultLimit=null!=a?a:Math.floor(this._limit/2),this._channelManager=o;const{statManager:c}=d.Vault.of(this._iid);this._channelManager.subscribeChannelEvent(this._key,{onUpdate:(e,t)=>{const{source:s}=t,n=e.findIndex((e=>e.isIdentical(this.channel)));n>=0&&(this._replaceChannelOfCollection(e[n]),this.channel._runIfHandleableWithGroupChannel((e=>{switch(s){case d.CollectionEventSource.EVENT_CHANNEL_UPDATED:{let t=!1;for(let s=0;s=e.messageOffsetTimestamp){t=!0;const e=s;if(e>0){const t=this._messages.splice(0,e);this._removeMessagesFromView(t.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!t&&this._messages.length>0&&this._removeMessagesFromView(this._messages.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break}case d.CollectionEventSource.EVENT_CHANNEL_UNMUTED:{const{sdkState:e}=d.Vault.of(this._iid),{user:s}=t;e.userId===s.userId&&this._clearCheckMyMutedTimer();break}case d.CollectionEventSource.EVENT_CHANNEL_MUTED:{const{sdkState:s}=d.Vault.of(this._iid),{user:n}=t;s.userId===n.userId&&-1!==e._myMutedRemainingTime&&this._startCheckMyMutedTimer(e._myMutedRemainingTime);break}case d.CollectionEventSource.EVENT_CHANNEL_LEFT:e.isPublic&&this._clearCheckMyMutedTimer()}d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;x(s)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel)}))))})),this._postprocessChannelUpdateEvent(e[n],s))},onRemove:(e,t)=>{const s=e.indexOf(this.channel.url);s>=0&&(this._clearCheckMyMutedTimer(),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url)})))),this._postprocessChannelRemoveEvent(e[s]))}}),this._channelManager.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(this.keyOf(t)));if(d.shouldGiveEvent(t)){if(s.length>0)switch(t){case d.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case d.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case d.CollectionEventSource.EVENT_MESSAGE_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:this._updateMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:this._addMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_RECEIVED:this.hasNext||this._addMessagesToView(s,t);break;case d.CollectionEventSource.SYNC_MESSAGE_FILL:this._addMessagesToView(s,t)}n.length>0&&this._removeMessagesFromView(n,t)}this._postprocessMessageUpdateEvent(e,t)},onRemove:(e,t)=>{this._removeMessagesFromView(e,t),this._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:(e,t)=>{this._applyReactionEventToView(e,t)},onThreadInfoUpdate:(e,t)=>{this._applyThreadInfoEventToView(e,t)}});const{cacheContext:u,dispatcher:_,messageBackgroundSyncThrottleController:p}=d.Vault.of(this._iid);this._channel._updateMessageCollectionLastAccessedAt(),_.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Re.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=we.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Fe.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new xe(this._key,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.min(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:i.length>=this._prevResultLimit&&this.viewTopd.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.max(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:!(i.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>e,nextToken:this._syncRange.bottom}}return u.localCacheEnabled&&c.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(s=u.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==n?n:0,use_local_cache:u.localCacheEnabled,starting_point:0,message_init_policy:""}})),{hasNext:!1,nextToken:0}}))))})))),this._connectionEventContext=_.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)switch(e.stateType){case d.ConnectionStateType.CONNECTED:d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){this._activate()}))));break;case d.ConnectionStateType.LOGOUT:this.dispose();break;default:this._clearCheckMyMutedTimer(),this._prevFill.stop(),this._nextFill.stop()}}))}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)}_activate(){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:e}=d.Vault.of(this._iid);e.debug("check huge gap"),this._checkHugeGap(),yield this._refreshChannel(d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS)}))}_replaceChannelOfCollection(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}_shouldStartBackgroundSync(){const{cacheContext:e}=d.Vault.of(this._iid);return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}_setBaseMessageCollectionHandler(e){this._handler=e}_filterUnderOffsetMessage(e){return e}_updateChildMessagesInView(e){const t=[];return this._messages.forEach((s=>{s instanceof h.BaseMessage&&s.parentMessageId===e.messageId&&s.applyParentMessage(e)&&t.push(s)})),t}_updatePollsToView(e,t){const s=[];for(const t of e){const e=Te(this._messages,t.messageId);if(e>=0){const n=this._messages[e];n.isUserMessage()&&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,n;const i={source:t};s.length>0&&(null===(n=(e=this._handler).onMessagesUpdated)||void 0===n||n.call(e,i,this.channel,s))})))),s}_applyPollUpdateEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyPollVoteEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyReactionEventToView(e,t){const s=Te(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyReactionEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_applyThreadInfoEventToView(e,t){const s=Te(this._messages,e.targetMessageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyThreadInfoUpdateEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_removeMessagesFromView(e,t){const s=[],n=[];for(const t of e){const e=this._messages.findIndex((e=>this.keyOf(e)===t));if(e>=0){const t=this._messages[e];s.push(this.keyOf(t)),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,i;const a={source:t};null===(i=null===(e=this._handler)||void 0===e?void 0:e.onMessagesDeleted)||void 0===i||i.call(e,a,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*(){let i=[];n&&(i=yield this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter));const a=t>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,t,!1):[],r=s>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1):[];return{messages:[...i,...a,...r].sort(((e,t)=>t.createdAt-e.createdAt)),prevMessagesCount:a.length,nextMessagesCount:r.length}}))}_getRemoteMessages(e,{prevLimit:t=0,nextLimit:s=0,source:n=d.CollectionEventSource.REQUEST_MESSAGE,reverse:i=!1,checkingHasNext:a=!1,checkingContinuousMessages:r=!1}){return d.__awaiter(this,void 0,void 0,(function*(){const o=h.MessageManager.of(this._iid);return t>0||s>0?yield o._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,d.undefineNullProps(Object.assign(Object.assign(Object.assign({},this.filter),He),{isInclusive:!0,reverse:i,prevResultSize:t,nextResultSize:s})),n,a,r):{messages:[],isContinuousMessages:!1}}))}_checkHugeGap(){var e,t,s,n,i;return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r,cacheContext:o,statManager:l,logger:h}=d.Vault.of(this._iid);if(this._messages.length>0){const s=this._syncRange.top,n=this.viewTop,i=this._syncRange.bottom,c=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,n,s),_=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,i,c);try{yield d.asyncRetry((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t=new De(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:s,prevCount:u,nextStart:i,nextEnd:c,nextCount:_,checkingContinuousMessages:o.localCacheEnabled},this.filter),He)),l=yield r.send(t),{isHugeGap:h,prevMessages:p=[],prevHasMore:m,isContinuousPrevMessages:g,nextMessages:C=[],nextHasmore:E,isContinuousNextMessages:v}=l.as(ke);if(h)d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected()}))));else{const t=this.viewTop,s=this.viewBottom,n=Math.min(Number.MAX_SAFE_INTEGER,t,...p.map((e=>e.createdAt))),i=Math.max(0,s,...C.map((e=>e.createdAt)));a.dispatch(new d.MessageUpdateEventCommand({messages:p,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),a.dispatch(new d.MessageUpdateEventCommand({messages:C,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(n,i),(g||v)&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(n,i)),m&&this._prevFill.start(n),E&&this._nextFill.start(i)}}))),1)}catch(e){h.debug("Failed HugeGap Check ",e)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}else{const e=Date.now();try{const{messages:t,isContinuousMessages:n,hasNext:i}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:o.localCacheEnabled});if(t.length>0){const a=t.map((e=>e.createdAt));let r=0,o=0;for(let t=0;t=e&&o++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=i?i:o>=this._nextResultLimit,this._syncRange.extends(...a),n&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(t,d.CollectionEventSource.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)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(n=o.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==i?i:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}}))}_loadUnsentMessages(){return d.__awaiter(this,void 0,void 0,(function*(){this._unsentMessages=yield this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)}))}_hasPollMessage(){return d.__awaiter(this,void 0,void 0,(function*(){return(yield this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)).length>0}))}_refreshChannel(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:s}=d.Vault.of(this._iid);try{yield this._channelManager.refreshChannel(this.channel.url,!0,e,t)}catch(e){s.warn("Failed to refresh channel",e)}}))}_startCheckMyMutedTimer(e){this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((()=>d.__awaiter(this,void 0,void 0,(function*(){this._checkMyMutedStateTimer=void 0;let e=!0;try{e=!(yield this._channel.getMyMutedInfo()).isMuted}catch(t){e=!0}finally{if(e){const{sessionManager:e}=d.Vault.of(this._iid);this.channel._runIfHandleableWithGroupChannel((t=>{var s,n;t.myMutedState=d.MutedState.UNMUTED;const i={source:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:e.currentUser};null===(n=null===(s=this._handler)||void 0===s?void 0:s.onChannelUpdated)||void 0===n||n.call(s,i,this.channel)}))}}}))),e+1e3)}_clearCheckMyMutedTimer(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}_setHasNextAndHasPrevious(e,t){const s=e.map((e=>e.createdAt));let n=0,i=0;for(let e=0;ethis._startingPoint&&i++}this._hasPrevious=n>=this._prevResultLimit,this._hasNext=null!=t?t:i>=this._nextResultLimit}initialize(e){const t=new Ve;this._messages=[],this._unsentMessages=[],this._syncRange=new Se({}),this._hasNext=!0,this._hasPrevious=!0;let s=[],n={messages:[],prevMessagesCount:0,nextMessagesCount:0};return d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var i;const a=yield null===(i=this._backgroundSync)||void 0===i?void 0:i.loadMetadata(),{cacheContext:r,statManager:o}=d.Vault.of(this._iid);if(e===exports.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((e=>d.__awaiter(this,void 0,void 0,(function*(){n=e,s=this._filterUnderOffsetMessage(n.messages),this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE),yield this._loadUnsentMessages(),t._invokeResponse("local",null,s)})))).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("local",e,null)})).finally((()=>d.__awaiter(this,void 0,void 0,(function*(){var i,r;const{cacheContext:l}=d.Vault.of(this._iid);let h=!0,c=!0,u=!1;l.localCacheEnabled&&s.length>0&&a.range.includes(...s.map((e=>e.createdAt)))&&(!a.previousComplete&&n.prevMessagesCounta.range.bottom||n.nextMessagesCount{const t=Math.max(...s.map((e=>e.createdAt)));e._latestMessageInfo&&t>=e._latestMessageInfo.createdAt&&(c=!1)})),c?(h=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled}).then((({messages:e,isContinuousMessages:s,hasNext:n})=>{var i,a;const r=this._filterUnderOffsetMessage(e);this._messages=[],r.length>0?(this._setHasNextAndHasPrevious(r,n),this._syncRange.extends(...r.map((e=>e.createdAt))),s&&(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(r,d.CollectionEventSource.REQUEST_MESSAGE)):(this._hasPrevious=!1,this._hasNext=!1),t._invokeResponse("remote",null,r)})).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(s),t._invokeResponse("remote",null,s)),l.localCacheEnabled&&o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:h?"cache_hit":"cache_miss",max_db_size:null!==(r=null===(i=l.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==r?r:0,message_init_policy:e,use_local_cache:l.localCacheEnabled,collection_id:this._key}}))}))));o.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}}))})))),t}loadPrevious(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasPrevious)return[];if(this._isLoadingPrevious)return a.warn("Messages are already fetching."),[];this._isLoadingPrevious=!0;const r=this.viewTop;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{prevLimit:this._prevResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._prevResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasPrevious=o.length>=this._prevResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a;const{cacheContext:l}=d.Vault.of(this._iid),h=yield this._getRemoteMessages(r,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:l.localCacheEnabled});o=this._filterUnderOffsetMessage(h.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasPrevious=o.length>=this._prevResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(n=l.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==a?a:0,use_local_cache:l.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingPrevious=!1,o}))}loadNext(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasNext)return[];if(this._isLoadingNext)return a.warn("Messages are already fetching."),[];this._isLoadingNext=!0;const r=this.viewBottom;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{nextLimit:this._nextResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._nextResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasNext=o.length>=this._nextResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a,l;const{cacheContext:h}=d.Vault.of(this._iid),c=yield this._getRemoteMessages(r,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled});o=this._filterUnderOffsetMessage(c.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&c.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.bottom))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasNext=null!==(n=c.hasNext)&&void 0!==n?n:o.length>=this._nextResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(l=null===(a=h.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==l?l:0,use_local_cache:h.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingNext=!1,o}))}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."});yield this._channelManager.removeFailedMessageFromCache(e);const t=this._unsentMessages.findIndex((t=>t.reqId===e));t>-1&&this._unsentMessages.splice(t,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._runIfHandleableWithGroupChannel((e=>{e.myMemberState!==exports.MemberState.NONE&&(this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}class qe extends Ge{keyOf(e){return e.messageId}constructor(e,t){super(e,Object.assign(Object.assign({},t),{channelManager:be.of(e)}))}initialize(e){return 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)})))),super.initialize(e)}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_activate(){const e=Object.create(null,{_activate:{get:()=>super._activate}});return d.__awaiter(this,void 0,void 0,(function*(){yield e._activate.call(this),yield 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)}))))}))}_addMessagesToView(e,t){const s=this._filterUnderOffsetMessage(e),n=[],i=[];for(const e of s)if(t===d.CollectionEventSource.SYNC_MESSAGE_FILL){if(e.messageId>0){if(Ne(this._messages,e)<0){Ne(this._unsentMessages,e)<0&&n.push(e);const t=Ue(this._messages,e);this._messages.splice(t,0,e)}}else if(e instanceof h.SendableMessage){Ne(this._unsentMessages,e)<0&&Ne(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e))}}else if(e.messageId>0){const t=Ne(this._messages,e);if(t<0){const t=Ne(this._unsentMessages,e);t<0?n.push(e):(this._unsentMessages.splice(t,1),i.push(e));const s=Ue(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 h.SendableMessage){const t=Ne(this._unsentMessages,e);t<0?Ne(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,a,r;const o={source:t};n.length>0&&(null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===s||s.call(e,o,this.channel,n)),i.length>0&&(null===(r=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===r||r.call(a,o,this.channel,i))}))))}_updateMessagesToView(e,t){const s=[],n=[],i=[];for(const t of e)if(t.messageId>0){const e=Ne(this._messages,t);if(e>=0)n.push(t),this._messages[e]=t;else{const e=Ne(this._unsentMessages,t);if(e>=0){const[s]=this._unsentMessages.splice(e,1);if(this.hasNext&&s)i.push(s);else{n.push(t);const e=Ue(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 h.SendableMessage){const e=Ne(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,r,o;const l={source:t};n.length>0?null===(a=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===a||a.call(e,l,this.channel,n):i.length>0?null===(o=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===o||o.call(r,l,this.channel,[],i):s.length>0&&this._addMessagesToView(s,t)})))),n}}const Be={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 je 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 ze 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 p(e,t))))}}var We,$e,Ke;exports.MutedMemberFilter=void 0,(We=exports.MutedMemberFilter||(exports.MutedMemberFilter={})).ALL="all",We.MUTED="muted",We.UNMUTED="unmuted",exports.MemberListOrder=void 0,($e=exports.MemberListOrder||(exports.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",$e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",exports.MemberStateFilter=void 0,(Ke=exports.MemberStateFilter||(exports.MemberStateFilter={})).ALL="all",Ke.JOINED="joined_only",Ke.INVITED="invited_only",Ke.INVITED_BY_FRIEND="invited_by_friend",Ke.INVITED_BY_NON_FRIEND="invited_by_non_friend";class Qe 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 je(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{members:n,token:i}=s.as(ze);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class Ye 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 Je extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t),this.channel.myMemberState=exports.MemberState.JOINED}}class Xe 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:c,operatorUserIds:u,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:c,cover_url:a,cover_file:r,access_code:o,operator_ids:u,message_survival_seconds:_})}}class Ze extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class et 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 tt 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 st 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 nt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.countPreference=t.count_preference}}class it extends d.APIRequestCommand{constructor(e){const{channelUrl:t,locale:s}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/reset_user_history`,this.params=d.deundefined({locale:s})}}class at extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}const rt=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}),ot=Object.assign(Object.assign({},h.UserMessageUpdateParamsDefault),{scheduledAt:void 0});class lt extends d.APIRequestCommand{constructor(e){var t,s;super();let n=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((e=>e.userId))));const{channelType:i,channelUrl:a,scheduledMessageId:r}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(i)}/${encodeURIComponent(a)}/scheduled_messages/${encodeURIComponent(r)}`,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:null===(t=e._thumbnails)||void 0===t?void 0:t.map((e=>h.Thumbnail.payloadify(e))),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:n,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}))}}class dt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.message=new h.FileMessage(e,t)}}class ht 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=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class ct 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 ut 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 _t 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 pt 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({userId:e,channelUrl:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`}}class gt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}var Ct,Et;exports.CountPreference=void 0,(Ct=exports.CountPreference||(exports.CountPreference={})).ALL="all",Ct.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Ct.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Ct.OFF="off",exports.HiddenState=void 0,(Et=exports.HiddenState||(exports.HiddenState={})).UNHIDDEN="unhidden",Et.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Et.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";class vt extends h.BaseChannel{constructor(e,t){var s,n,i,a,r,o,l,c,u,_,m,g,C,E,v,f,M,y,S;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._hasBotInfo={general:!1,ai:!1},this.isDistinct=!1,this.isSuper=!1,this.isBroadcast=!1,this.isExclusive=!1,this.isPublic=!1,this.isDiscoverable=!0,this.isChatNotification=!1,this.isAccessCodeRequired=!1,this.isPushEnabled=!1,this.unreadMessageCount=0,this.unreadMentionCount=0,this.totalUnreadReplyCount=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=d.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.lastPinnedMessage=null,this._latestMessageInfo=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.isChatNotification=null!==(l=t.is_chat_notification)&&void 0!==l&&l,this.isAccessCodeRequired=null!==(c=t.is_access_code_required)&&void 0!==c&&c,this.isPushEnabled=null!==(u=t.is_push_enabled)&&void 0!==u&&u,Array.isArray(t.members)&&this.members.push(...t.members.map((e=>new p(this._iid,e)))),this.memberCount=null!==(_=t.member_count)&&void 0!==_?_:0,this.joinedMemberCount=null!==(m=t.joined_member_count)&&void 0!==m?m:0,this.hiddenState=d.isEnumOf(exports.HiddenState,t.hidden_state)?t.hidden_state:exports.HiddenState.UNHIDDEN,this.messageOffsetTimestamp=null!==(g=t.ts_message_offset)&&void 0!==g?g:0,this.messageSurvivalSeconds=null!==(C=t.message_survival_seconds)&&void 0!==C?C:-1,this.lastMessage=t.last_message?h.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(d.MutedState,t.is_muted)?this.myMutedState=t.is_muted:d.isTypeOf("boolean",t.is_muted)?this.myMutedState=t.is_muted?d.MutedState.MUTED:d.MutedState.UNMUTED:this.myMutedState=d.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!==(E=t.user_last_read)&&void 0!==E?E: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!==(f=t.joined_ts)&&void 0!==f?f:0,this._updateUnreadCount(null!==(M=t.unread_message_count)&&void 0!==M?M:0,null!==(y=t.unread_mention_count)&&void 0!==y?y:0),this.totalUnreadReplyCount=null!==(S=t.total_unread_thread_message_count)&&void 0!==S?S:0,this.lastPinnedMessage=t.latest_pinned_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.latest_pinned_message)):null,t.latest_message&&(this._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),this._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot}}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}get hasBot(){return this._hasBotInfo.general}get hasAiBot(){return this._hasBotInfo.ai}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,total_unread_thread_message_count:e.totalUnreadReplyCount,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=>p.payloadify(e))),last_message:e.lastMessage?h.payloadifyMessage(e.lastMessage):null,inviter:e.inviter?d.User.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?h.payloadifyMessage(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))}_shouldUpdateLastMessageWith(e){if(e.silent)return!1;const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.lastMessageThreadingPolicy){case d.LastMessageThreadingPolicy.NONE:case d.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case d.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt{t.onChannelChanged&&t.onChannelChanged(e)})),s.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}}))}_shouldUpdateUnreadCountWith(e){const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.unreadCountThreadingPolicy){case d.UnreadCountThreadingPolicy.NONE:case d.UnreadCountThreadingPolicy.INCLUDE_REPLY:break;case d.UnreadCountThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}_updateLastMessage(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}_updateUnreadCount(e,t){if("number"==typeof e&&e>=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,Object.assign(e,this._serializeCachedMetaData())}))}createMessageCollection(e={}){return new qe(this._iid,Object.assign(Object.assign({},e),{channel:this}))}createMemberListQuery(e={}){return new Qe(this._iid,this.url,e)}createThreadedParentMessageListQuery(e={}){return new _.ThreadedParentMessageListQuery(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 p?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 h.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 h.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 h.ReadStatus(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.payloadify(n),ts:null!=e?e:0})}})),s}getDeliveryStatus(e=!0){const{sdkState:t}=d.Vault.of(this._iid);if(!t.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;const s={};return this.members.forEach((n=>{if(e||n.userId!==t.userId){const e=this._undeliveredMemberStateMap.get(n.userId);s[n.userId]=new m(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.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*(){return this._refresh()}))}_refresh(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t,dispatcher:s}=d.Vault.of(this._iid),n=new F({channelUrl:this.url}),i=yield t.send(n),{channel:a}=i.as(D);return this._update(a),e||s.dispatch(new P({channels:[a],context:{source:d.CollectionEventSource.REFRESH_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 P({channels:[this],context:{source:d.CollectionEventSource.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 P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}))}))}updateChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},Be),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 Xe(Object.assign({channelUrl:this.url},t)),a=yield n.send(i),{channel:r}=a.as(Ze);return this._update(r),s.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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,sessionManager:n}=d.Vault.of(this._iid),i=new re({channelUrl:this.url,userIds:e}),a=yield s.send(i),{channel:r}=a.as(oe);return this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:n.currentUser,invitees:[]},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 te({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(se);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},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 ie({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 Ye({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(Je);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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 de({channelUrl:this.url,userId:e.userId});return yield t.send(s),this.myMemberState=exports.MemberState.NONE,this}))}sendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=>{n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendMultipleFilesMessage(e){const t=new h.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=be.of(this._iid);this._updateLastMessage(e),n.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 h.SendableMessage){const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new d.UnsentMessageRemoveEventCommand({reqId:e.reqId,source:d.CollectionEventSource.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 ue(Object.assign({channelUrl:this.url,userId:n.userId},t)),r=yield i.send(a),{messageOffsetTimestamp:o}=r.as(_e);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 P({channels:[this],context:{source:d.CollectionEventSource.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 tt({channelUrl:this.url});return yield t.send(s),this.hiddenState=exports.HiddenState.UNHIDDEN,e.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 et({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 h.ReadRequestCommand({channelUrl:this.url}),i=yield s.send(n),{readStatus:a}=i.as(h.ReadEventCommand);if(this._updateUnreadMemberState(e.userId,a.readAt),this.unreadMessageCount>0||this.unreadMentionCount>0){this._updateUnreadCount(0,0);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 Me({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 me({channelUrl:this.url,time:this._typingStarted});yield 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 Ce({channelUrl:this.url,time:this._typingStarted});yield e.send(t)}}))}createScheduledUserMessage(e){e=Object.assign(Object.assign({},h.ScheduledUserMessageCreateParamsDefault),e),d.unless(h.validateScheduledUserMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=new h.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({},ot),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 ht(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({},h.ScheduledFileMessageCreateParamsDefault),e),d.unless(h.validateScheduledFileMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=Date.now(),s=this._generateRequestId(),n=new h.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({},rt),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 lt(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(dt);return r}))}cancelScheduledMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new ct({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 ut({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 mt({userId:e.userId,channelUrl:this.url}),n=yield t.send(s),{pushTriggerOption:i}=n.as(gt);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 _t({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),a=yield n.send(i),{pushTriggerOption:r}=a.as(pt);return this.myPushTriggerOption=r,t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 st({channelUrl:this.url,userId:s.userId,countPreference:e}),a=yield n.send(i),{countPreference:r}=a.as(nt);return this.myCountPreference=r,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),r}))}resetMyHistory(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t,sdkState:s}=d.Vault.of(this._iid),n=new it({channelUrl:this.url,locale:s.localeForChatbot}),i=yield t.send(n),{messageOffsetTimestamp:a}=i.as(at);return this.messageOffsetTimestamp=a,this.lastMessage&&this.lastMessage.createdAt{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),n._trigger(e)})),n}if(e.isFileMessage()){const s=this._validateFailedFileMessageHasFile(e,t);d.unless(s).throw(d.SendbirdError.invalidParameters);const n=h.createFileMessageCreateParamsFromFailedFileMessage(e,t),i=new h.MessageRequestHandler;return this._sendFileMessage(n,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{i._trigger(e)})).onFailed(((e,t)=>{i._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),i._trigger(e)})),i}if(e.isMultipleFilesMessage()){const t=e.messageParams,s=new h.MultipleFilesMessageRequestHandler;return this._sendMultipleFilesMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{s._trigger(e)})).onFailed(((e,t)=>{s._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),s._trigger(e)})).onFileUploaded(((e,t,n,i)=>{s._triggerOnFileUploaded(e,t,n,i)})),s}}copyMessage(e,t){if(d.unless(e instanceof h.BaseChannel&&t instanceof h.SendableMessage&&t.sendingStatus===d.SendingStatus.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(d.SendbirdError.invalidParameters),t.isUserMessage()){d.unless(!t.poll).throw(d.SendbirdError.notSupportedError);const s=h.createUserMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendUserMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isFileMessage()){const s=h.createFileMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendFileMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isMultipleFilesMessage()){if(e.isGroupChannel()){const s=h.createMultipleFilesMessageCreateParams(t),n=new h.MultipleFilesMessageRequestHandler;return e._sendMultipleFilesMessage(s,h.SendMessageRequestType.COPY).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})).onFileUploaded(((e,t,s,i)=>{n._triggerOnFileUploaded(e,t,s,i)})),n}throw d.SendbirdError.channelTypeNotSupportedError}}}exports.BaseMessageCollection=Ge,exports.DeliveryStatus=m,exports.GetTotalUnreadMessageCountRequestCommand=$,exports.GetTotalUnreadMessageCountResponseCommand=K,exports.GroupChannel=vt,exports.GroupChannelChangeLogsParamsDefault=f,exports.GroupChannelCountParamsDefault=y,exports.GroupChannelCreateParamsDefault=E,exports.GroupChannelEventSource=I,exports.GroupChannelFilter=g,exports.GroupChannelListQuery=fe,exports.GroupChannelManager=be,exports.Member=p,exports.MemberListQuery=Qe,exports.MessageCollection=qe,exports.MessageCollectionInitHandler=Ve,exports.Sync=xe,exports.TimeRange=Se,exports.TotalUnreadMessageCountParamsDefault=N,exports.indexOfMessage=Ne,exports.placeOfMessage=Ue,exports.shouldGiveEvent=x,exports.validateGroupChannelChangeLogsParams=M,exports.validateGroupChannelCountParams=S,exports.validateGroupChannelCreateParams=v,exports.validateTotalUnreadMessageCountParams=T; diff --git a/cjs/lib/__definition.d.cts b/cjs/lib/__definition.d.cts index 79b1ac4..d31cb4e 100644 --- a/cjs/lib/__definition.d.cts +++ b/cjs/lib/__definition.d.cts @@ -1089,7 +1089,6 @@ declare abstract class BaseStore { constructor(props: BaseStoreParams); abstract checkAvailability(): Promise; abstract init(dbname: string): Promise; - abstract clear(): Promise; get adjustedItemSizeLimit(): number; usage(): Promise; getAllKeys(): Promise; @@ -1098,6 +1097,7 @@ declare abstract class BaseStore { setMany(items: StoreItem[]): Promise; remove(key: string): Promise; removeMany(keys: string[]): Promise; + clear(): Promise; } declare interface BaseStoreParams { diff --git a/cjs/message.cjs b/cjs/message.cjs index 8b0014d..8288f26 100644 --- a/cjs/message.cjs +++ b/cjs/message.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-ad182031.cjs"),s=require("./lib/__bundle-9d371926.cjs"),t=require("./lib/__bundle-e8b53f2f.cjs");const r={channelUrl:"",scheduledMessageId:0},a={reverse:!1,limit:20};class n extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}){super.init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}),this._manager=new s.MessageManager(e,{sdkState:t,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:u})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s.MessageRetrievalParamsDefault),t);e.unless(s.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters);const a=yield this._manager.getMessage(r);if(a instanceof s.BaseMessage||a instanceof s.NotificationMessage||null===a)return a;throw"Unknown message type is given."}))}getScheduledMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),s);return e.unless((s=>e.isTypeOf("string",s.channelUrl)&&""!==s.channelUrl&&e.isTypeOf("number",s.scheduledMessageId)&&s.scheduledMessageId>0)(t)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(t)}))}getMessageTemplatesByToken(s,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},a),t);return e.unless(e.isTypeOf("string",s,!0)&&(s=>e.isTypeOf("boolean",s.reverse,!0)&&e.isTypeOf("number",s.limit,!0)&&e.isArrayOf("string",s.keys,!0))(r)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplatesByToken(s,r)}))}getMessageTemplate(s){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",s)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplate(s)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageReviewStatus",{enumerable:!0,get:function(){return e.MessageReviewStatus}}),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=s.AdminMessage,exports.AppleCriticalAlertOptions=s.AppleCriticalAlertOptions,exports.BaseMessage=s.BaseMessage,exports.Feedback=s.Feedback,Object.defineProperty(exports,"FeedbackRating",{enumerable:!0,get:function(){return s.FeedbackRating}}),exports.FileMessage=s.FileMessage,exports.MessageForm=s.MessageForm,exports.MessageFormItem=s.MessageFormItem,Object.defineProperty(exports,"MessageFormItemLayout",{enumerable:!0,get:function(){return s.MessageFormItemLayout}}),exports.MessageMetaArray=s.MessageMetaArray,exports.MessageRequestHandler=s.MessageRequestHandler,exports.MessageReviewInfo=s.MessageReviewInfo,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return s.MessageSearchOrder}}),exports.MessageSearchQuery=s.MessageSearchQuery,exports.MultipleFilesMessage=s.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=s.MultipleFilesMessageRequestHandler,exports.OGImage=s.OGImage,exports.OGMetaData=s.OGMetaData,exports.PreviousMessageListQuery=s.PreviousMessageListQuery,exports.Reaction=s.Reaction,exports.ReactionEvent=s.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return s.ReactionEventOperation}}),exports.Sender=s.Sender,exports.ThreadInfo=s.ThreadInfo,exports.ThreadInfoUpdateEvent=s.ThreadInfoUpdateEvent,exports.Thumbnail=s.Thumbnail,exports.UploadedFileInfo=s.UploadedFileInfo,exports.UserMessage=s.UserMessage,exports.ThreadedParentMessageListQuery=t.ThreadedParentMessageListQuery,exports.MessageModule=n; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),s=require("./lib/__bundle-165fd6e1.cjs"),t=require("./lib/__bundle-bfe2e997.cjs");const r={channelUrl:"",scheduledMessageId:0},a={reverse:!1,limit:20};class n extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}){super.init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}),this._manager=new s.MessageManager(e,{sdkState:t,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:u})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s.MessageRetrievalParamsDefault),t);e.unless(s.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters);const a=yield this._manager.getMessage(r);if(a instanceof s.BaseMessage||a instanceof s.NotificationMessage||null===a)return a;throw"Unknown message type is given."}))}getScheduledMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),s);return e.unless((s=>e.isTypeOf("string",s.channelUrl)&&""!==s.channelUrl&&e.isTypeOf("number",s.scheduledMessageId)&&s.scheduledMessageId>0)(t)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(t)}))}getMessageTemplatesByToken(s,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},a),t);return e.unless(e.isTypeOf("string",s,!0)&&(s=>e.isTypeOf("boolean",s.reverse,!0)&&e.isTypeOf("number",s.limit,!0)&&e.isArrayOf("string",s.keys,!0))(r)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplatesByToken(s,r)}))}getMessageTemplate(s){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",s)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplate(s)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageReviewStatus",{enumerable:!0,get:function(){return e.MessageReviewStatus}}),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=s.AdminMessage,exports.AppleCriticalAlertOptions=s.AppleCriticalAlertOptions,exports.BaseMessage=s.BaseMessage,exports.Feedback=s.Feedback,Object.defineProperty(exports,"FeedbackRating",{enumerable:!0,get:function(){return s.FeedbackRating}}),exports.FileMessage=s.FileMessage,exports.MessageForm=s.MessageForm,exports.MessageFormItem=s.MessageFormItem,Object.defineProperty(exports,"MessageFormItemLayout",{enumerable:!0,get:function(){return s.MessageFormItemLayout}}),exports.MessageMetaArray=s.MessageMetaArray,exports.MessageRequestHandler=s.MessageRequestHandler,exports.MessageReviewInfo=s.MessageReviewInfo,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return s.MessageSearchOrder}}),exports.MessageSearchQuery=s.MessageSearchQuery,exports.MultipleFilesMessage=s.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=s.MultipleFilesMessageRequestHandler,exports.OGImage=s.OGImage,exports.OGMetaData=s.OGMetaData,exports.PreviousMessageListQuery=s.PreviousMessageListQuery,exports.Reaction=s.Reaction,exports.ReactionEvent=s.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return s.ReactionEventOperation}}),exports.Sender=s.Sender,exports.ThreadInfo=s.ThreadInfo,exports.ThreadInfoUpdateEvent=s.ThreadInfoUpdateEvent,exports.Thumbnail=s.Thumbnail,exports.UploadedFileInfo=s.UploadedFileInfo,exports.UserMessage=s.UserMessage,exports.ThreadedParentMessageListQuery=t.ThreadedParentMessageListQuery,exports.MessageModule=n; diff --git a/cjs/openChannel.cjs b/cjs/openChannel.cjs index 7378b65..6f7cbef 100644 --- a/cjs/openChannel.cjs +++ b/cjs/openChannel.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-ad182031.cjs"),n=require("./lib/__bundle-9d371926.cjs"),t=require("./lib/__bundle-5374ca23.cjs"),a=require("./lib/__bundle-a5185d74.cjs"),s=require("./lib/__bundle-441c4e66.cjs");require("./lib/__bundle-dae7bdf2.cjs");class i 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 r={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)}`,this.params={show_pinned_messages:!0}}}class l extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class d extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o,is_ephemeral:l}))}}class h extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class c extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}class u extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class C extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}const p={};class _ extends t.BaseChannelManager{constructor(n,t){super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.OPEN})),this.subscribeChannelEvent=e.noop,this.unsubscribeChannelEvent=e.noop,this.refreshChannel=()=>e.__awaiter(this,void 0,void 0,(function*(){return e.noop()})),this._openChannelCache=new i(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n).catch((n=>{if(e.isThrowingOutside(n)&&"foreground"===this._sdkState.appState)throw 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]||(p[n]=this)}static of(e){return p[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new P(this._iid,P.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)}get handlers(){return[...this._openChannelHandlers.values()]}_handleEvent(a){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(a.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let s=null;if("MESG"===a.code?s=a.as(n.UserMessageEventCommand):"FILE"===a.code?s=a.as(n.FileMessageEventCommand):"ADMM"!==a.code&&"BRDM"!=a.code||(s=a.as(t.AdminMessageEventCommand)),s){const{message:n,isMentioned:t}=s;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 s=null;if("MEDI"===a.code?s=a.as(n.UpdateUserMessageEventCommand):"FEDI"===a.code?s=a.as(n.UpdateFileMessageEventCommand):"AEDI"===a.code&&(s=a.as(t.UpdateAdminMessageEventCommand)),s){const{message:n,mentionCountChange:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);let s=!1;a.lastPinnedMessage&&a.lastPinnedMessage.messageId===n.messageId&&a.lastPinnedMessage.updatedAte.__awaiter(this,void 0,void 0,(function*(){var e,i;for(const r of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(s&&(null===(e=r.onPinnedMessageUpdated)||void 0===e||e.call(r,a),null===(i=r.onChannelChanged)||void 0===i||i.call(r,a)),r.onMessageUpdated&&r.onMessageUpdated(a,n),t>0&&r.onMentionReceived&&r.onMentionReceived(a,n))}))))}}break}case"DELM":{const{channelUrl:n,channelType:t,messageId:s}=a.as(e.DeleteMessageEventCommand);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.onMessageDeleted&&e.onMessageDeleted(t,s)}))))}break}case"MRCT":{const{channelUrl:n,channelType:s,event:i}=a.as(t.ReactionEventCommand);if(s===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,i)}))))}break}case"MTHD":{const{event:n}=a.as(t.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}=a.as(t.MemberCountUpdateEventCommand),s=[];for(const e of n){const{channelUrl:n,participantCount:t,updatedAt:a}=e,i=yield this.getChannelFromCache(n);i&&i._updateParticipantCount(t,a)&&s.push(i)}if(s.length>0){const n=yield this.upsertChannelsToCache(s);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:s,channelUrl:i,channelType:r}=a.as(t.PollUpdateEventCommand);if(i&&r===e.ChannelType.OPEN){const t=yield this.getChannel(i,!0);this._dispatcher.dispatch(new e.PollUpdateInternalEventCommand({event:n,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),s===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(t,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(t,n)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:i}=a.as(n.PollVoteEventCommand);if(s&&i===e.ChannelType.OPEN){const n=yield this.getChannel(s,!0);this._dispatcher.dispatch(new e.PollVoteInternalEventCommand({event:t,source:e.CollectionEventSource.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:s}=a.as(t.ChannelEventCommand);if(s.isOpenChannelEvent)switch(s.category){case t.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(c),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(C),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(s.channelUrl,!0),{operators:i}=a.as(t.OperatorUpdateEventCommand);n.operators=i,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,i)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_MUTE:case t.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=a.as(r?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserMuted&&e.onUserMuted(i,o):e.onUserUnmuted&&e.onUserUnmuted(i,o)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_BAN:case t.ChannelEventCategory.USER_CHANNEL_UNBAN:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=a.as(r?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserBanned&&e.onUserBanned(i,o):e.onUserUnbanned&&e.onUserUnbanned(i,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_FREEZE:case t.ChannelEventCategory.CHANNEL_UNFREEZE:{const t=yield this.getChannel(s.channelUrl,!0),{freeze:i}=a.as(n.FreezeEventCommand);t.isFrozen=i,this.upsertChannelsToCache([t]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onChannelFrozen&&e.onChannelFrozen(t):e.onChannelUnfrozen&&e.onChannelUnfrozen(t)}))}))));break}case t.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(s.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 t.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(s.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaDataEventCommand);i&&t._upsertCachedMetaData(i,s.ts),r&&t._upsertCachedMetaData(r,s.ts),o&&t._removeFromCachedMetaData(o,s.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaDataCreated&&e.onMetaDataCreated(t,i),r&&e.onMetaDataUpdated&&e.onMetaDataUpdated(t,r),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(t,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaCounterCreated&&e.onMetaCounterCreated(t,i),r&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(t,r),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(t,o)}))}))));break}case t.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const n=yield this.getChannel(s.channelUrl,!0),{pinnedMessageIds:i,latestPinnedMessage:r,ts:o}=a.as(t.UpdatePinnedMessageEventCommand);o>n._pinnedMessagesUpdatedAt&&(n.pinnedMessageIds=i,n.lastPinnedMessage=r,n._pinnedMessagesUpdatedAt=o,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))})))));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,t)}))}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:i}=s.as(l);return(yield this.upsertChannelsToCache([i]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),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 d(t),s=yield this._requestQueue.send(a),{channel:i}=s.as(l);return this.upsertChannelsToCache([i]),i}))}}const v={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class g 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 m extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:s}=n;this.token=t,this.participants=s.map((n=>new a.Participant(e,n)))}}class E 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 g(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:i}=a.as(m);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class f extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o}))}}class U extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class y 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 P extends n.BaseChannel{constructor(t,a){var s;super(t,a),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(s=a.participant_count)&&void 0!==s?s:0,this.operators=Array.isArray(a.operators)?a.operators.map((n=>new e.User(t,n))):[],this.lastPinnedMessage=a.latest_pinned_message?n.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},a.latest_pinned_message)):null}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))),latest_pinned_message:t.lastPinnedMessage?n.payloadifyMessage(t.lastPinnedMessage):null})))}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 E(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 h({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:i}=a.as(c);this._updateParticipantCount(s,i);_.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),a=new u({channelUrl:this.url}),s=yield t.send(a),{participantCount:i,ts:r}=s.as(C);this._updateParticipantCount(i,r);_.of(this._iid).setExitedToCache(this);n.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,!0)||e.isFile(n.coverUrlOrImage,!0))&&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 f(Object.assign({channelUrl:this.url},t)),i=yield a.send(s),{channel:r}=i.as(U);this._update(r);const o=_.of(this._iid);return yield o.upsertChannelsToCache([r]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,i){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:i});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new y({channelUrl:this.url});yield n.send(t);const a=_.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}updateUserMessage(n,t){const a=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateUserMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}updateFileMessage(n,t){const a=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateFileMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}}class M extends s.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,this.onPinnedMessageUpdated=e.noop}}class T extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:i,customTypes:r,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:i,custom_types:r,show_frozen:o,show_metadata:l,show_pinned_messages:!0})}}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 P(e,n)))),this.ts="number"==typeof s?s:null}}class O extends e.BaseListQuery{constructor(e,n){var t,a,s,i,r;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!==(i=n.urlKeyword)&&void 0!==i?i:null,this.customTypes=null!==(r=n.customTypes)&&void 0!==r?r: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 T(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:i}=a.as(A);this._token=i,this._hasNext=!!i;const r=_.of(this._iid);return yield r.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class b extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}),this._manager=new _(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:i,cacheContext:o,sessionManager:a})}createOpenChannelListQuery(e={}){return new O(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,i){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},r);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=i,this._manager.createChannel(e)}))}}exports.OpenChannel=P,exports.OpenChannelHandler=class extends M{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=O,exports.OpenChannelModule=b,exports.ParticipantListQuery=E; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),n=require("./lib/__bundle-165fd6e1.cjs"),t=require("./lib/__bundle-d3673ecc.cjs"),a=require("./lib/__bundle-c127c886.cjs"),s=require("./lib/__bundle-611abb88.cjs");require("./lib/__bundle-dae7bdf2.cjs");class i 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 r={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)}`,this.params={show_pinned_messages:!0}}}class l extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class d extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o,is_ephemeral:l}))}}class h extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class c extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}class u extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class C extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}const p={};class _ extends t.BaseChannelManager{constructor(n,t){super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.OPEN})),this.subscribeChannelEvent=e.noop,this.unsubscribeChannelEvent=e.noop,this.refreshChannel=()=>e.__awaiter(this,void 0,void 0,(function*(){return e.noop()})),this._openChannelCache=new i(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n).catch((n=>{if(e.isThrowingOutside(n)&&"foreground"===this._sdkState.appState)throw 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]||(p[n]=this)}static of(e){return p[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new P(this._iid,P.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)}get handlers(){return[...this._openChannelHandlers.values()]}_handleEvent(a){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(a.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let s=null;if("MESG"===a.code?s=a.as(n.UserMessageEventCommand):"FILE"===a.code?s=a.as(n.FileMessageEventCommand):"ADMM"!==a.code&&"BRDM"!=a.code||(s=a.as(t.AdminMessageEventCommand)),s){const{message:n,isMentioned:t}=s;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 s=null;if("MEDI"===a.code?s=a.as(n.UpdateUserMessageEventCommand):"FEDI"===a.code?s=a.as(n.UpdateFileMessageEventCommand):"AEDI"===a.code&&(s=a.as(t.UpdateAdminMessageEventCommand)),s){const{message:n,mentionCountChange:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);let s=!1;a.lastPinnedMessage&&a.lastPinnedMessage.messageId===n.messageId&&a.lastPinnedMessage.updatedAte.__awaiter(this,void 0,void 0,(function*(){var e,i;for(const r of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(s&&(null===(e=r.onPinnedMessageUpdated)||void 0===e||e.call(r,a),null===(i=r.onChannelChanged)||void 0===i||i.call(r,a)),r.onMessageUpdated&&r.onMessageUpdated(a,n),t>0&&r.onMentionReceived&&r.onMentionReceived(a,n))}))))}}break}case"DELM":{const{channelUrl:n,channelType:t,messageId:s}=a.as(e.DeleteMessageEventCommand);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.onMessageDeleted&&e.onMessageDeleted(t,s)}))))}break}case"MRCT":{const{channelUrl:n,channelType:s,event:i}=a.as(t.ReactionEventCommand);if(s===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,i)}))))}break}case"MTHD":{const{event:n}=a.as(t.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}=a.as(t.MemberCountUpdateEventCommand),s=[];for(const e of n){const{channelUrl:n,participantCount:t,updatedAt:a}=e,i=yield this.getChannelFromCache(n);i&&i._updateParticipantCount(t,a)&&s.push(i)}if(s.length>0){const n=yield this.upsertChannelsToCache(s);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:s,channelUrl:i,channelType:r}=a.as(t.PollUpdateEventCommand);if(i&&r===e.ChannelType.OPEN){const t=yield this.getChannel(i,!0);this._dispatcher.dispatch(new e.PollUpdateInternalEventCommand({event:n,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),s===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(t,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(t,n)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:i}=a.as(n.PollVoteEventCommand);if(s&&i===e.ChannelType.OPEN){const n=yield this.getChannel(s,!0);this._dispatcher.dispatch(new e.PollVoteInternalEventCommand({event:t,source:e.CollectionEventSource.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:s}=a.as(t.ChannelEventCommand);if(s.isOpenChannelEvent)switch(s.category){case t.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(c),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(C),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(s.channelUrl,!0),{operators:i}=a.as(t.OperatorUpdateEventCommand);n.operators=i,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,i)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_MUTE:case t.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=a.as(r?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserMuted&&e.onUserMuted(i,o):e.onUserUnmuted&&e.onUserUnmuted(i,o)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_BAN:case t.ChannelEventCategory.USER_CHANNEL_UNBAN:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=a.as(r?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserBanned&&e.onUserBanned(i,o):e.onUserUnbanned&&e.onUserUnbanned(i,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_FREEZE:case t.ChannelEventCategory.CHANNEL_UNFREEZE:{const t=yield this.getChannel(s.channelUrl,!0),{freeze:i}=a.as(n.FreezeEventCommand);t.isFrozen=i,this.upsertChannelsToCache([t]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onChannelFrozen&&e.onChannelFrozen(t):e.onChannelUnfrozen&&e.onChannelUnfrozen(t)}))}))));break}case t.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(s.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 t.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(s.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaDataEventCommand);i&&t._upsertCachedMetaData(i,s.ts),r&&t._upsertCachedMetaData(r,s.ts),o&&t._removeFromCachedMetaData(o,s.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaDataCreated&&e.onMetaDataCreated(t,i),r&&e.onMetaDataUpdated&&e.onMetaDataUpdated(t,r),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(t,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaCounterCreated&&e.onMetaCounterCreated(t,i),r&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(t,r),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(t,o)}))}))));break}case t.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const n=yield this.getChannel(s.channelUrl,!0),{pinnedMessageIds:i,latestPinnedMessage:r,ts:o}=a.as(t.UpdatePinnedMessageEventCommand);o>n._pinnedMessagesUpdatedAt&&(n.pinnedMessageIds=i,n.lastPinnedMessage=r,n._pinnedMessagesUpdatedAt=o,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))})))));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,t)}))}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:i}=s.as(l);return(yield this.upsertChannelsToCache([i]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),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 d(t),s=yield this._requestQueue.send(a),{channel:i}=s.as(l);return this.upsertChannelsToCache([i]),i}))}}const v={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class g 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 m extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:s}=n;this.token=t,this.participants=s.map((n=>new a.Participant(e,n)))}}class E 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 g(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:i}=a.as(m);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class f extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o}))}}class U extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class y 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 P extends n.BaseChannel{constructor(t,a){var s;super(t,a),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(s=a.participant_count)&&void 0!==s?s:0,this.operators=Array.isArray(a.operators)?a.operators.map((n=>new e.User(t,n))):[],this.lastPinnedMessage=a.latest_pinned_message?n.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},a.latest_pinned_message)):null}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))),latest_pinned_message:t.lastPinnedMessage?n.payloadifyMessage(t.lastPinnedMessage):null})))}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 E(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 h({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:i}=a.as(c);this._updateParticipantCount(s,i);_.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),a=new u({channelUrl:this.url}),s=yield t.send(a),{participantCount:i,ts:r}=s.as(C);this._updateParticipantCount(i,r);_.of(this._iid).setExitedToCache(this);n.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,!0)||e.isFile(n.coverUrlOrImage,!0))&&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 f(Object.assign({channelUrl:this.url},t)),i=yield a.send(s),{channel:r}=i.as(U);this._update(r);const o=_.of(this._iid);return yield o.upsertChannelsToCache([r]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,i){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:i});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new y({channelUrl:this.url});yield n.send(t);const a=_.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}updateUserMessage(n,t){const a=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateUserMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}updateFileMessage(n,t){const a=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateFileMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}}class M extends s.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,this.onPinnedMessageUpdated=e.noop}}class T extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:i,customTypes:r,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:i,custom_types:r,show_frozen:o,show_metadata:l,show_pinned_messages:!0})}}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 P(e,n)))),this.ts="number"==typeof s?s:null}}class b extends e.BaseListQuery{constructor(e,n){var t,a,s,i,r;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!==(i=n.urlKeyword)&&void 0!==i?i:null,this.customTypes=null!==(r=n.customTypes)&&void 0!==r?r: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 T(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:i}=a.as(A);this._token=i,this._hasNext=!!i;const r=_.of(this._iid);return yield r.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class O extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}),this._manager=new _(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:i,cacheContext:o,sessionManager:a})}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,i){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},r);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=i,this._manager.createChannel(e)}))}}exports.OpenChannel=P,exports.OpenChannelHandler=class extends M{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=b,exports.OpenChannelModule=O,exports.ParticipantListQuery=E; diff --git a/cjs/poll.cjs b/cjs/poll.cjs index 40d377b..e2e95d4 100644 --- a/cjs/poll.cjs +++ b/cjs/poll.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-ad182031.cjs"),t=require("./lib/__bundle-dae7bdf2.cjs");class r extends e.Module{constructor(){super(...arguments),this.name="poll"}init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}){super.init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new e.PollManager(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n})}create(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollCreateParamsDefault),t);return e.unless(e.validatePollCreateParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.create(r)}))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollRetrievalParamsDefault),t);return e.unless(e.validatePollRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.get(r)}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollOptionRetrievalParamsDefault),t);return e.unless(e.validatePollOptionRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(r)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=e.Poll,exports.PollListQuery=e.PollListQuery,exports.PollOption=e.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return e.PollStatus}}),exports.PollVoteEvent=e.PollVoteEvent,exports.PollVoterListQuery=e.PollVoterListQuery,exports.PollUpdateEvent=t.PollUpdateEvent,exports.PollModule=r; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),t=require("./lib/__bundle-dae7bdf2.cjs");class r extends e.Module{constructor(){super(...arguments),this.name="poll"}init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}){super.init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new e.PollManager(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n})}create(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollCreateParamsDefault),t);return e.unless(e.validatePollCreateParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.create(r)}))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollRetrievalParamsDefault),t);return e.unless(e.validatePollRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.get(r)}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollOptionRetrievalParamsDefault),t);return e.unless(e.validatePollOptionRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(r)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=e.Poll,exports.PollListQuery=e.PollListQuery,exports.PollOption=e.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return e.PollStatus}}),exports.PollVoteEvent=e.PollVoteEvent,exports.PollVoterListQuery=e.PollVoterListQuery,exports.PollUpdateEvent=t.PollUpdateEvent,exports.PollModule=r; diff --git a/feedChannel.js b/feedChannel.js index dee0080..5fcf4b2 100644 --- a/feedChannel.js +++ b/feedChannel.js @@ -1 +1 @@ -import{e,u as t,c as n,w as r,s as a,g as i,p as o,q as s,_ as c,b as u,af as l,t as h,b8 as d,B as f,A as p,d as v,f as _,h as g,bg as y,az as m,a as C,bp as b,aQ as w,Q as E,V as M,au as T,W as N,bq as k,z as x,a2 as I,C as S,O as A,a8 as U,G as D,an as F,bk as R,aw as O,ai as P,b9 as H,ba as L,aA as j,aO as G,a_ as V}from"./lib/__bundle-85fbca74.js";import{i as z,aO as B,aj as Q,aP as q,ac as W,aQ as K,aR as J,T as Y,z as X,aS as Z,aT as $}from"./lib/__bundle-3ceb5f92.js";export{aj as NotificationMessage,aR as NotificationMessageStatus}from"./lib/__bundle-3ceb5f92.js";import{y as ee,z as te,A as ne,B as re,o as ae,E as ie,F as oe,I as se,b as ce}from"./lib/__bundle-0e590e6a.js";import{g as ue,N as le}from"./lib/__bundle-80bd1744.js";import{D as he}from"./lib/__bundle-b7a55976.js";import{B as de,C as fe,a as pe}from"./lib/__bundle-ace226dc.js";import"./lib/__bundle-acd77193.js";var ve=function(){function n(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}return n.payloadify=function(n){return e(t({id:n.id,name:n.name,is_default:n.isDefault}))},Object.defineProperty(n.prototype,"customType",{get:function(){return this.isDefault?"*":String(this.id)},enumerable:!1,configurable:!0}),n}(),_e=function(t){function l(e,n){var r=n.sdkState,a=n.cacheContext,i=n.channelManager,o=t.call(this,e)||this;return o._channels=new Map,o._sdkState=r,o._cacheContext=a,o._channelManager=i,o}return n(l,t),Object.defineProperty(l.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return r(!!e).throw(a.databaseError),e.collection(z)},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),l.prototype._serialize=function(e,t){return void 0===t&&(t=0),i(i({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},l.prototype._deserialize=function(e){return this._channelManager.buildFeedChannelFromSerializedData(e)},Object.defineProperty(l.prototype,"channels",{get:function(){return o([],s(this._channels.values()),!1)},enumerable:!1,configurable:!0}),l.prototype.isCachedInMemory=function(e){return this._channels.has(e)},l.prototype.get=function(e){return c(this,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=n.sent())return this._channels.set(e,this._deserialize(t)),[2,this._channels.get(e)];n.label=2;case 2:return[2,void 0];case 3:return[2,this._channels.get(e)]}}))}))},l.prototype.fetch=function(e){var t=e.token,n=e.limit,r=void 0===n?B:n,a=e.backward,i=void 0!==a&&a,o=e.order,s=void 0===o?"latest_last_message":o,l=e.borderlineChannelUrl;return c(this,void 0,void 0,(function(){var e,n,a,o,c=this;return u(this,(function(u){switch(u.label){case 0:return this.localCacheEnabled?(e=ue(s),n={where:function(e){if(t&&"latest_last_message"===s)if(!i&&e.lastMessageUpdatedAt>t||i&&e.lastMessageUpdatedAt0&&this._dispatcher.dispatch(new ge({channels:d,context:{source:o}})),f.length>0&&this._dispatcher.dispatch(new ye({channelUrls:f,context:{source:o}})),[2,{updatedChannels:d,deletedChannelUrls:f,hasMore:p,token:v}]}}))}))},l.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){var t,n,o,s,c,l,h;return u(this,(function(u){switch(u.label){case 0:return t=i(i({},te),e),r(ne(t)).throw(a.invalidParameters),n=M.of(this._iid),o=n.sdkState,s=n.requestQueue,c=new re({userId:o.userId,filter:t,includeFeedChannel:!0}),[4,s.send(c)];case 1:return l=u.sent(),h=l.as(ee).unreadFeedCount,[2,void 0===h?0:h]}}))}))},l.prototype.getTotalUnreadNotificationCount=function(){return c(this,void 0,void 0,(function(){var e,t,n,r,a,i;return u(this,(function(o){switch(o.label){case 0:return e=M.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pe({userId:t.userId}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(ee).unreadFeedCount,[2,void 0===i?0:i]}}))}))},l.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){var e,t;return u(this,(function(n){switch(n.label){case 0:return e=new Ie,[4,this._requestQueue.send(e)];case 1:return t=n.sent(),[2,{jsonString:t.as(Se).jsonString}]}}))}))},l.prototype.getNotificationTemplateListByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n,o,s,c,l,h,d;return u(this,(function(u){switch(u.label){case 0:return n=i(i({},De),t),r(C("string",e)&&function(e){return C("boolean",e.reverse,!0)&&E("string",e.keys,!0)&&C("number",e.limit,!0)}(n)).throw(a.invalidParameters),o=new Ae({token:e,keys:n.keys,reverse:n.reverse,limit:n.limit}),[4,this._requestQueue.send(o)];case 1:return s=u.sent(),c=s.as(Ue),l=c.hasMore,h=c.nextToken,d=c.notificationTemplateList,[2,{hasMore:l,token:h,notificationTemplateList:d}]}}))}))},l.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){var t,n;return u(this,(function(i){switch(i.label){case 0:return r(C("string",e)).throw(a.invalidParameters),t=new Fe({key:e}),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,{jsonString:n.as(Re).jsonString}]}}))}))},l.prototype.upsertChannelsToCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.removeChannelsFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return t.sent(),[2]}}))}))},l.prototype.getNotificationMessageFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=I.REFRESH_CHANNEL),c(this,void 0,void 0,(function(){var r,a,i,o,s;return u(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Ee({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Me).channel).myMemberState!==ae.NONE?[3,2]:(this._dispatcher.dispatch(new ye({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new ge({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(s=c.sent()).code!==U.NON_AUTHORIZED&&s.code!==U.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new ye({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},l.prototype.refreshNotificationCollections=function(){this._dispatcher.dispatch(new le)},l.prototype.subscribeChannelEvent=function(e,t){this._feedChannelBroadcast.subscribe(e,t)},l.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},l.prototype._handleEvent=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,l,d,f,p=this;return u(this,(function(v){switch(v.label){case 0:switch(e.code){case"ADMM":case"BRDM":return[3,1];case"READ":return[3,4];case"SYEV":return[3,7]}return[3,13];case 1:return(s="ADMM"===e.code||"BRDM"===e.code?e.as(Oe):null)&&s.message.channelType===this._channelType?(t=s.message,n=s.isMentioned,[4,this.getChannel(t.channelUrl,!0)]):[3,3];case 2:(r=v.sent())._runIfHandleableWithGroupChannel((function(e){var a;t instanceof Q&&n&&(null===(a=t.mentionedUsers)||void 0===a||a.forEach((function(t){var n,r;try{for(var a=h(e.members),i=a.next();!i.done;i=a.next()){var o=i.value;if(t.userId===o.userId){t.nickname=o.nickname,t.plainProfileUrl=o.plainProfileUrl,t.metaData=o.metaData;break}}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}))),p._dispatcher.dispatch(new ge({channels:[r],context:{source:I.EVENT_MESSAGE_RECEIVED}})),p._dispatcher.dispatch(new F({messages:[t],source:I.EVENT_MESSAGE_RECEIVED})),D((function(){return c(p,void 0,void 0,(function(){var e,a,i,o,s;return u(this,(function(c){try{for(e=h(this._feedChannelHandlers.values()),a=e.next();!a.done;a=e.next())(i=a.value).onMessageReceived&&i.onMessageReceived(r,t),n&&i.onMentionReceived&&i.onMentionReceived(r,t)}catch(e){o={error:e}}finally{try{a&&!a.done&&(s=e.return)&&s.call(e)}finally{if(o)throw o.error}}return[2]}))}))}))})),v.label=3;case 3:return[3,13];case 4:return(s="READ"===e.code?e.as(W):null)&&s.readStatus.channelType===this._channelType?(a=s.readStatus,i=this._feedChannelCache.isCachedInMemory(a.channelUrl),[4,this.getChannel(a.channelUrl,!0)]):[3,6];case 5:(o=v.sent())._runIfHandleableWithGroupChannel((function(e){i&&e._updateUnreadMemberState(a.reader.userId,a.readAt),a.reader.userId===p._sdkState.userId&&(i?(e.unreadMessageCount>0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))))})),v.label=6;case 6:return[3,13];case 7:if(!(s="SYEV"===e.code?e.as(fe):null)||s.event.channelType!==this._channelType)return[3,12];switch(l=s.event,l.category){case pe.CHANNEL_DELETED:return[3,8];case pe.CHANNEL_PROP_CHANGED:return[3,10]}return[3,12];case 8:return[4,this.getChannel(l.channelUrl,!0)];case 9:return d=v.sent(),this._dispatcher.dispatch(new ye({channelUrls:[l.channelUrl],context:{source:I.EVENT_CHANNEL_DELETED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(d.url,d.channelType)})),[2]}))}))})),[3,12];case 10:return[4,this.getChannelWithoutCache(l.channelUrl,!0)];case 11:return f=v.sent(),this._dispatcher.dispatch(new ge({channels:[f],context:{source:I.EVENT_CHANNEL_UPDATED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(f)})),[2]}))}))})),[3,12];case 12:return[3,13];case 13:return[2]}}))}))},l.prototype.getMessageFromCache=function(e){var t;return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},l.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return c(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,r.sent()]}}))}))},l.prototype.getMessagesFromCache=function(e,t,n,r,a,i){return void 0===a&&(a=K),void 0===i&&(i=!0),c(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i})];case 1:return[2,o.sent()]}}))}))},l}(de),je=function(e){function t(t,n){var r=e.call(this,t,i(i({},n),{channelManager:Le.of(t)}))||this,a=M.of(r._iid),o=a.connectionManager,s=a.dispatcher;return r._notificationCollectionEventContext=s.on((function(e){e instanceof le&&O(10).then((function(){o.isConnected||o.isConnecting||r.refresh()}))})),r}return n(t,e),t.prototype.keyOf=function(e){return e.notificationId},Object.defineProperty(t.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._notificationCollectionEventContext.close()},t.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},t.prototype._postprocessChannelUpdateEvent=function(e,t){var n,r,a=this._messages.filter((function(t){return t.messageStatus===J.SENT&&t.createdAt<=e.myLastRead}));if(a.length>0){try{for(var i=h(a),o=i.next();!o.done;o=i.next()){o.value.messageStatus=J.READ}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}this._updateMessagesToView(a,t)}},t.prototype._postprocessMessageUpdateEvent=function(e,t){var n,r;if(t===I.EVENT_CHANNEL_READ){var a=[],i=this._messages.map((function(e){return e.notificationId}));try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var c=s.value.notificationId,u=i.indexOf(c);u>=0&&(this._messages[u].messageStatus=J.READ,a.push(this._messages[u]))}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a.length>0&&this._updateMessagesToView(a,t)}},t.prototype._addMessagesToView=function(e,t){var n,r,a=this,i=this._filterUnderOffsetMessage(e),o=[],s=[];try{for(var l=h(i),d=l.next();!d.done;d=l.next()){var f,p=d.value;if(t===I.SYNC_MESSAGE_FILL){if((f=ie(this._messages,p))<0){var v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}}else if((f=ie(this._messages,p))<0){v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}else this._messages[f]=p,s.push(p)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r,a,i;return u(this,(function(c){return e={source:t},o.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===r||r.call(n,e,this.channel,o)),s.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,e,this.channel,s)),[2]}))}))}))},t.prototype._updateMessagesToView=function(e,t){var n,r,a=this,i=[];try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var l=s.value,d=ie(this._messages,l);d>=0&&(i.push(l),this._messages[d]=l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r;return u(this,(function(a){return e={source:t},i.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,i)),[2]}))}))})),i},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._activate()];case 1:return e.sent(),[2]}}))}))},t}(se),Ge=function(e){function t(t,n){var r,a,o=this;return(o=e.call(this,t,n)||this).channelType=S.FEED,o._groupChannel=new ce(t,n),o.isCategoryFilterEnabled=null!==(r=n.is_category_filter_enabled)&&void 0!==r&&r,o.isTemplateLabelEnabled=null===(a=n.is_template_label_enabled)||void 0===a||a,o.notificationCategories=n.categories?n.categories.map((function(e){return new ve(e)})):[],o.lastMessage=n.last_message?Y(o._iid,i({channel_type:o.channelType},n.last_message)):null,o}return n(t,e),t.payloadify=function(e){var t;return i(i({},ce.payloadify(null!==(t=e._groupChannel)&&void 0!==t?t:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((function(e){return ve.payloadify(e)})),last_message:e.lastMessage?Q.payloadify(e.lastMessage):null})},Object.defineProperty(t.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var e,t;return i(i({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((function(e){return P(e)})),lastMessage:null!==(t=null===(e=this.lastMessage)||void 0===e?void 0:e.serialize())&&void 0!==t?t:null})},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},t.prototype.markAsRead=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,c,l,h,d=this;return u(this,(function(u){switch(u.label){case 0:return t=M.of(this._iid),n=t.sdkState,r=t.dispatcher,a=t.requestQueue,!(i=null==e?void 0:e.filter((function(e){return!e||e.messageStatus===J.SENT})).map((function(e){return e.notificationId})))||i.length>0?(o=new $({userId:n.userId,channelUrl:this.url,channelType:S.FEED,notificationIds:i}),[4,a.send(o)]):[3,2];case 1:s=u.sent(),c=s.as(Z),l=c.unreadMessageCount,h=c.readAt,e?("number"==typeof l&&(this._groupChannel._updateUnreadCount(l,this._groupChannel.unreadMentionCount),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)}))),e.forEach((function(e){e.messageStatus=J.READ})),r.dispatch(new F({messages:e,source:I.EVENT_CHANNEL_READ}))):(this._groupChannel._updateUnreadMemberState(n.userId,h),this._groupChannel.unreadMessageCount!==l&&(this._groupChannel._updateUnreadCount(l,0),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})))),r.dispatch(new ge({channels:[this],context:{source:I.EVENT_CHANNEL_READ}})),u.label=2;case 2:return[2]}}))}))},t.prototype.markAsClicked=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.logClicked(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.logClicked=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30)try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.logImpression=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return[2,this.logViewed(e)]}))}))},t.prototype.logViewed=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30){try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2,!0]}return[2,!1]}))}))},t.prototype.logCustom=function(e,t){return c(this,void 0,void 0,(function(){var n,r,a,i,o,s;return u(this,(function(c){if(n=M.of(this._iid).statManager,0t||i&&e.lastMessageUpdatedAt0&&this._dispatcher.dispatch(new ge({channels:d,context:{source:o}})),f.length>0&&this._dispatcher.dispatch(new ye({channelUrls:f,context:{source:o}})),[2,{updatedChannels:d,deletedChannelUrls:f,hasMore:p,token:v}]}}))}))},l.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){var t,n,o,s,c,l,h;return u(this,(function(u){switch(u.label){case 0:return t=i(i({},te),e),r(ne(t)).throw(a.invalidParameters),n=M.of(this._iid),o=n.sdkState,s=n.requestQueue,c=new re({userId:o.userId,filter:t,includeFeedChannel:!0}),[4,s.send(c)];case 1:return l=u.sent(),h=l.as(ee).unreadFeedCount,[2,void 0===h?0:h]}}))}))},l.prototype.getTotalUnreadNotificationCount=function(){return c(this,void 0,void 0,(function(){var e,t,n,r,a,i;return u(this,(function(o){switch(o.label){case 0:return e=M.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pe({userId:t.userId}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(ee).unreadFeedCount,[2,void 0===i?0:i]}}))}))},l.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){var e,t;return u(this,(function(n){switch(n.label){case 0:return e=new Ie,[4,this._requestQueue.send(e)];case 1:return t=n.sent(),[2,{jsonString:t.as(Se).jsonString}]}}))}))},l.prototype.getNotificationTemplateListByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n,o,s,c,l,h,d;return u(this,(function(u){switch(u.label){case 0:return n=i(i({},De),t),r(C("string",e)&&function(e){return C("boolean",e.reverse,!0)&&E("string",e.keys,!0)&&C("number",e.limit,!0)}(n)).throw(a.invalidParameters),o=new Ae({token:e,keys:n.keys,reverse:n.reverse,limit:n.limit}),[4,this._requestQueue.send(o)];case 1:return s=u.sent(),c=s.as(Ue),l=c.hasMore,h=c.nextToken,d=c.notificationTemplateList,[2,{hasMore:l,token:h,notificationTemplateList:d}]}}))}))},l.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){var t,n;return u(this,(function(i){switch(i.label){case 0:return r(C("string",e)).throw(a.invalidParameters),t=new Fe({key:e}),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,{jsonString:n.as(Re).jsonString}]}}))}))},l.prototype.upsertChannelsToCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.removeChannelsFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return t.sent(),[2]}}))}))},l.prototype.getNotificationMessageFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=I.REFRESH_CHANNEL),c(this,void 0,void 0,(function(){var r,a,i,o,s;return u(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Ee({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Me).channel).myMemberState!==ae.NONE?[3,2]:(this._dispatcher.dispatch(new ye({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new ge({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(s=c.sent()).code!==U.NON_AUTHORIZED&&s.code!==U.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new ye({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},l.prototype.refreshNotificationCollections=function(){this._dispatcher.dispatch(new le)},l.prototype.subscribeChannelEvent=function(e,t){this._feedChannelBroadcast.subscribe(e,t)},l.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},l.prototype._handleEvent=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,l,d,f,p=this;return u(this,(function(v){switch(v.label){case 0:switch(e.code){case"ADMM":case"BRDM":return[3,1];case"READ":return[3,4];case"SYEV":return[3,7]}return[3,13];case 1:return(s="ADMM"===e.code||"BRDM"===e.code?e.as(Oe):null)&&s.message.channelType===this._channelType?(t=s.message,n=s.isMentioned,[4,this.getChannel(t.channelUrl,!0)]):[3,3];case 2:(r=v.sent())._runIfHandleableWithGroupChannel((function(e){var a;t instanceof Q&&n&&(null===(a=t.mentionedUsers)||void 0===a||a.forEach((function(t){var n,r;try{for(var a=h(e.members),i=a.next();!i.done;i=a.next()){var o=i.value;if(t.userId===o.userId){t.nickname=o.nickname,t.plainProfileUrl=o.plainProfileUrl,t.metaData=o.metaData;break}}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}))),p._dispatcher.dispatch(new ge({channels:[r],context:{source:I.EVENT_MESSAGE_RECEIVED}})),p._dispatcher.dispatch(new F({messages:[t],source:I.EVENT_MESSAGE_RECEIVED})),D((function(){return c(p,void 0,void 0,(function(){var e,a,i,o,s;return u(this,(function(c){try{for(e=h(this._feedChannelHandlers.values()),a=e.next();!a.done;a=e.next())(i=a.value).onMessageReceived&&i.onMessageReceived(r,t),n&&i.onMentionReceived&&i.onMentionReceived(r,t)}catch(e){o={error:e}}finally{try{a&&!a.done&&(s=e.return)&&s.call(e)}finally{if(o)throw o.error}}return[2]}))}))}))})),v.label=3;case 3:return[3,13];case 4:return(s="READ"===e.code?e.as(W):null)&&s.readStatus.channelType===this._channelType?(a=s.readStatus,i=this._feedChannelCache.isCachedInMemory(a.channelUrl),[4,this.getChannel(a.channelUrl,!0)]):[3,6];case 5:(o=v.sent())._runIfHandleableWithGroupChannel((function(e){i&&e._updateUnreadMemberState(a.reader.userId,a.readAt),a.reader.userId===p._sdkState.userId&&(i?(e.unreadMessageCount>0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))))})),v.label=6;case 6:return[3,13];case 7:if(!(s="SYEV"===e.code?e.as(fe):null)||s.event.channelType!==this._channelType)return[3,12];switch(l=s.event,l.category){case pe.CHANNEL_DELETED:return[3,8];case pe.CHANNEL_PROP_CHANGED:return[3,10]}return[3,12];case 8:return[4,this.getChannel(l.channelUrl,!0)];case 9:return d=v.sent(),this._dispatcher.dispatch(new ye({channelUrls:[l.channelUrl],context:{source:I.EVENT_CHANNEL_DELETED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(d.url,d.channelType)})),[2]}))}))})),[3,12];case 10:return[4,this.getChannelWithoutCache(l.channelUrl,!0)];case 11:return f=v.sent(),this._dispatcher.dispatch(new ge({channels:[f],context:{source:I.EVENT_CHANNEL_UPDATED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(f)})),[2]}))}))})),[3,12];case 12:return[3,13];case 13:return[2]}}))}))},l.prototype.getMessageFromCache=function(e){var t;return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},l.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return c(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,r.sent()]}}))}))},l.prototype.getMessagesFromCache=function(e,t,n,r,a,i){return void 0===a&&(a=K),void 0===i&&(i=!0),c(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i})];case 1:return[2,o.sent()]}}))}))},l}(de),je=function(e){function t(t,n){var r=e.call(this,t,i(i({},n),{channelManager:Le.of(t)}))||this,a=M.of(r._iid),o=a.connectionManager,s=a.dispatcher;return r._notificationCollectionEventContext=s.on((function(e){e instanceof le&&O(10).then((function(){o.isConnected||o.isConnecting||r.refresh()}))})),r}return n(t,e),t.prototype.keyOf=function(e){return e.notificationId},Object.defineProperty(t.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._notificationCollectionEventContext.close()},t.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},t.prototype._postprocessChannelUpdateEvent=function(e,t){var n,r,a=this._messages.filter((function(t){return t.messageStatus===J.SENT&&t.createdAt<=e.myLastRead}));if(a.length>0){try{for(var i=h(a),o=i.next();!o.done;o=i.next()){o.value.messageStatus=J.READ}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}this._updateMessagesToView(a,t)}},t.prototype._postprocessMessageUpdateEvent=function(e,t){var n,r;if(t===I.EVENT_CHANNEL_READ){var a=[],i=this._messages.map((function(e){return e.notificationId}));try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var c=s.value.notificationId,u=i.indexOf(c);u>=0&&(this._messages[u].messageStatus=J.READ,a.push(this._messages[u]))}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a.length>0&&this._updateMessagesToView(a,t)}},t.prototype._addMessagesToView=function(e,t){var n,r,a=this,i=this._filterUnderOffsetMessage(e),o=[],s=[];try{for(var l=h(i),d=l.next();!d.done;d=l.next()){var f,p=d.value;if(t===I.SYNC_MESSAGE_FILL){if((f=ie(this._messages,p))<0){var v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}}else if((f=ie(this._messages,p))<0){v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}else this._messages[f]=p,s.push(p)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r,a,i;return u(this,(function(c){return e={source:t},o.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===r||r.call(n,e,this.channel,o)),s.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,e,this.channel,s)),[2]}))}))}))},t.prototype._updateMessagesToView=function(e,t){var n,r,a=this,i=[];try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var l=s.value,d=ie(this._messages,l);d>=0&&(i.push(l),this._messages[d]=l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r;return u(this,(function(a){return e={source:t},i.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,i)),[2]}))}))})),i},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._activate()];case 1:return e.sent(),[2]}}))}))},t}(se),Ge=function(e){function t(t,n){var r,a,o=this;return(o=e.call(this,t,n)||this).channelType=S.FEED,o._groupChannel=new ce(t,n),o.isCategoryFilterEnabled=null!==(r=n.is_category_filter_enabled)&&void 0!==r&&r,o.isTemplateLabelEnabled=null===(a=n.is_template_label_enabled)||void 0===a||a,o.notificationCategories=n.categories?n.categories.map((function(e){return new ve(e)})):[],o.lastMessage=n.last_message?Y(o._iid,i({channel_type:o.channelType},n.last_message)):null,o}return n(t,e),t.payloadify=function(e){var t;return i(i({},ce.payloadify(null!==(t=e._groupChannel)&&void 0!==t?t:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((function(e){return ve.payloadify(e)})),last_message:e.lastMessage?Q.payloadify(e.lastMessage):null})},Object.defineProperty(t.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var e,t;return i(i({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((function(e){return P(e)})),lastMessage:null!==(t=null===(e=this.lastMessage)||void 0===e?void 0:e.serialize())&&void 0!==t?t:null})},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},t.prototype.markAsRead=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,c,l,h,d=this;return u(this,(function(u){switch(u.label){case 0:return t=M.of(this._iid),n=t.sdkState,r=t.dispatcher,a=t.requestQueue,!(i=null==e?void 0:e.filter((function(e){return!e||e.messageStatus===J.SENT})).map((function(e){return e.notificationId})))||i.length>0?(o=new $({userId:n.userId,channelUrl:this.url,channelType:S.FEED,notificationIds:i}),[4,a.send(o)]):[3,2];case 1:s=u.sent(),c=s.as(Z),l=c.unreadMessageCount,h=c.readAt,e?("number"==typeof l&&(this._groupChannel._updateUnreadCount(l,this._groupChannel.unreadMentionCount),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)}))),e.forEach((function(e){e.messageStatus=J.READ})),r.dispatch(new F({messages:e,source:I.EVENT_CHANNEL_READ}))):(this._groupChannel._updateUnreadMemberState(n.userId,h),this._groupChannel.unreadMessageCount!==l&&(this._groupChannel._updateUnreadCount(l,0),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})))),r.dispatch(new ge({channels:[this],context:{source:I.EVENT_CHANNEL_READ}})),u.label=2;case 2:return[2]}}))}))},t.prototype.markAsClicked=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.logClicked(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.logClicked=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30)try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.logImpression=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return[2,this.logViewed(e)]}))}))},t.prototype.logViewed=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30){try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2,!0]}return[2,!1]}))}))},t.prototype.logCustom=function(e,t){return c(this,void 0,void 0,(function(){var n,r,a,i,o,s;return u(this,(function(c){if(n=M.of(this._iid).statManager,0=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(l=this._metadata.range).extends.apply(l,y([],E(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),p.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),[3,13];case 9:return o=s.sent(),p.debug("channel background sync error",o),o instanceof g&&o.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw o;case 12:return C.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(S=null===(b=m.localCacheConfig)||void 0===b?void 0:b.maxSize)&&void 0!==S?S:0,use_local_cache:m.localCacheEnabled,starting_point:0,message_init_policy:null!==(w=null===(M=t.order)||void 0===M?void 0:M.toString())&&void 0!==w?w:"",collection_id:c.userId}})),[7];case 13:return[3,15];case 14:e.hasNext=!1,e.nextToken="",s.label=15;case 15:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)o.resume();else o.pause()}))}return t.of=function(e){return Pe[e]||(Pe[e]=new t({_iid:e})),Pe[e].ref++,Pe[e]},t.clear=function(e){Pe[e]&&(Pe[e].close(),delete Pe[e])},Object.defineProperty(t.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 _e({})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,i.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new _e(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.resume=function(){var e,t,n=i.of(this._iid),a=n.logger;n.sessionManager.session.hasSession&&(a.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:""))},t.prototype.pause=function(){i.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid])},t}(),Re={},Ve=function(){function t(t){var n=t._iid,a=this;this.ref=0,this._iid=n;var r,o=i.of(this._iid),l=o.logger,u=o.sdkState,c=o.dispatcher,d=o.cacheContext,p=o.statManager;this._metadataKey=(r=u.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta")),this._subscribers=new T;var m=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new fe(m,(function(){return e(a,void 0,void 0,(function(){var e,t,n,a,r,i,o,c,h,f,m,y;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),l.debug("channel changelog sync from",null===(f=this._metadata)||void 0===f?void 0:f.token),s.label=2;case 2:s.trys.push([2,9,,12]),t={includeEmpty:!0,includeMetaData:!0},s.label=3;case 3:return s.trys.push([3,5,,6]),[4,d.preference.get(L(u.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannelChangeLogs(null!==(y=null===(m=this._metadata)||void 0===m?void 0:m.token)&&void 0!==y?y:"",t,A.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=s.sent(),r=a.updatedChannels,i=a.deletedChannelUrls,o=a.hasMore,c=a.token,this._subscribers.dispatch("progress",{updatedChannels:r,deletedChannelUrls:i,hasMore:o,token:c}),e.hasNext=o,e.nextToken=c,this._metadata&&(this._metadata.token=c),l.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),d.localCacheEnabled&&p.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:r.length>0||i.length>0?"cache_miss":"cache_hit",max_db_size:r.length,use_local_cache:d.localCacheEnabled,starting_point:0,message_init_policy:i.length.toString(),collection_id:u.userId}})),[3,12];case 9:return h=s.sent(),l.debug("channel changelog sync error",h),h instanceof g&&h.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw h;case 12:return[2,e]}}))}))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=c.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)a.resume();else a.pause()}))}return t.of=function(e){return Re[e]||(Re[e]=new t({_iid:e})),Re[e].ref++,Re[e]},t.clear=function(e){Re[e]&&(Re[e].close(),delete Re[e])},Object.defineProperty(t.prototype,"isRunning",{get:function(){return this._sync.isRunning},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e,t,n,a;return s(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=i.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.on=function(e,t){return this._subscribers.on(e,t)},t.prototype.resume=function(){i.of(this._iid).sessionManager.session.hasSession&&this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid])},t}(),Ke=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},ze=function(e,t,n){if(e.length>0){for(var a=Ke(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(o<0))return{place:s,oldPosition:a};r=s+1,s=Math.floor((r+i)/2)}}return{place:Qe(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Qe=function(e,t,n){switch(n){case Ge.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?0===(a=t.lastMessage.createdAt-e.lastMessage.createdAt)?t.createdAt-e.createdAt:a:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var a;return 0===(a=e.name.localeCompare(t.name))?e.createdAt-t.createdAt:a;default:return 0}},je=function(){function t(t,n){var a=n.filter,r=void 0===a?new ge:a,o=n.order,l=void 0===o?Ge.LATEST_LAST_MESSAGE:o,u=n.limit,c=void 0===u?ke:u,d=n.includeChangesOnInitialLoad,p=void 0!==d&&d,_=this;this.channels=[],this._isInitialized=!1,this._iid=t,this._key="gcc-".concat(I()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=r,this.order=l,this._hasMore=!0,this._token="",this._limit=c;var v=i.of(this._iid),m=v.sdkState,g=v.cacheContext,y=v.dispatcher;g.localCacheEnabled&&(this._backgroundSync=He.of(t),this._backgroundSync.resume()),this._changelogSync=Ve.of(t),this._changelogSync.resume(),ve.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(me(n)){var a=e.filter((function(e){return _.filter.match(e,m.userId)})),r=e.filter((function(e){return!_.filter.match(e,m.userId)})).map((function(e){return e.url}));a.length>0&&_._addChannelsToView(a,t),r.length>0&&_._removeChannelsFromView(r,t)}},onRemove:function(e,t){_._removeChannelsFromView(e,t)}}),y.on((function(t){t instanceof h&&(t.stateType===f.CONNECTED?_._isGetRemoteChannelsSucceeded||e(_,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):t.stateType===f.LOGOUT&&_.dispose())}))}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,n,a){var r,i,o,l,u=this;void 0===a&&(a=!1);var c=[],h=[],d=[];try{for(var p=F(t),f=p.next();!f.done;f=p.next()){var _=f.value,v=Ke(this.channels,_);v>=0&&this.channels.splice(v,1);var m=ze(this.channels,_,this.order).place;if(v<0)m===this.channels.length?!a&&this._hasMore||(c.push(_),this.channels.push(_)):(c.push(_),this.channels.splice(m,0,_));else switch(n.source){case A.EVENT_CHANNEL_UPDATED:case A.EVENT_MESSAGE_RECEIVED:case A.SYNC_CHANNEL_CHANGELOGS:case A.EVENT_MESSAGE_SENT:this.order===Ge.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&m===this.channels.length?d.push(_):(this.channels.splice(m,0,_),h.push(_));break;default:this.channels.splice(m,0,_),h.push(_)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}if(d.length>0)try{for(var g=F(d),y=g.next();!y.done;y=g.next()){_=y.value;var C=Ke(this.channels,_);-1!==C&&this.channels.splice(C,1)}}catch(e){o={error:e}}finally{try{y&&!y.done&&(l=g.return)&&l.call(g)}finally{if(o)throw o.error}}me(n.source)&&N((function(){return e(u,void 0,void 0,(function(){var e,t,a;return s(this,(function(r){return c.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(n,c),h.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,h),d.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,d.map((function(e){return e.url}))),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,n){var a,r,i=this,o=[],l=function(e){var t=u.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(u.channels[t].url),u.channels.splice(t,1))},u=this;try{for(var c=F(t),h=c.next();!h.done;h=c.next()){l(h.value)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(a)throw a.error}}return me(n.source)&&o.length>0&&N((function(){return e(i,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=ve.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.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()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(a){switch(a.label){case 0:return[4,ve.of(this._iid).getMyGroupChannels(this._token,R(z(z({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},t.prototype._revokeLoadMore=function(){return e(this,void 0,void 0,(function(){var e;return s(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,{source:A.REQUEST_CHANNEL},!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},t.prototype.loadMore=function(){var t;return e(this,void 0,void 0,(function(){var n,a,r,o,l,u,c,h,d,p,f,_,m,y,C,b,S,M,E,w=this;return s(this,(function(L){switch(L.label){case 0:if(this._isDisposed)throw new g({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return n=null,this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning?[4,new Promise((function(e){w._changelogSyncSubscriberContext=w._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}))]:[3,2];case 1:n=L.sent(),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close(),L.label=2;case 2:return a=i.of(this._iid),r=a.cacheContext,o=a.connectionManager,l=a.statManager,this._isInitialized?[3,5]:(this._isInitialized=!0,r.localCacheEnabled?[4,this._backgroundSync.loadMetadata()]:[3,4]);case 3:L.sent(),L.label=4;case 4:l.put(new B({type:v.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{group_channel:!0}}})),L.label=5;case 5:return u=[],this._hasMore?!r.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed?[3,7]:[4,Z((function(){return e(w,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return u=e.sent(),[2]}}))}))}))]:[3,11];case 6:return L.sent(),this._hasMore=u.length>=this._limit,[3,10];case 7:return L.trys.push([7,9,,10]),[4,this._getRemoteChannels()];case 8:return u=L.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,10];case 9:return L.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,10];case 10:this._addChannelsToView(u,{source:A.REQUEST_CHANNEL},!0),L.label=11;case 11:if(n){try{for(c=F(n.updatedChannels),h=c.next();!h.done;h=c.next())d=h.value,(C=Ke(u,d))>=0?u[C]=d:(p=ze(u,d,this.order).place,u.splice(p,0,d))}catch(e){b={error:e}}finally{try{h&&!h.done&&(S=c.return)&&S.call(c)}finally{if(b)throw b.error}}f=u.map((function(e){return e.url}));try{for(_=F(n.deletedChannelUrls),m=_.next();!m.done;m=_.next())y=m.value,(C=f.indexOf(y))>=0&&(u.splice(C,1),f.splice(C,1))}catch(e){M={error:e}}finally{try{m&&!m.done&&(E=_.return)&&E.call(_)}finally{if(M)throw M.error}}}return[2,u]}}))}))},t.prototype.dispose=function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),ve.of(this._iid).unsubscribeChannelEvent(this._key))},t}(),We=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,_=t.metadataValues,v=t.metadataValueStartsWith,m=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=ee.GET,n.path=te,n.params=ne(R({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:ye.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:_,metadata_value_startswith:v,show_frozen:m,show_metadata:g})),n}return $(t,e),t}(ae),Be=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new Ce(t,e)}))),a.ts="number"==typeof s?s:0,a}return $(t,e),t}(re);!function(e){e.ALL="all",e.JOINED="joined"}(De||(De={}));var qe=function(t){function n(e,n){var a,r,i,s,o,l,u,c,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=De.ALL,m.superChannelFilter=Se.ALL,m.metadataKey=null,m.metadataValues=null,m.metadataOrderKeyFilter=null,m.metadataValueStartsWith=null,m.order=Ue.CHRONOLOGICAL,m.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,m.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,m.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,m.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,m.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,m.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,m.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,m.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:De.ALL,m.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Se.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:Ue.CHRONOLOGICAL,m}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("boolean",this.includeEmpty)&&ie("boolean",this.includeFrozen)&&ie("boolean",this.includeMetaData)&&ie("string",this.channelNameContainsFilter,!0)&&se("string",this.channelUrlsFilter,!0)&&se("string",this.customTypesFilter,!0)&&ie("string",this.customTypeStartsWithFilter,!0)&&oe(De,this.membershipFilter)&&oe(Se,this.superChannelFilter)&&oe(Ue,this.order)&&ie("string",this.metadataOrderKeyFilter,!0)&&ie("string",this.metadataKey,!0)&&se("string",this.metadataValues,!0)&&ie("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o,l;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=i.of(this._iid).requestQueue,n=new We(R(z(z({},this),{token:this._token}))),[4,t.send(n)]):[3,2]):[3,5];case 1:return a=s.sent(),r=a.as(Be),o=r.channels,l=r.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),Ye=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 $(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=ue,t.onUserLeft=ue,t.onUserReceivedInvitation=ue,t.onUserDeclinedInvitation=ue,t.onChannelHidden=ue,t.onUnreadMemberStatusUpdated=ue,t.onUndeliveredMemberStatusUpdated=ue,t.onTypingStatusUpdated=ue,t.onPollUpdated=ue,t.onPollVoted=ue,t.onPollDeleted=ue,t.onPinnedMessageUpdated=ue,t}return $(t,e),t}(Ie)),Xe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=ee.GET,n.path="".concat(ce),n.params=ne(R({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return $(t,e),t}(ae),Je=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return Ne(t,e)})),a}return $(t,e),t}(re),Ze=function(t){function n(e,n){var a,r,i,s,o,l=this;return(l=t.call(this,e,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=he.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:he.ALL,l}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("string",this.channelUrl,!0)&&(oe(Oe,this.order)||null===this.order)&&ie("boolean",this.reverse)&&(se(xe,this.scheduledStatus)||null===this.scheduledStatus)&&oe(he,this.messageTypeFilter)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=i.of(this._iid).requestQueue,t=new Xe(R(z(z({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),a=n.as(Je),r=a.scheduledMessages,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),$e=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return $(n,t),n.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new ve(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new je(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Me(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ze(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){de(ie("string",e)&&t instanceof Ye).throw(g.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){de(ie("string",e)).throw(g.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(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannel(t)]}))}))},n.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("string",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("number",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},we),t),de(Le(e)).throw(g.invalidParameters),[2,this._manager.getGroupChannelCount(e)]}))}))},n.prototype.getUnreadItemCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getUnreadItemCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(t)];case 1:return[2,e.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(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),[2,this._manager.createChannel(e)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),e&&(e.isDistinct=!0),[2,this.createChannel(e)]}))}))},n.prototype.createChannelWithUserIds=function(t,n,a,r,i,o){return void 0===n&&(n=!1),void 0===i&&(i=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return s(this,(function(s){return e=z(z({},Te),{invitedUserIds:t,isDistinct:n,name:a,data:i,customType:o}),"string"==typeof r?e.coverUrl=r:e.coverImage=r,[2,this.createChannel(e)]}))}))},n.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(se("string",t)).throw(g.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},n.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return de(ie("string",t)).throw(g.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},n}(pe);export{je as GroupChannelCollection,Ye as GroupChannelHandler,$e as GroupChannelModule,De as MembershipFilter,qe as PublicGroupChannelListQuery,Ze as ScheduledMessageListQuery}; +import{_ as e,V as i,b as s,D as h,F as f,b9 as _,ba as v,s as g,p as y,q as E,a2 as A,K as L,E as T,t as F,G as N,n as I,u as R,g as z,bb as B,a8 as J,B as Z,c as $,A as ee,az as te,e as ne,f as ae,h as re,a as ie,Q as se,X as oe,aO as le,aA as ue,bc as ce,aq as he,w as de,a_ as pe}from"./lib/__bundle-1db3fd0b.js";export{bd as MessageEventSource,be as MutedState}from"./lib/__bundle-1db3fd0b.js";import{S as fe,T as _e,G as ve,s as me,a as ge,P as ye,b as Ce,c as Se,d as Me,e as Ee,v as Ae,f as we,g as Le,h as Te,i as Fe}from"./lib/__bundle-cc71b396.js";export{C as CountPreference,D as DeliveryStatus,b as GroupChannel,j as GroupChannelEventSource,a as GroupChannelFilter,d as GroupChannelListQuery,k as GroupChannelSearchField,H as HiddenChannelFilter,l as HiddenState,M as Member,m as MemberListOrder,n as MemberListQuery,o as MemberState,p as MemberStateFilter,r as MessageCollection,t as MessageCollectionInitHandler,u as MessageCollectionInitPolicy,w as MutedMemberFilter,q as MyMemberStateFilter,O as OperatorFilter,P as PublicChannelFilter,Q as QueryType,c as SuperChannelFilter,U as UnreadChannelFilter,x as UnreadItemKey}from"./lib/__bundle-cc71b396.js";import{Q as ke,T as Ne,V as xe}from"./lib/__bundle-e1a5e3f1.js";export{K as MessageFilter,W as PinnedMessage,X as PinnedMessageListQuery,Y as ReadStatus,V as ScheduledStatus}from"./lib/__bundle-e1a5e3f1.js";import{G as Ge,P as Ue,S as Oe}from"./lib/__bundle-24f017be.js";export{G as GroupChannelListOrder,P as PublicGroupChannelListOrder,S as ScheduledMessageListOrder}from"./lib/__bundle-24f017be.js";import{B as Ie}from"./lib/__bundle-123134d8.js";import"./lib/__bundle-e53b9010.js";import"./lib/__bundle-acd77193.js";var De,Pe={},He=function(){function t(t){var n=t._iid,a=t.limit,r=void 0===a?100:a,o=this;this.ref=0,this._iid=n,this._limit=r;var l,u=i.of(this._iid),c=u.sdkState,d=u.dispatcher,p=u.logger,m=u.cacheContext,C=u.statManager;this._metadataKey=(l=c.userId,"sendbird:".concat(l,"@groupchannel/sync.meta"));var b=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(c.userId);this._sync=new fe(b,(function(){return e(o,void 0,void 0,(function(){var e,t,n,a,r,i,o,l,u,h,d,f,b,S,M,w;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(s.sent(),p.debug("channel background sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),null===(h=this._metadata)||void 0===h?void 0:h.completed)return[3,14];t={includeEmpty:!0,includeMetaData:!0,order:Ge.CHRONOLOGICAL},s.label=2;case 2:if(s.trys.push([2,9,12,13]),t.order!==Ge.LATEST_LAST_MESSAGE)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,m.preference.get(L(c.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannels(null!==(f=null===(d=this._metadata)||void 0===d?void 0:d.token)&&void 0!==f?f:"",t,this._limit,A.SYNC_CHANNEL_BACKGROUND)];case 7:return a=s.sent(),r=a.channels,i=a.token,e.hasNext=r.length>=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(l=this._metadata.range).extends.apply(l,y([],E(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),p.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),[3,13];case 9:return o=s.sent(),p.debug("channel background sync error",o),o instanceof g&&o.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw o;case 12:return C.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(S=null===(b=m.localCacheConfig)||void 0===b?void 0:b.maxSize)&&void 0!==S?S:0,use_local_cache:m.localCacheEnabled,starting_point:0,message_init_policy:null!==(w=null===(M=t.order)||void 0===M?void 0:M.toString())&&void 0!==w?w:"",collection_id:c.userId}})),[7];case 13:return[3,15];case 14:e.hasNext=!1,e.nextToken="",s.label=15;case 15:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)o.resume();else o.pause()}))}return t.of=function(e){return Pe[e]||(Pe[e]=new t({_iid:e})),Pe[e].ref++,Pe[e]},t.clear=function(e){Pe[e]&&(Pe[e].close(),delete Pe[e])},Object.defineProperty(t.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 _e({})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,i.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new _e(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.resume=function(){var e,t,n=i.of(this._iid),a=n.logger;n.sessionManager.session.hasSession&&(a.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:""))},t.prototype.pause=function(){i.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid])},t}(),Re={},Ve=function(){function t(t){var n=t._iid,a=this;this.ref=0,this._iid=n;var r,o=i.of(this._iid),l=o.logger,u=o.sdkState,c=o.dispatcher,d=o.cacheContext,p=o.statManager;this._metadataKey=(r=u.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta")),this._subscribers=new T;var m=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new fe(m,(function(){return e(a,void 0,void 0,(function(){var e,t,n,a,r,i,o,c,h,f,m,y;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),l.debug("channel changelog sync from",null===(f=this._metadata)||void 0===f?void 0:f.token),s.label=2;case 2:s.trys.push([2,9,,12]),t={includeEmpty:!0,includeMetaData:!0},s.label=3;case 3:return s.trys.push([3,5,,6]),[4,d.preference.get(L(u.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannelChangeLogs(null!==(y=null===(m=this._metadata)||void 0===m?void 0:m.token)&&void 0!==y?y:"",t,A.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=s.sent(),r=a.updatedChannels,i=a.deletedChannelUrls,o=a.hasMore,c=a.token,this._subscribers.dispatch("progress",{updatedChannels:r,deletedChannelUrls:i,hasMore:o,token:c}),e.hasNext=o,e.nextToken=c,this._metadata&&(this._metadata.token=c),l.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),d.localCacheEnabled&&p.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:r.length>0||i.length>0?"cache_miss":"cache_hit",max_db_size:r.length,use_local_cache:d.localCacheEnabled,starting_point:0,message_init_policy:i.length.toString(),collection_id:u.userId}})),[3,12];case 9:return h=s.sent(),l.debug("channel changelog sync error",h),h instanceof g&&h.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw h;case 12:return[2,e]}}))}))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=c.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)a.resume();else a.pause()}))}return t.of=function(e){return Re[e]||(Re[e]=new t({_iid:e})),Re[e].ref++,Re[e]},t.clear=function(e){Re[e]&&(Re[e].close(),delete Re[e])},Object.defineProperty(t.prototype,"isRunning",{get:function(){return this._sync.isRunning},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e,t,n,a;return s(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=i.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.on=function(e,t){return this._subscribers.on(e,t)},t.prototype.resume=function(){i.of(this._iid).sessionManager.session.hasSession&&this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid])},t}(),Ke=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},ze=function(e,t,n){if(e.length>0){for(var a=Ke(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(o<0))return{place:s,oldPosition:a};r=s+1,s=Math.floor((r+i)/2)}}return{place:Qe(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Qe=function(e,t,n){switch(n){case Ge.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?0===(a=t.lastMessage.createdAt-e.lastMessage.createdAt)?t.createdAt-e.createdAt:a:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var a;return 0===(a=e.name.localeCompare(t.name))?e.createdAt-t.createdAt:a;default:return 0}},je=function(){function t(t,n){var a=n.filter,r=void 0===a?new ge:a,o=n.order,l=void 0===o?Ge.LATEST_LAST_MESSAGE:o,u=n.limit,c=void 0===u?ke:u,d=n.includeChangesOnInitialLoad,p=void 0!==d&&d,_=this;this.channels=[],this._isInitialized=!1,this._iid=t,this._key="gcc-".concat(I()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=r,this.order=l,this._hasMore=!0,this._token="",this._limit=c;var v=i.of(this._iid),m=v.sdkState,g=v.cacheContext,y=v.dispatcher;g.localCacheEnabled&&(this._backgroundSync=He.of(t),this._backgroundSync.resume()),this._changelogSync=Ve.of(t),this._changelogSync.resume(),ve.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(me(n)){var a=e.filter((function(e){return _.filter.match(e,m.userId)})),r=e.filter((function(e){return!_.filter.match(e,m.userId)})).map((function(e){return e.url}));a.length>0&&_._addChannelsToView(a,t),r.length>0&&_._removeChannelsFromView(r,t)}},onRemove:function(e,t){_._removeChannelsFromView(e,t)}}),y.on((function(t){t instanceof h&&(t.stateType===f.CONNECTED?_._isGetRemoteChannelsSucceeded||e(_,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):t.stateType===f.LOGOUT&&_.dispose())}))}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,n,a){var r,i,o,l,u=this;void 0===a&&(a=!1);var c=[],h=[],d=[];try{for(var p=F(t),f=p.next();!f.done;f=p.next()){var _=f.value,v=Ke(this.channels,_);v>=0&&this.channels.splice(v,1);var m=ze(this.channels,_,this.order).place;if(v<0)m===this.channels.length?!a&&this._hasMore||(c.push(_),this.channels.push(_)):(c.push(_),this.channels.splice(m,0,_));else switch(n.source){case A.EVENT_CHANNEL_UPDATED:case A.EVENT_MESSAGE_RECEIVED:case A.SYNC_CHANNEL_CHANGELOGS:case A.EVENT_MESSAGE_SENT:this.order===Ge.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&m===this.channels.length?d.push(_):(this.channels.splice(m,0,_),h.push(_));break;default:this.channels.splice(m,0,_),h.push(_)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}if(d.length>0)try{for(var g=F(d),y=g.next();!y.done;y=g.next()){_=y.value;var C=Ke(this.channels,_);-1!==C&&this.channels.splice(C,1)}}catch(e){o={error:e}}finally{try{y&&!y.done&&(l=g.return)&&l.call(g)}finally{if(o)throw o.error}}me(n.source)&&N((function(){return e(u,void 0,void 0,(function(){var e,t,a;return s(this,(function(r){return c.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(n,c),h.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,h),d.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,d.map((function(e){return e.url}))),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,n){var a,r,i=this,o=[],l=function(e){var t=u.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(u.channels[t].url),u.channels.splice(t,1))},u=this;try{for(var c=F(t),h=c.next();!h.done;h=c.next()){l(h.value)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(a)throw a.error}}return me(n.source)&&o.length>0&&N((function(){return e(i,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=ve.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.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()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(a){switch(a.label){case 0:return[4,ve.of(this._iid).getMyGroupChannels(this._token,R(z(z({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},t.prototype._revokeLoadMore=function(){return e(this,void 0,void 0,(function(){var e;return s(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,{source:A.REQUEST_CHANNEL},!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},t.prototype.loadMore=function(){var t;return e(this,void 0,void 0,(function(){var n,a,r,o,l,u,c,h,d,p,f,_,m,y,C,b,S,M,E,w=this;return s(this,(function(L){switch(L.label){case 0:if(this._isDisposed)throw new g({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return n=null,this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning?[4,new Promise((function(e){w._changelogSyncSubscriberContext=w._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}))]:[3,2];case 1:n=L.sent(),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close(),L.label=2;case 2:return a=i.of(this._iid),r=a.cacheContext,o=a.connectionManager,l=a.statManager,this._isInitialized?[3,5]:(this._isInitialized=!0,r.localCacheEnabled?[4,this._backgroundSync.loadMetadata()]:[3,4]);case 3:L.sent(),L.label=4;case 4:l.put(new B({type:v.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{group_channel:!0}}})),L.label=5;case 5:return u=[],this._hasMore?!r.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed?[3,7]:[4,Z((function(){return e(w,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return u=e.sent(),[2]}}))}))}))]:[3,11];case 6:return L.sent(),this._hasMore=u.length>=this._limit,[3,10];case 7:return L.trys.push([7,9,,10]),[4,this._getRemoteChannels()];case 8:return u=L.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,10];case 9:return L.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,10];case 10:this._addChannelsToView(u,{source:A.REQUEST_CHANNEL},!0),L.label=11;case 11:if(n){try{for(c=F(n.updatedChannels),h=c.next();!h.done;h=c.next())d=h.value,(C=Ke(u,d))>=0?u[C]=d:(p=ze(u,d,this.order).place,u.splice(p,0,d))}catch(e){b={error:e}}finally{try{h&&!h.done&&(S=c.return)&&S.call(c)}finally{if(b)throw b.error}}f=u.map((function(e){return e.url}));try{for(_=F(n.deletedChannelUrls),m=_.next();!m.done;m=_.next())y=m.value,(C=f.indexOf(y))>=0&&(u.splice(C,1),f.splice(C,1))}catch(e){M={error:e}}finally{try{m&&!m.done&&(E=_.return)&&E.call(_)}finally{if(M)throw M.error}}}return[2,u]}}))}))},t.prototype.dispose=function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),ve.of(this._iid).unsubscribeChannelEvent(this._key))},t}(),We=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,_=t.metadataValues,v=t.metadataValueStartsWith,m=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=ee.GET,n.path=te,n.params=ne(R({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:ye.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:_,metadata_value_startswith:v,show_frozen:m,show_metadata:g})),n}return $(t,e),t}(ae),Be=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new Ce(t,e)}))),a.ts="number"==typeof s?s:0,a}return $(t,e),t}(re);!function(e){e.ALL="all",e.JOINED="joined"}(De||(De={}));var qe=function(t){function n(e,n){var a,r,i,s,o,l,u,c,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=De.ALL,m.superChannelFilter=Se.ALL,m.metadataKey=null,m.metadataValues=null,m.metadataOrderKeyFilter=null,m.metadataValueStartsWith=null,m.order=Ue.CHRONOLOGICAL,m.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,m.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,m.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,m.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,m.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,m.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,m.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,m.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:De.ALL,m.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Se.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:Ue.CHRONOLOGICAL,m}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("boolean",this.includeEmpty)&&ie("boolean",this.includeFrozen)&&ie("boolean",this.includeMetaData)&&ie("string",this.channelNameContainsFilter,!0)&&se("string",this.channelUrlsFilter,!0)&&se("string",this.customTypesFilter,!0)&&ie("string",this.customTypeStartsWithFilter,!0)&&oe(De,this.membershipFilter)&&oe(Se,this.superChannelFilter)&&oe(Ue,this.order)&&ie("string",this.metadataOrderKeyFilter,!0)&&ie("string",this.metadataKey,!0)&&se("string",this.metadataValues,!0)&&ie("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o,l;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=i.of(this._iid).requestQueue,n=new We(R(z(z({},this),{token:this._token}))),[4,t.send(n)]):[3,2]):[3,5];case 1:return a=s.sent(),r=a.as(Be),o=r.channels,l=r.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),Ye=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 $(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=ue,t.onUserLeft=ue,t.onUserReceivedInvitation=ue,t.onUserDeclinedInvitation=ue,t.onChannelHidden=ue,t.onUnreadMemberStatusUpdated=ue,t.onUndeliveredMemberStatusUpdated=ue,t.onTypingStatusUpdated=ue,t.onPollUpdated=ue,t.onPollVoted=ue,t.onPollDeleted=ue,t.onPinnedMessageUpdated=ue,t}return $(t,e),t}(Ie)),Xe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=ee.GET,n.path="".concat(ce),n.params=ne(R({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return $(t,e),t}(ae),Je=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return Ne(t,e)})),a}return $(t,e),t}(re),Ze=function(t){function n(e,n){var a,r,i,s,o,l=this;return(l=t.call(this,e,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=he.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:he.ALL,l}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("string",this.channelUrl,!0)&&(oe(Oe,this.order)||null===this.order)&&ie("boolean",this.reverse)&&(se(xe,this.scheduledStatus)||null===this.scheduledStatus)&&oe(he,this.messageTypeFilter)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=i.of(this._iid).requestQueue,t=new Xe(R(z(z({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),a=n.as(Je),r=a.scheduledMessages,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),$e=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return $(n,t),n.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new ve(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new je(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Me(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ze(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){de(ie("string",e)&&t instanceof Ye).throw(g.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){de(ie("string",e)).throw(g.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(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannel(t)]}))}))},n.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("string",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("number",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},we),t),de(Le(e)).throw(g.invalidParameters),[2,this._manager.getGroupChannelCount(e)]}))}))},n.prototype.getUnreadItemCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getUnreadItemCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(t)];case 1:return[2,e.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(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),[2,this._manager.createChannel(e)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),e&&(e.isDistinct=!0),[2,this.createChannel(e)]}))}))},n.prototype.createChannelWithUserIds=function(t,n,a,r,i,o){return void 0===n&&(n=!1),void 0===i&&(i=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return s(this,(function(s){return e=z(z({},Te),{invitedUserIds:t,isDistinct:n,name:a,data:i,customType:o}),"string"==typeof r?e.coverUrl=r:e.coverImage=r,[2,this.createChannel(e)]}))}))},n.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(se("string",t)).throw(g.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},n.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return de(ie("string",t)).throw(g.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},n}(pe);export{je as GroupChannelCollection,Ye as GroupChannelHandler,$e as GroupChannelModule,De as MembershipFilter,qe as PublicGroupChannelListQuery,Ze as ScheduledMessageListQuery}; diff --git a/index.js b/index.js index 77822c8..537fa15 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -import{i as e,a as t,_ as i,b as a,C as u,c,E as d,A as l,d as h,e as f,u as p,f as v,U as g,g as m,h as b,P as _,j as w,k,l as I,m as A,S as N,L as M,n as Q,o as j,V as q,p as x,q as K,v as W,r as V,s as Z,t as X,w as ee,x as te,y as ne,z as re,B as ie,D as se,F as oe,W as ae,G as ue,H as ce,I as de,J as le,K as he,M as fe,N as pe,O as ve,Q as ge,R as me,T as be,X as _e,Y as ye,Z as we,$ as ke,a0 as Se}from"./lib/__bundle-85fbca74.js";export{a1 as AppInfo,a3 as CachedChannelInfo,a4 as CachedDataClearOrder,C as ChannelType,a2 as CollectionEventSource,r as ConnectionState,Y as DeviceOsPlatform,a5 as LastMessageThreadingPolicy,L as LocalCacheConfig,a6 as NotificationInfo,a0 as PushTemplate,T as PushTokenRegistrationState,P as PushTokenType,$ as PushTriggerOption,a7 as Role,S as SendbirdChatOptions,s as SendbirdError,a8 as SendbirdErrorCode,ad as SendbirdPlatform,ac as SendbirdProduct,a9 as UIKitConfigInfo,aa as UnreadCountThreadingPolicy,U as User,ab as UserOnlineState}from"./lib/__bundle-85fbca74.js";import{N as Ie,a as Ce,b as Ee,c as Te,g as Pe,M as De,d as Ue,e as Oe,f as Ae,h as Ne,i as Me,j as Le,k as Re,l as ze,m as Qe,L as je,n as Fe,o as qe,p as He,A as xe,I as Ke,q as Ge,U as We,C as Ve,r as Be,B as Je,F as Ye,s as Ze,S as $e,t as Xe,u as et,v as tt,w as nt,x as rt}from"./lib/__bundle-3ceb5f92.js";export{r as ApplicationUserListQuery,y as BannedUserListQuery,z as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,n as LogLevel,o as MemoryStore,D as MutedUserListQuery,O as OperatorListQuery,P as Participant,E as Plugin,R as ReportCategory,G as RestrictedUser,H as RestrictionInfo,J as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-3ceb5f92.js";import{PollModule as it}from"./poll.js";import{g as st,G as ot,A as at,U as ut,a as ct,b as dt,D as lt,R as ht}from"./lib/__bundle-b7a55976.js";import{g as ft,N as pt}from"./lib/__bundle-80bd1744.js";import"./lib/__bundle-acd77193.js";var vt=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 vt(e)})):[]},mt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new gt(e)})):[]},bt={profileImage:void 0,profileUrl:void 0,nickname:void 0},_t=function(e){return function(t,n){return i(void 0,void 0,void 0,(function(){var r,s,o,c;return a(this,(function(d){switch(d.label){case 0:switch(t){case 1:case 2:case 3:case 4:return[3,1];case 5:return[3,2];case 6:return[3,4]}return[3,11];case 1:return n(),[3,12];case 2:return[4,e.store.clear()];case 3:return d.sent(),n(),[3,12];case 4:return d.trys.push([4,9,,10]),r=function(e){return{v2:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Ce,keyName:Ee,index:[st(ot.LATEST_LAST_MESSAGE),st(ot.CHRONOLOGICAL),st(ot.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Ie,keyName:Te,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ue,keyName:Oe,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ae,keyName:Ne}])];case 1:return[2,t.sent()]}}))}))},v3:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Me,keyName:Le,index:[ft("latest_last_message")]}])];case 1:return[2,t.sent()]}}))}))},v4:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Re,keyName:ze,index:[Qe()]}])];case 1:return[2,t.sent()]}}))}))}}}(e),s=r.v2,o=r.v3,c=r.v4,[4,s()];case 5:return d.sent(),[4,o()];case 6:return d.sent(),[4,c()];case 7:return d.sent(),[4,e.collection(Ie).removeIf({where:{channelType:u.OPEN}})];case 8:case 9:return d.sent(),[3,10];case 10:return n(),[3,12];case 11:n(),d.label=12;case 12:return[2]}}))}))}},yt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},wt=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?yt: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 c(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}(d),kt=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 i(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:l.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),St=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=l.PUT,a.path="".concat(h,"/").concat(encodeURIComponent(n)),a.params=f(p({nickname:r,profile_url:i,profile_file:s,preferred_languages:o})),a}return c(t,e),t}(v),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,m({},n)),r}return c(t,e),t}(b),Ct=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),a.params=f({apns_device_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Et=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),a.params=f({gcm_reg_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Pt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Dt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ut=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ot=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=l.GET,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return c(t,e),t}(v),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?_[n.type.toLowerCase()]:_.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return c(t,e),t}(b),Nt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return c(t,e),t}(v),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(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=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return c(t,e),t}(v),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(t,e),t}(b),zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Qt=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 c(t,e),t}(b),jt=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=l.PUT,c.path="".concat(h,"/").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 c(t,e),t}(v),Ft=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 c(t,e),t}(b),qt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Ht=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 c(t,e),t}(b),xt=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=l.PUT,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return c(t,e),t}(v),Kt=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 c(t,e),t}(b),Gt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,n),r}c(t,e)}(b);var Wt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var Vt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Jt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return c(t,e),t}(v),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),r}return c(t,e),t}(v),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),Xt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return c(t,e),t}(v),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),tn=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.GET,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return c(t,e),t}(v),nn=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 g(t,e)})),updatedUsers:n.updated.map((function(e){return new g(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return c(t,e),t}(b),rn=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").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 c(t,e),t}(v),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return c(t,e),t}(b),on=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var an=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new g(t,e)})),r}return c(t,e),t}(b),cn=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var dn=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return c(t,e),t}(v),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return c(t,e),t}(b),hn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var fn,pn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path=w,t}return c(t,e),t}(v),vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new mt(n),r}return c(t,e),t}(b),gn=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(w,"/").concat(n),r}return c(t,e),t}(v),mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new gt(n),r}return c(t,e),t}(b),bn=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(k,"/").concat(n),r}return c(t,e),t}(v),_n=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new vt(n),r}return c(t,e),t}(b),yn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path="".concat(I),t}return c(t,e),t}(v),wn=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 c(t,e),t}(b);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(fn||(fn={}));var kn,Sn=function(e){function t(t){var n=t.deviceToken,r=t.pushTrackingId,i=t.messageId,s=t.allowedPushNotification,o=t.channelKey,a=t.templateKey,u=t.eventType,c=t.notificationEventDeadline,d=e.call(this)||this;return d.method=l.POST,d.path=A,d.params=f({device_token:n,push_tracking_id:r,message_id:i,allowed_push_notification:s,channel_key:o,template_key:a,event_type:u,notification_event_deadline:c}),d}return c(t,e),t}(v);var In=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var s=q.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,d=s.sessionManager,l=s.requestQueue,h=s.logger,f=s.userEventHandlers,p=s.appStateToggleEnabled;this._onlineDetector=new kt({logger:h,connectionDelegate:{reconnect:function(){return i(r,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:if(t=q.of(e),n=t.sdkState,r=t.connectionManager,(i=t.sessionManager).session.hasSession)return[3,5];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.connect(i.session.authToken)];case 2:return a.sent(),[3,4];case 3:if(s=a.sent(),ve(s))throw s;return h.debug("connect failed by reconnect event = ",s),[3,4];case 4:return[3,9];case 5:if("foreground"!==n.appState)return[3,9];a.label=6;case 6:return a.trys.push([6,8,,9]),[4,r.resetAndReconnect()];case 7:return a.sent(),[3,9];case 8:if(o=a.sent(),ve(o))throw o;return h.debug("resetAndReconnect failed by reconnect event = ",o),[3,9];case 9:return c.dispatch(new pt),[2]}}))}))},disconnect:function(){ie((function(){return i(r,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,q.of(e).connectionManager.disconnect()];case 1:return t.sent(),[2]}}))}))}))}}});var v=new at(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,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 wt({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){var n;if(t instanceof se){if(t.stateType===oe.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof ae){if("USEV"===t.code){var s=t.as(ut).event;if(s.category===ct.FRIEND_DISCOVERED){var c=dt.getDataAsFriendDiscoveredEvent(e,s).friendDiscoveries;ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ce){var d=q.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;"number"==typeof p&&p>d.ts&&(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){d.customTypes[e]!==t.customTypes[e]&&(l=!0),d.customTypes[e]=t.customTypes[e]})),l=l&&d.ts>0,d.ts=p),l&&ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof de?(u.preference.set(r._getUserProfileCacheKey(o.userId),le.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(he(r.appId),{value:!0})):t instanceof fe&&t.error&&t.error.isSessionInvalidatedError&&(h.debug("session revoked."),r._internalDisconnect(t.error))}))}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 N: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,g=void 0!==v&&v,m=e.localCacheConfig,b=void 0===m?new M:m,_=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,k=e.useMMKVStorageStore,S=void 0===k?null:k,I=e.appStateToggleEnabled,C=void 0===I||I;if(!kn||f){var E="su-".concat(Q()),T=null!=_?_:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new je;P.level=null!=p?p:Fe.WARN;var D=new qe({encryption:T});c||(j()?S?D=new He({MMKV:S,encryption:T}):w&&(D=new xe({AsyncStorage:w,encryption:T}),P.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):D=new Ke({encryption:T})),new q(E,{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:D,encryption:T,logger:P,localCacheEnabled:g,localCacheConfig:b,debugMode:c,appStateToggleEnabled:C});var U=[new Ge,new it],O=new n(E,a,x(x([],K(s),!1),K(U),!1));return kn||(kn=O),O}return kn},Object.defineProperty(n,"instance",{get:function(){return kn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return W},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?V.OPEN:e.isConnecting?V.CONNECTING:V.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._getNestDBVersion=function(){return 7},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._internalDisconnect=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return t=q.of(this._iid),n=t.connectionManager,r=t.sdkState,i=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),[4,n.logout(e)];case 1:return s.sent(),[4,this.clearCachedData()];case 2:return s.sent(),r.appState="foreground",[2]}}))}))},n.prototype.getMemoryStoreForDebugging=function(){var e=q.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof qe?n.store:null;throw Z.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.addSendbirdExtensions=function(e,t,n){var r,i,s=q.of(this._iid),o=s.logger,a=s.sdkState,u=new RegExp(pe);if(0===e.length)return o.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return o.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=X(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=K(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return o.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return i(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 qe),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.setLocaleForChatbot=function(e){var t=q.of(this._iid).sdkState,n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(e.trim());n&&(t.localeForChatbot=n)},n.prototype.initializeCache=function(e){return i(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:if(t=q.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.dispatcher,s=t.logger,n.userId&&n.userId===e)return[3,11];if(o="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,9];a.label=1;case 1:return a.trys.push([1,6,,8]),r.nestdb&&r.nestdb.state!==rt.CLOSED&&r.nestdb.name===o?[3,3]:(u="sendbird@".concat(n.appId,"/").concat(e,".db"),(c=r.nestdb=new Xe({name:u,version:this._getNestDBVersion(),store:r.store,config:new et({dbname:u,itemSizeLimit:61440})})).on("upgrade",_t(c)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",_t(c))})),[4,c.open()]);case 2:return a.sent(),this._storeInitialized=!0,i.dispatch(new lt(this._iid,{userId:e})),[3,5];case 3:return[4,this._safeInitializeStore(o)];case 4:a.sent(),a.label=5;case 5:return n.userId=e,[3,8];case 6:return d=a.sent(),s.warn("Nest DB Open Failed. ",d),r.store instanceof qe||(r.replaceStore(new qe),r.localCacheEnabled=!1),[4,this._safeInitializeStore(o)];case 7:throw a.sent(),n.userId=e,Z.databaseError;case 8:return[3,11];case 9:return[4,this._safeInitializeStore(o)];case 10:a.sent(),n.userId=e,a.label=11;case 11:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return i(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 i(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 i(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=tt.of(this._iid),n=nt.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return i(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:s.sent(),s.label=2;case 2:return[2]}}))}))},n.prototype._setupPreference=function(e){return i(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.cacheContext,i=t.statManager,[4,r.preference.init(this._getPreferenceCacheKey(e),this._getNestDBVersion())];case 1:return o.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 2:return(s=o.sent())&&new le(this._iid,s).apply(),[4,i.init("sendbird@".concat(n.appId,"/").concat(e,".statlog"))];case 3:return o.sent(),[2]}}))}))},n.prototype._ready=function(e,n,r){return void 0===r&&(r={}),i(this,void 0,void 0,(function(){var i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)&&t("string",n,!0)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.cacheContext,u=i.connectionManager,c=r.errorForOtherUser,s.userId&&s.userId!==e?c?[3,2]:[4,u.logout()]:[3,3];case 1:return a.sent(),[3,3];case 2:throw c;case 3:return a.trys.push([3,5,6,8]),[4,this.initializeCache(e)];case 4:return a.sent(),q.of(this._iid).dispatcher.dispatch(new ht),[3,8];case 5:return a.sent(),d=q.of(this._iid).logger,o.localCacheEnabled=!1,d.warn("Cache initialization failed - cache is not available."),[3,8];case 6:return[4,this._setupPreference(e)];case 7:return a.sent(),[7];case 8:return[2]}}))}))},n.prototype.authenticateFeed=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.authenticate(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.authenticate=function(e,t){var n;return i(this,void 0,void 0,(function(){var r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return r=q.of(this._iid),i=r.sessionManager,s=r.connectionManager,[4,this._ready(e,t,{errorForOtherUser:s.isConnected?Z.alreadyConnectedAsAnotherUser:void 0})];case 1:return a.sent(),(null===(n=i.session.services)||void 0===n?void 0:n.includes(me.CHAT))?[3,3]:(t||i.handler||(o=new $e,this.setSessionHandler(o)),[4,i.authenticate(e,t)]);case 2:a.sent(),a.label=3;case 3:return[2,this.currentUser]}}))}))},n.prototype.connect=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this._ready(e,t)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,,4,5]),[4,q.of(this._iid).connectionManager.connect(t)];case 3:return n.sent(),[3,5];case 4:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 5:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._internalDisconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return i(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(!0)];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().catch((function(e){r.debug("setBackgroundState error = ",e)})))},n.prototype.setForegroundState=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,i=e.logger;"background"===n.appState&&(n.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((function(e){i.debug("setForgroundState error = ",e)})),r.dispatch(new pt))},n.prototype.setSessionHandler=function(e){ee(e instanceof $e).throw(Z.invalidParameters),q.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){ee(t("string",e)&&n instanceof We).throw(Z.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){ee(t("string",e)&&n instanceof Ve).throw(Z.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 Be(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Je(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Ye(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new Ze(this._iid,e)},n.prototype.createPollListQuery=function(e){return new te(this._iid,m({},e))},n.prototype.createPollVoterListQuery=function(e){return new ne(this._iid,m({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=re(e);return new g(this._iid,g.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=m(m({},bt),n),ee(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(Z.invalidParameters),this.currentUser?(i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new St(m({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(It).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw Z.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),this.currentUser?(t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(It).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw Z.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.ANDROID,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.FCM,e)?[2,be.SUCCESS]:(h=new Et({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.FCM,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Pt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Ut({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.IOS,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.APNS,e)?[2,be.SUCCESS]:(h=new Ct({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.APNS,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Tt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Dt({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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.markPushNotificationAsDelivered=function(e,t){var n;return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_,y,w,k;return a(this,(function(a){switch(a.label){case 0:if(r=q.of(this._iid),i=r.logger,s=r.sessionManager,o=r.requestQueue,u=r.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=fn.DELIVERED,d=u.parseData(e),l=d.pushTrackingId,h=d.sessionTopics,f=d.sessionKey,p=d.messageId,v=d.channelKey,g=d.templateKey,m=d.notificationEventDeadline,!f)throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!h.includes(we.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(u.isAcked(l,c))return i.info("already delivered push notification:",l),[2];b=Boolean(v),_=t&&b,y=null===(n=s.deviceTokens[0])||void 0===n?void 0:n.token,w=new Sn({deviceToken:null!=y?y:"",pushTrackingId:l,eventType:c,messageId:p,channelKey:v,templateKey:g,notificationEventDeadline:m,allowedPushNotification:_}),f&&(w.headers["Session-Key"]=f),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,o.send(w)];case 2:return a.sent(),u.markAsAcked(l,c),[3,4];case 3:throw k=a.sent(),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(l,". error: ").concat(k)),k;case 4:return[2]}}))}))},n.prototype.markPushNotificationAsClicked=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_;return a(this,(function(a){switch(a.label){case 0:if(n=q.of(this._iid),r=n.logger,i=n.sessionManager,s=n.requestQueue,o=n.pushNotificationAckManager,r.debug("markPushNotificationAsClicked:",e),u=fn.CLICKED,c=o.parseData(e),d=c.pushTrackingId,l=c.sessionTopics,h=c.sessionKey,f=c.messageId,p=c.channelKey,v=c.templateKey,g=c.notificationEventDeadline,!h)throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!l.includes(we.PUSH_ACKNOWLEDGEMENT))throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(o.isAcked(d,u))return r.info("already clicked push notification:",d),[2];m=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,b=new Sn({deviceToken:null!=m?m:"",pushTrackingId:d,eventType:u,messageId:f,channelKey:p,templateKey:v,notificationEventDeadline:g}),h&&(b.headers["Session-Key"]=h),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,s.send(b)];case 2:return a.sent(),o.markAsAcked(d,u),[3,4];case 3:throw _=a.sent(),r.debug("failed to mark push notification as clicked. push tracking id: ".concat(d,". error: ").concat(_)),_;case 4:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return i(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 Nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Mt).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)).throw(Z.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(Rt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return i(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 zt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Qt).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,s,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===u&&(u=""),i(this,void 0,void 0,(function(){var i,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",s)&&t("number",o)&&t("string",u)).throw(Z.invalidParameters),i=q.of(this._iid),c=i.sdkState,d=i.requestQueue,l=new jt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:s,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(Ft).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return i(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(Ht).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),i(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new xt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(Kt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return i(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 ee(t("string",e)&&_e(_,n)).throw(Z.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new Ot({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(At).pushTokens;try{for(l=X(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 i(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 Vt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Bt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(ke,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Jt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Yt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return i(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 Zt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as($t).name]}}))}))},n.prototype.setPushTemplate=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(Se,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(en).name]}}))}))},n.prototype.blockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Gt({userId:r.userId,blockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Wt({userId:r.userId,unblockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new tn({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(nn).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return i(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 dn({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ln).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(t("boolean",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new hn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return i(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 rn({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(sn).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new on({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new an({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(un).users]}}))}))},n.prototype.deleteFriend=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new cn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return i(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 pn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(vn).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return i(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 gn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(mn).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return i(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 bn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(_n).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return i(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),ee(e.hasExtension("sb_uikit")).throw(Z.notSupportedError),t=e.requestQueue,n=new yn,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(wn).uikitConfiguration]}}))}))},n}();export{vt as Emoji,gt as EmojiCategory,mt as EmojiContainer,In as default}; +import{i as e,a as t,_ as i,b as a,C as u,c,E as d,A as l,d as h,e as f,u as p,f as v,U as g,g as m,h as b,P as _,j as w,k,l as I,m as A,S as N,L as M,n as Q,o as j,V as q,p as x,q as K,v as W,r as V,s as Z,t as X,w as ee,x as te,y as ne,z as re,B as ie,D as se,F as oe,W as ae,G as ue,H as ce,I as de,J as le,K as he,M as fe,N as pe,O as ve,Q as ge,R as me,T as be,X as _e,Y as ye,Z as we,$ as ke,a0 as Se}from"./lib/__bundle-1db3fd0b.js";export{a1 as AppInfo,a3 as CachedChannelInfo,a4 as CachedDataClearOrder,C as ChannelType,a2 as CollectionEventSource,r as ConnectionState,Y as DeviceOsPlatform,a5 as LastMessageThreadingPolicy,L as LocalCacheConfig,a6 as NotificationInfo,a0 as PushTemplate,T as PushTokenRegistrationState,P as PushTokenType,$ as PushTriggerOption,a7 as Role,S as SendbirdChatOptions,s as SendbirdError,a8 as SendbirdErrorCode,ad as SendbirdPlatform,ac as SendbirdProduct,a9 as UIKitConfigInfo,aa as UnreadCountThreadingPolicy,U as User,ab as UserOnlineState}from"./lib/__bundle-1db3fd0b.js";import{N as Ie,a as Ce,b as Ee,c as Te,g as Pe,M as De,d as Ue,e as Oe,f as Ae,h as Ne,i as Me,j as Le,k as Re,l as ze,m as Qe,L as je,n as Fe,o as qe,p as He,A as xe,I as Ke,q as Ge,U as We,C as Ve,r as Be,B as Je,F as Ye,s as Ze,S as $e,t as Xe,u as et,v as tt,w as nt,x as rt}from"./lib/__bundle-e1a5e3f1.js";export{r as ApplicationUserListQuery,y as BannedUserListQuery,z as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,n as LogLevel,o as MemoryStore,D as MutedUserListQuery,O as OperatorListQuery,P as Participant,E as Plugin,R as ReportCategory,G as RestrictedUser,H as RestrictionInfo,J as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-e1a5e3f1.js";import{PollModule as it}from"./poll.js";import{g as st,G as ot,A as at,U as ut,a as ct,b as dt,D as lt,R as ht}from"./lib/__bundle-24f017be.js";import{g as ft,N as pt}from"./lib/__bundle-31d4ecef.js";import"./lib/__bundle-acd77193.js";var vt=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 vt(e)})):[]},mt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new gt(e)})):[]},bt={profileImage:void 0,profileUrl:void 0,nickname:void 0},_t=function(e){return function(t,n){return i(void 0,void 0,void 0,(function(){var r,s,o,c;return a(this,(function(d){switch(d.label){case 0:switch(t){case 1:case 2:case 3:case 4:return[3,1];case 5:return[3,2];case 6:return[3,4]}return[3,11];case 1:return n(),[3,12];case 2:return[4,e.reset()];case 3:return d.sent(),n(),[3,12];case 4:return d.trys.push([4,9,,10]),r=function(e){return{v2:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Ce,keyName:Ee,index:[st(ot.LATEST_LAST_MESSAGE),st(ot.CHRONOLOGICAL),st(ot.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Ie,keyName:Te,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ue,keyName:Oe,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ae,keyName:Ne}])];case 1:return[2,t.sent()]}}))}))},v3:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Me,keyName:Le,index:[ft("latest_last_message")]}])];case 1:return[2,t.sent()]}}))}))},v4:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Re,keyName:ze,index:[Qe()]}])];case 1:return[2,t.sent()]}}))}))}}}(e),s=r.v2,o=r.v3,c=r.v4,[4,s()];case 5:return d.sent(),[4,o()];case 6:return d.sent(),[4,c()];case 7:return d.sent(),[4,e.collection(Ie).removeIf({where:{channelType:u.OPEN}})];case 8:case 9:return d.sent(),[3,10];case 10:return n(),[3,12];case 11:n(),d.label=12;case 12:return[2]}}))}))}},yt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},wt=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?yt: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 c(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}(d),kt=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 i(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:l.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),St=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=l.PUT,a.path="".concat(h,"/").concat(encodeURIComponent(n)),a.params=f(p({nickname:r,profile_url:i,profile_file:s,preferred_languages:o})),a}return c(t,e),t}(v),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,m({},n)),r}return c(t,e),t}(b),Ct=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),a.params=f({apns_device_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Et=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),a.params=f({gcm_reg_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Pt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Dt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ut=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ot=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=l.GET,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return c(t,e),t}(v),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?_[n.type.toLowerCase()]:_.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return c(t,e),t}(b),Nt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return c(t,e),t}(v),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(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=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return c(t,e),t}(v),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(t,e),t}(b),zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Qt=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 c(t,e),t}(b),jt=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=l.PUT,c.path="".concat(h,"/").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 c(t,e),t}(v),Ft=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 c(t,e),t}(b),qt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Ht=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 c(t,e),t}(b),xt=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=l.PUT,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return c(t,e),t}(v),Kt=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 c(t,e),t}(b),Gt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,n),r}c(t,e)}(b);var Wt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var Vt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Jt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return c(t,e),t}(v),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),r}return c(t,e),t}(v),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),Xt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return c(t,e),t}(v),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),tn=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.GET,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return c(t,e),t}(v),nn=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 g(t,e)})),updatedUsers:n.updated.map((function(e){return new g(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return c(t,e),t}(b),rn=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").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 c(t,e),t}(v),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return c(t,e),t}(b),on=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var an=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new g(t,e)})),r}return c(t,e),t}(b),cn=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var dn=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return c(t,e),t}(v),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return c(t,e),t}(b),hn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var fn,pn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path=w,t}return c(t,e),t}(v),vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new mt(n),r}return c(t,e),t}(b),gn=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(w,"/").concat(n),r}return c(t,e),t}(v),mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new gt(n),r}return c(t,e),t}(b),bn=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(k,"/").concat(n),r}return c(t,e),t}(v),_n=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new vt(n),r}return c(t,e),t}(b),yn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path="".concat(I),t}return c(t,e),t}(v),wn=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 c(t,e),t}(b);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(fn||(fn={}));var kn,Sn=function(e){function t(t){var n=t.deviceToken,r=t.pushTrackingId,i=t.messageId,s=t.allowedPushNotification,o=t.channelKey,a=t.templateKey,u=t.eventType,c=t.notificationEventDeadline,d=e.call(this)||this;return d.method=l.POST,d.path=A,d.params=f({device_token:n,push_tracking_id:r,message_id:i,allowed_push_notification:s,channel_key:o,template_key:a,event_type:u,notification_event_deadline:c}),d}return c(t,e),t}(v);var In=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var s=q.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,d=s.sessionManager,l=s.requestQueue,h=s.logger,f=s.userEventHandlers,p=s.appStateToggleEnabled;this._onlineDetector=new kt({logger:h,connectionDelegate:{reconnect:function(){return i(r,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:if(t=q.of(e),n=t.sdkState,r=t.connectionManager,(i=t.sessionManager).session.hasSession)return[3,5];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.connect(i.session.authToken)];case 2:return a.sent(),[3,4];case 3:if(s=a.sent(),ve(s))throw s;return h.debug("connect failed by reconnect event = ",s),[3,4];case 4:return[3,9];case 5:if("foreground"!==n.appState)return[3,9];a.label=6;case 6:return a.trys.push([6,8,,9]),[4,r.resetAndReconnect()];case 7:return a.sent(),[3,9];case 8:if(o=a.sent(),ve(o))throw o;return h.debug("resetAndReconnect failed by reconnect event = ",o),[3,9];case 9:return c.dispatch(new pt),[2]}}))}))},disconnect:function(){ie((function(){return i(r,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,q.of(e).connectionManager.disconnect()];case 1:return t.sent(),[2]}}))}))}))}}});var v=new at(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,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 wt({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){var n;if(t instanceof se){if(t.stateType===oe.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof ae){if("USEV"===t.code){var s=t.as(ut).event;if(s.category===ct.FRIEND_DISCOVERED){var c=dt.getDataAsFriendDiscoveredEvent(e,s).friendDiscoveries;ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ce){var d=q.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;"number"==typeof p&&p>d.ts&&(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){d.customTypes[e]!==t.customTypes[e]&&(l=!0),d.customTypes[e]=t.customTypes[e]})),l=l&&d.ts>0,d.ts=p),l&&ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof de?(u.preference.set(r._getUserProfileCacheKey(o.userId),le.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(he(r.appId),{value:!0})):t instanceof fe&&t.error&&t.error.isSessionInvalidatedError&&(h.debug("session revoked."),r._internalDisconnect(t.error))}))}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 N: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,g=void 0!==v&&v,m=e.localCacheConfig,b=void 0===m?new M:m,_=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,k=e.useMMKVStorageStore,S=void 0===k?null:k,I=e.appStateToggleEnabled,C=void 0===I||I;if(!kn||f){var E="su-".concat(Q()),T=null!=_?_:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new je;P.level=null!=p?p:Fe.WARN;var D=new qe({encryption:T});c||(j()?S?D=new He({MMKV:S,encryption:T}):w&&(D=new xe({AsyncStorage:w,encryption:T}),P.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):D=new Ke({encryption:T})),new q(E,{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:D,encryption:T,logger:P,localCacheEnabled:g,localCacheConfig:b,debugMode:c,appStateToggleEnabled:C});var U=[new Ge,new it],O=new n(E,a,x(x([],K(s),!1),K(U),!1));return kn||(kn=O),O}return kn},Object.defineProperty(n,"instance",{get:function(){return kn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return W},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?V.OPEN:e.isConnecting?V.CONNECTING:V.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._getNestDBVersion=function(){return 7},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._internalDisconnect=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return t=q.of(this._iid),n=t.connectionManager,r=t.sdkState,i=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),[4,n.logout(e)];case 1:return s.sent(),[4,this.clearCachedData()];case 2:return s.sent(),r.appState="foreground",[2]}}))}))},n.prototype.getMemoryStoreForDebugging=function(){var e=q.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof qe?n.store:null;throw Z.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.addSendbirdExtensions=function(e,t,n){var r,i,s=q.of(this._iid),o=s.logger,a=s.sdkState,u=new RegExp(pe);if(0===e.length)return o.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return o.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=X(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=K(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return o.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return i(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 qe),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.setLocaleForChatbot=function(e){var t=q.of(this._iid).sdkState,n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(e.trim());n&&(t.localeForChatbot=n)},n.prototype.initializeCache=function(e){return i(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:if(t=q.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.dispatcher,s=t.logger,n.userId&&n.userId===e)return[3,13];o="sendbird@".concat(n.appId,"/").concat(e,".db"),a.label=1;case 1:return a.trys.push([1,9,11,13]),r.localCacheEnabled?r.nestdb&&r.nestdb.state!==tt.CLOSED&&r.nestdb.name===o?[3,3]:(u="sendbird@".concat(n.appId,"/").concat(e,".db"),(c=r.nestdb=new nt({name:u,version:this._getNestDBVersion(),store:r.store,config:new rt({dbname:u,itemSizeLimit:61440})})).on("upgrade",_t(c)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",_t(c))})),[4,c.open()]):[3,6];case 2:return a.sent(),this._storeInitialized=!0,i.dispatch(new lt(this._iid,{userId:e})),[3,5];case 3:return[4,this._safeInitializeStore(o)];case 4:a.sent(),a.label=5;case 5:return n.userId=e,[3,8];case 6:return[4,this._safeInitializeStore(o)];case 7:a.sent(),n.userId=e,a.label=8;case 8:return[3,13];case 9:return d=a.sent(),s.warn("Nest DB Open Failed. ",d),r.store instanceof qe||(r.replaceStore(new qe),r.localCacheEnabled=!1),[4,this._safeInitializeStore(o)];case 10:throw a.sent(),n.userId=e,Z.databaseError;case 11:return[4,this._setupPreference(e)];case 12:return a.sent(),[7];case 13:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return i(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 i(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 i(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=Xe.of(this._iid),n=et.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return i(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:s.sent(),s.label=2;case 2:return[2]}}))}))},n.prototype._setupPreference=function(e){return i(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.cacheContext,i=t.statManager,[4,r.preference.init(this._getPreferenceCacheKey(e),this._getNestDBVersion())];case 1:return o.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 2:return(s=o.sent())&&new le(this._iid,s).apply(),[4,i.init("sendbird@".concat(n.appId,"/").concat(e,".statlog"))];case 3:return o.sent(),[2]}}))}))},n.prototype._ready=function(e,n,r){return void 0===r&&(r={}),i(this,void 0,void 0,(function(){var i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)&&t("string",n,!0)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.cacheContext,u=i.connectionManager,c=r.errorForOtherUser,s.userId&&s.userId!==e?c?[3,2]:[4,u.logout()]:[3,3];case 1:return a.sent(),[3,3];case 2:throw c;case 3:return a.trys.push([3,5,,6]),[4,this.initializeCache(e)];case 4:return a.sent(),q.of(this._iid).dispatcher.dispatch(new ht),[3,6];case 5:return a.sent(),d=q.of(this._iid).logger,o.localCacheEnabled=!1,d.warn("Cache initialization failed - cache is not available."),[3,6];case 6:return[2]}}))}))},n.prototype.authenticateFeed=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.authenticate(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.authenticate=function(e,t){var n;return i(this,void 0,void 0,(function(){var r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return r=q.of(this._iid),i=r.sessionManager,s=r.connectionManager,[4,this._ready(e,t,{errorForOtherUser:s.isConnected?Z.alreadyConnectedAsAnotherUser:void 0})];case 1:return a.sent(),(null===(n=i.session.services)||void 0===n?void 0:n.includes(me.CHAT))?[3,3]:(t||i.handler||(o=new $e,this.setSessionHandler(o)),[4,i.authenticate(e,t)]);case 2:a.sent(),a.label=3;case 3:return[2,this.currentUser]}}))}))},n.prototype.connect=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this._ready(e,t)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,,4,5]),[4,q.of(this._iid).connectionManager.connect(t)];case 3:return n.sent(),[3,5];case 4:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 5:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._internalDisconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return i(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(!0)];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().catch((function(e){r.debug("setBackgroundState error = ",e)})))},n.prototype.setForegroundState=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,i=e.logger;"background"===n.appState&&(n.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((function(e){i.debug("setForgroundState error = ",e)})),r.dispatch(new pt))},n.prototype.setSessionHandler=function(e){ee(e instanceof $e).throw(Z.invalidParameters),q.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){ee(t("string",e)&&n instanceof We).throw(Z.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){ee(t("string",e)&&n instanceof Ve).throw(Z.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 Be(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Je(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Ye(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new Ze(this._iid,e)},n.prototype.createPollListQuery=function(e){return new te(this._iid,m({},e))},n.prototype.createPollVoterListQuery=function(e){return new ne(this._iid,m({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=re(e);return new g(this._iid,g.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=m(m({},bt),n),ee(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(Z.invalidParameters),this.currentUser?(i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new St(m({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(It).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw Z.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),this.currentUser?(t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(It).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw Z.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.ANDROID,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.FCM,e)?[2,be.SUCCESS]:(h=new Et({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.FCM,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Pt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Ut({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.IOS,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.APNS,e)?[2,be.SUCCESS]:(h=new Ct({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.APNS,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Tt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Dt({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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.markPushNotificationAsDelivered=function(e,t){var n;return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_,y,w,k;return a(this,(function(a){switch(a.label){case 0:if(r=q.of(this._iid),i=r.logger,s=r.sessionManager,o=r.requestQueue,u=r.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=fn.DELIVERED,d=u.parseData(e),l=d.pushTrackingId,h=d.sessionTopics,f=d.sessionKey,p=d.messageId,v=d.channelKey,g=d.templateKey,m=d.notificationEventDeadline,!f)throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!h.includes(we.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(u.isAcked(l,c))return i.info("already delivered push notification:",l),[2];b=Boolean(v),_=t&&b,y=null===(n=s.deviceTokens[0])||void 0===n?void 0:n.token,w=new Sn({deviceToken:null!=y?y:"",pushTrackingId:l,eventType:c,messageId:p,channelKey:v,templateKey:g,notificationEventDeadline:m,allowedPushNotification:_}),f&&(w.headers["Session-Key"]=f),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,o.send(w)];case 2:return a.sent(),u.markAsAcked(l,c),[3,4];case 3:throw k=a.sent(),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(l,". error: ").concat(k)),k;case 4:return[2]}}))}))},n.prototype.markPushNotificationAsClicked=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_;return a(this,(function(a){switch(a.label){case 0:if(n=q.of(this._iid),r=n.logger,i=n.sessionManager,s=n.requestQueue,o=n.pushNotificationAckManager,r.debug("markPushNotificationAsClicked:",e),u=fn.CLICKED,c=o.parseData(e),d=c.pushTrackingId,l=c.sessionTopics,h=c.sessionKey,f=c.messageId,p=c.channelKey,v=c.templateKey,g=c.notificationEventDeadline,!h)throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!l.includes(we.PUSH_ACKNOWLEDGEMENT))throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(o.isAcked(d,u))return r.info("already clicked push notification:",d),[2];m=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,b=new Sn({deviceToken:null!=m?m:"",pushTrackingId:d,eventType:u,messageId:f,channelKey:p,templateKey:v,notificationEventDeadline:g}),h&&(b.headers["Session-Key"]=h),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,s.send(b)];case 2:return a.sent(),o.markAsAcked(d,u),[3,4];case 3:throw _=a.sent(),r.debug("failed to mark push notification as clicked. push tracking id: ".concat(d,". error: ").concat(_)),_;case 4:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return i(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 Nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Mt).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)).throw(Z.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(Rt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return i(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 zt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Qt).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,s,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===u&&(u=""),i(this,void 0,void 0,(function(){var i,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",s)&&t("number",o)&&t("string",u)).throw(Z.invalidParameters),i=q.of(this._iid),c=i.sdkState,d=i.requestQueue,l=new jt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:s,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(Ft).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return i(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(Ht).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),i(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new xt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(Kt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return i(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 ee(t("string",e)&&_e(_,n)).throw(Z.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new Ot({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(At).pushTokens;try{for(l=X(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 i(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 Vt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Bt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(ke,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Jt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Yt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return i(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 Zt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as($t).name]}}))}))},n.prototype.setPushTemplate=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(Se,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(en).name]}}))}))},n.prototype.blockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Gt({userId:r.userId,blockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Wt({userId:r.userId,unblockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new tn({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(nn).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return i(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 dn({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ln).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(t("boolean",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new hn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return i(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 rn({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(sn).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new on({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new an({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(un).users]}}))}))},n.prototype.deleteFriend=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new cn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return i(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 pn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(vn).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return i(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 gn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(mn).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return i(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 bn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(_n).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return i(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),ee(e.hasExtension("sb_uikit")).throw(Z.notSupportedError),t=e.requestQueue,n=new yn,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(wn).uikitConfiguration]}}))}))},n}();export{vt as Emoji,gt as EmojiCategory,mt as EmojiContainer,In as default}; diff --git a/lib/__bundle-a7b76e00.js b/lib/__bundle-123134d8.js similarity index 89% rename from lib/__bundle-a7b76e00.js rename to lib/__bundle-123134d8.js index e7d4864..c0e480d 100644 --- a/lib/__bundle-a7b76e00.js +++ b/lib/__bundle-123134d8.js @@ -1 +1 @@ -import{aA as e}from"./__bundle-85fbca74.js";var t=function(){this.onUserMuted=e,this.onUserUnmuted=e,this.onUserBanned=e,this.onUserUnbanned=e,this.onChannelChanged=e,this.onChannelDeleted=e,this.onChannelFrozen=e,this.onChannelUnfrozen=e,this.onOperatorUpdated=e,this.onChannelMemberCountChanged=e,this.onMetaDataCreated=e,this.onMetaDataUpdated=e,this.onMetaDataDeleted=e,this.onMetaCounterCreated=e,this.onMetaCounterUpdated=e,this.onMetaCounterDeleted=e,this.onMessageReceived=e,this.onMessageUpdated=e,this.onMessageDeleted=e,this.onMentionReceived=e,this.onReactionUpdated=e,this.onThreadInfoUpdated=e};export{t as B}; +import{aA as e}from"./__bundle-1db3fd0b.js";var t=function(){this.onUserMuted=e,this.onUserUnmuted=e,this.onUserBanned=e,this.onUserUnbanned=e,this.onChannelChanged=e,this.onChannelDeleted=e,this.onChannelFrozen=e,this.onChannelUnfrozen=e,this.onOperatorUpdated=e,this.onChannelMemberCountChanged=e,this.onMetaDataCreated=e,this.onMetaDataUpdated=e,this.onMetaDataDeleted=e,this.onMetaCounterCreated=e,this.onMetaCounterUpdated=e,this.onMetaCounterDeleted=e,this.onMessageReceived=e,this.onMessageUpdated=e,this.onMessageDeleted=e,this.onMentionReceived=e,this.onReactionUpdated=e,this.onThreadInfoUpdated=e};export{t as B}; diff --git a/lib/__bundle-1db3fd0b.js b/lib/__bundle-1db3fd0b.js new file mode 100644 index 0000000..11a2cfc --- /dev/null +++ b/lib/__bundle-1db3fd0b.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 i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[i++],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 i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function c(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r0&&b.indexOf(e)>=0},I=function(e){return e>0&&m.indexOf(e)>=0},k=function(e,t){if(void 0===t&&(t=!1),t&&D(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},O=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(),i=c([],a(t),!1).sort(),r=0;r=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}(),L={encrypt:function(e){return e},decrypt:function(e){return e}},x=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return r(this,void 0,void 0,(function(){return s(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),r(this,void 0,void 0,(function(){var i,r,a,c,u,l,h,d,_,f;return s(this,(function(s){switch(s.label){case 0:return this._version=t,this._keysAddress=e,i="".concat(e,".metadata.version"),[4,this._store.get(i)];case 1:return r=s.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=s.sent())&&void 0!==n?n:[],!r||r.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(i,64),o?(this._clearOrder=s,this._customClearOrderComparator=o):this._clearOrder=E.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=c}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===E.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableAutoResend",{get:function(){return this._enableAutoResend},enumerable:!1,configurable:!0}),e}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(P||(P={}));var q,V,H,z,G,j,K,B,Q,W,Z,Y,X,J=function(){function e(){this.isRefreshing=!1}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasChatServicePermission",{get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(P.CHAT))},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]},e}(),$=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)}))},ee=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=$()}return e.prototype._register=function(e,t,n){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: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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))},e}(),te=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new ee({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new ee({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,i,r=this._container[e];if(r){var s=[];try{for(var a=o(r.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=r.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&s.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}s.forEach((function(e){return r.delete(e)}))}},e}(),ne=function(){function e(){this._dispatcher=new te}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}(),ie=function(){},re=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},se=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){for(var t=c([],a(e),!1),n=0;n0&&(i.extension_sdk_info=r.map((function(e){var t=e.product,n=e.platform,i=e.version;return"".concat(t,"/").concat(n,"/").concat(i)})).join(",")),Object.keys(i).forEach((function(e){return delete c[e]})),Object.keys(c).length>0&&(i=n(n({},i),c))}return Object.entries(i).map((function(e){var t=a(e,2),n=t[0],i=t[1];return"".concat(n,"=").concat(i)})).join("&")},e.userAgentWithExtension=function(e){var t=Ye()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",i=e.sb_uikit?"u".concat(e.sb_uikit):"",r=e["device-os-platform"]?"o".concat(e["device-os-platform"]):Xe()?"omobile-web":"oweb";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(i,"/").concat(r)},e}(),et=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=function(e){n(e)}}))},tt=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t.requestId,n}return t(n,e),n}(ie),nt=function(e){function n(t){var n=e.call(this)||this;return n.method=oe.DELETE,n.path="".concat(Ie(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),t.messageToken&&(n.params=re({mesg_token:t.messageToken})),n}return t(n,e),n}(xe);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Ue);var it=function(e){function n(t,n,i){var r,s=this;return(s=e.call(this,t,"DELM",i)||this).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(r=i.sender_id)&&void 0!==r?r:void 0,s}return t(n,e),n}(Fe),rt=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=n,this._sdkState=i,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof Pe&&c.cancel(e.requestId)})),this._logger=s,this._shouldImportFetchCompat=a}return e.prototype._createHeader=function(e,t){var i=this._sdkState,r=i.appId,s=i.appVersion,o=i.sendbirdRuntimeEnvironment,a=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(r).concat(s?",".concat(s):""),"SB-User-Agent":$e.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":$e.sendbirdSdkUserAgentWithExtension(o)});return t||(a["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(a["Session-Key"]=this._session.sessionKey),a["App-Id"]=r,this._session&&this._session.authToken&&(a["Access-Token"]=this._session.authToken),a},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new je(new Ze({type:Le.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._isBodyRequired=function(e){var t=e.method;return t!==oe.GET&&(t!==oe.DELETE||e instanceof nt)},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a,c,l,h,d,_,f,p,E,g,b,m,y,w;return s(this,(function(s){switch(s.label){case 0:t=e.path,n=e.method,i=e.uploadProgressHandler,r=this._isBodyRequired(e),o=this._sdkState.api,a="".concat(o.host).concat(t).concat(r?"":e.query),c=r?e.payload:null,l=this._createHeader(e,c instanceof FormData?c:void 0),h=new AbortController,d=h.signal,this._abortControl.set(e.requestId,h),_=Date.now(),s.label=1;case 1:return s.trys.push([1,13,,14]),i?[4,import("./__bundle-4b40b3a8.js")]:[3,6];case 2:f=s.sent().xmlHttpRequest,s.label=3;case 3:return s.trys.push([3,5,,6]),[4,f(this._iid,{requestId:e.requestId,method:e.method,url:a,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i})];case 4:return p=s.sent(),this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,p];case 5:if(!((E=s.sent())instanceof v&&E.code===u.XMLHTTPREQUEST_NOT_SUPPORTED))throw E;return this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),[3,6];case 6:return 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,8]:[4,import("./__bundle-7c3d40f4.js")];case 7:s.sent(),s.label=8;case 8:return"function"==typeof fetch?[3,10]:[4,import("./__bundle-46d64517.js")];case 9:s.sent(),s.label=10;case 10:return[4,fetch(a,{method:n,body:c,headers:l,signal:d})];case 11:return[4,(g=s.sent()).json()];case 12:if(b=s.sent(),g.ok||g.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,new Ue(this._iid,b)];if(b){if((m=new v(b)).isSessionExpiredError){if(this._dispatcher.dispatch(new Me({reason:m.code,message:m.message})),!(e instanceof Ve))return y=new et,this._dispatcher.dispatch(new Ke({request:e,deferred:y,error:m})),[2,y.promise];throw m}throw m.isSessionInvalidatedError?(this._dispatcher.dispatch(new Me({reason:m.code,message:m.message})),m):m}throw v.requestFailed;case 13:throw w=s.sent(),this._statLogApiResult(e,_,w),w instanceof v?(this._logger.debug("fail api request",w),w):"AbortError"===(null==w?void 0:w.name)?v.requestCanceled:(this._logger.debug("fail api request",w),v.networkError);case 14:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new tt({requestId:e}))},e.prototype.cancelAll=function(){var e,t;try{for(var n=o(this._abortControl.values()),i=n.next();!i.done;i=n.next()){i.value.abort()}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear(),this._dispatcher.dispatch(new tt({}))},e}(),st=function(){};function ot(e){let t=e.length;for(;--t>=0;)e[t]=0}const at=256,ct=286,ut=30,lt=15,ht=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]),dt=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]),_t=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ft=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pt=new Array(576);ot(pt);const Et=new Array(60);ot(Et);const gt=new Array(512);ot(gt);const vt=new Array(256);ot(vt);const bt=new Array(29);ot(bt);const mt=new Array(ut);function yt(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}let wt,St,Tt;function Nt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ot(mt);const Ct=e=>e<256?gt[e]:gt[256+(e>>>7)],At=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},It=(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<{It(e,n[2*t],n[2*t+1])},Ot=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},Dt=(e,t,n)=>{const i=new Array(16);let r,s,o=0;for(r=1;r<=lt;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=Ot(i[t]++,t))}},Rt=e=>{let t;for(t=0;t{e.bi_valid>8?At(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},xt=(e,t,n,i)=>{const r=2*t,s=2*n;return e[r]{const i=e.heap[n];let r=n<<1;for(;r<=e.heap_len&&(r{let i,r,s,o,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,r=e.pending_buf[e.sym_buf+a++],0===i?kt(e,r,t):(s=vt[r],kt(e,s+at+1,t),o=ht[s],0!==o&&(r-=bt[s],It(e,r,o)),i--,s=Ct(i),kt(e,s,n),o=dt[s],0!==o&&(i-=mt[s],It(e,i,o)))}while(a{const n=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)Ut(e,n,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ut(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,n[2*c]=n[2*o]+n[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,n[2*o+1]=n[2*a+1]=c,e.heap[1]=c++,Ut(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,i=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=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<=lt;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>i||(e.bl_count[d]++,_=0,l>=a&&(_=o[l-a]),f=n[2*l],e.opt_len+=f*(d+_),s&&(e.static_len+=f*(r[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>i||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),Dt(n,u,e.bl_count)},Ft=(e,t,n)=>{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=t[2*(i+1)+1],++a{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),i=0;i<=n;i++)if(r=o,o=t[2*(i+1)+1],!(++a{It(e,0+(i?1:0),3),Lt(e),At(e,n),At(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var zt=(e,t,n,i)=>{let r,s,o=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(Ft(e,e.dyn_ltree,e.l_desc.max_code),Ft(e,e.dyn_dtree,e.d_desc.max_code),Mt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ft[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&-1!==t?Ht(e,t,n,i):4===e.strategy||s===r?(It(e,2+(i?1:0),3),Pt(e,pt,Et)):(It(e,4+(i?1:0),3),((e,t,n,i)=>{let r;for(It(e,t-257,5),It(e,n-1,5),It(e,i-4,4),r=0;r{Vt||((()=>{let e,t,n,i,r;const s=new Array(16);for(n=0,i=0;i<28;i++)for(bt[i]=n,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++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(vt[n]+at+1)]++,e.dyn_dtree[2*Ct(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{It(e,2,3),kt(e,256,pt),(e=>{16===e.bi_valid?(At(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 jt=(e,t,n,i)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+t[i++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Kt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Bt=(e,t,n,i)=>{const r=Kt,s=i+n;e^=-1;for(let n=i;n>>8^r[255&(e^t[n])];return~e},Qt={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"},Wt={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:Zt,_tr_stored_block:Yt,_tr_flush_block:Xt,_tr_tally:Jt,_tr_align:$t}=Gt,{Z_NO_FLUSH:en,Z_PARTIAL_FLUSH:tn,Z_FULL_FLUSH:nn,Z_FINISH:rn,Z_BLOCK:sn,Z_OK:on,Z_STREAM_END:an,Z_STREAM_ERROR:cn,Z_DATA_ERROR:un,Z_BUF_ERROR:ln,Z_DEFAULT_COMPRESSION:hn,Z_FILTERED:dn,Z_HUFFMAN_ONLY:_n,Z_RLE:fn,Z_FIXED:pn,Z_DEFAULT_STRATEGY:En,Z_UNKNOWN:gn,Z_DEFLATED:vn}=Wt,bn=258,mn=262,yn=42,wn=113,Sn=666,Tn=(e,t)=>(e.msg=Qt[t],t),Nn=e=>2*e-(e>4?9:0),Cn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},An=e=>{let t,n,i,r=e.w_size;t=e.hash_size,i=t;do{n=e.head[--i],e.head[i]=n>=r?n-r:0}while(--t);t=r,i=t;do{n=e.prev[--i],e.prev[i]=n>=r?n-r:0}while(--t)};let In=(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))},On=(e,t)=>{Xt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,kn(e.strm)},Dn=(e,t)=>{e.pending_buf[e.pending++]=t},Rn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Ln=(e,t,n,i)=>{let r=e.avail_in;return r>i&&(r=i),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),n),1===e.state.wrap?e.adler=jt(e.adler,t,r,n):2===e.state.wrap&&(e.adler=Bt(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)},xn=(e,t)=>{let n,i,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-mn?e.strstart-(e.w_size-mn):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+bn;let _=u[s+o-1],f=u[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+o]===f&&u[n+o-1]===_&&u[n]===u[s]&&u[++n]===u[s+1]){s+=2,n++;do{}while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&so){if(e.match_start=t,o=i,i>=a)break;_=u[s+o-1],f=u[s+o]}}}while((t=h[t&l])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead},Un=e=>{const t=e.w_size;let n,i,r;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-mn)&&(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),An(e),i+=t),0===e.strm.avail_in)break;if(n=Ln(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=n,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=In(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=In(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,i,r,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(n=65535,r=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(n=i+e.strm.avail_in),n>r&&(n=r),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,kn(e.strm),i&&(i>n&&(i=n),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,n-=i),n&&(Ln(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===o);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_waterr&&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++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(Ln(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,s=r>e.w_size?e.w_size:r,i=e.strstart-e.block_start,(i>=s||(i||t===rn)&&t!==en&&0===e.strm.avail_in&&i<=r)&&(n=i>r?r:i,o=t===rn&&0===e.strm.avail_in&&n===i?1:0,Yt(e,e.block_start,n,o),e.block_start+=n,kn(e.strm)),o?3:1)},Mn=(e,t)=>{let n,i;for(;;){if(e.lookahead=3&&(e.ins_h=In(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-mn&&(e.match_length=xn(e,n)),e.match_length>=3)if(i=Jt(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=In(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=In(e,e.ins_h,e.window[e.strstart+1]);else i=Jt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(On(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2},Fn=(e,t)=>{let n,i,r;for(;;){if(e.lookahead=3&&(e.ins_h=In(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){r=e.strstart+e.lookahead-3,i=Jt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=In(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++,i&&(On(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Jt(e,0,e.window[e.strstart-1]),i&&On(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=Jt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2};function qn(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}const Vn=[new qn(0,0,0,0,Pn),new qn(4,4,8,4,Mn),new qn(4,5,16,8,Mn),new qn(4,6,32,32,Mn),new qn(4,4,16,16,Fn),new qn(8,16,32,32,Fn),new qn(8,16,128,128,Fn),new qn(8,32,128,256,Fn),new qn(32,128,258,1024,Fn),new qn(32,258,258,4096,Fn)];function Hn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=vn,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),Cn(this.dyn_ltree),Cn(this.dyn_dtree),Cn(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),Cn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Cn(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 zn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==yn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==wn&&t.status!==Sn?1:0},Gn=e=>{if(zn(e))return Tn(e,cn);e.total_in=e.total_out=0,e.data_type=gn;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?yn:wn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Zt(t),on},jn=e=>{const t=Gn(e);var n;return t===on&&((n=e.state).window_size=2*n.w_size,Cn(n.head),n.max_lazy_match=Vn[n.level].max_lazy,n.good_match=Vn[n.level].good_length,n.nice_match=Vn[n.level].nice_length,n.max_chain_length=Vn[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},Kn=(e,t,n,i,r,s)=>{if(!e)return cn;let o=1;if(t===hn&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>9||n!==vn||i<8||i>15||t<0||t>9||s<0||s>pn||8===i&&1!==o)return Tn(e,cn);8===i&&(i=9);const a=new Hn;return e.state=a,a.strm=e,a.status=yn,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<Kn(e,t,vn,15,8,En),deflateInit2:Kn,deflateReset:jn,deflateResetKeep:Gn,deflateSetHeader:(e,t)=>zn(e)||2!==e.state.wrap?cn:(e.state.gzhead=t,on),deflate:(e,t)=>{if(zn(e)||t>sn||t<0)return e?Tn(e,cn):cn;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Sn&&t!==rn)return Tn(e,0===e.avail_out?ln:cn);const i=n.last_flush;if(n.last_flush=t,0!==n.pending){if(kn(e),0===e.avail_out)return n.last_flush=-1,on}else if(0===e.avail_in&&Nn(t)<=Nn(i)&&t!==rn)return Tn(e,ln);if(n.status===Sn&&0!==e.avail_in)return Tn(e,ln);if(n.status===yn&&0===n.wrap&&(n.status=wn),n.status===yn){let t=vn+(n.w_bits-8<<4)<<8,i=-1;if(i=n.strategy>=_n||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=i<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Rn(n,t),0!==n.strstart&&(Rn(n,e.adler>>>16),Rn(n,65535&e.adler)),e.adler=1,n.status=wn,kn(e),0!==n.pending)return n.last_flush=-1,on}if(57===n.status)if(e.adler=0,Dn(n,31),Dn(n,139),Dn(n,8),n.gzhead)Dn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Dn(n,255&n.gzhead.time),Dn(n,n.gzhead.time>>8&255),Dn(n,n.gzhead.time>>16&255),Dn(n,n.gzhead.time>>24&255),Dn(n,9===n.level?2:n.strategy>=_n||n.level<2?4:0),Dn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Dn(n,255&n.gzhead.extra.length),Dn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Bt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Dn(n,0),Dn(n,0),Dn(n,0),Dn(n,0),Dn(n,0),Dn(n,9===n.level?2:n.strategy>=_n||n.level<2?4:0),Dn(n,3),n.status=wn,kn(e),0!==n.pending)return n.last_flush=-1,on;if(69===n.status){if(n.gzhead.extra){let t=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=r,kn(e),0!==n.pending)return n.last_flush=-1,on;t=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>t&&(e.adler=Bt(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,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,on;i=0}t=n.gzindexi&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,on;i=0}t=n.gzindexi&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(kn(e),0!==n.pending))return n.last_flush=-1,on;Dn(n,255&e.adler),Dn(n,e.adler>>8&255),e.adler=0}if(n.status=wn,kn(e),0!==n.pending)return n.last_flush=-1,on}if(0!==e.avail_in||0!==n.lookahead||t!==en&&n.status!==Sn){let i=0===n.level?Pn(n,t):n.strategy===_n?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Un(e),0===e.lookahead)){if(t===en)return 1;break}if(e.match_length=0,n=Jt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(On(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===fn?((e,t)=>{let n,i,r,s;const o=e.window;for(;;){if(e.lookahead<=bn){if(Un(e),e.lookahead<=bn&&t===en)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=e.strstart+bn;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=Jt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Jt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(On(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2})(n,t):Vn[n.level].func(n,t);if(3!==i&&4!==i||(n.status=Sn),1===i||3===i)return 0===e.avail_out&&(n.last_flush=-1),on;if(2===i&&(t===tn?$t(n):t!==sn&&(Yt(n,0,0,!1),t===nn&&(Cn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),kn(e),0===e.avail_out))return n.last_flush=-1,on}return t!==rn?on:n.wrap<=0?an:(2===n.wrap?(Dn(n,255&e.adler),Dn(n,e.adler>>8&255),Dn(n,e.adler>>16&255),Dn(n,e.adler>>24&255),Dn(n,255&e.total_in),Dn(n,e.total_in>>8&255),Dn(n,e.total_in>>16&255),Dn(n,e.total_in>>24&255)):(Rn(n,e.adler>>>16),Rn(n,65535&e.adler)),kn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?on:an)},deflateEnd:e=>{if(zn(e))return cn;const t=e.state.status;return e.state=null,t===wn?Tn(e,un):on},deflateSetDictionary:(e,t)=>{let n=t.length;if(zn(e))return cn;const i=e.state,r=i.wrap;if(2===r||1===r&&i.status!==yn||i.lookahead)return cn;if(1===r&&(e.adler=jt(e.adler,t,n,0)),i.wrap=0,n>=i.w_size){0===r&&(Cn(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(n-i.w_size,n),0),t=e,n=i.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Un(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=In(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,Un(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=o,e.input=a,e.avail_in=s,i.wrap=r,on},deflateInfo:"pako deflate (from Nodeca project)"};const Qn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Wn={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)Qn(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,i=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Yn[254]=Yn[254]=1;var Xn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,i,r,s,o=e.length,a=0;for(r=0;r>>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 i,r;const s=new Array(2*n);for(r=0,i=0;i4)s[r++]=65533,i+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&i1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Zn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let i=0;i{(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 Jn=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 $n=Object.prototype.toString,{Z_NO_FLUSH:ei,Z_SYNC_FLUSH:ti,Z_FULL_FLUSH:ni,Z_FINISH:ii,Z_OK:ri,Z_STREAM_END:si,Z_DEFAULT_COMPRESSION:oi,Z_DEFAULT_STRATEGY:ai,Z_DEFLATED:ci}=Wt;function ui(e){this.options=Wn.assign({level:oi,method:ci,chunkSize:16384,windowBits:15,memLevel:8,strategy:ai},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 Jn,this.strm.avail_out=0;let n=Bn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ri)throw new Error(Qt[n]);if(t.header&&Bn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Xn.string2buf(t.dictionary):"[object ArrayBuffer]"===$n.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Bn.deflateSetDictionary(this.strm,e),n!==ri)throw new Error(Qt[n]);this._dict_set=!0}}function li(e,t){const n=new ui(t);if(n.push(e,!0),n.err)throw n.msg||Qt[n.err];return n.result}ui.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?ii:ei,"string"==typeof e?n.input=Xn.string2buf(e):"[object ArrayBuffer]"===$n.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(i),n.next_out=0,n.avail_out=i),(s===ti||s===ni)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(r=Bn.deflate(n,s),r===si)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),r=Bn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===ri;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},ui.prototype.onData=function(e){this.chunks.push(e)},ui.prototype.onEnd=function(e){e===ri&&(this.result=Wn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var hi={Deflate:ui,deflate:li,deflateRaw:function(e,t){return(t=t||{}).raw=!0,li(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,li(e,t)},constants:Wt};const di=16209;var _i=function(e,t){let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T,N;const C=e.state;n=e.next_in,T=e.input,i=n+(e.avail_in-5),r=e.next_out,N=e.output,s=r-(t-e.avail_out),o=r+(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,E=(1<>>24,d>>>=b,_-=b,b=v>>>16&255,0===b)N[r++]=65535&v;else{if(!(16&b)){if(64&b){if(32&b){C.mode=16191;break e}e.msg="invalid literal/length code",C.mode=di;break e}v=f[(65535&v)+(d&(1<>>=b,_-=b),_<15&&(d+=T[n++]<<_,_+=8,d+=T[n++]<<_,_+=8),v=p[d&g];;){if(b=v>>>24,d>>>=b,_-=b,b=v>>>16&255,16&b){if(y=65535&v,b&=15,_a){e.msg="invalid distance too far back",C.mode=di;break e}if(d>>>=b,_-=b,b=r-s,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=di;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)N[r++]=S[w++],N[r++]=S[w++],N[r++]=S[w++],m-=3;m&&(N[r++]=S[w++],m>1&&(N[r++]=S[w++]))}else{w=r-y;do{N[r++]=N[w++],N[r++]=N[w++],N[r++]=N[w++],m-=3}while(m>2);m&&(N[r++]=N[w++],m>1&&(N[r++]=N[w++]))}break}if(64&b){e.msg="invalid distance code",C.mode=di;break e}v=p[(65535&v)+(d&(1<>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=r,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,E=0,g=0,v=0,b=0,m=0,y=0,w=0,S=0,T=0,N=null;const C=new Uint16Array(16),A=new Uint16Array(16);let I,k,O,D=null;for(p=0;p<=fi;p++)C[p]=0;for(E=0;E=1&&0===C[v];v--);if(b>v&&(b=v),0===v)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(A[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){I=p-y,o[E]+1=f?(k=D[o[E]-f],O=N[o[E]-f]):(k=96,O=0),u=1<>y)+l]=I<<24|k<<16|O}while(0!==l);for(u=1<>=1;if(0!==u?(T&=u-1,T+=u):T=0,E++,0==--C[p]){if(p===v)break;p=t[n+o[E]]}if(p>b&&(T&d)!==h){for(0===y&&(y=b),_+=g,m=p-y,w=1<852||2===e&&S>592)return 1;h=T&d,r[h]=b<<24|m<<16|_-s}}return 0!==T&&(r[_+T]=p-y<<24|64<<16),a.bits=b,0};const{Z_FINISH:mi,Z_BLOCK:yi,Z_TREES:wi,Z_OK:Si,Z_STREAM_END:Ti,Z_NEED_DICT:Ni,Z_STREAM_ERROR:Ci,Z_DATA_ERROR:Ai,Z_MEM_ERROR:Ii,Z_BUF_ERROR:ki,Z_DEFLATED:Oi}=Wt,Di=16180,Ri=16190,Li=16191,xi=16192,Ui=16194,Pi=16199,Mi=16200,Fi=16206,qi=16209,Vi=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Hi(){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 zi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Gi=e=>{if(zi(e))return Ci;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=Di,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,Si},ji=e=>{if(zi(e))return Ci;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Gi(e)},Ki=(e,t)=>{let n;if(zi(e))return Ci;const i=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Ci:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,ji(e))},Bi=(e,t)=>{if(!e)return Ci;const n=new Hi;e.state=n,n.strm=e,n.window=null,n.mode=Di;const i=Ki(e,t);return i!==Si&&(e.state=null),i};let Qi,Wi,Zi=!0;const Yi=e=>{if(Zi){Qi=new Int32Array(512),Wi=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(bi(1,e.lens,0,288,Qi,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;bi(2,e.lens,0,32,Wi,0,e.work,{bits:5}),Zi=!1}e.lencode=Qi,e.lenbits=9,e.distcode=Wi,e.distbits=5},Xi=(e,t,n,i)=>{let r;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):(r=s.wsize-s.wnext,r>i&&(r=i),s.window.set(t.subarray(n-i,n-i+r),s.wnext),(i-=r)?(s.window.set(t.subarray(n-i,n),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whaveBi(e,15),inflateInit2:Bi,inflate:(e,t)=>{let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T=0;const N=new Uint8Array(4);let C,A;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(zi(e)||!e.output||!e.input&&0!==e.avail_in)return Ci;n=e.state,n.mode===Li&&(n.mode=xi),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=Si;e:for(;;)switch(n.mode){case Di:if(0===n.wrap){n.mode=xi;break}for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>>8&255,n.check=Bt(n.check,N,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=qi;break}if((15&u)!==Oi){e.msg="unknown compression method",n.mode=qi;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=qi;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Bt(n.check,N,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>8&255,N[2]=u>>>16&255,N[3]=u>>>24&255,n.check=Bt(n.check,N,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>8),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Bt(n.check,N,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+=i[s++]<>>8&255,n.check=Bt(n.check,N,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(i.subarray(s,s+_),w)),512&n.flags&&4&n.wrap&&(n.check=Bt(n.check,i,_,s)),a-=_,s+=_,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=i[s+_++],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=Li;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>=7&l,l-=7&l,n.mode=Fi;break}for(;l<3;){if(0===a)break e;a--,u+=i[s++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(Yi(n),n.mode=Pi,t===wi){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=qi}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=i[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=qi;break}if(n.length=65535&u,u=0,l=0,n.mode=Ui,t===wi)break e;case Ui:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;r.set(i.subarray(s,s+_),o),a-=_,s+=_,c-=_,o+=_,n.length-=_;break}n.mode=Li;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=i[s++]<>>=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=qi;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,C={bits:n.lenbits},S=bi(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=qi;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=E,l-=E,n.lens[n.have++]=v;else{if(16===v){for(A=E+2;l>>=E,l-=E,0===n.have){e.msg="invalid bit length repeat",n.mode=qi;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===v){for(A=E+3;l>>=E,l-=E,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(A=E+7;l>>=E,l-=E,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=qi;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===qi)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=qi;break}if(n.lenbits=9,C={bits:n.lenbits},S=bi(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=qi;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=bi(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=qi;break}if(n.mode=Pi,t===wi)break e;case Pi:n.mode=Mi;case Mi:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,n.hold=u,n.bits=l,_i(e,d),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===Li&&(n.back=-1);break}for(n.back=0;T=n.lencode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,n.length=v,0===g){n.mode=16205;break}if(32&g){n.back=-1,n.mode=Li;break}if(64&g){e.msg="invalid literal/length code",n.mode=qi;break}n.extra=15&g,n.mode=16201;case 16201:if(n.extra){for(A=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;T=n.distcode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,64&g){e.msg="invalid distance code",n.mode=qi;break}n.offset=v,n.extra=15&g,n.mode=16203;case 16203:if(n.extra){for(A=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=qi;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=qi;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=r,f=o-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{r[o++]=p[f++]}while(--_);0===n.length&&(n.mode=Mi);break;case 16205:if(0===c)break e;r[o++]=n.length,c--,n.mode=Mi;break;case Fi:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=i[s++]<{if(zi(e))return Ci;let t=e.state;return t.window&&(t.window=null),e.state=null,Si},inflateGetHeader:(e,t)=>{if(zi(e))return Ci;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Si):Ci},inflateSetDictionary:(e,t)=>{const n=t.length;let i,r,s;return zi(e)?Ci:(i=e.state,0!==i.wrap&&i.mode!==Ri?Ci:i.mode===Ri&&(r=1,r=jt(r,t,n,0),r!==i.check)?Ai:(s=Xi(e,t,n,n),s?(i.mode=16210,Ii):(i.havedict=1,Si)))},inflateInfo:"pako inflate (from Nodeca project)"};var $i=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 er=Object.prototype.toString,{Z_NO_FLUSH:tr,Z_FINISH:nr,Z_OK:ir,Z_STREAM_END:rr,Z_NEED_DICT:sr,Z_STREAM_ERROR:or,Z_DATA_ERROR:ar,Z_MEM_ERROR:cr}=Wt;function ur(e){this.options=Wn.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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Jn,this.strm.avail_out=0;let n=Ji.inflateInit2(this.strm,t.windowBits);if(n!==ir)throw new Error(Qt[n]);if(this.header=new $i,Ji.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Xn.string2buf(t.dictionary):"[object ArrayBuffer]"===er.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Ji.inflateSetDictionary(this.strm,t.dictionary),n!==ir)))throw new Error(Qt[n])}function lr(e,t){const n=new ur(t);if(n.push(e),n.err)throw n.msg||Qt[n.err];return n.result}ur.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?nr:tr,"[object ArrayBuffer]"===er.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(i),n.next_out=0,n.avail_out=i),s=Ji.inflate(n,o),s===sr&&r&&(s=Ji.inflateSetDictionary(n,r),s===ir?s=Ji.inflate(n,o):s===ar&&(s=sr));n.avail_in>0&&s===rr&&n.state.wrap>0&&0!==e[n.next_in];)Ji.inflateReset(n),s=Ji.inflate(n,o);switch(s){case or:case ar:case sr:case cr:return this.onEnd(s),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||s===rr))if("string"===this.options.to){let e=Xn.utf8border(n.output,n.next_out),t=n.next_out-e,r=Xn.buf2string(n.output,e);n.next_out=t,n.avail_out=i-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==ir||0!==a){if(s===rr)return s=Ji.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},ur.prototype.onData=function(e){this.chunks.push(e)},ur.prototype.onEnd=function(e){e===ir&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Wn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var hr={Inflate:ur,inflate:lr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,lr(e,t)},ungzip:lr,constants:Wt};const{Deflate:dr,deflate:_r,deflateRaw:fr,gzip:pr}=hi,{Inflate:Er,inflate:gr,inflateRaw:vr,ungzip:br}=hr;var mr,yr={Deflate:dr,deflate:_r,deflateRaw:fr,gzip:pr,Inflate:Er,inflate:gr,inflateRaw:vr,ungzip:br,constants:Wt},wr=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){return t=yr.ungzip(e),[2,String.fromCharCode.apply(null,t)]}))}))};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(mr||(mr={}));var Sr,Tr=function(e){function n(t,n){var i=n.sdkState,r=n.dispatcher,s=n.logger,o=e.call(this)||this;return o.lastActive=0,o._iid=t,o._sdkState=i,o._dispatcher=r,o._logger=s,o}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===mr.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return mr.CONNECTING;case 1:return mr.OPEN}return mr.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ws",{get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Fe.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 i=new Me(n.payload);i.expiresIn>=0&&t._dispatcher.dispatch(i)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e,t){return void 0===t&&(t=""),r(this,void 0,void 0,(function(){var n=this;return s(this,(function(i){return this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return r(n,void 0,void 0,(function(){var t,n,i,o,a,c,u,l=this;return s(this,(function(h){switch(h.label){case 0:return(null===(u=this._sdkState.websocket)||void 0===u?void 0:u.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return r(l,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,wr(t.result)];case 1:return e=i.sent(),this._handleMessage(e),[3,3];case 2:return n=i.sent(),this.error(n),[3,3];case 3:return[2]}}))}))},[3,12]):[3,1]:[3,13];case 1:if(!(e.data instanceof ArrayBuffer))return[3,6];h.label=2;case 2:return h.trys.push([2,4,,5]),[4,wr(new Uint8Array(e.data))];case 3:return a=h.sent(),this._handleMessage(a),[3,5];case 4:return n=h.sent(),this.error(n),[3,5];case 5:return[3,12];case 6:if(!("undefined"!=typeof Buffer&&e.data instanceof Buffer))return[3,11];h.label=7;case 7:return h.trys.push([7,9,,10]),i=e.data,o=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),[4,wr(o)];case 8:return a=h.sent(),this._handleMessage(a),[3,10];case 9:return c=h.sent(),this.error(c),[3,10];case 10:return[3,12];case 11:"string"==typeof e.data&&this._handleMessage(e.data),h.label=12;case 12:return[3,14];case 13:this._handleMessage(e.data),h.label=14;case 14:return[2]}}))}))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",v.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now(),[2]}))}))},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws?(e._ws.onopen=st,e._ws.onmessage=st,e._ws.onerror=st,e.connectionState!==mr.CLOSED?(e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=void 0):t()):t()}))},n.prototype.send=function(e){if(!this._ws)throw v.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}(te),Nr=function(e){function n(t){var n=t.all,i=t.feed,r=t.custom_types,s=t.ts,o=e.call(this)||this;return o.all=n,o.feed=i,o.customTypes=r,o.ts=s,o}return t(n,e),n}(ie),Cr=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=r,this._logger=s,this.apiClient=new rt(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:a}),this.websocketClient=new Tr(e,{sdkState:i,dispatcher:r,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new Nr(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 v({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(v.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r=this;return s(this,(function(s){if(!this._sdkState.websocket)throw v.connectionRequired;if(t=new et,e.ackRequired){i=function(i,s){r._ackStateMap.has(e.requestId)&&(r._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),i?(r._logger.debug("fail websocket request",e.requestId,i),t.reject(i)):(r._logger.debug("receive websocket ack",e.requestId,e),r._logger.debug("receive websocket ack",s),t.resolve(s)))};try{n=setTimeout((function(){return i(v.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return i(void 0,e)},reject:function(e){return i(e)}}),this.websocketClient.send(e)}catch(e){i(e)}}else try{this.websocketClient.send(e),t.resolve()}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return e instanceof xe?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof qe?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw v.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"}(Sr||(Sr={}));var Ar,Ir,kr=function(e){function n(t){var n=t.stateType,i=e.call(this)||this;return i.stateType=n,i}return t(n,e),n}(ie),Or=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Dr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Rr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Lr=function(){function e(e){var t,n,i,r;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(n=e.feed_channels)&&void 0!==n?n:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(r=e.settings_updated_at)&&void 0!==r?r:0}return e.payloadify=function(e){return re(se({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))},e}(),xr=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},Ur=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 re(se({last_updated_at:e.lastUpdatedAt}))},e}(),Pr=function(){function e(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}return e.payloadify=function(e){return re(se({template_list_token:e.token}))},e}(),Mr=function(){function e(e){void 0===e&&(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}),this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}return e.payloadify=function(e){return re(se({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))},e}(),Fr=function(){function e(e){void 0===e&&(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}),this.default=new Mr(e.default),this.realTime=new Mr(e.realtime)}return e.payloadify=function(e){return re(se({default:Mr.payloadify(e.default),realtime:Mr.payloadify(e.realTime)}))},e}(),qr=1048576,Vr=5;!function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Ar||(Ar={})),function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Ir||(Ir={}));var Hr=function(){function e(e){var t,n,i,r,s,o,a;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*qr: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!==(i=e.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(r=e.allow_sdk_log_ingestion)||void 0===r||r,this.unreadCountThreadingPolicy=null!==(s=e.unread_cnt_threading_policy)&&void 0!==s?s:Ar.NONE,this.lastMessageThreadingPolicy=null!==(o=e.last_msg_threading_policy)&&void 0!==o?o:Ir.NONE,this.uikitConfigInfo=new Ur(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new Lr(e.notifications):null,this.messageTemplateInfo=e.message_template?new Pr(e.message_template):null,this.statConfigInfo=e.log_publish_config?new Fr(e.log_publish_config):new Fr}return e.payloadify=function(e){return re(se({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/qr,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?Ur.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Lr.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Pr.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Fr.payloadify(e.statConfigInfo):null}))},e}(),zr=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return{}},e}(),Gr=function(e){function n(t){var n=t.userId,i=t.metadata,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(ce,"/").concat(n,"/metadata"),r.params={metadata:i},r}return t(n,e),n}(xe),jr=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metaData=n,i}return t(n,e),n}(Ue),Kr=function(e){function n(t){var n=t.userId,i=t.metadata,r=t.upsert,s=e.call(this)||this;return s.method=oe.PUT,s.path="".concat(ce,"/").concat(n,"/metadata"),s.params={metadata:i,upsert:r},s}return t(n,e),n}(xe),Br=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metadata=n,i}return t(n,e),n}(Ue),Qr=function(e){function n(t){var n=t.userId,i=t.metadataKey,r=e.call(this)||this;return r.method=oe.DELETE,r.path="".concat(ce,"/").concat(n,"/metadata/").concat(i),r}return t(n,e),n}(xe);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Ue);var Wr=function(e){function n(t){var n=t.userId,i=e.call(this)||this;return i.method=oe.DELETE,i.path="".concat(ce,"/").concat(n,"/metadata"),i}return t(n,e),n}(xe);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Ue);var Zr,Yr=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Xr=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Jr=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"}(Zr||(Zr={}));var $r,es=function(e){function i(t,n){var i,r,s,o,u,l,h,d,_,f,p,E,g=this;return(g=e.call(this,t)||this).userId=null!==(r=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==r?r:"",g.nickname=null!==(o=null!==(s=n.nickname)&&void 0!==s?s:n.name)&&void 0!==o?o:"",g.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",g.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,g.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},g.connectionStatus=Zr.NON_AVAILABLE,S(Zr,n.is_online)?g.connectionStatus=n.is_online:w("boolean",n.is_online)&&(g.connectionStatus=n.is_online?Zr.ONLINE:Zr.OFFLINE),g.isActive=null===(_=n.is_active)||void 0===_||_,g.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,g.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,g.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,g.friendName=null!==(E=n.friend_name)&&void 0!==E?E:null,g}return t(i,e),i.payloadify=function(t){return re(se(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(i.prototype,"profileUrl",{get:function(){var e=Ws.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),i.prototype.serialize=function(){return Yr(this)},i.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)}))},i.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(i){t?delete n.metaData[i]:n.metaData[i]=e[i]}))},i.prototype.createMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return Jr(this._isValidMetaData(e)).throw(v.invalidParameters),t=Ws.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Gr({userId:n.userId,metadata:e}),[4,i.send(r)];case 1:return o=s.sent(),a=o.as(jr).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},i.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n,i,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:return Jr(this._isValidMetaData(e)).throw(v.invalidParameters),n=Ws.of(this._iid),i=n.sdkState,r=n.requestQueue,o=new Kr({userId:i.userId,metadata:e,upsert:t}),[4,r.send(o)];case 1:return a=s.sent(),c=a.as(Br).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},i.prototype.deleteMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return Jr(w("string",e)).throw(v.invalidParameters),t=Ws.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Qr({userId:n.userId,metadataKey:e}),[4,i.send(r)];case 1:return s.sent(),this._applyMetaData(((o={})[e]=!0,o),!0),[2,this.metaData]}}))}))},i.prototype.deleteAllMetaData=function(){return r(this,void 0,void 0,(function(){var e,t,n,i;return s(this,(function(r){switch(r.label){case 0:return e=Ws.of(this._iid),t=e.sdkState,n=e.requestQueue,i=new Wr({userId:t.userId}),[4,n.send(i)];case 1:return r.sent(),this.metaData={},[2]}}))}))},i}(zr),ts=function(e){function n(t){var n=t.userProfile,i=e.call(this)||this;return i.userProfile=n,i}return t(n,e),n}(ie),ns=function(){function e(e,t){var n,i,r,s,o,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new Hr(t),this.user=new es(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=t.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(r=t.pong_timeout)&&void 0!==r?r:5e3,this.reconnectInterval=null!==(o=null===(s=t.reconnect)||void 0===s?void 0:s.interval)&&void 0!==o?o: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 re(se(n(n(n({},es.payloadify(e.user)),Hr.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,i=Ws.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:function(i){return i>0?1e3*Math.min(e*Math.pow(n,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 ts({userProfile:this}))},e}(),is=function(e){function i(t){var i=t.request,r=void 0===i||i,s=t.features,o=void 0===s?{}:s,a=t.options,c=void 0===a?{}:a,u=t.statConfigInfo,l=e.call(this)||this;return l.request=r,l.features=n({localCache:!0,notification:!0},o),l.options=n({ingestion:!0},c),l.statConfigInfo=u,l}return t(i,e),i}(ie),rs=function(e){function i(t,n,i){var r,s,o,a,c=this;return(c=e.call(this,t,n,i)||this).error=null,c.services=[],c.userProfile=new ns(t,i),c.deviceTokenLastDeletedAt=null!==(r=i.device_token_last_deleted_at)&&void 0!==r?r:0,c.key=null!==(s=i.key)&&void 0!==s?s:"",c.ekey=null!==(o=i.ekey)&&void 0!==o?o:"",c.error=i.error?new v(i):null,c.services=null!==(a=i.services)&&void 0!==a?a:[],c}return t(i,e),i.asError=function(e){return new i("","LOGI",n({user_id:"",error:!0},e))},i.prototype.applyTo=function(e){return r(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(r){switch(r.label){case 0:return this.error?[3,4]:(t=Ws.of(e))?(n=t.sessionManager,i=t.dispatcher,[4,n.login(this)]):[3,2];case 1:return r.sent(),this.userProfile.apply(),i.dispatch(new is({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),[3,3];case 2:throw v.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},i}(Fe),ss=function(){function e(){this.type=Sr.NONE,this.name="none"}return e.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,t.cause,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e}(),os=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e()];case 1:return n.sent(),[3,3];case 2:if(!((t=n.sent())instanceof v))throw t;return t.throwOutside(),[3,3];case 3:return[2]}}))}))},as=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e()];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},cs=function(e){function n(t){void 0===t&&(t={});var n,i=this;return(i=e.call(this)||this).type=Sr.LOGOUT,i.name="logout",i._wasPreviouslyConnected=null===(n=t.wasPreviouslyConnected)||void 0===n||n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(o){switch(o.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return o.sent(),[4,e.changeState(new ms,t)];case 2:return o.sent(),this._wasPreviouslyConnected&&os((function(){return r(i,void 0,void 0,(function(){return s(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(ss),us=function(e){function n(){var t=e.call(this)||this;return t.type=Sr.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new gs({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new fs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new cs,t)];case 1:return n.sent(),[2]}}))}))},n}(ss),ls=function(e){function n(t){var n=t.autoReconnect,i=e.call(this)||this;return i.type=Sr.INTERNAL_DISCONNECTED,i.name="internaldisconnected",i._autoReconnect=!1,i._autoReconnect=n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new fs,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new gs({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new fs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new us,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new cs,t)];case 1:return n.sent(),[2]}}))}))},n}(ss),hs=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},ds=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),_s=function(e,t,n){return void 0===n&&(n=new ds),r(void 0,void 0,void 0,(function(){var i,r,o,a,c,u;return s(this,(function(s){switch(s.label){case 0:i=0,r=null,o=function(e){return r=null!=e?e:new Error("Halted")},a=function(){i=0},s.label=1;case 1:if(!(-1===t||i=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new kr({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 r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.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 n.sent(),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.session.authToken=void 0,t.error.isSessionExpiredError||t.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Me({reason:t.error.code,message:t.error.message})):this._logger.warn("login failed: ".concat(t.error)),this._rejectConnectionRequest(t.error),n.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(){var e,t=this.sdkState,n=t.appId,i=t.appVersion,r=t.userId,s=t.extensions,o=t.sendbirdRuntimeEnvironment,a=this.cacheContext.localCacheEnabled,c=this._sessionManager.session,u=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=s?s:{}).sb_uikit,d=$e.userAgentWithExtension(s);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(n).concat(i?"&av=".concat(i):"").concat(c.hasSession?"":"&user_id=".concat(encodeURIComponent(r)),"&pmce=").concat(u?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent($e.sendbirdSdkUserAgentWithExtension(o)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(Ss))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(a?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")},n.prototype._statLogConnection=function(e){var t;this._dispatcher.dispatch(new je(new Ze({type:Le.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=""),r(this,void 0,void 0,(function(){var n,i,r,o=this;return s(this,(function(s){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(v.connectionCanceled)),n=new et,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){o._loginTimer=void 0,o._rejectConnectionRequest(v.loginTimeout)}),null===(t=this.sdkState.websocket)||void 0===t?void 0:t.responseTimeout),i=this._sessionManager.session,e&&(i.authToken=e,i.sessionKey=void 0),r=this._url(),i.sessionKey||i.authToken?this._websocketClient.connect(r,JSON.stringify(i.hasSession?{auth:i.sessionKey}:{token:i.authToken})):this._websocketClient.connect(r,JSON.stringify({}))),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(rs.asError(v.connectionRenew))},n.prototype.disconnect=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,[4,this.disconnect()];case 1:return e.sent(),[4,this._sessionManager.clear()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)},n}(te),Ns=function(e){function n(t){var n=t.appId,i=t.userId,r=t.includeUIKitConfig,s=void 0!==r&&r,o=t.localCacheEnabled,a=void 0===o||o,c=t.expiringSession,u=void 0===c||c,l=e.call(this)||this;return l.path="".concat(ue,"/").concat(i,"/authentication"),l.method=oe.POST,l.params=re({expiring_session:!!u,include_logi:!0,include_extra_data:String(Ss),uikit_config:s,use_local_cache:a,app_id:n}),l.requireAuth=!1,l}return t(n,e),n}(xe),Cs=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.logi=new rs(t,"LOGI",n),i}return t(n,e),n}(Ue);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(bs||(bs={}));var As,Is,ks=[Ve,Ns],Os=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,a=t.useFetchCompat,c=void 0!==a&&a,u=this;this._currentConnectionStateType=Sr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Cr(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:c}),this._session=n,this._logger=s,this._dispatcher=r,this._dispatcher.on((function(e){var t,n,i;if(e instanceof kr){var r=e.stateType;switch(u._currentConnectionStateType=r,r){case Sr.CONNECTED:u._resolveLazyCallQueue();break;case Sr.INITIALIZED:case Sr.INTERNAL_DISCONNECTED:case Sr.EXTERNAL_DISCONNECTED:case Sr.LOGOUT:u._rejectLazyCallQueue((null===(i=u._session)||void 0===i?void 0:i.hasSession)?v.connectionClosed:v.connectionRequired)}}else if(e instanceof Or)u._session.hasChatServicePermission||u._resolveLazyCallQueue(bs.API);else if(e instanceof Dr||e instanceof Rr)u._rejectLazyCallQueue(v.connectionClosed);else if(e instanceof Ke){var s=e.request,a=e.deferred,c=e.error;try{for(var l=o(ks),h=l.next();!h.done;h=l.next()){if(s instanceof h.value)return void a.reject(c)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}u._lazyCallQueue.push({command:s,deferred:a})}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===Sr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Sr.CONNECTING||this._currentConnectionStateType===Sr.RECONNECTING||this._session.isRefreshing},enumerable:!1,configurable:!0}),e.prototype._classifyLazyCallQueueByScope=function(e){var t,n=[],i=[];switch(e){case bs.ALL:t=null;break;case bs.WEBSOCKET:t=qe;break;case bs.API:t=xe}var r=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(r=!0),r?i.push(e):n.push(e)})),[n,i]},e.prototype._resolveLazyCallQueue=function(e){var t=this;void 0===e&&(e=bs.ALL);var n=a(this._classifyLazyCallQueueByScope(e),2),i=n[0],o=n[1];this._lazyCallQueue=o,i.forEach((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:t=e.command,n=e.deferred,(i=e.timeout)&&clearTimeout(i),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.send(t)];case 2:return r=s.sent(),n.resolve(r),[3,4];case 3:return o=s.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}))},e.prototype._rejectLazyCallQueue=function(e,t){var n=this;void 0===t&&(t=bs.ALL);var i=a(this._classifyLazyCallQueueByScope(t),2),o=i[0],c=i[1];this._lazyCallQueue=c,o.forEach((function(t){return r(n,void 0,void 0,(function(){var n,i;return s(this,(function(r){return n=t.deferred,i=t.timeout,clearTimeout(i),n.reject(e),[2]}))}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(r){switch(r.label){case 0:return e instanceof qe?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:case 7:return[2,r.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new et,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),v.connectionRequired;case 3:case 9:return[3,11];case 4:return e instanceof xe?this._session.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,10];case 6:return e.hasSessionKey?(this._logger.debug("send api request with tmp session key",e),[4,this.commandRouter.send(e)]):[3,8];case 8:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new et,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=v.connectionRequired,this._logger.debug("fail api request",n),n;case 10:throw v.invalidCommand;case 11:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),e instanceof qe||e instanceof xe?[4,this.commandRouter.send(e)]:[3,2];case 1:return[2,t.sent()];case 2:throw v.invalidCommand}}))}))},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(v.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}(),Ds="sendbird@devicetokens",Rs=function(){function e(e){var t=e.type,n=e.token,i=e.device_os,r=e.device_manufacturer,s=e.system_push_enabled;this.type=t,this.token=n,this.deviceOS=i,this.deviceManufacturer=r,this.systemPushEnabled=s}return e.payloadify=function(e){return re(se({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))},e}(),Ls=new WeakMap,xs=function(e){function n(t){var n=t._iid,i=t.session,r=t.cacheContext,s=t.sdkState,o=t.dispatcher,a=t.requestQueue,c=t.logger,u=t.pushNotificationAckManager,l=e.call(this)||this;return l._currentConnectionStateType=Sr.INITIALIZED,l._isRefreshingAuthToken=!1,l.currentUser=null,l.session=i,l._iid=n,l._cacheContext=r,l._sdkState=s,l._dispatcher=o,l._requestQueue=a,l._logger=c,l._pushNotificationAckManager=u,l._deviceTokens=[],l._dispatcher.on((function(e){var t,n,i;if(e instanceof kr){var r=e.stateType;l._currentConnectionStateType=r}else if(e instanceof Me&&l.handler&&!l.isSessionKeyRefreshing){if(l._currentConnectionStateType===Sr.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?l.close():((null===(n=e.error)||void 0===n?void 0:n.isSessionTokenExpiredError)&&l.refreshAuthToken().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(l._logger.debug("session expired"),l.handler.onSessionExpired&&l.handler.onSessionExpired(),l.refreshSessionKey().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e}))))}})),l}return t(n,e),Object.defineProperty(n.prototype,"ekey",{get:function(){return Ls.get(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokens",{get:function(){return this._deviceTokens},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokenLastDeletedAt",{get:function(){return this._deviceTokenLastDeletedAt},enumerable:!1,configurable:!0}),n.prototype.indexOfDeviceToken=function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))},n.prototype.hasDeviceToken=function(e,t){return this.indexOfDeviceToken(e,t)>=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return new He({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=s.sent(),i=n.as(Ge),r=i.newKey,o=i.error)throw o;return this.session.sessionKey=null!=r?r:this.session.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(i){switch(i.label){case 0:return t=new Ve({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),[4,_s((function(e){return r(n,void 0,void 0,(function(){var n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=s.sent(),i=n.as(ze),r=i.key,o=i.services,this.session.sessionKey=r,this.session.services=o,[3,3];case 2:if(a=s.sent(),!this._isSessionRelatedError(a))throw a;return e(a),[3,3];case 3:return[2]}}))}))}),3)];case 1:return i.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:if(this._currentConnectionStateType!==Sr.CONNECTED)return[3,8];r.label=1;case 1:return r.trys.push([1,3,,8]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return r.sent(),this.complete(),[2];case 3:n=r.sent(),r.label=4;case 4:return r.trys.push([4,6,,7]),[4,this._handleSessionRefreshError(n,t)];case 5:return r.sent(),[2];case 6:return r.sent(),[3,7];case 7:return[3,8];case 8:return r.trys.push([8,10,,12]),[4,this._refreshSessionKeyByApi(e)];case 9:return r.sent(),this.complete(),[3,12];case 10:return i=r.sent(),[4,this._handleSessionRefreshError(i,t)];case 11:return r.sent(),[3,12];case 12:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e,t=this,n=new et;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var i=null,o=function(){i&&(clearTimeout(i),i=null)},a=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},c=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};i=setTimeout((function(){return c()}),1e3*this._sdkState.sessionTokenRefreshTimeout),os((function(){return r(t,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(a,c),[2]}))}))}))}else n.resolve(null);return n.promise},n.prototype._handleSessionRefreshError=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return e instanceof v&&(e.isSessionTokenExpiredError||e.code===u.APPLICATION_NOT_FOUND)?(this.session.authToken=void 0,t?[4,this._receiveNewAuthToken()]:[3,6]):[3,6];case 1:return(n=i.sent())?(this.session.authToken=n,[4,this._refreshSessionKey(this.session.authToken,!1)]):[3,3];case 2:return i.sent(),[3,5];case 3:return[4,this.clear()];case 4:i.sent(),i.label=5;case 5:return[2];case 6:throw e}}))}))},n.prototype._isSessionRelatedError=function(e){return e instanceof v&&(e.isSessionExpiredError||e.isSessionInvalidatedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this.session.isRefreshing},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isSessionExpiring",{get:function(){return!!this.handler},enumerable:!1,configurable:!0}),n.prototype.authenticate=function(e,t){var n;return r(this,void 0,void 0,(function(){var i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.session.authToken=t,i=new Ns({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!t||this.isSessionExpiring}),[4,this._requestQueue.commandRouter.send(i)];case 1:return r=s.sent(),(o=r.as(Cs).logi).error?[3,4]:this.session.hasChatServicePermission?[3,3]:[4,o.applyTo(this._iid)];case 2:s.sent(),s.label=3;case 3:return[3,5];case 4:throw o.error;case 5:return[2]}}))}))},n.prototype.login=function(e){var t;return r(this,void 0,void 0,(function(){var n,i,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return n=e.key,i=e.ekey,r=e.services,o=e.userProfile,a=e.deviceTokenLastDeletedAt,c=void 0===a?0:a,this.session.sessionKey=n,this.session.services=r,Ls.set(this,i),this._deviceTokenCacheEnabled=null===(t=null==o?void 0:o.appInfo)||void 0===t?void 0:t.deviceTokenCache,u=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,u.get(Ds)]:[3,5];case 1:return!(l=s.sent())||l.lastDeletedAt0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])},e.prototype._isDuplicateStat=function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t},e.prototype._flush=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r;return s(this,(function(s){switch(s.label){case 0:if(t=!0,!(e.length>0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Ms({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=As.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=As.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},e.prototype._save=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=c(c([],a(this.queue),!1),a(this.flushWaitQueue),!1),[4,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((function(e){return Ze.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})];case 1:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save(),[2]}))}))},e}(),qs=function(e){function n(t){var n,i,r,s,o=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:o,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,i=n.getFullYear(),r=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0"),"".concat(i).concat(r).concat(s)),"_").concat(o),l}return t(n,e),n}(Ze),Vs=function(e){function n(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(n,e),Object.defineProperty(n.prototype,"_isSendable",{get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),n.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,e.prototype.init.call(this,t+".daily")];case 1:return n.sent(),this.queue=this.logInfo.statLogs.map((function(e){return new Ze({type:e.stat_type,ts:e.ts,data:e.data})})),[2]}}))}))},n.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),t.localCacheStat?(this.enabledState=t.enabledStat?As.ENABLED:As.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=As.DISABLED,[4,this.clear()];case 2:s.sent(),s.label=3;case 3:return this.isEnabled&&this._isSendable?[4,this._getUploadStats()]:[3,9];case 4:n=s.sent(),i=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),r=0,s.label=5;case 5:return r=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),i.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,e.prototype.init.call(this,t+".realtime")];case 1:return i.sent(),this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Ze({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}})),[2]}}))}))},i.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.statConfig=e,this._mergeQueue(),t.notificationStat?(this.enabledState=t.enabledStat?As.ENABLED:As.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=As.DISABLED,[4,this.clear()];case 2:i.sent(),i.label=3;case 3:return this.isEnabled&&this._isSendable?(n=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),[4,hs(n)]):[3,6];case 4:return i.sent(),[4,this._flush(this.queue)];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},i.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.enabledState===As.DISABLED?[2,!0]:(t=this.enabledState===As.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,this._isDuplicateStat(e)?[2,!0]:(t.push(e),this.enabledState===As.PENDING?[3,2]:[4,this._save()]));case 1:n.sent(),n.label=2;case 2:return this.isEnabled?(this._mergeQueue(),this.isEnabled&&this._isSendable?[4,this._flush(t)]:[3,4]):[3,4];case 3:return[2,n.sent()];case 4:return[2,!0]}}))}))},i}(Fs),Gs=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,i=e.dispatcher,r=e.logger;this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=$(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=i,this.logger=r,this._dailyStatCollector=new Vs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Hs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._realTimeStatCollector=new zs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}return e.prototype._migration=function(){return r(this,void 0,void 0,(function(){var e,t,i,r;return s(this,(function(s){switch(s.label){case 0:return[4,this.cacheContext.preference.get(this.key)];case 1:return(e=s.sent())?(t=[],e.statLogs.forEach((function(e){e.stat_type===Le.FEATURE_LOCALCACHE&&t.push(new Ze({type:e.stat_type,ts:e.ts,data:e.data}))})),[4,this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((function(e){return Ze.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})]):[3,6];case 2:return s.sent(),i=[],e.statLogs.forEach((function(e){e.stat_type!==Le.FEATURE_LOCALCACHE&&e.stat_type!==Le.NOTIFICATION&&(e.stat_type===Le.FEATURE_LOCALCACHE_EVENT&&(e.data=n({message_init_policy:"",starting_point:0},e.data)),i.push(new Ze({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:i.map((function(e){return Ze.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 3:return s.sent(),r=[],e.statLogs.forEach((function(e){var t;e.stat_type===Le.NOTIFICATION&&(e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),r.push(new Ze({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:r.map((function(e){return Ze.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 4:return s.sent(),[4,this.cacheContext.preference.remove(this.key)];case 5:s.sent(),s.label=6;case 6:return[2]}}))}))},e.prototype.init=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.key=e,[4,this._migration()];case 1:return n.sent(),[4,this._dailyStatCollector.init(this.key)];case 2:return n.sent(),[4,this._defaultStatCollector.init(this.key)];case 3:return n.sent(),[4,this._realTimeStatCollector.init(this.key)];case 4:return n.sent(),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){return e instanceof je?(t=e.statLog,this.put(t)):e instanceof is&&(n=e.request,i=e.features,r=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=n,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._realTimeStatCollector.setConfig(null!==(a=this._statConfig.realTime)&&void 0!==a?a:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:r.ingestion})),[2]}))}))}))),[2]}}))}))},e.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=!0,e instanceof qs?this._collectFeatureLocalCacheStat?[4,this._dailyStatCollector.put(e)]:[3,2]:[3,3];case 1:t=n.sent(),n.label=2;case 2:return[3,13];case 3:switch(e.type){case Le.API_RESULT:case Le.WEBSOCKET_CONNECT:return[3,4];case Le.FEATURE_LOCALCACHE:case Le.FEATURE_LOCALCACHE_EVENT:return[3,7];case Le.NOTIFICATION:return[3,10]}return[3,13];case 4:return this._collectRequestStat?[4,this._defaultStatCollector.put(e)]:[3,6];case 5:t=n.sent(),n.label=6;case 6:return[3,13];case 7:return this._collectFeatureLocalCacheStat?[4,this._defaultStatCollector.put(e)]:[3,9];case 8:t=n.sent(),n.label=9;case 9:return[3,13];case 10:return this._collectionNotificationStat?[4,this._realTimeStatCollector.put(e)]:[3,12];case 11:t=n.sent(),n.label=12;case 12:return[3,13];case 13:return t?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=As.COLLECT_ONLY,this._defaultStatCollector.enabledState=As.COLLECT_ONLY,this._realTimeStatCollector.enabledState=As.COLLECT_ONLY,this.logger.debug(v.statLogUploadLimitExceededError))),[2]}}))}))},e.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)},e}(),js=function(){function e(e){var t=e.limit,n=void 0===t?5:t;this.workersByKey={},this.limit=n}return e.prototype.run=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.workersByKey[e]||(this.workersByKey[e]=[]),this.workersByKey[e].length0})).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},i.payloadify=function(t){return re(se(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 lo.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})))},i.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[i];r>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=r)}})),i.req_id&&i.voted_option_ids&&(this.votedPollOptionIds=i.voted_option_ids),"number"==typeof i.voter_count&&(this.voterCount=i.voter_count),!0},i.prototype.serialize=function(){return Yr(this)},i}(zr),_o=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}(),fo=function(e){function n(t,n,i,r){var s=e.call(this,t,r)||this;return s.channelUrl=n,s.channelType=i,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(q,this.channelType)},n}(_o),po=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},Eo=function(e){function n(t){var n=t.title,i=t.optionTexts,r=t.data,s=t.allowUserSuggestion,o=t.allowMultipleVotes,a=t.closeAt,c=e.call(this)||this;return c.method=oe.POST,c.path=be,c.params={title:n,options:i,data:r,allow_user_suggestion:s,allow_multiple_votes:o,close_at:a},c}return t(n,e),n}(xe),go=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new ho(t,n),i}return t(n,e),n}(Ue),vo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=e.call(this)||this;return s.method=oe.GET,s.path="".concat(be,"/").concat(encodeURIComponent(r)),s.params={channel_url:n,channel_type:i},s}return t(n,e),n}(xe),bo=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new ho(t,n),i}return t(n,e),n}(Ue),mo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s)),o.params={channel_url:n,channel_type:i},o}return t(n,e),n}(xe),yo=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.pollOption=new lo(t,n),i}return t(n,e),n}(Ue),wo=function(e){function n(t){var n=t.channelType,i=t.channelUrl,r=t.timestamp,s=t.token,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(Ie(n),"/").concat(encodeURIComponent(i),"/polls/changelogs"),o.params=re({change_ts:r,token:s}),o}return t(n,e),n}(xe),So=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.updatedPolls=n.updated.map((function(e){return function(e,t){return new ho(e,t)}(t,e)})),i.deletedPollIds=n.deleted.map((function(e){return e})),i.hasMore=n.has_more,i.nextToken=n.next,i}return t(n,e),n}(Ue),To={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},No=function(e){return w("string",e.title)&&(t=e.optionTexts,N("string",t)&&t.every((function(e){return""!==e.trim()})))&&uo(e.data)&&w("boolean",e.allowUserSuggestion,!0)&&w("boolean",e.allowMultipleVotes,!0)&&w("number",e.closeAt,!0);var t},Co={channelUrl:"",channelType:q.BASE,pollId:0,pollOptionId:0},Ao=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)&&e.pollId>0&&w("number",e.pollOptionId)&&e.pollOptionId>0},Io={channelUrl:"",channelType:q.BASE,pollId:0},ko=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)},Oo={},Do=function(){function e(e,t){var n=t.sdkState,i=t.dispatcher,r=t.sessionManager,s=t.requestQueue,o=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=r,this._requestQueue=s,this._dispatcher=i,this._logger=o,Oo[e]=this}return e.of=function(e){return Oo[e]},e.prototype.buildPollFromSerializedData=function(e){var t=Xr(e);return new ho(this._iid,ho.payloadify(t))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return Jr(ko(e)).throw(v.invalidParameters),t=new vo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(bo).poll]}}))}))},e.prototype.create=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return Jr(No(e)).throw(v.invalidParameters),t=new Eo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(go).poll]}}))}))},e.prototype.getOption=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return Jr(Ao(e)).throw(v.invalidParameters),t=new mo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(yo).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,i){return void 0===i&&(i=Ks.SYNC_POLL_CHANGELOGS),r(this,void 0,void 0,(function(){var r,o,a,c,u,l,h;return s(this,(function(s){switch(s.label){case 0:return r=new wo(se({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(r)];case 1:return o=s.sent(),a=o.as(So),c=a.updatedPolls,u=a.deletedPollIds,l=a.hasMore,h=a.nextToken,c.length>0&&this._dispatcher.dispatch(new ro({polls:c,source:i})),[2,{updatedPolls:c,deletedPollIds:u,hasMore:l,token:h}]}}))}))},e}(),Ro=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.token,s=t.limit,o=e.call(this)||this;return o.method=oe.GET,o.path=be,o.params={channel_url:n,channel_type:i,token:r,limit:s},o}return t(n,e),n}(xe),Lo=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).polls=(null!==(i=n.polls)&&void 0!==i?i:[]).map((function(e){return new ho(t,e)})),r.token=n.next,r}return t(n,e),n}(Ue),xo=function(e){function i(t,n){return e.call(this,t,n.channelUrl,n.channelType,n)||this}return t(i,e),i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Ws.of(this._iid).requestQueue,t=new Ro(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(Lo),o=r.polls,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(fo),Uo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=t.token,a=t.limit,c=e.call(this)||this;return c.method=oe.GET,c.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s),"/voters"),c.params={channel_url:n,channel_type:i,token:o,limit:a},c}return t(n,e),n}(xe),Po=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).voters=(null!==(i=n.voters)&&void 0!==i?i:[]).map((function(e){return new es(t,e)})),r.token=n.next,r}return t(n,e),n}(Ue),Mo=function(e){function i(t,n){var i=e.call(this,t,n.channelUrl,n.channelType,n)||this;return i.pollId=n.pollId,i.pollOptionId=n.pollOptionId,i}return t(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&w("number",this.pollId)&&w("number",this.pollOptionId)},i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Ws.of(this._iid).requestQueue,t=new Uo(n(n({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(Po),o=r.voters,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(fo);export{_ as $,oe as A,as as B,q as C,kr as D,te as E,Sr as F,os as G,Nr as H,ts as I,ns as J,xr as K,F as L,Me as M,Je as N,g as O,f as P,N as Q,P as R,R as S,d as T,es as U,Ws as V,Fe as W,S as X,We as Y,Ps as Z,r as _,w as a,Z as a$,p as a0,Hr as a1,Ks as a2,M as a3,E as a4,Ir as a5,Lr as a6,V as a7,u as a8,Ur as a9,st as aA,fo as aB,ke as aC,Ee as aD,De as aE,j as aF,uo as aG,be as aH,po as aI,Vr as aJ,I as aK,nt as aL,oo as aM,Do as aN,_o as aO,L as aP,i as aQ,to as aR,no as aS,so as aT,ro as aU,io as aV,eo as aW,Ne as aX,X as aY,pe as aZ,Zs as a_,Ar as aa,Zr as ab,Be as ac,Qe as ad,le as ae,zr as af,y as ag,z as ah,Yr as ai,K as aj,qe as ak,Ie as al,Ae as am,$s as an,W as ao,A as ap,G as aq,ho as ar,Y as as,Q as at,Oe as au,tt as av,hs as aw,et as ax,B as ay,he as az,s as b,To as b0,No as b1,Io as b2,ko as b3,Co as b4,Ao as b5,lo as b6,Ys as b7,ie as b8,Ze as b9,Le as ba,qs as bb,me as bc,Xs as bd,H as be,O as bf,de as bg,C as bh,it as bi,ao as bj,Js as bk,_s as bl,co as bm,fe as bn,_e as bo,Se as bp,Te as bq,Ve as br,Ke as bs,t as c,ce as d,re as e,xe as f,n as g,Ue as h,k as i,ve as j,ge as k,ye as l,Ce as m,$ as n,Ye as o,c as p,a as q,mr as r,v as s,o as t,se as u,l as v,Jr as w,xo as x,Mo as y,Xr as z}; diff --git a/lib/__bundle-b7a55976.js b/lib/__bundle-24f017be.js similarity index 85% rename from lib/__bundle-b7a55976.js rename to lib/__bundle-24f017be.js index 19ddbf3..b020039 100644 --- a/lib/__bundle-b7a55976.js +++ b/lib/__bundle-24f017be.js @@ -1 +1 @@ -import{c as e,b8 as t,_ as s,b as n,ao as r,aK as a,D as i,F as o,t as u,a8 as c,an as d,a2 as h,ay as l,U as _,W as A}from"./__bundle-85fbca74.js";import{w as g,K as f}from"./__bundle-3ceb5f92.js";var E,p,R;!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"}(E||(E={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(p||(p={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(R||(R={}));var C,L=function(e){switch(e){case E.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case E.CHRONOLOGICAL:return["-createdAt","syncIndex"];case E.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},b=function(t){function s(e){var s=e.message,n=t.call(this)||this;return n.message=s,n}return e(s,t),s}(t),I={},S=function(){function e(e,t){var s=t.localCacheEnabled,n=t.enableAutoResend,r=t.dispatcher,a=t.sdkState,u=t.logger,c=this;this._iid=e,I[e]=this,this._localCacheEnabled=s,this._enableAutoResend=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=u,this._sdkState=a,this._localCacheEnabled&&r.on((function(e){if(e instanceof i)switch(e.stateType){case o.CONNECTED:c._isProcessingAutoResend||c.processAutoResendRegisteredPendingMessages().then((function(){return c._processNextAutoResend()}));break;case o.INTERNAL_DISCONNECTED:case o.EXTERNAL_DISCONNECTED:c._isProcessingAutoResend=!1}}))}return e.of=function(e){return I[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,a,i,o;return n(this,(function(n){switch(n.label){case 0:return this._enableAutoResend?[4,this._fetchAllCachedPendingMessages()]:[2];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())0===(a=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",a.reqId),a.sendingStatus=r.FAILED,a.errorCode=c.ACK_TIMEOUT,this._dispatcher.dispatch(new d({messages:[a],source:h.LOCAL_MESSAGE_FAILED})))}catch(e){i={error:e}}finally{try{s&&!s.done&&(o=t.return)&&o.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,i,o,c,l,_;return n(this,(function(n){switch(n.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())i=s.value,this._enableAutoResend&&i.errorCode&&a(i.errorCode)&&(o=(new Date).getTime(),c=i.createdAt+2592e5,this._enableAutoResend&&o<=c?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(c).toLocaleString()),i.sendingStatus=r.FAILED,this._dispatcher.dispatch(new d({messages:[i],source:h.LOCAL_MESSAGE_FAILED}))))}catch(e){l={error:e}}finally{try{s&&!s.done&&(_=t.return)&&_.call(t)}finally{if(l)throw l.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===r.SUCCEEDED||e.sendingStatus===r.FAILED&&!a(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t;return n(this,(function(s){switch(s.label){case 0:return e=g.of(this._iid),(t=new f).replyType=l.ALL,[4,e.fetch({sendingStatus:r.PENDING,backward:!0,filter:t})];case 1:return[2,s.sent()]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return s(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(this._localCacheEnabled&&this._enableAutoResend&&"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 b({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"}(C||(C={}));var N=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var s=t.data,n=s.blocker,r=s.blockee;return{blocker:new _(e,n),blockee:new _(e,r)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var s=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(s)?s.map((function(t){return new _(e,t)})):[]}},e}(),v=function(t){function s(e,s){var n=s.userId,r=t.call(this)||this;return r._iid=e,r.userId=n,r}return e(s,t),s}(t),D=function(t){function s(){return t.call(this)||this}return e(s,t),s}(t),T=function(t){function s(e,s,n){var r=t.call(this,e,"USEV",n)||this;return r.event=new N(n),r}return e(s,t),s}(A);export{S as A,v as D,E as G,p as P,D as R,R as S,T as U,C as a,N as b,b as c,L as g}; +import{c as e,b8 as t,_ as s,b as n,ao as r,aK as a,D as i,F as o,t as u,a8 as d,an as c,a2 as h,ay as l,U as _,W as A}from"./__bundle-1db3fd0b.js";import{u as g,K as f}from"./__bundle-e1a5e3f1.js";var E,p,R;!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"}(E||(E={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(p||(p={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(R||(R={}));var C,L=function(e){switch(e){case E.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case E.CHRONOLOGICAL:return["-createdAt","syncIndex"];case E.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},b=function(t){function s(e){var s=e.message,n=t.call(this)||this;return n.message=s,n}return e(s,t),s}(t),I={},S=function(){function e(e,t){var s=t.localCacheEnabled,n=t.enableAutoResend,r=t.dispatcher,a=t.sdkState,u=t.logger,d=this;this._iid=e,I[e]=this,this._localCacheEnabled=s,this._enableAutoResend=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=u,this._sdkState=a,this._localCacheEnabled&&r.on((function(e){if(e instanceof i)switch(e.stateType){case o.CONNECTED:d._isProcessingAutoResend||d.processAutoResendRegisteredPendingMessages().then((function(){return d._processNextAutoResend()}));break;case o.INTERNAL_DISCONNECTED:case o.EXTERNAL_DISCONNECTED:d._isProcessingAutoResend=!1}}))}return e.of=function(e){return I[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,a,i,o;return n(this,(function(n){switch(n.label){case 0:return this._enableAutoResend?[4,this._fetchAllCachedPendingMessages()]:[2];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())0===(a=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",a.reqId),a.sendingStatus=r.FAILED,a.errorCode=d.ACK_TIMEOUT,this._dispatcher.dispatch(new c({messages:[a],source:h.LOCAL_MESSAGE_FAILED})))}catch(e){i={error:e}}finally{try{s&&!s.done&&(o=t.return)&&o.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,i,o,d,l,_;return n(this,(function(n){switch(n.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())i=s.value,this._enableAutoResend&&i.errorCode&&a(i.errorCode)&&(o=(new Date).getTime(),d=i.createdAt+2592e5,this._enableAutoResend&&o<=d?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(d).toLocaleString()),i.sendingStatus=r.FAILED,this._dispatcher.dispatch(new c({messages:[i],source:h.LOCAL_MESSAGE_FAILED}))))}catch(e){l={error:e}}finally{try{s&&!s.done&&(_=t.return)&&_.call(t)}finally{if(l)throw l.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===r.SUCCEEDED||e.sendingStatus===r.FAILED&&!a(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t;return n(this,(function(s){switch(s.label){case 0:return e=g.of(this._iid),(t=new f).replyType=l.ALL,[4,e.fetch({sendingStatus:r.PENDING,backward:!0,filter:t})];case 1:return[2,s.sent()]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return s(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(this._localCacheEnabled&&this._enableAutoResend&&"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 b({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"}(C||(C={}));var N=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var s=t.data,n=s.blocker,r=s.blockee;return{blocker:new _(e,n),blockee:new _(e,r)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var s=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(s)?s.map((function(t){return new _(e,t)})):[]}},e}(),v=function(t){function s(e,s){var n=s.userId,r=t.call(this)||this;return r._iid=e,r.userId=n,r}return e(s,t),s}(t),D=function(t){function s(){return t.call(this)||this}return e(s,t),s}(t),T=function(t){function s(e,s,n){var r=t.call(this,e,"USEV",n)||this;return r.event=new N(n),r}return e(s,t),s}(A);export{S as A,v as D,E as G,p as P,D as R,R as S,T as U,C as a,N as b,b as c,L as g}; diff --git a/lib/__bundle-31d4ecef.js b/lib/__bundle-31d4ecef.js new file mode 100644 index 0000000..cd39cdd --- /dev/null +++ b/lib/__bundle-31d4ecef.js @@ -0,0 +1 @@ +import{c as t,b8 as n}from"./__bundle-1db3fd0b.js";var e=function(t){return["-lastMessageUpdatedAt","-createdAt","syncIndex"]},r=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t(e,n),e}(n);export{r as N,e as g}; diff --git a/lib/__bundle-152581cd.js b/lib/__bundle-4b40b3a8.js similarity index 86% rename from lib/__bundle-152581cd.js rename to lib/__bundle-4b40b3a8.js index a164658..19b0e4a 100644 --- a/lib/__bundle-152581cd.js +++ b/lib/__bundle-4b40b3a8.js @@ -1 +1 @@ -import{V as e,s as t,h as s,M as r,br as a,ax as n,bs as o,av as d}from"./__bundle-85fbca74.js";var i=function(i,u){return new Promise((function(c,p){if("undefined"!=typeof XMLHttpRequest){var f=e.of(i),l=f.dispatcher,g=f.logger,h=u.requestId,m=u.method,q=u.url,v=u.headers,w=void 0===v?{}:v,b=u.data,E=void 0===b?"":b,x=u.uploadProgressHandler,y=!1,H=new XMLHttpRequest;H.open(m,q),Object.keys(w).forEach((function(e){H.setRequestHeader(e,w[e])})),x&&H.upload.addEventListener("progress",(function(e){e.lengthComputable?x(h,e.loaded,e.total):g.debug("Progress computing failed: `Content-Length` header is not given.")})),H.onabort=function(){p(t.requestCanceled)},H.onerror=function(e){p(t.networkError)},H.onreadystatechange=function(){if(H.readyState===XMLHttpRequest.DONE&&!y)if(0===H.status||H.status>=200&&H.status<400)try{var e=JSON.parse(H.responseText);c(new s(i,e))}catch(u){p(t.networkError)}else try{var d=JSON.parse(H.responseText);if(d){var u=new t(d);if(u.isSessionExpiredError){if(l.dispatch(new r({reason:u.code,message:u.message})),!(H instanceof a)){var f=new n;return l.dispatch(new o({request:H,deferred:f,error:u})),f.promise}}else u.isSessionInvalidatedError&&l.dispatch(new r({reason:u.code,message:u.message}));p(u)}else p(t.requestFailed)}catch(u){p(t.requestFailed)}},l.on((function(e){e instanceof d&&(e.requestId&&e.requestId!==h||(y=!0,H.abort()))})),H.send(E)}else p(t.xmlHttpRequestNotSupported)}))};export{i as xmlHttpRequest}; +import{V as e,s as t,h as s,M as r,br as a,ax as n,bs as o,av as d}from"./__bundle-1db3fd0b.js";var i=function(i,u){return new Promise((function(c,p){if("undefined"!=typeof XMLHttpRequest){var f=e.of(i),l=f.dispatcher,g=f.logger,h=u.requestId,m=u.method,q=u.url,v=u.headers,b=void 0===v?{}:v,w=u.data,E=void 0===w?"":w,x=u.uploadProgressHandler,y=!1,H=new XMLHttpRequest;H.open(m,q),Object.keys(b).forEach((function(e){H.setRequestHeader(e,b[e])})),x&&H.upload.addEventListener("progress",(function(e){e.lengthComputable?x(h,e.loaded,e.total):g.debug("Progress computing failed: `Content-Length` header is not given.")})),H.onabort=function(){p(t.requestCanceled)},H.onerror=function(e){p(t.networkError)},H.onreadystatechange=function(){if(H.readyState===XMLHttpRequest.DONE&&!y)if(0===H.status||H.status>=200&&H.status<400)try{var e=JSON.parse(H.responseText);c(new s(i,e))}catch(u){p(t.networkError)}else try{var d=JSON.parse(H.responseText);if(d){var u=new t(d);if(u.isSessionExpiredError){if(l.dispatch(new r({reason:u.code,message:u.message})),!(H instanceof a)){var f=new n;return l.dispatch(new o({request:H,deferred:f,error:u})),f.promise}}else u.isSessionInvalidatedError&&l.dispatch(new r({reason:u.code,message:u.message}));p(u)}else p(t.requestFailed)}catch(u){p(t.requestFailed)}},l.on((function(e){e instanceof d&&(e.requestId&&e.requestId!==h||(y=!0,H.abort()))})),H.send(E)}else p(t.xmlHttpRequestNotSupported)}))};export{i as xmlHttpRequest}; diff --git a/lib/__bundle-80bd1744.js b/lib/__bundle-80bd1744.js deleted file mode 100644 index 47df17c..0000000 --- a/lib/__bundle-80bd1744.js +++ /dev/null @@ -1 +0,0 @@ -import{c as t,b8 as n}from"./__bundle-85fbca74.js";var a=function(t){return["-lastMessageUpdatedAt","-createdAt","syncIndex"]},e=function(n){function a(){return null!==n&&n.apply(this,arguments)||this}return t(a,n),a}(n);export{e as N,a as g}; diff --git a/lib/__bundle-85fbca74.js b/lib/__bundle-85fbca74.js deleted file mode 100644 index e2c2aac..0000000 --- a/lib/__bundle-85fbca74.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 i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[i++],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 i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function c(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r0&&b.indexOf(e)>=0},I=function(e){return e>0&&m.indexOf(e)>=0},k=function(e,t){if(void 0===t&&(t=!1),t&&D(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},O=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(),i=c([],a(t),!1).sort(),r=0;r=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}(),L={encrypt:function(e){return e},decrypt:function(e){return e}},x=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return r(this,void 0,void 0,(function(){return s(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),r(this,void 0,void 0,(function(){var i,r,a,c,u,l,h,d,_,f;return s(this,(function(s){switch(s.label){case 0:return this._version=t,this._keysAddress=e,i="".concat(e,".metadata.version"),[4,this._store.get(i)];case 1:return r=s.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=s.sent())&&void 0!==n?n:[],!r||r.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(i,64),o?(this._clearOrder=s,this._customClearOrderComparator=o):this._clearOrder=E.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=c}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===E.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableAutoResend",{get:function(){return this._enableAutoResend},enumerable:!1,configurable:!0}),e}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(P||(P={}));var q,V,H,z,G,j,K,B,Q,W,Z,Y,X,J=function(){function e(){this.isRefreshing=!1}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasChatServicePermission",{get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(P.CHAT))},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]},e}(),$=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)}))},ee=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=$()}return e.prototype._register=function(e,t,n){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: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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))},e}(),te=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new ee({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new ee({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,i,r=this._container[e];if(r){var s=[];try{for(var a=o(r.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=r.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&s.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}s.forEach((function(e){return r.delete(e)}))}},e}(),ne=function(){function e(){this._dispatcher=new te}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}(),ie=function(){},re=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},se=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){for(var t=c([],a(e),!1),n=0;n0&&(i.extension_sdk_info=r.map((function(e){var t=e.product,n=e.platform,i=e.version;return"".concat(t,"/").concat(n,"/").concat(i)})).join(",")),Object.keys(i).forEach((function(e){return delete c[e]})),Object.keys(c).length>0&&(i=n(n({},i),c))}return Object.entries(i).map((function(e){var t=a(e,2),n=t[0],i=t[1];return"".concat(n,"=").concat(i)})).join("&")},e.userAgentWithExtension=function(e){var t=Ye()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",i=e.sb_uikit?"u".concat(e.sb_uikit):"",r=e["device-os-platform"]?"o".concat(e["device-os-platform"]):Xe()?"omobile-web":"oweb";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(i,"/").concat(r)},e}(),et=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=function(e){n(e)}}))},tt=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t.requestId,n}return t(n,e),n}(ie),nt=function(e){function n(t){var n=e.call(this)||this;return n.method=oe.DELETE,n.path="".concat(Ie(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),t.messageToken&&(n.params=re({mesg_token:t.messageToken})),n}return t(n,e),n}(xe);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Ue);var it=function(e){function n(t,n,i){var r,s=this;return(s=e.call(this,t,"DELM",i)||this).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(r=i.sender_id)&&void 0!==r?r:void 0,s}return t(n,e),n}(Fe),rt=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=n,this._sdkState=i,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof Pe&&c.cancel(e.requestId)})),this._logger=s,this._shouldImportFetchCompat=a}return e.prototype._createHeader=function(e,t){var i=this._sdkState,r=i.appId,s=i.appVersion,o=i.sendbirdRuntimeEnvironment,a=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(r).concat(s?",".concat(s):""),"SB-User-Agent":$e.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":$e.sendbirdSdkUserAgentWithExtension(o)});return t||(a["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(a["Session-Key"]=this._session.sessionKey),a["App-Id"]=r,this._session&&this._session.authToken&&(a["Access-Token"]=this._session.authToken),a},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new je(new Ze({type:Le.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._isBodyRequired=function(e){var t=e.method;return t!==oe.GET&&(t!==oe.DELETE||e instanceof nt)},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a,c,l,h,d,_,f,p,E,g,b,m,y,w;return s(this,(function(s){switch(s.label){case 0:t=e.path,n=e.method,i=e.uploadProgressHandler,r=this._isBodyRequired(e),o=this._sdkState.api,a="".concat(o.host).concat(t).concat(r?"":e.query),c=r?e.payload:null,l=this._createHeader(e,c instanceof FormData?c:void 0),h=new AbortController,d=h.signal,this._abortControl.set(e.requestId,h),_=Date.now(),s.label=1;case 1:return s.trys.push([1,13,,14]),i?[4,import("./__bundle-152581cd.js")]:[3,6];case 2:f=s.sent().xmlHttpRequest,s.label=3;case 3:return s.trys.push([3,5,,6]),[4,f(this._iid,{requestId:e.requestId,method:e.method,url:a,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i})];case 4:return p=s.sent(),this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,p];case 5:if(!((E=s.sent())instanceof v&&E.code===u.XMLHTTPREQUEST_NOT_SUPPORTED))throw E;return this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),[3,6];case 6:return 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,8]:[4,import("./__bundle-7c3d40f4.js")];case 7:s.sent(),s.label=8;case 8:return"function"==typeof fetch?[3,10]:[4,import("./__bundle-46d64517.js")];case 9:s.sent(),s.label=10;case 10:return[4,fetch(a,{method:n,body:c,headers:l,signal:d})];case 11:return[4,(g=s.sent()).json()];case 12:if(b=s.sent(),g.ok||g.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,new Ue(this._iid,b)];if(b){if((m=new v(b)).isSessionExpiredError){if(this._dispatcher.dispatch(new Me({reason:m.code,message:m.message})),!(e instanceof Ve))return y=new et,this._dispatcher.dispatch(new Ke({request:e,deferred:y,error:m})),[2,y.promise];throw m}throw m.isSessionInvalidatedError?(this._dispatcher.dispatch(new Me({reason:m.code,message:m.message})),m):m}throw v.requestFailed;case 13:throw w=s.sent(),this._statLogApiResult(e,_,w),w instanceof v?(this._logger.debug("fail api request",w),w):"AbortError"===(null==w?void 0:w.name)?v.requestCanceled:(this._logger.debug("fail api request",w),v.networkError);case 14:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new tt({requestId:e}))},e.prototype.cancelAll=function(){var e,t;try{for(var n=o(this._abortControl.values()),i=n.next();!i.done;i=n.next()){i.value.abort()}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear(),this._dispatcher.dispatch(new tt({}))},e}(),st=function(){};function ot(e){let t=e.length;for(;--t>=0;)e[t]=0}const at=256,ct=286,ut=30,lt=15,ht=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]),dt=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]),_t=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ft=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pt=new Array(576);ot(pt);const Et=new Array(60);ot(Et);const gt=new Array(512);ot(gt);const vt=new Array(256);ot(vt);const bt=new Array(29);ot(bt);const mt=new Array(ut);function yt(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}let wt,St,Tt;function Nt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ot(mt);const Ct=e=>e<256?gt[e]:gt[256+(e>>>7)],At=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},It=(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<{It(e,n[2*t],n[2*t+1])},Ot=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},Dt=(e,t,n)=>{const i=new Array(16);let r,s,o=0;for(r=1;r<=lt;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=Ot(i[t]++,t))}},Rt=e=>{let t;for(t=0;t{e.bi_valid>8?At(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},xt=(e,t,n,i)=>{const r=2*t,s=2*n;return e[r]{const i=e.heap[n];let r=n<<1;for(;r<=e.heap_len&&(r{let i,r,s,o,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,r=e.pending_buf[e.sym_buf+a++],0===i?kt(e,r,t):(s=vt[r],kt(e,s+at+1,t),o=ht[s],0!==o&&(r-=bt[s],It(e,r,o)),i--,s=Ct(i),kt(e,s,n),o=dt[s],0!==o&&(i-=mt[s],It(e,i,o)))}while(a{const n=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)Ut(e,n,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ut(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,n[2*c]=n[2*o]+n[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,n[2*o+1]=n[2*a+1]=c,e.heap[1]=c++,Ut(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,i=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=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<=lt;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>i||(e.bl_count[d]++,_=0,l>=a&&(_=o[l-a]),f=n[2*l],e.opt_len+=f*(d+_),s&&(e.static_len+=f*(r[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>i||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),Dt(n,u,e.bl_count)},Ft=(e,t,n)=>{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=t[2*(i+1)+1],++a{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),i=0;i<=n;i++)if(r=o,o=t[2*(i+1)+1],!(++a{It(e,0+(i?1:0),3),Lt(e),At(e,n),At(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var zt=(e,t,n,i)=>{let r,s,o=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(Ft(e,e.dyn_ltree,e.l_desc.max_code),Ft(e,e.dyn_dtree,e.d_desc.max_code),Mt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ft[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&-1!==t?Ht(e,t,n,i):4===e.strategy||s===r?(It(e,2+(i?1:0),3),Pt(e,pt,Et)):(It(e,4+(i?1:0),3),((e,t,n,i)=>{let r;for(It(e,t-257,5),It(e,n-1,5),It(e,i-4,4),r=0;r{Vt||((()=>{let e,t,n,i,r;const s=new Array(16);for(n=0,i=0;i<28;i++)for(bt[i]=n,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++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(vt[n]+at+1)]++,e.dyn_dtree[2*Ct(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{It(e,2,3),kt(e,256,pt),(e=>{16===e.bi_valid?(At(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 jt=(e,t,n,i)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+t[i++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Kt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Bt=(e,t,n,i)=>{const r=Kt,s=i+n;e^=-1;for(let n=i;n>>8^r[255&(e^t[n])];return~e},Qt={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"},Wt={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:Zt,_tr_stored_block:Yt,_tr_flush_block:Xt,_tr_tally:Jt,_tr_align:$t}=Gt,{Z_NO_FLUSH:en,Z_PARTIAL_FLUSH:tn,Z_FULL_FLUSH:nn,Z_FINISH:rn,Z_BLOCK:sn,Z_OK:on,Z_STREAM_END:an,Z_STREAM_ERROR:cn,Z_DATA_ERROR:un,Z_BUF_ERROR:ln,Z_DEFAULT_COMPRESSION:hn,Z_FILTERED:dn,Z_HUFFMAN_ONLY:_n,Z_RLE:fn,Z_FIXED:pn,Z_DEFAULT_STRATEGY:En,Z_UNKNOWN:gn,Z_DEFLATED:vn}=Wt,bn=258,mn=262,yn=42,wn=113,Sn=666,Tn=(e,t)=>(e.msg=Qt[t],t),Nn=e=>2*e-(e>4?9:0),Cn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},An=e=>{let t,n,i,r=e.w_size;t=e.hash_size,i=t;do{n=e.head[--i],e.head[i]=n>=r?n-r:0}while(--t);t=r,i=t;do{n=e.prev[--i],e.prev[i]=n>=r?n-r:0}while(--t)};let In=(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))},On=(e,t)=>{Xt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,kn(e.strm)},Dn=(e,t)=>{e.pending_buf[e.pending++]=t},Rn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Ln=(e,t,n,i)=>{let r=e.avail_in;return r>i&&(r=i),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),n),1===e.state.wrap?e.adler=jt(e.adler,t,r,n):2===e.state.wrap&&(e.adler=Bt(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)},xn=(e,t)=>{let n,i,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-mn?e.strstart-(e.w_size-mn):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+bn;let _=u[s+o-1],f=u[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+o]===f&&u[n+o-1]===_&&u[n]===u[s]&&u[++n]===u[s+1]){s+=2,n++;do{}while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&so){if(e.match_start=t,o=i,i>=a)break;_=u[s+o-1],f=u[s+o]}}}while((t=h[t&l])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead},Un=e=>{const t=e.w_size;let n,i,r;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-mn)&&(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),An(e),i+=t),0===e.strm.avail_in)break;if(n=Ln(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=n,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=In(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=In(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,i,r,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(n=65535,r=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(n=i+e.strm.avail_in),n>r&&(n=r),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,kn(e.strm),i&&(i>n&&(i=n),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,n-=i),n&&(Ln(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===o);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_waterr&&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++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(Ln(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,s=r>e.w_size?e.w_size:r,i=e.strstart-e.block_start,(i>=s||(i||t===rn)&&t!==en&&0===e.strm.avail_in&&i<=r)&&(n=i>r?r:i,o=t===rn&&0===e.strm.avail_in&&n===i?1:0,Yt(e,e.block_start,n,o),e.block_start+=n,kn(e.strm)),o?3:1)},Mn=(e,t)=>{let n,i;for(;;){if(e.lookahead=3&&(e.ins_h=In(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-mn&&(e.match_length=xn(e,n)),e.match_length>=3)if(i=Jt(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=In(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=In(e,e.ins_h,e.window[e.strstart+1]);else i=Jt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(On(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2},Fn=(e,t)=>{let n,i,r;for(;;){if(e.lookahead=3&&(e.ins_h=In(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){r=e.strstart+e.lookahead-3,i=Jt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=In(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++,i&&(On(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Jt(e,0,e.window[e.strstart-1]),i&&On(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=Jt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2};function qn(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}const Vn=[new qn(0,0,0,0,Pn),new qn(4,4,8,4,Mn),new qn(4,5,16,8,Mn),new qn(4,6,32,32,Mn),new qn(4,4,16,16,Fn),new qn(8,16,32,32,Fn),new qn(8,16,128,128,Fn),new qn(8,32,128,256,Fn),new qn(32,128,258,1024,Fn),new qn(32,258,258,4096,Fn)];function Hn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=vn,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),Cn(this.dyn_ltree),Cn(this.dyn_dtree),Cn(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),Cn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Cn(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 zn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==yn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==wn&&t.status!==Sn?1:0},Gn=e=>{if(zn(e))return Tn(e,cn);e.total_in=e.total_out=0,e.data_type=gn;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?yn:wn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Zt(t),on},jn=e=>{const t=Gn(e);var n;return t===on&&((n=e.state).window_size=2*n.w_size,Cn(n.head),n.max_lazy_match=Vn[n.level].max_lazy,n.good_match=Vn[n.level].good_length,n.nice_match=Vn[n.level].nice_length,n.max_chain_length=Vn[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},Kn=(e,t,n,i,r,s)=>{if(!e)return cn;let o=1;if(t===hn&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>9||n!==vn||i<8||i>15||t<0||t>9||s<0||s>pn||8===i&&1!==o)return Tn(e,cn);8===i&&(i=9);const a=new Hn;return e.state=a,a.strm=e,a.status=yn,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<Kn(e,t,vn,15,8,En),deflateInit2:Kn,deflateReset:jn,deflateResetKeep:Gn,deflateSetHeader:(e,t)=>zn(e)||2!==e.state.wrap?cn:(e.state.gzhead=t,on),deflate:(e,t)=>{if(zn(e)||t>sn||t<0)return e?Tn(e,cn):cn;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Sn&&t!==rn)return Tn(e,0===e.avail_out?ln:cn);const i=n.last_flush;if(n.last_flush=t,0!==n.pending){if(kn(e),0===e.avail_out)return n.last_flush=-1,on}else if(0===e.avail_in&&Nn(t)<=Nn(i)&&t!==rn)return Tn(e,ln);if(n.status===Sn&&0!==e.avail_in)return Tn(e,ln);if(n.status===yn&&0===n.wrap&&(n.status=wn),n.status===yn){let t=vn+(n.w_bits-8<<4)<<8,i=-1;if(i=n.strategy>=_n||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=i<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Rn(n,t),0!==n.strstart&&(Rn(n,e.adler>>>16),Rn(n,65535&e.adler)),e.adler=1,n.status=wn,kn(e),0!==n.pending)return n.last_flush=-1,on}if(57===n.status)if(e.adler=0,Dn(n,31),Dn(n,139),Dn(n,8),n.gzhead)Dn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Dn(n,255&n.gzhead.time),Dn(n,n.gzhead.time>>8&255),Dn(n,n.gzhead.time>>16&255),Dn(n,n.gzhead.time>>24&255),Dn(n,9===n.level?2:n.strategy>=_n||n.level<2?4:0),Dn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Dn(n,255&n.gzhead.extra.length),Dn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Bt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Dn(n,0),Dn(n,0),Dn(n,0),Dn(n,0),Dn(n,0),Dn(n,9===n.level?2:n.strategy>=_n||n.level<2?4:0),Dn(n,3),n.status=wn,kn(e),0!==n.pending)return n.last_flush=-1,on;if(69===n.status){if(n.gzhead.extra){let t=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=r,kn(e),0!==n.pending)return n.last_flush=-1,on;t=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>t&&(e.adler=Bt(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,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,on;i=0}t=n.gzindexi&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,on;i=0}t=n.gzindexi&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(kn(e),0!==n.pending))return n.last_flush=-1,on;Dn(n,255&e.adler),Dn(n,e.adler>>8&255),e.adler=0}if(n.status=wn,kn(e),0!==n.pending)return n.last_flush=-1,on}if(0!==e.avail_in||0!==n.lookahead||t!==en&&n.status!==Sn){let i=0===n.level?Pn(n,t):n.strategy===_n?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Un(e),0===e.lookahead)){if(t===en)return 1;break}if(e.match_length=0,n=Jt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(On(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===fn?((e,t)=>{let n,i,r,s;const o=e.window;for(;;){if(e.lookahead<=bn){if(Un(e),e.lookahead<=bn&&t===en)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=e.strstart+bn;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=Jt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Jt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(On(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2})(n,t):Vn[n.level].func(n,t);if(3!==i&&4!==i||(n.status=Sn),1===i||3===i)return 0===e.avail_out&&(n.last_flush=-1),on;if(2===i&&(t===tn?$t(n):t!==sn&&(Yt(n,0,0,!1),t===nn&&(Cn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),kn(e),0===e.avail_out))return n.last_flush=-1,on}return t!==rn?on:n.wrap<=0?an:(2===n.wrap?(Dn(n,255&e.adler),Dn(n,e.adler>>8&255),Dn(n,e.adler>>16&255),Dn(n,e.adler>>24&255),Dn(n,255&e.total_in),Dn(n,e.total_in>>8&255),Dn(n,e.total_in>>16&255),Dn(n,e.total_in>>24&255)):(Rn(n,e.adler>>>16),Rn(n,65535&e.adler)),kn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?on:an)},deflateEnd:e=>{if(zn(e))return cn;const t=e.state.status;return e.state=null,t===wn?Tn(e,un):on},deflateSetDictionary:(e,t)=>{let n=t.length;if(zn(e))return cn;const i=e.state,r=i.wrap;if(2===r||1===r&&i.status!==yn||i.lookahead)return cn;if(1===r&&(e.adler=jt(e.adler,t,n,0)),i.wrap=0,n>=i.w_size){0===r&&(Cn(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(n-i.w_size,n),0),t=e,n=i.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Un(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=In(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,Un(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=o,e.input=a,e.avail_in=s,i.wrap=r,on},deflateInfo:"pako deflate (from Nodeca project)"};const Qn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Wn={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)Qn(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,i=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Yn[254]=Yn[254]=1;var Xn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,i,r,s,o=e.length,a=0;for(r=0;r>>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 i,r;const s=new Array(2*n);for(r=0,i=0;i4)s[r++]=65533,i+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&i1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Zn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let i=0;i{(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 Jn=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 $n=Object.prototype.toString,{Z_NO_FLUSH:ei,Z_SYNC_FLUSH:ti,Z_FULL_FLUSH:ni,Z_FINISH:ii,Z_OK:ri,Z_STREAM_END:si,Z_DEFAULT_COMPRESSION:oi,Z_DEFAULT_STRATEGY:ai,Z_DEFLATED:ci}=Wt;function ui(e){this.options=Wn.assign({level:oi,method:ci,chunkSize:16384,windowBits:15,memLevel:8,strategy:ai},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 Jn,this.strm.avail_out=0;let n=Bn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ri)throw new Error(Qt[n]);if(t.header&&Bn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Xn.string2buf(t.dictionary):"[object ArrayBuffer]"===$n.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Bn.deflateSetDictionary(this.strm,e),n!==ri)throw new Error(Qt[n]);this._dict_set=!0}}function li(e,t){const n=new ui(t);if(n.push(e,!0),n.err)throw n.msg||Qt[n.err];return n.result}ui.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?ii:ei,"string"==typeof e?n.input=Xn.string2buf(e):"[object ArrayBuffer]"===$n.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(i),n.next_out=0,n.avail_out=i),(s===ti||s===ni)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(r=Bn.deflate(n,s),r===si)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),r=Bn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===ri;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},ui.prototype.onData=function(e){this.chunks.push(e)},ui.prototype.onEnd=function(e){e===ri&&(this.result=Wn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var hi={Deflate:ui,deflate:li,deflateRaw:function(e,t){return(t=t||{}).raw=!0,li(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,li(e,t)},constants:Wt};const di=16209;var _i=function(e,t){let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T,N;const C=e.state;n=e.next_in,T=e.input,i=n+(e.avail_in-5),r=e.next_out,N=e.output,s=r-(t-e.avail_out),o=r+(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,E=(1<>>24,d>>>=b,_-=b,b=v>>>16&255,0===b)N[r++]=65535&v;else{if(!(16&b)){if(64&b){if(32&b){C.mode=16191;break e}e.msg="invalid literal/length code",C.mode=di;break e}v=f[(65535&v)+(d&(1<>>=b,_-=b),_<15&&(d+=T[n++]<<_,_+=8,d+=T[n++]<<_,_+=8),v=p[d&g];;){if(b=v>>>24,d>>>=b,_-=b,b=v>>>16&255,16&b){if(y=65535&v,b&=15,_a){e.msg="invalid distance too far back",C.mode=di;break e}if(d>>>=b,_-=b,b=r-s,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=di;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)N[r++]=S[w++],N[r++]=S[w++],N[r++]=S[w++],m-=3;m&&(N[r++]=S[w++],m>1&&(N[r++]=S[w++]))}else{w=r-y;do{N[r++]=N[w++],N[r++]=N[w++],N[r++]=N[w++],m-=3}while(m>2);m&&(N[r++]=N[w++],m>1&&(N[r++]=N[w++]))}break}if(64&b){e.msg="invalid distance code",C.mode=di;break e}v=p[(65535&v)+(d&(1<>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=r,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,E=0,g=0,v=0,b=0,m=0,y=0,w=0,S=0,T=0,N=null;const C=new Uint16Array(16),A=new Uint16Array(16);let I,k,O,D=null;for(p=0;p<=fi;p++)C[p]=0;for(E=0;E=1&&0===C[v];v--);if(b>v&&(b=v),0===v)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(A[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){I=p-y,o[E]+1=f?(k=D[o[E]-f],O=N[o[E]-f]):(k=96,O=0),u=1<>y)+l]=I<<24|k<<16|O}while(0!==l);for(u=1<>=1;if(0!==u?(T&=u-1,T+=u):T=0,E++,0==--C[p]){if(p===v)break;p=t[n+o[E]]}if(p>b&&(T&d)!==h){for(0===y&&(y=b),_+=g,m=p-y,w=1<852||2===e&&S>592)return 1;h=T&d,r[h]=b<<24|m<<16|_-s}}return 0!==T&&(r[_+T]=p-y<<24|64<<16),a.bits=b,0};const{Z_FINISH:mi,Z_BLOCK:yi,Z_TREES:wi,Z_OK:Si,Z_STREAM_END:Ti,Z_NEED_DICT:Ni,Z_STREAM_ERROR:Ci,Z_DATA_ERROR:Ai,Z_MEM_ERROR:Ii,Z_BUF_ERROR:ki,Z_DEFLATED:Oi}=Wt,Di=16180,Ri=16190,Li=16191,xi=16192,Ui=16194,Pi=16199,Mi=16200,Fi=16206,qi=16209,Vi=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Hi(){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 zi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Gi=e=>{if(zi(e))return Ci;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=Di,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,Si},ji=e=>{if(zi(e))return Ci;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Gi(e)},Ki=(e,t)=>{let n;if(zi(e))return Ci;const i=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Ci:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,ji(e))},Bi=(e,t)=>{if(!e)return Ci;const n=new Hi;e.state=n,n.strm=e,n.window=null,n.mode=Di;const i=Ki(e,t);return i!==Si&&(e.state=null),i};let Qi,Wi,Zi=!0;const Yi=e=>{if(Zi){Qi=new Int32Array(512),Wi=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(bi(1,e.lens,0,288,Qi,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;bi(2,e.lens,0,32,Wi,0,e.work,{bits:5}),Zi=!1}e.lencode=Qi,e.lenbits=9,e.distcode=Wi,e.distbits=5},Xi=(e,t,n,i)=>{let r;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):(r=s.wsize-s.wnext,r>i&&(r=i),s.window.set(t.subarray(n-i,n-i+r),s.wnext),(i-=r)?(s.window.set(t.subarray(n-i,n),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whaveBi(e,15),inflateInit2:Bi,inflate:(e,t)=>{let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T=0;const N=new Uint8Array(4);let C,A;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(zi(e)||!e.output||!e.input&&0!==e.avail_in)return Ci;n=e.state,n.mode===Li&&(n.mode=xi),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=Si;e:for(;;)switch(n.mode){case Di:if(0===n.wrap){n.mode=xi;break}for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>>8&255,n.check=Bt(n.check,N,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=qi;break}if((15&u)!==Oi){e.msg="unknown compression method",n.mode=qi;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=qi;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Bt(n.check,N,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>8&255,N[2]=u>>>16&255,N[3]=u>>>24&255,n.check=Bt(n.check,N,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>8),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Bt(n.check,N,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+=i[s++]<>>8&255,n.check=Bt(n.check,N,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(i.subarray(s,s+_),w)),512&n.flags&&4&n.wrap&&(n.check=Bt(n.check,i,_,s)),a-=_,s+=_,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=i[s+_++],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=Li;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>=7&l,l-=7&l,n.mode=Fi;break}for(;l<3;){if(0===a)break e;a--,u+=i[s++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(Yi(n),n.mode=Pi,t===wi){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=qi}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=i[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=qi;break}if(n.length=65535&u,u=0,l=0,n.mode=Ui,t===wi)break e;case Ui:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;r.set(i.subarray(s,s+_),o),a-=_,s+=_,c-=_,o+=_,n.length-=_;break}n.mode=Li;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=i[s++]<>>=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=qi;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,C={bits:n.lenbits},S=bi(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=qi;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=E,l-=E,n.lens[n.have++]=v;else{if(16===v){for(A=E+2;l>>=E,l-=E,0===n.have){e.msg="invalid bit length repeat",n.mode=qi;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===v){for(A=E+3;l>>=E,l-=E,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(A=E+7;l>>=E,l-=E,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=qi;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===qi)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=qi;break}if(n.lenbits=9,C={bits:n.lenbits},S=bi(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=qi;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=bi(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=qi;break}if(n.mode=Pi,t===wi)break e;case Pi:n.mode=Mi;case Mi:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,n.hold=u,n.bits=l,_i(e,d),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===Li&&(n.back=-1);break}for(n.back=0;T=n.lencode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,n.length=v,0===g){n.mode=16205;break}if(32&g){n.back=-1,n.mode=Li;break}if(64&g){e.msg="invalid literal/length code",n.mode=qi;break}n.extra=15&g,n.mode=16201;case 16201:if(n.extra){for(A=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;T=n.distcode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,64&g){e.msg="invalid distance code",n.mode=qi;break}n.offset=v,n.extra=15&g,n.mode=16203;case 16203:if(n.extra){for(A=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=qi;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=qi;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=r,f=o-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{r[o++]=p[f++]}while(--_);0===n.length&&(n.mode=Mi);break;case 16205:if(0===c)break e;r[o++]=n.length,c--,n.mode=Mi;break;case Fi:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=i[s++]<{if(zi(e))return Ci;let t=e.state;return t.window&&(t.window=null),e.state=null,Si},inflateGetHeader:(e,t)=>{if(zi(e))return Ci;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Si):Ci},inflateSetDictionary:(e,t)=>{const n=t.length;let i,r,s;return zi(e)?Ci:(i=e.state,0!==i.wrap&&i.mode!==Ri?Ci:i.mode===Ri&&(r=1,r=jt(r,t,n,0),r!==i.check)?Ai:(s=Xi(e,t,n,n),s?(i.mode=16210,Ii):(i.havedict=1,Si)))},inflateInfo:"pako inflate (from Nodeca project)"};var $i=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 er=Object.prototype.toString,{Z_NO_FLUSH:tr,Z_FINISH:nr,Z_OK:ir,Z_STREAM_END:rr,Z_NEED_DICT:sr,Z_STREAM_ERROR:or,Z_DATA_ERROR:ar,Z_MEM_ERROR:cr}=Wt;function ur(e){this.options=Wn.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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Jn,this.strm.avail_out=0;let n=Ji.inflateInit2(this.strm,t.windowBits);if(n!==ir)throw new Error(Qt[n]);if(this.header=new $i,Ji.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Xn.string2buf(t.dictionary):"[object ArrayBuffer]"===er.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Ji.inflateSetDictionary(this.strm,t.dictionary),n!==ir)))throw new Error(Qt[n])}function lr(e,t){const n=new ur(t);if(n.push(e),n.err)throw n.msg||Qt[n.err];return n.result}ur.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?nr:tr,"[object ArrayBuffer]"===er.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(i),n.next_out=0,n.avail_out=i),s=Ji.inflate(n,o),s===sr&&r&&(s=Ji.inflateSetDictionary(n,r),s===ir?s=Ji.inflate(n,o):s===ar&&(s=sr));n.avail_in>0&&s===rr&&n.state.wrap>0&&0!==e[n.next_in];)Ji.inflateReset(n),s=Ji.inflate(n,o);switch(s){case or:case ar:case sr:case cr:return this.onEnd(s),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||s===rr))if("string"===this.options.to){let e=Xn.utf8border(n.output,n.next_out),t=n.next_out-e,r=Xn.buf2string(n.output,e);n.next_out=t,n.avail_out=i-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==ir||0!==a){if(s===rr)return s=Ji.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},ur.prototype.onData=function(e){this.chunks.push(e)},ur.prototype.onEnd=function(e){e===ir&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Wn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var hr={Inflate:ur,inflate:lr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,lr(e,t)},ungzip:lr,constants:Wt};const{Deflate:dr,deflate:_r,deflateRaw:fr,gzip:pr}=hi,{Inflate:Er,inflate:gr,inflateRaw:vr,ungzip:br}=hr;var mr,yr={Deflate:dr,deflate:_r,deflateRaw:fr,gzip:pr,Inflate:Er,inflate:gr,inflateRaw:vr,ungzip:br,constants:Wt},wr=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){return t=yr.ungzip(e),[2,String.fromCharCode.apply(null,t)]}))}))};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(mr||(mr={}));var Sr,Tr=function(e){function n(t,n){var i=n.sdkState,r=n.dispatcher,s=n.logger,o=e.call(this)||this;return o.lastActive=0,o._iid=t,o._sdkState=i,o._dispatcher=r,o._logger=s,o}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===mr.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return mr.CONNECTING;case 1:return mr.OPEN}return mr.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ws",{get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Fe.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 i=new Me(n.payload);i.expiresIn>=0&&t._dispatcher.dispatch(i)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e,t){return void 0===t&&(t=""),r(this,void 0,void 0,(function(){var n=this;return s(this,(function(i){return this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return r(n,void 0,void 0,(function(){var t,n,i,o,a=this;return s(this,(function(c){switch(c.label){case 0:return(null===(o=this._sdkState.websocket)||void 0===o?void 0:o.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return r(a,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,wr(t.result)];case 1:return e=i.sent(),this._handleMessage(e),[3,3];case 2:return n=i.sent(),this.error(n),[3,3];case 3:return[2]}}))}))},[3,7]):[3,1]:[3,8];case 1:if(!(e.data instanceof ArrayBuffer))return[3,6];c.label=2;case 2:return c.trys.push([2,4,,5]),[4,wr(new Uint8Array(e.data))];case 3:return n=c.sent(),this._handleMessage(n),[3,5];case 4:return i=c.sent(),this.error(i),[3,5];case 5:return[3,7];case 6:"string"==typeof e.data&&this._handleMessage(e.data),c.label=7;case 7:return[3,9];case 8:this._handleMessage(e.data),c.label=9;case 9:return[2]}}))}))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",v.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now(),[2]}))}))},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws?(e._ws.onopen=st,e._ws.onmessage=st,e._ws.onerror=st,e.connectionState!==mr.CLOSED?(e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=void 0):t()):t()}))},n.prototype.send=function(e){if(!this._ws)throw v.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}(te),Nr=function(e){function n(t){var n=t.all,i=t.feed,r=t.custom_types,s=t.ts,o=e.call(this)||this;return o.all=n,o.feed=i,o.customTypes=r,o.ts=s,o}return t(n,e),n}(ie),Cr=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=r,this._logger=s,this.apiClient=new rt(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:a}),this.websocketClient=new Tr(e,{sdkState:i,dispatcher:r,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new Nr(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 v({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(v.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r=this;return s(this,(function(s){if(!this._sdkState.websocket)throw v.connectionRequired;if(t=new et,e.ackRequired){i=function(i,s){r._ackStateMap.has(e.requestId)&&(r._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),i?(r._logger.debug("fail websocket request",e.requestId,i),t.reject(i)):(r._logger.debug("receive websocket ack",e.requestId,e),r._logger.debug("receive websocket ack",s),t.resolve(s)))};try{n=setTimeout((function(){return i(v.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return i(void 0,e)},reject:function(e){return i(e)}}),this.websocketClient.send(e)}catch(e){i(e)}}else try{this.websocketClient.send(e),t.resolve()}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return e instanceof xe?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof qe?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw v.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"}(Sr||(Sr={}));var Ar,Ir,kr=function(e){function n(t){var n=t.stateType,i=e.call(this)||this;return i.stateType=n,i}return t(n,e),n}(ie),Or=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Dr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Rr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Lr=function(){function e(e){var t,n,i,r;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(n=e.feed_channels)&&void 0!==n?n:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(r=e.settings_updated_at)&&void 0!==r?r:0}return e.payloadify=function(e){return re(se({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))},e}(),xr=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},Ur=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 re(se({last_updated_at:e.lastUpdatedAt}))},e}(),Pr=function(){function e(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}return e.payloadify=function(e){return re(se({template_list_token:e.token}))},e}(),Mr=function(){function e(e){void 0===e&&(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}),this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}return e.payloadify=function(e){return re(se({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))},e}(),Fr=function(){function e(e){void 0===e&&(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}),this.default=new Mr(e.default),this.realTime=new Mr(e.realtime)}return e.payloadify=function(e){return re(se({default:Mr.payloadify(e.default),realtime:Mr.payloadify(e.realTime)}))},e}(),qr=1048576,Vr=5;!function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Ar||(Ar={})),function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Ir||(Ir={}));var Hr=function(){function e(e){var t,n,i,r,s,o,a;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*qr: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!==(i=e.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(r=e.allow_sdk_log_ingestion)||void 0===r||r,this.unreadCountThreadingPolicy=null!==(s=e.unread_cnt_threading_policy)&&void 0!==s?s:Ar.NONE,this.lastMessageThreadingPolicy=null!==(o=e.last_msg_threading_policy)&&void 0!==o?o:Ir.NONE,this.uikitConfigInfo=new Ur(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new Lr(e.notifications):null,this.messageTemplateInfo=e.message_template?new Pr(e.message_template):null,this.statConfigInfo=e.log_publish_config?new Fr(e.log_publish_config):new Fr}return e.payloadify=function(e){return re(se({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/qr,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?Ur.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Lr.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Pr.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Fr.payloadify(e.statConfigInfo):null}))},e}(),zr=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return{}},e}(),Gr=function(e){function n(t){var n=t.userId,i=t.metadata,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(ce,"/").concat(n,"/metadata"),r.params={metadata:i},r}return t(n,e),n}(xe),jr=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metaData=n,i}return t(n,e),n}(Ue),Kr=function(e){function n(t){var n=t.userId,i=t.metadata,r=t.upsert,s=e.call(this)||this;return s.method=oe.PUT,s.path="".concat(ce,"/").concat(n,"/metadata"),s.params={metadata:i,upsert:r},s}return t(n,e),n}(xe),Br=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metadata=n,i}return t(n,e),n}(Ue),Qr=function(e){function n(t){var n=t.userId,i=t.metadataKey,r=e.call(this)||this;return r.method=oe.DELETE,r.path="".concat(ce,"/").concat(n,"/metadata/").concat(i),r}return t(n,e),n}(xe);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Ue);var Wr=function(e){function n(t){var n=t.userId,i=e.call(this)||this;return i.method=oe.DELETE,i.path="".concat(ce,"/").concat(n,"/metadata"),i}return t(n,e),n}(xe);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Ue);var Zr,Yr=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Xr=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Jr=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"}(Zr||(Zr={}));var $r,es=function(e){function i(t,n){var i,r,s,o,u,l,h,d,_,f,p,E,g=this;return(g=e.call(this,t)||this).userId=null!==(r=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==r?r:"",g.nickname=null!==(o=null!==(s=n.nickname)&&void 0!==s?s:n.name)&&void 0!==o?o:"",g.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",g.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,g.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},g.connectionStatus=Zr.NON_AVAILABLE,S(Zr,n.is_online)?g.connectionStatus=n.is_online:w("boolean",n.is_online)&&(g.connectionStatus=n.is_online?Zr.ONLINE:Zr.OFFLINE),g.isActive=null===(_=n.is_active)||void 0===_||_,g.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,g.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,g.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,g.friendName=null!==(E=n.friend_name)&&void 0!==E?E:null,g}return t(i,e),i.payloadify=function(t){return re(se(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(i.prototype,"profileUrl",{get:function(){var e=Ws.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),i.prototype.serialize=function(){return Yr(this)},i.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)}))},i.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(i){t?delete n.metaData[i]:n.metaData[i]=e[i]}))},i.prototype.createMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return Jr(this._isValidMetaData(e)).throw(v.invalidParameters),t=Ws.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Gr({userId:n.userId,metadata:e}),[4,i.send(r)];case 1:return o=s.sent(),a=o.as(jr).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},i.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n,i,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:return Jr(this._isValidMetaData(e)).throw(v.invalidParameters),n=Ws.of(this._iid),i=n.sdkState,r=n.requestQueue,o=new Kr({userId:i.userId,metadata:e,upsert:t}),[4,r.send(o)];case 1:return a=s.sent(),c=a.as(Br).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},i.prototype.deleteMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return Jr(w("string",e)).throw(v.invalidParameters),t=Ws.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Qr({userId:n.userId,metadataKey:e}),[4,i.send(r)];case 1:return s.sent(),this._applyMetaData(((o={})[e]=!0,o),!0),[2,this.metaData]}}))}))},i.prototype.deleteAllMetaData=function(){return r(this,void 0,void 0,(function(){var e,t,n,i;return s(this,(function(r){switch(r.label){case 0:return e=Ws.of(this._iid),t=e.sdkState,n=e.requestQueue,i=new Wr({userId:t.userId}),[4,n.send(i)];case 1:return r.sent(),this.metaData={},[2]}}))}))},i}(zr),ts=function(e){function n(t){var n=t.userProfile,i=e.call(this)||this;return i.userProfile=n,i}return t(n,e),n}(ie),ns=function(){function e(e,t){var n,i,r,s,o,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new Hr(t),this.user=new es(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=t.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(r=t.pong_timeout)&&void 0!==r?r:5e3,this.reconnectInterval=null!==(o=null===(s=t.reconnect)||void 0===s?void 0:s.interval)&&void 0!==o?o: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 re(se(n(n(n({},es.payloadify(e.user)),Hr.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,i=Ws.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:function(i){return i>0?1e3*Math.min(e*Math.pow(n,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 ts({userProfile:this}))},e}(),is=function(e){function i(t){var i=t.request,r=void 0===i||i,s=t.features,o=void 0===s?{}:s,a=t.options,c=void 0===a?{}:a,u=t.statConfigInfo,l=e.call(this)||this;return l.request=r,l.features=n({localCache:!0,notification:!0},o),l.options=n({ingestion:!0},c),l.statConfigInfo=u,l}return t(i,e),i}(ie),rs=function(e){function i(t,n,i){var r,s,o,a,c=this;return(c=e.call(this,t,n,i)||this).error=null,c.services=[],c.userProfile=new ns(t,i),c.deviceTokenLastDeletedAt=null!==(r=i.device_token_last_deleted_at)&&void 0!==r?r:0,c.key=null!==(s=i.key)&&void 0!==s?s:"",c.ekey=null!==(o=i.ekey)&&void 0!==o?o:"",c.error=i.error?new v(i):null,c.services=null!==(a=i.services)&&void 0!==a?a:[],c}return t(i,e),i.asError=function(e){return new i("","LOGI",n({user_id:"",error:!0},e))},i.prototype.applyTo=function(e){return r(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(r){switch(r.label){case 0:return this.error?[3,4]:(t=Ws.of(e))?(n=t.sessionManager,i=t.dispatcher,[4,n.login(this)]):[3,2];case 1:return r.sent(),this.userProfile.apply(),i.dispatch(new is({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),[3,3];case 2:throw v.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},i}(Fe),ss=function(){function e(){this.type=Sr.NONE,this.name="none"}return e.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,t.cause,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e}(),os=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e()];case 1:return n.sent(),[3,3];case 2:if(!((t=n.sent())instanceof v))throw t;return t.throwOutside(),[3,3];case 3:return[2]}}))}))},as=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e()];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},cs=function(e){function n(t){void 0===t&&(t={});var n,i=this;return(i=e.call(this)||this).type=Sr.LOGOUT,i.name="logout",i._wasPreviouslyConnected=null===(n=t.wasPreviouslyConnected)||void 0===n||n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(o){switch(o.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return o.sent(),[4,e.changeState(new ms,t)];case 2:return o.sent(),this._wasPreviouslyConnected&&os((function(){return r(i,void 0,void 0,(function(){return s(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(ss),us=function(e){function n(){var t=e.call(this)||this;return t.type=Sr.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new gs({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new fs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new cs,t)];case 1:return n.sent(),[2]}}))}))},n}(ss),ls=function(e){function n(t){var n=t.autoReconnect,i=e.call(this)||this;return i.type=Sr.INTERNAL_DISCONNECTED,i.name="internaldisconnected",i._autoReconnect=!1,i._autoReconnect=n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new fs,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new gs({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new fs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new us,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new cs,t)];case 1:return n.sent(),[2]}}))}))},n}(ss),hs=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},ds=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),_s=function(e,t,n){return void 0===n&&(n=new ds),r(void 0,void 0,void 0,(function(){var i,r,o,a,c,u;return s(this,(function(s){switch(s.label){case 0:i=0,r=null,o=function(e){return r=null!=e?e:new Error("Halted")},a=function(){i=0},s.label=1;case 1:if(!(-1===t||i=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new kr({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 r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.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 n.sent(),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.session.authToken=void 0,t.error.isSessionExpiredError||t.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Me({reason:t.error.code,message:t.error.message})):this._logger.warn("login failed: ".concat(t.error)),this._rejectConnectionRequest(t.error),n.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(){var e,t=this.sdkState,n=t.appId,i=t.appVersion,r=t.userId,s=t.extensions,o=t.sendbirdRuntimeEnvironment,a=this.cacheContext.localCacheEnabled,c=this._sessionManager.session,u=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=s?s:{}).sb_uikit,d=$e.userAgentWithExtension(s);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(n).concat(i?"&av=".concat(i):"").concat(c.hasSession?"":"&user_id=".concat(encodeURIComponent(r)),"&pmce=").concat(u?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent($e.sendbirdSdkUserAgentWithExtension(o)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(Ss))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(a?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")},n.prototype._statLogConnection=function(e){var t;this._dispatcher.dispatch(new je(new Ze({type:Le.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=""),r(this,void 0,void 0,(function(){var n,i,r,o=this;return s(this,(function(s){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(v.connectionCanceled)),n=new et,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){o._loginTimer=void 0,o._rejectConnectionRequest(v.loginTimeout)}),null===(t=this.sdkState.websocket)||void 0===t?void 0:t.responseTimeout),i=this._sessionManager.session,e&&(i.authToken=e,i.sessionKey=void 0),r=this._url(),i.sessionKey||i.authToken?this._websocketClient.connect(r,JSON.stringify(i.hasSession?{auth:i.sessionKey}:{token:i.authToken})):this._websocketClient.connect(r,JSON.stringify({}))),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(rs.asError(v.connectionRenew))},n.prototype.disconnect=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,[4,this.disconnect()];case 1:return e.sent(),[4,this._sessionManager.clear()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)},n}(te),Ns=function(e){function n(t){var n=t.appId,i=t.userId,r=t.includeUIKitConfig,s=void 0!==r&&r,o=t.localCacheEnabled,a=void 0===o||o,c=t.expiringSession,u=void 0===c||c,l=e.call(this)||this;return l.path="".concat(ue,"/").concat(i,"/authentication"),l.method=oe.POST,l.params=re({expiring_session:!!u,include_logi:!0,include_extra_data:String(Ss),uikit_config:s,use_local_cache:a,app_id:n}),l.requireAuth=!1,l}return t(n,e),n}(xe),Cs=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.logi=new rs(t,"LOGI",n),i}return t(n,e),n}(Ue);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(bs||(bs={}));var As,Is,ks=[Ve,Ns],Os=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,a=t.useFetchCompat,c=void 0!==a&&a,u=this;this._currentConnectionStateType=Sr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Cr(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:c}),this._session=n,this._logger=s,this._dispatcher=r,this._dispatcher.on((function(e){var t,n,i;if(e instanceof kr){var r=e.stateType;switch(u._currentConnectionStateType=r,r){case Sr.CONNECTED:u._resolveLazyCallQueue();break;case Sr.INITIALIZED:case Sr.INTERNAL_DISCONNECTED:case Sr.EXTERNAL_DISCONNECTED:case Sr.LOGOUT:u._rejectLazyCallQueue((null===(i=u._session)||void 0===i?void 0:i.hasSession)?v.connectionClosed:v.connectionRequired)}}else if(e instanceof Or)u._session.hasChatServicePermission||u._resolveLazyCallQueue(bs.API);else if(e instanceof Dr||e instanceof Rr)u._rejectLazyCallQueue(v.connectionClosed);else if(e instanceof Ke){var s=e.request,a=e.deferred,c=e.error;try{for(var l=o(ks),h=l.next();!h.done;h=l.next()){if(s instanceof h.value)return void a.reject(c)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}u._lazyCallQueue.push({command:s,deferred:a})}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===Sr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Sr.CONNECTING||this._currentConnectionStateType===Sr.RECONNECTING||this._session.isRefreshing},enumerable:!1,configurable:!0}),e.prototype._classifyLazyCallQueueByScope=function(e){var t,n=[],i=[];switch(e){case bs.ALL:t=null;break;case bs.WEBSOCKET:t=qe;break;case bs.API:t=xe}var r=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(r=!0),r?i.push(e):n.push(e)})),[n,i]},e.prototype._resolveLazyCallQueue=function(e){var t=this;void 0===e&&(e=bs.ALL);var n=a(this._classifyLazyCallQueueByScope(e),2),i=n[0],o=n[1];this._lazyCallQueue=o,i.forEach((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:t=e.command,n=e.deferred,(i=e.timeout)&&clearTimeout(i),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.send(t)];case 2:return r=s.sent(),n.resolve(r),[3,4];case 3:return o=s.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}))},e.prototype._rejectLazyCallQueue=function(e,t){var n=this;void 0===t&&(t=bs.ALL);var i=a(this._classifyLazyCallQueueByScope(t),2),o=i[0],c=i[1];this._lazyCallQueue=c,o.forEach((function(t){return r(n,void 0,void 0,(function(){var n,i;return s(this,(function(r){return n=t.deferred,i=t.timeout,clearTimeout(i),n.reject(e),[2]}))}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(r){switch(r.label){case 0:return e instanceof qe?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:case 7:return[2,r.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new et,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),v.connectionRequired;case 3:case 9:return[3,11];case 4:return e instanceof xe?this._session.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,10];case 6:return e.hasSessionKey?(this._logger.debug("send api request with tmp session key",e),[4,this.commandRouter.send(e)]):[3,8];case 8:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new et,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=v.connectionRequired,this._logger.debug("fail api request",n),n;case 10:throw v.invalidCommand;case 11:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),e instanceof qe||e instanceof xe?[4,this.commandRouter.send(e)]:[3,2];case 1:return[2,t.sent()];case 2:throw v.invalidCommand}}))}))},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(v.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}(),Ds="sendbird@devicetokens",Rs=function(){function e(e){var t=e.type,n=e.token,i=e.device_os,r=e.device_manufacturer,s=e.system_push_enabled;this.type=t,this.token=n,this.deviceOS=i,this.deviceManufacturer=r,this.systemPushEnabled=s}return e.payloadify=function(e){return re(se({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))},e}(),Ls=new WeakMap,xs=function(e){function n(t){var n=t._iid,i=t.session,r=t.cacheContext,s=t.sdkState,o=t.dispatcher,a=t.requestQueue,c=t.logger,u=t.pushNotificationAckManager,l=e.call(this)||this;return l._currentConnectionStateType=Sr.INITIALIZED,l._isRefreshingAuthToken=!1,l.currentUser=null,l.session=i,l._iid=n,l._cacheContext=r,l._sdkState=s,l._dispatcher=o,l._requestQueue=a,l._logger=c,l._pushNotificationAckManager=u,l._deviceTokens=[],l._dispatcher.on((function(e){var t,n,i;if(e instanceof kr){var r=e.stateType;l._currentConnectionStateType=r}else if(e instanceof Me&&l.handler&&!l.isSessionKeyRefreshing){if(l._currentConnectionStateType===Sr.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?l.close():((null===(n=e.error)||void 0===n?void 0:n.isSessionTokenExpiredError)&&l.refreshAuthToken().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(l._logger.debug("session expired"),l.handler.onSessionExpired&&l.handler.onSessionExpired(),l.refreshSessionKey().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e}))))}})),l}return t(n,e),Object.defineProperty(n.prototype,"ekey",{get:function(){return Ls.get(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokens",{get:function(){return this._deviceTokens},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokenLastDeletedAt",{get:function(){return this._deviceTokenLastDeletedAt},enumerable:!1,configurable:!0}),n.prototype.indexOfDeviceToken=function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))},n.prototype.hasDeviceToken=function(e,t){return this.indexOfDeviceToken(e,t)>=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return new He({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=s.sent(),i=n.as(Ge),r=i.newKey,o=i.error)throw o;return this.session.sessionKey=null!=r?r:this.session.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(i){switch(i.label){case 0:return t=new Ve({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),[4,_s((function(e){return r(n,void 0,void 0,(function(){var n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=s.sent(),i=n.as(ze),r=i.key,o=i.services,this.session.sessionKey=r,this.session.services=o,[3,3];case 2:if(a=s.sent(),!this._isSessionRelatedError(a))throw a;return e(a),[3,3];case 3:return[2]}}))}))}),3)];case 1:return i.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:if(this._currentConnectionStateType!==Sr.CONNECTED)return[3,8];r.label=1;case 1:return r.trys.push([1,3,,8]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return r.sent(),this.complete(),[2];case 3:n=r.sent(),r.label=4;case 4:return r.trys.push([4,6,,7]),[4,this._handleSessionRefreshError(n,t)];case 5:return r.sent(),[2];case 6:return r.sent(),[3,7];case 7:return[3,8];case 8:return r.trys.push([8,10,,12]),[4,this._refreshSessionKeyByApi(e)];case 9:return r.sent(),this.complete(),[3,12];case 10:return i=r.sent(),[4,this._handleSessionRefreshError(i,t)];case 11:return r.sent(),[3,12];case 12:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e,t=this,n=new et;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var i=null,o=function(){i&&(clearTimeout(i),i=null)},a=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},c=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};i=setTimeout((function(){return c()}),1e3*this._sdkState.sessionTokenRefreshTimeout),os((function(){return r(t,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(a,c),[2]}))}))}))}else n.resolve(null);return n.promise},n.prototype._handleSessionRefreshError=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return e instanceof v&&(e.isSessionTokenExpiredError||e.code===u.APPLICATION_NOT_FOUND)?(this.session.authToken=void 0,t?[4,this._receiveNewAuthToken()]:[3,6]):[3,6];case 1:return(n=i.sent())?(this.session.authToken=n,[4,this._refreshSessionKey(this.session.authToken,!1)]):[3,3];case 2:return i.sent(),[3,5];case 3:return[4,this.clear()];case 4:i.sent(),i.label=5;case 5:return[2];case 6:throw e}}))}))},n.prototype._isSessionRelatedError=function(e){return e instanceof v&&(e.isSessionExpiredError||e.isSessionInvalidatedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this.session.isRefreshing},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isSessionExpiring",{get:function(){return!!this.handler},enumerable:!1,configurable:!0}),n.prototype.authenticate=function(e,t){var n;return r(this,void 0,void 0,(function(){var i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.session.authToken=t,i=new Ns({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!t||this.isSessionExpiring}),[4,this._requestQueue.commandRouter.send(i)];case 1:return r=s.sent(),(o=r.as(Cs).logi).error?[3,4]:this.session.hasChatServicePermission?[3,3]:[4,o.applyTo(this._iid)];case 2:s.sent(),s.label=3;case 3:return[3,5];case 4:throw o.error;case 5:return[2]}}))}))},n.prototype.login=function(e){var t;return r(this,void 0,void 0,(function(){var n,i,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return n=e.key,i=e.ekey,r=e.services,o=e.userProfile,a=e.deviceTokenLastDeletedAt,c=void 0===a?0:a,this.session.sessionKey=n,this.session.services=r,Ls.set(this,i),this._deviceTokenCacheEnabled=null===(t=null==o?void 0:o.appInfo)||void 0===t?void 0:t.deviceTokenCache,u=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,u.get(Ds)]:[3,5];case 1:return!(l=s.sent())||l.lastDeletedAt0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])},e.prototype._isDuplicateStat=function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t},e.prototype._flush=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r;return s(this,(function(s){switch(s.label){case 0:if(t=!0,!(e.length>0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Ms({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=As.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=As.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},e.prototype._save=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=c(c([],a(this.queue),!1),a(this.flushWaitQueue),!1),[4,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((function(e){return Ze.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})];case 1:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save(),[2]}))}))},e}(),qs=function(e){function n(t){var n,i,r,s,o=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:o,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,i=n.getFullYear(),r=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0"),"".concat(i).concat(r).concat(s)),"_").concat(o),l}return t(n,e),n}(Ze),Vs=function(e){function n(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(n,e),Object.defineProperty(n.prototype,"_isSendable",{get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),n.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,e.prototype.init.call(this,t+".daily")];case 1:return n.sent(),this.queue=this.logInfo.statLogs.map((function(e){return new Ze({type:e.stat_type,ts:e.ts,data:e.data})})),[2]}}))}))},n.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),t.localCacheStat?(this.enabledState=t.enabledStat?As.ENABLED:As.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=As.DISABLED,[4,this.clear()];case 2:s.sent(),s.label=3;case 3:return this.isEnabled&&this._isSendable?[4,this._getUploadStats()]:[3,9];case 4:n=s.sent(),i=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),r=0,s.label=5;case 5:return r=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),i.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,e.prototype.init.call(this,t+".realtime")];case 1:return i.sent(),this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Ze({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}})),[2]}}))}))},i.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.statConfig=e,this._mergeQueue(),t.notificationStat?(this.enabledState=t.enabledStat?As.ENABLED:As.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=As.DISABLED,[4,this.clear()];case 2:i.sent(),i.label=3;case 3:return this.isEnabled&&this._isSendable?(n=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),[4,hs(n)]):[3,6];case 4:return i.sent(),[4,this._flush(this.queue)];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},i.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.enabledState===As.DISABLED?[2,!0]:(t=this.enabledState===As.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,this._isDuplicateStat(e)?[2,!0]:(t.push(e),this.enabledState===As.PENDING?[3,2]:[4,this._save()]));case 1:n.sent(),n.label=2;case 2:return this.isEnabled?(this._mergeQueue(),this.isEnabled&&this._isSendable?[4,this._flush(t)]:[3,4]):[3,4];case 3:return[2,n.sent()];case 4:return[2,!0]}}))}))},i}(Fs),Gs=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,i=e.dispatcher,r=e.logger;this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=$(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=i,this.logger=r,this._dailyStatCollector=new Vs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Hs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._realTimeStatCollector=new zs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}return e.prototype._migration=function(){return r(this,void 0,void 0,(function(){var e,t,i,r;return s(this,(function(s){switch(s.label){case 0:return[4,this.cacheContext.preference.get(this.key)];case 1:return(e=s.sent())?(t=[],e.statLogs.forEach((function(e){e.stat_type===Le.FEATURE_LOCALCACHE&&t.push(new Ze({type:e.stat_type,ts:e.ts,data:e.data}))})),[4,this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((function(e){return Ze.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})]):[3,6];case 2:return s.sent(),i=[],e.statLogs.forEach((function(e){e.stat_type!==Le.FEATURE_LOCALCACHE&&e.stat_type!==Le.NOTIFICATION&&(e.stat_type===Le.FEATURE_LOCALCACHE_EVENT&&(e.data=n({message_init_policy:"",starting_point:0},e.data)),i.push(new Ze({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:i.map((function(e){return Ze.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 3:return s.sent(),r=[],e.statLogs.forEach((function(e){var t;e.stat_type===Le.NOTIFICATION&&(e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),r.push(new Ze({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:r.map((function(e){return Ze.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 4:return s.sent(),[4,this.cacheContext.preference.remove(this.key)];case 5:s.sent(),s.label=6;case 6:return[2]}}))}))},e.prototype.init=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.key=e,[4,this._migration()];case 1:return n.sent(),[4,this._dailyStatCollector.init(this.key)];case 2:return n.sent(),[4,this._defaultStatCollector.init(this.key)];case 3:return n.sent(),[4,this._realTimeStatCollector.init(this.key)];case 4:return n.sent(),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){return e instanceof je?(t=e.statLog,this.put(t)):e instanceof is&&(n=e.request,i=e.features,r=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=n,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._realTimeStatCollector.setConfig(null!==(a=this._statConfig.realTime)&&void 0!==a?a:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:r.ingestion})),[2]}))}))}))),[2]}}))}))},e.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=!0,e instanceof qs?this._collectFeatureLocalCacheStat?[4,this._dailyStatCollector.put(e)]:[3,2]:[3,3];case 1:t=n.sent(),n.label=2;case 2:return[3,13];case 3:switch(e.type){case Le.API_RESULT:case Le.WEBSOCKET_CONNECT:return[3,4];case Le.FEATURE_LOCALCACHE:case Le.FEATURE_LOCALCACHE_EVENT:return[3,7];case Le.NOTIFICATION:return[3,10]}return[3,13];case 4:return this._collectRequestStat?[4,this._defaultStatCollector.put(e)]:[3,6];case 5:t=n.sent(),n.label=6;case 6:return[3,13];case 7:return this._collectFeatureLocalCacheStat?[4,this._defaultStatCollector.put(e)]:[3,9];case 8:t=n.sent(),n.label=9;case 9:return[3,13];case 10:return this._collectionNotificationStat?[4,this._realTimeStatCollector.put(e)]:[3,12];case 11:t=n.sent(),n.label=12;case 12:return[3,13];case 13:return t?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=As.COLLECT_ONLY,this._defaultStatCollector.enabledState=As.COLLECT_ONLY,this._realTimeStatCollector.enabledState=As.COLLECT_ONLY,this.logger.debug(v.statLogUploadLimitExceededError))),[2]}}))}))},e.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)},e}(),js=function(){function e(e){var t=e.limit,n=void 0===t?5:t;this.workersByKey={},this.limit=n}return e.prototype.run=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.workersByKey[e]||(this.workersByKey[e]=[]),this.workersByKey[e].length0})).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},i.payloadify=function(t){return re(se(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 lo.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})))},i.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[i];r>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=r)}})),i.req_id&&i.voted_option_ids&&(this.votedPollOptionIds=i.voted_option_ids),"number"==typeof i.voter_count&&(this.voterCount=i.voter_count),!0},i.prototype.serialize=function(){return Yr(this)},i}(zr),_o=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}(),fo=function(e){function n(t,n,i,r){var s=e.call(this,t,r)||this;return s.channelUrl=n,s.channelType=i,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(q,this.channelType)},n}(_o),po=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},Eo=function(e){function n(t){var n=t.title,i=t.optionTexts,r=t.data,s=t.allowUserSuggestion,o=t.allowMultipleVotes,a=t.closeAt,c=e.call(this)||this;return c.method=oe.POST,c.path=be,c.params={title:n,options:i,data:r,allow_user_suggestion:s,allow_multiple_votes:o,close_at:a},c}return t(n,e),n}(xe),go=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new ho(t,n),i}return t(n,e),n}(Ue),vo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=e.call(this)||this;return s.method=oe.GET,s.path="".concat(be,"/").concat(encodeURIComponent(r)),s.params={channel_url:n,channel_type:i},s}return t(n,e),n}(xe),bo=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new ho(t,n),i}return t(n,e),n}(Ue),mo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s)),o.params={channel_url:n,channel_type:i},o}return t(n,e),n}(xe),yo=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.pollOption=new lo(t,n),i}return t(n,e),n}(Ue),wo=function(e){function n(t){var n=t.channelType,i=t.channelUrl,r=t.timestamp,s=t.token,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(Ie(n),"/").concat(encodeURIComponent(i),"/polls/changelogs"),o.params=re({change_ts:r,token:s}),o}return t(n,e),n}(xe),So=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.updatedPolls=n.updated.map((function(e){return function(e,t){return new ho(e,t)}(t,e)})),i.deletedPollIds=n.deleted.map((function(e){return e})),i.hasMore=n.has_more,i.nextToken=n.next,i}return t(n,e),n}(Ue),To={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},No=function(e){return w("string",e.title)&&(t=e.optionTexts,N("string",t)&&t.every((function(e){return""!==e.trim()})))&&uo(e.data)&&w("boolean",e.allowUserSuggestion,!0)&&w("boolean",e.allowMultipleVotes,!0)&&w("number",e.closeAt,!0);var t},Co={channelUrl:"",channelType:q.BASE,pollId:0,pollOptionId:0},Ao=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)&&e.pollId>0&&w("number",e.pollOptionId)&&e.pollOptionId>0},Io={channelUrl:"",channelType:q.BASE,pollId:0},ko=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)},Oo={},Do=function(){function e(e,t){var n=t.sdkState,i=t.dispatcher,r=t.sessionManager,s=t.requestQueue,o=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=r,this._requestQueue=s,this._dispatcher=i,this._logger=o,Oo[e]=this}return e.of=function(e){return Oo[e]},e.prototype.buildPollFromSerializedData=function(e){var t=Xr(e);return new ho(this._iid,ho.payloadify(t))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return Jr(ko(e)).throw(v.invalidParameters),t=new vo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(bo).poll]}}))}))},e.prototype.create=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return Jr(No(e)).throw(v.invalidParameters),t=new Eo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(go).poll]}}))}))},e.prototype.getOption=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return Jr(Ao(e)).throw(v.invalidParameters),t=new mo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(yo).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,i){return void 0===i&&(i=Ks.SYNC_POLL_CHANGELOGS),r(this,void 0,void 0,(function(){var r,o,a,c,u,l,h;return s(this,(function(s){switch(s.label){case 0:return r=new wo(se({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(r)];case 1:return o=s.sent(),a=o.as(So),c=a.updatedPolls,u=a.deletedPollIds,l=a.hasMore,h=a.nextToken,c.length>0&&this._dispatcher.dispatch(new ro({polls:c,source:i})),[2,{updatedPolls:c,deletedPollIds:u,hasMore:l,token:h}]}}))}))},e}(),Ro=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.token,s=t.limit,o=e.call(this)||this;return o.method=oe.GET,o.path=be,o.params={channel_url:n,channel_type:i,token:r,limit:s},o}return t(n,e),n}(xe),Lo=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).polls=(null!==(i=n.polls)&&void 0!==i?i:[]).map((function(e){return new ho(t,e)})),r.token=n.next,r}return t(n,e),n}(Ue),xo=function(e){function i(t,n){return e.call(this,t,n.channelUrl,n.channelType,n)||this}return t(i,e),i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Ws.of(this._iid).requestQueue,t=new Ro(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(Lo),o=r.polls,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(fo),Uo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=t.token,a=t.limit,c=e.call(this)||this;return c.method=oe.GET,c.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s),"/voters"),c.params={channel_url:n,channel_type:i,token:o,limit:a},c}return t(n,e),n}(xe),Po=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).voters=(null!==(i=n.voters)&&void 0!==i?i:[]).map((function(e){return new es(t,e)})),r.token=n.next,r}return t(n,e),n}(Ue),Mo=function(e){function i(t,n){var i=e.call(this,t,n.channelUrl,n.channelType,n)||this;return i.pollId=n.pollId,i.pollOptionId=n.pollOptionId,i}return t(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&w("number",this.pollId)&&w("number",this.pollOptionId)},i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Ws.of(this._iid).requestQueue,t=new Uo(n(n({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(Po),o=r.voters,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(fo);export{_ as $,oe as A,as as B,q as C,kr as D,te as E,Sr as F,os as G,Nr as H,ts as I,ns as J,xr as K,F as L,Me as M,Je as N,g as O,f as P,N as Q,P as R,R as S,d as T,es as U,Ws as V,Fe as W,S as X,We as Y,Ps as Z,r as _,w as a,Z as a$,p as a0,Hr as a1,Ks as a2,M as a3,E as a4,Ir as a5,Lr as a6,V as a7,u as a8,Ur as a9,st as aA,fo as aB,ke as aC,Ee as aD,De as aE,j as aF,uo as aG,be as aH,po as aI,Vr as aJ,I as aK,nt as aL,oo as aM,Do as aN,_o as aO,L as aP,i as aQ,to as aR,no as aS,so as aT,ro as aU,io as aV,eo as aW,Ne as aX,X as aY,pe as aZ,Zs as a_,Ar as aa,Zr as ab,Be as ac,Qe as ad,le as ae,zr as af,y as ag,z as ah,Yr as ai,K as aj,qe as ak,Ie as al,Ae as am,$s as an,W as ao,A as ap,G as aq,ho as ar,Y as as,Q as at,Oe as au,tt as av,hs as aw,et as ax,B as ay,he as az,s as b,To as b0,No as b1,Io as b2,ko as b3,Co as b4,Ao as b5,lo as b6,Ys as b7,ie as b8,Ze as b9,Le as ba,qs as bb,me as bc,Xs as bd,H as be,O as bf,de as bg,C as bh,it as bi,ao as bj,Js as bk,_s as bl,co as bm,fe as bn,_e as bo,Se as bp,Te as bq,Ve as br,Ke as bs,t as c,ce as d,re as e,xe as f,n as g,Ue as h,k as i,ve as j,ge as k,ye as l,Ce as m,$ as n,Ye as o,c as p,a as q,mr as r,v as s,o as t,se as u,l as v,Jr as w,xo as x,Mo as y,Xr as z}; diff --git a/lib/__bundle-0e590e6a.js b/lib/__bundle-cc71b396.js similarity index 99% rename from lib/__bundle-0e590e6a.js rename to lib/__bundle-cc71b396.js index e887b5f..98b2398 100644 --- a/lib/__bundle-0e590e6a.js +++ b/lib/__bundle-cc71b396.js @@ -1 +1 @@ -import{c as e,e as t,u as n,g as s,X as r,a7 as a,C as i,U as o,af as u,bf as c,w as l,s as h,p as d,q as _,_ as p,b as f,t as v,Q as m,a as g,i as E,aq as C,a2 as y,b8 as M,B as b,A as N,d as U,f as S,h as T,bg as A,az as I,bc as w,W as L,ak as D,bh as x,ai as R,aO as F,V as P,z as k,O,G as H,a3 as V,be as G,aM as B,aT as q,aS as z,an as j,aR as W,aW as Q,bi as Y,a8 as K,bj as J,E as X,D as Z,F as $,b9 as ee,ba as te,ay as ne,aN as se,al as re,ao as ae,bk as ie,n as oe,aA as ue,bl as ce,bb as le,aB as he,aj as de,aF as _e,a5 as pe,aa as fe,aw as ve,$ as me,aV as ge}from"./__bundle-85fbca74.js";import{G as Ee,a as Ce,Q as ye,V as Me,Z as be,v as Ne,w as Ue,_ as Se,$ as Te,a0 as Ae,a1 as Ie,a2 as we,K as Le,x as De,a3 as xe,a4 as Re,a5 as Fe,a6 as Pe,a7 as ke,a8 as Oe,a9 as He,aa as Ve,ab as Ge,ac as Be,ad as qe,ae as ze,af as je,ag as We,ah as Qe,ai as Ye,aj as Ke,ak as Je,T as Xe,al as Ze,am as $e,an as et,ao as tt,ap as nt,aq as st,ar as rt,as as at,at as it,Y as ot,au as ut,av as ct,aw as lt,ax as ht,ay as dt,az as _t,aA as pt,aB as ft,z as vt,aC as mt,aD as gt,aE as Et,aF as Ct,aG as yt,aH as Mt,aI as bt,aJ as Nt,aK as Ut}from"./__bundle-3ceb5f92.js";import{G as St,g as Tt,D as At,c as It,R as wt,U as Lt,a as Dt,b as xt,A as Rt}from"./__bundle-b7a55976.js";import{C as Ft,B as Pt,U as kt,a as Ot,O as Ht,P as Vt,M as Gt,T as Bt,R as qt,b as zt,A as jt}from"./__bundle-ace226dc.js";var Wt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Wt||(Wt={}));var Qt,Yt,Kt,Jt,Xt,Zt,$t,en,tn=function(i){function o(e,t){var n=i.call(this,e,t)||this;return n.state=null,n.role=null,n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,n.state=r(Wt,t.state)?t.state:null,n.role=r(a,t.role)?t.role:null,"boolean"==typeof t.is_muted&&(n.isMuted=t.is_muted),"boolean"==typeof t.is_blocked_by_me&&(n.isBlockedByMe=t.is_blocked_by_me),"boolean"==typeof t.is_blocking_me&&(n.isBlockingMe=t.is_blocking_me),n}return e(o,i),o.payloadify=function(e){return t(n(s(s({},i.payloadify.call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))},o}(Ee),nn=function(t){function n(e,n){var s,r,a=this;return(a=t.call(this,e)||this).channelUrl=null!==(s=n.channel_url)&&void 0!==s?s:"",a.channelType=null!==(r=n.channel_type)&&void 0!==r?r:i.GROUP,a.member=new o(a._iid,n.user),a.deliveryAt=n.ts,a}return e(n,t),n}(u);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Qt||(Qt={})),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"}(Yt||(Yt={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Kt||(Kt={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Jt||(Jt={})),function(e){e.ALL="all",e.UNHIDDEN="unhidden_only",e.HIDDEN="hidden_only",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Xt||(Xt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Zt||(Zt={})),function(e){e.AND="AND",e.OR="OR"}($t||($t={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(en||(en={}));var sn,rn=function(){function e(e){var t,n,s,r,a,i,o,u,c,l,h,d,_,p,f;this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(t=null==e?void 0:e.includeEmpty)&&void 0!==t&&t,this.nicknameContainsFilter=null!==(n=null==e?void 0:e.nicknameContainsFilter)&&void 0!==n?n:null,this.nicknameStartsWithFilter=null!==(s=null==e?void 0:e.nicknameStartsWithFilter)&&void 0!==s?s:null,this.nicknameExactMatchFilter=null!==(r=null==e?void 0:e.nicknameExactMatchFilter)&&void 0!==r?r:null,this.channelNameContainsFilter=null!==(a=null==e?void 0:e.channelNameContainsFilter)&&void 0!==a?a:"",this.myMemberStateFilter=null!==(i=null==e?void 0:e.myMemberStateFilter)&&void 0!==i?i:Yt.ALL,this.customTypesFilter=null!==(o=null==e?void 0:e.customTypesFilter)&&void 0!==o?o:null,this.channelUrlsFilter=null!==(u=null==e?void 0:e.channelUrlsFilter)&&void 0!==u?u:null,this.superChannelFilter=null!==(c=null==e?void 0:e.superChannelFilter)&&void 0!==c?c:Kt.ALL,this.publicChannelFilter=null!==(l=null==e?void 0:e.publicChannelFilter)&&void 0!==l?l:Qt.ALL,this.customTypeStartsWithFilter=null!==(h=null==e?void 0:e.customTypeStartsWithFilter)&&void 0!==h?h:null,this.unreadChannelFilter=null!==(d=null==e?void 0:e.unreadChannelFilter)&&void 0!==d?d:Jt.ALL,this.hiddenChannelFilter=null!==(_=null==e?void 0:e.hiddenChannelFilter)&&void 0!==_?_:Xt.UNHIDDEN,this.includeFrozen=null===(p=null==e?void 0:e.includeFrozen)||void 0===p||p,(null==e?void 0:e.createdAfter)&&(this.createdAfter=e.createdAfter),(null==e?void 0:e.createdBefore)&&(this.createdBefore=e.createdBefore),this.includeMetaData=null===(f=null==e?void 0:e.includeMetaData)||void 0===f||f}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=$t.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 s=JSON.parse(JSON.stringify(this));return Object.keys(s).forEach((function(e){n[e]=s[e]})),n},e.prototype.match=function(e,t){if(this._searchFilter){var n=this._searchFilter,s=n.query,r=n.fields;if(s&&r&&r.length>0&&!r.some((function(t){switch(t){case en.CHANNEL_NAME:return e.name.toLowerCase().includes(s.toLowerCase());case en.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(s.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var a=this._userIdsFilter,i=a.userIds,o=a.includeMode,u=a.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(i.length>0)switch(u){case $t.AND:if(i.some((function(e){return!l.includes(e)})))return!1;break;case $t.OR:if(i.every((function(e){return!l.includes(e)})))return!1}}else{if(i.includes(t)||i.push(t),e.members.length>i.length)return!1;if(!c(i,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var _=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=_})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Yt.ALL:if("none"===e.myMemberState)return!1;break;case Yt.JOINED:if("joined"!==e.myMemberState)return!1;break;case Yt.INVITED:if("invited"!==e.myMemberState)return!1;break;case Yt.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Yt.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Xt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Xt.HIDDEN:if(!e.isHidden)return!1;break;case Xt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Xt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Jt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Qt.PUBLIC:if(!e.isPublic)return!1;break;case Qt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Kt.SUPER:if(!e.isSuper)return!1;break;case Kt.NON_SUPER:if(e.isSuper)return!1}return!(this.createdAfter&&e.createdAtthis.createdBefore)},e}(),an=function(t){function n(e,n){var s=n.sdkState,r=n.cacheContext,a=t.call(this,e)||this;return a._channels=new Map,a._sdkState=s,a._cacheContext=r,a}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return l(!!e).throw(h.databaseError),e.collection(Ce)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return ps.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],_(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case St.CHRONOLOGICAL:if(!a&&n.createdAt>t||a&&n.createdAtt||a&&n.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)s._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});s._update(e),n.push(s)}else a._channels.set(e.url,e),n.push(e)})),!this.localCacheEnabled)return[3,2];for(s=[],r=0;r0?[4,this.upsert(s)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},n.prototype.unblock=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],_(this._channels.keys()),!1)),p(this,void 0,void 0,(function(){var n,s,r,a,i,o,u,c;return f(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),s=v(t),r=s.next(),l.label=2;case 2:return r.done?[3,5]:(a=r.value,[4,this.get(a)]);case 3:(null==(i=l.sent())?void 0:i._updateUnreadMemberState(this._sdkState.userId,e))&&(i._updateUnreadCount(0,0),n.push(i)),l.label=4;case 4:return r=s.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{r&&!r.done&&(c=s.return)&&c.call(s)}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}(u),on={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},un=function(e){return m("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},cn={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},ln=function(e){return m("string",e.customTypes,!0)&&g("boolean",e.includeEmpty,!0)&&g("boolean",e.includeFrozen,!0)&&g("boolean",e.includeMetaData,!0)&&g("boolean",e.includeChatNotification,!0)},hn={myMemberStateFilter:Yt.ALL},dn=function(e){return r(Yt,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"}(sn||(sn={}));var _n={keys:[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT,sn.NONSUPER_UNREAD_MENTION_COUNT,sn.SUPER_UNREAD_MENTION_COUNT,sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,sn.NONSUPER_UNREAD_MESSAGE_COUNT,sn.SUPER_UNREAD_MESSAGE_COUNT,sn.GROUP_CHANNEL_INVITATION_COUNT,sn.NONSUPER_INVITATION_COUNT,sn.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},pn={channelCustomTypesFilter:void 0,superChannelFilter:Kt.ALL},fn=function(e){return m("string",e.channelCustomTypesFilter,!0)&&r(Kt,e.superChannelFilter)},vn={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:C.ALL},mn=s({},y),gn=function(e){return e.startsWith("EVENT_")||e===y.SYNC_CHANNEL_CHANGELOGS||e===y.REFRESH_CHANNEL},En=function(t){function n(e){var n=e.channels,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=e.ts,o=t.call(this)||this;return o.channels=n,o.context=s,o.isWebSocketEventComing=a,o.ts=i,o}return e(n,t),n}(M),Cn=function(t){function n(e){var n=e.channelUrls,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=t.call(this)||this;return i.channelUrls=n,i.context=s,i.isWebSocketEventComing=a,i}return e(n,t),n}(M),yn=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,s=e.unsentMessageCache,r=e.dispatcher,a=this;this._observers=new Map,r.on((function(e){return p(a,void 0,void 0,(function(){var r,a,i,o,u,c,l,h,d,_,m,g,E,C,M,N,U,S,T=this;return f(this,(function(A){switch(A.label){case 0:if(!(e instanceof En))return[3,19];if(r=e.channels,E=e.context,C=e.isWebSocketEventComing,a=r.filter((function(e){return e instanceof ur})),E.source!==y.EVENT_CHANNEL_RESET_HISTORY&&E.source!==y.EVENT_CHANNEL_HIDDEN)return[3,9];A.label=1;case 1:A.trys.push([1,6,7,8]),i=v(a),o=i.next(),A.label=2;case 2:return o.done?[3,5]:(d=o.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 3:A.sent(),A.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return u=A.sent(),M={error:u},[3,8];case 7:try{o&&!o.done&&(N=i.return)&&N.call(i)}finally{if(M)throw M.error}return[7];case 8:return[3,17];case 9:c=t.filterOffsetChanged(a),A.label=10;case 10:A.trys.push([10,15,16,17]),l=v(c),h=l.next(),A.label=11;case 11:return h.done?[3,14]:(d=h.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 12:A.sent(),A.label=13;case 13:return h=l.next(),[3,11];case 14:return[3,17];case 15:return _=A.sent(),U={error:_},[3,17];case 16:try{h&&!h.done&&(S=l.return)&&S.call(l)}finally{if(U)throw U.error}return[7];case 17:return[4,t.upsert(a,e.ts)];case 18:return m=A.sent(),C||this._broadcastUpdateEvent(m,E),[3,24];case 19:return e instanceof Cn?(g=e.channelUrls,E=e.context,C=e.isWebSocketEventComing,[4,t.remove(g)]):[3,22];case 20:return A.sent(),[4,b((function(){return p(T,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=v(g),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(r=t.value,[4,n.removeMessagesOfChannel(r)]);case 2:return u.sent(),[4,s.removeMessagesOfChannel(r)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return a=u.sent(),i={error:a},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(i)throw i.error}return[7];case 8:return[2]}}))}))}))];case 21:return A.sent(),C||this._broadcastRemoveEvent(g,E),[3,24];case 22:return e instanceof At?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,24];case 23:A.sent(),A.label=24;case 24:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onUpdate&&i.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onRemove&&i.onRemove(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}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}(),Mn=function(r){function a(e){var a=e.userId,i=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c,h=r.call(this)||this,d=s(s({},cn),u),_=d.customTypes,p=d.includeEmpty,f=d.includeFrozen;return h.method=N.GET,h.path="".concat(U,"/").concat(encodeURIComponent(a),"/my_group_channels/changelogs"),h.params=t(n({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:_,show_empty:p,show_frozen:f,include_chat_notification:l})),h}return e(a,r),a}(S),bn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedChannels=n.updated.map((function(t){return new ur(e,Object.assign(t,{ts:n.ts}))})),s.deletedChannelUrls=n.deleted,s.hasMore=n.has_more,s.token=n.next,s.ts=n.ts,s}return e(n,t),n}(T),Nn=function(t){function n(e){var n=e.channelUrl,s=e.isInternalCall,r=e.showLatestMessage,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(s?A:I,"/").concat(encodeURIComponent(n)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=r&&r},a}return e(n,t),n}(S),Un=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Sn={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:Yt.ALL,unreadChannelFilter:Jt.ALL,superChannelFilter:Kt.ALL,publicChannelFilter:Qt.ALL,hiddenChannelFilter:Xt.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:$t.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:St.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0},Tn=function(n){function s(e){var s=this,r=e.userId,a=e.token,i=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,_=e.nicknameContainsFilter,p=e.nicknameStartsWithFilter,f=e.nicknameExactMatchFilter,v=e.channelNameContainsFilter,m=e.channelUrlsFilter,g=e.customTypesFilter,E=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,y=e.metadataOrderKeyFilter,M=e.metadataKey,b=e.metadataValues,S=e.metadataValueStartsWith,T=e.includeFrozen,A=e.includeMetaData,I=e.searchFilter,w=e.userIdsFilter,L=e.includeChatNotification,D=void 0!==L&&L,x=e.includeLeftChannel,R=void 0!==x&&x,F=e.createdAfter,P=e.createdBefore;return(s=n.call(this)||this).method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(r),"/my_group_channels"),s.params=t({token:a,limit:i,order:null!=o?o:Sn.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=u?u:Sn.includeEmpty,member_state_filter:null!=c?c:Sn.myMemberStateFilter,super_mode:null!=l?l:Sn.superChannelFilter,public_mode:null!=h?h:Sn.publicChannelFilter,unread_filter:null!=d?d:Sn.unreadChannelFilter,members_nickname_contains:_,members_nickname_startswith:p,members_nickname:f,name_contains:v,channel_urls:m,custom_types:g,custom_type_startswith:E,hidden_mode:C,metadata_order_key:y,metadata_key:M,metadata_values:b,metadata_value_startswith:S,show_frozen:T,show_metadata:A,include_chat_notification:D,include_left_channel:R,created_after:F,created_before:P}),I&&I.query&&I.fields&&(s.params.search_query=I.query,s.params.search_fields=I.fields),w&&w.userIds&&w.userIds.length>0&&(w.includeMode?(s.params.members_include_in=w.userIds,s.params.query_type=w.queryType.toUpperCase()):s.params.members_exactly_in=w.userIds),s}return e(s,n),s}(S),An=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.channels=[];var r=n.next,a=n.channels,i=n.ts;return s.token=r,a&&a.length>0&&(s.channels=a.map((function(t){return t.ts=i,new ur(e,t)}))),s.ts=null!=i?i:0,s}return e(n,t),n}(T),In=function(t){function n(e){var n=e.userId,s=e.filter,r=t.call(this)||this,a=s.myMemberStateFilter;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/group_channel_count"),r.params={state:null!=a?a:Yt.ALL},r}return e(n,t),n}(S),wn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.groupChannelCount=n.group_channel_count,s}return e(n,t),n}(T),Ln=function(n){function s(e){var s=e.userId,r=e.filter,a=n.call(this)||this,i=r.keys,o=r.customTypeFilters,u=r.customTypesFilter;return a.method=N.GET,a.path="".concat(U,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=t({item_keys:i,custom_types:null!=u?u:o}),a}return e(s,n),s}(S),Dn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=n[sn.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=n[sn.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=n[sn.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=n[sn.SUPER_INVITATION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=n[sn.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=n[sn.NONSUPER_INVITATION_COUNT]),s}return e(n,t),n}(T),xn=function(t){function n(e){var n=e.userId,s=t.call(this)||this;return s.method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_channel_count"),s}return e(n,t),n}(S),Rn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s}return e(n,t),n}(T),Fn=function(t){function n(e){var n=e.userId,s=e.filter,r=e.includeFeedChannel,a=void 0!==r&&r,i=t.call(this)||this,o=s.channelCustomTypesFilter,u=s.superChannelFilter;return i.method=N.GET,i.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_message_count"),i.params={super_mode:null!=u?u:Kt.ALL,custom_types:o,include_feed_channel:a},i}return e(n,t),n}(S),Pn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s.unreadFeedCount=n.unread_feed_count,s}return e(n,t),n}(T),kn=function(t){function n(e){var n=e.channelUrl,s=e.scheduledStatus,r=e.messageTypeFilter,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(w,"/count"),a.params={channel_url:n,status:Hn(s)},r&&(a.params.message_type=r),a}return e(n,t),n}(S),On=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.count=n.count,s}return e(n,t),n}(T),Hn=function(e){if(!e)return[];var t=[];return e.forEach((function(e){switch(e){case Me.PENDING:t.push(be.PENDING);break;case Me.SENT:t.push(be.IN_QUEUE),t.push(be.SENT);break;case Me.CANCELED:t.push(be.CANCELED);break;case Me.FAILED:t.push(be.FAILED)}})),t},Vn=function(n){function s(e){var s=this,r=e.userId,a=e.channelUrl,i=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,h=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,E=e.name,C=e.data,y=e.customType,M=e.messageSurvivalSeconds,b=e.invitedUserIds,U=e.operatorUserIds;return(s=n.call(this)||this).method=N.POST,s.path=I,s.params=t({user_ids:d([r],_(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:a,cover_url:i,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:p,is_public:h,is_discoverable:f,strict:v,is_ephemeral:m,access_code:g,name:E,data:C,custom_type:y,operator_ids:U,message_survival_seconds:M}),s}return e(s,n),s}(S),Gn=function(t){function n(e,n){var s,r=this;return(r=t.call(this,e,n)||this).channel=new ur(e,n),r.isCreated=null===(s=n.is_created)||void 0===s||s,r}return e(n,t),n}(T),Bn=function(t){function n(e){var n=e.userId,s=e.channelUrls,r=t.call(this)||this;return r.method=N.PUT,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),r.params={channel_urls:s},r}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var qn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/join"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),zn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u,l=a.users,h=void 0===l?null:l;return r.memberCount=o,r.joinedMemberCount=c,r.members=Array.isArray(h)?h.map((function(t){return new tn(e,t)})):[new tn(e,s.data)],r}return e(n,t),n}(Ft),Wn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/leave"),n.params={user_id:r,should_remove_operator_status:a},n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Qn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u;return r.memberCount=o,r.joinedMemberCount=c,r.member=new tn(r._iid,s.data),r}return e(n,t),n}(Ft),Yn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userIds;return(n=t.call(this)||this).method=N.POST,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/invite"),n.params={user_ids:r},n}return e(n,t),n}(S),Kn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this;r.inviter=null;var a=s.data,i=a.member_count,u=void 0===i?0:i,c=a.joined_member_count,l=void 0===c?0:c,h=a.inviter,d=a.invitees,_=void 0===d?[]:d;return r.memberCount=u,r.joinedMemberCount=l,h&&Object.keys(h).length>0&&(r.inviter=new o(e,h)),r.invitees=_.map((function(t){return new tn(e,t)})),r}return e(n,t),n}(Ft),Xn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/decline"),n.params={user_id:r},n}return e(n,t),n}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.NONE,s}e(n,t)}(T);var Zn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,u=a.joined_member_count,c=a.inviter,l=a.invitee;return r.memberCount=null!=i?i:0,r.joinedMemberCount=null!=u?u:0,r.inviter=new o(e,c),r.invitee=new tn(e,l),r}return e(n,t),n}(Ft),$n={hidePreviousMessages:!1,allowAutoUnhide:!0},es=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.hidePreviousMessages,i=e.allowAutoUnhide;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n.params={user_id:r,hide_previous_messages:null!=a?a:$n.hidePreviousMessages,allow_auto_unhide:null!=i?i:$n.allowAutoUnhide},n}return e(n,t),n}(S),ts=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),ns=function(t){function n(e,n,s){var r,a,i,o=this;return(o=t.call(this,e,"SYEV",s)||this).allowAutoUnhide=null,o.hidePreviousMessages=null,o.messageOffsetTimestamp=null,s.data&&(o.allowAutoUnhide=null!==(r=s.data.allow_auto_unhide)&&void 0!==r?r:null,o.hidePreviousMessages=null!==(a=s.data.hide_previous_messages)&&void 0!==a?a:null),o.messageOffsetTimestamp=null!==(i=s.ts_message_offset)&&void 0!==i?i:null,o}return e(n,t),n}(L),ss=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),rs=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),as=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),is=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),os=function(t){function n(e){var n=e.channelUrl,s=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:s}})||this}return e(n,t),n}(D),us=function(t){function a(e,n){var s,r,a,i,o,u,c,l,h,d,_,p,f,v,m,g,E,C,y,M,b,N,U,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.includeChatNotification=!1,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Yt.ALL,S.unreadChannelFilter=Jt.ALL,S.superChannelFilter=Kt.ALL,S.publicChannelFilter=Qt.ALL,S.hiddenChannelFilter=Xt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=St.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,S.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,S.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,S.includeChatNotification=null!==(i=n.includeChatNotification)&&void 0!==i&&i,S.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,S.customTypesFilter=null!==(u=n.customTypesFilter)&&void 0!==u?u:null,S.customTypeStartsWithFilter=null!==(c=n.customTypeStartsWithFilter)&&void 0!==c?c:"",S.nicknameContainsFilter=null!==(l=n.nicknameContainsFilter)&&void 0!==l?l:null,S.nicknameStartsWithFilter=null!==(h=n.nicknameStartsWithFilter)&&void 0!==h?h:null,S.nicknameExactMatchFilter=null!==(d=n.nicknameExactMatchFilter)&&void 0!==d?d:null,S.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Yt.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Jt.ALL,S.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:Kt.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Qt.ALL,S.hiddenChannelFilter=null!==(g=n.hiddenChannelFilter)&&void 0!==g?g:Xt.UNHIDDEN,S.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},S.userIdsFilter=null!==(C=n.userIdsFilter)&&void 0!==C?C:{userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null!==(y=n.metadataKey)&&void 0!==y?y:null,S.metadataValues=null!==(M=n.metadataValues)&&void 0!==M?M:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(N=n.metadataValueStartsWith)&&void 0!==N?N:null,S.order=null!==(U=n.order)&&void 0!==U?U:St.LATEST_LAST_MESSAGE,n.createdAfter&&(S.createdAfter=n.createdAfter),n.createdBefore&&(S.createdBefore=n.createdBefore),S}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&m("string",this.channelUrlsFilter,!0)&&m("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&r(Yt,this.myMemberStateFilter)&&r(Kt,this.superChannelFilter)&&r(Qt,this.publicChannelFilter)&&r(Jt,this.unreadChannelFilter)&&r(Xt,this.hiddenChannelFilter)&&m(en,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&m("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&r($t,this.userIdsFilter.queryType)&&r(St,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&m("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)&&x(this.createdAfter,!0)&&x(this.createdBefore,!0)},a.prototype.serialize=function(){return R(this)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,ps.of(this._iid).getMyGroupChannels(this._token,n(s({},this)),this.limit,y.REQUEST_CHANNEL,!0)]):[3,2]:[3,5];case 1:return e=a.sent(),t=e.channels,r=e.token,this._token=r,this._hasNext=!!r,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(F),cs=function(n){function s(e){var s=e.channelUrl,r=e.userId,a=n.call(this)||this;return a.method=N.PUT,a.path="".concat(I,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=t({userId:r}),a}return e(s,n),s}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var ls,hs=function(t){function n(e,n,s){var r=t.call(this,e,"DLVR",s)||this;return r.channelUrl=s.channel_url,r.deliveredStateUpdate=s.updated,r}return e(n,t),n}(L),ds=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,s=e.bottom,r=void 0===s?0:s;this.top=n,this.bottom=r}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0&&n.onMentionReceived&&n.onMentionReceived(g,_)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=6;case 6:return[3,79];case 7:return U=e.as(Y),me=U.channelUrl,ge=U.channelType,S=U.messageId,T=U.silent,A=U.messageCreatedAt,I=U.senderId,ge!==i.GROUP?[3,9]:[4,this.getChannel(me,!0)];case 8:w=xn.sent(),L=I===this._sdkState.userId,T||L||A>0&&w.myLastRead0&&w._updateUnreadCount(w.unreadMessageCount-1,0),this._dispatcher.dispatch(new Q({messageIds:[S],source:y.EVENT_MESSAGE_DELETED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onMessageDeleted&&n.onMessageDeleted(w,S)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=9;case 9:return[3,79];case 10:return(D=e.as(Be).readStatus).channelType!==i.GROUP?[3,12]:(V=this._groupChannelCache.isCachedInMemory(D.channelUrl),[4,this.getChannel(D.channelUrl,!0)]);case 11:x=xn.sent(),V&&x._updateUnreadMemberState(D.reader.userId,D.readAt),D.reader.userId===this._sdkState.userId?V?(x.unreadMessageCount>0||x.unreadMentionCount>0)&&(x._updateUnreadCount(0,0),this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):0!==x.unreadMessageCount&&0!==x.unreadMentionCount||(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUnreadMemberStatusUpdated&&n.onUnreadMemberStatusUpdated(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),xn.label=12;case 12:return[3,79];case 13:return R=e.as(hs),me=R.channelUrl,F=R.deliveredStateUpdate,k=void 0===F?{}:F,V=this._groupChannelCache.isCachedInMemory(me),[4,this.getChannel(me,!0)];case 14:return K=xn.sent(),V&&Object.keys(k).forEach((function(e){K._updateUndeliveredMemberState(e,k[e])})),Object.keys(k).some((function(e){return e!==Dn._sdkState.userId}))&&(this._dispatcher.dispatch(new En({channels:[K],context:{source:y.EVENT_CHANNEL_DELIVERED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUndeliveredMemberStatusUpdated&&n.onUndeliveredMemberStatusUpdated(K)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 15:return X=e.as(qt),me=X.channelUrl,ge=X.channelType,Z=X.event,ge!==i.GROUP?[3,18]:[4,this.getChannel(me,!0)];case 16:return $=xn.sent(),[4,this.getMessageFromCache(Z.messageId)];case 17:(ne=xn.sent())?ne instanceof Ge&&(ne.applyReactionEvent(Z),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new W({event:Z,source:y.EVENT_MESSAGE_REACTION_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onReactionUpdated&&n.onReactionUpdated($,Z)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=18;case 18:return[3,79];case 19:return(ee=e.as(Bt).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(ee.channelUrl,!0)];case 20:return te=xn.sent(),[4,this.getMessageFromCache(ee.targetMessageId)];case 21:(ne=xn.sent())?ne instanceof Ge&&(ne.applyThreadInfoUpdateEvent(ee),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new z({event:ee,source:y.EVENT_MESSAGE_THREADINFO_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onThreadInfoUpdated&&n.onThreadInfoUpdated(te,ee)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=22;case 22:return[3,79];case 23:se=e.as(Gt).groupChannelMemberCounts,re=[],xn.label=24;case 24:xn.trys.push([24,29,30,31]),ae=v(se),ie=ae.next(),xn.label=25;case 25:return ie.done?[3,28]:(oe=ie.value,me=oe.channelUrl,ct=oe.memberCount,lt=oe.joinedMemberCount,ue=oe.updatedAt,[4,this.getChannelFromCache(me)]);case 26:(ce=xn.sent())&&ce._setLatestMemberCount(ct,lt,ue)&&re.push(ce),xn.label=27;case 27:return ie=ae.next(),[3,25];case 28:return[3,31];case 29:return le=xn.sent(),Nn={error:le},[3,31];case 30:try{ie&&!ie.done&&(Un=ae.return)&&Un.call(ae)}finally{if(Nn)throw Nn.error}return[7];case 31:return re.length>0&&(this._dispatcher.dispatch(new En({channels:re,context:{source:y.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelMemberCountChanged&&n.onChannelMemberCountChanged(re)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 32:return he=e.as(Vt),de=he.event,_e=he.status,me=he.channelUrl,ge=he.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,34];case 33:pe=xn.sent(),this._dispatcher.dispatch(new q({event:de,source:y.EVENT_POLL_UPDATED})),H(_e===J?function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollDeleted&&n.onPollDeleted(pe,de.pollId)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}:function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollUpdated&&n.onPollUpdated(pe,de)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}),xn.label=34;case 34:return[3,79];case 35:return fe=e.as(Ve),ve=fe.event,me=fe.channelUrl,ge=fe.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,37];case 36:Ee=xn.sent(),this._dispatcher.dispatch(new B({event:ve,source:y.EVENT_POLL_VOTED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollVoted&&n.onPollVoted(Ee,ve)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=37;case 37:return[3,79];case 38:if(!(Ce=e.as(Ft).event).isGroupChannelEvent)return[3,77];switch(Ce.category){case Ot.CHANNEL_JOIN:return[3,39];case Ot.CHANNEL_LEAVE:return[3,41];case Ot.CHANNEL_OPERATOR_UPDATE:return[3,45];case Ot.CHANNEL_INVITE:return[3,47];case Ot.CHANNEL_DECLINE_INVITE:return[3,49];case Ot.TYPING_START:case Ot.TYPING_END:return[3,51];case Ot.USER_CHANNEL_MUTE:case Ot.USER_CHANNEL_UNMUTE:return[3,53];case Ot.USER_CHANNEL_BAN:return[3,55];case Ot.USER_CHANNEL_UNBAN:return[3,59];case Ot.CHANNEL_FREEZE:case Ot.CHANNEL_UNFREEZE:return[3,61];case Ot.CHANNEL_HIDE:return[3,63];case Ot.CHANNEL_UNHIDE:return[3,65];case Ot.CHANNEL_DELETED:return[3,67];case Ot.CHANNEL_PROP_CHANGED:return[3,69];case Ot.CHANNEL_META_DATA_CHANGED:return[3,71];case Ot.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case Ot.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(Ce.channelUrl,!0)];case 40:return ye=xn.sent(),Me=e.as(jn),be=Me.memberCount,Ne=Me.joinedMemberCount,Ue=Me.members,Se=!1,Ue.forEach((function(e){ye.isExclusive||ye.isSuper||ye.isBroadcast?Se=Se||ye._setLatestMemberCount(be,Ne,Ce.ts):(e.state=Wt.JOINED,ye.addMember(e,Ce.ts),Dn._updateJoinedMemberCount(ye)),e.userId===Dn._sdkState.userId&&(ye.myMemberState=Wt.JOINED)})),this._dispatcher.dispatch(new En({channels:[ye],context:{source:y.EVENT_CHANNEL_JOINED,users:Ue}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var s=v(Ue),r=s.next();!r.done;r=s.next()){var a=r.value;e.onUserJoined&&e.onUserJoined(ye,a)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}ye.isBroadcast&&Se&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,77];case 41:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Ae=Mt.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(Ce.channelUrl,!0)];case 43:Ae=xn.sent(),xn.label=44;case 44:return Te=Ae,Ie=e.as(Qn),ct=Ie.memberCount,lt=Ie.joinedMemberCount,we=Ie.member,Le=!1,De=P.of(this._iid).appInfo,Te.isExclusive||Te.isSuper||Te.isBroadcast?Le=Te._setLatestMemberCount(ct,lt,Ce.ts):((null==De?void 0:De.enabledChannelMemberShipHistory)?((Ye=Te.members.find((function(e){return e.userId===we.userId})))&&(Ye.state=Wt.LEFT),Te.memberCount=ct):Te.removeMember(we),this._updateJoinedMemberCount(Te)),we.userId===this._sdkState.userId?(Te.myMemberState=Wt.NONE,Te.invitedAt=0,Te.joinedAt=0,Te._updateUnreadCount(0,0),Te.isPublic?this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})):(this._markAsLeave(Te),this._dispatcher.dispatch(new Cn({channelUrls:[Te.url],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})))):this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(Te,we),Te.isBroadcast&&Le&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Te])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(Ce.channelUrl,!0)];case 46:Ke=xn.sent(),Je=e.as(Ht).operators,Xe=Je.map((function(e){return e.userId}));try{for(Ze=v(Ke.members),$e=Ze.next();!$e.done;$e=Ze.next())(yt=$e.value).role=Xe.includes(yt.userId)?a.OPERATOR:a.NONE}catch(e){Sn={error:e}}finally{try{$e&&!$e.done&&(Tn=Ze.return)&&Tn.call(Ze)}finally{if(Sn)throw Sn.error}}return Ke.myRole=Xe.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new En({channels:[Ke],context:{source:y.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Je}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ke,Je)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(Ce.channelUrl,!0)];case 48:et=xn.sent(),tt=e.as(Jn),ct=tt.memberCount,lt=tt.joinedMemberCount,nt=tt.inviter,(st=tt.invitees).forEach((function(e){return e.state=Wt.INVITED}));try{for(rt=v(st),at=rt.next();!at.done;at=rt.next())it=at.value,et.isExclusive||et.isSuper||et.isBroadcast?et._setLatestMemberCount(ct,lt,Ce.ts):et.addMember(it,Ce.ts),this._sdkState.userId===it.userId&&(et.hiddenState=tr.UNHIDDEN,et.myMemberState!==Wt.JOINED&&(et.myMemberState=Wt.INVITED),et.invitedAt=Ce.ts)}catch(e){An={error:e}}finally{try{at&&!at.done&&(In=rt.return)&&In.call(rt)}finally{if(An)throw An.error}}return this._dispatcher.dispatch(new En({channels:[et],context:{source:y.EVENT_CHANNEL_INVITED,inviter:nt,invitees:st}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(et,nt,st)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(Ce.channelUrl,!0)];case 50:return ot=xn.sent(),ut=e.as(Zn),ct=ut.memberCount,lt=ut.joinedMemberCount,ht=ut.inviter,dt=ut.invitee,ot.isExclusive||ot.isSuper||ot.isBroadcast?ot._setLatestMemberCount(ct,lt,Ce.ts):ot.removeMember(dt),this._sdkState.userId===dt.userId?(ot.invitedAt=0,ot.myMemberState=Wt.NONE,ot.isPublic?this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})):this._dispatcher.dispatch(new Cn({channelUrls:[ot.url],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}}))):this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ot,ht,dt)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(Ce.channelUrl,!0)];case 52:return _t=xn.sent(),pt=Ce.category===Ot.TYPING_START,ft=e.as(pt?rs:is).user,_t._updateTypingStatus(ft,pt?Ce.ts:0),this._dispatcher.dispatch(new En({channels:[_t],context:{source:y.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(_t)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(Ce.channelUrl,!0)];case 54:vt=xn.sent(),mt=Ce.category===Ot.USER_CHANNEL_MUTE,(gt=e.as(mt?Oe:He).user).userId===this._sdkState.userId&&(vt.myMutedState=mt?G.MUTED:G.UNMUTED,vt._myMutedRemainingTime=gt.restrictionInfo.remainingDuration);try{for(Et=v(vt.members),Ct=Et.next();!Ct.done;Ct=Et.next())if((yt=Ct.value).userId===gt.userId){yt.isMuted=mt;break}}catch(e){wn={error:e}}finally{try{Ct&&!Ct.done&&(Ln=Et.return)&&Ln.call(Et)}finally{if(wn)throw wn.error}}return this._dispatcher.dispatch(new En({channels:[vt],context:{source:mt?y.EVENT_CHANNEL_MUTED:y.EVENT_CHANNEL_UNMUTED,user:gt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){mt?e.onUserMuted&&e.onUserMuted(vt,gt):e.onUserUnmuted&&e.onUserUnmuted(vt,gt)})),[2]}))}))})),[3,77];case 55:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Nt=Mt.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(Ce.channelUrl,!0)];case 57:Nt=xn.sent(),xn.label=58;case 58:return bt=Nt,this._markAsLeave(bt),Ut=e.as(ke).user,Ut.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[bt.url],context:{source:y.EVENT_CHANNEL_BANNED,user:Ut}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(bt,Ut)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(Ce.channelUrl,!0)];case 60:return St=xn.sent(),Tt=e.as(Pe).user,Tt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[St.url],context:{source:y.EVENT_CHANNEL_UNBANNED,user:Tt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(St,Tt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(Ce.channelUrl,!0)];case 62:return At=xn.sent(),It=e.as(Fe).freeze,At.isFrozen=It,this._dispatcher.dispatch(new En({channels:[At],context:{source:It?y.EVENT_CHANNEL_FROZEN:y.EVENT_CHANNEL_UNFROZEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){It?e.onChannelFrozen&&e.onChannelFrozen(At):e.onChannelUnfrozen&&e.onChannelUnfrozen(At)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(Ce.channelUrl,!0)];case 64:return wt=xn.sent(),Rt=e.as(ns),Pt=Rt.allowAutoUnhide,Qt=Rt.hidePreviousMessages,Yt=Rt.messageOffsetTimestamp,null!==Pt&&(wt.hiddenState=Pt?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Qt&&Qt&&wt._updateUnreadCount(0,0),null!==Yt&&(wt.messageOffsetTimestamp=Yt),this._dispatcher.dispatch(new En({channels:[wt],context:{source:y.EVENT_CHANNEL_HIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(wt)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(Ce.channelUrl,!0)];case 66:return(Kt=xn.sent()).hiddenState=tr.UNHIDDEN,this._dispatcher.dispatch(new En({channels:[Kt],context:{source:y.EVENT_CHANNEL_UNHIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Kt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(Ce.channelUrl,!0)];case 68:return Jt=xn.sent(),this._dispatcher.dispatch(new Cn({channelUrls:[Ce.channelUrl],context:{source:y.EVENT_CHANNEL_DELETED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Jt.url,Jt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(Ce.channelUrl,!0)];case 70:return Xt=xn.sent(),this._dispatcher.dispatch(new En({channels:[Xt],context:{source:y.EVENT_CHANNEL_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Xt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(Ce.channelUrl,!0)];case 72:return Zt=xn.sent(),$t=e.as(Re),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&(Zt._upsertCachedMetaData(en,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_CREATED,metaData:en},ts:Ce.ts}))),tn&&(Zt._upsertCachedMetaData(tn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_UPDATED,metaData:tn},ts:Ce.ts}))),nn&&(Zt._removeFromCachedMetaData(nn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:nn},ts:Ce.ts}))),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){en&&e.onMetaDataCreated&&e.onMetaDataCreated(Zt,en),tn&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Zt,tn),nn&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Zt,nn)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(Ce.channelUrl,!0)];case 74:return sn=xn.sent(),rn=e.as(xe),an=rn.created,on=rn.updated,un=rn.deleted,an&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:an}})),on&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:on}})),un&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:un}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){an&&e.onMetaCounterCreated&&e.onMetaCounterCreated(sn,an),on&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(sn,on),un&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(sn,un)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(Ce.channelUrl,!0)];case 76:return cn=xn.sent(),ln=e.as(kt),hn=ln.pinnedMessageIds,dn=ln.latestPinnedMessage,(_n=ln.ts)>cn._pinnedMessagesUpdatedAt&&(cn.pinnedMessageIds=null!=hn?hn:[],cn.lastPinnedMessage=dn,cn._pinnedMessagesUpdatedAt=_n,this._dispatcher.dispatch(new En({channels:[cn],context:{source:y.EVENT_PINNED_MESSAGE_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(cn)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(cn)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((pn=e.as(Lt).event).category){case Dt.USER_BLOCK:fn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=fn.blocker,gn=fn.blockee,this._groupChannelCache.block(mn.userId,gn.userId);break;case Dt.USER_UNBLOCK:vn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=vn.blocker,gn=vn.blockee,this._groupChannelCache.unblock(mn.userId,gn.userId)}return[3,79];case 79:return[3,81];case 80:if(yn=xn.sent(),O(yn))throw yn;return[3,81];case 81:return[2]}}))}))},u.prototype._markAsLeave=function(e){var t,n=this,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((function(){s.ref--,0===s.ref&&n._leftChannels.delete(e.url)}),1e4)},u.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},u.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},u.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},u.prototype.subscribeChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},u.prototype.unsubscribeChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},u.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===Wt.JOINED})).length},u.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n;return f(this,(function(s){switch(s.label){case 0:l(g("string",e)).throw(h.invalidParameters),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=s.sent())?[2,n]:[3,4];case 3:return s.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,s.sent()]}}))}))},u.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return l(g("string",e)).throw(h.invalidParameters),n=new Nn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(s=o.sent(),r=s.as(Un).channel,a=r.unreadMessageCount,i=r.unreadMentionCount,r.myCountPreference){case er.UNREAD_MESSAGE_COUNT_ONLY:i=0;break;case er.UNREAD_MENTION_COUNT_ONLY:a=0;break;case er.OFF:a=0,i=0}return r._updateUnreadCount(a,i),[4,this.upsertChannelsToCache([r])];case 2:return[2,o.sent()[0]]}}))}))},u.prototype.refreshChannel=function(e,t,n,s){return void 0===t&&(t=!0),void 0===n&&(n=y.REFRESH_CHANNEL),void 0===s&&(s=!1),p(this,void 0,void 0,(function(){var r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Nn({channelUrl:e,isInternalCall:t,showLatestMessage:s}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Un).channel).myMemberState!==Wt.NONE?[3,2]:(this._dispatcher.dispatch(new Cn({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new En({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(u=c.sent()).code!==K.NON_AUTHORIZED&&u.code!==K.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Cn({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},u.prototype.getMyGroupChannels=function(e,t,n,r,a){return void 0===r&&(r=y.REQUEST_CHANNEL),void 0===a&&(a=!1),p(this,void 0,void 0,(function(){var i,o,u,c,l,h,d,_,p;return f(this,(function(f){switch(f.label){case 0:return t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3)),i=!1,a&&(o=P.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(i=!0)),l=new Tn(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n,includeLeftChannel:a&&i})),[4,this._requestQueue.send(l)];case 1:return h=f.sent(),d=h.as(An),_=d.channels,p=d.token,this._dispatcher.dispatch(new En({channels:_,context:{source:r}})),[2,{channels:_,token:p}]}}))}))},u.prototype.getMyGroupChannelChangeLogs=function(e,t,r){return void 0===r&&(r=y.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var a,i,o,u,c,d,_,p;return f(this,(function(f){switch(f.label){case 0:return a=s(s({},cn),t),l((g("string",e)||g("number",e))&&ln(a)).throw(h.invalidParameters),i=new Mn(n({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:a})),[4,this._requestQueue.send(i)];case 1:return o=f.sent(),u=o.as(bn),c=u.updatedChannels,d=u.deletedChannelUrls,_=u.hasMore,p=u.ts,c.length>0&&this._dispatcher.dispatch(new En({channels:c,context:{source:r},ts:p})),d.length>0&&this._dispatcher.dispatch(new Cn({channelUrls:d,context:{source:r}})),[2,{updatedChannels:c,deletedChannelUrls:d,hasMore:_,token:u.token}]}}))}))},u.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(a){switch(a.label){case 0:return t=s(s({},hn),e),l(dn(t)).throw(h.invalidParameters),n=new In({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),[2,r.as(wn).groupChannelCount]}}))}))},u.prototype.getUnreadItemCount=function(e){return p(this,void 0,void 0,(function(){var n,r,a,i,o,u,c,d,_,p,v,g,E,C,y,M;return f(this,(function(f){switch(f.label){case 0:return n=s(s({},_n),e),l(function(e){return m(sn,e.keys)&&m("string",e.customTypeFilters,!0)&&m("string",e.customTypesFilter,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid),a=r.sdkState,i=r.requestQueue,o=new Ln({userId:a.userId,filter:n}),[4,i.send(o)];case 1:return u=f.sent(),c=u.as(Dn),d=c.groupChannelUnreadMentionCount,_=c.groupChannelUnreadMessageCount,p=c.groupChannelInvitationCount,v=c.superGroupChannelUnreadMentionCount,g=c.superGroupChannelUnreadMessageCount,E=c.superGroupChannelInvitationCount,C=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,M=c.nonSuperGroupChannelInvitationCount,[2,t({groupChannelUnreadMentionCount:d,groupChannelUnreadMessageCount:_,groupChannelInvitationCount:p,superGroupChannelUnreadMentionCount:v,superGroupChannelUnreadMessageCount:g,superGroupChannelInvitationCount:E,nonSuperGroupChannelUnreadMentionCount:C,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:M})]}}))}))},u.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new xn({userId:t.userId}),[4,n.send(s)];case 1:return r=a.sent(),[2,r.as(Rn).unreadCount]}}))}))},u.prototype.getTotalUnreadMessageCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return t=s(s({},pn),e),l(fn(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Fn({userId:r.userId,filter:t}),[4,a.send(i)];case 1:return o=u.sent(),[2,o.as(Pn).unreadCount]}}))}))},u.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,a,i;return f(this,(function(o){switch(o.label){case 0:return t=s(s({},vn),e),l(function(e){return g("string",e.channelUrl,!0)&&m(Me,e.scheduledStatus,!0)&&r(C,e.messageTypeFilter)}(t)).throw(h.invalidParameters),n=P.of(this._iid).requestQueue,a=new kn(t),[4,n.send(a)];case 1:return i=o.sent(),[2,i.as(On).count]}}))}))},u.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=P.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},u.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=P.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e},u.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=P.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},u.prototype.createChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a;return f(this,(function(i){switch(i.label){case 0:return t=s(s({},on),e),l(un(t)).throw(h.invalidParameters),t.isPublic||(t.accessCode=void 0),n=new Vn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),a=r.as(Gn).channel,[4,this.upsertChannelsToCache([a])];case 2:return i.sent(),[2,a]}}))}))},u.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return e=Date.now(),l(e-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Bn({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(s=v(n),r=s.next();!r.done;r=s.next())(a=r.value)._updateUnreadMemberState(this._sdkState.userId,e),a._updateUnreadCount(0,0)}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},u.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=Date.now(),l(m("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Bn({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:d.sent(),s=this._groupChannelCache.channels,r=[];try{for(a=v(s),i=a.next();!i.done;i=a.next())o=i.value,e.includes(o.url)&&(o._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0),r.push(o))}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=a.return)&&c.call(a)}finally{if(u)throw u.error}}return r.length>0?[4,this.upsertChannelsToCache(r)]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2]}}))}))},u.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},u.prototype.getMessageFromCache=function(e){var t;return p(this,void 0,void 0,(function(){return f(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]}}))}))},u.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return p(this,void 0,void 0,(function(){return f(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,s.sent()]}}))}))},u.prototype.getMessagesFromCache=function(e,t,n,s,r,a){return void 0===r&&(r=Ye),void 0===a&&(a=!0),p(this,void 0,void 0,(function(){return f(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:s,backward:"next"===n,inclusive:a})];case 1:return[2,i.sent()]}}))}))},u.prototype.getPollMessagesFromCache=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,r.sent()]}}))}))},u.prototype.getCachedMessageCountBetween=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.countBetween(e,t,new ds({top:n,bottom:s}))];case 1:return[2,r.sent()]}}))}))},u.prototype.getUnsentMessagesFromCache=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},u.prototype.removeFailedMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},u}(Pt),fs=function(e,t){return t instanceof qe?e.findIndex((function(e){return e instanceof qe&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vs=function(e,t){return e.findIndex((function(e){return e instanceof Ge?e.messageId===t:e instanceof Ke?e.notificationId===t:void 0}))},ms=function(e,t){if(e.length>0){for(var n=0,s=e.length-1,r=Math.floor((n+s)/2);n0)s=r,r=Math.floor((n+s)/2);else{if(!(a<0))return r;n=r+1,r=Math.floor((n+s)/2)}}return e[r].createdAt>t.createdAt?r:r+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(ls||(ls={}));var gs,Es=function(t){function n(e,n,s,r){var a=t.call(this)||this;return a._state=ls.IDLE,a._retryCount=0,a._retryLimit=3,a.priority=0,a._worker=n,a}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===ls.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===ls.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===ls.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(s){switch(s.label){case 0:if(!this.isRunning)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=s.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=s.sent(),this.dispatch("error",n),this._retryCount0&&(r=s.map((function(e){return e.createdAt})),(null===(v=this._metadata)||void 0===v?void 0:(i=v.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.length0&&(r=s.map((function(e){return e.createdAt})),(null===(h=this._metadata)||void 0===h?void 0:(i=h.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit,this._metadata&&(t.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return f.sent(),[3,7];case 5:throw a=f.sent(),m.debug("message background next sync error",a),a;case 6:return g.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:n.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(v=null===(p=l.localCacheConfig)||void 0===p?void 0:p.maxSize)&&void 0!==v?v:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[2,t]}}))}))}))];case 1:return[2,s.sent()]}}))}))})),this._connectionEventContext=v.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n){return Cs[t]||(Cs[t]={}),Cs[t][n.url]||(Cs[t][n.url]=new e({_iid:t,channel:n})),Cs[t][n.url].ref++,Cs[t][n.url]},e.clear=function(e,t){Cs[e]&&Cs[e][t]&&(Cs[e][t].close(),delete Cs[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 ds({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{range:new ds(e.range),previousComplete:e.previousComplete}:{range:new ds({}),previousComplete:!1},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(e){var t,n,s,r;void 0===e&&(e=Date.now());var a=P.of(this._iid),i=a.logger,o=a.sessionManager;a.cacheContext.localCacheEnabled&&o.session.hasSession&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==n?n:e),this._nextSync.start(null!==(r=null===(s=this._metadata)||void 0===s?void 0:s.range.bottom)&&void 0!==r?r:e))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Cs[this._iid][this._channel.url])},e}(),Ms={},bs=function(){function e(e){var t=e._iid,n=e.channel,r=e.includeParams,a=this;this.ref=0,this._iid=t,this._channel=n,this._includeParams=r;var i,o,u=P.of(this._iid),c=u.logger,l=u.sdkState,d=u.dispatcher;this._metadataKey=(i=l.userId,o=n.url,"sendbird:".concat(i,"@groupchannel/").concat(o,"/message/changelogs.meta"));var _=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(l.userId,this._channel.url);this._sync=new Es(_,(function(){return p(a,void 0,void 0,(function(){var e,t,n,r,a,i,o,u;return f(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:l.sent(),c.debug("message changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),l.label=2;case 2:return l.trys.push([2,5,,8]),[4,Je.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,s({replyType:ne.ALL},this._includeParams),y.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=l.sent(),n=t.updatedMessages,r=t.deletedMessageIds,a=t.hasMore,i=t.token,e.hasNext=a,e.nextToken=i,(n.length>0||r.length>0)&&this._metadata&&(this._metadata.token=i),c.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return l.sent(),[3,8];case 5:return o=l.sent(),c.debug("message changelog sync error",o),o instanceof h&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:l.sent(),l.label=7;case 7:throw o;case 8:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n,s){return Ms[t]||(Ms[t]={}),Ms[t][n.url]||(Ms[t][n.url]=new e({_iid:t,channel:n,includeParams:s})),Ms[t][n.url].ref++,Ms[t][n.url]},e.clear=function(e,t){Ms[e]&&Ms[e][t]&&(Ms[e][t].close(),delete Ms[e])},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=P.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:s=r.sent(),this._metadata={token:s?s.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e=P.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Ms[this._iid][this._channel.url])},e}(),Ns={},Us=function(){function e(e){var t=e._iid,n=e.channel,s=e.hasPollMessage,r=this;this.ref=0,this._iid=t,this._channel=n;var a,i,o=P.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(a=c.userId,i=n.url,"sendbird:".concat(a,"@groupchannel/").concat(i,"/poll/changelogs.meta"));var d=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new Es(d,(function(){return p(r,void 0,void 0,(function(){var e,t,n,r,a,i,o,c;return f(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,s()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=P.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,se.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return r=l.sent(),a=r.hasMore,i=r.token,e.hasNext=a,e.nextToken=i,this._metadata.token=i,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 h&&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 Z)if(e.stateType===$.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n,s){return Ns[t]||(Ns[t]={}),Ns[t][n.url]||(Ns[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:s})),Ns[t][n.url].ref++,Ns[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.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 p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){P.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){P.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 Ns[this._iid][this._channel.url])},e}(),Ss=function(n){function s(e){var s,r,a,i,o,u,c,l,h,d,_=this;return(_=n.call(this)||this).method=N.GET,_.path="".concat(re(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),_.params=t({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!==(r=e.customTypes)&&void 0!==r?r:["*"],message_type:null!==(a=e.messageType)&&void 0!==a?a:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:ne.NONE,include_reactions:null===(o=e.includeReactions)||void 0===o||o,include_meta_array:null===(u=e.includeMetaArray)||void 0===u||u,include_thread_info:null===(c=e.includeThreadInfo)||void 0===c||c,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(d=e.showSubchannelMessagesOnly)&&void 0!==d&&d,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),_}return e(s,n),s}(S),Ts=function(t){function n(e,n){var s,r,a,i,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(s=n.prev_messages)&&void 0!==s?s:[]).map((function(t){return Xe(e,t)})),c.prevHasMore=null!==(r=n.prev_hasmore)&&void 0!==r&&r,c.isContinuousPrevMessages=null!==(a=n.is_continuous_prev_messages)&&void 0!==a&&a,c.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return Xe(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}(T),As={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(gs||(gs={}));var Is,ws,Ls,Ds=function(){function e(){this._onCacheResult=ue,this._onApiResult=ue}return e.prototype._invokeResponse=function(e,t,n){var s=this;H((function(){return p(s,void 0,void 0,(function(){return f(this,(function(s){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}(),xs=function(){function e(e,t){var n=t.filter,s=t.startingPoint,r=t.limit,a=t.prevResultLimit,i=t.nextResultLimit,o=t.channel,u=t.channelManager,c=t.disableBackgroundSync,l=void 0!==c&&c,h=this;this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key="mc-".concat(oe()),this._isDisposed=!1,this.filter=null!=n?n:new Le,this._channel=o,this._syncRange=new ds({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=r||Ye,this._prevResultLimit=null!=a?a:Math.floor(this._limit/2),this._nextResultLimit=null!=i?i:Math.floor(this._limit/2),this._channelManager=u;var m=P.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source,s=e.findIndex((function(e){return e.isIdentical(h.channel)}));s>=0&&(h._replaceChannelOfCollection(e[s]),h.channel._runIfHandleableWithGroupChannel((function(e){switch(n){case y.EVENT_CHANNEL_UPDATED:for(var s=!1,r=0;r=e.messageOffsetTimestamp){s=!0;var a=r;if(a>0){var i=h._messages.splice(0,a);h._removeMessagesFromView(i.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&h._messages.length>0&&h._removeMessagesFromView(h._messages.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED);break;case y.EVENT_CHANNEL_UNMUTED:var o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&h._clearCheckMyMutedTimer();break;case y.EVENT_CHANNEL_MUTED:o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&-1!==e._myMutedRemainingTime&&h._startCheckMyMutedTimer(e._myMutedRemainingTime);break;case y.EVENT_CHANNEL_LEFT:e.isPublic&&h._clearCheckMyMutedTimer()}H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(s){return gn(n)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel),[2]}))}))}))})),h._postprocessChannelUpdateEvent(e[s],n))},onRemove:function(e,t){var n=e.indexOf(h.channel.url);n>=0&&(h._clearCheckMyMutedTimer(),H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(n){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url),[2]}))}))})),h._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,s,r=[],a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value;u.channelUrl===h._channel.url&&(h.filter.match(u)?r.push(u):a.push(h.keyOf(u)))}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}if(ie(t)){if(r.length>0)switch(t){case y.LOCAL_MESSAGE_CANCELED:case y.LOCAL_MESSAGE_RESEND_STARTED:case y.EVENT_MESSAGE_SENT_FAILED:case y.EVENT_MESSAGE_SENT_SUCCESS:case y.EVENT_MESSAGE_UPDATED:case y.EVENT_MESSAGE_THREADINFO_UPDATED:case y.EVENT_MESSAGE_REACTION_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_ADDED:case y.EVENT_MESSAGE_FEEDBACK_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_DELETED:case y.SYNC_MESSAGE_CHANGELOGS:h._updateMessagesToView(r,t);break;case y.EVENT_MESSAGE_SENT_PENDING:h._addMessagesToView(r,t);break;case y.EVENT_MESSAGE_RECEIVED:h.hasNext||h._addMessagesToView(r,t);break;case y.SYNC_MESSAGE_FILL:h._addMessagesToView(r,t)}a.length>0&&h._removeMessagesFromView(a,t)}h._postprocessMessageUpdateEvent(e,t)},onRemove:function(e,t){h._removeMessagesFromView(e,t),h._postprocessMessageRemoveEvent(e)},onRemoveUnsent:function(e,t){h._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){h._updatePollsToView(e,t)},onPollUpdate:function(e,t){h._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){h._applyPollVoteEventToView(e,t)},onReactionUpdate:function(e,t){h._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){h._applyThreadInfoEventToView(e,t)}});var g=P.of(this._iid),E=g.cacheContext,C=g.dispatcher,M=g.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),C.dispatch(new En({channels:[this._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=ys.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=bs.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Us.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Es(this._key,(function(e){return p(h,void 0,void 0,(function(){var t=this;return f(this,(function(n){switch(n.label){case 0:return[4,M.run("message-fill-sync-".concat(o.url,"-prev"),(function(){return p(t,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:y.SYNC_MESSAGE_FILL,checkingContinuousMessages:E.localCacheEnabled})];case 1:return t=u.sent(),n=t.messages,s=t.isContinuousMessages,n.length>0?(r=Math.min.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:n.length>=this._prevResultLimit&&this.viewTop0?(r=Math.max.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:!(n.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>r,nextToken:this._syncRange.bottom}]):(E.localCacheEnabled&&m.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(o=null===(i=E.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==o?o:0,use_local_cache:E.localCacheEnabled,starting_point:0,message_init_policy:""}})),[2,{hasNext:!1,nextToken:0}])}}))}))}))];case 1:return[2,n.sent()]}}))}))})),this._connectionEventContext=C.on((function(e){if(e instanceof Z)switch(e.stateType){case $.CONNECTED:b((function(){return p(h,void 0,void 0,(function(){return f(this,(function(e){return this._activate(),[2]}))}))}));break;case $.LOGOUT:h.dispose();break;default:h._clearCheckMyMutedTimer(),h._prevFill.stop(),h._nextFill.stop()}}))}return e.prototype.keyOf=function(e){return 0},Object.defineProperty(e.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),e.prototype._postprocessChannelUpdateEvent=function(e,t){},e.prototype._postprocessChannelRemoveEvent=function(e){},e.prototype._postprocessMessageUpdateEvent=function(e,t){},e.prototype._postprocessMessageRemoveEvent=function(e){},Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],_(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype._activate=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return P.of(this._iid).logger.debug("check huge gap"),this._checkHugeGap(),[4,this._refreshChannel(y.SYNC_CHANNEL_CHANGELOGS)];case 1:return e.sent(),[2]}}))}))},e.prototype._replaceChannelOfCollection=function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)},e.prototype._shouldStartBackgroundSync=function(){var e=P.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled},e.prototype._setBaseMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n instanceof Ge&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,s,r=this,a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value,c=vs(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l.isUserMessage()&&l.applyPoll(u),a.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}return a.length>0&&ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},a.length>0&&(null===(s=(n=this._handler).onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,a)),[2]}))}))})),a},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollUpdateEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollVoteEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyReactionEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyReactionEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._applyThreadInfoEventToView=function(e,t){var n=this,s=vs(this._messages,e.targetMessageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyThreadInfoUpdateEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._removeMessagesFromView=function(e,t){var n,s,r=this,a=[],i=[],o=function(e){var t=u._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var n=u._messages[t];a.push(u.keyOf(n)),i.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=v(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(n)throw n.error}}return ie(t)&&i.length>0&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===s||s.call(n,e,this.channel,a,i),[2]}))}))})),a},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,s=void 0===n?0:n,r=t.nextLimit,a=void 0===r?0:r,i=t.inclusive,o=void 0===i||i;return p(this,void 0,void 0,(function(){var t,n,r,i,u;return f(this,(function(c){switch(c.label){case 0:return t=[],o?[4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter)]:[3,2];case 1:t=c.sent(),c.label=2;case 2:return s>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,s,!1)]:[3,4];case 3:return r=c.sent(),[3,5];case 4:r=[],c.label=5;case 5:return n=r,a>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,a,!1)]:[3,7];case 6:return u=c.sent(),[3,8];case 7:u=[],c.label=8;case 8:return i=u,[2,{messages:d(d(d([],_(t),!1),_(n),!1),_(i),!1).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:n.length,nextMessagesCount:i.length}]}}))}))},e.prototype._getRemoteMessages=function(e,t){var r=t.prevLimit,a=void 0===r?0:r,i=t.nextLimit,o=void 0===i?0:i,u=t.source,c=void 0===u?y.REQUEST_MESSAGE:u,l=t.reverse,h=void 0!==l&&l,d=t.checkingHasNext,_=void 0!==d&&d,v=t.checkingContinuousMessages,m=void 0!==v&&v;return p(this,void 0,void 0,(function(){var t,r;return f(this,(function(i){switch(i.label){case 0:return t=Je.of(this._iid),a>0||o>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,n(s(s(s({},this.filter),As),{isInclusive:!0,reverse:h,prevResultSize:a,nextResultSize:o})),c,_,m)]:[3,2];case 1:return r=i.sent(),[3,3];case 2:r={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,r]}}))}))},e.prototype._checkHugeGap=function(){var e,t,n,r,a;return p(this,void 0,void 0,(function(){var i,o,u,c,l,v,m,g,E,C,M,b,N,U,S,T,A,I,w,L,D,x,R,F,k,O=this;return f(this,(function(V){switch(V.label){case 0:return i=P.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=i.cacheContext,l=i.statManager,v=i.logger,this._messages.length>0?(m=this._syncRange.top,g=this.viewTop,E=this._syncRange.bottom,C=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,g,m)]):[3,8];case 1:return M=V.sent(),[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,E,C)];case 2:b=V.sent(),V.label=3;case 3:return V.trys.push([3,5,6,7]),[4,ce((function(){return p(O,void 0,void 0,(function(){var e,t,n,r,a,i,l,h,v,N,U,S,T,A,I,w,L,D=this;return f(this,(function(x){switch(x.label){case 0:return e=new Ss(s(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:g,prevEnd:m,prevCount:M,nextStart:E,nextEnd:C,nextCount:b,checkingContinuousMessages:c.localCacheEnabled},this.filter),As)),[4,u.send(e)];case 1:return t=x.sent(),n=t.as(Ts),r=n.isHugeGap,a=n.prevMessages,i=void 0===a?[]:a,l=n.prevHasMore,h=n.isContinuousPrevMessages,v=n.nextMessages,N=void 0===v?[]:v,U=n.nextHasmore,S=n.isContinuousNextMessages,r?H((function(){return p(D,void 0,void 0,(function(){var e;return f(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected(),[2]}))}))})):(T=this.viewTop,A=this.viewBottom,I=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,T],_(i.map((function(e){return e.createdAt}))),!1)),w=Math.max.apply(Math,d([0,A],_(N.map((function(e){return e.createdAt}))),!1)),o.dispatch(new j({messages:i,source:y.SYNC_MESSAGE_FILL})),o.dispatch(new j({messages:N,source:y.SYNC_MESSAGE_FILL})),this._syncRange.extends(I,w),(h||S)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(I,w)),l&&this._prevFill.start(I),U&&this._nextFill.start(w)),[2]}}))}))}),1)];case 4:return V.sent(),[3,7];case 5:return N=V.sent(),v.debug("Failed HugeGap Check ",N),[3,7];case 6:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=c.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[3,13];case 8:U=Date.now(),V.label=9;case 9:return V.trys.push([9,11,12,13]),[4,this._getRemoteMessages(U,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:y.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:c.localCacheEnabled})];case 10:if(S=V.sent(),T=S.messages,A=S.isContinuousMessages,I=S.hasNext,T.length>0){for(w=T.map((function(e){return e.createdAt})),L=0,D=0,x=0;x=U&&D++;this._hasPrevious=L>=this._prevResultLimit,this._hasNext=null!=I?I:D>=this._nextResultLimit,(k=this._syncRange).extends.apply(k,d([],_(w),!1)),A&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(T,y.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,13];case 11:return(F=V.sent())instanceof h&&F.code===K.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,13];case 12:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(a=null===(r=c.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 13:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return e=this,[4,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return e._unsentMessages=t.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s;return f(this,(function(r){switch(r.label){case 0:n=P.of(this._iid).logger,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._channelManager.refreshChannel(this.channel.url,!0,e,t)];case 2:return r.sent(),[3,4];case 3:return s=r.sent(),n.warn("Failed to refresh channel",s),[3,4];case 4:return[2]}}))}))},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return p(t,void 0,void 0,(function(){var e,t,n,s=this;return f(this,(function(r){switch(r.label){case 0:this._checkMyMutedStateTimer=void 0,e=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=r.sent(),e=!t.isMuted,[3,5];case 3:return r.sent(),e=!0,[3,5];case 4:return e&&(n=P.of(this._iid).sessionManager,this.channel._runIfHandleableWithGroupChannel((function(e){var t,r;e.myMutedState=G.UNMUTED;var a={source:y.EVENT_CHANNEL_UNMUTED,user:n.currentUser};null===(r=null===(t=s._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===r||r.call(t,a,s.channel)}))),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)},e.prototype._setHasNextAndHaePrevious=function(e,t){for(var n=e.map((function(e){return e.createdAt})),s=0,r=0,a=0;athis._startingPoint&&r++}this._hasPrevious=s>=this._prevResultLimit,this._hasNext=null!=t?t:r>=this._nextResultLimit},e.prototype.initialize=function(e){var t=this,n=new Ds;this._messages=[],this._unsentMessages=[],this._syncRange=new ds({}),this._hasNext=!0,this._hasPrevious=!0;var s=[],r={messages:[],prevMessagesCount:0,nextMessagesCount:0};return H((function(){return p(t,void 0,void 0,(function(){var t,a,i,o,u,c=this;return f(this,(function(l){switch(l.label){case 0:return[4,null===(u=this._backgroundSync)||void 0===u?void 0:u.loadMetadata()];case 1:if(t=l.sent(),a=P.of(this._iid),i=a.cacheContext,o=a.statManager,e===gs.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(e){return p(c,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return r=e,s=this._filterUnderOffsetMessage(r.messages),this._addMessagesToView(s,y.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return t.sent(),n._invokeResponse("local",null,s),[2]}}))}))})).catch((function(e){if(O(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){return p(c,void 0,void 0,(function(){var a,i,u,c,l,h,p,v=this;return f(this,(function(f){switch(f.label){case 0:return a=P.of(this._iid).cacheContext,i=!0,u=!0,c=!1,a.localCacheEnabled&&s.length>0&&(l=t.range).includes.apply(l,d([],_(s.map((function(e){return e.createdAt}))),!1))&&(!t.previousComplete&&r.prevMessagesCountt.range.bottom||r.nextMessagesCount=e._latestMessageInfo.createdAt&&(u=!1)})),u?(i=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:a.localCacheEnabled}).then((function(e){var t,s,r,a=e.messages,i=e.isContinuousMessages,o=e.hasNext,u=v._filterUnderOffsetMessage(a);v._messages=[],u.length>0?(v._setHasNextAndHaePrevious(u,o),(t=v._syncRange).extends.apply(t,d([],_(u.map((function(e){return e.createdAt}))),!1)),i&&(null===(s=v._backgroundSync)||void 0===s?void 0:s.range.overlap(v._syncRange))&&(null===(r=v._backgroundSync)||void 0===r||r.range.extends(v._syncRange.top,v._syncRange.bottom)),v._addMessagesToView(u,y.REQUEST_MESSAGE)):(v._hasPrevious=!1,v._hasNext=!1),n._invokeResponse("remote",null,u)})).catch((function(e){if(O(e))throw e;n._invokeResponse("remote",e,null)}))):(this._setHasNextAndHaePrevious(s),n._invokeResponse("remote",null,s)),a.localCacheEnabled&&o.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:i?"cache_hit":"cache_miss",max_db_size:null!==(p=null===(h=a.localCacheConfig)||void 0===h?void 0:h.maxSize)&&void 0!==p?p:0,message_init_policy:e,use_local_cache:a.localCacheEnabled,collection_id:this._key}})),[2]}}))}))}));return o.put(new le({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}})),[2]}}))}))})),n},e.prototype.loadPrevious=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasPrevious?this._isLoadingPrevious?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingPrevious=!0,o=this.viewTop,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{prevLimit:this._prevResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._prevResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h=this;return f(this,(function(p){switch(p.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=p.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top))),u=u.filter((function(e){return fs(h._messages,e)<0})),this._hasPrevious=u.length>=this._prevResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(c=null===(i=e.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==c?c:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=u.length>=this._prevResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingPrevious=!1,[2,u]}}))}))},e.prototype.loadNext=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasNext?this._isLoadingNext?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingNext=!0,o=this.viewBottom,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{nextLimit:this._nextResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._nextResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h,p=this;return f(this,(function(f){switch(f.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=f.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom))),u=u.filter((function(e){return fs(p._messages,e)<0})),this._hasNext=null!==(i=t.hasNext)&&void 0!==i?i:u.length>=this._nextResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(h=null===(c=e.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==h?h:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=u.length>=this._nextResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingNext=!1,[2,u]}}))}))},e.prototype.removeFailedMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return[4,this._channelManager.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,s=this;if(!this._isDisposed){this._isDisposed=!0;var r=P.of(this._iid),a=r.cacheContext,i=r.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(e){e.myMemberState!==Wt.NONE&&(s._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new En({channels:[s._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})))})),a.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}},e}(),Rs=function(t){function n(e,n){return t.call(this,e,s(s({},n),{channelManager:ps.of(e)}))||this}return e(n,t),n.prototype.keyOf=function(e){return e.messageId},n.prototype.initialize=function(e){var n=this;return b((function(){return p(n,void 0,void 0,(function(){var e;return f(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]}}))}))})),t.prototype.initialize.call(this,e)},n.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},n.prototype._activate=function(){return p(this,void 0,void 0,(function(){var e=this;return f(this,(function(n){switch(n.label){case 0:return[4,t.prototype._activate.call(this)];case 1:return n.sent(),[4,b((function(){return p(e,void 0,void 0,(function(){var e;return f(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]}}))}))}))];case 2:return n.sent(),[2]}}))}))},n.prototype._addMessagesToView=function(e,t){var n,s,r=this,a=this._filterUnderOffsetMessage(e),i=[],o=[];try{for(var u=v(a),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===y.SYNC_MESSAGE_FILL){if(l.messageId>0){if((E=fs(this._messages,l))<0){fs(this._unsentMessages,l)<0&&i.push(l);var h=ms(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof qe){(E=fs(this._unsentMessages,l))<0&&fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l))}}else if(l.messageId>0){if((E=fs(this._messages,l))<0){var m=fs(this._unsentMessages,l);m<0?i.push(l):(this._unsentMessages.splice(m,1),o.push(l));h=ms(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[E]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,d([],_(g),!1))}}else if(l instanceof qe){var E;(E=fs(this._unsentMessages,l))<0?fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l)):(o.push(l),this._unsentMessages[E]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,a;return f(this,(function(u){return e={source:t},i.length>0&&(null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===s||s.call(n,e,this.channel,i)),o.length>0&&(null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,e,this.channel,o)),[2]}))}))}))},n.prototype._updateMessagesToView=function(e,t){var n,s,r=this,a=[],i=[],o=[];try{for(var u=v(e),c=u.next();!c.done;c=u.next()){var l,h=c.value;if(h.messageId>0)if((l=fs(this._messages,h))>=0)i.push(h),this._messages[l]=h;else{var m=fs(this._unsentMessages,h);if(m>=0){var g=_(this._unsentMessages.splice(m,1),1)[0];if(this.hasNext&&g)o.push(g);else{i.push(h);var E=ms(this._messages,h);this._messages.splice(E,0,h)}}else{var C=this._messages.map((function(e){return e.createdAt}));(h.createdAtMath.max.apply(Math,d([],_(C),!1))&&!this._hasNext)&&a.push(h)}}else if(h instanceof qe)(l=fs(this._unsentMessages,h))>=0&&(i.push(h),this._unsentMessages[l]=h)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}return ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,u;return f(this,(function(c){return e={source:t},i.length>0?null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,i):o.length>0?null===(u=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===u||u.call(r,e,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t),[2]}))}))})),i},n}(xs),Fs={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},Ps=function(t){function n(e){var n=this,s=e.channelUrl,r=e.token,a=e.limit,i=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=N.GET,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/members"),n.params={token:r,limit:a,order:i,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}(S),ks=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.members=[];var r=n.next,a=n.members;return s.token=r,a&&a.length>0&&(s.members=a.map((function(t){return new tn(e,t)}))),s}return e(n,t),n}(T);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Is||(Is={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(ws||(ws={})),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"}(Ls||(Ls={}));var Os=function(t){function a(e,n,s){var r,a,o,u,c=this;return(c=t.call(this,e,n,i.GROUP,s)||this).mutedMemberFilter=Is.ALL,c.memberStateFilter=Ls.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Zt.ALL,c.order=ws.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(r=s.mutedMemberFilter)&&void 0!==r?r:Is.ALL,c.memberStateFilter=null!==(a=s.memberStateFilter)&&void 0!==a?a:Ls.ALL,c.nicknameStartsWithFilter=null!==(o=s.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=s.order)&&void 0!==u?u:ws.MEMBER_NICKNAME_ALPHABETICAL,c}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&r(Is,this.mutedMemberFilter)&&r(Ls,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&r(Zt,this.operatorFilter)&&r(ws,this.order)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=P.of(this._iid).requestQueue,t=new Ps(n(s(s({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=u.sent(),a=r.as(ks),i=a.members,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(he),Hs=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/accept"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),Vs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.JOINED,s}return e(n,t),n}(T),Gs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.isDistinct,i=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,_=e.customType,p=e.operatorUserIds,f=e.messageSurvivalSeconds;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r)),s.params=t({is_distinct:a,is_public:i,is_discoverable:o,name:h,data:d,custom_type:_,cover_url:u,cover_file:c,access_code:l,operator_ids:p,message_survival_seconds:f}),s}return e(s,n),s}(S),Bs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),qs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s)),n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var zs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var js=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.countPreference,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:r},a}return e(n,t),n}(S),Ws=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.countPreference=n.count_preference,s}return e(n,t),n}(T),Qs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.locale;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r),"/reset_user_history"),s.params=t({locale:a}),s}return e(s,n),s}(S),Ys=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),Ks=s(s({},Ze),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Js=s(s({},et),{scheduledAt:void 0}),Xs=function(s){function r(e){var r,a,i=this;i=s.call(this)||this;var o=[];e.mentionType===de.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((function(e){return e.userId}))));var u=e.channelType,c=e.channelUrl,l=e.scheduledMessageId;return i.method=N.PUT,i.path="".concat(re(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((function(e){return nt.payloadify(e)})),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(a=e.metaArrays)||void 0===a?void 0:a.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})),i}return e(r,s),r}(S),Zs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Ae(e,n),s}return e(n,t),n}(T),$s=function(s){function r(e){var r,a=this;a=s.call(this)||this;var i=[];e.mentionType===de.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return a.method=N.PUT,a.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),a.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(r=e.metaArrays)||void 0===r?void 0:r.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),a}return e(r,s),r}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Te(e,n),s}e(n,t)}(T);var er,tr,nr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.DELETE,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a)),n}return e(n,t),n}(S),sr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.POST,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a),"/send_now"),n}return e(n,t),n}(S),rr=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.pushTriggerOption,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:r},a}return e(n,t),n}(S),ar=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T),ir=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=t.call(this)||this;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),r}return e(n,t),n}(S),or=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T);!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"}(er||(er={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(tr||(tr={}));var ur=function(u){function c(e,t){var n,c,l,h,p,f,v,m,E,C,y,M,b,N,U,S,T,A,I,w,L=this;return(L=u.call(this,e,t)||this)._unreadMemberStateMap=new Map,L._undeliveredMemberStateMap=new Map,L._typingStatus=new Map,L._lastMemberCountUpdated=0,L._typingStarted=0,L._typingEnded=0,L._hasBotInfo={general:!1,ai:!1},L.isDistinct=!1,L.isSuper=!1,L.isBroadcast=!1,L.isExclusive=!1,L.isPublic=!1,L.isDiscoverable=!0,L.isChatNotification=!1,L.isAccessCodeRequired=!1,L.isPushEnabled=!1,L.unreadMessageCount=0,L.unreadMentionCount=0,L.totalUnreadReplyCount=0,L.members=[],L.memberCount=0,L.joinedMemberCount=0,L.hiddenState=tr.UNHIDDEN,L.lastMessage=null,L.messageOffsetTimestamp=0,L.messageSurvivalSeconds=-1,L.myMemberState=Wt.NONE,L.myRole=a.NONE,L.myMutedState=G.UNMUTED,L.myLastRead=0,L.myCountPreference=er.ALL,L.myPushTriggerOption=me.DEFAULT,L.inviter=null,L.invitedAt=0,L.joinedAt=0,L.lastPinnedMessage=null,L._latestMessageInfo=null,L._pinnedMessagesUpdatedAt=0,L._myMutedRemainingTime=-1,L.channelType=i.GROUP,L.isDistinct=null!==(c=t.is_distinct)&&void 0!==c&&c,L.isSuper=null!==(l=t.is_super)&&void 0!==l&&l,L.isBroadcast=null!==(h=t.is_broadcast)&&void 0!==h&&h,L.isExclusive=null!==(p=t.is_exclusive)&&void 0!==p&&p,L.isPublic=null!==(f=t.is_public)&&void 0!==f&&f,L.isDiscoverable=null!==(v=t.is_discoverable)&&void 0!==v?v:L.isPublic,L.isChatNotification=null!==(m=t.is_chat_notification)&&void 0!==m&&m,L.isAccessCodeRequired=null!==(E=t.is_access_code_required)&&void 0!==E&&E,L.isPushEnabled=null!==(C=t.is_push_enabled)&&void 0!==C&&C,Array.isArray(t.members)&&(n=L.members).push.apply(n,d([],_(t.members.map((function(e){return new tn(L._iid,e)}))),!1)),L.memberCount=null!==(y=t.member_count)&&void 0!==y?y:0,L.joinedMemberCount=null!==(M=t.joined_member_count)&&void 0!==M?M:0,L.hiddenState=r(tr,t.hidden_state)?t.hidden_state:tr.UNHIDDEN,L.messageOffsetTimestamp=null!==(b=t.ts_message_offset)&&void 0!==b?b:0,L.messageSurvivalSeconds=null!==(N=t.message_survival_seconds)&&void 0!==N?N:-1,L.lastMessage=t.last_message?Xe(L._iid,s({channel_type:L.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((function(e){g("number",t.read_receipt[e])&&L._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((function(e){g("number",t.delivery_receipt[e])&&L._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),L.myMemberState=r(Wt,t.member_state)?t.member_state:Wt.NONE,L.myRole=r(a,t.my_role)?t.my_role:a.NONE,r(G,t.is_muted)?L.myMutedState=t.is_muted:g("boolean",t.is_muted)?L.myMutedState=t.is_muted?G.MUTED:G.UNMUTED:L.myMutedState=G.UNMUTED,L.myCountPreference=r(er,t.count_preference)?t.count_preference:er.ALL,L.myPushTriggerOption=r(me,t.push_trigger_option)?t.push_trigger_option:me.ALL,L.myLastRead=null!==(U=t.user_last_read)&&void 0!==U?U:0,L.inviter=t.inviter?new o(L._iid,t.inviter):null,L.invitedAt=null!==(S=t.invited_at)&&void 0!==S?S:0,L.joinedAt=null!==(T=t.joined_ts)&&void 0!==T?T:0,L._updateUnreadCount(null!==(A=t.unread_message_count)&&void 0!==A?A:0,null!==(I=t.unread_mention_count)&&void 0!==I?I:0),L.totalUnreadReplyCount=null!==(w=t.total_unread_thread_message_count)&&void 0!==w?w:0,L.lastPinnedMessage=t.latest_pinned_message?Xe(L._iid,s({channel_type:L.channelType},t.latest_pinned_message)):null,t.latest_message&&(L._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),L._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot},L}return e(c,u),Object.defineProperty(c.prototype,"isHidden",{get:function(){return this.hiddenState!==tr.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._unreadMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._undeliveredMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasBot",{get:function(){return this._hasBotInfo.general},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasAiBot",{get:function(){return this._hasBotInfo.ai},enumerable:!1,configurable:!0}),c.payloadify=function(e){return t(n(s(s({},u.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,total_unread_thread_message_count:e.totalUnreadReplyCount,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 tn.payloadify(e)})),last_message:e.lastMessage?at(e.lastMessage):null,inviter:e.inviter?o.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?at(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))},c.prototype._shouldUpdateLastMessageWith=function(e){if(e.silent)return!1;var t=P.of(this._iid).appInfo;switch(null==t?void 0:t.lastMessageThreadingPolicy){case pe.NONE:case pe.INCLUDE_REPLY:break;case pe.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case pe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case fe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},c.prototype._updateLastMessage=function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)},c.prototype._updateUnreadCount=function(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===er.ALL||this.myCountPreference===er.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=P.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===er.ALL||this.myCountPreference===er.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},c.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)},c.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},c.prototype._setLatestMemberCount=function(e,t,n){var s=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,s=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),s},c.prototype.isReadMessage=function(e){var t=P.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt},c.prototype.serialize=function(){var e=this;return R(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))},c.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Rs(this._iid,s(s({},e),{channel:this}))},c.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Os(this._iid,this.url,e)},c.prototype.createThreadedParentMessageListQuery=function(e){return void 0===e&&(e={}),new it(this._iid,this.url,this.channelType,e)},c.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 s=this.members[n];s.state===Wt.JOINED&&(e.state=s.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},c.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof tn?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},c.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof qe&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var s=P.of(this._iid).sdkState,r=e.createdAt,a=0;try{for(var i=v(this.members),o=i.next();!o.done;o=i.next()){var u=o.value;if(s.userId!==u.userId&&u.state===Wt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&a.push(i)}})),a},c.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var s=P.of(this._iid).sdkState;if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var r=e instanceof qe?e.sender:null,a=[];return this.members.forEach((function(i){if(t||i.userId!==s.userId&&i.userId!==(null==r?void 0:r.userId)){var o=n._unreadMemberStateMap.get(i.userId);o&&o=t&&(e._typingStatus.delete(a),s=!0)})),s},c.prototype.refresh=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){return[2,this._refresh()]}))}))},c.prototype._refresh=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return t=P.of(this._iid),n=t.requestQueue,s=t.dispatcher,r=new Nn({channelUrl:this.url}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Un).channel,this._update(i),e||s.dispatch(new En({channels:[i],context:{source:y.REFRESH_CHANNEL}})),[2,this]}}))}))},c.prototype.freeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.freeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.unfreeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.unfreeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.updateChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return t=s(s({},Fs),e),l(function(e){return g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new Gs(s({channelUrl:this.url},t)),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Bs).channel,this._update(u),r.dispatch(new En({channels:[u],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.invite=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return l(e.every((function(e){return e instanceof o}))).throw(h.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},c.prototype.inviteWithUserIds=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(m("string",e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.requestQueue,r=t.sessionManager,a=new Yn({channelUrl:this.url,userIds:e}),[4,s.send(a)];case 1:return i=u.sent(),o=i.as(Kn).channel,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_INVITED,inviter:r.currentUser,invitees:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.join=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new qn({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(zn).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.leave=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return t=P.of(this._iid),n=t.sdkState,s=t.requestQueue,r=new Wn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,s.send(r)];case 1:return a.sent(),this.myMemberState=Wt.NONE,[2]}}))}))},c.prototype.acceptInvitation=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new Hs({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(Vs).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.declineInvitation=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new Xn({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),this.myMemberState=Wt.NONE,[2,this]}}))}))},c.prototype.sendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),ps.of(t._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.updateUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateUserMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendMultipleFilesMessage=function(e){var t=this,n=new ut,s=P.of(this._iid).dispatcher;return u.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){n._trigger(e)})).onFailed((function(e,t){n._triggerFailed(e,t)})).onSucceeded((function(e){var r=ps.of(t._iid);t._updateLastMessage(e),r.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})).onFileUploaded((function(e,t,s,r){n._triggerOnFileUploaded(e,t,s,r)})),n},c.prototype.updateFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateFileMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.deleteMessage=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,u.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&e instanceof qe&&P.of(this._iid).dispatcher.dispatch(new ge({reqId:e.reqId,source:y.EVENT_MESSAGE_DELETED})),[2]}}))}))},c.prototype.hide=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=s(s({},$n),e),l(function(e){return g("boolean",e.hidePreviousMessages,!0)&&g("boolean",e.allowAutoUnhide,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.sdkState,i=n.requestQueue,o=new es(s({channelUrl:this.url,userId:a.userId},t)),[4,i.send(o)];case 1:return u=d.sent(),c=u.as(ts).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.unhide=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=new zs({channelUrl:this.url}),[4,n.send(s)];case 1:return r.sent(),this.hiddenState=tr.UNHIDDEN,t.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.delete=function(){return p(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=P.of(this._iid).requestQueue,t=new qs({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o=this;return f(this,(function(u){switch(u.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.dispatcher,s=e.requestQueue,r=new yt({channelUrl:this.url}),[4,s.send(r)];case 1:return a=u.sent(),i=a.as(Be).readStatus,this._updateUnreadMemberState(t.userId,i.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_READ}})),[2]}}))}))},c.prototype.markAsDelivered=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new cs({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),[2]}}))}))},c.prototype.startTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=n?(this._typingStarted=s,this._typingEnded=0,r=new ss({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.endTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=n?(this._typingStarted=0,this._typingEnded=s,r=new as({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.createScheduledUserMessage=function(e){e=s(s({},ct),e),l(lt(e)).throw(h.invalidParameters);var t=new Ct;return this._createScheduledUserMessage(e,t),t},c.prototype.updateScheduledUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a,i;return f(this,(function(o){switch(o.label){case 0:return n=s(s({},Js),t),l(function(e){return tt(e)&&g("number",e.scheduledAt,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid).requestQueue,a=new $s(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(a)];case 1:return i=o.sent(),[2,i.as(Mt).message]}}))}))},c.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},ht),e),l(dt(e)).throw(h.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new Ct;return ve(bt).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);H((function(){return p(t,void 0,void 0,(function(){return f(this,(function(e){return[2,a._trigger(s)]}))}))}))})),E(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a},c.prototype.updateScheduledFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a;return f(this,(function(i){switch(i.label){case 0:return n=s(s({},Ks),t),l(function(e){return $e(e)&&g("number",e.scheduledAt,!0)&&(E(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(h.invalidParameters),E(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return r=new Xs(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,P.of(this._iid).requestQueue.send(r)];case 3:return a=i.sent(),[2,a.as(Zs).message]}}))}))},c.prototype.cancelScheduledMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new nr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.sendScheduledMessageNow=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new sr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.getMyPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a;return f(this,(function(i){switch(i.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new ir({userId:t.userId,channelUrl:this.url}),[4,n.send(s)];case 1:return r=i.sent(),a=r.as(or).pushTriggerOption,this.myPushTriggerOption=a,[2,a]}}))}))},c.prototype.setMyPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(me,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new rr({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(ar).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.setMyCountPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(er,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new js({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Ws).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.resetMyHistory=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=e.sdkState,r=new Qs({channelUrl:this.url,locale:s.localeForChatbot}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Ys).messageOffsetTimestamp,this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt0&&!r.some((function(t){switch(t){case en.CHANNEL_NAME:return e.name.toLowerCase().includes(s.toLowerCase());case en.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(s.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var a=this._userIdsFilter,i=a.userIds,o=a.includeMode,u=a.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(i.length>0)switch(u){case $t.AND:if(i.some((function(e){return!l.includes(e)})))return!1;break;case $t.OR:if(i.every((function(e){return!l.includes(e)})))return!1}}else{if(i.includes(t)||i.push(t),e.members.length>i.length)return!1;if(!c(i,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var _=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=_})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Yt.ALL:if("none"===e.myMemberState)return!1;break;case Yt.JOINED:if("joined"!==e.myMemberState)return!1;break;case Yt.INVITED:if("invited"!==e.myMemberState)return!1;break;case Yt.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Yt.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Xt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Xt.HIDDEN:if(!e.isHidden)return!1;break;case Xt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Xt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Jt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Qt.PUBLIC:if(!e.isPublic)return!1;break;case Qt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Kt.SUPER:if(!e.isSuper)return!1;break;case Kt.NON_SUPER:if(e.isSuper)return!1}return!(this.createdAfter&&e.createdAtthis.createdBefore)},e}(),an=function(t){function n(e,n){var s=n.sdkState,r=n.cacheContext,a=t.call(this,e)||this;return a._channels=new Map,a._sdkState=s,a._cacheContext=r,a}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return l(!!e).throw(h.databaseError),e.collection(Ce)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return ps.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],_(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case St.CHRONOLOGICAL:if(!a&&n.createdAt>t||a&&n.createdAtt||a&&n.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)s._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});s._update(e),n.push(s)}else a._channels.set(e.url,e),n.push(e)})),!this.localCacheEnabled)return[3,2];for(s=[],r=0;r0?[4,this.upsert(s)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},n.prototype.unblock=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],_(this._channels.keys()),!1)),p(this,void 0,void 0,(function(){var n,s,r,a,i,o,u,c;return f(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),s=v(t),r=s.next(),l.label=2;case 2:return r.done?[3,5]:(a=r.value,[4,this.get(a)]);case 3:(null==(i=l.sent())?void 0:i._updateUnreadMemberState(this._sdkState.userId,e))&&(i._updateUnreadCount(0,0),n.push(i)),l.label=4;case 4:return r=s.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{r&&!r.done&&(c=s.return)&&c.call(s)}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}(u),on={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},un=function(e){return m("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},cn={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},ln=function(e){return m("string",e.customTypes,!0)&&g("boolean",e.includeEmpty,!0)&&g("boolean",e.includeFrozen,!0)&&g("boolean",e.includeMetaData,!0)&&g("boolean",e.includeChatNotification,!0)},hn={myMemberStateFilter:Yt.ALL},dn=function(e){return r(Yt,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"}(sn||(sn={}));var _n={keys:[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT,sn.NONSUPER_UNREAD_MENTION_COUNT,sn.SUPER_UNREAD_MENTION_COUNT,sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,sn.NONSUPER_UNREAD_MESSAGE_COUNT,sn.SUPER_UNREAD_MESSAGE_COUNT,sn.GROUP_CHANNEL_INVITATION_COUNT,sn.NONSUPER_INVITATION_COUNT,sn.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},pn={channelCustomTypesFilter:void 0,superChannelFilter:Kt.ALL},fn=function(e){return m("string",e.channelCustomTypesFilter,!0)&&r(Kt,e.superChannelFilter)},vn={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:C.ALL},mn=s({},y),gn=function(e){return e.startsWith("EVENT_")||e===y.SYNC_CHANNEL_CHANGELOGS||e===y.REFRESH_CHANNEL},En=function(t){function n(e){var n=e.channels,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=e.ts,o=t.call(this)||this;return o.channels=n,o.context=s,o.isWebSocketEventComing=a,o.ts=i,o}return e(n,t),n}(M),Cn=function(t){function n(e){var n=e.channelUrls,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=t.call(this)||this;return i.channelUrls=n,i.context=s,i.isWebSocketEventComing=a,i}return e(n,t),n}(M),yn=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,s=e.unsentMessageCache,r=e.dispatcher,a=this;this._observers=new Map,r.on((function(e){return p(a,void 0,void 0,(function(){var r,a,i,o,u,c,l,h,d,_,m,g,E,C,M,N,U,S,T=this;return f(this,(function(A){switch(A.label){case 0:if(!(e instanceof En))return[3,19];if(r=e.channels,E=e.context,C=e.isWebSocketEventComing,a=r.filter((function(e){return e instanceof ur})),E.source!==y.EVENT_CHANNEL_RESET_HISTORY&&E.source!==y.EVENT_CHANNEL_HIDDEN)return[3,9];A.label=1;case 1:A.trys.push([1,6,7,8]),i=v(a),o=i.next(),A.label=2;case 2:return o.done?[3,5]:(d=o.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 3:A.sent(),A.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return u=A.sent(),M={error:u},[3,8];case 7:try{o&&!o.done&&(N=i.return)&&N.call(i)}finally{if(M)throw M.error}return[7];case 8:return[3,17];case 9:c=t.filterOffsetChanged(a),A.label=10;case 10:A.trys.push([10,15,16,17]),l=v(c),h=l.next(),A.label=11;case 11:return h.done?[3,14]:(d=h.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 12:A.sent(),A.label=13;case 13:return h=l.next(),[3,11];case 14:return[3,17];case 15:return _=A.sent(),U={error:_},[3,17];case 16:try{h&&!h.done&&(S=l.return)&&S.call(l)}finally{if(U)throw U.error}return[7];case 17:return[4,t.upsert(a,e.ts)];case 18:return m=A.sent(),C||this._broadcastUpdateEvent(m,E),[3,24];case 19:return e instanceof Cn?(g=e.channelUrls,E=e.context,C=e.isWebSocketEventComing,[4,t.remove(g)]):[3,22];case 20:return A.sent(),[4,b((function(){return p(T,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=v(g),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(r=t.value,[4,n.removeMessagesOfChannel(r)]);case 2:return u.sent(),[4,s.removeMessagesOfChannel(r)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return a=u.sent(),i={error:a},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(i)throw i.error}return[7];case 8:return[2]}}))}))}))];case 21:return A.sent(),C||this._broadcastRemoveEvent(g,E),[3,24];case 22:return e instanceof At?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,24];case 23:A.sent(),A.label=24;case 24:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onUpdate&&i.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onRemove&&i.onRemove(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}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}(),Mn=function(r){function a(e){var a=e.userId,i=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c,h=r.call(this)||this,d=s(s({},cn),u),_=d.customTypes,p=d.includeEmpty,f=d.includeFrozen;return h.method=N.GET,h.path="".concat(U,"/").concat(encodeURIComponent(a),"/my_group_channels/changelogs"),h.params=t(n({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:_,show_empty:p,show_frozen:f,include_chat_notification:l})),h}return e(a,r),a}(S),bn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedChannels=n.updated.map((function(t){return new ur(e,Object.assign(t,{ts:n.ts}))})),s.deletedChannelUrls=n.deleted,s.hasMore=n.has_more,s.token=n.next,s.ts=n.ts,s}return e(n,t),n}(T),Nn=function(t){function n(e){var n=e.channelUrl,s=e.isInternalCall,r=e.showLatestMessage,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(s?A:I,"/").concat(encodeURIComponent(n)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=r&&r},a}return e(n,t),n}(S),Un=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Sn={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:Yt.ALL,unreadChannelFilter:Jt.ALL,superChannelFilter:Kt.ALL,publicChannelFilter:Qt.ALL,hiddenChannelFilter:Xt.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:$t.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:St.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0},Tn=function(n){function s(e){var s=this,r=e.userId,a=e.token,i=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,_=e.nicknameContainsFilter,p=e.nicknameStartsWithFilter,f=e.nicknameExactMatchFilter,v=e.channelNameContainsFilter,m=e.channelUrlsFilter,g=e.customTypesFilter,E=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,y=e.metadataOrderKeyFilter,M=e.metadataKey,b=e.metadataValues,S=e.metadataValueStartsWith,T=e.includeFrozen,A=e.includeMetaData,I=e.searchFilter,w=e.userIdsFilter,L=e.includeChatNotification,D=void 0!==L&&L,x=e.includeLeftChannel,R=void 0!==x&&x,F=e.createdAfter,P=e.createdBefore;return(s=n.call(this)||this).method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(r),"/my_group_channels"),s.params=t({token:a,limit:i,order:null!=o?o:Sn.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=u?u:Sn.includeEmpty,member_state_filter:null!=c?c:Sn.myMemberStateFilter,super_mode:null!=l?l:Sn.superChannelFilter,public_mode:null!=h?h:Sn.publicChannelFilter,unread_filter:null!=d?d:Sn.unreadChannelFilter,members_nickname_contains:_,members_nickname_startswith:p,members_nickname:f,name_contains:v,channel_urls:m,custom_types:g,custom_type_startswith:E,hidden_mode:C,metadata_order_key:y,metadata_key:M,metadata_values:b,metadata_value_startswith:S,show_frozen:T,show_metadata:A,include_chat_notification:D,include_left_channel:R,created_after:F,created_before:P}),I&&I.query&&I.fields&&(s.params.search_query=I.query,s.params.search_fields=I.fields),w&&w.userIds&&w.userIds.length>0&&(w.includeMode?(s.params.members_include_in=w.userIds,s.params.query_type=w.queryType.toUpperCase()):s.params.members_exactly_in=w.userIds),s}return e(s,n),s}(S),An=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.channels=[];var r=n.next,a=n.channels,i=n.ts;return s.token=r,a&&a.length>0&&(s.channels=a.map((function(t){return t.ts=i,new ur(e,t)}))),s.ts=null!=i?i:0,s}return e(n,t),n}(T),In=function(t){function n(e){var n=e.userId,s=e.filter,r=t.call(this)||this,a=s.myMemberStateFilter;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/group_channel_count"),r.params={state:null!=a?a:Yt.ALL},r}return e(n,t),n}(S),wn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.groupChannelCount=n.group_channel_count,s}return e(n,t),n}(T),Ln=function(n){function s(e){var s=e.userId,r=e.filter,a=n.call(this)||this,i=r.keys,o=r.customTypeFilters,u=r.customTypesFilter;return a.method=N.GET,a.path="".concat(U,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=t({item_keys:i,custom_types:null!=u?u:o}),a}return e(s,n),s}(S),Dn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=n[sn.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=n[sn.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=n[sn.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=n[sn.SUPER_INVITATION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=n[sn.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=n[sn.NONSUPER_INVITATION_COUNT]),s}return e(n,t),n}(T),xn=function(t){function n(e){var n=e.userId,s=t.call(this)||this;return s.method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_channel_count"),s}return e(n,t),n}(S),Rn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s}return e(n,t),n}(T),Fn=function(t){function n(e){var n=e.userId,s=e.filter,r=e.includeFeedChannel,a=void 0!==r&&r,i=t.call(this)||this,o=s.channelCustomTypesFilter,u=s.superChannelFilter;return i.method=N.GET,i.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_message_count"),i.params={super_mode:null!=u?u:Kt.ALL,custom_types:o,include_feed_channel:a},i}return e(n,t),n}(S),Pn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s.unreadFeedCount=n.unread_feed_count,s}return e(n,t),n}(T),kn=function(t){function n(e){var n=e.channelUrl,s=e.scheduledStatus,r=e.messageTypeFilter,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(w,"/count"),a.params={channel_url:n,status:Hn(s)},r&&(a.params.message_type=r),a}return e(n,t),n}(S),On=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.count=n.count,s}return e(n,t),n}(T),Hn=function(e){if(!e)return[];var t=[];return e.forEach((function(e){switch(e){case Me.PENDING:t.push(be.PENDING);break;case Me.SENT:t.push(be.IN_QUEUE),t.push(be.SENT);break;case Me.CANCELED:t.push(be.CANCELED);break;case Me.FAILED:t.push(be.FAILED)}})),t},Vn=function(n){function s(e){var s=this,r=e.userId,a=e.channelUrl,i=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,h=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,E=e.name,C=e.data,y=e.customType,M=e.messageSurvivalSeconds,b=e.invitedUserIds,U=e.operatorUserIds;return(s=n.call(this)||this).method=N.POST,s.path=I,s.params=t({user_ids:d([r],_(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:a,cover_url:i,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:p,is_public:h,is_discoverable:f,strict:v,is_ephemeral:m,access_code:g,name:E,data:C,custom_type:y,operator_ids:U,message_survival_seconds:M}),s}return e(s,n),s}(S),Gn=function(t){function n(e,n){var s,r=this;return(r=t.call(this,e,n)||this).channel=new ur(e,n),r.isCreated=null===(s=n.is_created)||void 0===s||s,r}return e(n,t),n}(T),Bn=function(t){function n(e){var n=e.userId,s=e.channelUrls,r=t.call(this)||this;return r.method=N.PUT,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),r.params={channel_urls:s},r}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var qn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/join"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),zn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u,l=a.users,h=void 0===l?null:l;return r.memberCount=o,r.joinedMemberCount=c,r.members=Array.isArray(h)?h.map((function(t){return new tn(e,t)})):[new tn(e,s.data)],r}return e(n,t),n}(Ft),Wn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/leave"),n.params={user_id:r,should_remove_operator_status:a},n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Qn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u;return r.memberCount=o,r.joinedMemberCount=c,r.member=new tn(r._iid,s.data),r}return e(n,t),n}(Ft),Yn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userIds;return(n=t.call(this)||this).method=N.POST,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/invite"),n.params={user_ids:r},n}return e(n,t),n}(S),Kn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this;r.inviter=null;var a=s.data,i=a.member_count,u=void 0===i?0:i,c=a.joined_member_count,l=void 0===c?0:c,h=a.inviter,d=a.invitees,_=void 0===d?[]:d;return r.memberCount=u,r.joinedMemberCount=l,h&&Object.keys(h).length>0&&(r.inviter=new o(e,h)),r.invitees=_.map((function(t){return new tn(e,t)})),r}return e(n,t),n}(Ft),Xn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/decline"),n.params={user_id:r},n}return e(n,t),n}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.NONE,s}e(n,t)}(T);var Zn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,u=a.joined_member_count,c=a.inviter,l=a.invitee;return r.memberCount=null!=i?i:0,r.joinedMemberCount=null!=u?u:0,r.inviter=new o(e,c),r.invitee=new tn(e,l),r}return e(n,t),n}(Ft),$n={hidePreviousMessages:!1,allowAutoUnhide:!0},es=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.hidePreviousMessages,i=e.allowAutoUnhide;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n.params={user_id:r,hide_previous_messages:null!=a?a:$n.hidePreviousMessages,allow_auto_unhide:null!=i?i:$n.allowAutoUnhide},n}return e(n,t),n}(S),ts=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),ns=function(t){function n(e,n,s){var r,a,i,o=this;return(o=t.call(this,e,"SYEV",s)||this).allowAutoUnhide=null,o.hidePreviousMessages=null,o.messageOffsetTimestamp=null,s.data&&(o.allowAutoUnhide=null!==(r=s.data.allow_auto_unhide)&&void 0!==r?r:null,o.hidePreviousMessages=null!==(a=s.data.hide_previous_messages)&&void 0!==a?a:null),o.messageOffsetTimestamp=null!==(i=s.ts_message_offset)&&void 0!==i?i:null,o}return e(n,t),n}(L),ss=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),rs=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),as=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),is=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),os=function(t){function n(e){var n=e.channelUrl,s=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:s}})||this}return e(n,t),n}(D),us=function(t){function a(e,n){var s,r,a,i,o,u,c,l,h,d,_,p,f,v,m,g,E,C,y,M,b,N,U,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.includeChatNotification=!1,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Yt.ALL,S.unreadChannelFilter=Jt.ALL,S.superChannelFilter=Kt.ALL,S.publicChannelFilter=Qt.ALL,S.hiddenChannelFilter=Xt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=St.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,S.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,S.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,S.includeChatNotification=null!==(i=n.includeChatNotification)&&void 0!==i&&i,S.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,S.customTypesFilter=null!==(u=n.customTypesFilter)&&void 0!==u?u:null,S.customTypeStartsWithFilter=null!==(c=n.customTypeStartsWithFilter)&&void 0!==c?c:"",S.nicknameContainsFilter=null!==(l=n.nicknameContainsFilter)&&void 0!==l?l:null,S.nicknameStartsWithFilter=null!==(h=n.nicknameStartsWithFilter)&&void 0!==h?h:null,S.nicknameExactMatchFilter=null!==(d=n.nicknameExactMatchFilter)&&void 0!==d?d:null,S.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Yt.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Jt.ALL,S.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:Kt.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Qt.ALL,S.hiddenChannelFilter=null!==(g=n.hiddenChannelFilter)&&void 0!==g?g:Xt.UNHIDDEN,S.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},S.userIdsFilter=null!==(C=n.userIdsFilter)&&void 0!==C?C:{userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null!==(y=n.metadataKey)&&void 0!==y?y:null,S.metadataValues=null!==(M=n.metadataValues)&&void 0!==M?M:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(N=n.metadataValueStartsWith)&&void 0!==N?N:null,S.order=null!==(U=n.order)&&void 0!==U?U:St.LATEST_LAST_MESSAGE,n.createdAfter&&(S.createdAfter=n.createdAfter),n.createdBefore&&(S.createdBefore=n.createdBefore),S}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&m("string",this.channelUrlsFilter,!0)&&m("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&r(Yt,this.myMemberStateFilter)&&r(Kt,this.superChannelFilter)&&r(Qt,this.publicChannelFilter)&&r(Jt,this.unreadChannelFilter)&&r(Xt,this.hiddenChannelFilter)&&m(en,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&m("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&r($t,this.userIdsFilter.queryType)&&r(St,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&m("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)&&x(this.createdAfter,!0)&&x(this.createdBefore,!0)},a.prototype.serialize=function(){return R(this)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,ps.of(this._iid).getMyGroupChannels(this._token,n(s({},this)),this.limit,y.REQUEST_CHANNEL,!0)]):[3,2]:[3,5];case 1:return e=a.sent(),t=e.channels,r=e.token,this._token=r,this._hasNext=!!r,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(F),cs=function(n){function s(e){var s=e.channelUrl,r=e.userId,a=n.call(this)||this;return a.method=N.PUT,a.path="".concat(I,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=t({userId:r}),a}return e(s,n),s}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var ls,hs=function(t){function n(e,n,s){var r=t.call(this,e,"DLVR",s)||this;return r.channelUrl=s.channel_url,r.deliveredStateUpdate=s.updated,r}return e(n,t),n}(L),ds=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,s=e.bottom,r=void 0===s?0:s;this.top=n,this.bottom=r}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0&&n.onMentionReceived&&n.onMentionReceived(g,_)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=6;case 6:return[3,79];case 7:return U=e.as(Y),me=U.channelUrl,ge=U.channelType,S=U.messageId,T=U.silent,A=U.messageCreatedAt,I=U.senderId,ge!==i.GROUP?[3,9]:[4,this.getChannel(me,!0)];case 8:w=xn.sent(),L=I===this._sdkState.userId,T||L||A>0&&w.myLastRead0&&w._updateUnreadCount(w.unreadMessageCount-1,0),this._dispatcher.dispatch(new Q({messageIds:[S],source:y.EVENT_MESSAGE_DELETED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onMessageDeleted&&n.onMessageDeleted(w,S)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=9;case 9:return[3,79];case 10:return(D=e.as(Be).readStatus).channelType!==i.GROUP?[3,12]:(V=this._groupChannelCache.isCachedInMemory(D.channelUrl),[4,this.getChannel(D.channelUrl,!0)]);case 11:x=xn.sent(),V&&x._updateUnreadMemberState(D.reader.userId,D.readAt),D.reader.userId===this._sdkState.userId?V?(x.unreadMessageCount>0||x.unreadMentionCount>0)&&(x._updateUnreadCount(0,0),this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):0!==x.unreadMessageCount&&0!==x.unreadMentionCount||(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUnreadMemberStatusUpdated&&n.onUnreadMemberStatusUpdated(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),xn.label=12;case 12:return[3,79];case 13:return R=e.as(hs),me=R.channelUrl,F=R.deliveredStateUpdate,k=void 0===F?{}:F,V=this._groupChannelCache.isCachedInMemory(me),[4,this.getChannel(me,!0)];case 14:return K=xn.sent(),V&&Object.keys(k).forEach((function(e){K._updateUndeliveredMemberState(e,k[e])})),Object.keys(k).some((function(e){return e!==Dn._sdkState.userId}))&&(this._dispatcher.dispatch(new En({channels:[K],context:{source:y.EVENT_CHANNEL_DELIVERED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUndeliveredMemberStatusUpdated&&n.onUndeliveredMemberStatusUpdated(K)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 15:return X=e.as(qt),me=X.channelUrl,ge=X.channelType,Z=X.event,ge!==i.GROUP?[3,18]:[4,this.getChannel(me,!0)];case 16:return $=xn.sent(),[4,this.getMessageFromCache(Z.messageId)];case 17:(ne=xn.sent())?ne instanceof Ge&&(ne.applyReactionEvent(Z),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new W({event:Z,source:y.EVENT_MESSAGE_REACTION_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onReactionUpdated&&n.onReactionUpdated($,Z)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=18;case 18:return[3,79];case 19:return(ee=e.as(Bt).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(ee.channelUrl,!0)];case 20:return te=xn.sent(),[4,this.getMessageFromCache(ee.targetMessageId)];case 21:(ne=xn.sent())?ne instanceof Ge&&(ne.applyThreadInfoUpdateEvent(ee),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new z({event:ee,source:y.EVENT_MESSAGE_THREADINFO_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onThreadInfoUpdated&&n.onThreadInfoUpdated(te,ee)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=22;case 22:return[3,79];case 23:se=e.as(Gt).groupChannelMemberCounts,re=[],xn.label=24;case 24:xn.trys.push([24,29,30,31]),ae=v(se),ie=ae.next(),xn.label=25;case 25:return ie.done?[3,28]:(oe=ie.value,me=oe.channelUrl,ct=oe.memberCount,lt=oe.joinedMemberCount,ue=oe.updatedAt,[4,this.getChannelFromCache(me)]);case 26:(ce=xn.sent())&&ce._setLatestMemberCount(ct,lt,ue)&&re.push(ce),xn.label=27;case 27:return ie=ae.next(),[3,25];case 28:return[3,31];case 29:return le=xn.sent(),Nn={error:le},[3,31];case 30:try{ie&&!ie.done&&(Un=ae.return)&&Un.call(ae)}finally{if(Nn)throw Nn.error}return[7];case 31:return re.length>0&&(this._dispatcher.dispatch(new En({channels:re,context:{source:y.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelMemberCountChanged&&n.onChannelMemberCountChanged(re)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 32:return he=e.as(Vt),de=he.event,_e=he.status,me=he.channelUrl,ge=he.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,34];case 33:pe=xn.sent(),this._dispatcher.dispatch(new q({event:de,source:y.EVENT_POLL_UPDATED})),H(_e===J?function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollDeleted&&n.onPollDeleted(pe,de.pollId)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}:function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollUpdated&&n.onPollUpdated(pe,de)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}),xn.label=34;case 34:return[3,79];case 35:return fe=e.as(Ve),ve=fe.event,me=fe.channelUrl,ge=fe.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,37];case 36:Ee=xn.sent(),this._dispatcher.dispatch(new B({event:ve,source:y.EVENT_POLL_VOTED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollVoted&&n.onPollVoted(Ee,ve)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=37;case 37:return[3,79];case 38:if(!(Ce=e.as(Ft).event).isGroupChannelEvent)return[3,77];switch(Ce.category){case Ot.CHANNEL_JOIN:return[3,39];case Ot.CHANNEL_LEAVE:return[3,41];case Ot.CHANNEL_OPERATOR_UPDATE:return[3,45];case Ot.CHANNEL_INVITE:return[3,47];case Ot.CHANNEL_DECLINE_INVITE:return[3,49];case Ot.TYPING_START:case Ot.TYPING_END:return[3,51];case Ot.USER_CHANNEL_MUTE:case Ot.USER_CHANNEL_UNMUTE:return[3,53];case Ot.USER_CHANNEL_BAN:return[3,55];case Ot.USER_CHANNEL_UNBAN:return[3,59];case Ot.CHANNEL_FREEZE:case Ot.CHANNEL_UNFREEZE:return[3,61];case Ot.CHANNEL_HIDE:return[3,63];case Ot.CHANNEL_UNHIDE:return[3,65];case Ot.CHANNEL_DELETED:return[3,67];case Ot.CHANNEL_PROP_CHANGED:return[3,69];case Ot.CHANNEL_META_DATA_CHANGED:return[3,71];case Ot.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case Ot.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(Ce.channelUrl,!0)];case 40:return ye=xn.sent(),Me=e.as(jn),be=Me.memberCount,Ne=Me.joinedMemberCount,Ue=Me.members,Se=!1,Ue.forEach((function(e){ye.isExclusive||ye.isSuper||ye.isBroadcast?Se=Se||ye._setLatestMemberCount(be,Ne,Ce.ts):(e.state=Wt.JOINED,ye.addMember(e,Ce.ts),Dn._updateJoinedMemberCount(ye)),e.userId===Dn._sdkState.userId&&(ye.myMemberState=Wt.JOINED)})),this._dispatcher.dispatch(new En({channels:[ye],context:{source:y.EVENT_CHANNEL_JOINED,users:Ue}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var s=v(Ue),r=s.next();!r.done;r=s.next()){var a=r.value;e.onUserJoined&&e.onUserJoined(ye,a)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}ye.isBroadcast&&Se&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,77];case 41:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Ae=Mt.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(Ce.channelUrl,!0)];case 43:Ae=xn.sent(),xn.label=44;case 44:return Te=Ae,Ie=e.as(Qn),ct=Ie.memberCount,lt=Ie.joinedMemberCount,we=Ie.member,Le=!1,De=P.of(this._iid).appInfo,Te.isExclusive||Te.isSuper||Te.isBroadcast?Le=Te._setLatestMemberCount(ct,lt,Ce.ts):((null==De?void 0:De.enabledChannelMemberShipHistory)?((Ye=Te.members.find((function(e){return e.userId===we.userId})))&&(Ye.state=Wt.LEFT),Te.memberCount=ct):Te.removeMember(we),this._updateJoinedMemberCount(Te)),we.userId===this._sdkState.userId?(Te.myMemberState=Wt.NONE,Te.invitedAt=0,Te.joinedAt=0,Te._updateUnreadCount(0,0),Te.isPublic?this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})):(this._markAsLeave(Te),this._dispatcher.dispatch(new Cn({channelUrls:[Te.url],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})))):this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(Te,we),Te.isBroadcast&&Le&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Te])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(Ce.channelUrl,!0)];case 46:Ke=xn.sent(),Je=e.as(Ht).operators,Xe=Je.map((function(e){return e.userId}));try{for(Ze=v(Ke.members),$e=Ze.next();!$e.done;$e=Ze.next())(yt=$e.value).role=Xe.includes(yt.userId)?a.OPERATOR:a.NONE}catch(e){Sn={error:e}}finally{try{$e&&!$e.done&&(Tn=Ze.return)&&Tn.call(Ze)}finally{if(Sn)throw Sn.error}}return Ke.myRole=Xe.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new En({channels:[Ke],context:{source:y.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Je}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ke,Je)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(Ce.channelUrl,!0)];case 48:et=xn.sent(),tt=e.as(Jn),ct=tt.memberCount,lt=tt.joinedMemberCount,nt=tt.inviter,(st=tt.invitees).forEach((function(e){return e.state=Wt.INVITED}));try{for(rt=v(st),at=rt.next();!at.done;at=rt.next())it=at.value,et.isExclusive||et.isSuper||et.isBroadcast?et._setLatestMemberCount(ct,lt,Ce.ts):et.addMember(it,Ce.ts),this._sdkState.userId===it.userId&&(et.hiddenState=tr.UNHIDDEN,et.myMemberState!==Wt.JOINED&&(et.myMemberState=Wt.INVITED),et.invitedAt=Ce.ts)}catch(e){An={error:e}}finally{try{at&&!at.done&&(In=rt.return)&&In.call(rt)}finally{if(An)throw An.error}}return this._dispatcher.dispatch(new En({channels:[et],context:{source:y.EVENT_CHANNEL_INVITED,inviter:nt,invitees:st}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(et,nt,st)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(Ce.channelUrl,!0)];case 50:return ot=xn.sent(),ut=e.as(Zn),ct=ut.memberCount,lt=ut.joinedMemberCount,ht=ut.inviter,dt=ut.invitee,ot.isExclusive||ot.isSuper||ot.isBroadcast?ot._setLatestMemberCount(ct,lt,Ce.ts):ot.removeMember(dt),this._sdkState.userId===dt.userId?(ot.invitedAt=0,ot.myMemberState=Wt.NONE,ot.isPublic?this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})):this._dispatcher.dispatch(new Cn({channelUrls:[ot.url],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}}))):this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ot,ht,dt)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(Ce.channelUrl,!0)];case 52:return _t=xn.sent(),pt=Ce.category===Ot.TYPING_START,ft=e.as(pt?rs:is).user,_t._updateTypingStatus(ft,pt?Ce.ts:0),this._dispatcher.dispatch(new En({channels:[_t],context:{source:y.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(_t)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(Ce.channelUrl,!0)];case 54:vt=xn.sent(),mt=Ce.category===Ot.USER_CHANNEL_MUTE,(gt=e.as(mt?Oe:He).user).userId===this._sdkState.userId&&(vt.myMutedState=mt?G.MUTED:G.UNMUTED,vt._myMutedRemainingTime=gt.restrictionInfo.remainingDuration);try{for(Et=v(vt.members),Ct=Et.next();!Ct.done;Ct=Et.next())if((yt=Ct.value).userId===gt.userId){yt.isMuted=mt;break}}catch(e){wn={error:e}}finally{try{Ct&&!Ct.done&&(Ln=Et.return)&&Ln.call(Et)}finally{if(wn)throw wn.error}}return this._dispatcher.dispatch(new En({channels:[vt],context:{source:mt?y.EVENT_CHANNEL_MUTED:y.EVENT_CHANNEL_UNMUTED,user:gt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){mt?e.onUserMuted&&e.onUserMuted(vt,gt):e.onUserUnmuted&&e.onUserUnmuted(vt,gt)})),[2]}))}))})),[3,77];case 55:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Nt=Mt.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(Ce.channelUrl,!0)];case 57:Nt=xn.sent(),xn.label=58;case 58:return bt=Nt,this._markAsLeave(bt),Ut=e.as(ke).user,Ut.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[bt.url],context:{source:y.EVENT_CHANNEL_BANNED,user:Ut}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(bt,Ut)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(Ce.channelUrl,!0)];case 60:return St=xn.sent(),Tt=e.as(Pe).user,Tt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[St.url],context:{source:y.EVENT_CHANNEL_UNBANNED,user:Tt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(St,Tt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(Ce.channelUrl,!0)];case 62:return At=xn.sent(),It=e.as(Fe).freeze,At.isFrozen=It,this._dispatcher.dispatch(new En({channels:[At],context:{source:It?y.EVENT_CHANNEL_FROZEN:y.EVENT_CHANNEL_UNFROZEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){It?e.onChannelFrozen&&e.onChannelFrozen(At):e.onChannelUnfrozen&&e.onChannelUnfrozen(At)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(Ce.channelUrl,!0)];case 64:return wt=xn.sent(),Rt=e.as(ns),Pt=Rt.allowAutoUnhide,Qt=Rt.hidePreviousMessages,Yt=Rt.messageOffsetTimestamp,null!==Pt&&(wt.hiddenState=Pt?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Qt&&Qt&&wt._updateUnreadCount(0,0),null!==Yt&&(wt.messageOffsetTimestamp=Yt),this._dispatcher.dispatch(new En({channels:[wt],context:{source:y.EVENT_CHANNEL_HIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(wt)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(Ce.channelUrl,!0)];case 66:return(Kt=xn.sent()).hiddenState=tr.UNHIDDEN,this._dispatcher.dispatch(new En({channels:[Kt],context:{source:y.EVENT_CHANNEL_UNHIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Kt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(Ce.channelUrl,!0)];case 68:return Jt=xn.sent(),this._dispatcher.dispatch(new Cn({channelUrls:[Ce.channelUrl],context:{source:y.EVENT_CHANNEL_DELETED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Jt.url,Jt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(Ce.channelUrl,!0)];case 70:return Xt=xn.sent(),this._dispatcher.dispatch(new En({channels:[Xt],context:{source:y.EVENT_CHANNEL_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Xt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(Ce.channelUrl,!0)];case 72:return Zt=xn.sent(),$t=e.as(Re),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&(Zt._upsertCachedMetaData(en,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_CREATED,metaData:en},ts:Ce.ts}))),tn&&(Zt._upsertCachedMetaData(tn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_UPDATED,metaData:tn},ts:Ce.ts}))),nn&&(Zt._removeFromCachedMetaData(nn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:nn},ts:Ce.ts}))),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){en&&e.onMetaDataCreated&&e.onMetaDataCreated(Zt,en),tn&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Zt,tn),nn&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Zt,nn)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(Ce.channelUrl,!0)];case 74:return sn=xn.sent(),rn=e.as(xe),an=rn.created,on=rn.updated,un=rn.deleted,an&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:an}})),on&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:on}})),un&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:un}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){an&&e.onMetaCounterCreated&&e.onMetaCounterCreated(sn,an),on&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(sn,on),un&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(sn,un)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(Ce.channelUrl,!0)];case 76:return cn=xn.sent(),ln=e.as(kt),hn=ln.pinnedMessageIds,dn=ln.latestPinnedMessage,(_n=ln.ts)>cn._pinnedMessagesUpdatedAt&&(cn.pinnedMessageIds=null!=hn?hn:[],cn.lastPinnedMessage=dn,cn._pinnedMessagesUpdatedAt=_n,this._dispatcher.dispatch(new En({channels:[cn],context:{source:y.EVENT_PINNED_MESSAGE_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(cn)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(cn)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((pn=e.as(Lt).event).category){case Dt.USER_BLOCK:fn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=fn.blocker,gn=fn.blockee,this._groupChannelCache.block(mn.userId,gn.userId);break;case Dt.USER_UNBLOCK:vn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=vn.blocker,gn=vn.blockee,this._groupChannelCache.unblock(mn.userId,gn.userId)}return[3,79];case 79:return[3,81];case 80:if(yn=xn.sent(),O(yn))throw yn;return[3,81];case 81:return[2]}}))}))},u.prototype._markAsLeave=function(e){var t,n=this,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((function(){s.ref--,0===s.ref&&n._leftChannels.delete(e.url)}),1e4)},u.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},u.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},u.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},u.prototype.subscribeChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},u.prototype.unsubscribeChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},u.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===Wt.JOINED})).length},u.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n;return f(this,(function(s){switch(s.label){case 0:l(g("string",e)).throw(h.invalidParameters),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=s.sent())?[2,n]:[3,4];case 3:return s.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,s.sent()]}}))}))},u.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return l(g("string",e)).throw(h.invalidParameters),n=new Nn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(s=o.sent(),r=s.as(Un).channel,a=r.unreadMessageCount,i=r.unreadMentionCount,r.myCountPreference){case er.UNREAD_MESSAGE_COUNT_ONLY:i=0;break;case er.UNREAD_MENTION_COUNT_ONLY:a=0;break;case er.OFF:a=0,i=0}return r._updateUnreadCount(a,i),[4,this.upsertChannelsToCache([r])];case 2:return[2,o.sent()[0]]}}))}))},u.prototype.refreshChannel=function(e,t,n,s){return void 0===t&&(t=!0),void 0===n&&(n=y.REFRESH_CHANNEL),void 0===s&&(s=!1),p(this,void 0,void 0,(function(){var r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Nn({channelUrl:e,isInternalCall:t,showLatestMessage:s}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Un).channel).myMemberState!==Wt.NONE?[3,2]:(this._dispatcher.dispatch(new Cn({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new En({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(u=c.sent()).code!==K.NON_AUTHORIZED&&u.code!==K.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Cn({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},u.prototype.getMyGroupChannels=function(e,t,n,r,a){return void 0===r&&(r=y.REQUEST_CHANNEL),void 0===a&&(a=!1),p(this,void 0,void 0,(function(){var i,o,u,c,l,h,d,_,p;return f(this,(function(f){switch(f.label){case 0:return t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3)),i=!1,a&&(o=P.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(i=!0)),l=new Tn(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n,includeLeftChannel:a&&i})),[4,this._requestQueue.send(l)];case 1:return h=f.sent(),d=h.as(An),_=d.channels,p=d.token,this._dispatcher.dispatch(new En({channels:_,context:{source:r}})),[2,{channels:_,token:p}]}}))}))},u.prototype.getMyGroupChannelChangeLogs=function(e,t,r){return void 0===r&&(r=y.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var a,i,o,u,c,d,_,p;return f(this,(function(f){switch(f.label){case 0:return a=s(s({},cn),t),l((g("string",e)||g("number",e))&&ln(a)).throw(h.invalidParameters),i=new Mn(n({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:a})),[4,this._requestQueue.send(i)];case 1:return o=f.sent(),u=o.as(bn),c=u.updatedChannels,d=u.deletedChannelUrls,_=u.hasMore,p=u.ts,c.length>0&&this._dispatcher.dispatch(new En({channels:c,context:{source:r},ts:p})),d.length>0&&this._dispatcher.dispatch(new Cn({channelUrls:d,context:{source:r}})),[2,{updatedChannels:c,deletedChannelUrls:d,hasMore:_,token:u.token}]}}))}))},u.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(a){switch(a.label){case 0:return t=s(s({},hn),e),l(dn(t)).throw(h.invalidParameters),n=new In({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),[2,r.as(wn).groupChannelCount]}}))}))},u.prototype.getUnreadItemCount=function(e){return p(this,void 0,void 0,(function(){var n,r,a,i,o,u,c,d,_,p,v,g,E,C,y,M;return f(this,(function(f){switch(f.label){case 0:return n=s(s({},_n),e),l(function(e){return m(sn,e.keys)&&m("string",e.customTypeFilters,!0)&&m("string",e.customTypesFilter,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid),a=r.sdkState,i=r.requestQueue,o=new Ln({userId:a.userId,filter:n}),[4,i.send(o)];case 1:return u=f.sent(),c=u.as(Dn),d=c.groupChannelUnreadMentionCount,_=c.groupChannelUnreadMessageCount,p=c.groupChannelInvitationCount,v=c.superGroupChannelUnreadMentionCount,g=c.superGroupChannelUnreadMessageCount,E=c.superGroupChannelInvitationCount,C=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,M=c.nonSuperGroupChannelInvitationCount,[2,t({groupChannelUnreadMentionCount:d,groupChannelUnreadMessageCount:_,groupChannelInvitationCount:p,superGroupChannelUnreadMentionCount:v,superGroupChannelUnreadMessageCount:g,superGroupChannelInvitationCount:E,nonSuperGroupChannelUnreadMentionCount:C,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:M})]}}))}))},u.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new xn({userId:t.userId}),[4,n.send(s)];case 1:return r=a.sent(),[2,r.as(Rn).unreadCount]}}))}))},u.prototype.getTotalUnreadMessageCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return t=s(s({},pn),e),l(fn(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Fn({userId:r.userId,filter:t}),[4,a.send(i)];case 1:return o=u.sent(),[2,o.as(Pn).unreadCount]}}))}))},u.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,a,i;return f(this,(function(o){switch(o.label){case 0:return t=s(s({},vn),e),l(function(e){return g("string",e.channelUrl,!0)&&m(Me,e.scheduledStatus,!0)&&r(C,e.messageTypeFilter)}(t)).throw(h.invalidParameters),n=P.of(this._iid).requestQueue,a=new kn(t),[4,n.send(a)];case 1:return i=o.sent(),[2,i.as(On).count]}}))}))},u.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=P.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},u.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=P.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e},u.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=P.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},u.prototype.createChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a;return f(this,(function(i){switch(i.label){case 0:return t=s(s({},on),e),l(un(t)).throw(h.invalidParameters),t.isPublic||(t.accessCode=void 0),n=new Vn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),a=r.as(Gn).channel,[4,this.upsertChannelsToCache([a])];case 2:return i.sent(),[2,a]}}))}))},u.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return e=Date.now(),l(e-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Bn({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(s=v(n),r=s.next();!r.done;r=s.next())(a=r.value)._updateUnreadMemberState(this._sdkState.userId,e),a._updateUnreadCount(0,0)}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},u.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=Date.now(),l(m("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Bn({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:d.sent(),s=this._groupChannelCache.channels,r=[];try{for(a=v(s),i=a.next();!i.done;i=a.next())o=i.value,e.includes(o.url)&&(o._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0),r.push(o))}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=a.return)&&c.call(a)}finally{if(u)throw u.error}}return r.length>0?[4,this.upsertChannelsToCache(r)]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2]}}))}))},u.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},u.prototype.getMessageFromCache=function(e){var t;return p(this,void 0,void 0,(function(){return f(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]}}))}))},u.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return p(this,void 0,void 0,(function(){return f(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,s.sent()]}}))}))},u.prototype.getMessagesFromCache=function(e,t,n,s,r,a){return void 0===r&&(r=Ye),void 0===a&&(a=!0),p(this,void 0,void 0,(function(){return f(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:s,backward:"next"===n,inclusive:a})];case 1:return[2,i.sent()]}}))}))},u.prototype.getPollMessagesFromCache=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,r.sent()]}}))}))},u.prototype.getCachedMessageCountBetween=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.countBetween(e,t,new ds({top:n,bottom:s}))];case 1:return[2,r.sent()]}}))}))},u.prototype.getUnsentMessagesFromCache=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},u.prototype.removeFailedMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},u}(Pt),fs=function(e,t){return t instanceof qe?e.findIndex((function(e){return e instanceof qe&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vs=function(e,t){return e.findIndex((function(e){return e instanceof Ge?e.messageId===t:e instanceof Ke?e.notificationId===t:void 0}))},ms=function(e,t){if(e.length>0){for(var n=0,s=e.length-1,r=Math.floor((n+s)/2);n0)s=r,r=Math.floor((n+s)/2);else{if(!(a<0))return r;n=r+1,r=Math.floor((n+s)/2)}}return e[r].createdAt>t.createdAt?r:r+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(ls||(ls={}));var gs,Es=function(t){function n(e,n,s,r){var a=t.call(this)||this;return a._state=ls.IDLE,a._retryCount=0,a._retryLimit=3,a.priority=0,a._worker=n,a}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===ls.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===ls.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===ls.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(s){switch(s.label){case 0:if(!this.isRunning)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=s.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=s.sent(),this.dispatch("error",n),this._retryCount0&&(r=s.map((function(e){return e.createdAt})),(null===(v=this._metadata)||void 0===v?void 0:(i=v.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.length0&&(r=s.map((function(e){return e.createdAt})),(null===(h=this._metadata)||void 0===h?void 0:(i=h.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit,this._metadata&&(t.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return f.sent(),[3,7];case 5:throw a=f.sent(),m.debug("message background next sync error",a),a;case 6:return g.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:n.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(v=null===(p=l.localCacheConfig)||void 0===p?void 0:p.maxSize)&&void 0!==v?v:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[2,t]}}))}))}))];case 1:return[2,s.sent()]}}))}))})),this._connectionEventContext=v.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n){return Cs[t]||(Cs[t]={}),Cs[t][n.url]||(Cs[t][n.url]=new e({_iid:t,channel:n})),Cs[t][n.url].ref++,Cs[t][n.url]},e.clear=function(e,t){Cs[e]&&Cs[e][t]&&(Cs[e][t].close(),delete Cs[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 ds({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{range:new ds(e.range),previousComplete:e.previousComplete}:{range:new ds({}),previousComplete:!1},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(e){var t,n,s,r;void 0===e&&(e=Date.now());var a=P.of(this._iid),i=a.logger,o=a.sessionManager;a.cacheContext.localCacheEnabled&&o.session.hasSession&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==n?n:e),this._nextSync.start(null!==(r=null===(s=this._metadata)||void 0===s?void 0:s.range.bottom)&&void 0!==r?r:e))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Cs[this._iid][this._channel.url])},e}(),Ms={},bs=function(){function e(e){var t=e._iid,n=e.channel,r=e.includeParams,a=this;this.ref=0,this._iid=t,this._channel=n,this._includeParams=r;var i,o,u=P.of(this._iid),c=u.logger,l=u.sdkState,d=u.dispatcher;this._metadataKey=(i=l.userId,o=n.url,"sendbird:".concat(i,"@groupchannel/").concat(o,"/message/changelogs.meta"));var _=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(l.userId,this._channel.url);this._sync=new Es(_,(function(){return p(a,void 0,void 0,(function(){var e,t,n,r,a,i,o,u;return f(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:l.sent(),c.debug("message changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),l.label=2;case 2:return l.trys.push([2,5,,8]),[4,Je.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,s({replyType:ne.ALL},this._includeParams),y.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=l.sent(),n=t.updatedMessages,r=t.deletedMessageIds,a=t.hasMore,i=t.token,e.hasNext=a,e.nextToken=i,(n.length>0||r.length>0)&&this._metadata&&(this._metadata.token=i),c.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return l.sent(),[3,8];case 5:return o=l.sent(),c.debug("message changelog sync error",o),o instanceof h&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:l.sent(),l.label=7;case 7:throw o;case 8:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n,s){return Ms[t]||(Ms[t]={}),Ms[t][n.url]||(Ms[t][n.url]=new e({_iid:t,channel:n,includeParams:s})),Ms[t][n.url].ref++,Ms[t][n.url]},e.clear=function(e,t){Ms[e]&&Ms[e][t]&&(Ms[e][t].close(),delete Ms[e])},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=P.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:s=r.sent(),this._metadata={token:s?s.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e=P.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Ms[this._iid][this._channel.url])},e}(),Ns={},Us=function(){function e(e){var t=e._iid,n=e.channel,s=e.hasPollMessage,r=this;this.ref=0,this._iid=t,this._channel=n;var a,i,o=P.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(a=c.userId,i=n.url,"sendbird:".concat(a,"@groupchannel/").concat(i,"/poll/changelogs.meta"));var d=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new Es(d,(function(){return p(r,void 0,void 0,(function(){var e,t,n,r,a,i,o,c;return f(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,s()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=P.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,se.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return r=l.sent(),a=r.hasMore,i=r.token,e.hasNext=a,e.nextToken=i,this._metadata.token=i,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 h&&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 Z)if(e.stateType===$.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n,s){return Ns[t]||(Ns[t]={}),Ns[t][n.url]||(Ns[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:s})),Ns[t][n.url].ref++,Ns[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.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 p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){P.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){P.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 Ns[this._iid][this._channel.url])},e}(),Ss=function(n){function s(e){var s,r,a,i,o,u,c,l,h,d,_=this;return(_=n.call(this)||this).method=N.GET,_.path="".concat(re(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),_.params=t({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!==(r=e.customTypes)&&void 0!==r?r:["*"],message_type:null!==(a=e.messageType)&&void 0!==a?a:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:ne.NONE,include_reactions:null===(o=e.includeReactions)||void 0===o||o,include_meta_array:null===(u=e.includeMetaArray)||void 0===u||u,include_thread_info:null===(c=e.includeThreadInfo)||void 0===c||c,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(d=e.showSubchannelMessagesOnly)&&void 0!==d&&d,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),_}return e(s,n),s}(S),Ts=function(t){function n(e,n){var s,r,a,i,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(s=n.prev_messages)&&void 0!==s?s:[]).map((function(t){return Xe(e,t)})),c.prevHasMore=null!==(r=n.prev_hasmore)&&void 0!==r&&r,c.isContinuousPrevMessages=null!==(a=n.is_continuous_prev_messages)&&void 0!==a&&a,c.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return Xe(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}(T),As={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(gs||(gs={}));var Is,ws,Ls,Ds=function(){function e(){this._onCacheResult=ue,this._onApiResult=ue}return e.prototype._invokeResponse=function(e,t,n){var s=this;H((function(){return p(s,void 0,void 0,(function(){return f(this,(function(s){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}(),xs=function(){function e(e,t){var n=t.filter,s=t.startingPoint,r=t.limit,a=t.prevResultLimit,i=t.nextResultLimit,o=t.channel,u=t.channelManager,c=t.disableBackgroundSync,l=void 0!==c&&c,h=this;this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key="mc-".concat(oe()),this._isDisposed=!1,this.filter=null!=n?n:new Le,this._channel=o,this._syncRange=new ds({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=r||Ye,this._prevResultLimit=null!=a?a:Math.floor(this._limit/2),this._nextResultLimit=null!=i?i:Math.floor(this._limit/2),this._channelManager=u;var m=P.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source,s=e.findIndex((function(e){return e.isIdentical(h.channel)}));s>=0&&(h._replaceChannelOfCollection(e[s]),h.channel._runIfHandleableWithGroupChannel((function(e){switch(n){case y.EVENT_CHANNEL_UPDATED:for(var s=!1,r=0;r=e.messageOffsetTimestamp){s=!0;var a=r;if(a>0){var i=h._messages.splice(0,a);h._removeMessagesFromView(i.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&h._messages.length>0&&h._removeMessagesFromView(h._messages.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED);break;case y.EVENT_CHANNEL_UNMUTED:var o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&h._clearCheckMyMutedTimer();break;case y.EVENT_CHANNEL_MUTED:o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&-1!==e._myMutedRemainingTime&&h._startCheckMyMutedTimer(e._myMutedRemainingTime);break;case y.EVENT_CHANNEL_LEFT:e.isPublic&&h._clearCheckMyMutedTimer()}H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(s){return gn(n)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel),[2]}))}))}))})),h._postprocessChannelUpdateEvent(e[s],n))},onRemove:function(e,t){var n=e.indexOf(h.channel.url);n>=0&&(h._clearCheckMyMutedTimer(),H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(n){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url),[2]}))}))})),h._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,s,r=[],a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value;u.channelUrl===h._channel.url&&(h.filter.match(u)?r.push(u):a.push(h.keyOf(u)))}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}if(ie(t)){if(r.length>0)switch(t){case y.LOCAL_MESSAGE_CANCELED:case y.LOCAL_MESSAGE_RESEND_STARTED:case y.EVENT_MESSAGE_SENT_FAILED:case y.EVENT_MESSAGE_SENT_SUCCESS:case y.EVENT_MESSAGE_UPDATED:case y.EVENT_MESSAGE_THREADINFO_UPDATED:case y.EVENT_MESSAGE_REACTION_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_ADDED:case y.EVENT_MESSAGE_FEEDBACK_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_DELETED:case y.SYNC_MESSAGE_CHANGELOGS:h._updateMessagesToView(r,t);break;case y.EVENT_MESSAGE_SENT_PENDING:h._addMessagesToView(r,t);break;case y.EVENT_MESSAGE_RECEIVED:h.hasNext||h._addMessagesToView(r,t);break;case y.SYNC_MESSAGE_FILL:h._addMessagesToView(r,t)}a.length>0&&h._removeMessagesFromView(a,t)}h._postprocessMessageUpdateEvent(e,t)},onRemove:function(e,t){h._removeMessagesFromView(e,t),h._postprocessMessageRemoveEvent(e)},onRemoveUnsent:function(e,t){h._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){h._updatePollsToView(e,t)},onPollUpdate:function(e,t){h._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){h._applyPollVoteEventToView(e,t)},onReactionUpdate:function(e,t){h._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){h._applyThreadInfoEventToView(e,t)}});var g=P.of(this._iid),E=g.cacheContext,C=g.dispatcher,M=g.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),C.dispatch(new En({channels:[this._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=ys.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=bs.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Us.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Es(this._key,(function(e){return p(h,void 0,void 0,(function(){var t=this;return f(this,(function(n){switch(n.label){case 0:return[4,M.run("message-fill-sync-".concat(o.url,"-prev"),(function(){return p(t,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:y.SYNC_MESSAGE_FILL,checkingContinuousMessages:E.localCacheEnabled})];case 1:return t=u.sent(),n=t.messages,s=t.isContinuousMessages,n.length>0?(r=Math.min.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:n.length>=this._prevResultLimit&&this.viewTop0?(r=Math.max.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:!(n.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>r,nextToken:this._syncRange.bottom}]):(E.localCacheEnabled&&m.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(o=null===(i=E.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==o?o:0,use_local_cache:E.localCacheEnabled,starting_point:0,message_init_policy:""}})),[2,{hasNext:!1,nextToken:0}])}}))}))}))];case 1:return[2,n.sent()]}}))}))})),this._connectionEventContext=C.on((function(e){if(e instanceof Z)switch(e.stateType){case $.CONNECTED:b((function(){return p(h,void 0,void 0,(function(){return f(this,(function(e){return this._activate(),[2]}))}))}));break;case $.LOGOUT:h.dispose();break;default:h._clearCheckMyMutedTimer(),h._prevFill.stop(),h._nextFill.stop()}}))}return e.prototype.keyOf=function(e){return 0},Object.defineProperty(e.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),e.prototype._postprocessChannelUpdateEvent=function(e,t){},e.prototype._postprocessChannelRemoveEvent=function(e){},e.prototype._postprocessMessageUpdateEvent=function(e,t){},e.prototype._postprocessMessageRemoveEvent=function(e){},Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],_(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype._activate=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return P.of(this._iid).logger.debug("check huge gap"),this._checkHugeGap(),[4,this._refreshChannel(y.SYNC_CHANNEL_CHANGELOGS)];case 1:return e.sent(),[2]}}))}))},e.prototype._replaceChannelOfCollection=function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)},e.prototype._shouldStartBackgroundSync=function(){var e=P.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled},e.prototype._setBaseMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n instanceof Ge&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,s,r=this,a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value,c=vs(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l.isUserMessage()&&l.applyPoll(u),a.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}return a.length>0&&ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},a.length>0&&(null===(s=(n=this._handler).onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,a)),[2]}))}))})),a},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollUpdateEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollVoteEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyReactionEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyReactionEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._applyThreadInfoEventToView=function(e,t){var n=this,s=vs(this._messages,e.targetMessageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyThreadInfoUpdateEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._removeMessagesFromView=function(e,t){var n,s,r=this,a=[],i=[],o=function(e){var t=u._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var n=u._messages[t];a.push(u.keyOf(n)),i.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=v(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(n)throw n.error}}return ie(t)&&i.length>0&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===s||s.call(n,e,this.channel,a,i),[2]}))}))})),a},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,s=void 0===n?0:n,r=t.nextLimit,a=void 0===r?0:r,i=t.inclusive,o=void 0===i||i;return p(this,void 0,void 0,(function(){var t,n,r,i,u;return f(this,(function(c){switch(c.label){case 0:return t=[],o?[4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter)]:[3,2];case 1:t=c.sent(),c.label=2;case 2:return s>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,s,!1)]:[3,4];case 3:return r=c.sent(),[3,5];case 4:r=[],c.label=5;case 5:return n=r,a>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,a,!1)]:[3,7];case 6:return u=c.sent(),[3,8];case 7:u=[],c.label=8;case 8:return i=u,[2,{messages:d(d(d([],_(t),!1),_(n),!1),_(i),!1).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:n.length,nextMessagesCount:i.length}]}}))}))},e.prototype._getRemoteMessages=function(e,t){var r=t.prevLimit,a=void 0===r?0:r,i=t.nextLimit,o=void 0===i?0:i,u=t.source,c=void 0===u?y.REQUEST_MESSAGE:u,l=t.reverse,h=void 0!==l&&l,d=t.checkingHasNext,_=void 0!==d&&d,v=t.checkingContinuousMessages,m=void 0!==v&&v;return p(this,void 0,void 0,(function(){var t,r;return f(this,(function(i){switch(i.label){case 0:return t=Je.of(this._iid),a>0||o>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,n(s(s(s({},this.filter),As),{isInclusive:!0,reverse:h,prevResultSize:a,nextResultSize:o})),c,_,m)]:[3,2];case 1:return r=i.sent(),[3,3];case 2:r={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,r]}}))}))},e.prototype._checkHugeGap=function(){var e,t,n,r,a;return p(this,void 0,void 0,(function(){var i,o,u,c,l,v,m,g,E,C,M,b,N,U,S,T,A,I,w,L,D,x,R,F,k,O=this;return f(this,(function(V){switch(V.label){case 0:return i=P.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=i.cacheContext,l=i.statManager,v=i.logger,this._messages.length>0?(m=this._syncRange.top,g=this.viewTop,E=this._syncRange.bottom,C=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,g,m)]):[3,8];case 1:return M=V.sent(),[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,E,C)];case 2:b=V.sent(),V.label=3;case 3:return V.trys.push([3,5,6,7]),[4,ce((function(){return p(O,void 0,void 0,(function(){var e,t,n,r,a,i,l,h,v,N,U,S,T,A,I,w,L,D=this;return f(this,(function(x){switch(x.label){case 0:return e=new Ss(s(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:g,prevEnd:m,prevCount:M,nextStart:E,nextEnd:C,nextCount:b,checkingContinuousMessages:c.localCacheEnabled},this.filter),As)),[4,u.send(e)];case 1:return t=x.sent(),n=t.as(Ts),r=n.isHugeGap,a=n.prevMessages,i=void 0===a?[]:a,l=n.prevHasMore,h=n.isContinuousPrevMessages,v=n.nextMessages,N=void 0===v?[]:v,U=n.nextHasmore,S=n.isContinuousNextMessages,r?H((function(){return p(D,void 0,void 0,(function(){var e;return f(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected(),[2]}))}))})):(T=this.viewTop,A=this.viewBottom,I=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,T],_(i.map((function(e){return e.createdAt}))),!1)),w=Math.max.apply(Math,d([0,A],_(N.map((function(e){return e.createdAt}))),!1)),o.dispatch(new j({messages:i,source:y.SYNC_MESSAGE_FILL})),o.dispatch(new j({messages:N,source:y.SYNC_MESSAGE_FILL})),this._syncRange.extends(I,w),(h||S)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(I,w)),l&&this._prevFill.start(I),U&&this._nextFill.start(w)),[2]}}))}))}),1)];case 4:return V.sent(),[3,7];case 5:return N=V.sent(),v.debug("Failed HugeGap Check ",N),[3,7];case 6:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=c.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[3,13];case 8:U=Date.now(),V.label=9;case 9:return V.trys.push([9,11,12,13]),[4,this._getRemoteMessages(U,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:y.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:c.localCacheEnabled})];case 10:if(S=V.sent(),T=S.messages,A=S.isContinuousMessages,I=S.hasNext,T.length>0){for(w=T.map((function(e){return e.createdAt})),L=0,D=0,x=0;x=U&&D++;this._hasPrevious=L>=this._prevResultLimit,this._hasNext=null!=I?I:D>=this._nextResultLimit,(k=this._syncRange).extends.apply(k,d([],_(w),!1)),A&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(T,y.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,13];case 11:return(F=V.sent())instanceof h&&F.code===K.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,13];case 12:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(a=null===(r=c.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 13:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return e=this,[4,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return e._unsentMessages=t.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s;return f(this,(function(r){switch(r.label){case 0:n=P.of(this._iid).logger,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._channelManager.refreshChannel(this.channel.url,!0,e,t)];case 2:return r.sent(),[3,4];case 3:return s=r.sent(),n.warn("Failed to refresh channel",s),[3,4];case 4:return[2]}}))}))},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return p(t,void 0,void 0,(function(){var e,t,n,s=this;return f(this,(function(r){switch(r.label){case 0:this._checkMyMutedStateTimer=void 0,e=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=r.sent(),e=!t.isMuted,[3,5];case 3:return r.sent(),e=!0,[3,5];case 4:return e&&(n=P.of(this._iid).sessionManager,this.channel._runIfHandleableWithGroupChannel((function(e){var t,r;e.myMutedState=G.UNMUTED;var a={source:y.EVENT_CHANNEL_UNMUTED,user:n.currentUser};null===(r=null===(t=s._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===r||r.call(t,a,s.channel)}))),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)},e.prototype._setHasNextAndHasPrevious=function(e,t){for(var n=e.map((function(e){return e.createdAt})),s=0,r=0,a=0;athis._startingPoint&&r++}this._hasPrevious=s>=this._prevResultLimit,this._hasNext=null!=t?t:r>=this._nextResultLimit},e.prototype.initialize=function(e){var t=this,n=new Ds;this._messages=[],this._unsentMessages=[],this._syncRange=new ds({}),this._hasNext=!0,this._hasPrevious=!0;var s=[],r={messages:[],prevMessagesCount:0,nextMessagesCount:0};return H((function(){return p(t,void 0,void 0,(function(){var t,a,i,o,u,c=this;return f(this,(function(l){switch(l.label){case 0:return[4,null===(u=this._backgroundSync)||void 0===u?void 0:u.loadMetadata()];case 1:if(t=l.sent(),a=P.of(this._iid),i=a.cacheContext,o=a.statManager,e===gs.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(e){return p(c,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return r=e,s=this._filterUnderOffsetMessage(r.messages),this._addMessagesToView(s,y.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return t.sent(),n._invokeResponse("local",null,s),[2]}}))}))})).catch((function(e){if(O(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){return p(c,void 0,void 0,(function(){var a,i,u,c,l,h,p,v=this;return f(this,(function(f){switch(f.label){case 0:return a=P.of(this._iid).cacheContext,i=!0,u=!0,c=!1,a.localCacheEnabled&&s.length>0&&(l=t.range).includes.apply(l,d([],_(s.map((function(e){return e.createdAt}))),!1))&&(!t.previousComplete&&r.prevMessagesCountt.range.bottom||r.nextMessagesCount=e._latestMessageInfo.createdAt&&(u=!1)})),u?(i=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:a.localCacheEnabled}).then((function(e){var t,s,r,a=e.messages,i=e.isContinuousMessages,o=e.hasNext,u=v._filterUnderOffsetMessage(a);v._messages=[],u.length>0?(v._setHasNextAndHasPrevious(u,o),(t=v._syncRange).extends.apply(t,d([],_(u.map((function(e){return e.createdAt}))),!1)),i&&(null===(s=v._backgroundSync)||void 0===s?void 0:s.range.overlap(v._syncRange))&&(null===(r=v._backgroundSync)||void 0===r||r.range.extends(v._syncRange.top,v._syncRange.bottom)),v._addMessagesToView(u,y.REQUEST_MESSAGE)):(v._hasPrevious=!1,v._hasNext=!1),n._invokeResponse("remote",null,u)})).catch((function(e){if(O(e))throw e;n._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(s),n._invokeResponse("remote",null,s)),a.localCacheEnabled&&o.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:i?"cache_hit":"cache_miss",max_db_size:null!==(p=null===(h=a.localCacheConfig)||void 0===h?void 0:h.maxSize)&&void 0!==p?p:0,message_init_policy:e,use_local_cache:a.localCacheEnabled,collection_id:this._key}})),[2]}}))}))}));return o.put(new le({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}})),[2]}}))}))})),n},e.prototype.loadPrevious=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasPrevious?this._isLoadingPrevious?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingPrevious=!0,o=this.viewTop,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{prevLimit:this._prevResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._prevResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h=this;return f(this,(function(p){switch(p.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=p.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top))),u=u.filter((function(e){return fs(h._messages,e)<0})),this._hasPrevious=u.length>=this._prevResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(c=null===(i=e.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==c?c:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=u.length>=this._prevResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingPrevious=!1,[2,u]}}))}))},e.prototype.loadNext=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasNext?this._isLoadingNext?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingNext=!0,o=this.viewBottom,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{nextLimit:this._nextResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._nextResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h,p=this;return f(this,(function(f){switch(f.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=f.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom))),u=u.filter((function(e){return fs(p._messages,e)<0})),this._hasNext=null!==(i=t.hasNext)&&void 0!==i?i:u.length>=this._nextResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(h=null===(c=e.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==h?h:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=u.length>=this._nextResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingNext=!1,[2,u]}}))}))},e.prototype.removeFailedMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return[4,this._channelManager.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,s=this;if(!this._isDisposed){this._isDisposed=!0;var r=P.of(this._iid),a=r.cacheContext,i=r.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(e){e.myMemberState!==Wt.NONE&&(s._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new En({channels:[s._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})))})),a.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}},e}(),Rs=function(t){function n(e,n){return t.call(this,e,s(s({},n),{channelManager:ps.of(e)}))||this}return e(n,t),n.prototype.keyOf=function(e){return e.messageId},n.prototype.initialize=function(e){var n=this;return b((function(){return p(n,void 0,void 0,(function(){var e;return f(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]}}))}))})),t.prototype.initialize.call(this,e)},n.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},n.prototype._activate=function(){return p(this,void 0,void 0,(function(){var e=this;return f(this,(function(n){switch(n.label){case 0:return[4,t.prototype._activate.call(this)];case 1:return n.sent(),[4,b((function(){return p(e,void 0,void 0,(function(){var e;return f(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]}}))}))}))];case 2:return n.sent(),[2]}}))}))},n.prototype._addMessagesToView=function(e,t){var n,s,r=this,a=this._filterUnderOffsetMessage(e),i=[],o=[];try{for(var u=v(a),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===y.SYNC_MESSAGE_FILL){if(l.messageId>0){if((E=fs(this._messages,l))<0){fs(this._unsentMessages,l)<0&&i.push(l);var h=ms(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof qe){(E=fs(this._unsentMessages,l))<0&&fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l))}}else if(l.messageId>0){if((E=fs(this._messages,l))<0){var m=fs(this._unsentMessages,l);m<0?i.push(l):(this._unsentMessages.splice(m,1),o.push(l));h=ms(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[E]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,d([],_(g),!1))}}else if(l instanceof qe){var E;(E=fs(this._unsentMessages,l))<0?fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l)):(o.push(l),this._unsentMessages[E]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,a;return f(this,(function(u){return e={source:t},i.length>0&&(null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===s||s.call(n,e,this.channel,i)),o.length>0&&(null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,e,this.channel,o)),[2]}))}))}))},n.prototype._updateMessagesToView=function(e,t){var n,s,r=this,a=[],i=[],o=[];try{for(var u=v(e),c=u.next();!c.done;c=u.next()){var l,h=c.value;if(h.messageId>0)if((l=fs(this._messages,h))>=0)i.push(h),this._messages[l]=h;else{var m=fs(this._unsentMessages,h);if(m>=0){var g=_(this._unsentMessages.splice(m,1),1)[0];if(this.hasNext&&g)o.push(g);else{i.push(h);var E=ms(this._messages,h);this._messages.splice(E,0,h)}}else{var C=this._messages.map((function(e){return e.createdAt}));(h.createdAtMath.max.apply(Math,d([],_(C),!1))&&!this._hasNext)&&a.push(h)}}else if(h instanceof qe)(l=fs(this._unsentMessages,h))>=0&&(i.push(h),this._unsentMessages[l]=h)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}return ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,u;return f(this,(function(c){return e={source:t},i.length>0?null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,i):o.length>0?null===(u=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===u||u.call(r,e,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t),[2]}))}))})),i},n}(xs),Fs={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},Ps=function(t){function n(e){var n=this,s=e.channelUrl,r=e.token,a=e.limit,i=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=N.GET,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/members"),n.params={token:r,limit:a,order:i,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}(S),ks=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.members=[];var r=n.next,a=n.members;return s.token=r,a&&a.length>0&&(s.members=a.map((function(t){return new tn(e,t)}))),s}return e(n,t),n}(T);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Is||(Is={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(ws||(ws={})),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"}(Ls||(Ls={}));var Os=function(t){function a(e,n,s){var r,a,o,u,c=this;return(c=t.call(this,e,n,i.GROUP,s)||this).mutedMemberFilter=Is.ALL,c.memberStateFilter=Ls.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Zt.ALL,c.order=ws.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(r=s.mutedMemberFilter)&&void 0!==r?r:Is.ALL,c.memberStateFilter=null!==(a=s.memberStateFilter)&&void 0!==a?a:Ls.ALL,c.nicknameStartsWithFilter=null!==(o=s.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=s.order)&&void 0!==u?u:ws.MEMBER_NICKNAME_ALPHABETICAL,c}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&r(Is,this.mutedMemberFilter)&&r(Ls,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&r(Zt,this.operatorFilter)&&r(ws,this.order)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=P.of(this._iid).requestQueue,t=new Ps(n(s(s({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=u.sent(),a=r.as(ks),i=a.members,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(he),Hs=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/accept"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),Vs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.JOINED,s}return e(n,t),n}(T),Gs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.isDistinct,i=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,_=e.customType,p=e.operatorUserIds,f=e.messageSurvivalSeconds;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r)),s.params=t({is_distinct:a,is_public:i,is_discoverable:o,name:h,data:d,custom_type:_,cover_url:u,cover_file:c,access_code:l,operator_ids:p,message_survival_seconds:f}),s}return e(s,n),s}(S),Bs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),qs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s)),n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var zs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var js=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.countPreference,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:r},a}return e(n,t),n}(S),Ws=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.countPreference=n.count_preference,s}return e(n,t),n}(T),Qs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.locale;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r),"/reset_user_history"),s.params=t({locale:a}),s}return e(s,n),s}(S),Ys=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),Ks=s(s({},Ze),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Js=s(s({},et),{scheduledAt:void 0}),Xs=function(s){function r(e){var r,a,i=this;i=s.call(this)||this;var o=[];e.mentionType===de.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((function(e){return e.userId}))));var u=e.channelType,c=e.channelUrl,l=e.scheduledMessageId;return i.method=N.PUT,i.path="".concat(re(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((function(e){return nt.payloadify(e)})),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(a=e.metaArrays)||void 0===a?void 0:a.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})),i}return e(r,s),r}(S),Zs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Ae(e,n),s}return e(n,t),n}(T),$s=function(s){function r(e){var r,a=this;a=s.call(this)||this;var i=[];e.mentionType===de.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return a.method=N.PUT,a.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),a.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(r=e.metaArrays)||void 0===r?void 0:r.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),a}return e(r,s),r}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Te(e,n),s}e(n,t)}(T);var er,tr,nr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.DELETE,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a)),n}return e(n,t),n}(S),sr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.POST,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a),"/send_now"),n}return e(n,t),n}(S),rr=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.pushTriggerOption,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:r},a}return e(n,t),n}(S),ar=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T),ir=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=t.call(this)||this;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),r}return e(n,t),n}(S),or=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T);!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"}(er||(er={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(tr||(tr={}));var ur=function(u){function c(e,t){var n,c,l,h,p,f,v,m,E,C,y,M,b,N,U,S,T,A,I,w,L=this;return(L=u.call(this,e,t)||this)._unreadMemberStateMap=new Map,L._undeliveredMemberStateMap=new Map,L._typingStatus=new Map,L._lastMemberCountUpdated=0,L._typingStarted=0,L._typingEnded=0,L._hasBotInfo={general:!1,ai:!1},L.isDistinct=!1,L.isSuper=!1,L.isBroadcast=!1,L.isExclusive=!1,L.isPublic=!1,L.isDiscoverable=!0,L.isChatNotification=!1,L.isAccessCodeRequired=!1,L.isPushEnabled=!1,L.unreadMessageCount=0,L.unreadMentionCount=0,L.totalUnreadReplyCount=0,L.members=[],L.memberCount=0,L.joinedMemberCount=0,L.hiddenState=tr.UNHIDDEN,L.lastMessage=null,L.messageOffsetTimestamp=0,L.messageSurvivalSeconds=-1,L.myMemberState=Wt.NONE,L.myRole=a.NONE,L.myMutedState=G.UNMUTED,L.myLastRead=0,L.myCountPreference=er.ALL,L.myPushTriggerOption=me.DEFAULT,L.inviter=null,L.invitedAt=0,L.joinedAt=0,L.lastPinnedMessage=null,L._latestMessageInfo=null,L._pinnedMessagesUpdatedAt=0,L._myMutedRemainingTime=-1,L.channelType=i.GROUP,L.isDistinct=null!==(c=t.is_distinct)&&void 0!==c&&c,L.isSuper=null!==(l=t.is_super)&&void 0!==l&&l,L.isBroadcast=null!==(h=t.is_broadcast)&&void 0!==h&&h,L.isExclusive=null!==(p=t.is_exclusive)&&void 0!==p&&p,L.isPublic=null!==(f=t.is_public)&&void 0!==f&&f,L.isDiscoverable=null!==(v=t.is_discoverable)&&void 0!==v?v:L.isPublic,L.isChatNotification=null!==(m=t.is_chat_notification)&&void 0!==m&&m,L.isAccessCodeRequired=null!==(E=t.is_access_code_required)&&void 0!==E&&E,L.isPushEnabled=null!==(C=t.is_push_enabled)&&void 0!==C&&C,Array.isArray(t.members)&&(n=L.members).push.apply(n,d([],_(t.members.map((function(e){return new tn(L._iid,e)}))),!1)),L.memberCount=null!==(y=t.member_count)&&void 0!==y?y:0,L.joinedMemberCount=null!==(M=t.joined_member_count)&&void 0!==M?M:0,L.hiddenState=r(tr,t.hidden_state)?t.hidden_state:tr.UNHIDDEN,L.messageOffsetTimestamp=null!==(b=t.ts_message_offset)&&void 0!==b?b:0,L.messageSurvivalSeconds=null!==(N=t.message_survival_seconds)&&void 0!==N?N:-1,L.lastMessage=t.last_message?Xe(L._iid,s({channel_type:L.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((function(e){g("number",t.read_receipt[e])&&L._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((function(e){g("number",t.delivery_receipt[e])&&L._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),L.myMemberState=r(Wt,t.member_state)?t.member_state:Wt.NONE,L.myRole=r(a,t.my_role)?t.my_role:a.NONE,r(G,t.is_muted)?L.myMutedState=t.is_muted:g("boolean",t.is_muted)?L.myMutedState=t.is_muted?G.MUTED:G.UNMUTED:L.myMutedState=G.UNMUTED,L.myCountPreference=r(er,t.count_preference)?t.count_preference:er.ALL,L.myPushTriggerOption=r(me,t.push_trigger_option)?t.push_trigger_option:me.ALL,L.myLastRead=null!==(U=t.user_last_read)&&void 0!==U?U:0,L.inviter=t.inviter?new o(L._iid,t.inviter):null,L.invitedAt=null!==(S=t.invited_at)&&void 0!==S?S:0,L.joinedAt=null!==(T=t.joined_ts)&&void 0!==T?T:0,L._updateUnreadCount(null!==(A=t.unread_message_count)&&void 0!==A?A:0,null!==(I=t.unread_mention_count)&&void 0!==I?I:0),L.totalUnreadReplyCount=null!==(w=t.total_unread_thread_message_count)&&void 0!==w?w:0,L.lastPinnedMessage=t.latest_pinned_message?Xe(L._iid,s({channel_type:L.channelType},t.latest_pinned_message)):null,t.latest_message&&(L._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),L._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot},L}return e(c,u),Object.defineProperty(c.prototype,"isHidden",{get:function(){return this.hiddenState!==tr.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._unreadMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._undeliveredMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasBot",{get:function(){return this._hasBotInfo.general},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasAiBot",{get:function(){return this._hasBotInfo.ai},enumerable:!1,configurable:!0}),c.payloadify=function(e){return t(n(s(s({},u.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,total_unread_thread_message_count:e.totalUnreadReplyCount,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 tn.payloadify(e)})),last_message:e.lastMessage?at(e.lastMessage):null,inviter:e.inviter?o.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?at(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))},c.prototype._shouldUpdateLastMessageWith=function(e){if(e.silent)return!1;var t=P.of(this._iid).appInfo;switch(null==t?void 0:t.lastMessageThreadingPolicy){case pe.NONE:case pe.INCLUDE_REPLY:break;case pe.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case pe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case fe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},c.prototype._updateLastMessage=function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)},c.prototype._updateUnreadCount=function(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===er.ALL||this.myCountPreference===er.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=P.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===er.ALL||this.myCountPreference===er.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},c.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)},c.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},c.prototype._setLatestMemberCount=function(e,t,n){var s=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,s=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),s},c.prototype.isReadMessage=function(e){var t=P.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt},c.prototype.serialize=function(){var e=this;return R(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))},c.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Rs(this._iid,s(s({},e),{channel:this}))},c.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Os(this._iid,this.url,e)},c.prototype.createThreadedParentMessageListQuery=function(e){return void 0===e&&(e={}),new it(this._iid,this.url,this.channelType,e)},c.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 s=this.members[n];s.state===Wt.JOINED&&(e.state=s.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},c.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof tn?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},c.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof qe&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var s=P.of(this._iid).sdkState,r=e.createdAt,a=0;try{for(var i=v(this.members),o=i.next();!o.done;o=i.next()){var u=o.value;if(s.userId!==u.userId&&u.state===Wt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&a.push(i)}})),a},c.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var s=P.of(this._iid).sdkState;if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var r=e instanceof qe?e.sender:null,a=[];return this.members.forEach((function(i){if(t||i.userId!==s.userId&&i.userId!==(null==r?void 0:r.userId)){var o=n._unreadMemberStateMap.get(i.userId);o&&o=t&&(e._typingStatus.delete(a),s=!0)})),s},c.prototype.refresh=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){return[2,this._refresh()]}))}))},c.prototype._refresh=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return t=P.of(this._iid),n=t.requestQueue,s=t.dispatcher,r=new Nn({channelUrl:this.url}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Un).channel,this._update(i),e||s.dispatch(new En({channels:[i],context:{source:y.REFRESH_CHANNEL}})),[2,this]}}))}))},c.prototype.freeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.freeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.unfreeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.unfreeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.updateChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return t=s(s({},Fs),e),l(function(e){return g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new Gs(s({channelUrl:this.url},t)),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Bs).channel,this._update(u),r.dispatch(new En({channels:[u],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.invite=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return l(e.every((function(e){return e instanceof o}))).throw(h.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},c.prototype.inviteWithUserIds=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(m("string",e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.requestQueue,r=t.sessionManager,a=new Yn({channelUrl:this.url,userIds:e}),[4,s.send(a)];case 1:return i=u.sent(),o=i.as(Kn).channel,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_INVITED,inviter:r.currentUser,invitees:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.join=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new qn({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(zn).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.leave=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return t=P.of(this._iid),n=t.sdkState,s=t.requestQueue,r=new Wn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,s.send(r)];case 1:return a.sent(),this.myMemberState=Wt.NONE,[2]}}))}))},c.prototype.acceptInvitation=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new Hs({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(Vs).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.declineInvitation=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new Xn({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),this.myMemberState=Wt.NONE,[2,this]}}))}))},c.prototype.sendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),ps.of(t._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.updateUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateUserMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendMultipleFilesMessage=function(e){var t=this,n=new ut,s=P.of(this._iid).dispatcher;return u.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){n._trigger(e)})).onFailed((function(e,t){n._triggerFailed(e,t)})).onSucceeded((function(e){var r=ps.of(t._iid);t._updateLastMessage(e),r.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})).onFileUploaded((function(e,t,s,r){n._triggerOnFileUploaded(e,t,s,r)})),n},c.prototype.updateFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateFileMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.deleteMessage=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,u.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&e instanceof qe&&P.of(this._iid).dispatcher.dispatch(new ge({reqId:e.reqId,source:y.EVENT_MESSAGE_DELETED})),[2]}}))}))},c.prototype.hide=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=s(s({},$n),e),l(function(e){return g("boolean",e.hidePreviousMessages,!0)&&g("boolean",e.allowAutoUnhide,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.sdkState,i=n.requestQueue,o=new es(s({channelUrl:this.url,userId:a.userId},t)),[4,i.send(o)];case 1:return u=d.sent(),c=u.as(ts).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.unhide=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=new zs({channelUrl:this.url}),[4,n.send(s)];case 1:return r.sent(),this.hiddenState=tr.UNHIDDEN,t.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.delete=function(){return p(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=P.of(this._iid).requestQueue,t=new qs({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o=this;return f(this,(function(u){switch(u.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.dispatcher,s=e.requestQueue,r=new yt({channelUrl:this.url}),[4,s.send(r)];case 1:return a=u.sent(),i=a.as(Be).readStatus,this._updateUnreadMemberState(t.userId,i.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_READ}})),[2]}}))}))},c.prototype.markAsDelivered=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new cs({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),[2]}}))}))},c.prototype.startTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=n?(this._typingStarted=s,this._typingEnded=0,r=new ss({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.endTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=n?(this._typingStarted=0,this._typingEnded=s,r=new as({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.createScheduledUserMessage=function(e){e=s(s({},ct),e),l(lt(e)).throw(h.invalidParameters);var t=new Ct;return this._createScheduledUserMessage(e,t),t},c.prototype.updateScheduledUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a,i;return f(this,(function(o){switch(o.label){case 0:return n=s(s({},Js),t),l(function(e){return tt(e)&&g("number",e.scheduledAt,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid).requestQueue,a=new $s(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(a)];case 1:return i=o.sent(),[2,i.as(Mt).message]}}))}))},c.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},ht),e),l(dt(e)).throw(h.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new Ct;return ve(bt).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);H((function(){return p(t,void 0,void 0,(function(){return f(this,(function(e){return[2,a._trigger(s)]}))}))}))})),E(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a},c.prototype.updateScheduledFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a;return f(this,(function(i){switch(i.label){case 0:return n=s(s({},Ks),t),l(function(e){return $e(e)&&g("number",e.scheduledAt,!0)&&(E(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(h.invalidParameters),E(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return r=new Xs(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,P.of(this._iid).requestQueue.send(r)];case 3:return a=i.sent(),[2,a.as(Zs).message]}}))}))},c.prototype.cancelScheduledMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new nr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.sendScheduledMessageNow=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new sr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.getMyPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a;return f(this,(function(i){switch(i.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new ir({userId:t.userId,channelUrl:this.url}),[4,n.send(s)];case 1:return r=i.sent(),a=r.as(or).pushTriggerOption,this.myPushTriggerOption=a,[2,a]}}))}))},c.prototype.setMyPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(me,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new rr({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(ar).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.setMyCountPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(er,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new js({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Ws).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.resetMyHistory=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=e.sdkState,r=new Qs({channelUrl:this.url,locale:s.localeForChatbot}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Ys).messageOffsetTimestamp,this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt0:void 0,u.lastRepliedAt=null!==(a=t.last_replied_at)&&void 0!==a?a:0,u.updatedAt=null!==(o=t.updated_at)&&void 0!==o?o:0,u}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{reply_count:r.replyCount,unread_message_count:r.unreadReplyCount,member_count:r.memberCount,most_replies:Array.isArray(r.mostRepliedUsers)?r.mostRepliedUsers.map((function(e){return c.payloadify(e)})):[],push_enabled:"boolean"==typeof r.isPushNotificationEnabled?r.isPushNotificationEnabled?1:0:void 0,last_replied_at:r.lastRepliedAt,updated_at:r.updatedAt})))},Object.defineProperty(i.prototype,"_isUpdateRequired",{get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled},enumerable:!1,configurable:!0}),i.prototype._updateFrom=function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled},i}(l);!function(e){e.ADD="add",e.DELETE="delete"}(Ce||(Ce={}));var xe,De=function(e){this.messageId=0,this.operation=null,this.updatedAt=0;var t=h("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,n=e.user_id,r=e.operation?e.operation.toLowerCase():null,i=e.reaction,s=e.updated_at;t&&h("string",n)&&h("string",r)&&f(Ce,r)&&h("string",i)&&i&&h("number",s)&&(this.messageId=t,this.userId=n,this.key=i,this.operation=r,this.updatedAt=s)},Le=function(){function n(e){var t,n,r,i=e.key,s=null!==(r=p([],m(e.user_ids),!1))&&void 0!==r?r:[],a=e.updated_at;h("string",i)&&i&&d("string",s)&&s.length>0&&h("number",a)&&(this.key=i,this.userIds=s,this.updatedAt=a);var o={};try{for(var u=v(this.userIds),c=u.next();!c.done;c=u.next()){o[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._version=o}return Object.defineProperty(n.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({key:n.key,user_ids:n.userIds,updated_at:n.updatedAt}))},n.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 Ce.ADD:t<0&&this.userIds.push(e.userId);break;case Ce.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},n}(),Fe=function(){function n(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 n.payloadify=function(n){var r,i;return e(t({url:n.url,secure_url:n.secureUrl,type:n.type,width:null!==(r=n.width)&&void 0!==r?r:0,height:null!==(i=n.height)&&void 0!==i?i:0,alt:n.alt}))},n}(),qe=function(){function n(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 Fe(e["og:image"]))}return n.payloadify=function(n){return e(t({"og:title":n.title,"og:url":n.url,"og:description":n.description,"og:image":n.defaultImage?Fe.payloadify(n.defaultImage):null}))},n}(),ze=function(){function n(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 n.prototype.serialize=function(){return{name:this.name,volume:this.volume}},n.payloadify=function(n){return e(t({name:n.name,volume:n.volume}))},n}();!function(e){e.GOOD="good",e.BAD="bad"}(xe||(xe={}));var Be=function(){function n(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}return n._getStatus=function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"},n._isSubmitted=function(e){return"SUBMITTED"===n._getStatus(e)},n._getPayloadByStatus=function(e){return"NO_FEEDBACK"===e?{}:null},n.payloadify=function(n){return e(t({id:n.id,rating:n.rating,comment:n.comment}))},n}(),Ke=function(n){function i(e,t){var r,i=this;return(i=n.call(this,e,t)||this).isBlockedByMe=!1,i.role=f(y,t.role)?t.role:y.NONE,i.isBlockedByMe=null!==(r=t.is_blocked_by_me)&&void 0!==r&&r,i}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{role:r.role,is_blocked_by_me:r.isBlockedByMe})))},i}(c),je=function(){function n(e){this.key=e.key,this.value=d("string",e.value)?p([],m(e.value),!1):[]}return n.payloadify=function(n){var r;return e(t({key:n.key,value:null!==(r=n.value)&&void 0!==r?r:[]}))},n}(),Qe=function(e){switch(e){case g.BASE:return"";case g.USER:return"MESG";case g.FILE:return"FILE";case g.ADMIN:return"ADMM"}},Ge=function(n){function i(e,t){var r,i,s,a,o,u,l,d,h,p=this;(p=n.call(this,e)||this).channelType=I.BASE,p.messageType=g.BASE,p.mentionType=null,p.mentionedUsers=null,p.mentionedUserIds=null,p.mentionedMessageTemplate=void 0,p.metaArrays=[],p.extendedMessage={},p.createdAt=0,p.updatedAt=0,p.channelUrl=t.channel_url,p.channelType=f(I,t.channel_type)?t.channel_type:I.GROUP,t.channel&&(t.channel.channel_url&&(p.channelUrl=t.channel.channel_url),t.channel.channel_type&&(p.channelType=t.channel.channel_type)),p.data=null!==(r=t.data)&&void 0!==r?r:"",p.customType=null!==(i=t.custom_type)&&void 0!==i?i:"",p.mentionType=f(E,t.mention_type)?t.mention_type:null,p.mentionedUsers=t.mentioned_users?t.mentioned_users.map((function(e){return new c(p._iid,e)})):null,p.mentionedUserIds=null!==(s=t.mentioned_user_ids)&&void 0!==s?s:null,p.mentionedUsers&&!p.mentionedUserIds&&(p.mentionedUserIds=p.mentionedUsers.map((function(e){return e.userId}))),p.mentionedMessageTemplate=t.mentioned_message_template;var m=null!==(a=t.metaarray)&&void 0!==a?a:{},v=null!==(o=t.metaarray_key_order)&&void 0!==o?o:Object.keys(m).sort((function(e,t){return e.localeCompare(t)}));p.metaArrays=[];for(var y=0;y0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({id:n.id,name:n.name,items:n.items.map((function(e){return dt.payloadify(e)})),version:n.version,is_submitted:n._isSubmitted}))},n.isMessageFormPayload=function(e){return Boolean(null==e?void 0:e.message_form)},n}(),dt=function(){function n(t){var n=t.id,r=t.name,i=t.required,s=t.sort_order,a=t.placeholder,o=t.style,u=t.item_type,c=t.validators,l=t.value,d=t.values;this.id=n,this.name=r,this.required=i,this.sortOrder=s,this.placeholder=a,0===Object.keys(o).length?this.style={layout:u}:this.style=e({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),d?this.submittedValues=d:l&&(this.submittedValues=[l]),this._validators=c}return n.prototype.isValid=function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case it.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case it.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case it.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case it.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case it.DECIMAL_PLACE:return 0!==e.length&&(n=Number(e),!(isNaN(n)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(n,t.max_decimal_place)));default:return!0}}))}(e,t._validators);return n}))},n.payloadify=function(n){return e(t({id:n.id,name:n.name,required:n.required,sort_order:n.sortOrder,placeholder:n.placeholder,style:e({layout:n.style.layout,options:n.style.options,default_options:n.style.defaultOptions,result_count:n.style.resultCount}),item_type:n.style.layout,validators:n._validators,values:n.submittedValues}))},n}(),ht=function(t){function n(n){var r=t.call(this)||this;return r.method=i.POST,r.path="".concat(S,"/").concat(n.formId,"/submit"),r.params=e({message_id:n.messageId,items:n.items}),r}return r(n,t),n}(a);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ut||(ut={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ct||(ct={}));var ft,pt=function(i){function s(e,t){var n,r,s,a,o,u,c,l,d=this;return(d=i.call(this,e,t)||this).parentMessage=null,d.silent=!1,d.isOperatorMessage=!1,d.threadInfo=null,d.reactions=[],d.appleCriticalAlertOptions=null,d.scheduledInfo=null,d.suggestedReplies=null,d.myFeedback=null,d.myFeedbackStatus="NOT_APPLICABLE",d.messageForm=null,d._isContinuousMessages=!1,d._scheduledStatus=null,d.messageId=null!==(r=null!==(n=t.msg_id)&&void 0!==n?n:t.message_id)&&void 0!==r?r:0,d.parentMessageId=null!==(s="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==s?s:0,d.threadInfo=t.thread_info?new Re(d._iid,t.thread_info):null,d.reactions=t.reactions?t.reactions.map((function(e){return new Le(e)})):[],d.ogMetaData=t.og_tag?new qe(t.og_tag):null,d.silent=null!==(a=t.silent)&&void 0!==a&&a,d.isOperatorMessage=null!==(o=t.is_op_msg)&&void 0!==o&&o,d.appleCriticalAlertOptions=t.apple_critical_alert_options?new ze(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(d.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},d._scheduledStatus=t.scheduled_status),d._isContinuousMessages=null!==(u=t.is_continuous_messages)&&void 0!==u&&u,d.myFeedback=Be._isSubmitted(t.feedback)?new Be(t.feedback):null,d.myFeedbackStatus=Be._getStatus(t.feedback),d.suggestedReplies=null!==(l=null===(c=t.extended_message_payload)||void 0===c?void 0:c.suggested_replies)&&void 0!==l?l:null,d.messageForm=lt.isMessageFormPayload(t.extended_message_payload)?new lt(d.messageId,t.extended_message_payload.message_form):null,d}return r(s,i),s.payloadify=function(n){var r,s;return e(t(u(u({},i.payloadify.call(this,n)),{message_id:n.messageId,parent_message_id:n.parentMessageId,thread_info:n.threadInfo?Re.payloadify(n.threadInfo):null,reactions:n.reactions.map((function(e){return Le.payloadify(e)})),og_tag:n.ogMetaData?qe.payloadify(n.ogMetaData):null,silent:n.silent,is_op_msg:n.isOperatorMessage,apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,scheduled_message_id:null===(r=n.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=n.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:n._scheduledStatus,feedback:n.myFeedback?Be.payloadify(n.myFeedback):Be._getPayloadByStatus(n.myFeedbackStatus)})))},s._getParentMessageInfoPayload=function(n){return e(t({type:Qe(n.messageType),ts:n.createdAt,user:n.sender?Ke.payloadify(n.sender):null,message:n.message,file:{url:n.plainUrl,name:n.name,type:n.type,require_auth:n.requireAuth},files:Array.isArray(n.fileInfoList)?n.fileInfoList.map((function(e){return at.payloadify(e)})):null}))},s.prototype.isIdentical=function(e){return this.messageId===e.messageId},s.prototype.applyThreadInfoUpdateEvent=function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)},s.prototype.applyReactionEvent=function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1},s.prototype._triggerThreadInfoUpdatedEvent=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){return(e=n.of(this._iid).dispatcher).dispatch(new ot({channelType:I.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_THREADINFO_UPDATED})),[2]}))}))},s.prototype.markThreadAsRead=function(){return A(this,void 0,void 0,(function(){var e,t;return U(this,(function(r){switch(r.label){case 0:return e=n.of(this._iid).requestQueue,t=new Xe({channelUrl:this.channelUrl,messageId:this.messageId}),[4,e.send(t)];case 1:return r.sent(),this.threadInfo&&0!==this.threadInfo.unreadReplyCount?(this.threadInfo.unreadReplyCount=0,[4,this._triggerThreadInfoUpdatedEvent()]):[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},s.prototype.setPushNotificationEnabled=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return t=n.of(this._iid).requestQueue,r=new Ze({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),[4,t.send(r)];case 1:return i.sent(),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e),[2]}}))}))},s.prototype.submitMessageForm=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(t=n.of(this._iid).requestQueue,r=null,i=null,s=this.messageForm,!e&&s){if(!s.isSubmittable)throw new O({code:P.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(s.isSubmitted)throw new O({code:P.INVALID_PARAMETER,message:"The form has already been submitted."});r=s.id,i=s.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[])}else e&&(r=e.formId,i=Object.entries(e.answers).reduce((function(e,t){var n=m(t,2),r=n[0],i=n[1],s=Number(r);if(Number.isNaN(s))throw new O({code:P.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:s,value:i}),e}),[]));if(!r||!i)throw new O({code:P.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});return a=new ht({messageId:this.messageId,formId:r,items:i}),[4,t.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.submitFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new $e({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(et),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_ADDED})),[2]}}))}))},s.prototype.updateFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new tt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(nt),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_UPDATED})),[2]}}))}))},s.prototype.deleteFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new rt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e}),[4,r.send(s)];case 1:return a.sent(),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_DELETED})),[2]}}))}))},s}(Ge),mt=function(n){function i(e,t){var r,i,s,a,o=this;if((o=n.call(this,e,t)||this).reqId="",o.replyToChannel=!1,o.errorCode=0,o.sender=t.user?new Ke(o._iid,t.user):t.sender_id,o.reqId=null!==(i=null!==(r=t.req_id)&&void 0!==r?r:t.request_id)&&void 0!==i?i:"",o.replyToChannel=null!==(s=t.is_reply_to_channel)&&void 0!==s&&s,t.request_state&&f(k,t.request_state)&&(o.sendingStatus=t.request_state),!o.sendingStatus)if(o.messageId>0)o.sendingStatus=k.SUCCEEDED;else if(o.scheduledInfo)switch(t.scheduled_status&&(o._scheduledStatus=t.scheduled_status),t.scheduled_status){case ct.SENT:case ct.IN_QUEUE:o.sendingStatus=k.SUCCEEDED;break;case ct.PENDING:o.sendingStatus=k.SCHEDULED;break;case ct.FAILED:case ct.REMOVED:o.sendingStatus=k.FAILED;break;case ct.CANCELED:o.sendingStatus=k.CANCELED}else o.sendingStatus=k.PENDING;return o.errorCode=null!==(a=t.error_code)&&void 0!==a?a:0,o._messageToken=t.mesg_token,o}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{user:Ke.payloadify(r.sender),req_id:r.reqId,is_reply_to_channel:r.replyToChannel,request_state:r.sendingStatus,error_code:r.errorCode,mesg_token:r._messageToken})))},Object.defineProperty(i.prototype,"isResendable",{get:function(){return(this.sendingStatus===k.FAILED||this.sendingStatus===k.CANCELED)&&R(this.errorCode)},enumerable:!1,configurable:!0}),i.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},i}(pt),vt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},yt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)},_t=function(n){function i(r,i){var s,a,o,c,l=this;if((l=n.call(this,r,i)||this).translations={},l.message=null!==(s=i.message)&&void 0!==s?s:"",l.messageType=g.ADMIN,l.translations=null!==(a=i.translations)&&void 0!==a?a:{},i.parent_message_info){var d=i.parent_message_info;l.parentMessage=Mt(r,e(t(u(u({},d),{message_id:l.parentMessageId,channel_url:l.channelUrl,channel_type:l.channelType,file:d.file,url:null===(o=d.file)||void 0===o?void 0:o.url,require_auth:null===(c=d.file)||void 0===c?void 0:c.require_auth}))))}return l}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{message:r.message,translations:r.translations,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i}(pt),gt=function(){function n(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&&h("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return n.payloadify=function(n){return e(t({type:n.type,vendor:n.vendor,detail:n.detail}))},n}(),bt=function(){function t(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}return t.payloadify=function(t){return e({status:t.status,original_message_info:t.originalMessageInfo?{id:t.originalMessageInfo.messageId,ts:t.originalMessageInfo.createdAt}:void 0})},t}(),It=function(n){function i(r,i){var s,a,o,c,l,d,h,f=this;if((f=n.call(this,r,i)||this).message="",f.messageParams=null,f.translations={},f.translationTargetLanguages=[],f.messageSurvivalSeconds=-1,f.plugins=[],f._poll=null,f.message=i.message,f.messageType=g.USER,f.translations=null!==(o=i.translations)&&void 0!==o?o:{},f.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(f.translations).length&&f.translationTargetLanguages.length>0)try{for(var p=v(f.translationTargetLanguages),m=p.next();!m.done;m=p.next()){var y=m.value;f.translations[y]=""}}catch(e){s={error:e}}finally{try{m&&!m.done&&(a=p.return)&&a.call(p)}finally{if(s)throw s.error}}if(f.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,f.plugins=i.plugins?i.plugins.map((function(e){return new gt(e)})):[],f._poll=i.poll?new L(f._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;f.parentMessage=Mt(r,e(t(u(u({},_),{created_at:_.ts,message_id:f.parentMessageId,channel_url:f.channelUrl,channel_type:f.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(f.messageReviewInfo=new bt(i.review_info)),f}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{message:r.message,translations:r.translations,message_survival_seconds:r.messageSurvivalSeconds,plugins:r.plugins.map((function(e){return gt.payloadify(e)})),poll:r._poll?L.payloadify(r._poll):null,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null,review_info:r.messageReviewInfo?bt.payloadify(r.messageReviewInfo):void 0})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(i.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),i}(mt),Et=function(n){function i(r,i){var s,a,o,c,l,d,h,f,p=this;if((p=n.call(this,r,i)||this).messageParams=null,p.fileInfoList=[],p.messageSurvivalSeconds=-1,p.messageType=g.FILE,p.data=null!==(o=null!==(a=null===(s=i.file)||void 0===s?void 0:s.data)&&void 0!==a?a:i.custom)&&void 0!==o?o:"",p.fileInfoList=null!==(l=null===(c=i.files)||void 0===c?void 0:c.map((function(e){return new at(r,e)})))&&void 0!==l?l:[],p.messageSurvivalSeconds=null!==(d=i.message_survival_seconds)&&void 0!==d?d:-1,i.parent_message_info){var m=i.parent_message_info;p.parentMessage=Mt(r,e(t(u(u({},m),{created_at:m.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:m.file,url:null===(h=m.file)||void 0===h?void 0:h.url,require_auth:null===(f=m.file)||void 0===f?void 0:f.require_auth}))))}return p}return r(i,n),i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.payloadify=function(r){var i,s,a,o,c,l;return e(t(u(u({},n.payloadify.call(this,r)),{file:{name:null!==(s=null===(i=r.fileInfoList[0])||void 0===i?void 0:i.fileName)&&void 0!==s?s:"",size:null!==(o=null===(a=r.fileInfoList[0])||void 0===a?void 0:a.fileSize)&&void 0!==o?o:0,type:null!==(l=null===(c=r.fileInfoList[0])||void 0===c?void 0:c.mimeType)&&void 0!==l?l:"",data:r.data},files:Array.isArray(r.fileInfoList)?r.fileInfoList.map((function(e){return at.payloadify(e)})):null,message_survival_seconds:r.messageSurvivalSeconds,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},i._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},i}(mt);!function(e){e.SENT="SENT",e.READ="READ"}(ft||(ft={}));var Tt=function(n){function i(e,t){var r,i,s=this;if((s=n.call(this,e,t)||this).notificationData=null,s.notificationId=t.notification_message_id,s.messageType=g.ADMIN,s.messageStatus=null!==(r=t.message_status)&&void 0!==r?r:ft.SENT,s.priority=null!==(i=t.priority)&&void 0!==i?i:F.NORMAL,s.notificationEventDeadline=t.notification_event_deadline,0===s.extendedMessage.sub_type)try{var a=JSON.parse(s.extendedMessage.sub_data),o=a.label,u=a.tags,c=void 0===u?[]:u,l=a.template_key,d=a.template_variables;s.notificationData={label:o,tags:c,templateKey:l,templateVariables:d}}catch(e){}return s}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{notification_message_id:r.notificationId,message_status:r.messageStatus,priority:r.priority,notification_event_deadline:r.notificationEventDeadline})))},i.prototype.isIdentical=function(e){return this.notificationId===e.notificationId},i}(Ge),wt=function(e){if(e.notificationId)return Tt.payloadify(e);switch(e.messageType){case g.USER:return It.payloadify(e);case g.FILE:return e.fileInfoList?Et.payloadify(e):St.payloadify(e);case g.ADMIN:return _t.payloadify(e);default:throw O.unknown}},Mt=function(e,t){if(t.notification_message_id)return new Tt(e,t);switch(t.type){case"MESG":return new It(e,t);case"FILE":return Et._isMultipleFilesMessagePayload(t)?new Et(e,t):new St(e,t);case"ADMM":case"BRDM":return new _t(e,t);default:return null}},St=function(i){function s(n,r){var s,a,o,c,l,d,h,f,p,m,v,y,_,b,I=this;(I=i.call(this,n,r)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=g.FILE;var E=r.file;if(I.plainUrl=(null!==(a=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==a?a:"").split("?auth=")[0],I.name=null!==(c=null!==(o=null==E?void 0:E.name)&&void 0!==o?o:r.name)&&void 0!==c?c:"File",I.size=null!==(d=null!==(l=null==E?void 0:E.size)&&void 0!==l?l:r.size)&&void 0!==d?d:0,I.data=null!==(f=null!==(h=null==E?void 0:E.data)&&void 0!==h?h:r.custom)&&void 0!==f?f:"",I.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(m=r.type)&&void 0!==m?m:"",I.requireAuth=null!==(v=r.require_auth)&&void 0!==v&&v,I.thumbnails=r.thumbnails?r.thumbnails.map((function(e){var t;return new Oe(I._iid,"string"==typeof e?{url:e,width:0,height:0}:u(u({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),I.requireAuth)})):[],I.messageSurvivalSeconds=null!==(y=r.message_survival_seconds)&&void 0!==y?y:-1,r.parent_message_info){var T=r.parent_message_info;I.parentMessage=Mt(n,e(t(u(u({},T),{created_at:T.ts,message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:T.file,url:null===(_=T.file)||void 0===_?void 0:_.url,require_auth:null===(b=T.file)||void 0===b?void 0:b.require_auth}))))}return I}return r(s,i),s.payloadify=function(n){var r;return e(t(u(u({},i.payloadify.call(this,n)),{url:n.plainUrl,require_auth:n.requireAuth,file:{name:n.name,size:n.size,type:n.type,data:n.data},thumbnails:null===(r=n.thumbnails)||void 0===r?void 0:r.map((function(e){return{url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:n.messageSurvivalSeconds,parent_message_info:n.parentMessage?i._getParentMessageInfoPayload.call(this,n.parentMessage):null})))},Object.defineProperty(s.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},s}(mt),At=function(e){function t(t,n){var r=n.file,i=n.fileUrl,s=n.fileName,a=n.fileSize,o=n.mimeType,u=n.thumbnailSizes,c=n._uploadedMetaData,l=n._thumbnails,d=e.call(this,t)||this;return d._plainUrl=i,d.file=r,d.fileName=s,d.fileSize=a,d.mimeType=o,d.thumbnailSizes=u,d._uploadedMetaData=c,d._thumbnails=l,d}return r(t,e),t.getPlainUrl=function(e){return e instanceof t?e._plainUrl:e.fileUrl},Object.defineProperty(t.prototype,"fileUrl",{get:function(){var e,t=n.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}},t}(l),Ut=function(n){function i(r){var i,s,a,o,u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,files:r.files?Pt(r.files):null,url:r.url,name:null!==(i=r.fileName)&&void 0!==i?i:"",type:null!==(s=r.mimeType)&&void 0!==s?s:"",size:null!==(a=r.fileSize)&&void 0!==a?a:0,custom:r.data,custom_type:r.customType,thumbnails:null===(o=r._thumbnails)||void 0===o?void 0:o.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:u,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,pin_message:r.isPinnedMessage}))})||this}return r(i,n),i}(T),Nt=function(n){function s(r){var s,a,o=this;o=n.call(this)||this;var u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),o.method=i.POST,o.path="".concat(w(r.channelType),"/").concat(encodeURIComponent(r.channelUrl),"/messages"),o.params=e(t({message_type:g.FILE,user_id:r.userId,files:r.files?Pt(r.files):null,url:r.fileUrl,mention_type:r.mentionType,mentioned_user_ids:u,file_name:r.fileName,file_size:r.fileSize,file_type:r.mimeType,data:r.data,custom_type:r.customType,thumbnails:null===(s=r._thumbnails)||void 0===s?void 0:s.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,sorted_metaarray:null===(a=r.metaArrays)||void 0===a?void 0:a.map((function(e){return je.payloadify(e)})),push_option:r.pushNotificationDeliveryOption,parent_message_id:r.parentMessageId?r.parentMessageId:null,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,reply_to_channel:r.isReplyToChannel,req_id:r.reqId,pin_message:r.isPinnedMessage})),o}return r(s,n),s}(a),Ct=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"FILE",i)||this).message=i.files&&i.files.length>=2?new Et(t,i):new St(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),Ot=function(e){function t(t,r){var i,s,a,o,u=this;(u=e.call(this,t,r)||this).message=r.files&&r.files.length>=2?new Et(t,r):new St(t,r);var c=n.of(t).sdkState;return u.isMentioned=z(u.message.mentionType,null!==(a=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(s=u.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return r(t,e),t}(o);function Pt(n){return n.map((function(n){var r,i;return e(t({url:At.getPlainUrl(n),file_name:n.fileName,file_type:n.mimeType,file_size:n.fileSize,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),require_auth:null===(i=n._uploadedMetaData)||void 0===i?void 0:i.requireAuth}))}))}var kt;!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"}(kt||(kt={}));var Rt=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext,o=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=a,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof K&&(o._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===j.CONNECTED||this._connectionState===j.CONNECTING||this._connectionState===j.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){switch(s.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(r=new Ut(n),[4,this._requestQueue.send(r)]):[3,2];case 1:return i=s.sent(),[2,i.as(Ct).message];case 2:return r=new Nt(u(u({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),[2,i.as(Ot).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=u(u({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{r=t.params;n.url=r.fileUrl,n.requireAuth=r.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p;return U(this,(function(m){switch(m.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,r=[],i=!0,m.label=1;case 1:m.trys.push([1,15,16,17]),s=v(n.messageQueue),a=s.next(),m.label=2;case 2:if(a.done)return[3,14];switch(o=a.value,o.state){case kt.PENDING:case kt.UPLOADING:return[3,3];case kt.UPLOADED:return[3,4];case kt.FAILED:return[3,12]}return[3,13];case 3:return i=!1,r.push(o),[3,13];case 4:if(!i)return[3,10];m.label=5;case 5:return m.trys.push([5,8,,9]),o.state=kt.SENDING,[4,this._sendFileMessage(e,o)];case 6:return u=m.sent(),o.deferred.resolve(u),[4,Q(100)];case 7:return m.sent(),[3,9];case 8:return c=m.sent(),o.deferred.reject(c),[3,9];case 9:return[3,11];case 10:r.push(o),m.label=11;case 11:return[3,13];case 12:return l=null!==(t=o.error)&&void 0!==t?t:O.unknown,o.deferred.reject(l.code===P.REQUEST_CANCELED?O.fileUploadCanceled:l),[3,13];case 13:return a=s.next(),[3,2];case 14:return[3,17];case 15:return d=m.sent(),f={error:d},[3,17];case 16:try{a&&!a.done&&(p=s.return)&&p.call(s)}finally{if(f)throw f.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:m.sent(),m.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,m.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d;return U(this,(function(h){switch(h.label){case 0:return(n=this._queueMap.get(e.url))&&(r=n.messageQueue.find((function(e){return e.state===kt.PENDING})))?r.multipleFileUploadInfo?(i=r.multipleFileUploadInfo,s=i.uploadIndex,a=i.uploadCount,o=i.requestHandler,d=r.params,u=d.fileInfoList[s],!G(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]):[3,4]:[3,9];case 1:return h.sent(),[3,3];case 2:r.state=s=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,u,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return a=new Pe({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(a)];case 1:return o=v.sent(),u=o.as(ke),c=u.url,l=u.fileSize,d=void 0===l?n.fileSize:l,h=u.thumbnails,f=void 0===h?[]:h,p=u.requireAuth,m=void 0!==p&&p,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(i=n.mimeType)&&void 0!==i?i:n.file.type,n.fileSize=null!==(s=n.fileSize)&&void 0!==s?s:n.file.size,n.fileUrl=c,n.fileSize=d,n.requireAuth=m,n._thumbnails=f,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,c,l,d,h,f,p,m,v,y;return U(this,(function(_){switch(_.label){case 0:return a=t.multipleFileUploadInfo.uploadIndex,o=n.fileInfoList[a],c=new Pe({file:o.file,channelUrl:e.url,thumbnailSizes:o.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(c)];case 1:return l=_.sent(),d=l.as(ke),h=d.url,f=d.fileSize,p=void 0===f?o.fileSize:f,m=d.thumbnails,v=d.requireAuth,y=void 0!==v&&v,o.fileName=null!==(r=o.fileName)&&void 0!==r?r:o.file.name,o.mimeType=null!==(i=o.mimeType)&&void 0!==i?i:o.file.type,o.fileSize=null!==(s=o.fileSize)&&void 0!==s?s:o.file.size,o.file=void 0,o.fileUrl=h,o.fileSize=p,o._thumbnails=m,o._uploadedMetaData=u(u({},o._uploadedMetaData),{requireAuth:y,isUploaded:!0}),o instanceof At||(n.fileInfoList[a]=new At(this._iid,o)),[2]}}))}))},e.prototype.request=function(e,t,n,r){return void 0===r&&(r={}),A(this,void 0,void 0,(function(){var i,s,a,o,c;return U(this,(function(l){return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),a=new V,o={requestId:t,params:n,state:kt.PENDING,deferred:a},function(e){return"fileInfoList"in e}(n)&&(c=u({uploadIndex:0,uploadCount:n.fileInfoList.length},r),o.multipleFileUploadInfo=c),s.messageQueue.push(o),this._uploadNextPendingItem(e),[2,a.promise]}))}))},e.prototype.cancel=function(e,t){var n,r,i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:p([],m(i.messageQueue),!1);try{for(var a=v(s),o=a.next();!o.done;o=a.next()){var u=o.value;if(u)switch(u.state){case kt.PENDING:if(u.state=kt.FAILED,u.error=O.requestCanceled,u.multipleFileUploadInfo&&!u.multipleFileUploadInfo.isCopy){var c=u.multipleFileUploadInfo,l=c.uploadIndex,d=c.requestHandler,h=u.params.fileInfoList[l];null==d||d._triggerOnFileUploaded(u.requestId,l,h,O.fileUploadCanceled)}this._resolveMessageQueue(e);break;case kt.UPLOADING:this._requestQueue.cancel(u.requestId),this._dispatcher.dispatch(new B({requestId:u.requestId}))}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new B({requestId:t})))},e}();var xt,Dt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:H.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Lt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&f(H,e.replyType)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)&&h("boolean",e.showSubchannelMessagesOnly)},Ft={replyType:H.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},qt=function(e){return f(H,e.replyType)&&h("boolean",e.includeReactions)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)},zt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.includeMetaArray,o=t.includeReactions,u=t.includeThreadInfo,c=t.includeParentMessageInfo,l=e.call(this)||this;return l.method=i.GET,l.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s)),l.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions:o,include_thread_info:u,include_parent_message_info:c,include_poll_details:!0},l}return r(t,e),t}(a),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o),Kt=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.timestamp,u=r.token,c=r.prevResultSize,l=r.nextResultSize,d=r.isInclusive,h=r.reverse,f=r.messageTypeFilter,p=r.customTypesFilter,m=r.senderUserIdsFilter,v=r.replyType,y=r.includeMetaArray,_=r.includeReactions,g=r.parentMessageId,b=r.includeThreadInfo,I=r.includeParentMessageInfo,E=r.showSubchannelMessagesOnly,T=r.checkingHasNext,M=r.checkingContinuousMessages,S=n.call(this)||this;return S.method=i.GET,S.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages"),S.params=e(t({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:m,include_reply_type:v,with_sorted_meta_array:y,include_reactions:_,parent_message_id:g,include_thread_info:b,include_parent_message_info:I,show_subchannel_message_only:E,include_poll_details:!0,checking_has_next:T,checking_continuous_messages:M})),S}return r(s,n),s}(a),jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return void 0!==n.is_continuous_messages&&(r.isContinuousMessages=n.is_continuous_messages),void 0!==n.has_next&&(r.hasNext=n.has_next),r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),Qt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.timestamp,a=t.token,o=t.replyType,u=t.includeMetaArray,c=t.includeReactions,l=t.includeThreadInfo,d=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=i.GET,h.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:s,token:a,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_reply_type:o,include_parent_message_info:d,include_poll_details:!0},h}return r(t,e),t}(a),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return Mt(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return r(t,e),t}(o),Vt=function(e){function t(t){var n=t.channelUrl,r=t.scheduledMessageId,s=e.call(this)||this;return s.method=i.GET,s.path="".concat(W,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),s.params={},s}return r(t,e),t}(a),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o);!function(e){e.MUTED="muted",e.BANNED="banned"}(xt||(xt={}));var Wt=function(){function n(e){var t,n,r,i;this.restrictionType=null,f(xt,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(r=null!==(n=e.end_at)&&void 0!==n?n:e.muted_end_at)&&void 0!==r?r:-1,this.remainingDuration=null!==(i=e.remaining_duration)&&void 0!==i?i:-1}return n.payloadify=function(n){return e(t({restriction_type:n.restrictionType,description:n.description,end_at:n.endAt,remaining_duration:n.remainingDuration}))},n}(),Yt=function(n){function i(e,t){var r=n.call(this,e,t)||this;return r.restrictionInfo=new Wt(t),r}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),Wt.payloadify(r.restrictionInfo))))},i}(c),Jt=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return r(t,e),t}(c),Xt=function(){function e(){this._onPending=Y,this._onFailed=Y,this._onSucceeded=Y}return e.prototype._trigger=function(e){switch(null==e?void 0:e.sendingStatus){case k.PENDING:0===e.errorCode&&this._onPending(e);break;case k.SCHEDULED:case k.SUCCEEDED:this._onSucceeded(e)}},e.prototype._triggerFailed=function(e,t){switch(null==t?void 0:t.sendingStatus){case k.FAILED:case k.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}(),Zt={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},$t=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(je,e.metaArrays,!0)&&h("number",e.parentMessageId,!0)&&h("boolean",e.isReplyToChannel)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)&&h("boolean",e.isPinnedMessage,!0)},en=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},tn=u(u({},Zt),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function nn(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var rn,sn=function(n){var r;return e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,pollId:null===(r=n.poll)||void 0===r?void 0:r.id,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,message:n.message,translationTargetLanguages:Object.keys(n.translations),extendedMessagePayload:n.extendedMessagePayload}))},an=function(e){return $t(e)&&h("string",e.message)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)&&h("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(rn||(rn={}));var on=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},un=function(e){return e===rn.BLOB||e===rn.FILE},cn=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},ln=u(u({},Zt),{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});function dn(e){var n,r,i,s;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=e.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails}))}var hn,fn=function(n,r){var i;return n.messageParams?(!n.url&&G(r)&&(n.messageParams.file=r),n.messageParams):e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,file:r,fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,thumbnailSizes:null===(i=n.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))},pn=function(e){return $t(e)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},mn={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},vn=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(je,e.metaArrays,!0)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)},yn=u(u({},mn),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),_n=function(e){return vn(e)&&h("string",e.message,!0)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)},gn=u({},mn),bn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.token,a=t.limit,o=e.call(this)||this;return o.method=i.GET,o.path="".concat(w(r),"/").concat(encodeURIComponent(n),"/operators"),o.params={token:s,limit:a},o}return r(t,e),t}(a),In=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new c(t,e)})),r.token=n.next,r}return r(t,e),t}(o),En=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=n.of(this._iid).requestQueue,r=new bn(u(u({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(r)]):[3,2]):[3,5];case 1:return i=c.sent(),s=i.as(In),a=s.operators,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),Tn=function(e){function n(t,n,r,i){var s,a,o,u,c,l,d,h,f,p,m=this;return(m=e.call(this,t,n,r,i)||this).reverse=!1,m.messageTypeFilter=x.ALL,m.customTypesFilter=null,m.senderUserIdsFilter=null,m.replyType=H.NONE,m.includeMetaArray=!1,m.includeReactions=!1,m.includeParentMessageInfo=!1,m.includeThreadInfo=!1,m.showSubchannelMessagesOnly=!1,m._edge=Number.MAX_SAFE_INTEGER,m.reverse=null!==(s=i.reverse)&&void 0!==s&&s,m.messageTypeFilter=null!==(a=i.messageTypeFilter)&&void 0!==a?a:x.ALL,m.customTypesFilter=null!==(o=i.customTypesFilter)&&void 0!==o?o:null,m.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,m.replyType=null!==(c=i.replyType)&&void 0!==c?c:H.NONE,m.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,m.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,m.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,m.includeThreadInfo=null!==(f=i.includeThreadInfo)&&void 0!==f&&f,m.showSubchannelMessagesOnly=null!==(p=i.showSubchannelMessagesOnly)&&void 0!==p&&p,m}return r(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.reverse)&&f(x,this.messageTypeFilter)&&f(H,this.replyType)&&d("string",this.customTypesFilter,!0)&&d("string",this.senderUserIdsFilter,!0)&&h("boolean",this.includeMetaArray)&&h("boolean",this.includeReactions)&&h("boolean",this.includeParentMessageInfo)&&h("boolean",this.includeThreadInfo)&&h("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,ea.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t({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=n.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 O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},n}(J),wn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.limit,o=t.token;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:o},n}return r(t,e),t}(a),Mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.mutedUsers=[];var i=n.next,s=n.muted_list;return r.token=i,s&&s.length>0&&(r.mutedUsers=s.map((function(e){return new Yt(t,e)}))),r}return r(t,e),t}(o),Sn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new wn(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Mn),s=i.mutedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),An=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.limit,u=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({limit:o,token:u}),r}return r(n,t),n}(a),Un=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map((function(e){return new Yt(t,e.user)}))),r}return r(t,e),t}(o),Nn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new An(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Un),s=i.bannedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(hn||(hn={}));var Cn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var On=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var Pn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return r(t,e),t}(a),kn=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,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return r(t,e),t}(o),Rn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return r(t,e),t}(a),xn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),Dn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return r(t,e),t}(a),Ln=function(e){function t(t,n){var r,i,s=this;return(s=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},s.ts=null!==(i=n.ts)&&void 0!==i?i:null,s}return r(t,e),t}(o),Fn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata,o=t.upsert;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=o&&o},n}return r(t,e),t}(a),qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),zn=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 r(t,e),t}(M),Bn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return r(t,e),t}(a),Kn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),jn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return r(t,e),t}(a),Qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),Gn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return r(t,e),t}(a),Vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Hn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return r(t,e),t}(a),Wn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Yn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter,o=t.upsert,u=void 0!==o&&o,c=t.mode,l=void 0===c?"set":c;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:u,mode:l},n}return r(t,e),t}(a),Jn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Xn=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 r(t,e),t}(M),Zn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params={},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var $n=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var er=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId,o=t.seconds,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:o,description:u},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var tr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),nr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var rr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ir=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.userId,u=n.seconds,c=n.description;return(r=t.call(this)||this).method=i.POST,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({user_id:o,seconds:u,description:c}),r}return r(n,t),n}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var sr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(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 r(t,e),t}(M),ar=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var or=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ur=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var cr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return r(t,e),t}(M),lr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(X(s),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:o,report_description:u},n}return r(t,e),t}(a),dr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.offendingUserId,c=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(Z,"/users/").concat(u),n.params={channel_url:r,channel_type:s===I.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:o,report_description:c},n}return r(t,e),t}(a),hr=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.category,u=n.userId,c=n.offendingUserId,l=n.messageId,d=n.description,h=n.messageToken;return(r=t.call(this)||this).method=i.POST,r.path="".concat(X(a),"/").concat(encodeURIComponent(s),"/messages/").concat(l),r.params=e({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),r}return r(n,t),n}(a),fr=function(n){function i(r){var i=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,poll_id:r.pollId,pin_message:r.isPinnedMessage,extended_message_payload:r.extendedMessagePayload}))})||this}return r(i,n),i}(T),pr=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"MESG",i)||this).message=new It(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),mr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,poll_id:r.pollId}))})||this}return r(i,n),i}(T),vr=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"MEDI",s)||this).message=new It(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),yr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,apple_critical_alert_options:r.appleCriticalAlertOptions}))})||this}return r(i,n),i}(T),_r=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"FEDI",s)||this).message=new St(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),gr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),br=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(n),r}return r(t,e),t}(o),Ir=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.DELETE,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),Er=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(u({},n)),r}return r(t,e),t}(o),Tr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.translationTargetLanguages,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s),"/translation"),o.params={target_langs:a},o}return r(t,e),t}(a),wr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Mr=function(n){function s(r){var s,a=this;a=n.call(this)||this;var o=[];r.mentionType===E.USERS&&(r.mentionedUserIds?o=r.mentionedUserIds:r.mentionedUsers&&(o=r.mentionedUsers.map((function(e){return e.userId}))));var u=r.channelType,c=r.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=e(t({req_id:r.reqId,scheduled_at:r.scheduledAt,message_type:ee.USER,message:r.message,custom_type:r.customType,data:r.data,mention_type:r.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=r.metaArrays)||void 0===s?void 0:s.map((function(e){return je.payloadify(e)})),apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption})),a}return r(s,n),s}(a),Sr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Ar=function(e){function n(n){var r,s,a=this;a=e.call(this)||this;var o=[];n.mentionType===E.USERS&&(n.mentionedUserIds?o=n.mentionedUserIds:n.mentionedUsers&&(o=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=t({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ee.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=n.metaArrays)||void 0===s?void 0:s.map((function(e){return je.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,push_option:n.pushNotificationDeliveryOption}),a}return r(n,e),n}(a),Ur=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new St(t,n),r}return r(t,e),t}(o),Nr=function(e){function t(t){var n=t.pollId,r=t.title,s=t.data,a=t.allowUserSuggestion,o=t.allowMultipleVotes,u=t.closeAt,c=e.call(this)||this;return c.method=i.PUT,c.path="".concat(ne,"/").concat(encodeURIComponent(n)),c.params={title:r,data:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return r(t,e),t}(a),Cr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Or=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.DELETE,r.path="".concat(ne,"/").concat(encodeURIComponent(n)),r}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var Pr=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.PUT,r.path="".concat(ne,"/").concat(encodeURIComponent(n),"/close"),r}return r(t,e),t}(a),kr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Rr=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.pollId,a=t.optionText,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(ne,"/").concat(encodeURIComponent(s),"/options"),o.params={channel_url:n,channel_type:r,text:a},o}return r(t,e),t}(a),xr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Dr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=t.optionText,a=e.call(this)||this;return a.method=i.PUT,a.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:s},a}return r(t,e),t}(a),Lr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Fr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=e.call(this)||this;return s.method=i.DELETE,s.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var qr=function(t){function n(n){var r=n.reqId,i=n.channelType,s=n.channelUrl,a=n.pollId,o=n.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:e({req_id:r,channel_type:i===I.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:a,option_ids:o})})||this}return r(n,t),n}(T),zr=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=new re(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return r(t,e),t}(M),Br=100,Kr="GroupChannel",jr="url",Qr=100,Gr="Message",Vr="messageId",Hr=100,Wr="NotificationMessage",Yr="notificationId",Jr="Poll",Xr="pollId",Zr=100,$r="FeedChannel",ei="url";function ti(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((function(e){var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))}var ni=u(u({},Zt),{fileInfoList:[]}),ri=function(e){return(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},ii=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._onFileUploaded=Y,t}return r(t,e),t.prototype._triggerOnFileUploaded=function(e,t,n,r){this._onFileUploaded(e,t,n,r)},t.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},t.prototype.onPending=function(t){return e.prototype.onPending.call(this,t),this},t.prototype.onFailed=function(t){return e.prototype.onFailed.call(this,t),this},t.prototype.onSucceeded=function(t){return e.prototype.onSucceeded.call(this,t),this},t}(Xt),si=function(e){function t(t,n){var r=e.call(this,t)||this;return r.message=null,r.message=Mt(t,n.message),r}return r(t,e),t}(l),ai=function(t){function n(n){var r=this,s=n.channelType,a=n.channelUrl,o=n.limit,u=n.token,c=n.includeReactions,l=n.includeMetaArray,d=n.includeParentMessageInfo,h=n.includeThreadInfo,f=n.includePollDetails;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/pinned_messages"),r.params=e({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),r}return r(n,t),n}(a),oi=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.pinned_messages,s=n.has_more,a=n.next;return r.pinnedMessages=i.map((function(e){return new si(t,e)})),r.hasMore=s,r.token=a,r}return r(t,e),t}(o),ui=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s.includeMetaArray=i.includeMetaArray,s.includeReactions=i.includeReactions,s.includeParentMessageInfo=i.includeParentMessageInfo,s.includeThreadInfo=i.includeThreadInfo,s.includePollDetails=i.includePollDetails,s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.includeMetaArray,!0)&&h("boolean",this.includeReactions,!0)&&h("boolean",this.includeParentMessageInfo,!0)&&h("boolean",this.includeThreadInfo,!0)&&h("boolean",this.includePollDetails,!0)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new ai(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=c.sent(),i=r.as(oi),s=i.pinnedMessages,a=i.hasMore,o=i.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ci=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.POST,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var li=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.DELETE,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var di,hi=2;!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(di||(di={}));var fi,pi=function(i){function s(e,t){var n,r,s,a,o,u,l,d=this;return(d=i.call(this,e)||this)._name="",d._createdAt=0,d.pinnedMessageIds=[],d.channelType=I.BASE,d.coverUrl="",d.customType="",d.data="",d.isFrozen=!1,d.isEphemeral=!1,d.creator=null,d._messageCollectionLastAccessedAt=0,d._url=t.channel_url,d._name=null!==(n=t.name)&&void 0!==n?n:"",d._createdAt=1e3*t.created_at,d.coverUrl=null!==(r=t.cover_url)&&void 0!==r?r:"",d.customType=null!==(s=t.custom_type)&&void 0!==s?s:"",d.data=null!==(a=t.data)&&void 0!==a?a:"",d.isFrozen=null!==(o=t.freeze)&&void 0!==o&&o,d.isEphemeral=null!==(u=t.is_ephemeral)&&void 0!==u&&u,d.creator=t.created_by?new c(d._iid,t.created_by):null,t.metadata&&Object.keys(t.metadata).length>0&&t.ts?(d._cachedMetaData=new Map,Object.keys(t.metadata).forEach((function(e){d._cachedMetaData.set(e,{value:t.metadata[e],isRemoved:!1,updatedAt:t.ts})}))):"string"==typeof t.metadata&&(d._cachedMetaData=new Map(Object.entries(JSON.parse(t.metadata)))),d.pinnedMessageIds=null!==(l=t.pinned_message_ids)&&void 0!==l?l:[],d}return r(s,i),Object.defineProperty(s.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),s.prototype.toJSON=function(){return u(u({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},s.payloadify=function(n){return e(t(u(u({},i.payloadify.call(this,n)),{channel_url:n.url,name:n.name,cover_url:n.coverUrl,custom_type:n.customType,data:n.data,freeze:n.isFrozen,is_ephemeral:n.isEphemeral,created_by:n.creator?c.payloadify(n.creator):null,created_at:n.createdAt/1e3,metadata:n.cachedMetaData,pinned_message_ids:n.pinnedMessageIds})))},s.prototype.isGroupChannel=function(){return this.channelType===I.GROUP},s.prototype.isOpenChannel=function(){return this.channelType===I.OPEN},s.prototype.isFeedChannel=function(){return this.channelType===I.FEED},Object.defineProperty(s.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(s.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),s.prototype._serializeCachedMetaData=function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}},s.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},s.prototype._update=function(t){var n=e(t);Object.assign(this,n)},s.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})}))},s.prototype._updateCachedMetaData=function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(i,s){var a;i.updatedAt<=t&&(n._cachedMetaData.set(s,{value:null!==(a=e[s])&&void 0!==a?a:i.value,isRemoved:!e[s],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}},s.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0})),s=new Et(this._iid,i);return s.messageParams=t,s},s.prototype._validateFailedFileMessageHasFile=function(e,t){var n;return Boolean(e.url)||G(t)||G(null===(n=e.messageParams)||void 0===n?void 0:n.file)},s.prototype._createPendingScheduledFileMessage=function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r},s.prototype._markMessageAsFailed=function(e,t,n){void 0===n&&(n=!1),e.errorCode=t.code,t.code===P.REQUEST_CANCELED||t.code===P.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=k.CANCELED:n||(e.sendingStatus=k.FAILED)},s.prototype.sendUserMessage=function(e){var t=u(u({},tn),e);return D(an(t)).throw(O.invalidParameters),this._sendUserMessage(t)},s.prototype._sendUserMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,c=null!=r?r:this._generateRequestId(),l=Date.now(),d=new Xt;return Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l);a.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(r)]}))}))}));var s=new fr(u(u({},e),{channelUrl:i.url,channelType:i.channelType,reqId:c}));o.send(s).then((function(e){var t=e.as(pr).message;a.dispatch(new N({messages:[t],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(t)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l),s=n.of(i._iid).cacheContext,o=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,o),a.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._triggerFailed(t,r)]}))}))}))}))}))})),d},s.prototype._autoResendUserMessage=function(e){return D(e instanceof It&&!!e.messageParams).throw(O.invalidParameters),this._sendUserMessage(e.messageParams,di.SEND,e.reqId)},s.prototype.resendUserMessage=function(e){var t;return A(this,void 0,void 0,(function(){var n,r;return U(this,(function(i){return D(e instanceof It&&!e.scheduledInfo).throw(O.invalidParameters),n=new V,r=null!==(t=e.messageParams)&&void 0!==t?t:sn(e),this._sendUserMessage(r,di.RESEND,e.reqId).onFailed((function(e){return n.reject(e)})).onSucceeded((function(e){return n.resolve(e)})),[2,n.promise]}))}))},s.prototype.updateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},yn),t),D(h("number",e)&&_n(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new mr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(vr).message]}}))}))},s.prototype.copyUserMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof It&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),D(!n.poll).throw(O.notSupportedError),o=new V,c=null!==(r=n.messageParams)&&void 0!==r?r:t(u(u({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(a=n.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),e._sendUserMessage(c).onSucceeded((function(e){o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.translateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof It&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Tr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(wr).message]}}))}))},s.prototype._createScheduledUserMessage=function(e,t){var r=this,i=n.of(this._iid).requestQueue,s=Date.now(),a=this._generateRequestId();Q(2).then((function(){var n=r._createPendingScheduledUserMessage(e,a,s);ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))}));var o=new Mr(u({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(o).then((function(e){var n=e.as(Sr).message;ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var i=r._createPendingScheduledUserMessage(e,a,s);r._markMessageAsFailed(i,n),ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,i)]}))}))}))}))}))},s.prototype.sendFileMessage=function(e){var t=u(u({},ln),e);return D(pn(t)).throw(O.invalidParameters),this._sendFileMessage(t)},s.prototype.sendMultipleFilesMessage=function(e){var t,r=u(u({},ni),e),i=n.of(this._iid);D(function(e,t){return void 0===t&&(t=ie),$t(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return ri(e)}))}(r,null===(t=i.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(O.invalidParameters);var s=!!e.fileInfoList.find((function(e){var t=i.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return D(!s).throw(O.fileSizeLimitExceededError),this._sendMultipleFilesMessage(r)},s.prototype._sendFileMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid).dispatcher,a=ea.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new Xt;return Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u);s.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(r)]}))}))})),a.request(i,o,e).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u),a=n.of(i._iid).cacheContext,l=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,l),s.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:t.code===P.FILE_UPLOAD_CANCEL_FAILED?C.LOCAL_MESSAGE_CANCELED:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,r)]}))}))}))}))}))})),c},s.prototype._autoResendFileMessage=function(e){D(e instanceof St&&!!e.messageParams).throw(O.invalidParameters);var t=n.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,di.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},s.prototype._sendMultipleFilesMessage=function(e,t,r){var i=this,s=n.of(this._iid).dispatcher,a=ea.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new ii;return Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);s.dispatch(new N({messages:[n],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(n)]}))}))})),a.request(i,o,e,{requestHandler:c,isCopy:t===di.COPY}).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);i._markMessageAsFailed(n,t),s.dispatch(new N({messages:[n],source:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,n)]}))}))}))}))}))})),c},s.prototype._createScheduledFileMessage=function(e,t,r,i){var s=this,a=n.of(this._iid).requestQueue,o=new Ar(u(u({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(Ur).message;ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var a=s._createPendingScheduledFileMessage(e,r,i);s._markMessageAsFailed(a,n),ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,a)]}))}))}))}))}))},s.prototype.sendFileMessages=function(e){var t,n;D(e.every((function(e){return pn(u(u({},ln),e))}))).throw(O.invalidParameters);var r=new Xt;try{for(var i=v(e),s=i.next();!s.done;s=i.next()){var a=s.value;this.sendFileMessage(a).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{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},s.prototype.resendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){return n=this._validateFailedFileMessageHasFile(e,t),D(e instanceof St&&n&&!e.scheduledInfo).throw(O.invalidParameters),r=new V,i=fn(e,t),this._sendFileMessage(i,di.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),[2,r.promise]}))}))},s.prototype.resendMessage=function(e,t){var n,r;if(D(e instanceof mt&&!e.scheduledInfo&&e.isResendable).throw(O.invalidParameters),e.isUserMessage()){var i=null!==(n=e.messageParams)&&void 0!==n?n:sn(e);return this._sendUserMessage(i,di.RESEND,e.reqId)}if(e.isFileMessage()){var s=this._validateFailedFileMessageHasFile(e,t);D(s).throw(O.invalidParameters);i=null!==(r=e.messageParams)&&void 0!==r?r:fn(e,t);return this._sendFileMessage(i,di.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.updateFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},gn),t),D(h("number",e)&&function(e){return vn(e)}(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new yr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(_r).message]}}))}))},s.prototype.uploadFile=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=n.of(this._iid).requestQueue,r=se(),(i=new Pe({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:r})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(r),[4,t.send(i)];case 1:return s=c.sent(),a=s.as(ke),o=a.url,u=a.thumbnails,[2,{requestId:r,url:o,thumbnails:u}]}}))}))},s.prototype.cancelUploadingFileMessage=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),ea.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},s.prototype.copyFileMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof St&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),o=new V,c=t(u(u({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=n.thumbnails)||void 0===a?void 0:a.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(c).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.copyMessage=function(e,t){D(e instanceof s&&t instanceof mt&&t.sendingStatus===k.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(O.invalidParameters);var n=t,r=e;if(n.isUserMessage()){D(!n.poll).throw(O.notSupportedError);var i=nn(n);return r._sendUserMessage(i)}if(n.isFileMessage()){i=dn(n);return r._sendFileMessage(i)}if(t.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.deleteMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(e instanceof pt).throw(O.invalidParameters),e.messageId>0?(t=n.of(this._iid).requestQueue,r=new de({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof mt?e._messageToken:void 0}),[4,t.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},s.prototype.addReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new gr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(br).reactionEvent]}}))}))},s.prototype.deleteReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Ir({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Er).reactionEvent]}}))}))},s.prototype._updateUserMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new mr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(vr).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype._updateFileMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new yr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(_r).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype.createMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new je({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},s.prototype.deleteMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new je({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},s.prototype.addMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof je}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},s.prototype.removeMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof je}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},s.prototype.report=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return D(f(hn,e)&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new lr({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:t}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.reportUser=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof c&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new dr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.userId,category:t,description:r}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.reportMessage=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof mt&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new hr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:t,description:r,messageToken:e._messageToken}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.updatePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(h("number",e)&&function(e){return h("string",e.title,!0)&&te(e.data)&&h("boolean",e.allowUserSuggestion,!0)&&h("boolean",e.allowMultipleVotes,!0)&&h("number",e.closeAt,!0)}(t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Nr(u({pollId:e},t)),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Cr).poll]}}))}))},s.prototype.deletePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i;return U(this,(function(s){switch(s.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Or({pollId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},s.prototype.closePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Pr({pollId:e}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(kr).poll]}}))}))},s.prototype.addPollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=h("number",e)&&h("string",t)&&""!==t.trim(),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Rr({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(xr).poll]}}))}))},s.prototype.updatePollOption=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return i=h("number",e)&&h("number",t)&&h("string",r)&&""!==r.trim(),D(i).throw(O.invalidParameters),s=n.of(this._iid).requestQueue,a=new Dr({pollId:e,pollOptionId:t,optionText:r}),[4,s.send(a)];case 1:return o=u.sent(),[2,o.as(Lr).poll]}}))}))},s.prototype.deletePollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return r=h("number",e)&&h("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Fr({pollId:e,pollOptionId:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},s.prototype.votePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a,o,u,c;return U(this,(function(l){switch(l.label){case 0:return r=h("number",e)&&d("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid),s=i.requestQueue,a=i.dispatcher,o=new qr({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(zr).event,a.dispatch(new he({event:c,source:C.EVENT_POLL_VOTED})),[2,c]}}))}))},s.prototype.getPollChangeLogsSinceTimestamp=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("number",e)).throw(O.invalidParameters),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.getPollChangeLogsSinceToken=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("string",e,!0)),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new ce(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},s.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new le(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},s.prototype.pinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new ci({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s.prototype.unpinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new li({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s}(l),mi=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 r(t,e),t}((function(){this.onConnected=Y,this.onReconnectStarted=Y,this.onReconnectSucceeded=Y,this.onReconnectFailed=Y,this.onDisconnected=Y})),vi=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 r(t,e),t}((function(){this.onSessionExpired=Y,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=Y,this.onSessionRefreshed=Y,this.onSessionClosed=Y})),yi=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 r(t,e),t}((function(){this.onFriendsDiscovered=Y,this.onTotalUnreadMessageCountChanged=Y,this.onTotalUnreadMessageCountUpdated=Y})),_i=function(t){function n(n){var r=n.limit,s=n.token,a=n.userIdsFilter,o=n.metaDataKeyFilter,u=n.metaDataValuesFilter,c=n.nicknameStartsWithFilter,l=t.call(this)||this;return l.method=i.GET,l.path=pe,l.params=e({limit:r,token:s,user_ids:a,metadatakey:o,metadatavalues_in:u,nickname_startswith:c}),l}return r(n,t),n}(a),gi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),bi=function(e){function i(t,n){var r,i,s,a=this;return(a=e.call(this,t,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)&&h("string",this.metaDataKeyFilter,!0)&&d("string",this.metaDataValuesFilter,!0)&&h("string",this.nicknameStartsWithFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new _i(t(u(u({},this),{token:this._token}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(gi),a=s.users,o=s.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),Ii=function(t){function n(n){var r=n.userId,s=n.limit,a=n.token,o=n.userIdsFilter,u=t.call(this)||this;return u.method=i.GET,u.path="".concat(pe,"/").concat(r,"/block"),u.params=e({limit:s,token:a,user_ids:o}),u}return r(n,t),n}(a),Ei=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Ti=function(e){function i(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Ii(t(u(u({},this),{userId:r.userId,token:this._token}))),[4,i.send(s)]):[3,2]:[3,5];case 1:return a=d.sent(),o=a.as(Ei),c=o.users,l=o.next,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,c];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),wi=function(e){function t(t){var n=t.userId,r=t.limit,s=t.token,a=e.call(this)||this;return a.method=i.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(n),"/friends"),a.params={limit:r,token:s},a}return r(t,e),t}(a),Mi=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 c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Si=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),t=e.sdkState,r=e.requestQueue,i=new wi(u(u({},this),{userId:t.userId,token:this._token})),[4,r.send(i)]):[3,2]:[3,5];case 1:return s=d.sent(),a=s.as(Mi),o=a.users,c=a.hasMore,l=a.next,this._token=l,this._hasNext=c,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(me),Ai={},Ui=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,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,d=void 0===l?11:l,h=e.transactionApplyDelay,f=void 0===h?200:h,p=e.disableLogger,m=void 0!==p&&p;return Ai[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=c,this.blockHashConstant=d,this.transactionApplyDelay=f,this.disableLogger=m,Ai[t]=this),Ai[t]}return e.get=function(e){return Ai[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_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"}(fi||(fi={}));var Ni,Ci=function(e){function t(n){var r=n.code,i=void 0===r?fi.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 r(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:fi.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.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:fi.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:fi.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:fi.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:fi.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:fi.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:fi.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:fi.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:fi.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:fi.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:fi.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"}(Ni||(Ni={}));var Oi,Pi=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Ci.circularReferenceFound;t.set(e,!0);var n=void 0;if(Array.isArray(e))n=e.map((function(e){return Pi(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]=Pi(e[r],t);return t.delete(e),n}return e},ki=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Ci.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Ri=function(e,t){for(var n=0,r=0;r>>0)%t},xi=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Di=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!Di(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Di(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(!(ki(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(ki(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(ki(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(ki(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)},Li=function(){},Fi=function(){return Promise.resolve()},qi=function(e){return e},zi=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Oi||(Oi={}));var Bi,Ki,ji,Qi=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?qi:a,u=e.backward,c=void 0===u?Fi:u,l=e.forward,d=void 0===l?Fi:l,h=e.complete,f=void 0===h?Li:h;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=c,this._forward=d,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 A(this,void 0,void 0,(function(){var e,t,n;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(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}(),Gi=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 u in this.condition[s])if(o.includes(u))for(var c=r;c>=0;c--)if(a*ki(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(a*ki(this._indexer.origin[c].columnValues[i],this.condition[s])<=0){r=c;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var d=function(r){var i=h._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),h.condition[i])if("object"==typeof h.condition[i])Object.keys(h.condition[i]).forEach((function(a){if((s>0?t:n).includes(a))for(var o=l;o=0){l=o;break}}));else for(var a=l;a=0){l=a;break}},h=this,i=0;i-1){var r=this._items[n];return t===ji.PERSISTENT&&(r.state=Ki.PERSISTENT),t!==ji.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)ts.includes(this._items[r].state)&&ts.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 i=this._items.filter((function(e){return e.state===Ki.VOLATILE})),s=i.length-this._limit;if(s>0){var a=[];try{for(var o=v(this._items),u=o.next();!u.done;u=o.next()){var c=u.value;c.state===Ki.VOLATILE&&s>0?s--:a.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this._items=a}}}},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!==Ki.VOLATILE}))},e}(),is=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(Wi(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(Wi(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=[]),A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,p([],m(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],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,c,l,d;return U(this,(function(h){switch(h.label){case 0:n=rs.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return u(u({},e.data),{generation:r})})))];case 2:for(a=h.sent(),o=0;o0))return[3,4];for(t=[],n={},o=e.length-1;o>=0;o--)r=e[o],l=r.data,n[l.key]||(n[l.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=p.sent(),[4,this._store.set({key:this.recordsetKey,value:s})];case 2:return p.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(p.sent(),a=rs.get(this.dbname),o=0;o0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=a.sent())&&(s=ss.createFromCacheItem(i),null==s?void 0:s.getItemByKey(e)))return[2,s];a.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return n=Ui.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,rs.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(null==(a=s?ss.createFromCacheItem(s):new ss({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:a.add(t))?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(this,(function(r){switch(r.label){case 0:return e=Ji(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(),rs.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),os={},us=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 u=function(e,t,n){return"".concat(Wi(e,t),"/index.").concat(n)}(t,n,i.join(">"));return os[u]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=u,this._transaction=s,this._store=a,this._transaction.on(Bi.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Bi.ERROR,this.indexerKey,(function(){return o.abort()}))),os[u]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in os)delete os[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=m(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=m(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var a=v(this.fields),o=a.next();!o.done;o=a.next()){var u=o.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw Ci.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=ki(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 A(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,y;return U(this,(function(_){switch(_.label){case 0:return[4,(e=rs.get(this.dbname)).find(this._store,this.indexerKey,ji.PERSISTENT)];case 1:return(t=_.sent())?[3,11]:(n=Ji(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=_.sent(),_.label=3;case 3:_.trys.push([3,8,9,10]),i=v(r),s=i.next(),_.label=4;case 4:return s.done?[3,7]:(a=s.value).startsWith(n)?[4,e.find(this._store,a,ji.NO_CACHE)]:[3,6];case 5:if(o=_.sent(),u=ss.createFromCacheItem(o))try{for(m=void 0,c=v(u.items),l=c.next();!l.done;l=c.next())d=l.value,this._addItem(d)}catch(e){m={error:e}}finally{try{l&&!l.done&&(y=c.return)&&y.call(c)}finally{if(m)throw m.error}}_.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return h=_.sent(),f={error:h},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=Pi(this._origin),_.label=12;case 12:return os[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return rs.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete os[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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=Pi(this._origin)},e.prototype.abort=function(){this._table=Pi(this._origin)},e}(),cs=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},ls=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"}($i||($i={})),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"}(es||(es={}));var ds,hs={},fs=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=$i.PROCESSING,this._queue=[],this._activationQueue=[],hs[e]&&!t.forceCreate||(this.nodeId=ls(),this.key=e,cs()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data;if(null==i?void 0:i.isNestDbMessage){var s=i.nodeId,a=i.requestId,o=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&o===n.key)switch(u){case es.NEWNODE:n._sendSync();break;case es.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case es.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,d=l.currentItemRequestId,h=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:es.REQUEST_LOCK,ts:e.ts})};try{for(var p=v(h),m=p.next();!m.done;m=p.next()){f(m.value)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case es.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case es.REQUEST_LOCK:n._requestLock(i);break;case es.ACQUIRE_LOCK:var y=n._queue.find((function(e){return e.requestId===a}));n._acquire(y);break;case es.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(es.REMOVENODE)}))),hs[e]=this),hs[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==$i.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:ls(),key:this.key,op:e,data:t.data,ts:Date.now()};return cs()&&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(es.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(es.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(es.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 A(this,void 0,void 0,(function(){var e=this;return U(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=$i.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(es.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(es.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(es.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}(),ps=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=Ni.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=p([[r]],m(s.filter((function(e){return us.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new fs(function(e,t){return"".concat(Wi(e,t),".lock")}(t,n)),this._blobContainer=new Zi({dbname:t,collectionName:n,store:a}),this._transaction=new is({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return r=Yi(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===Ni.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,y,_=this;return U(this,(function(g){switch(g.label){case 0:return[4,this._mutex.lock()];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,9,,10]),t=Ui.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=g.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:g.sent(),this._blockManager=new as({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=p([],m(this.indexes),!1),i=[],s=r.map((function(e){return us.createKey(e)})),a=n?n.indexes.map((function(e){return us.createKey(e)})):[];try{for(o=v(a),u=o.next();!u.done;u=o.next())c=u.value,s.includes(c)||i.push(us.parseKey(c))}catch(e){f={error:e}}finally{try{u&&!u.done&&(y=o.return)&&y.call(o)}finally{if(f)throw f.error}}return(l=[]).push.apply(l,p([],m(r.map((function(e){var t=new us({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,p([],m(i.map((function(e){return new us({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return g.sent(),[4,this._transaction.commit()];case 6:return g.sent(),s.sort().join(",")===a.sort().join(",")?[3,8]:(d=Yi(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:d,value:this._metadata})]);case 7:g.sent(),g.label=8;case 8:return this._state=Ni.READY,this._mutex.unlock(),[3,10];case 9:throw h=g.sent(),this._mutex.unlock(),h;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Ni.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=us.createKey(e);try{for(var i=v(this._indexers),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===us.createKey(a.fields))return a}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw Ci.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return e=Yi(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return o.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return o.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return o.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:o.sent(),o.label=5;case 5:o.trys.push([5,10,11,12]),n=v(this._indexers),r=n.next(),o.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:o.sent(),o.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=o.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw Ci.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=v(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),a=v(this._indexers),o=a.next(),p.label=16;case 16:return o.done?[3,20]:0===(u=o.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return o=a.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),h={error:c},[3,23];case 22:try{o&&!o.done&&(f=a.return)&&f.call(a)}finally{if(h)throw h.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=v(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return a=c.sent(),o={error:a},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=o.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:o.sent(),o.label=3;case 3:o.trys.push([3,8,9,10]),n=v(this._indexers),r=n.next(),o.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:o.sent(),o.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=o.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return U(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=v(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(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,Pi(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Ci.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new Vi({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ci.collectionNotReady},e.prototype.insertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestInsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpdate(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p,m,y=this;return U(this,(function(_){switch(_.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:_.sent(),_.label=2;case 2:return _.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,a=e.backward,o=void 0!==a&&a,u=[],[4,new Gi({condition:r,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(s)}).each((function(e){return A(y,void 0,void 0,(function(){var n,i;return U(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Di(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];else t.set(n);u.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:_.sent(),_.label=4;case 4:_.trys.push([4,9,10,11]),c=v(u),l=c.next(),_.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestUpdate(Pi(d))]);case 6:_.sent(),_.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return h=_.sent(),p={error:h},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return _.sent(),this._mutex.unlock(),[2,u];case 13:return f=_.sent(),[4,this._transaction.clear()];case 14:throw _.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),Ci.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m=this;return U(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,a=void 0!==s&&s,o=[],[4,new Gi({condition:n,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(i)}).each((function(e){return A(m,void 0,void 0,(function(){var t,r;return U(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Di(n,t)&&(r=t[this.keyName],o.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=v(o),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return d=y.sent(),f={error:d},[3,11];case 10:try{c&&!c.done&&(p=u.return)&&p.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,o];case 13:throw h=y.sent(),this._mutex.unlock(),h;case 14:return[3,16];case 15:throw this._transaction.clear(),Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),ms="[NESTDB]",vs=!0,ys=function(){function e(){}return e.off=function(){vs=!1},e.log=function(){for(var e=[],t=0;t1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return A(o,void 0,void 0,(function(){var n,i;return U(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw Ci.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}}))}))})))]:[3,4];case 3:return a=u.sent(),[3,5];case 4:a=[r],u.label=5;case 5:return s=a,[2,this.encryption.decrypt(JSON.parse(s.join("")))];case 6:return u.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,u({},e.value)]}}))}))},e.prototype.setMany=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,p([],m(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 A(this,void 0,void 0,(function(){var t,n,r,i=this;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:t=[],n=function(e){var n,i,s;return U(this,(function(a){switch(a.label){case 0:return n=r._getRawKey(e,".0"),[4,r._getRaw(n)];case 1:return(i=a.sent())&&(s=i.metadata,t.push.apply(t,p([],m(r._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return l._getRawKey(e,".".concat(t))}))),!1))),[2]}}))},r=this,d.label=1;case 1:d.trys.push([1,6,7,8]),i=v(e),s=i.next(),d.label=2;case 2:return s.done?[3,5]:(a=s.value,[5,n(a)]);case 3:d.sent(),d.label=4;case 4:return s=i.next(),[3,2];case 5:return[3,8];case 6:return o=d.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}return[7];case 8:return t.length>0?[4,this._removeRaw(t)]:[3,10];case 9:d.sent(),d.label=10;case 10:return[2,e]}}))}))},e}(),bs={},Is=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,u(u({},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 r(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return bs[this.dbname]},set:function(e){bs[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(bs[this.dbname])return[2,Object.keys(bs[this.dbname])];throw Ci.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return bs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:return t.sent(),[2,bs[this.dbname][e]?u({key:e},bs[this.dbname][e]):null];case 2:throw Ci.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return bs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:c.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,s=r.data,a=r.metadata,bs[this.dbname][i]=Object.freeze({data:s,metadata:a})}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}}return[3,3];case 2:throw Ci.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return bs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:a.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,bs[this.dbname][r]&&delete bs[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw Ci.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 A(this,void 0,void 0,(function(){return U(this,(function(e){return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,bs[this.dbname]||(bs[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.set=function(t){return A(this,void 0,void 0,(function(){var n,r;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u;return U(this,(function(c){try{for(n=v(t),r=n.next();!r.done;r=n.next())if(i=r.value,(s=this.observer[i.key])&&"function"==typeof s.set&&(a=s.set()))throw a}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,xi(this.delay)];case 1:return e.sent(),bs[this.dbname]={},[2]}}))}))},t}(gs),Es="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(ds||(ds={}));var Ts,ws=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=Es,r._state=ds.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 r(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype.isTransactionInactiveError=function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")},t.prototype._putToObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.put(t);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))]}))}))},t.prototype._deleteFromObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.delete(t);i.addEventListener("success",(function(){return n(t)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))]}))}))},t.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=ds.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Es,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=ds.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=ds.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=ds.UNINITIALIZED,r(e.target.error)}))}else r(Ci.storeNotAvailable)}))},t.prototype._getObjectStore=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 ds.UNINITIALIZED:case ds.OPEN:return[3,2];case ds.OPENING:case ds.CLOSED:return[3,3]}return[3,4];case 2:throw Ci.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 A(this,void 0,void 0,(function(){var e;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._putToObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._putToObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._deleteFromObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._deleteFromObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){var e,t=this;return U(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||!cs())return[3,4];if(!(cs()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Ci.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(Ci.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),t._indexedDb){var i=t._indexedDb.deleteDatabase("_testMozilla");i.onerror=function(){return e()},i.onsuccess=function(){return e()}}else n(Ci.storeNotAvailable)}}catch(e){n(Ci.storeNotAvailableInPrivateBrowsing)}else n(Ci.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Ci.storeNotAvailable;case 5:return[3,7];case 6:throw Ci.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(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(),[4,this._resetIfEncryptionChanged()];case 3:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(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}(gs),Ms=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?2097152:i,a=ye(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,u(u({},a),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:t=[];try{for(n=v(e),r=n.next();!r.done;r=n.next())i=r.value,s=i.key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(s),JSON.stringify(i)])}catch(e){a={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return u.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._asyncStorage)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(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}(gs),Ss=function(e){function t(t){var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._mmkv)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(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}(gs);!function(e){e.INIT="INIT",e.OPENING="OPENING",e.OPENED="OPENED",e.CLOSED="CLOSED"}(Ts||(Ts={}));var As,Us=function(){function e(e){var t=e.name,n=e.version,r=e.store,i=e.config;this.name=t,this._version=n,this._state=Ts.INIT,this._config=i||new Ui({dbname:t}),this._store=r,this._event={success:Li,error:Li,storeReplaced:Li,upgrade:zi},this._collections=new Map,this._globalMutex=new fs("".concat(this.name,".lock")),this._config.disableLogger&&ys.off(),new rs({dbname:t,limit:this._config.cacheLimit})}return Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),e.prototype.estimateUsage=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,(t=this._store,A(void 0,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,t.usage()];case 1:return[2,e.sent()]}}))})))];case 1:return[2,e.sent()]}var t}))}))},e.prototype.commitSchema=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this._state!==Ts.OPENING?[3,2]:[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=e.collectionName,n=e.keyName,r=e.index,i=void 0===r?[]:r,this._collections.has(t)||this._collections.set(t,new ps({dbname:this.name,collectionName:t,keyName:n,indexes:i,store:this._store})),(s=this._collections.get(t))?[4,s.init()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[3,3];case 2:throw Ci.databaseSchemaNotOnUpgrade;case 3:return[2]}}))}))},e.prototype.open=function(){var e;return A(this,void 0,void 0,(function(){var t,n,r,i,s=this;return U(this,(function(a){switch(a.label){case 0:return[4,this._globalMutex.lock()];case 1:if(a.sent(),this._state===Ts.OPENED)return[3,12];this._state=Ts.OPENING,a.label=2;case 2:return a.trys.push([2,5,,12]),[4,this._store.init(this.name)];case 3:return a.sent(),o=this.name,t="".concat(Hi(o),".metadata"),n={version:0,collectionNames:[]},[4,this._store.get(t)];case 4:return r=null!==(e=a.sent())&&void 0!==e?e:n,[2,new Promise((function(e,n){var i=function(e){r.version0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof mt))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof pt)switch(this.replyType){case H.NONE:if(e.parentMessageId>0)return!1;break;case H.ONLY_REPLY_TO_CHANNEL:if(e instanceof mt&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Ns||(Ns={}));var Ps,ks=function(e){switch(e){case Ns.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Ns.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Rs=function(){return["channelUrl","-createdAt","-notificationId"]},xs=u(u({},tn),{scheduledAt:void 0}),Ds=function(e){return an(e)&&h("number",e.scheduledAt,!0)},Ls=u(u({},Zt),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Fs=function(e){return $t(e)&&h("number",e.scheduledAt)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},qs="UnsentMessage",zs="reqId",Bs={},Ks=function(t){function i(e){var n=t.call(this,e)||this;return n._mutex=new fs("unsendmessagecache.lock"),Bs[e]=n,n}return r(i,t),Object.defineProperty(i.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),i.of=function(e,t){return void 0===t&&(t=!1),Bs[e]&&!t||(Bs[e]=new i(e)),Bs[e]},Object.defineProperty(i.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(qs);if(!t)throw O.databaseError;return t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),i.prototype._serialize=function(t){if(t.messageId>0)throw O.invalidParameters;var n,r=u({},t.serialize());return t instanceof It?(t.messageParams&&(r.messageParams=en(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=(n=t.scheduledInfo.scheduledMessageParams,u(u({},en(n)),{scheduledAt:n.scheduledAt})))):t instanceof St?(t.messageParams&&(r.messageParams=cn(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=function(e){return u(u({},cn(e)),{scheduledAt:e.scheduledAt})}(t.scheduledInfo.scheduledMessageParams))):t instanceof Et&&t.messageParams&&(r.messageParams=function(t){return e({fileInfoList:t.fileInfoList,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption})}(t.messageParams)),r},i.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),ea.of(this._iid).buildMessageFromSerializedData(e)},i.prototype._deserializeWithMessageCreateParams=function(e){var t,n,r;return A(this,void 0,void 0,(function(){var i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return i=ea.of(this._iid),s=this._deserialize(e),e.messageParams?s instanceof It?(o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),[3,6]):[3,1]:[3,6];case 1:return s instanceof St?(o=e.messageParams).fileKey&&"string"==typeof o.fileKey&&un(null!==(t=o.fileType)&&void 0!==t?t:"")?(a=o,[4,this.collection.getBlob(o.fileKey)]):[3,3]:[3,4];case 2:a.file=null!==(n=d.sent())&&void 0!==n?n:void 0,d.label=3;case 3:return s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(o,s),[3,6];case 4:return s instanceof Et&&((o=e.messageParams)&&o.fileInfoList)?(s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(o,s),[4,Promise.all(s.messageParams.fileInfoList.map((function(e){return A(l,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&un(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!==(s=a.sent())&&void 0!==s?s:void 0,a.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:d.sent(),d.label=6;case 6:return s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?s instanceof It?(u=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(u,s),[3,10]):[3,7]:[3,10];case 7:return s instanceof St?(u=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof u.fileKey&&"string"==typeof u.fileType&&un(u.fileType)?(c=u,[4,this.collection.getBlob(u.fileKey)]):[3,9]:[3,10];case 8:c.file=null!==(r=d.sent())&&void 0!==r?r:void 0,d.label=9;case 9:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(u,s),d.label=10;case 10:return[2,s]}}))}))},i.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},i.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new Os:n,i=e.order,s=void 0===i?Ns.CHANNEL_LATEST:i,a=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return A(this,void 0,void 0,(function(){var e,n,i,o,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?(e=ks(s),n={"/where":function(e){return!!(s!==Ns.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(l._deserialize(e))}},t&&(n.channelUrl=t),a&&(n.sendingStatus=a),i={where:n,index:e,backward:u},[4,this.collection.query(i)]):[3,3];case 1:return[4,d.sent().fetch({})];case 2:return o=d.sent(),[2,Promise.all(o.map((function(e){return A(l,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},i.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Os),A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:Ns.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},i.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return e instanceof St||e instanceof Et?[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]}}))}))},i.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},i.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.saveBlob=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i=this;return U(this,(function(s){switch(s.label){case 0:return e instanceof St?e.messageParams&&(r=e.messageParams).file&&on(r.file)?[4,this.collection.saveBlob(r.file,e.reqId)]:[3,2]:[3,5];case 1:n=s.sent(),r.fileKey=n,r.fileType=rn.BLOB,s.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&on(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=s.sent(),t.fileKey=n,t.fileType=rn.BLOB,s.label=4;case 4:return[3,7];case 5:return e instanceof Et&&((r=e.messageParams)&&r.fileInfoList&&Array.isArray(r.fileInfoList))?[4,Promise.all(r.fileInfoList.map((function(t,n){return A(i,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return t.file&&on(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=rn.BLOB,i.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},i}(l),js={},Qs=function(e){function t(t){var n=e.call(this,t)||this;return js[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Ks.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),js[e]&&!n||(js[e]=new t(e)),js[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Gr)},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 u(u({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),ea.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Os:s,o=e.order,u=void 0===o?Ns.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,d=e.parentMessageId,h=e.isPollOnly,f=void 0!==h&&h,p=e.exactMatch,m=void 0!==p&&p,v=e.inclusive,y=void 0===v||v;return A(this,void 0,void 0,(function(){var e,r,s,o=this;return U(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=ks(u),r={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Ns.CHANNEL_LATEST:if(m&&e.createdAt!==n)return!1;if(l){if(y&&e.createdAtn||!y&&e.createdAt>=n)return!1;break;case Ns.NEWEST_CHILD_MESSAGE:if(!d||0===e.parentMessageId||e.parentMessageId!==d)return!1}return!(f&&!e._poll)&&a.match(o._deserialize(e))}},index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({limit:null!=i?i:void 0})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return A(o,void 0,void 0,(function(){return U(this,(function(t){return[2,this._deserialize(e)]}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Os),A(this,void 0,void 0,(function(){return U(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:Ns.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,13];case 1:d.sent(),d.label=2;case 2:d.trys.push([2,7,8,9]),n=v(e),r=n.next(),d.label=3;case 3:return r.done?[3,6]:(i=r.value,(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)?[4,this.get(i.messageId)]:[3,5]);case 4:(null==(s=d.sent())?void 0:s.threadInfo)&&i.threadInfo._updateFrom(s.threadInfo),d.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return a=d.sent(),u={error:a},[3,9];case 8:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 9:return o=e.map((function(e){return l._serialize(e)})),[4,this.collection.upsertMany(o)];case 10:return d.sent(),[4,this.upsertChildMessages(e)];case 11:return d.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 12:d.sent(),d.label=13;case 13:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:ks(Ns.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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:ks(Ns.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=ks(Ns.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 A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return e instanceof St&&e.messageParams&&((t=e.messageParams).file&&on(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.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=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return s=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return a=o.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),s&&(t+=JSON.stringify(s).length),a&&(t+=JSON.stringify(a).length),[2,t]}}))}))},t}(l),Gs={},Vs=function(e){function t(t){var n=e.call(this,t)||this;return Gs[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),Gs[e]&&!n||(Gs[e]=new t(e)),Gs[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Wr)},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 u({},e.serialize())},t.prototype._deserialize=function(e){return ea.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Os:s,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,d=e.inclusive,h=void 0===d||d;return A(this,void 0,void 0,(function(){var e,r=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(e={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(h&&e.createdAtn||!h&&e.createdAt>=n)return!1}return a.match(r._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},[4,this.collection.query(e)]):[3,3];case 1:return[4,s.sent().fetch({limit:null!=i?i:void 0})];case 2:return[2,s.sent().map((function(e){return r._deserialize(e)}))];case 3:return[2,[]]}}))}))},t.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?(t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.markAsReadByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,messageStatus:ft.SENT,createdAt:{"<":t}}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.markAsReadByMessageIds=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:ft.SENT}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:return[2,n.sent().length];case 2:return[2,0]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]})]:[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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:ks(Ns.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=["channelUrl","-createdAt","-notificationId"],[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}(l),Hs={},Ws=function(e){function t(t){var n=e.call(this,t)||this;return n._observers=new Map,n._dispatcherContext=n._dispatcher.on((function(e){return A(n,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,v,y,_,g,b=this;return U(this,(function(E){switch(E.label){case 0:return e instanceof N?(t=e.messages,g=e.source,a=e.isWebSocketEventComing,n=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&e.messageId>0})),r=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&0===e.messageId})),i=t.filter((function(e){return e instanceof Tt})),n.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(n)];case 1:return e.sent(),[4,this._unsentMessageCache.remove(n.map((function(e){return e instanceof mt?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,7];case 1:E.sent(),a||this._broadcastUpdateEvent(n,g),E.label=2;case 2:return r.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.upsert(r)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:E.sent(),a||this._broadcastUpdateEvent(r,g),E.label=4;case 4:return i.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._notificationCache.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,6];case 5:E.sent(),a||this._broadcastUpdateEvent(i,g),E.label=6;case 6:return[3,24];case 7:return e instanceof we?(s=e.messageIds,g=e.source,a=e.isWebSocketEventComing,o=s.filter((function(e){return"number"==typeof e})),u=s.filter((function(e){return"string"==typeof e})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return o.length>0?[4,this._messageCache.remove(o)]:[3,2];case 1:e.sent(),e.label=2;case 2:return u.length>0?[4,this._notificationCache.remove(u)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))}))]):[3,9];case 8:return E.sent(),a||this._broadcastRemoveEvent(s,g),[3,24];case 9:return e instanceof Te?(c=e.reqId,g=e.source,[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.remove([c])];case 1:return e.sent(),[2]}}))}))}))]):[3,11];case 10:return E.sent(),this._broadcastRemoveUnsentEvent(c,g),[3,24];case 11:return e instanceof Ee?(l=e.polls,g=e.source,this._cacheContext.localCacheEnabled?(d=l.map((function(e){return e.messageId})),[4,Promise.all(d.map((function(e){return b._messageCache.get(e)})))]):[3,14]):[3,15];case 12:return(h=E.sent().filter((function(e){return e}))).length>0&&l.forEach((function(e){var t=h.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(h)];case 1:return[2,e.sent()]}}))}))}))];case 13:E.sent(),E.label=14;case 14:return this._broadcastPollChangeLogEvent(l,g),[3,24];case 15:return e instanceof Ie?(f=e.event,g=e.source,[4,this._messageCache.get(f.messageId)]):[3,19];case 16:return(p=E.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollUpdateEvent(f)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([p])];case 1:return[2,e.sent()]}}))}))}))]:[3,18];case 17:E.sent(),E.label=18;case 18:return this._broadcastPollUpdateEvent(f,g),[3,24];case 19:return e instanceof he?(m=e.event,g=e.source,[4,this._messageCache.get(m.messageId)]):[3,23];case 20:return(v=E.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(m)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,22];case 21:E.sent(),E.label=22;case 22:return this._broadcastPollVoteEvent(m,g),[3,24];case 23:e instanceof _e?(y=e.event,g=e.source,y.messageId>0&&this._broadcastReactionUpdateEvent(y,g)):e instanceof ge&&(_=e.event,g=e.source,this._broadcastThreadUpdateEvent(_,g)),E.label=24;case 24:return[2]}}))}))})),n}return r(t,e),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dispatcher",{get:function(){return n.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_messageCache",{get:function(){return Qs.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Ks.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_notificationCache",{get:function(){return Vs.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){var r;return void 0===n&&(n=!1),Hs[e]&&!n||(Hs[e]&&(null===(r=Hs[e]._dispatcherContext)||void 0===r||r.close()),Hs[e]=new t(e)),Hs[e]},t.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemove&&a.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastReactionUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastThreadUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype.subscribe=function(e,t){this._observers.set(e,t)},t.prototype.unsubscribe=function(e){this._observers.delete(e)},t.prototype.unsubscribeAll=function(){this._observers.clear()},t}(l),Ys=function(t){function n(n){var r=this,s=n.reverse,a=void 0!==s&&s,o=n.limit,u=void 0===o?20:o,c=n.keys,l=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(Me),r.params=e({token:l,limit:u,reverse:a,order:Se.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),r}return r(n,t),n}(a),Js=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.next,s=n.has_more,a=void 0!==s&&s,o=n.templates;return r.nextToken=i,r.hasMore=a,r.templates=o.map((function(e){return{template:JSON.stringify(e)}})),r}return r(t,e),t}(o),Xs=function(e){function t(t){var n=this,r=t.key;return(n=e.call(this)||this).method=i.GET,n.path="".concat(Me,"/").concat(r),n}return r(t,e),t}(a),Zs=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.template=JSON.stringify(n),r}return r(t,e),t}(o),$s={},ea=function(){function n(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=a,Qs.of(e),Ks.of(e),Ws.of(e),this.fileMessageQueue=new Rt(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),$s[e]=this}return n.of=function(e){return $s[e]},n.prototype.buildMessageFromSerializedData=function(e){var t=Ae(e);if(t.notificationId)return new Tt(this._iid,Tt.payloadify(t));switch(t.messageType){case g.USER:return new It(this._iid,It.payloadify(t));case g.FILE:return Et._isMultipleFilesMessageSerializedData(t)?new Et(this._iid,Et.payloadify(t)):new St(this._iid,St.payloadify(t));case g.ADMIN:return new _t(this._iid,_t.payloadify(t))}throw O.invalidParameters},n.prototype.buildUserMessageCreateParamsFromSerializedData=function(n,r){return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,message:r.message,translationTargetLanguages:Object.keys(r.translations),pollId:n.pollId}))},n.prototype.buildFileMessageCreateParamsFromSerializedData=function(n,r){var i;return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,file:n.file,fileKey:n.fileKey,fileUrl:r.plainUrl,fileName:r.name,fileSize:r.size,mimeType:r.type,thumbnailSizes:null===(i=r.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:n.fileType,requireAuth:r.requireAuth}))},n.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(t,n){var r=this;return e({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUserIds:n.mentionedUserIds,mentionedUsers:n.mentionedUsers,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption,appleCriticalAlertOptions:n.appleCriticalAlertOptions,reqId:n.reqId,fileInfoList:t.fileInfoList.map((function(e){return new At(r._iid,e)}))})},n.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildSenderFromSerializedData=function(e){var t=Ae(e);return new Ke(this._iid,Ke.payloadify(t))},n.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new zt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Bt).message]}}))}))},n.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Vt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Ht).message]}}))}))},n.prototype.getMessagesByMessageId=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new Kt(u(u({channelType:t,channelUrl:e,token:String(n)},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(jt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype.getMessagesByTimestamp=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new Kt(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(jt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype._getMessagesByTimestampForCollection=function(e,t,n,r,i,s,a){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var o,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return o=new Kt(u(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r),{checkingHasNext:s,checkingContinuousMessages:a})),[4,this._requestQueue.send(o)];case 1:return c=p.sent(),l=c.as(jt),d=l.messages,h=l.isContinuousMessages,f=l.hasNext,this._dispatcher.dispatch(new N({messages:d,source:i})),[2,{messages:d,isContinuousMessages:h,hasNext:f}]}}))}))},n.prototype.getThreadedMessagesByTimestamp=function(e,t,n,r){return void 0===r&&(r=C.REQUEST_THREADED_MESSAGE),A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return i=new Kt(u(u(u({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},vt),n),{replyType:H.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return s=c.sent(),a=s.as(jt).messages,(o=a.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new N({messages:o,source:r})),[2,{parentMessage:a[0],threadedMessages:o}]}}))}))},n.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return n=new Ys(u({token:e},t)),[4,this._requestQueue.send(n)];case 1:return r=c.sent(),i=r.as(Js),s=i.hasMore,a=i.nextToken,o=i.templates,[2,{hasMore:s,token:a,templates:o}]}}))}))},n.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Xs({key:e}),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,{template:n.as(Zs).template}]}}))}))},n.prototype.getMessageChangelogs=function(n,r,i,s,a){return void 0===a&&(a=C.REQUEST_MESSAGE_CHANGELOGS),A(this,void 0,void 0,(function(){var o,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return o=new Qt(e(t(u(u({channelType:r,channelUrl:n,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},Ft),s)))),[4,this._requestQueue.send(o)];case 1:return c=v.sent(),l=c.as(Gt),d=l.updatedMessages,h=l.deletedMessagesInfo,f=l.hasMore,p=l.nextToken,m=h.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new N({messages:d,source:a})),m.length>0&&this._dispatcher.dispatch(new we({messageIds:m,source:a})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:f,token:p}]}}))}))},n}(),ta=function(e){function t(t,n){var r=e.call(this,t)||this;r.targetMessageId=0;var i=n.thread_info,s=n.parent_message_id,a=n.channel_url,o=n.channel_type;return i&&h("object",i)&&h("number",s)&&h("string",a)&&h("string",o)&&(r.threadInfo=new Re(t,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return r(t,e),t}(l),na={channelUrl:"",channelType:I.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},ra=function(e){function t(t){var n=t.channelCustomType,r=t.keyword,s=t.limit,a=t.reverse,o=t.exactMatch,u=t.channelUrl,c=t.order,l=t.messageTimestampFrom,d=t.messageTimestampTo,h=t.advancedQuery,f=t.targetFields,p=t.nextToken,m=e.call(this)||this;return m.method=i.GET,m.path="".concat(Ue,"/messages"),m.params={custom_type:n,query:r,limit:s,reverse:a,exact_match:o,channel_url:u,message_ts_from:l,message_ts_to:d,sort_field:c,advanced_query:h,target_fields:f,after:p},m}return r(t,e),t}(a),ia=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return Mt(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return r(t,e),t}(o);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Ps||(Ps={}));var sa=function(e){function i(t,n){var r,i,s,a,o,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Ps.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(a=n.channelCustomType)&&void 0!==a?a:"",h.messageTimestampFrom=null!==(o=n.messageTimestampFrom)&&void 0!==o?o:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:Ps.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&h("string",this.keyword)&&this.keyword.length>0&&h("boolean",this.reverse)&&h("boolean",this.exactMatch)&&h("string",this.channelUrl)&&h("string",this.channelCustomType)&&(h("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(h("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&f(Ps,this.order)&&h("boolean",this.advancedQuery)&&d("string",this.targetFields,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new ra(t(u(u({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=d.sent(),s=i.as(ia),a=s.messages,o=s.hasNext,c=s.nextToken,l=s.totalCount,this._nextToken=c,this._hasNext=o,this._isLoading=!1,this.totalCount=l,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),aa=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.limit,u=r.token,c=n.call(this)||this;return c.method=i.GET,c.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages/parent_thread_message"),c.params=e(t({limit:o,token:u})),c}return r(s,n),s}(a),oa=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.next,r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),ua=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s._edge="",s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.load=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new aa({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(oa),s=i.messages,a=i.token,this._edge=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ca={channelUrl:"",scheduledMessageId:0},la={reverse:!1,limit:20},da=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return r(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new ea(t,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},t.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},t.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},t.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=u(u({},na),e),D(function(e){return h("string",e.channelUrl)&&f(I,e.channelType)&&h("number",e.messageId)&&h("boolean",e.includeReactions,!0)&&h("boolean",e.includeMetaArray,!0)&&h("boolean",e.includeParentMessageInfo,!0)&&h("boolean",e.includeThreadInfo,!0)}(t)).throw(O.invalidParameters),[4,this._manager.getMessage(t)];case 1:if((n=r.sent())instanceof pt||n instanceof Tt||null===n)return[2,n];throw"Unknown message type is given."}}))}))},t.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){return t=u(u({},ca),e),D(function(e){return h("string",e.channelUrl)&&""!==e.channelUrl&&h("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(O.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},t.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return n=u(u({},la),t),D(h("string",e,!0)&&function(e){return h("boolean",e.reverse,!0)&&h("number",e.limit,!0)&&d("string",e.keys,!0)}(n)).throw(O.invalidParameters),[2,this._manager.getMessageTemplatesByToken(e,n)]}))}))},t.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),[2,this._manager.getMessageTemplate(e)]}))}))},t}(Ne);export{It as $,Ms as A,Ti as B,mi as C,Sn as D,gt as E,Si as F,Yt as G,Wt as H,ws as I,xt as J,Os as K,Cs as L,Ns as M,Gr as N,En as O,Jt as P,Br as Q,hn as R,vi as S,Mt as T,yi as U,ut as V,si as W,ui as X,Ve as Y,ct as Z,ot as _,Kr as a,Ce as a$,St as a0,ta as a1,Re as a2,Xn as a3,zn as a4,cr as a5,or as a6,sr as a7,tr as a8,rr as a9,di as aA,fn as aB,nn as aC,dn as aD,ti as aE,Xt as aF,He as aG,Sr as aH,hi as aI,ke as aJ,Pe as aK,Ws as aL,_t as aM,De as aN,Zr as aO,Vs as aP,Hr as aQ,ft as aR,Je as aS,We as aT,bt as aU,Ps as aV,Et as aW,Fe as aX,qe as aY,Tn as aZ,Le as a_,zr as aa,pt as ab,Ye as ac,mt as ad,vr as ae,_r as af,pr as ag,Ct as ah,Qr as ai,Tt as aj,ea as ak,mn as al,vn as am,yn as an,_n as ao,Oe as ap,je as aq,ze as ar,wt as as,ua as at,ii as au,xs as av,Ds as aw,Ls as ax,Fs as ay,sn as az,jr as b,Ke as b0,at as b1,Be as b2,xe as b3,lt as b4,dt as b5,st as b6,Vr as c,qs as d,zs as e,Jr as f,ks as g,Xr as h,$r as i,ei as j,Wr as k,Yr as l,Rs as m,As as n,Is as o,Ss as p,da as q,bi as r,sa as s,Us as t,Ui as u,Qs as v,Ks as w,Ts as x,Nn as y,pi as z}; +import{e,u as t,V as n,c as r,A as i,ae as s,f as a,h as o,g as u,U as c,af as l,Q as d,a as h,X as f,p,q as m,t as v,a7 as y,ag as _,ah as g,ai as b,C as I,aj as E,ak as T,al as w,W as M,am as S,_ as A,b as U,an as N,a2 as C,s as O,a8 as P,ao as k,ap as R,aq as x,w as D,ar as L,as as F,at as q,au as z,av as B,D as K,F as j,aw as Q,i as G,ax as V,ay as H,az as W,aA as Y,aB as J,aC as X,aD as Z,aE as $,aF as ee,aG as te,aH as ne,aI as re,aJ as ie,n as se,G as ae,O as oe,aK as ue,x as ce,y as le,aL as de,aM as he,aN as fe,d as pe,aO as me,aP as ve,aQ as ye,aR as _e,aS as ge,B as be,aT as Ie,aU as Ee,aV as Te,aW as we,aX as Me,aY as Se,z as Ae,aZ as Ue,a_ as Ne}from"./__bundle-1db3fd0b.js";var Ce,Oe=function(){function r(e,t,n){var r,i;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(r=t.real_width)&&void 0!==r?r:t.width,this.realHeight=null!==(i=t.real_height)&&void 0!==i?i:t.height,this._requireAuth=n}return r.payloadify=function(n){return e(t(n instanceof r?{url:n.plainUrl,width:n.width,height:n.height,real_width:n.realWidth,real_height:n.realHeight}:{url:"",width:n.maxWidth,height:n.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(r.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),r}(),Pe=function(t){function n(n){var r=t.call(this)||this;if(r.method=i.POST,r.path="".concat(s),r.params=e({file:n.file,channel_url:n.channelUrl}),n.thumbnailSizes)for(var a=0;a0:void 0,u.lastRepliedAt=null!==(a=t.last_replied_at)&&void 0!==a?a:0,u.updatedAt=null!==(o=t.updated_at)&&void 0!==o?o:0,u}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{reply_count:r.replyCount,unread_message_count:r.unreadReplyCount,member_count:r.memberCount,most_replies:Array.isArray(r.mostRepliedUsers)?r.mostRepliedUsers.map((function(e){return c.payloadify(e)})):[],push_enabled:"boolean"==typeof r.isPushNotificationEnabled?r.isPushNotificationEnabled?1:0:void 0,last_replied_at:r.lastRepliedAt,updated_at:r.updatedAt})))},Object.defineProperty(i.prototype,"_isUpdateRequired",{get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled},enumerable:!1,configurable:!0}),i.prototype._updateFrom=function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled},i}(l);!function(e){e.ADD="add",e.DELETE="delete"}(Ce||(Ce={}));var xe,De=function(e){this.messageId=0,this.operation=null,this.updatedAt=0;var t=h("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,n=e.user_id,r=e.operation?e.operation.toLowerCase():null,i=e.reaction,s=e.updated_at;t&&h("string",n)&&h("string",r)&&f(Ce,r)&&h("string",i)&&i&&h("number",s)&&(this.messageId=t,this.userId=n,this.key=i,this.operation=r,this.updatedAt=s)},Le=function(){function n(e){var t,n,r,i=e.key,s=null!==(r=p([],m(e.user_ids),!1))&&void 0!==r?r:[],a=e.updated_at;h("string",i)&&i&&d("string",s)&&s.length>0&&h("number",a)&&(this.key=i,this.userIds=s,this.updatedAt=a);var o={};try{for(var u=v(this.userIds),c=u.next();!c.done;c=u.next()){o[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._version=o}return Object.defineProperty(n.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({key:n.key,user_ids:n.userIds,updated_at:n.updatedAt}))},n.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 Ce.ADD:t<0&&this.userIds.push(e.userId);break;case Ce.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},n}(),Fe=function(){function n(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 n.payloadify=function(n){var r,i;return e(t({url:n.url,secure_url:n.secureUrl,type:n.type,width:null!==(r=n.width)&&void 0!==r?r:0,height:null!==(i=n.height)&&void 0!==i?i:0,alt:n.alt}))},n}(),qe=function(){function n(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 Fe(e["og:image"]))}return n.payloadify=function(n){return e(t({"og:title":n.title,"og:url":n.url,"og:description":n.description,"og:image":n.defaultImage?Fe.payloadify(n.defaultImage):null}))},n}(),ze=function(){function n(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 n.prototype.serialize=function(){return{name:this.name,volume:this.volume}},n.payloadify=function(n){return e(t({name:n.name,volume:n.volume}))},n}();!function(e){e.GOOD="good",e.BAD="bad"}(xe||(xe={}));var Be=function(){function n(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}return n._getStatus=function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"},n._isSubmitted=function(e){return"SUBMITTED"===n._getStatus(e)},n._getPayloadByStatus=function(e){return"NO_FEEDBACK"===e?{}:null},n.payloadify=function(n){return e(t({id:n.id,rating:n.rating,comment:n.comment}))},n}(),Ke=function(n){function i(e,t){var r,i=this;return(i=n.call(this,e,t)||this).isBlockedByMe=!1,i.role=f(y,t.role)?t.role:y.NONE,i.isBlockedByMe=null!==(r=t.is_blocked_by_me)&&void 0!==r&&r,i}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{role:r.role,is_blocked_by_me:r.isBlockedByMe})))},i}(c),je=function(){function n(e){this.key=e.key,this.value=d("string",e.value)?p([],m(e.value),!1):[]}return n.payloadify=function(n){var r;return e(t({key:n.key,value:null!==(r=n.value)&&void 0!==r?r:[]}))},n}(),Qe=function(e){switch(e){case g.BASE:return"";case g.USER:return"MESG";case g.FILE:return"FILE";case g.ADMIN:return"ADMM"}},Ge=function(n){function i(e,t){var r,i,s,a,o,u,l,d,h,p=this;(p=n.call(this,e)||this).channelType=I.BASE,p.messageType=g.BASE,p.mentionType=null,p.mentionedUsers=null,p.mentionedUserIds=null,p.mentionedMessageTemplate=void 0,p.metaArrays=[],p.extendedMessage={},p.createdAt=0,p.updatedAt=0,p.channelUrl=t.channel_url,p.channelType=f(I,t.channel_type)?t.channel_type:I.GROUP,t.channel&&(t.channel.channel_url&&(p.channelUrl=t.channel.channel_url),t.channel.channel_type&&(p.channelType=t.channel.channel_type)),p.data=null!==(r=t.data)&&void 0!==r?r:"",p.customType=null!==(i=t.custom_type)&&void 0!==i?i:"",p.mentionType=f(E,t.mention_type)?t.mention_type:null,p.mentionedUsers=t.mentioned_users?t.mentioned_users.map((function(e){return new c(p._iid,e)})):null,p.mentionedUserIds=null!==(s=t.mentioned_user_ids)&&void 0!==s?s:null,p.mentionedUsers&&!p.mentionedUserIds&&(p.mentionedUserIds=p.mentionedUsers.map((function(e){return e.userId}))),p.mentionedMessageTemplate=t.mentioned_message_template;var m=null!==(a=t.metaarray)&&void 0!==a?a:{},v=null!==(o=t.metaarray_key_order)&&void 0!==o?o:Object.keys(m).sort((function(e,t){return e.localeCompare(t)}));p.metaArrays=[];for(var y=0;y0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({id:n.id,name:n.name,items:n.items.map((function(e){return dt.payloadify(e)})),version:n.version,is_submitted:n._isSubmitted}))},n.isMessageFormPayload=function(e){return Boolean(null==e?void 0:e.message_form)},n}(),dt=function(){function n(t){var n=t.id,r=t.name,i=t.required,s=t.sort_order,a=t.placeholder,o=t.style,u=t.item_type,c=t.validators,l=t.value,d=t.values;this.id=n,this.name=r,this.required=i,this.sortOrder=s,this.placeholder=a,0===Object.keys(o).length?this.style={layout:u}:this.style=e({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),d?this.submittedValues=d:l&&(this.submittedValues=[l]),this._validators=c}return n.prototype.isValid=function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case it.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case it.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case it.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case it.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case it.DECIMAL_PLACE:return 0!==e.length&&(n=Number(e),!(isNaN(n)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(n,t.max_decimal_place)));default:return!0}}))}(e,t._validators);return n}))},n.payloadify=function(n){return e(t({id:n.id,name:n.name,required:n.required,sort_order:n.sortOrder,placeholder:n.placeholder,style:e({layout:n.style.layout,options:n.style.options,default_options:n.style.defaultOptions,result_count:n.style.resultCount}),item_type:n.style.layout,validators:n._validators,values:n.submittedValues}))},n}(),ht=function(t){function n(n){var r=t.call(this)||this;return r.method=i.POST,r.path="".concat(S,"/").concat(n.formId,"/submit"),r.params=e({message_id:n.messageId,items:n.items}),r}return r(n,t),n}(a);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ut||(ut={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ct||(ct={}));var ft,pt=function(i){function s(e,t){var n,r,s,a,o,u,c,l,d=this;return(d=i.call(this,e,t)||this).parentMessage=null,d.silent=!1,d.isOperatorMessage=!1,d.threadInfo=null,d.reactions=[],d.appleCriticalAlertOptions=null,d.scheduledInfo=null,d.suggestedReplies=null,d.myFeedback=null,d.myFeedbackStatus="NOT_APPLICABLE",d.messageForm=null,d._isContinuousMessages=!1,d._scheduledStatus=null,d.messageId=null!==(r=null!==(n=t.msg_id)&&void 0!==n?n:t.message_id)&&void 0!==r?r:0,d.parentMessageId=null!==(s="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==s?s:0,d.threadInfo=t.thread_info?new Re(d._iid,t.thread_info):null,d.reactions=t.reactions?t.reactions.map((function(e){return new Le(e)})):[],d.ogMetaData=t.og_tag?new qe(t.og_tag):null,d.silent=null!==(a=t.silent)&&void 0!==a&&a,d.isOperatorMessage=null!==(o=t.is_op_msg)&&void 0!==o&&o,d.appleCriticalAlertOptions=t.apple_critical_alert_options?new ze(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(d.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},d._scheduledStatus=t.scheduled_status),d._isContinuousMessages=null!==(u=t.is_continuous_messages)&&void 0!==u&&u,d.myFeedback=Be._isSubmitted(t.feedback)?new Be(t.feedback):null,d.myFeedbackStatus=Be._getStatus(t.feedback),d.suggestedReplies=null!==(l=null===(c=t.extended_message_payload)||void 0===c?void 0:c.suggested_replies)&&void 0!==l?l:null,d.messageForm=lt.isMessageFormPayload(t.extended_message_payload)?new lt(d.messageId,t.extended_message_payload.message_form):null,d}return r(s,i),s.payloadify=function(n){var r,s;return e(t(u(u({},i.payloadify.call(this,n)),{message_id:n.messageId,parent_message_id:n.parentMessageId,thread_info:n.threadInfo?Re.payloadify(n.threadInfo):null,reactions:n.reactions.map((function(e){return Le.payloadify(e)})),og_tag:n.ogMetaData?qe.payloadify(n.ogMetaData):null,silent:n.silent,is_op_msg:n.isOperatorMessage,apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,scheduled_message_id:null===(r=n.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=n.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:n._scheduledStatus,feedback:n.myFeedback?Be.payloadify(n.myFeedback):Be._getPayloadByStatus(n.myFeedbackStatus)})))},s._getParentMessageInfoPayload=function(n){return e(t({type:Qe(n.messageType),ts:n.createdAt,user:n.sender?Ke.payloadify(n.sender):null,message:n.message,file:{url:n.plainUrl,name:n.name,type:n.type,require_auth:n.requireAuth},files:Array.isArray(n.fileInfoList)?n.fileInfoList.map((function(e){return at.payloadify(e)})):null}))},s.prototype.isIdentical=function(e){return this.messageId===e.messageId},s.prototype.applyThreadInfoUpdateEvent=function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)},s.prototype.applyReactionEvent=function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1},s.prototype._triggerThreadInfoUpdatedEvent=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){return(e=n.of(this._iid).dispatcher).dispatch(new ot({channelType:I.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_THREADINFO_UPDATED})),[2]}))}))},s.prototype.markThreadAsRead=function(){return A(this,void 0,void 0,(function(){var e,t;return U(this,(function(r){switch(r.label){case 0:return e=n.of(this._iid).requestQueue,t=new Xe({channelUrl:this.channelUrl,messageId:this.messageId}),[4,e.send(t)];case 1:return r.sent(),this.threadInfo&&0!==this.threadInfo.unreadReplyCount?(this.threadInfo.unreadReplyCount=0,[4,this._triggerThreadInfoUpdatedEvent()]):[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},s.prototype.setPushNotificationEnabled=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return t=n.of(this._iid).requestQueue,r=new Ze({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),[4,t.send(r)];case 1:return i.sent(),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e),[2]}}))}))},s.prototype.submitMessageForm=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(t=n.of(this._iid).requestQueue,r=null,i=null,s=this.messageForm,!e&&s){if(!s.isSubmittable)throw new O({code:P.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(s.isSubmitted)throw new O({code:P.INVALID_PARAMETER,message:"The form has already been submitted."});r=s.id,i=s.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[])}else e&&(r=e.formId,i=Object.entries(e.answers).reduce((function(e,t){var n=m(t,2),r=n[0],i=n[1],s=Number(r);if(Number.isNaN(s))throw new O({code:P.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:s,value:i}),e}),[]));if(!r||!i)throw new O({code:P.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});return a=new ht({messageId:this.messageId,formId:r,items:i}),[4,t.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.submitFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new $e({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(et),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_ADDED})),[2]}}))}))},s.prototype.updateFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new tt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(nt),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_UPDATED})),[2]}}))}))},s.prototype.deleteFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new rt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e}),[4,r.send(s)];case 1:return a.sent(),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_DELETED})),[2]}}))}))},s}(Ge),mt=function(n){function i(e,t){var r,i,s,a,o=this;if((o=n.call(this,e,t)||this).reqId="",o.replyToChannel=!1,o.errorCode=0,o.sender=t.user?new Ke(o._iid,t.user):t.sender_id,o.reqId=null!==(i=null!==(r=t.req_id)&&void 0!==r?r:t.request_id)&&void 0!==i?i:"",o.replyToChannel=null!==(s=t.is_reply_to_channel)&&void 0!==s&&s,t.request_state&&f(k,t.request_state)&&(o.sendingStatus=t.request_state),!o.sendingStatus)if(o.messageId>0)o.sendingStatus=k.SUCCEEDED;else if(o.scheduledInfo)switch(t.scheduled_status&&(o._scheduledStatus=t.scheduled_status),t.scheduled_status){case ct.SENT:case ct.IN_QUEUE:o.sendingStatus=k.SUCCEEDED;break;case ct.PENDING:o.sendingStatus=k.SCHEDULED;break;case ct.FAILED:case ct.REMOVED:o.sendingStatus=k.FAILED;break;case ct.CANCELED:o.sendingStatus=k.CANCELED}else o.sendingStatus=k.PENDING;return o.errorCode=null!==(a=t.error_code)&&void 0!==a?a:0,o._messageToken=t.mesg_token,o}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{user:Ke.payloadify(r.sender),req_id:r.reqId,is_reply_to_channel:r.replyToChannel,request_state:r.sendingStatus,error_code:r.errorCode,mesg_token:r._messageToken})))},Object.defineProperty(i.prototype,"isResendable",{get:function(){return(this.sendingStatus===k.FAILED||this.sendingStatus===k.CANCELED)&&R(this.errorCode)},enumerable:!1,configurable:!0}),i.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},i}(pt),vt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},yt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)},_t=function(n){function i(r,i){var s,a,o,c,l=this;if((l=n.call(this,r,i)||this).translations={},l.message=null!==(s=i.message)&&void 0!==s?s:"",l.messageType=g.ADMIN,l.translations=null!==(a=i.translations)&&void 0!==a?a:{},i.parent_message_info){var d=i.parent_message_info;l.parentMessage=Mt(r,e(t(u(u({},d),{message_id:l.parentMessageId,channel_url:l.channelUrl,channel_type:l.channelType,file:d.file,url:null===(o=d.file)||void 0===o?void 0:o.url,require_auth:null===(c=d.file)||void 0===c?void 0:c.require_auth}))))}return l}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{message:r.message,translations:r.translations,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i}(pt),gt=function(){function n(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&&h("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return n.payloadify=function(n){return e(t({type:n.type,vendor:n.vendor,detail:n.detail}))},n}(),bt=function(){function t(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}return t.payloadify=function(t){return e({status:t.status,original_message_info:t.originalMessageInfo?{id:t.originalMessageInfo.messageId,ts:t.originalMessageInfo.createdAt}:void 0})},t}(),It=function(n){function i(r,i){var s,a,o,c,l,d,h,f=this;if((f=n.call(this,r,i)||this).message="",f.messageParams=null,f.translations={},f.translationTargetLanguages=[],f.messageSurvivalSeconds=-1,f.plugins=[],f._poll=null,f.message=i.message,f.messageType=g.USER,f.translations=null!==(o=i.translations)&&void 0!==o?o:{},f.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(f.translations).length&&f.translationTargetLanguages.length>0)try{for(var p=v(f.translationTargetLanguages),m=p.next();!m.done;m=p.next()){var y=m.value;f.translations[y]=""}}catch(e){s={error:e}}finally{try{m&&!m.done&&(a=p.return)&&a.call(p)}finally{if(s)throw s.error}}if(f.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,f.plugins=i.plugins?i.plugins.map((function(e){return new gt(e)})):[],f._poll=i.poll?new L(f._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;f.parentMessage=Mt(r,e(t(u(u({},_),{created_at:_.ts,message_id:f.parentMessageId,channel_url:f.channelUrl,channel_type:f.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(f.messageReviewInfo=new bt(i.review_info)),f}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{message:r.message,translations:r.translations,message_survival_seconds:r.messageSurvivalSeconds,plugins:r.plugins.map((function(e){return gt.payloadify(e)})),poll:r._poll?L.payloadify(r._poll):null,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null,review_info:r.messageReviewInfo?bt.payloadify(r.messageReviewInfo):void 0})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(i.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),i}(mt),Et=function(n){function i(r,i){var s,a,o,c,l,d,h,f,p=this;if((p=n.call(this,r,i)||this).messageParams=null,p.fileInfoList=[],p.messageSurvivalSeconds=-1,p.messageType=g.FILE,p.data=null!==(o=null!==(a=null===(s=i.file)||void 0===s?void 0:s.data)&&void 0!==a?a:i.custom)&&void 0!==o?o:"",p.fileInfoList=null!==(l=null===(c=i.files)||void 0===c?void 0:c.map((function(e){return new at(r,e)})))&&void 0!==l?l:[],p.messageSurvivalSeconds=null!==(d=i.message_survival_seconds)&&void 0!==d?d:-1,i.parent_message_info){var m=i.parent_message_info;p.parentMessage=Mt(r,e(t(u(u({},m),{created_at:m.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:m.file,url:null===(h=m.file)||void 0===h?void 0:h.url,require_auth:null===(f=m.file)||void 0===f?void 0:f.require_auth}))))}return p}return r(i,n),i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.payloadify=function(r){var i,s,a,o,c,l;return e(t(u(u({},n.payloadify.call(this,r)),{file:{name:null!==(s=null===(i=r.fileInfoList[0])||void 0===i?void 0:i.fileName)&&void 0!==s?s:"",size:null!==(o=null===(a=r.fileInfoList[0])||void 0===a?void 0:a.fileSize)&&void 0!==o?o:0,type:null!==(l=null===(c=r.fileInfoList[0])||void 0===c?void 0:c.mimeType)&&void 0!==l?l:"",data:r.data},files:Array.isArray(r.fileInfoList)?r.fileInfoList.map((function(e){return at.payloadify(e)})):null,message_survival_seconds:r.messageSurvivalSeconds,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},i._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},i}(mt);!function(e){e.SENT="SENT",e.READ="READ"}(ft||(ft={}));var Tt=function(n){function i(e,t){var r,i,s=this;if((s=n.call(this,e,t)||this).notificationData=null,s.notificationId=t.notification_message_id,s.messageType=g.ADMIN,s.messageStatus=null!==(r=t.message_status)&&void 0!==r?r:ft.SENT,s.priority=null!==(i=t.priority)&&void 0!==i?i:F.NORMAL,s.notificationEventDeadline=t.notification_event_deadline,0===s.extendedMessage.sub_type)try{var a=JSON.parse(s.extendedMessage.sub_data),o=a.label,u=a.tags,c=void 0===u?[]:u,l=a.template_key,d=a.template_variables;s.notificationData={label:o,tags:c,templateKey:l,templateVariables:d}}catch(e){}return s}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{notification_message_id:r.notificationId,message_status:r.messageStatus,priority:r.priority,notification_event_deadline:r.notificationEventDeadline})))},i.prototype.isIdentical=function(e){return this.notificationId===e.notificationId},i}(Ge),wt=function(e){if(e.notificationId)return Tt.payloadify(e);switch(e.messageType){case g.USER:return It.payloadify(e);case g.FILE:return e.fileInfoList?Et.payloadify(e):St.payloadify(e);case g.ADMIN:return _t.payloadify(e);default:throw O.unknown}},Mt=function(e,t){if(t.notification_message_id)return new Tt(e,t);switch(t.type){case"MESG":return new It(e,t);case"FILE":return Et._isMultipleFilesMessagePayload(t)?new Et(e,t):new St(e,t);case"ADMM":case"BRDM":return new _t(e,t);default:return null}},St=function(i){function s(n,r){var s,a,o,c,l,d,h,f,p,m,v,y,_,b,I=this;(I=i.call(this,n,r)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=g.FILE;var E=r.file;if(I.plainUrl=(null!==(a=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==a?a:"").split("?auth=")[0],I.name=null!==(c=null!==(o=null==E?void 0:E.name)&&void 0!==o?o:r.name)&&void 0!==c?c:"File",I.size=null!==(d=null!==(l=null==E?void 0:E.size)&&void 0!==l?l:r.size)&&void 0!==d?d:0,I.data=null!==(f=null!==(h=null==E?void 0:E.data)&&void 0!==h?h:r.custom)&&void 0!==f?f:"",I.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(m=r.type)&&void 0!==m?m:"",I.requireAuth=null!==(v=r.require_auth)&&void 0!==v&&v,I.thumbnails=r.thumbnails?r.thumbnails.map((function(e){var t;return new Oe(I._iid,"string"==typeof e?{url:e,width:0,height:0}:u(u({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),I.requireAuth)})):[],I.messageSurvivalSeconds=null!==(y=r.message_survival_seconds)&&void 0!==y?y:-1,r.parent_message_info){var T=r.parent_message_info;I.parentMessage=Mt(n,e(t(u(u({},T),{created_at:T.ts,message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:T.file,url:null===(_=T.file)||void 0===_?void 0:_.url,require_auth:null===(b=T.file)||void 0===b?void 0:b.require_auth}))))}return I}return r(s,i),s.payloadify=function(n){var r;return e(t(u(u({},i.payloadify.call(this,n)),{url:n.plainUrl,require_auth:n.requireAuth,file:{name:n.name,size:n.size,type:n.type,data:n.data},thumbnails:null===(r=n.thumbnails)||void 0===r?void 0:r.map((function(e){return{url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:n.messageSurvivalSeconds,parent_message_info:n.parentMessage?i._getParentMessageInfoPayload.call(this,n.parentMessage):null})))},Object.defineProperty(s.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},s}(mt),At=function(e){function t(t,n){var r=n.file,i=n.fileUrl,s=n.fileName,a=n.fileSize,o=n.mimeType,u=n.thumbnailSizes,c=n._uploadedMetaData,l=n._thumbnails,d=e.call(this,t)||this;return d._plainUrl=i,d.file=r,d.fileName=s,d.fileSize=a,d.mimeType=o,d.thumbnailSizes=u,d._uploadedMetaData=c,d._thumbnails=l,d}return r(t,e),t.getPlainUrl=function(e){return e instanceof t?e._plainUrl:e.fileUrl},Object.defineProperty(t.prototype,"fileUrl",{get:function(){var e,t=n.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}},t}(l),Ut=function(n){function i(r){var i,s,a,o,u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,files:r.files?Pt(r.files):null,url:r.url,name:null!==(i=r.fileName)&&void 0!==i?i:"",type:null!==(s=r.mimeType)&&void 0!==s?s:"",size:null!==(a=r.fileSize)&&void 0!==a?a:0,custom:r.data,custom_type:r.customType,thumbnails:null===(o=r._thumbnails)||void 0===o?void 0:o.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:u,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,pin_message:r.isPinnedMessage}))})||this}return r(i,n),i}(T),Nt=function(n){function s(r){var s,a,o=this;o=n.call(this)||this;var u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),o.method=i.POST,o.path="".concat(w(r.channelType),"/").concat(encodeURIComponent(r.channelUrl),"/messages"),o.params=e(t({message_type:g.FILE,user_id:r.userId,files:r.files?Pt(r.files):null,url:r.fileUrl,mention_type:r.mentionType,mentioned_user_ids:u,file_name:r.fileName,file_size:r.fileSize,file_type:r.mimeType,data:r.data,custom_type:r.customType,thumbnails:null===(s=r._thumbnails)||void 0===s?void 0:s.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,sorted_metaarray:null===(a=r.metaArrays)||void 0===a?void 0:a.map((function(e){return je.payloadify(e)})),push_option:r.pushNotificationDeliveryOption,parent_message_id:r.parentMessageId?r.parentMessageId:null,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,reply_to_channel:r.isReplyToChannel,req_id:r.reqId,pin_message:r.isPinnedMessage})),o}return r(s,n),s}(a),Ct=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"FILE",i)||this).message=i.files&&i.files.length>=2?new Et(t,i):new St(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),Ot=function(e){function t(t,r){var i,s,a,o,u=this;(u=e.call(this,t,r)||this).message=r.files&&r.files.length>=2?new Et(t,r):new St(t,r);var c=n.of(t).sdkState;return u.isMentioned=z(u.message.mentionType,null!==(a=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(s=u.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return r(t,e),t}(o);function Pt(n){return n.map((function(n){var r,i;return e(t({url:At.getPlainUrl(n),file_name:n.fileName,file_type:n.mimeType,file_size:n.fileSize,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),require_auth:null===(i=n._uploadedMetaData)||void 0===i?void 0:i.requireAuth}))}))}var kt;!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"}(kt||(kt={}));var Rt=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext,o=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=a,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof K&&(o._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===j.CONNECTED||this._connectionState===j.CONNECTING||this._connectionState===j.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){switch(s.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(r=new Ut(n),[4,this._requestQueue.send(r)]):[3,2];case 1:return i=s.sent(),[2,i.as(Ct).message];case 2:return r=new Nt(u(u({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),[2,i.as(Ot).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=u(u({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{r=t.params;n.url=r.fileUrl,n.requireAuth=r.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p;return U(this,(function(m){switch(m.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,r=[],i=!0,m.label=1;case 1:m.trys.push([1,15,16,17]),s=v(n.messageQueue),a=s.next(),m.label=2;case 2:if(a.done)return[3,14];switch(o=a.value,o.state){case kt.PENDING:case kt.UPLOADING:return[3,3];case kt.UPLOADED:return[3,4];case kt.FAILED:return[3,12]}return[3,13];case 3:return i=!1,r.push(o),[3,13];case 4:if(!i)return[3,10];m.label=5;case 5:return m.trys.push([5,8,,9]),o.state=kt.SENDING,[4,this._sendFileMessage(e,o)];case 6:return u=m.sent(),o.deferred.resolve(u),[4,Q(100)];case 7:return m.sent(),[3,9];case 8:return c=m.sent(),o.deferred.reject(c),[3,9];case 9:return[3,11];case 10:r.push(o),m.label=11;case 11:return[3,13];case 12:return l=null!==(t=o.error)&&void 0!==t?t:O.unknown,o.deferred.reject(l.code===P.REQUEST_CANCELED?O.fileUploadCanceled:l),[3,13];case 13:return a=s.next(),[3,2];case 14:return[3,17];case 15:return d=m.sent(),f={error:d},[3,17];case 16:try{a&&!a.done&&(p=s.return)&&p.call(s)}finally{if(f)throw f.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:m.sent(),m.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,m.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d;return U(this,(function(h){switch(h.label){case 0:return(n=this._queueMap.get(e.url))&&(r=n.messageQueue.find((function(e){return e.state===kt.PENDING})))?r.multipleFileUploadInfo?(i=r.multipleFileUploadInfo,s=i.uploadIndex,a=i.uploadCount,o=i.requestHandler,d=r.params,u=d.fileInfoList[s],!G(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]):[3,4]:[3,9];case 1:return h.sent(),[3,3];case 2:r.state=s=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,u,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return a=new Pe({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(a)];case 1:return o=v.sent(),u=o.as(ke),c=u.url,l=u.fileSize,d=void 0===l?n.fileSize:l,h=u.thumbnails,f=void 0===h?[]:h,p=u.requireAuth,m=void 0!==p&&p,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(i=n.mimeType)&&void 0!==i?i:n.file.type,n.fileSize=null!==(s=n.fileSize)&&void 0!==s?s:n.file.size,n.fileUrl=c,n.fileSize=d,n.requireAuth=m,n._thumbnails=f,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,c,l,d,h,f,p,m,v,y;return U(this,(function(_){switch(_.label){case 0:return a=t.multipleFileUploadInfo.uploadIndex,o=n.fileInfoList[a],c=new Pe({file:o.file,channelUrl:e.url,thumbnailSizes:o.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(c)];case 1:return l=_.sent(),d=l.as(ke),h=d.url,f=d.fileSize,p=void 0===f?o.fileSize:f,m=d.thumbnails,v=d.requireAuth,y=void 0!==v&&v,o.fileName=null!==(r=o.fileName)&&void 0!==r?r:o.file.name,o.mimeType=null!==(i=o.mimeType)&&void 0!==i?i:o.file.type,o.fileSize=null!==(s=o.fileSize)&&void 0!==s?s:o.file.size,o.file=void 0,o.fileUrl=h,o.fileSize=p,o._thumbnails=m,o._uploadedMetaData=u(u({},o._uploadedMetaData),{requireAuth:y,isUploaded:!0}),o instanceof At||(n.fileInfoList[a]=new At(this._iid,o)),[2]}}))}))},e.prototype.request=function(e,t,n,r){return void 0===r&&(r={}),A(this,void 0,void 0,(function(){var i,s,a,o,c;return U(this,(function(l){return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),a=new V,o={requestId:t,params:n,state:kt.PENDING,deferred:a},function(e){return"fileInfoList"in e}(n)&&(c=u({uploadIndex:0,uploadCount:n.fileInfoList.length},r),o.multipleFileUploadInfo=c),s.messageQueue.push(o),this._uploadNextPendingItem(e),[2,a.promise]}))}))},e.prototype.cancel=function(e,t){var n,r,i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:p([],m(i.messageQueue),!1);try{for(var a=v(s),o=a.next();!o.done;o=a.next()){var u=o.value;if(u)switch(u.state){case kt.PENDING:if(u.state=kt.FAILED,u.error=O.requestCanceled,u.multipleFileUploadInfo&&!u.multipleFileUploadInfo.isCopy){var c=u.multipleFileUploadInfo,l=c.uploadIndex,d=c.requestHandler,h=u.params.fileInfoList[l];null==d||d._triggerOnFileUploaded(u.requestId,l,h,O.fileUploadCanceled)}this._resolveMessageQueue(e);break;case kt.UPLOADING:this._requestQueue.cancel(u.requestId),this._dispatcher.dispatch(new B({requestId:u.requestId}))}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new B({requestId:t})))},e}();var xt,Dt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:H.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Lt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&f(H,e.replyType)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)&&h("boolean",e.showSubchannelMessagesOnly)},Ft={replyType:H.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},qt=function(e){return f(H,e.replyType)&&h("boolean",e.includeReactions)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)},zt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.includeMetaArray,o=t.includeReactions,u=t.includeThreadInfo,c=t.includeParentMessageInfo,l=e.call(this)||this;return l.method=i.GET,l.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s)),l.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions:o,include_thread_info:u,include_parent_message_info:c,include_poll_details:!0},l}return r(t,e),t}(a),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o),Kt=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.timestamp,u=r.token,c=r.prevResultSize,l=r.nextResultSize,d=r.isInclusive,h=r.reverse,f=r.messageTypeFilter,p=r.customTypesFilter,m=r.senderUserIdsFilter,v=r.replyType,y=r.includeMetaArray,_=r.includeReactions,g=r.parentMessageId,b=r.includeThreadInfo,I=r.includeParentMessageInfo,E=r.showSubchannelMessagesOnly,T=r.checkingHasNext,M=r.checkingContinuousMessages,S=n.call(this)||this;return S.method=i.GET,S.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages"),S.params=e(t({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:m,include_reply_type:v,with_sorted_meta_array:y,include_reactions:_,parent_message_id:g,include_thread_info:b,include_parent_message_info:I,show_subchannel_message_only:E,include_poll_details:!0,checking_has_next:T,checking_continuous_messages:M})),S}return r(s,n),s}(a),jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return void 0!==n.is_continuous_messages&&(r.isContinuousMessages=n.is_continuous_messages),void 0!==n.has_next&&(r.hasNext=n.has_next),r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),Qt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.timestamp,a=t.token,o=t.replyType,u=t.includeMetaArray,c=t.includeReactions,l=t.includeThreadInfo,d=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=i.GET,h.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:s,token:a,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_reply_type:o,include_parent_message_info:d,include_poll_details:!0},h}return r(t,e),t}(a),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return Mt(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return r(t,e),t}(o),Vt=function(e){function t(t){var n=t.channelUrl,r=t.scheduledMessageId,s=e.call(this)||this;return s.method=i.GET,s.path="".concat(W,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),s.params={},s}return r(t,e),t}(a),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o);!function(e){e.MUTED="muted",e.BANNED="banned"}(xt||(xt={}));var Wt=function(){function n(e){var t,n,r,i;this.restrictionType=null,f(xt,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(r=null!==(n=e.end_at)&&void 0!==n?n:e.muted_end_at)&&void 0!==r?r:-1,this.remainingDuration=null!==(i=e.remaining_duration)&&void 0!==i?i:-1}return n.payloadify=function(n){return e(t({restriction_type:n.restrictionType,description:n.description,end_at:n.endAt,remaining_duration:n.remainingDuration}))},n}(),Yt=function(n){function i(e,t){var r=n.call(this,e,t)||this;return r.restrictionInfo=new Wt(t),r}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),Wt.payloadify(r.restrictionInfo))))},i}(c),Jt=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return r(t,e),t}(c),Xt=function(){function e(){this._onPending=Y,this._onFailed=Y,this._onSucceeded=Y}return e.prototype._trigger=function(e){switch(null==e?void 0:e.sendingStatus){case k.PENDING:0===e.errorCode&&this._onPending(e);break;case k.SCHEDULED:case k.SUCCEEDED:this._onSucceeded(e)}},e.prototype._triggerFailed=function(e,t){switch(null==t?void 0:t.sendingStatus){case k.FAILED:case k.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}(),Zt={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},$t=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(je,e.metaArrays,!0)&&h("number",e.parentMessageId,!0)&&h("boolean",e.isReplyToChannel)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)&&h("boolean",e.isPinnedMessage,!0)},en=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},tn=u(u({},Zt),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function nn(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var rn,sn=function(n){var r;return e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,pollId:null===(r=n.poll)||void 0===r?void 0:r.id,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,message:n.message,translationTargetLanguages:Object.keys(n.translations),extendedMessagePayload:n.extendedMessagePayload}))},an=function(e){return $t(e)&&h("string",e.message)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)&&h("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(rn||(rn={}));var on=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},un=function(e){return e===rn.BLOB||e===rn.FILE},cn=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},ln=u(u({},Zt),{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});function dn(e){var n,r,i,s;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=e.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails}))}var hn,fn=function(n,r){var i;return n.messageParams?(!n.url&&G(r)&&(n.messageParams.file=r),n.messageParams):e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,file:r,fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,thumbnailSizes:null===(i=n.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))},pn=function(e){return $t(e)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},mn={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},vn=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(je,e.metaArrays,!0)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)},yn=u(u({},mn),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),_n=function(e){return vn(e)&&h("string",e.message,!0)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)},gn=u({},mn),bn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.token,a=t.limit,o=e.call(this)||this;return o.method=i.GET,o.path="".concat(w(r),"/").concat(encodeURIComponent(n),"/operators"),o.params={token:s,limit:a},o}return r(t,e),t}(a),In=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new c(t,e)})),r.token=n.next,r}return r(t,e),t}(o),En=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=n.of(this._iid).requestQueue,r=new bn(u(u({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(r)]):[3,2]):[3,5];case 1:return i=c.sent(),s=i.as(In),a=s.operators,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),Tn=function(e){function n(t,n,r,i){var s,a,o,u,c,l,d,h,f,p,m=this;return(m=e.call(this,t,n,r,i)||this).reverse=!1,m.messageTypeFilter=x.ALL,m.customTypesFilter=null,m.senderUserIdsFilter=null,m.replyType=H.NONE,m.includeMetaArray=!1,m.includeReactions=!1,m.includeParentMessageInfo=!1,m.includeThreadInfo=!1,m.showSubchannelMessagesOnly=!1,m._edge=Number.MAX_SAFE_INTEGER,m.reverse=null!==(s=i.reverse)&&void 0!==s&&s,m.messageTypeFilter=null!==(a=i.messageTypeFilter)&&void 0!==a?a:x.ALL,m.customTypesFilter=null!==(o=i.customTypesFilter)&&void 0!==o?o:null,m.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,m.replyType=null!==(c=i.replyType)&&void 0!==c?c:H.NONE,m.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,m.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,m.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,m.includeThreadInfo=null!==(f=i.includeThreadInfo)&&void 0!==f&&f,m.showSubchannelMessagesOnly=null!==(p=i.showSubchannelMessagesOnly)&&void 0!==p&&p,m}return r(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.reverse)&&f(x,this.messageTypeFilter)&&f(H,this.replyType)&&d("string",this.customTypesFilter,!0)&&d("string",this.senderUserIdsFilter,!0)&&h("boolean",this.includeMetaArray)&&h("boolean",this.includeReactions)&&h("boolean",this.includeParentMessageInfo)&&h("boolean",this.includeThreadInfo)&&h("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,ea.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t({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=n.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 O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},n}(J),wn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.limit,o=t.token;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:o},n}return r(t,e),t}(a),Mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.mutedUsers=[];var i=n.next,s=n.muted_list;return r.token=i,s&&s.length>0&&(r.mutedUsers=s.map((function(e){return new Yt(t,e)}))),r}return r(t,e),t}(o),Sn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new wn(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Mn),s=i.mutedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),An=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.limit,u=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({limit:o,token:u}),r}return r(n,t),n}(a),Un=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map((function(e){return new Yt(t,e.user)}))),r}return r(t,e),t}(o),Nn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new An(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Un),s=i.bannedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(hn||(hn={}));var Cn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var On=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var Pn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return r(t,e),t}(a),kn=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,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return r(t,e),t}(o),Rn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return r(t,e),t}(a),xn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),Dn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return r(t,e),t}(a),Ln=function(e){function t(t,n){var r,i,s=this;return(s=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},s.ts=null!==(i=n.ts)&&void 0!==i?i:null,s}return r(t,e),t}(o),Fn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata,o=t.upsert;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=o&&o},n}return r(t,e),t}(a),qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),zn=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 r(t,e),t}(M),Bn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return r(t,e),t}(a),Kn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),jn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return r(t,e),t}(a),Qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),Gn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return r(t,e),t}(a),Vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Hn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return r(t,e),t}(a),Wn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Yn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter,o=t.upsert,u=void 0!==o&&o,c=t.mode,l=void 0===c?"set":c;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:u,mode:l},n}return r(t,e),t}(a),Jn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Xn=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 r(t,e),t}(M),Zn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params={},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var $n=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var er=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId,o=t.seconds,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:o,description:u},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var tr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),nr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var rr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ir=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.userId,u=n.seconds,c=n.description;return(r=t.call(this)||this).method=i.POST,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({user_id:o,seconds:u,description:c}),r}return r(n,t),n}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var sr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(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 r(t,e),t}(M),ar=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var or=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ur=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var cr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return r(t,e),t}(M),lr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(X(s),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:o,report_description:u},n}return r(t,e),t}(a),dr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.offendingUserId,c=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(Z,"/users/").concat(u),n.params={channel_url:r,channel_type:s===I.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:o,report_description:c},n}return r(t,e),t}(a),hr=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.category,u=n.userId,c=n.offendingUserId,l=n.messageId,d=n.description,h=n.messageToken;return(r=t.call(this)||this).method=i.POST,r.path="".concat(X(a),"/").concat(encodeURIComponent(s),"/messages/").concat(l),r.params=e({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),r}return r(n,t),n}(a),fr=function(n){function i(r){var i=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,poll_id:r.pollId,pin_message:r.isPinnedMessage,extended_message_payload:r.extendedMessagePayload}))})||this}return r(i,n),i}(T),pr=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"MESG",i)||this).message=new It(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),mr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,poll_id:r.pollId}))})||this}return r(i,n),i}(T),vr=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"MEDI",s)||this).message=new It(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),yr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,apple_critical_alert_options:r.appleCriticalAlertOptions}))})||this}return r(i,n),i}(T),_r=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"FEDI",s)||this).message=new St(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),gr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),br=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(n),r}return r(t,e),t}(o),Ir=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.DELETE,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),Er=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(u({},n)),r}return r(t,e),t}(o),Tr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.translationTargetLanguages,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s),"/translation"),o.params={target_langs:a},o}return r(t,e),t}(a),wr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Mr=function(n){function s(r){var s,a=this;a=n.call(this)||this;var o=[];r.mentionType===E.USERS&&(r.mentionedUserIds?o=r.mentionedUserIds:r.mentionedUsers&&(o=r.mentionedUsers.map((function(e){return e.userId}))));var u=r.channelType,c=r.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=e(t({req_id:r.reqId,scheduled_at:r.scheduledAt,message_type:ee.USER,message:r.message,custom_type:r.customType,data:r.data,mention_type:r.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=r.metaArrays)||void 0===s?void 0:s.map((function(e){return je.payloadify(e)})),apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption})),a}return r(s,n),s}(a),Sr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Ar=function(e){function n(n){var r,s,a=this;a=e.call(this)||this;var o=[];n.mentionType===E.USERS&&(n.mentionedUserIds?o=n.mentionedUserIds:n.mentionedUsers&&(o=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=t({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ee.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=n.metaArrays)||void 0===s?void 0:s.map((function(e){return je.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,push_option:n.pushNotificationDeliveryOption}),a}return r(n,e),n}(a),Ur=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new St(t,n),r}return r(t,e),t}(o),Nr=function(e){function t(t){var n=t.pollId,r=t.title,s=t.data,a=t.allowUserSuggestion,o=t.allowMultipleVotes,u=t.closeAt,c=e.call(this)||this;return c.method=i.PUT,c.path="".concat(ne,"/").concat(encodeURIComponent(n)),c.params={title:r,data:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return r(t,e),t}(a),Cr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Or=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.DELETE,r.path="".concat(ne,"/").concat(encodeURIComponent(n)),r}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var Pr=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.PUT,r.path="".concat(ne,"/").concat(encodeURIComponent(n),"/close"),r}return r(t,e),t}(a),kr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Rr=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.pollId,a=t.optionText,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(ne,"/").concat(encodeURIComponent(s),"/options"),o.params={channel_url:n,channel_type:r,text:a},o}return r(t,e),t}(a),xr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Dr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=t.optionText,a=e.call(this)||this;return a.method=i.PUT,a.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:s},a}return r(t,e),t}(a),Lr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Fr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=e.call(this)||this;return s.method=i.DELETE,s.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var qr=function(t){function n(n){var r=n.reqId,i=n.channelType,s=n.channelUrl,a=n.pollId,o=n.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:e({req_id:r,channel_type:i===I.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:a,option_ids:o})})||this}return r(n,t),n}(T),zr=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=new re(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return r(t,e),t}(M),Br=100,Kr="GroupChannel",jr="url",Qr=100,Gr="Message",Vr="messageId",Hr=100,Wr="NotificationMessage",Yr="notificationId",Jr="Poll",Xr="pollId",Zr=100,$r="FeedChannel",ei="url";function ti(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((function(e){var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))}var ni=u(u({},Zt),{fileInfoList:[]}),ri=function(e){return(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},ii=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._onFileUploaded=Y,t}return r(t,e),t.prototype._triggerOnFileUploaded=function(e,t,n,r){this._onFileUploaded(e,t,n,r)},t.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},t.prototype.onPending=function(t){return e.prototype.onPending.call(this,t),this},t.prototype.onFailed=function(t){return e.prototype.onFailed.call(this,t),this},t.prototype.onSucceeded=function(t){return e.prototype.onSucceeded.call(this,t),this},t}(Xt),si=function(e){function t(t,n){var r=e.call(this,t)||this;return r.message=null,r.message=Mt(t,n.message),r}return r(t,e),t}(l),ai=function(t){function n(n){var r=this,s=n.channelType,a=n.channelUrl,o=n.limit,u=n.token,c=n.includeReactions,l=n.includeMetaArray,d=n.includeParentMessageInfo,h=n.includeThreadInfo,f=n.includePollDetails;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/pinned_messages"),r.params=e({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),r}return r(n,t),n}(a),oi=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.pinned_messages,s=n.has_more,a=n.next;return r.pinnedMessages=i.map((function(e){return new si(t,e)})),r.hasMore=s,r.token=a,r}return r(t,e),t}(o),ui=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s.includeMetaArray=i.includeMetaArray,s.includeReactions=i.includeReactions,s.includeParentMessageInfo=i.includeParentMessageInfo,s.includeThreadInfo=i.includeThreadInfo,s.includePollDetails=i.includePollDetails,s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.includeMetaArray,!0)&&h("boolean",this.includeReactions,!0)&&h("boolean",this.includeParentMessageInfo,!0)&&h("boolean",this.includeThreadInfo,!0)&&h("boolean",this.includePollDetails,!0)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new ai(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=c.sent(),i=r.as(oi),s=i.pinnedMessages,a=i.hasMore,o=i.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ci=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.POST,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var li=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.DELETE,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var di,hi=2;!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(di||(di={}));var fi,pi=function(i){function s(e,t){var n,r,s,a,o,u,l,d=this;return(d=i.call(this,e)||this)._name="",d._createdAt=0,d.pinnedMessageIds=[],d.channelType=I.BASE,d.coverUrl="",d.customType="",d.data="",d.isFrozen=!1,d.isEphemeral=!1,d.creator=null,d._messageCollectionLastAccessedAt=0,d._url=t.channel_url,d._name=null!==(n=t.name)&&void 0!==n?n:"",d._createdAt=1e3*t.created_at,d.coverUrl=null!==(r=t.cover_url)&&void 0!==r?r:"",d.customType=null!==(s=t.custom_type)&&void 0!==s?s:"",d.data=null!==(a=t.data)&&void 0!==a?a:"",d.isFrozen=null!==(o=t.freeze)&&void 0!==o&&o,d.isEphemeral=null!==(u=t.is_ephemeral)&&void 0!==u&&u,d.creator=t.created_by?new c(d._iid,t.created_by):null,t.metadata&&Object.keys(t.metadata).length>0&&t.ts?(d._cachedMetaData=new Map,Object.keys(t.metadata).forEach((function(e){d._cachedMetaData.set(e,{value:t.metadata[e],isRemoved:!1,updatedAt:t.ts})}))):"string"==typeof t.metadata&&(d._cachedMetaData=new Map(Object.entries(JSON.parse(t.metadata)))),d.pinnedMessageIds=null!==(l=t.pinned_message_ids)&&void 0!==l?l:[],d}return r(s,i),Object.defineProperty(s.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),s.prototype.toJSON=function(){return u(u({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},s.payloadify=function(n){return e(t(u(u({},i.payloadify.call(this,n)),{channel_url:n.url,name:n.name,cover_url:n.coverUrl,custom_type:n.customType,data:n.data,freeze:n.isFrozen,is_ephemeral:n.isEphemeral,created_by:n.creator?c.payloadify(n.creator):null,created_at:n.createdAt/1e3,metadata:n.cachedMetaData,pinned_message_ids:n.pinnedMessageIds})))},s.prototype.isGroupChannel=function(){return this.channelType===I.GROUP},s.prototype.isOpenChannel=function(){return this.channelType===I.OPEN},s.prototype.isFeedChannel=function(){return this.channelType===I.FEED},Object.defineProperty(s.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(s.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),s.prototype._serializeCachedMetaData=function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}},s.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},s.prototype._update=function(t){var n=e(t);Object.assign(this,n)},s.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})}))},s.prototype._updateCachedMetaData=function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(i,s){var a;i.updatedAt<=t&&(n._cachedMetaData.set(s,{value:null!==(a=e[s])&&void 0!==a?a:i.value,isRemoved:!e[s],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}},s.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0})),s=new Et(this._iid,i);return s.messageParams=t,s},s.prototype._validateFailedFileMessageHasFile=function(e,t){var n;return Boolean(e.url)||G(t)||G(null===(n=e.messageParams)||void 0===n?void 0:n.file)},s.prototype._createPendingScheduledFileMessage=function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r},s.prototype._markMessageAsFailed=function(e,t,n){void 0===n&&(n=!1),e.errorCode=t.code,t.code===P.REQUEST_CANCELED||t.code===P.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=k.CANCELED:n||(e.sendingStatus=k.FAILED)},s.prototype.sendUserMessage=function(e){var t=u(u({},tn),e);return D(an(t)).throw(O.invalidParameters),this._sendUserMessage(t)},s.prototype._sendUserMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,c=null!=r?r:this._generateRequestId(),l=Date.now(),d=new Xt;return Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l);a.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(r)]}))}))}));var s=new fr(u(u({},e),{channelUrl:i.url,channelType:i.channelType,reqId:c}));o.send(s).then((function(e){var t=e.as(pr).message;a.dispatch(new N({messages:[t],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(t)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l),s=n.of(i._iid).cacheContext,o=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,o),a.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._triggerFailed(t,r)]}))}))}))}))}))})),d},s.prototype._autoResendUserMessage=function(e){return D(e instanceof It&&!!e.messageParams).throw(O.invalidParameters),this._sendUserMessage(e.messageParams,di.SEND,e.reqId)},s.prototype.resendUserMessage=function(e){var t;return A(this,void 0,void 0,(function(){var n,r;return U(this,(function(i){return D(e instanceof It&&!e.scheduledInfo).throw(O.invalidParameters),n=new V,r=null!==(t=e.messageParams)&&void 0!==t?t:sn(e),this._sendUserMessage(r,di.RESEND,e.reqId).onFailed((function(e){return n.reject(e)})).onSucceeded((function(e){return n.resolve(e)})),[2,n.promise]}))}))},s.prototype.updateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},yn),t),D(h("number",e)&&_n(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new mr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(vr).message]}}))}))},s.prototype.copyUserMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof It&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),D(!n.poll).throw(O.notSupportedError),o=new V,c=null!==(r=n.messageParams)&&void 0!==r?r:t(u(u({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(a=n.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),e._sendUserMessage(c).onSucceeded((function(e){o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.translateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof It&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Tr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(wr).message]}}))}))},s.prototype._createScheduledUserMessage=function(e,t){var r=this,i=n.of(this._iid).requestQueue,s=Date.now(),a=this._generateRequestId();Q(2).then((function(){var n=r._createPendingScheduledUserMessage(e,a,s);ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))}));var o=new Mr(u({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(o).then((function(e){var n=e.as(Sr).message;ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var i=r._createPendingScheduledUserMessage(e,a,s);r._markMessageAsFailed(i,n),ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,i)]}))}))}))}))}))},s.prototype.sendFileMessage=function(e){var t=u(u({},ln),e);return D(pn(t)).throw(O.invalidParameters),this._sendFileMessage(t)},s.prototype.sendMultipleFilesMessage=function(e){var t,r=u(u({},ni),e),i=n.of(this._iid);D(function(e,t){return void 0===t&&(t=ie),$t(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return ri(e)}))}(r,null===(t=i.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(O.invalidParameters);var s=!!e.fileInfoList.find((function(e){var t=i.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return D(!s).throw(O.fileSizeLimitExceededError),this._sendMultipleFilesMessage(r)},s.prototype._sendFileMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid).dispatcher,a=ea.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new Xt;return Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u);s.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(r)]}))}))})),a.request(i,o,e).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u),a=n.of(i._iid).cacheContext,l=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,l),s.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:t.code===P.FILE_UPLOAD_CANCEL_FAILED?C.LOCAL_MESSAGE_CANCELED:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,r)]}))}))}))}))}))})),c},s.prototype._autoResendFileMessage=function(e){D(e instanceof St&&!!e.messageParams).throw(O.invalidParameters);var t=n.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,di.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},s.prototype._sendMultipleFilesMessage=function(e,t,r){var i=this,s=n.of(this._iid).dispatcher,a=ea.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new ii;return Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);s.dispatch(new N({messages:[n],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(n)]}))}))})),a.request(i,o,e,{requestHandler:c,isCopy:t===di.COPY}).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);i._markMessageAsFailed(n,t),s.dispatch(new N({messages:[n],source:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,n)]}))}))}))}))}))})),c},s.prototype._createScheduledFileMessage=function(e,t,r,i){var s=this,a=n.of(this._iid).requestQueue,o=new Ar(u(u({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(Ur).message;ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var a=s._createPendingScheduledFileMessage(e,r,i);s._markMessageAsFailed(a,n),ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,a)]}))}))}))}))}))},s.prototype.sendFileMessages=function(e){var t,n;D(e.every((function(e){return pn(u(u({},ln),e))}))).throw(O.invalidParameters);var r=new Xt;try{for(var i=v(e),s=i.next();!s.done;s=i.next()){var a=s.value;this.sendFileMessage(a).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{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},s.prototype.resendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){return n=this._validateFailedFileMessageHasFile(e,t),D(e instanceof St&&n&&!e.scheduledInfo).throw(O.invalidParameters),r=new V,i=fn(e,t),this._sendFileMessage(i,di.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),[2,r.promise]}))}))},s.prototype.resendMessage=function(e,t){var n,r;if(D(e instanceof mt&&!e.scheduledInfo&&e.isResendable).throw(O.invalidParameters),e.isUserMessage()){var i=null!==(n=e.messageParams)&&void 0!==n?n:sn(e);return this._sendUserMessage(i,di.RESEND,e.reqId)}if(e.isFileMessage()){var s=this._validateFailedFileMessageHasFile(e,t);D(s).throw(O.invalidParameters);i=null!==(r=e.messageParams)&&void 0!==r?r:fn(e,t);return this._sendFileMessage(i,di.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.updateFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},gn),t),D(h("number",e)&&function(e){return vn(e)}(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new yr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(_r).message]}}))}))},s.prototype.uploadFile=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=n.of(this._iid).requestQueue,r=se(),(i=new Pe({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:r})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(r),[4,t.send(i)];case 1:return s=c.sent(),a=s.as(ke),o=a.url,u=a.thumbnails,[2,{requestId:r,url:o,thumbnails:u}]}}))}))},s.prototype.cancelUploadingFileMessage=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),ea.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},s.prototype.copyFileMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof St&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),o=new V,c=t(u(u({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=n.thumbnails)||void 0===a?void 0:a.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(c).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.copyMessage=function(e,t){D(e instanceof s&&t instanceof mt&&t.sendingStatus===k.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(O.invalidParameters);var n=t,r=e;if(n.isUserMessage()){D(!n.poll).throw(O.notSupportedError);var i=nn(n);return r._sendUserMessage(i)}if(n.isFileMessage()){i=dn(n);return r._sendFileMessage(i)}if(t.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.deleteMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(e instanceof pt).throw(O.invalidParameters),e.messageId>0?(t=n.of(this._iid).requestQueue,r=new de({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof mt?e._messageToken:void 0}),[4,t.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},s.prototype.addReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new gr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(br).reactionEvent]}}))}))},s.prototype.deleteReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Ir({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Er).reactionEvent]}}))}))},s.prototype._updateUserMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new mr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(vr).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype._updateFileMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new yr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(_r).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype.createMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new je({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},s.prototype.deleteMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new je({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},s.prototype.addMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof je}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},s.prototype.removeMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof je}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},s.prototype.report=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return D(f(hn,e)&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new lr({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:t}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.reportUser=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof c&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new dr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.userId,category:t,description:r}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.reportMessage=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof mt&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new hr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:t,description:r,messageToken:e._messageToken}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.updatePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(h("number",e)&&function(e){return h("string",e.title,!0)&&te(e.data)&&h("boolean",e.allowUserSuggestion,!0)&&h("boolean",e.allowMultipleVotes,!0)&&h("number",e.closeAt,!0)}(t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Nr(u({pollId:e},t)),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Cr).poll]}}))}))},s.prototype.deletePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i;return U(this,(function(s){switch(s.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Or({pollId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},s.prototype.closePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Pr({pollId:e}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(kr).poll]}}))}))},s.prototype.addPollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=h("number",e)&&h("string",t)&&""!==t.trim(),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Rr({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(xr).poll]}}))}))},s.prototype.updatePollOption=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return i=h("number",e)&&h("number",t)&&h("string",r)&&""!==r.trim(),D(i).throw(O.invalidParameters),s=n.of(this._iid).requestQueue,a=new Dr({pollId:e,pollOptionId:t,optionText:r}),[4,s.send(a)];case 1:return o=u.sent(),[2,o.as(Lr).poll]}}))}))},s.prototype.deletePollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return r=h("number",e)&&h("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Fr({pollId:e,pollOptionId:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},s.prototype.votePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a,o,u,c;return U(this,(function(l){switch(l.label){case 0:return r=h("number",e)&&d("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid),s=i.requestQueue,a=i.dispatcher,o=new qr({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(zr).event,a.dispatch(new he({event:c,source:C.EVENT_POLL_VOTED})),[2,c]}}))}))},s.prototype.getPollChangeLogsSinceTimestamp=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("number",e)).throw(O.invalidParameters),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.getPollChangeLogsSinceToken=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("string",e,!0)),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new ce(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},s.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new le(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},s.prototype.pinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new ci({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s.prototype.unpinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new li({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s}(l),mi=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 r(t,e),t}((function(){this.onConnected=Y,this.onReconnectStarted=Y,this.onReconnectSucceeded=Y,this.onReconnectFailed=Y,this.onDisconnected=Y})),vi=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 r(t,e),t}((function(){this.onSessionExpired=Y,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=Y,this.onSessionRefreshed=Y,this.onSessionClosed=Y})),yi=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 r(t,e),t}((function(){this.onFriendsDiscovered=Y,this.onTotalUnreadMessageCountChanged=Y,this.onTotalUnreadMessageCountUpdated=Y})),_i=function(t){function n(n){var r=n.limit,s=n.token,a=n.userIdsFilter,o=n.metaDataKeyFilter,u=n.metaDataValuesFilter,c=n.nicknameStartsWithFilter,l=t.call(this)||this;return l.method=i.GET,l.path=pe,l.params=e({limit:r,token:s,user_ids:a,metadatakey:o,metadatavalues_in:u,nickname_startswith:c}),l}return r(n,t),n}(a),gi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),bi=function(e){function i(t,n){var r,i,s,a=this;return(a=e.call(this,t,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)&&h("string",this.metaDataKeyFilter,!0)&&d("string",this.metaDataValuesFilter,!0)&&h("string",this.nicknameStartsWithFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new _i(t(u(u({},this),{token:this._token}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(gi),a=s.users,o=s.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),Ii=function(t){function n(n){var r=n.userId,s=n.limit,a=n.token,o=n.userIdsFilter,u=t.call(this)||this;return u.method=i.GET,u.path="".concat(pe,"/").concat(r,"/block"),u.params=e({limit:s,token:a,user_ids:o}),u}return r(n,t),n}(a),Ei=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Ti=function(e){function i(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Ii(t(u(u({},this),{userId:r.userId,token:this._token}))),[4,i.send(s)]):[3,2]:[3,5];case 1:return a=d.sent(),o=a.as(Ei),c=o.users,l=o.next,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,c];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),wi=function(e){function t(t){var n=t.userId,r=t.limit,s=t.token,a=e.call(this)||this;return a.method=i.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(n),"/friends"),a.params={limit:r,token:s},a}return r(t,e),t}(a),Mi=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 c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Si=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),t=e.sdkState,r=e.requestQueue,i=new wi(u(u({},this),{userId:t.userId,token:this._token})),[4,r.send(i)]):[3,2]:[3,5];case 1:return s=d.sent(),a=s.as(Mi),o=a.users,c=a.hasMore,l=a.next,this._token=l,this._hasNext=c,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(me),Ai={},Ui=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,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,d=void 0===l?11:l,h=e.transactionApplyDelay,f=void 0===h?200:h,p=e.disableLogger,m=void 0!==p&&p;return Ai[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=c,this.blockHashConstant=d,this.transactionApplyDelay=f,this.disableLogger=m,Ai[t]=this),Ai[t]}return e.get=function(e){return Ai[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_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"}(fi||(fi={}));var Ni,Ci=function(e){function t(n){var r=n.code,i=void 0===r?fi.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 r(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:fi.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.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:fi.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:fi.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:fi.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:fi.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:fi.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:fi.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:fi.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:fi.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:fi.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:fi.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"}(Ni||(Ni={}));var Oi,Pi=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Ci.circularReferenceFound;t.set(e,!0);var n=void 0;if(Array.isArray(e))n=e.map((function(e){return Pi(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]=Pi(e[r],t);return t.delete(e),n}return e},ki=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Ci.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Ri=function(e,t){for(var n=0,r=0;r>>0)%t},xi=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Di=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!Di(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Di(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(!(ki(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(ki(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(ki(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(ki(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)},Li=function(){},Fi=function(){return Promise.resolve()},qi=function(e){return e},zi=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Oi||(Oi={}));var Bi,Ki,ji,Qi=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?qi:a,u=e.backward,c=void 0===u?Fi:u,l=e.forward,d=void 0===l?Fi:l,h=e.complete,f=void 0===h?Li:h;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=c,this._forward=d,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 A(this,void 0,void 0,(function(){var e,t,n;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(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}(),Gi=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 u in this.condition[s])if(o.includes(u))for(var c=r;c>=0;c--)if(a*ki(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(a*ki(this._indexer.origin[c].columnValues[i],this.condition[s])<=0){r=c;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var d=function(r){var i=h._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),h.condition[i])if("object"==typeof h.condition[i])Object.keys(h.condition[i]).forEach((function(a){if((s>0?t:n).includes(a))for(var o=l;o=0){l=o;break}}));else for(var a=l;a=0){l=a;break}},h=this,i=0;i-1){var r=this._items[n];return t===ji.PERSISTENT&&(r.state=Ki.PERSISTENT),t!==ji.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)ts.includes(this._items[r].state)&&ts.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 i=this._items.filter((function(e){return e.state===Ki.VOLATILE})),s=i.length-this._limit;if(s>0){var a=[];try{for(var o=v(this._items),u=o.next();!u.done;u=o.next()){var c=u.value;c.state===Ki.VOLATILE&&s>0?s--:a.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this._items=a}}}},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.clearForDatabase=function(e){this.clearByCondition((function(t){return t.key.startsWith(Hi(e))}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==Ki.VOLATILE}))},e}(),is=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(Wi(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(Wi(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=[]),A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,p([],m(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],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,c,l,d;return U(this,(function(h){switch(h.label){case 0:n=rs.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return u(u({},e.data),{generation:r})})))];case 2:for(a=h.sent(),o=0;o0))return[3,4];for(t=[],n={},o=e.length-1;o>=0;o--)r=e[o],l=r.data,n[l.key]||(n[l.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=p.sent(),[4,this._store.set({key:this.recordsetKey,value:s})];case 2:return p.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(p.sent(),a=rs.get(this.dbname),o=0;o0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=a.sent())&&(s=ss.createFromCacheItem(i),null==s?void 0:s.getItemByKey(e)))return[2,s];a.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return n=Ui.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,rs.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(null==(a=s?ss.createFromCacheItem(s):new ss({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:a.add(t))?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(this,(function(r){switch(r.label){case 0:return e=Ji(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(),rs.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),os={},us=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 u=function(e,t,n){return"".concat(Wi(e,t),"/index.").concat(n)}(t,n,i.join(">"));return os[u]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=u,this._transaction=s,this._store=a,this._transaction.on(Bi.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Bi.ERROR,this.indexerKey,(function(){return o.abort()}))),os[u]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in os)delete os[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=m(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=m(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var a=v(this.fields),o=a.next();!o.done;o=a.next()){var u=o.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw Ci.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=ki(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 A(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,y;return U(this,(function(_){switch(_.label){case 0:return[4,(e=rs.get(this.dbname)).find(this._store,this.indexerKey,ji.PERSISTENT)];case 1:return(t=_.sent())?[3,11]:(n=Ji(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=_.sent(),_.label=3;case 3:_.trys.push([3,8,9,10]),i=v(r),s=i.next(),_.label=4;case 4:return s.done?[3,7]:(a=s.value).startsWith(n)?[4,e.find(this._store,a,ji.NO_CACHE)]:[3,6];case 5:if(o=_.sent(),u=ss.createFromCacheItem(o))try{for(m=void 0,c=v(u.items),l=c.next();!l.done;l=c.next())d=l.value,this._addItem(d)}catch(e){m={error:e}}finally{try{l&&!l.done&&(y=c.return)&&y.call(c)}finally{if(m)throw m.error}}_.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return h=_.sent(),f={error:h},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=Pi(this._origin),_.label=12;case 12:return os[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return rs.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete os[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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=Pi(this._origin)},e.prototype.abort=function(){this._table=Pi(this._origin)},e}(),cs=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},ls=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"}($i||($i={})),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"}(es||(es={}));var ds,hs={},fs=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=$i.PROCESSING,this._queue=[],this._activationQueue=[],hs[e]&&!t.forceCreate||(this.nodeId=ls(),this.key=e,cs()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data;if(null==i?void 0:i.isNestDbMessage){var s=i.nodeId,a=i.requestId,o=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&o===n.key)switch(u){case es.NEWNODE:n._sendSync();break;case es.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case es.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,d=l.currentItemRequestId,h=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:es.REQUEST_LOCK,ts:e.ts})};try{for(var p=v(h),m=p.next();!m.done;m=p.next()){f(m.value)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case es.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case es.REQUEST_LOCK:n._requestLock(i);break;case es.ACQUIRE_LOCK:var y=n._queue.find((function(e){return e.requestId===a}));n._acquire(y);break;case es.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(es.REMOVENODE)}))),hs[e]=this),hs[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==$i.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:ls(),key:this.key,op:e,data:t.data,ts:Date.now()};return cs()&&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(es.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(es.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(es.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 A(this,void 0,void 0,(function(){var e=this;return U(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=$i.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(es.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(es.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(es.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}(),ps=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=Ni.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=p([[r]],m(s.filter((function(e){return us.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new fs(function(e,t){return"".concat(Wi(e,t),".lock")}(t,n)),this._blobContainer=new Zi({dbname:t,collectionName:n,store:a}),this._transaction=new is({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return r=Yi(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===Ni.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,y,_=this;return U(this,(function(g){switch(g.label){case 0:return[4,this._mutex.lock()];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,9,,10]),t=Ui.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=g.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:g.sent(),this._blockManager=new as({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=p([],m(this.indexes),!1),i=[],s=r.map((function(e){return us.createKey(e)})),a=n?n.indexes.map((function(e){return us.createKey(e)})):[];try{for(o=v(a),u=o.next();!u.done;u=o.next())c=u.value,s.includes(c)||i.push(us.parseKey(c))}catch(e){f={error:e}}finally{try{u&&!u.done&&(y=o.return)&&y.call(o)}finally{if(f)throw f.error}}return(l=[]).push.apply(l,p([],m(r.map((function(e){var t=new us({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,p([],m(i.map((function(e){return new us({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return g.sent(),[4,this._transaction.commit()];case 6:return g.sent(),s.sort().join(",")===a.sort().join(",")?[3,8]:(d=Yi(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:d,value:this._metadata})]);case 7:g.sent(),g.label=8;case 8:return this._state=Ni.READY,this._mutex.unlock(),[3,10];case 9:throw h=g.sent(),this._mutex.unlock(),h;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Ni.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=us.createKey(e);try{for(var i=v(this._indexers),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===us.createKey(a.fields))return a}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw Ci.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return e=Yi(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return o.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return o.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return o.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:o.sent(),o.label=5;case 5:o.trys.push([5,10,11,12]),n=v(this._indexers),r=n.next(),o.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:o.sent(),o.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=o.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw Ci.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=v(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),a=v(this._indexers),o=a.next(),p.label=16;case 16:return o.done?[3,20]:0===(u=o.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return o=a.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),h={error:c},[3,23];case 22:try{o&&!o.done&&(f=a.return)&&f.call(a)}finally{if(h)throw h.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=v(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return a=c.sent(),o={error:a},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=o.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:o.sent(),o.label=3;case 3:o.trys.push([3,8,9,10]),n=v(this._indexers),r=n.next(),o.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:o.sent(),o.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=o.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return U(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=v(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(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,Pi(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Ci.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new Vi({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ci.collectionNotReady},e.prototype.insertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestInsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpdate(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p,m,y=this;return U(this,(function(_){switch(_.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:_.sent(),_.label=2;case 2:return _.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,a=e.backward,o=void 0!==a&&a,u=[],[4,new Gi({condition:r,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(s)}).each((function(e){return A(y,void 0,void 0,(function(){var n,i;return U(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Di(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];else t.set(n);u.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:_.sent(),_.label=4;case 4:_.trys.push([4,9,10,11]),c=v(u),l=c.next(),_.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestUpdate(Pi(d))]);case 6:_.sent(),_.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return h=_.sent(),p={error:h},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return _.sent(),this._mutex.unlock(),[2,u];case 13:return f=_.sent(),[4,this._transaction.clear()];case 14:throw _.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),Ci.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m=this;return U(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,a=void 0!==s&&s,o=[],[4,new Gi({condition:n,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(i)}).each((function(e){return A(m,void 0,void 0,(function(){var t,r;return U(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Di(n,t)&&(r=t[this.keyName],o.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=v(o),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return d=y.sent(),f={error:d},[3,11];case 10:try{c&&!c.done&&(p=u.return)&&p.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,o];case 13:throw h=y.sent(),this._mutex.unlock(),h;case 14:return[3,16];case 15:throw this._transaction.clear(),Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),ms="[NESTDB]",vs=!0,ys=function(){function e(){}return e.off=function(){vs=!1},e.log=function(){for(var e=[],t=0;t1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return A(o,void 0,void 0,(function(){var n,i;return U(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw Ci.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}}))}))})))]:[3,4];case 3:return a=u.sent(),[3,5];case 4:a=[r],u.label=5;case 5:return s=a,[2,this.encryption.decrypt(JSON.parse(s.join("")))];case 6:return u.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,u({},e.value)]}}))}))},e.prototype.setMany=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,p([],m(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a=this;return U(this,(function(o){switch(o.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=o.sent())?(r=n.metadata,i=this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return a._getRawKey(e,".".concat(t))})),[4,this._removeRaw(i)]):[3,3];case 2:return o.sent(),null==(s=rs.get(this.dbname))||s.remove(e),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d=this;return U(this,(function(h){switch(h.label){case 0:t=rs.get(this.dbname),n=[],r=function(e){var r,s,a;return U(this,(function(o){switch(o.label){case 0:return r=i._getRawKey(e,".0"),[4,i._getRaw(r)];case 1:return(s=o.sent())&&(a=s.metadata,n.push.apply(n,p([],m(i._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return d._getRawKey(e,".".concat(t))}))),!1))),null==t||t.remove(e),[2]}}))},i=this,h.label=1;case 1:h.trys.push([1,6,7,8]),s=v(e),a=s.next(),h.label=2;case 2:return a.done?[3,5]:(o=a.value,[5,r(o)]);case 3:h.sent(),h.label=4;case 4:return a=s.next(),[3,2];case 5:return[3,8];case 6:return u=h.sent(),c={error:u},[3,8];case 7:try{a&&!a.done&&(l=s.return)&&l.call(s)}finally{if(c)throw c.error}return[7];case 8:return n.length>0?[4,this._removeRaw(n)]:[3,10];case 9:h.sent(),h.label=10;case 10:return[2,e]}}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){return null==(e=rs.get(this.dbname))||e.clearForDatabase(this.dbname),[2]}))}))},e}(),bs={},Is=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,u(u({},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 r(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return bs[this.dbname]},set:function(e){bs[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(bs[this.dbname])return[2,Object.keys(bs[this.dbname])];throw Ci.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return bs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:return t.sent(),[2,bs[this.dbname][e]?u({key:e},bs[this.dbname][e]):null];case 2:throw Ci.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return bs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:c.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,s=r.data,a=r.metadata,bs[this.dbname][i]=Object.freeze({data:s,metadata:a})}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}}return[3,3];case 2:throw Ci.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return bs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:a.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,bs[this.dbname][r]&&delete bs[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw Ci.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 A(this,void 0,void 0,(function(){return U(this,(function(e){return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,bs[this.dbname]||(bs[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.set=function(t){return A(this,void 0,void 0,(function(){var n,r;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u;return U(this,(function(c){try{for(n=v(t),r=n.next();!r.done;r=n.next())if(i=r.value,(s=this.observer[i.key])&&"function"==typeof s.set&&(a=s.set()))throw a}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return t.sent(),[4,xi(this.delay)];case 2:return t.sent(),bs[this.dbname]={},[2]}}))}))},t}(gs),Es="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(ds||(ds={}));var Ts,ws=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=Es,r._state=ds.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 r(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype.isTransactionInactiveError=function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")},t.prototype._putToObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.put(t);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))]}))}))},t.prototype._deleteFromObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.delete(t);i.addEventListener("success",(function(){return n(t)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))]}))}))},t.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=ds.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Es,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=ds.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=ds.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=ds.UNINITIALIZED,r(e.target.error)}))}else r(Ci.storeNotAvailable)}))},t.prototype._getObjectStore=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 ds.UNINITIALIZED:case ds.OPEN:return[3,2];case ds.OPENING:case ds.CLOSED:return[3,3]}return[3,4];case 2:throw Ci.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 A(this,void 0,void 0,(function(){var e;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._putToObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._putToObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._deleteFromObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._deleteFromObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){var e,t=this;return U(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||!cs())return[3,4];if(!(cs()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Ci.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(Ci.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),t._indexedDb){var i=t._indexedDb.deleteDatabase("_testMozilla");i.onerror=function(){return e()},i.onsuccess=function(){return e()}}else n(Ci.storeNotAvailable)}}catch(e){n(Ci.storeNotAvailableInPrivateBrowsing)}else n(Ci.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Ci.storeNotAvailable;case 5:return[3,7];case 6:throw Ci.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(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(),[4,this._resetIfEncryptionChanged()];case 3:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this._getObjectStore("readwrite")];case 2:return t=n.sent(),[4,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 3:return[2,n.sent()]}}))}))},t}(gs),Ms=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?2097152:i,a=ye(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,u(u({},a),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:t=[];try{for(n=v(e),r=n.next();!r.done;r=n.next())i=r.value,s=i.key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(s),JSON.stringify(i)])}catch(e){a={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return u.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._asyncStorage)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}}))}))},t}(gs),Ss=function(e){function t(t){var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._mmkv)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}}))}))},t}(gs);!function(e){e.INIT="INIT",e.OPENING="OPENING",e.OPENED="OPENED",e.CLOSED="CLOSED"}(Ts||(Ts={}));var As,Us=function(){function e(e){var t=e.name,n=e.version,r=e.store,i=e.config;this.name=t,this._version=n,this._state=Ts.INIT,this._config=i||new Ui({dbname:t}),this._store=r,this._event={success:Li,error:Li,storeReplaced:Li,upgrade:zi},this._collections=new Map,this._globalMutex=new fs("".concat(this.name,".lock")),this._config.disableLogger&&ys.off(),new rs({dbname:t,limit:this._config.cacheLimit})}return Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),e.prototype.estimateUsage=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,(t=this._store,A(void 0,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,t.usage()];case 1:return[2,e.sent()]}}))})))];case 1:return[2,e.sent()]}var t}))}))},e.prototype.commitSchema=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this._state!==Ts.OPENING?[3,2]:[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=e.collectionName,n=e.keyName,r=e.index,i=void 0===r?[]:r,this._collections.has(t)||this._collections.set(t,new ps({dbname:this.name,collectionName:t,keyName:n,indexes:i,store:this._store})),(s=this._collections.get(t))?[4,s.init()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[3,3];case 2:throw Ci.databaseSchemaNotOnUpgrade;case 3:return[2]}}))}))},e.prototype.open=function(){var e;return A(this,void 0,void 0,(function(){var t,n,r,i,s=this;return U(this,(function(a){switch(a.label){case 0:return[4,this._globalMutex.lock()];case 1:if(a.sent(),this._state===Ts.OPENED)return[3,12];this._state=Ts.OPENING,a.label=2;case 2:return a.trys.push([2,5,,12]),[4,this._store.init(this.name)];case 3:return a.sent(),o=this.name,t="".concat(Hi(o),".metadata"),n={version:0,collectionNames:[]},[4,this._store.get(t)];case 4:return r=null!==(e=a.sent())&&void 0!==e?e:n,[2,new Promise((function(e,n){var i=function(e){r.version0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof mt))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof pt)switch(this.replyType){case H.NONE:if(e.parentMessageId>0)return!1;break;case H.ONLY_REPLY_TO_CHANNEL:if(e instanceof mt&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Ns||(Ns={}));var Ps,ks=function(e){switch(e){case Ns.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Ns.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Rs=function(){return["channelUrl","-createdAt","-notificationId"]},xs=u(u({},tn),{scheduledAt:void 0}),Ds=function(e){return an(e)&&h("number",e.scheduledAt,!0)},Ls=u(u({},Zt),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Fs=function(e){return $t(e)&&h("number",e.scheduledAt)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},qs="UnsentMessage",zs="reqId",Bs={},Ks=function(t){function i(e){var n=t.call(this,e)||this;return n._mutex=new fs("unsendmessagecache.lock"),Bs[e]=n,n}return r(i,t),Object.defineProperty(i.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),i.of=function(e,t){return void 0===t&&(t=!1),Bs[e]&&!t||(Bs[e]=new i(e)),Bs[e]},Object.defineProperty(i.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(qs);if(!t)throw O.databaseError;return t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),i.prototype._serialize=function(t){if(t.messageId>0)throw O.invalidParameters;var n,r=u({},t.serialize());return t instanceof It?(t.messageParams&&(r.messageParams=en(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=(n=t.scheduledInfo.scheduledMessageParams,u(u({},en(n)),{scheduledAt:n.scheduledAt})))):t instanceof St?(t.messageParams&&(r.messageParams=cn(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=function(e){return u(u({},cn(e)),{scheduledAt:e.scheduledAt})}(t.scheduledInfo.scheduledMessageParams))):t instanceof Et&&t.messageParams&&(r.messageParams=function(t){return e({fileInfoList:t.fileInfoList,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption})}(t.messageParams)),r},i.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),ea.of(this._iid).buildMessageFromSerializedData(e)},i.prototype._deserializeWithMessageCreateParams=function(e){var t,n,r;return A(this,void 0,void 0,(function(){var i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return i=ea.of(this._iid),s=this._deserialize(e),e.messageParams?s instanceof It?(o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),[3,6]):[3,1]:[3,6];case 1:return s instanceof St?(o=e.messageParams).fileKey&&"string"==typeof o.fileKey&&un(null!==(t=o.fileType)&&void 0!==t?t:"")?(a=o,[4,this.collection.getBlob(o.fileKey)]):[3,3]:[3,4];case 2:a.file=null!==(n=d.sent())&&void 0!==n?n:void 0,d.label=3;case 3:return s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(o,s),[3,6];case 4:return s instanceof Et&&((o=e.messageParams)&&o.fileInfoList)?(s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(o,s),[4,Promise.all(s.messageParams.fileInfoList.map((function(e){return A(l,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&un(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!==(s=a.sent())&&void 0!==s?s:void 0,a.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:d.sent(),d.label=6;case 6:return s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?s instanceof It?(u=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(u,s),[3,10]):[3,7]:[3,10];case 7:return s instanceof St?(u=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof u.fileKey&&"string"==typeof u.fileType&&un(u.fileType)?(c=u,[4,this.collection.getBlob(u.fileKey)]):[3,9]:[3,10];case 8:c.file=null!==(r=d.sent())&&void 0!==r?r:void 0,d.label=9;case 9:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(u,s),d.label=10;case 10:return[2,s]}}))}))},i.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},i.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new Os:n,i=e.order,s=void 0===i?Ns.CHANNEL_LATEST:i,a=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return A(this,void 0,void 0,(function(){var e,n,i,o,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?(e=ks(s),n={"/where":function(e){return!!(s!==Ns.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(l._deserialize(e))}},t&&(n.channelUrl=t),a&&(n.sendingStatus=a),i={where:n,index:e,backward:u},[4,this.collection.query(i)]):[3,3];case 1:return[4,d.sent().fetch({})];case 2:return o=d.sent(),[2,Promise.all(o.map((function(e){return A(l,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},i.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Os),A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:Ns.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},i.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return e instanceof St||e instanceof Et?[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]}}))}))},i.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},i.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.saveBlob=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i=this;return U(this,(function(s){switch(s.label){case 0:return e instanceof St?e.messageParams&&(r=e.messageParams).file&&on(r.file)?[4,this.collection.saveBlob(r.file,e.reqId)]:[3,2]:[3,5];case 1:n=s.sent(),r.fileKey=n,r.fileType=rn.BLOB,s.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&on(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=s.sent(),t.fileKey=n,t.fileType=rn.BLOB,s.label=4;case 4:return[3,7];case 5:return e instanceof Et&&((r=e.messageParams)&&r.fileInfoList&&Array.isArray(r.fileInfoList))?[4,Promise.all(r.fileInfoList.map((function(t,n){return A(i,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return t.file&&on(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=rn.BLOB,i.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},i}(l),js={},Qs=function(e){function t(t){var n=e.call(this,t)||this;return js[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Ks.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),js[e]&&!n||(js[e]=new t(e)),js[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Gr)},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 u(u({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),ea.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Os:s,o=e.order,u=void 0===o?Ns.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,d=e.parentMessageId,h=e.isPollOnly,f=void 0!==h&&h,p=e.exactMatch,m=void 0!==p&&p,v=e.inclusive,y=void 0===v||v;return A(this,void 0,void 0,(function(){var e,r,s,o=this;return U(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=ks(u),r={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Ns.CHANNEL_LATEST:if(m&&e.createdAt!==n)return!1;if(l){if(y&&e.createdAtn||!y&&e.createdAt>=n)return!1;break;case Ns.NEWEST_CHILD_MESSAGE:if(!d||0===e.parentMessageId||e.parentMessageId!==d)return!1}return!(f&&!e._poll)&&a.match(o._deserialize(e))}},index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({limit:null!=i?i:void 0})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return A(o,void 0,void 0,(function(){return U(this,(function(t){return[2,this._deserialize(e)]}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Os),A(this,void 0,void 0,(function(){return U(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:Ns.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,13];case 1:d.sent(),d.label=2;case 2:d.trys.push([2,7,8,9]),n=v(e),r=n.next(),d.label=3;case 3:return r.done?[3,6]:(i=r.value,(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)?[4,this.get(i.messageId)]:[3,5]);case 4:(null==(s=d.sent())?void 0:s.threadInfo)&&i.threadInfo._updateFrom(s.threadInfo),d.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return a=d.sent(),u={error:a},[3,9];case 8:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 9:return o=e.map((function(e){return l._serialize(e)})),[4,this.collection.upsertMany(o)];case 10:return d.sent(),[4,this.upsertChildMessages(e)];case 11:return d.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 12:d.sent(),d.label=13;case 13:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:ks(Ns.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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:ks(Ns.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=ks(Ns.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 A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return e instanceof St&&e.messageParams&&((t=e.messageParams).file&&on(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.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=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return s=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return a=o.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),s&&(t+=JSON.stringify(s).length),a&&(t+=JSON.stringify(a).length),[2,t]}}))}))},t}(l),Gs={},Vs=function(e){function t(t){var n=e.call(this,t)||this;return Gs[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),Gs[e]&&!n||(Gs[e]=new t(e)),Gs[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Wr)},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 u({},e.serialize())},t.prototype._deserialize=function(e){return ea.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Os:s,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,d=e.inclusive,h=void 0===d||d;return A(this,void 0,void 0,(function(){var e,r=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(e={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(h&&e.createdAtn||!h&&e.createdAt>=n)return!1}return a.match(r._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},[4,this.collection.query(e)]):[3,3];case 1:return[4,s.sent().fetch({limit:null!=i?i:void 0})];case 2:return[2,s.sent().map((function(e){return r._deserialize(e)}))];case 3:return[2,[]]}}))}))},t.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?(t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.markAsReadByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,messageStatus:ft.SENT,createdAt:{"<":t}}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.markAsReadByMessageIds=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:ft.SENT}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:return[2,n.sent().length];case 2:return[2,0]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]})]:[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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:ks(Ns.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=["channelUrl","-createdAt","-notificationId"],[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}(l),Hs={},Ws=function(e){function t(t){var n=e.call(this,t)||this;return n._observers=new Map,n._dispatcherContext=n._dispatcher.on((function(e){return A(n,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,v,y,_,g,b=this;return U(this,(function(E){switch(E.label){case 0:return e instanceof N?(t=e.messages,g=e.source,a=e.isWebSocketEventComing,n=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&e.messageId>0})),r=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&0===e.messageId})),i=t.filter((function(e){return e instanceof Tt})),n.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(n)];case 1:return e.sent(),[4,this._unsentMessageCache.remove(n.map((function(e){return e instanceof mt?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,7];case 1:E.sent(),a||this._broadcastUpdateEvent(n,g),E.label=2;case 2:return r.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.upsert(r)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:E.sent(),a||this._broadcastUpdateEvent(r,g),E.label=4;case 4:return i.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._notificationCache.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,6];case 5:E.sent(),a||this._broadcastUpdateEvent(i,g),E.label=6;case 6:return[3,24];case 7:return e instanceof we?(s=e.messageIds,g=e.source,a=e.isWebSocketEventComing,o=s.filter((function(e){return"number"==typeof e})),u=s.filter((function(e){return"string"==typeof e})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return o.length>0?[4,this._messageCache.remove(o)]:[3,2];case 1:e.sent(),e.label=2;case 2:return u.length>0?[4,this._notificationCache.remove(u)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))}))]):[3,9];case 8:return E.sent(),a||this._broadcastRemoveEvent(s,g),[3,24];case 9:return e instanceof Te?(c=e.reqId,g=e.source,[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.remove([c])];case 1:return e.sent(),[2]}}))}))}))]):[3,11];case 10:return E.sent(),this._broadcastRemoveUnsentEvent(c,g),[3,24];case 11:return e instanceof Ee?(l=e.polls,g=e.source,this._cacheContext.localCacheEnabled?(d=l.map((function(e){return e.messageId})),[4,Promise.all(d.map((function(e){return b._messageCache.get(e)})))]):[3,14]):[3,15];case 12:return(h=E.sent().filter((function(e){return e}))).length>0&&l.forEach((function(e){var t=h.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(h)];case 1:return[2,e.sent()]}}))}))}))];case 13:E.sent(),E.label=14;case 14:return this._broadcastPollChangeLogEvent(l,g),[3,24];case 15:return e instanceof Ie?(f=e.event,g=e.source,[4,this._messageCache.get(f.messageId)]):[3,19];case 16:return(p=E.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollUpdateEvent(f)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([p])];case 1:return[2,e.sent()]}}))}))}))]:[3,18];case 17:E.sent(),E.label=18;case 18:return this._broadcastPollUpdateEvent(f,g),[3,24];case 19:return e instanceof he?(m=e.event,g=e.source,[4,this._messageCache.get(m.messageId)]):[3,23];case 20:return(v=E.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(m)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,22];case 21:E.sent(),E.label=22;case 22:return this._broadcastPollVoteEvent(m,g),[3,24];case 23:e instanceof _e?(y=e.event,g=e.source,y.messageId>0&&this._broadcastReactionUpdateEvent(y,g)):e instanceof ge&&(_=e.event,g=e.source,this._broadcastThreadUpdateEvent(_,g)),E.label=24;case 24:return[2]}}))}))})),n}return r(t,e),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dispatcher",{get:function(){return n.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_messageCache",{get:function(){return Qs.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Ks.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_notificationCache",{get:function(){return Vs.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){var r;return void 0===n&&(n=!1),Hs[e]&&!n||(Hs[e]&&(null===(r=Hs[e]._dispatcherContext)||void 0===r||r.close()),Hs[e]=new t(e)),Hs[e]},t.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemove&&a.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastReactionUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastThreadUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype.subscribe=function(e,t){this._observers.set(e,t)},t.prototype.unsubscribe=function(e){this._observers.delete(e)},t.prototype.unsubscribeAll=function(){this._observers.clear()},t}(l),Ys=function(t){function n(n){var r=this,s=n.reverse,a=void 0!==s&&s,o=n.limit,u=void 0===o?20:o,c=n.keys,l=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(Me),r.params=e({token:l,limit:u,reverse:a,order:Se.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),r}return r(n,t),n}(a),Js=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.next,s=n.has_more,a=void 0!==s&&s,o=n.templates;return r.nextToken=i,r.hasMore=a,r.templates=o.map((function(e){return{template:JSON.stringify(e)}})),r}return r(t,e),t}(o),Xs=function(e){function t(t){var n=this,r=t.key;return(n=e.call(this)||this).method=i.GET,n.path="".concat(Me,"/").concat(r),n}return r(t,e),t}(a),Zs=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.template=JSON.stringify(n),r}return r(t,e),t}(o),$s={},ea=function(){function n(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=a,Qs.of(e),Ks.of(e),Ws.of(e),this.fileMessageQueue=new Rt(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),$s[e]=this}return n.of=function(e){return $s[e]},n.prototype.buildMessageFromSerializedData=function(e){var t=Ae(e);if(t.notificationId)return new Tt(this._iid,Tt.payloadify(t));switch(t.messageType){case g.USER:return new It(this._iid,It.payloadify(t));case g.FILE:return Et._isMultipleFilesMessageSerializedData(t)?new Et(this._iid,Et.payloadify(t)):new St(this._iid,St.payloadify(t));case g.ADMIN:return new _t(this._iid,_t.payloadify(t))}throw O.invalidParameters},n.prototype.buildUserMessageCreateParamsFromSerializedData=function(n,r){return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,message:r.message,translationTargetLanguages:Object.keys(r.translations),pollId:n.pollId}))},n.prototype.buildFileMessageCreateParamsFromSerializedData=function(n,r){var i;return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,file:n.file,fileKey:n.fileKey,fileUrl:r.plainUrl,fileName:r.name,fileSize:r.size,mimeType:r.type,thumbnailSizes:null===(i=r.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:n.fileType,requireAuth:r.requireAuth}))},n.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(t,n){var r=this;return e({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUserIds:n.mentionedUserIds,mentionedUsers:n.mentionedUsers,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption,appleCriticalAlertOptions:n.appleCriticalAlertOptions,reqId:n.reqId,fileInfoList:t.fileInfoList.map((function(e){return new At(r._iid,e)}))})},n.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildSenderFromSerializedData=function(e){var t=Ae(e);return new Ke(this._iid,Ke.payloadify(t))},n.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new zt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Bt).message]}}))}))},n.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Vt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Ht).message]}}))}))},n.prototype.getMessagesByMessageId=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new Kt(u(u({channelType:t,channelUrl:e,token:String(n)},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(jt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype.getMessagesByTimestamp=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new Kt(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(jt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype._getMessagesByTimestampForCollection=function(e,t,n,r,i,s,a){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var o,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return o=new Kt(u(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r),{checkingHasNext:s,checkingContinuousMessages:a})),[4,this._requestQueue.send(o)];case 1:return c=p.sent(),l=c.as(jt),d=l.messages,h=l.isContinuousMessages,f=l.hasNext,this._dispatcher.dispatch(new N({messages:d,source:i})),[2,{messages:d,isContinuousMessages:h,hasNext:f}]}}))}))},n.prototype.getThreadedMessagesByTimestamp=function(e,t,n,r){return void 0===r&&(r=C.REQUEST_THREADED_MESSAGE),A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return i=new Kt(u(u(u({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},vt),n),{replyType:H.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return s=c.sent(),a=s.as(jt).messages,(o=a.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new N({messages:o,source:r})),[2,{parentMessage:a[0],threadedMessages:o}]}}))}))},n.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return n=new Ys(u({token:e},t)),[4,this._requestQueue.send(n)];case 1:return r=c.sent(),i=r.as(Js),s=i.hasMore,a=i.nextToken,o=i.templates,[2,{hasMore:s,token:a,templates:o}]}}))}))},n.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Xs({key:e}),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,{template:n.as(Zs).template}]}}))}))},n.prototype.getMessageChangelogs=function(n,r,i,s,a){return void 0===a&&(a=C.REQUEST_MESSAGE_CHANGELOGS),A(this,void 0,void 0,(function(){var o,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return o=new Qt(e(t(u(u({channelType:r,channelUrl:n,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},Ft),s)))),[4,this._requestQueue.send(o)];case 1:return c=v.sent(),l=c.as(Gt),d=l.updatedMessages,h=l.deletedMessagesInfo,f=l.hasMore,p=l.nextToken,m=h.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new N({messages:d,source:a})),m.length>0&&this._dispatcher.dispatch(new we({messageIds:m,source:a})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:f,token:p}]}}))}))},n}(),ta=function(e){function t(t,n){var r=e.call(this,t)||this;r.targetMessageId=0;var i=n.thread_info,s=n.parent_message_id,a=n.channel_url,o=n.channel_type;return i&&h("object",i)&&h("number",s)&&h("string",a)&&h("string",o)&&(r.threadInfo=new Re(t,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return r(t,e),t}(l),na={channelUrl:"",channelType:I.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},ra=function(e){function t(t){var n=t.channelCustomType,r=t.keyword,s=t.limit,a=t.reverse,o=t.exactMatch,u=t.channelUrl,c=t.order,l=t.messageTimestampFrom,d=t.messageTimestampTo,h=t.advancedQuery,f=t.targetFields,p=t.nextToken,m=e.call(this)||this;return m.method=i.GET,m.path="".concat(Ue,"/messages"),m.params={custom_type:n,query:r,limit:s,reverse:a,exact_match:o,channel_url:u,message_ts_from:l,message_ts_to:d,sort_field:c,advanced_query:h,target_fields:f,after:p},m}return r(t,e),t}(a),ia=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return Mt(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return r(t,e),t}(o);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Ps||(Ps={}));var sa=function(e){function i(t,n){var r,i,s,a,o,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Ps.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(a=n.channelCustomType)&&void 0!==a?a:"",h.messageTimestampFrom=null!==(o=n.messageTimestampFrom)&&void 0!==o?o:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:Ps.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&h("string",this.keyword)&&this.keyword.length>0&&h("boolean",this.reverse)&&h("boolean",this.exactMatch)&&h("string",this.channelUrl)&&h("string",this.channelCustomType)&&(h("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(h("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&f(Ps,this.order)&&h("boolean",this.advancedQuery)&&d("string",this.targetFields,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new ra(t(u(u({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=d.sent(),s=i.as(ia),a=s.messages,o=s.hasNext,c=s.nextToken,l=s.totalCount,this._nextToken=c,this._hasNext=o,this._isLoading=!1,this.totalCount=l,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),aa=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.limit,u=r.token,c=n.call(this)||this;return c.method=i.GET,c.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages/parent_thread_message"),c.params=e(t({limit:o,token:u})),c}return r(s,n),s}(a),oa=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.next,r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),ua=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s._edge="",s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.load=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new aa({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(oa),s=i.messages,a=i.token,this._edge=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ca={channelUrl:"",scheduledMessageId:0},la={reverse:!1,limit:20},da=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return r(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new ea(t,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},t.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},t.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},t.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=u(u({},na),e),D(function(e){return h("string",e.channelUrl)&&f(I,e.channelType)&&h("number",e.messageId)&&h("boolean",e.includeReactions,!0)&&h("boolean",e.includeMetaArray,!0)&&h("boolean",e.includeParentMessageInfo,!0)&&h("boolean",e.includeThreadInfo,!0)}(t)).throw(O.invalidParameters),[4,this._manager.getMessage(t)];case 1:if((n=r.sent())instanceof pt||n instanceof Tt||null===n)return[2,n];throw"Unknown message type is given."}}))}))},t.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){return t=u(u({},ca),e),D(function(e){return h("string",e.channelUrl)&&""!==e.channelUrl&&h("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(O.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},t.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return n=u(u({},la),t),D(h("string",e,!0)&&function(e){return h("boolean",e.reverse,!0)&&h("number",e.limit,!0)&&d("string",e.keys,!0)}(n)).throw(O.invalidParameters),[2,this._manager.getMessageTemplatesByToken(e,n)]}))}))},t.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),[2,this._manager.getMessageTemplate(e)]}))}))},t}(Ne);export{It as $,Ms as A,Ti as B,mi as C,Sn as D,gt as E,Si as F,Yt as G,Wt as H,ws as I,xt as J,Os as K,Cs as L,Ns as M,Gr as N,En as O,Jt as P,Br as Q,hn as R,vi as S,Mt as T,yi as U,ut as V,si as W,ui as X,Ve as Y,ct as Z,ot as _,Kr as a,Ce as a$,St as a0,ta as a1,Re as a2,Xn as a3,zn as a4,cr as a5,or as a6,sr as a7,tr as a8,rr as a9,di as aA,fn as aB,nn as aC,dn as aD,ti as aE,Xt as aF,He as aG,Sr as aH,hi as aI,ke as aJ,Pe as aK,Ws as aL,_t as aM,De as aN,Zr as aO,Vs as aP,Hr as aQ,ft as aR,Je as aS,We as aT,bt as aU,Ps as aV,Et as aW,Fe as aX,qe as aY,Tn as aZ,Le as a_,zr as aa,pt as ab,Ye as ac,mt as ad,vr as ae,_r as af,pr as ag,Ct as ah,Qr as ai,Tt as aj,ea as ak,mn as al,vn as am,yn as an,_n as ao,Oe as ap,je as aq,ze as ar,wt as as,ua as at,ii as au,xs as av,Ds as aw,Ls as ax,Fs as ay,sn as az,jr as b,Ke as b0,at as b1,Be as b2,xe as b3,lt as b4,dt as b5,st as b6,Vr as c,qs as d,zs as e,Jr as f,ks as g,Xr as h,$r as i,ei as j,Wr as k,Yr as l,Rs as m,As as n,Is as o,Ss as p,da as q,bi as r,sa as s,Qs as t,Ks as u,Ts as v,Us as w,Ui as x,Nn as y,pi as z}; diff --git a/lib/__bundle-ace226dc.js b/lib/__bundle-e53b9010.js similarity index 97% rename from lib/__bundle-ace226dc.js rename to lib/__bundle-e53b9010.js index 3ccedc6..667d378 100644 --- a/lib/__bundle-ace226dc.js +++ b/lib/__bundle-e53b9010.js @@ -1 +1 @@ -import{C as e,c as n,W as t,U as s,g as r,_ as a,b as i,af as o,V as u,au as E,aE as N,u as c,bm as _}from"./__bundle-85fbca74.js";import{T as l,aL as d,aM as h,aN as C,a1 as A}from"./__bundle-3ceb5f92.js";import{P as p}from"./__bundle-acd77193.js";var f;!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"}(f||(f={}));var m=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}(),v=function(e){function t(n,t,s){var r=e.call(this,n,"SYEV",s)||this;return r.event=new m(s),r}return n(t,e),t}(t),T=function(e){function t(n,t,r){var a=e.call(this,n,t,r)||this,i=r.data.operators,o=void 0===i?[]:i;return a.operators=o.map((function(e){return new s(a._iid,e)})),a}return n(t,e),t}(v),g=function(e){function t(n,t,s){var a,i=this;return(i=e.call(this,n,"SYEV",s)||this).pinnedMessageIds=[],i.latestPinnedMessage=null,i.ts=0,s.data&&(i.pinnedMessageIds=null!==(a=s.data.pinned_message_ids)&&void 0!==a?a:[],i.latestPinnedMessage=s.data.latest_pinned_message?l(n,r({},s.data.latest_pinned_message)):null),i.ts=s.ts,i}return n(t,e),t}(t),H=function(e){function t(n,t){var s=e.call(this,n)||this;return s._logger=t.logger,s._sdkState=t.sdkState,s._sessionManager=t.sessionManager,s._requestQueue=t.requestQueue,s._dispatcher=t.dispatcher,s._cacheContext=t.cacheContext,s._channelType=t.channelType,s}return n(t,e),Object.defineProperty(t.prototype,"_messageBroadcast",{get:function(){return d.of(this._iid)},enumerable:!1,configurable:!0}),t.prototype.subscribeMessageEvent=function(e,n){this._messageBroadcast.subscribe(e,n)},t.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},t.prototype.getMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,null]}))}))},t.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,n,t){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getMessagesFromCache=function(e,n,t,s,r,o){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getPollMessagesFromCache=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getCachedMessageCountBetween=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,0]}))}))},t.prototype.getUnsentMessagesFromCache=function(e,n){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.removeFailedMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},t}(o),L=function(e){function t(n,t,s){var r,a,i,o,N=this;(N=e.call(this,n,"ADMM",s)||this).message=new h(n,s);var c=u.of(n).sdkState;return N.isMentioned=E(N.message.mentionType,null!==(i=null!==(r=N.message.mentionedUserIds)&&void 0!==r?r:null===(a=N.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==i?i:[],c.userId),N.forceUpdateLastMessage=null!==(o=s.force_update_last_message)&&void 0!==o&&o,N}return n(t,e),t}(t),I=function(e){function t(n,t,s){var r,a,i,o,E,_=this;(_=e.call(this,n,"AEDI",s)||this).message=new h(n,s);var l=u.of(n).sdkState;return _.mentionCountChange=N({mentionType:null===(r=s.old_values)||void 0===r?void 0:r.mention_type,mentionedUserIds:null!==(i=null===(a=s.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==i?i:[]},c({mentionType:_.message.mentionType,mentionedUserIds:null!==(o=_.message.mentionedUserIds)&&void 0!==o?o:null===(E=_.message.mentionedUsers)||void 0===E?void 0:E.map((function(e){return e.userId}))}),l.userId),_}return n(t,e),t}(t),U=function(e){function t(n,t,s){var r=e.call(this,n,"MRCT",s)||this;return r.channelUrl=s.channel_url,r.channelType=s.channel_type,r.event=new C(s),r}return n(t,e),t}(t),M=function(e){function t(n,t,s){var r=e.call(this,n,"MTHD",s)||this;return r.event=new A(n,s),r}return n(t,e),t}(t),y=function(e){function t(n,t,s){var r=e.call(this,n,"MCNT",s)||this;return r.groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),r.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),r}return n(t,e),t}(t),b=function(e){function t(n,t,s){var r=e.call(this,n,"PEDI",s)||this;return r.event=new p(n,s),r.status=_(s.poll.status)||s.poll.status,r.channelUrl=s.channel_url,r.channelType=s.channel_type,r}return n(t,e),t}(t);export{L as A,H as B,v as C,y as M,T as O,b as P,U as R,M as T,g as U,f as a,I as b}; +import{C as e,c as n,W as t,U as s,g as r,_ as a,b as i,af as o,V as u,au as E,aE as N,u as c,bm as _}from"./__bundle-1db3fd0b.js";import{T as l,aL as d,aM as h,aN as C,a1 as A}from"./__bundle-e1a5e3f1.js";import{P as p}from"./__bundle-acd77193.js";var f;!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"}(f||(f={}));var m=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}(),v=function(e){function t(n,t,s){var r=e.call(this,n,"SYEV",s)||this;return r.event=new m(s),r}return n(t,e),t}(t),T=function(e){function t(n,t,r){var a=e.call(this,n,t,r)||this,i=r.data.operators,o=void 0===i?[]:i;return a.operators=o.map((function(e){return new s(a._iid,e)})),a}return n(t,e),t}(v),g=function(e){function t(n,t,s){var a,i=this;return(i=e.call(this,n,"SYEV",s)||this).pinnedMessageIds=[],i.latestPinnedMessage=null,i.ts=0,s.data&&(i.pinnedMessageIds=null!==(a=s.data.pinned_message_ids)&&void 0!==a?a:[],i.latestPinnedMessage=s.data.latest_pinned_message?l(n,r({},s.data.latest_pinned_message)):null),i.ts=s.ts,i}return n(t,e),t}(t),H=function(e){function t(n,t){var s=e.call(this,n)||this;return s._logger=t.logger,s._sdkState=t.sdkState,s._sessionManager=t.sessionManager,s._requestQueue=t.requestQueue,s._dispatcher=t.dispatcher,s._cacheContext=t.cacheContext,s._channelType=t.channelType,s}return n(t,e),Object.defineProperty(t.prototype,"_messageBroadcast",{get:function(){return d.of(this._iid)},enumerable:!1,configurable:!0}),t.prototype.subscribeMessageEvent=function(e,n){this._messageBroadcast.subscribe(e,n)},t.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},t.prototype.getMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,null]}))}))},t.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,n,t){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getMessagesFromCache=function(e,n,t,s,r,o){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getPollMessagesFromCache=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getCachedMessageCountBetween=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,0]}))}))},t.prototype.getUnsentMessagesFromCache=function(e,n){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.removeFailedMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},t}(o),L=function(e){function t(n,t,s){var r,a,i,o,N=this;(N=e.call(this,n,"ADMM",s)||this).message=new h(n,s);var c=u.of(n).sdkState;return N.isMentioned=E(N.message.mentionType,null!==(i=null!==(r=N.message.mentionedUserIds)&&void 0!==r?r:null===(a=N.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==i?i:[],c.userId),N.forceUpdateLastMessage=null!==(o=s.force_update_last_message)&&void 0!==o&&o,N}return n(t,e),t}(t),I=function(e){function t(n,t,s){var r,a,i,o,E,_=this;(_=e.call(this,n,"AEDI",s)||this).message=new h(n,s);var l=u.of(n).sdkState;return _.mentionCountChange=N({mentionType:null===(r=s.old_values)||void 0===r?void 0:r.mention_type,mentionedUserIds:null!==(i=null===(a=s.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==i?i:[]},c({mentionType:_.message.mentionType,mentionedUserIds:null!==(o=_.message.mentionedUserIds)&&void 0!==o?o:null===(E=_.message.mentionedUsers)||void 0===E?void 0:E.map((function(e){return e.userId}))}),l.userId),_}return n(t,e),t}(t),U=function(e){function t(n,t,s){var r=e.call(this,n,"MRCT",s)||this;return r.channelUrl=s.channel_url,r.channelType=s.channel_type,r.event=new C(s),r}return n(t,e),t}(t),M=function(e){function t(n,t,s){var r=e.call(this,n,"MTHD",s)||this;return r.event=new A(n,s),r}return n(t,e),t}(t),y=function(e){function t(n,t,s){var r=e.call(this,n,"MCNT",s)||this;return r.groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),r.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),r}return n(t,e),t}(t),b=function(e){function t(n,t,s){var r=e.call(this,n,"PEDI",s)||this;return r.event=new p(n,s),r.status=_(s.poll.status)||s.poll.status,r.channelUrl=s.channel_url,r.channelType=s.channel_type,r}return n(t,e),t}(t);export{L as A,H as B,v as C,y as M,T as O,b as P,U as R,M as T,g as U,f as a,I as b}; diff --git a/lib/__definition.d.ts b/lib/__definition.d.ts index 79b1ac4..d31cb4e 100644 --- a/lib/__definition.d.ts +++ b/lib/__definition.d.ts @@ -1089,7 +1089,6 @@ declare abstract class BaseStore { constructor(props: BaseStoreParams); abstract checkAvailability(): Promise; abstract init(dbname: string): Promise; - abstract clear(): Promise; get adjustedItemSizeLimit(): number; usage(): Promise; getAllKeys(): Promise; @@ -1098,6 +1097,7 @@ declare abstract class BaseStore { setMany(items: StoreItem[]): Promise; remove(key: string): Promise; removeMany(keys: string[]): Promise; + clear(): Promise; } declare interface BaseStoreParams { diff --git a/message.js b/message.js index b703d4a..4cd6b0a 100644 --- a/message.js +++ b/message.js @@ -1 +1 @@ -export{aj as MentionType,a$ as MessageReviewStatus,ah as MessageType,aq as MessageTypeFilter,at as PushNotificationDeliveryOption,ay as ReplyType,ao as SendingStatus}from"./lib/__bundle-85fbca74.js";export{aM as AdminMessage,ar as AppleCriticalAlertOptions,ab as BaseMessage,b2 as Feedback,b3 as FeedbackRating,a0 as FileMessage,b4 as MessageForm,b5 as MessageFormItem,b6 as MessageFormItemLayout,aq as MessageMetaArray,q as MessageModule,aF as MessageRequestHandler,aU as MessageReviewInfo,aV as MessageSearchOrder,s as MessageSearchQuery,aW as MultipleFilesMessage,au as MultipleFilesMessageRequestHandler,aX as OGImage,aY as OGMetaData,aZ as PreviousMessageListQuery,a_ as Reaction,aN as ReactionEvent,a$ as ReactionEventOperation,b0 as Sender,a2 as ThreadInfo,a1 as ThreadInfoUpdateEvent,at as ThreadedParentMessageListQuery,ap as Thumbnail,b1 as UploadedFileInfo,$ as UserMessage}from"./lib/__bundle-3ceb5f92.js"; +export{aj as MentionType,a$ as MessageReviewStatus,ah as MessageType,aq as MessageTypeFilter,at as PushNotificationDeliveryOption,ay as ReplyType,ao as SendingStatus}from"./lib/__bundle-1db3fd0b.js";export{aM as AdminMessage,ar as AppleCriticalAlertOptions,ab as BaseMessage,b2 as Feedback,b3 as FeedbackRating,a0 as FileMessage,b4 as MessageForm,b5 as MessageFormItem,b6 as MessageFormItemLayout,aq as MessageMetaArray,q as MessageModule,aF as MessageRequestHandler,aU as MessageReviewInfo,aV as MessageSearchOrder,s as MessageSearchQuery,aW as MultipleFilesMessage,au as MultipleFilesMessageRequestHandler,aX as OGImage,aY as OGMetaData,aZ as PreviousMessageListQuery,a_ as Reaction,aN as ReactionEvent,a$ as ReactionEventOperation,b0 as Sender,a2 as ThreadInfo,a1 as ThreadInfoUpdateEvent,at as ThreadedParentMessageListQuery,ap as Thumbnail,b1 as UploadedFileInfo,$ as UserMessage}from"./lib/__bundle-e1a5e3f1.js"; diff --git a/openChannel.js b/openChannel.js index aed7f3b..ebb5418 100644 --- a/openChannel.js +++ b/openChannel.js @@ -1 +1 @@ -import{c as e,_ as n,b as t,af as r,Q as a,a as s,i,A as o,bn as u,bo as l,f as c,h,e as d,u as p,ak as f,U as C,z as v,p as _,q as g,g as y,C as m,aA as U,W as E,O as M,D as w,F as P,t as b,G as T,aM as N,a2 as D,aT as H,bi as I,w as O,s as x,bj as A,aB as L,V as R,ai as F,aO as k,a_ as S}from"./lib/__bundle-85fbca74.js";import{a3 as z,a4 as q,a5 as Q,a7 as G,a6 as j,a8 as B,a9 as K,aa as V,ae as W,af as X,ag as Y,ah as Z,P as $,z as J,as as ee,T as ne,ak as te}from"./lib/__bundle-3ceb5f92.js";import{C as re,B as ae,U as se,a as ie,O as oe,P as ue,M as le,T as ce,R as he,b as de,A as pe}from"./lib/__bundle-ace226dc.js";import{B as fe}from"./lib/__bundle-a7b76e00.js";import"./lib/__bundle-acd77193.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),ve={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},_e=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:l,"/").concat(encodeURIComponent(t)),a.params={show_pinned_messages:!0},a}return e(t,n),t}(c),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),ye=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds,C=e.isEphemeral;return(t=n.call(this)||this).method=o.POST,t.path=l,t.params=d(p({channel_url:r,cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f,is_ephemeral:C})),t}return e(t,n),t}(c);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}e(t,n)}(h);var me=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),Ue=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"SYEV",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),Ee=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),Me=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"EXIT",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),we={},Pe=function(r){function o(e,a){var s=r.call(this,e,y(y({},a),{channelType:m.OPEN}))||this;return s.subscribeChannelEvent=U,s.unsubscribeChannelEvent=U,s.refreshChannel=function(){return n(s,void 0,void 0,(function(){return t(this,(function(e){return[2,U()]}))}))},s._openChannelCache=new Ce(e),s._openChannelHandlers=new Map,s._dispatcher.on((function(e){var n,t;if(e instanceof E)s._handleEvent(e).catch((function(e){if(M(e)&&"foreground"===s._sdkState.appState)throw e}));else if(e instanceof w&&e.stateType===P.CONNECTED){var r=s._openChannelCache.enteredChannels;try{for(var a=b(r),i=a.next();!i.done;i=a.next()){i.value.enter()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),we[e]||(we[e]=s),s}return e(o,r),o.of=function(e){return we[e]},o.prototype.buildOpenChannelFromSerializedData=function(e){var n=v(e);return new xe(this._iid,xe.payloadify(n))},o.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]}}))}))},o.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()]}}))}))},o.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,s,i,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=b(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 s=t.sent(),i={error:s},[3,7];case 6:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},o.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},o.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},Object.defineProperty(o.prototype,"handlers",{get:function(){return _([],g(this._openChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),o.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,s,i,o,u,l,c,h,d,p,f,C,v,_,g,y,U,E,w,P,O,x,L,R,F,k,S,$,J,ee,ne,te,ae,fe,Ce,ve,_e,ge,ye,me,Ee,we,Pe,be,Te,Ne,De,He,Ie,Oe,xe,Ae,Le,Re,Fe,ke,Se,ze,qe,Qe,Ge,je,Be,Ke,Ve,We,Xe,Ye,Ze,$e,Je,en,nn,tn=this;return t(this,(function(rn){switch(rn.label){case 0:switch(rn.trys.push([0,59,,60]),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,58];case 1:return i=null,"MESG"===e.code?i=e.as(Y):"FILE"===e.code?i=e.as(Z):"ADMM"!==e.code&&"BRDM"!=e.code||(i=e.as(pe)),i?(r=i.message,a=i.isMentioned,r.channelType!==m.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:s=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,i,o,u;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())i=n.value,this._openChannelCache.isEnteredChannel(s.url)&&(i.onMessageReceived&&i.onMessageReceived(s,r),a&&i.onMentionReceived&&i.onMentionReceived(s,r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}}return[2]}))}))})),rn.label=3;case 3:return[3,58];case 4:return i=null,"MEDI"===e.code?i=e.as(W):"FEDI"===e.code?i=e.as(X):"AEDI"===e.code&&(i=e.as(de)),i?(o=i.message,u=i.mentionCountChange,o.channelType!==m.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:l=rn.sent(),c=!1,l.lastPinnedMessage&&l.lastPinnedMessage.messageId===o.messageId&&l.lastPinnedMessage.updatedAt0&&r.onMentionReceived&&r.onMentionReceived(l,o))}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=6;case 6:return[3,58];case 7:return h=e.as(I),ne=h.channelUrl,te=h.channelType,d=h.messageId,te!==m.OPEN?[3,9]:[4,this.getChannel(ne,!0)];case 8:p=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(p.url)&&r.onMessageDeleted&&r.onMessageDeleted(p,d)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=9;case 9:return[3,58];case 10:return f=e.as(he),ne=f.channelUrl,te=f.channelType,C=f.event,te!==m.OPEN?[3,12]:[4,this.getChannel(ne,!0)];case 11:v=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated&&r.onReactionUpdated(v,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=12;case 12:return[3,58];case 13:return(_=e.as(ce).event).channelType!==m.OPEN?[3,15]:[4,this.getChannel(_.channelUrl,!0)];case 14:g=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(g.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(g,_)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=15;case 15:return[3,58];case 16:y=e.as(le).openChannelMemberCounts,U=[],rn.label=17;case 17:rn.trys.push([17,22,23,24]),E=b(y),w=E.next(),rn.label=18;case 18:return w.done?[3,21]:(P=w.value,ne=P.channelUrl,Ee=P.participantCount,O=P.updatedAt,[4,this.getChannelFromCache(ne)]);case 19:(x=rn.sent())&&x._updateParticipantCount(Ee,O)&&U.push(x),rn.label=20;case 20:return w=E.next(),[3,18];case 21:return[3,24];case 22:return L=rn.sent(),en={error:L},[3,24];case 23:try{w&&!w.done&&(nn=E.return)&&nn.call(E)}finally{if(en)throw en.error}return[7];case 24:return U.length>0?[4,this.upsertChannelsToCache(U)]:[3,26];case 25:R=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(R)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=26;case 26:return[3,58];case 27:return F=e.as(ue),k=F.event,S=F.status,ne=F.channelUrl,te=F.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,29];case 28:$=rn.sent(),this._dispatcher.dispatch(new H({event:k,source:D.EVENT_POLL_UPDATED})),T(S===A?function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted($,k.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated($,k)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),rn.label=29;case 29:return[3,58];case 30:return J=e.as(V),ee=J.event,ne=J.channelUrl,te=J.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,32];case 31:ae=rn.sent(),this._dispatcher.dispatch(new N({event:ee,source:D.EVENT_POLL_VOTED})),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(ae,ee)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=32;case 32:return[3,58];case 33:if(!(fe=e.as(re).event).isOpenChannelEvent)return[3,57];switch(fe.category){case ie.CHANNEL_ENTER:return[3,34];case ie.CHANNEL_EXIT:return[3,36];case ie.CHANNEL_OPERATOR_UPDATE:return[3,38];case ie.USER_CHANNEL_MUTE:case ie.USER_CHANNEL_UNMUTE:return[3,40];case ie.USER_CHANNEL_BAN:case ie.USER_CHANNEL_UNBAN:return[3,42];case ie.CHANNEL_FREEZE:case ie.CHANNEL_UNFREEZE:return[3,44];case ie.CHANNEL_DELETED:return[3,46];case ie.CHANNEL_PROP_CHANGED:return[3,49];case ie.CHANNEL_META_DATA_CHANGED:return[3,51];case ie.CHANNEL_META_COUNTERS_CHANGED:return[3,53];case ie.PINNED_MESSAGE_CHANGED:return[3,55]}return[3,57];case 34:return[4,this.getChannel(fe.channelUrl,!0)];case 35:return Ce=rn.sent(),ve=e.as(Ue),Ee=ve.participantCount,_e=ve.user,ge=Ce._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(Ce,_e),ge&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(Ce)})),[2]}))}))})),[3,57];case 36:return[4,this.getChannel(fe.channelUrl,!0)];case 37:return ye=rn.sent(),me=e.as(Me),Ee=me.participantCount,we=me.user,Pe=ye._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(ye,we),Pe&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ye)})),[2]}))}))})),[3,57];case 38:return[4,this.getChannel(fe.channelUrl,!0)];case 39:return be=rn.sent(),Te=e.as(oe).operators,be.operators=Te,this.upsertChannelsToCache([be]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(be,Te)})),[2]}))}))})),[3,57];case 40:return[4,this.getChannel(fe.channelUrl,!0)];case 41:return Ne=rn.sent(),De=fe.category===ie.USER_CHANNEL_MUTE,He=e.as(De?B:K).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){De?e.onUserMuted&&e.onUserMuted(Ne,He):e.onUserUnmuted&&e.onUserUnmuted(Ne,He)})),[2]}))}))})),[3,57];case 42:return[4,this.getChannel(fe.channelUrl,!0)];case 43:return Ie=rn.sent(),Oe=fe.category===ie.USER_CHANNEL_BAN,xe=e.as(Oe?G:j).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Oe?e.onUserBanned&&e.onUserBanned(Ie,xe):e.onUserUnbanned&&e.onUserUnbanned(Ie,xe)})),[2]}))}))})),[3,57];case 44:return[4,this.getChannel(fe.channelUrl,!0)];case 45:return Ae=rn.sent(),Le=e.as(Q).freeze,Ae.isFrozen=Le,this.upsertChannelsToCache([Ae]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Le?e.onChannelFrozen&&e.onChannelFrozen(Ae):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ae)})),[2]}))}))})),[3,57];case 46:return[4,this.getChannel(fe.channelUrl,!0)];case 47:return Re=rn.sent(),[4,this.removeChannelsFromCache([Re.url])];case 48:return rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Re.url,Re.channelType)})),[2]}))}))})),[3,57];case 49:return[4,this.getChannelWithoutCache(fe.channelUrl,!0)];case 50:return Fe=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Fe)})),[2]}))}))})),[3,57];case 51:return[4,this.getChannel(fe.channelUrl,!0)];case 52:return ke=rn.sent(),Se=e.as(q),ze=Se.created,qe=Se.updated,Qe=Se.deleted,ze&&ke._upsertCachedMetaData(ze,fe.ts),qe&&ke._upsertCachedMetaData(qe,fe.ts),Qe&&ke._removeFromCachedMetaData(Qe,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ze&&e.onMetaDataCreated&&e.onMetaDataCreated(ke,ze),qe&&e.onMetaDataUpdated&&e.onMetaDataUpdated(ke,qe),Qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(ke,Qe)})),[2]}))}))})),[3,57];case 53:return[4,this.getChannel(fe.channelUrl,!0)];case 54:return Ge=rn.sent(),je=e.as(z),Be=je.created,Ke=je.updated,Ve=je.deleted,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Be&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Ge,Be),Ke&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ge,Ke),Ve&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Ge,Ve)})),[2]}))}))})),[3,57];case 55:return[4,this.getChannel(fe.channelUrl,!0)];case 56:return We=rn.sent(),Xe=e.as(se),Ye=Xe.pinnedMessageIds,Ze=Xe.latestPinnedMessage,($e=Xe.ts)>We._pinnedMessagesUpdatedAt&&(We.pinnedMessageIds=Ye,We.lastPinnedMessage=Ze,We._pinnedMessagesUpdatedAt=$e,this.upsertChannelsToCache([We]),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelChanged&&r.onChannelChanged(We)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(We)})),[2]}))}))}))),[3,57];case 57:return[3,58];case 58:return[3,60];case 59:if(Je=rn.sent(),M(Je))throw Je;return[3,60];case 60:return[2]}}))}))},o.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},o.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},o.prototype.clearHandler=function(){this._openChannelHandlers.clear()},o.prototype.getChannel=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:O(s("string",e)).throw(x.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,r)];case 5:return[2,t.sent()]}}))}))},o.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,i;return t(this,(function(t){switch(t.label){case 0:return O(s("string",e)).throw(x.invalidParameters),n=new _e({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),i=a.as(ge).channel,[4,this.upsertChannelsToCache([i])];case 2:return[2,t.sent()[0]]}}))}))},o.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},ve),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)&&(s("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&s("boolean",e.isEphemeral,!0)}(n)).throw(x.invalidParameters),r=new ye(n),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(ge).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},o}(ae),be={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Te=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,s=e.limit;return(t=n.call(this)||this).method=o.GET,t.path="".concat(l,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:s},t}return e(t,n),t}(c),Ne=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,s=t.participants;return r.token=a,r.participants=s.map((function(n){return new $(e,n)})),r}return e(t,n),t}(h),De=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,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Te(y(y({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Ne),s=a.participants,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},a}(L),He=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=o.PUT,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f})),t}return e(t,n),t}(c),Ie=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),Oe=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=o.DELETE,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(c);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var xe=function(r){function o(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.lastPinnedMessage=null,a._pinnedMessagesUpdatedAt=0,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 C(e,n)})):[],a.lastPinnedMessage=n.latest_pinned_message?ne(a._iid,y({channel_type:a.channelType},n.latest_pinned_message)):null,a}return e(o,r),o.payloadify=function(e){return d(p(y(y({},J.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return C.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?ee(e.lastPinnedMessage):null})))},o.prototype.serialize=function(){return F(this)},o.prototype.isOperator=function(e){return e instanceof C?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},o.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},o.prototype.createParticipantListQuery=function(e){return new De(this._iid,this.url,e)},o.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Pe.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},o.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new me({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Ue),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Ee({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Me),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setExitedToCache(this),te.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},be),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)}(n)).throw(x.invalidParameters),r=R.of(this._iid).requestQueue,o=new He(y({channelUrl:this.url},n)),[4,r.send(o)];case 1:return u=t.sent(),l=u.as(Ie).channel,this._update(l),[4,Pe.of(this._iid).upsertChannelsToCache([l])];case 2:return t.sent(),[2,this]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(e,r,a,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=y(y({},be),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:s,customType:i}),[2,this.updateChannel(n)]}))}))},o.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Oe({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,Pe.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.updateUserMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateUserMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o.prototype.updateFileMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateFileMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o}(J),Ae=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=U,e.onUserExited=U,e.onChannelParticipantCountChanged=U,e.onPollUpdated=U,e.onPollVoted=U,e.onPollDeleted=U,e.onPinnedMessageUpdated=U,e}return e(t,n),t}(fe)),Le=function(n){function t(e){var t=this,r=e.token,a=e.limit,s=e.nameKeyword,i=e.urlKeyword,u=e.customTypes,c=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=o.GET,t.path=l,t.params=d({token:r,limit:a,name_contains:s,url_contains:i,custom_types:u,show_frozen:c,show_metadata:h,show_pinned_messages:!0}),t}return e(t,n),t}(c),Re=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,s=t.channels,i=t.ts;return r.token=a,s&&s.length>0&&(r.channels=s.map((function(n){return new xe(e,n)}))),r.ts="number"==typeof i?i:null,r}return e(t,n),t}(h),Fe=function(r){function i(e,n){var t,a,s,i,o,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,u.urlKeyword=null!==(i=n.urlKeyword)&&void 0!==i?i:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return e(i,r),i.prototype._validate=function(){return r.prototype._validate.call(this)&&s("boolean",this.includeFrozen)&&s("boolean",this.includeMetaData)&&s("string",this.nameKeyword,!0)&&s("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},i.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Le(p(y(y({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Re),s=a.channels,i=a.token,this._token=i,this._hasNext=!!i,[4,Pe.of(this._iid).upsertChannelsToCache(s)];case 2:return t.sent(),this._isLoading=!1,[2,s];case 3:return[2,[]];case 4:throw x.queryInProgress;case 5:return[3,7];case 6:throw x.invalidParameters;case 7:return[2]}}))}))},i}(k),ke=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,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new Pe(e,{sdkState:t,dispatcher:a,requestQueue:i,logger:o,cacheContext:l,sessionManager:s})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new Fe(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,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=y({},ve)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=s,n.customType=i,[2,this._manager.createChannel(n)]}))}))},a}(S);export{xe as OpenChannel,Ae as OpenChannelHandler,Fe as OpenChannelListQuery,ke as OpenChannelModule,De as ParticipantListQuery}; +import{c as e,_ as n,b as t,af as r,Q as a,a as s,i,A as o,bn as u,bo as l,f as c,h,e as d,u as p,ak as f,U as C,z as v,p as _,q as g,g as y,C as m,aA as U,W as E,O as M,D as w,F as P,t as b,G as T,aM as N,a2 as D,aT as H,bi as I,w as O,s as x,bj as A,aB as L,V as R,ai as F,aO as k,a_ as S}from"./lib/__bundle-1db3fd0b.js";import{a3 as z,a4 as q,a5 as Q,a7 as G,a6 as j,a8 as B,a9 as K,aa as V,ae as W,af as X,ag as Y,ah as Z,P as $,z as J,as as ee,T as ne,ak as te}from"./lib/__bundle-e1a5e3f1.js";import{C as re,B as ae,U as se,a as ie,O as oe,P as ue,M as le,T as ce,R as he,b as de,A as pe}from"./lib/__bundle-e53b9010.js";import{B as fe}from"./lib/__bundle-123134d8.js";import"./lib/__bundle-acd77193.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),ve={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},_e=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:l,"/").concat(encodeURIComponent(t)),a.params={show_pinned_messages:!0},a}return e(t,n),t}(c),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),ye=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds,C=e.isEphemeral;return(t=n.call(this)||this).method=o.POST,t.path=l,t.params=d(p({channel_url:r,cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f,is_ephemeral:C})),t}return e(t,n),t}(c);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}e(t,n)}(h);var me=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),Ue=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"SYEV",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),Ee=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),Me=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"EXIT",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),we={},Pe=function(r){function o(e,a){var s=r.call(this,e,y(y({},a),{channelType:m.OPEN}))||this;return s.subscribeChannelEvent=U,s.unsubscribeChannelEvent=U,s.refreshChannel=function(){return n(s,void 0,void 0,(function(){return t(this,(function(e){return[2,U()]}))}))},s._openChannelCache=new Ce(e),s._openChannelHandlers=new Map,s._dispatcher.on((function(e){var n,t;if(e instanceof E)s._handleEvent(e).catch((function(e){if(M(e)&&"foreground"===s._sdkState.appState)throw e}));else if(e instanceof w&&e.stateType===P.CONNECTED){var r=s._openChannelCache.enteredChannels;try{for(var a=b(r),i=a.next();!i.done;i=a.next()){i.value.enter()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),we[e]||(we[e]=s),s}return e(o,r),o.of=function(e){return we[e]},o.prototype.buildOpenChannelFromSerializedData=function(e){var n=v(e);return new xe(this._iid,xe.payloadify(n))},o.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]}}))}))},o.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()]}}))}))},o.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,s,i,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=b(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 s=t.sent(),i={error:s},[3,7];case 6:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},o.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},o.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},Object.defineProperty(o.prototype,"handlers",{get:function(){return _([],g(this._openChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),o.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,s,i,o,u,l,c,h,d,p,f,C,v,_,g,y,U,E,w,P,O,x,L,R,F,k,S,$,J,ee,ne,te,ae,fe,Ce,ve,_e,ge,ye,me,Ee,we,Pe,be,Te,Ne,De,He,Ie,Oe,xe,Ae,Le,Re,Fe,ke,Se,ze,qe,Qe,Ge,je,Be,Ke,Ve,We,Xe,Ye,Ze,$e,Je,en,nn,tn=this;return t(this,(function(rn){switch(rn.label){case 0:switch(rn.trys.push([0,59,,60]),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,58];case 1:return i=null,"MESG"===e.code?i=e.as(Y):"FILE"===e.code?i=e.as(Z):"ADMM"!==e.code&&"BRDM"!=e.code||(i=e.as(pe)),i?(r=i.message,a=i.isMentioned,r.channelType!==m.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:s=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,i,o,u;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())i=n.value,this._openChannelCache.isEnteredChannel(s.url)&&(i.onMessageReceived&&i.onMessageReceived(s,r),a&&i.onMentionReceived&&i.onMentionReceived(s,r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}}return[2]}))}))})),rn.label=3;case 3:return[3,58];case 4:return i=null,"MEDI"===e.code?i=e.as(W):"FEDI"===e.code?i=e.as(X):"AEDI"===e.code&&(i=e.as(de)),i?(o=i.message,u=i.mentionCountChange,o.channelType!==m.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:l=rn.sent(),c=!1,l.lastPinnedMessage&&l.lastPinnedMessage.messageId===o.messageId&&l.lastPinnedMessage.updatedAt0&&r.onMentionReceived&&r.onMentionReceived(l,o))}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=6;case 6:return[3,58];case 7:return h=e.as(I),ne=h.channelUrl,te=h.channelType,d=h.messageId,te!==m.OPEN?[3,9]:[4,this.getChannel(ne,!0)];case 8:p=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(p.url)&&r.onMessageDeleted&&r.onMessageDeleted(p,d)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=9;case 9:return[3,58];case 10:return f=e.as(he),ne=f.channelUrl,te=f.channelType,C=f.event,te!==m.OPEN?[3,12]:[4,this.getChannel(ne,!0)];case 11:v=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated&&r.onReactionUpdated(v,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=12;case 12:return[3,58];case 13:return(_=e.as(ce).event).channelType!==m.OPEN?[3,15]:[4,this.getChannel(_.channelUrl,!0)];case 14:g=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(g.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(g,_)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=15;case 15:return[3,58];case 16:y=e.as(le).openChannelMemberCounts,U=[],rn.label=17;case 17:rn.trys.push([17,22,23,24]),E=b(y),w=E.next(),rn.label=18;case 18:return w.done?[3,21]:(P=w.value,ne=P.channelUrl,Ee=P.participantCount,O=P.updatedAt,[4,this.getChannelFromCache(ne)]);case 19:(x=rn.sent())&&x._updateParticipantCount(Ee,O)&&U.push(x),rn.label=20;case 20:return w=E.next(),[3,18];case 21:return[3,24];case 22:return L=rn.sent(),en={error:L},[3,24];case 23:try{w&&!w.done&&(nn=E.return)&&nn.call(E)}finally{if(en)throw en.error}return[7];case 24:return U.length>0?[4,this.upsertChannelsToCache(U)]:[3,26];case 25:R=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(R)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=26;case 26:return[3,58];case 27:return F=e.as(ue),k=F.event,S=F.status,ne=F.channelUrl,te=F.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,29];case 28:$=rn.sent(),this._dispatcher.dispatch(new H({event:k,source:D.EVENT_POLL_UPDATED})),T(S===A?function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted($,k.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated($,k)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),rn.label=29;case 29:return[3,58];case 30:return J=e.as(V),ee=J.event,ne=J.channelUrl,te=J.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,32];case 31:ae=rn.sent(),this._dispatcher.dispatch(new N({event:ee,source:D.EVENT_POLL_VOTED})),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(ae,ee)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=32;case 32:return[3,58];case 33:if(!(fe=e.as(re).event).isOpenChannelEvent)return[3,57];switch(fe.category){case ie.CHANNEL_ENTER:return[3,34];case ie.CHANNEL_EXIT:return[3,36];case ie.CHANNEL_OPERATOR_UPDATE:return[3,38];case ie.USER_CHANNEL_MUTE:case ie.USER_CHANNEL_UNMUTE:return[3,40];case ie.USER_CHANNEL_BAN:case ie.USER_CHANNEL_UNBAN:return[3,42];case ie.CHANNEL_FREEZE:case ie.CHANNEL_UNFREEZE:return[3,44];case ie.CHANNEL_DELETED:return[3,46];case ie.CHANNEL_PROP_CHANGED:return[3,49];case ie.CHANNEL_META_DATA_CHANGED:return[3,51];case ie.CHANNEL_META_COUNTERS_CHANGED:return[3,53];case ie.PINNED_MESSAGE_CHANGED:return[3,55]}return[3,57];case 34:return[4,this.getChannel(fe.channelUrl,!0)];case 35:return Ce=rn.sent(),ve=e.as(Ue),Ee=ve.participantCount,_e=ve.user,ge=Ce._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(Ce,_e),ge&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(Ce)})),[2]}))}))})),[3,57];case 36:return[4,this.getChannel(fe.channelUrl,!0)];case 37:return ye=rn.sent(),me=e.as(Me),Ee=me.participantCount,we=me.user,Pe=ye._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(ye,we),Pe&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ye)})),[2]}))}))})),[3,57];case 38:return[4,this.getChannel(fe.channelUrl,!0)];case 39:return be=rn.sent(),Te=e.as(oe).operators,be.operators=Te,this.upsertChannelsToCache([be]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(be,Te)})),[2]}))}))})),[3,57];case 40:return[4,this.getChannel(fe.channelUrl,!0)];case 41:return Ne=rn.sent(),De=fe.category===ie.USER_CHANNEL_MUTE,He=e.as(De?B:K).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){De?e.onUserMuted&&e.onUserMuted(Ne,He):e.onUserUnmuted&&e.onUserUnmuted(Ne,He)})),[2]}))}))})),[3,57];case 42:return[4,this.getChannel(fe.channelUrl,!0)];case 43:return Ie=rn.sent(),Oe=fe.category===ie.USER_CHANNEL_BAN,xe=e.as(Oe?G:j).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Oe?e.onUserBanned&&e.onUserBanned(Ie,xe):e.onUserUnbanned&&e.onUserUnbanned(Ie,xe)})),[2]}))}))})),[3,57];case 44:return[4,this.getChannel(fe.channelUrl,!0)];case 45:return Ae=rn.sent(),Le=e.as(Q).freeze,Ae.isFrozen=Le,this.upsertChannelsToCache([Ae]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Le?e.onChannelFrozen&&e.onChannelFrozen(Ae):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ae)})),[2]}))}))})),[3,57];case 46:return[4,this.getChannel(fe.channelUrl,!0)];case 47:return Re=rn.sent(),[4,this.removeChannelsFromCache([Re.url])];case 48:return rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Re.url,Re.channelType)})),[2]}))}))})),[3,57];case 49:return[4,this.getChannelWithoutCache(fe.channelUrl,!0)];case 50:return Fe=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Fe)})),[2]}))}))})),[3,57];case 51:return[4,this.getChannel(fe.channelUrl,!0)];case 52:return ke=rn.sent(),Se=e.as(q),ze=Se.created,qe=Se.updated,Qe=Se.deleted,ze&&ke._upsertCachedMetaData(ze,fe.ts),qe&&ke._upsertCachedMetaData(qe,fe.ts),Qe&&ke._removeFromCachedMetaData(Qe,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ze&&e.onMetaDataCreated&&e.onMetaDataCreated(ke,ze),qe&&e.onMetaDataUpdated&&e.onMetaDataUpdated(ke,qe),Qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(ke,Qe)})),[2]}))}))})),[3,57];case 53:return[4,this.getChannel(fe.channelUrl,!0)];case 54:return Ge=rn.sent(),je=e.as(z),Be=je.created,Ke=je.updated,Ve=je.deleted,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Be&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Ge,Be),Ke&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ge,Ke),Ve&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Ge,Ve)})),[2]}))}))})),[3,57];case 55:return[4,this.getChannel(fe.channelUrl,!0)];case 56:return We=rn.sent(),Xe=e.as(se),Ye=Xe.pinnedMessageIds,Ze=Xe.latestPinnedMessage,($e=Xe.ts)>We._pinnedMessagesUpdatedAt&&(We.pinnedMessageIds=Ye,We.lastPinnedMessage=Ze,We._pinnedMessagesUpdatedAt=$e,this.upsertChannelsToCache([We]),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelChanged&&r.onChannelChanged(We)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(We)})),[2]}))}))}))),[3,57];case 57:return[3,58];case 58:return[3,60];case 59:if(Je=rn.sent(),M(Je))throw Je;return[3,60];case 60:return[2]}}))}))},o.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},o.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},o.prototype.clearHandler=function(){this._openChannelHandlers.clear()},o.prototype.getChannel=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:O(s("string",e)).throw(x.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,r)];case 5:return[2,t.sent()]}}))}))},o.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,i;return t(this,(function(t){switch(t.label){case 0:return O(s("string",e)).throw(x.invalidParameters),n=new _e({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),i=a.as(ge).channel,[4,this.upsertChannelsToCache([i])];case 2:return[2,t.sent()[0]]}}))}))},o.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},ve),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)&&(s("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&s("boolean",e.isEphemeral,!0)}(n)).throw(x.invalidParameters),r=new ye(n),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(ge).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},o}(ae),be={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Te=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,s=e.limit;return(t=n.call(this)||this).method=o.GET,t.path="".concat(l,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:s},t}return e(t,n),t}(c),Ne=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,s=t.participants;return r.token=a,r.participants=s.map((function(n){return new $(e,n)})),r}return e(t,n),t}(h),De=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,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Te(y(y({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Ne),s=a.participants,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},a}(L),He=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=o.PUT,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f})),t}return e(t,n),t}(c),Ie=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),Oe=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=o.DELETE,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(c);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var xe=function(r){function o(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.lastPinnedMessage=null,a._pinnedMessagesUpdatedAt=0,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 C(e,n)})):[],a.lastPinnedMessage=n.latest_pinned_message?ne(a._iid,y({channel_type:a.channelType},n.latest_pinned_message)):null,a}return e(o,r),o.payloadify=function(e){return d(p(y(y({},J.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return C.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?ee(e.lastPinnedMessage):null})))},o.prototype.serialize=function(){return F(this)},o.prototype.isOperator=function(e){return e instanceof C?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},o.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},o.prototype.createParticipantListQuery=function(e){return new De(this._iid,this.url,e)},o.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Pe.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},o.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new me({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Ue),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Ee({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Me),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setExitedToCache(this),te.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},be),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)}(n)).throw(x.invalidParameters),r=R.of(this._iid).requestQueue,o=new He(y({channelUrl:this.url},n)),[4,r.send(o)];case 1:return u=t.sent(),l=u.as(Ie).channel,this._update(l),[4,Pe.of(this._iid).upsertChannelsToCache([l])];case 2:return t.sent(),[2,this]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(e,r,a,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=y(y({},be),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:s,customType:i}),[2,this.updateChannel(n)]}))}))},o.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Oe({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,Pe.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.updateUserMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateUserMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o.prototype.updateFileMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateFileMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o}(J),Ae=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=U,e.onUserExited=U,e.onChannelParticipantCountChanged=U,e.onPollUpdated=U,e.onPollVoted=U,e.onPollDeleted=U,e.onPinnedMessageUpdated=U,e}return e(t,n),t}(fe)),Le=function(n){function t(e){var t=this,r=e.token,a=e.limit,s=e.nameKeyword,i=e.urlKeyword,u=e.customTypes,c=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=o.GET,t.path=l,t.params=d({token:r,limit:a,name_contains:s,url_contains:i,custom_types:u,show_frozen:c,show_metadata:h,show_pinned_messages:!0}),t}return e(t,n),t}(c),Re=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,s=t.channels,i=t.ts;return r.token=a,s&&s.length>0&&(r.channels=s.map((function(n){return new xe(e,n)}))),r.ts="number"==typeof i?i:null,r}return e(t,n),t}(h),Fe=function(r){function i(e,n){var t,a,s,i,o,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,u.urlKeyword=null!==(i=n.urlKeyword)&&void 0!==i?i:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return e(i,r),i.prototype._validate=function(){return r.prototype._validate.call(this)&&s("boolean",this.includeFrozen)&&s("boolean",this.includeMetaData)&&s("string",this.nameKeyword,!0)&&s("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},i.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Le(p(y(y({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Re),s=a.channels,i=a.token,this._token=i,this._hasNext=!!i,[4,Pe.of(this._iid).upsertChannelsToCache(s)];case 2:return t.sent(),this._isLoading=!1,[2,s];case 3:return[2,[]];case 4:throw x.queryInProgress;case 5:return[3,7];case 6:throw x.invalidParameters;case 7:return[2]}}))}))},i}(k),ke=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,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new Pe(e,{sdkState:t,dispatcher:a,requestQueue:i,logger:o,cacheContext:l,sessionManager:s})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new Fe(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,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=y({},ve)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=s,n.customType=i,[2,this._manager.createChannel(n)]}))}))},a}(S);export{xe as OpenChannel,Ae as OpenChannelHandler,Fe as OpenChannelListQuery,ke as OpenChannelModule,De as ParticipantListQuery}; diff --git a/package.json b/package.json index 8b0bf11..8572194 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.14.3", + "version": "4.14.4", "description": "Sendbird SDK for JavaScript", "sideEffects": false, "name": "@sendbird/chat", diff --git a/poll.js b/poll.js index ce0eb37..783c8d1 100644 --- a/poll.js +++ b/poll.js @@ -1 +1 @@ -import{c as t,aN as e,_ as r,a_ as a,b as n,g as o,b0 as i,w as s,b1 as l,s as u,b2 as c,b3 as p,b4 as d,b5 as h}from"./lib/__bundle-85fbca74.js";export{ar as Poll,x as PollListQuery,b6 as PollOption,b7 as PollStatus,aI as PollVoteEvent,y as PollVoterListQuery}from"./lib/__bundle-85fbca74.js";export{P as PollUpdateEvent}from"./lib/__bundle-acd77193.js";var b=function(a){function b(){var t=null!==a&&a.apply(this,arguments)||this;return t.name="poll",t}return t(b,a),b.prototype.init=function(t,r){var n=r.sdkState,o=r.dispatcher,i=r.sessionManager,s=r.requestQueue,l=r.logger,u=r.onlineDetector,c=r.cacheContext;a.prototype.init.call(this,t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c}),this._manager=new e(t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c})},b.prototype.create=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},i),t),s(l(e)).throw(u.invalidParameters),[2,this._manager.create(e)]}))}))},b.prototype.get=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},c),t),s(p(e)).throw(u.invalidParameters),[2,this._manager.get(e)]}))}))},b.prototype.getOption=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},d),t),s(h(e)).throw(u.invalidParameters),[2,this._manager.getOption(e)]}))}))},b.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},b}(a);export{b as PollModule}; +import{c as t,aN as e,_ as r,a_ as a,b as n,g as o,b0 as i,w as s,b1 as l,s as u,b2 as c,b3 as d,b4 as p,b5 as h}from"./lib/__bundle-1db3fd0b.js";export{ar as Poll,x as PollListQuery,b6 as PollOption,b7 as PollStatus,aI as PollVoteEvent,y as PollVoterListQuery}from"./lib/__bundle-1db3fd0b.js";export{P as PollUpdateEvent}from"./lib/__bundle-acd77193.js";var b=function(a){function b(){var t=null!==a&&a.apply(this,arguments)||this;return t.name="poll",t}return t(b,a),b.prototype.init=function(t,r){var n=r.sdkState,o=r.dispatcher,i=r.sessionManager,s=r.requestQueue,l=r.logger,u=r.onlineDetector,c=r.cacheContext;a.prototype.init.call(this,t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c}),this._manager=new e(t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c})},b.prototype.create=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},i),t),s(l(e)).throw(u.invalidParameters),[2,this._manager.create(e)]}))}))},b.prototype.get=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},c),t),s(d(e)).throw(u.invalidParameters),[2,this._manager.get(e)]}))}))},b.prototype.getOption=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},p),t),s(h(e)).throw(u.invalidParameters),[2,this._manager.getOption(e)]}))}))},b.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},b}(a);export{b as PollModule}; diff --git a/sendbird.min.js b/sendbird.min.js index abd388b..7420bfd 100644 --- a/sendbird.min.js +++ b/sendbird.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Sendbird={})}(this,(function(e){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=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 i,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw i}}}}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(r){var a=Object.getOwnPropertyDescriptor(r,t);return a.get?a.get.call(arguments.length<3?e:n):a.value}},o.apply(null,arguments)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function d(){d=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",u=i.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 i=t&&t.prototype instanceof g?t:g,s=Object.create(i.prototype),o=new M(r||[]);return a(s,"_invoke",{value:T(e,n,o)}),s}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var f="suspendedStart",p="suspendedYield",v="executing",_="completed",m={};function g(){}function y(){}function E(){}var k={};c(k,s,(function(){return this}));var b=Object.getPrototypeOf,C=b&&b(b(O([])));C&&C!==n&&r.call(C,s)&&(k=C);var w=E.prototype=g.prototype=Object.create(k);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(a,i,s,o){var u=h(e[a],e,i);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,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var i;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return i=i?i.then(a,a):a()}})}function T(t,n,r){var a=f;return function(i,s){if(a===v)throw Error("Generator is already running");if(a===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var o=r.delegate;if(o){var u=I(o,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===f)throw a=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=v;var c=h(t,n,r);if("normal"===c.type){if(a=r.done?_:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(a=_,r.method="throw",r.arg=c.arg)}}}function I(t,n){var r=n.method,a=t.iterator[r];if(a===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,I(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=h(a,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function N(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 A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function M(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(N,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function n(){for(;++a=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(u&&c){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),A(n),m}},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;A(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:O(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),m}},t}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,s,o=[],u=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(o.push(r.value),o.length!==t);u=!0);}catch(e){c=!0,a=e}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw a}}return o}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t,n,r){var a=o(u(1&r?e.prototype:e),t,n);return 2&r?function(e){return a.apply(n,e)}:a}function v(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){var t=function(e,t){if("object"!=typeof e||!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:t+""}function m(e){return m="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},m(e)}function g(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function y(e){var t="function"==typeof Map?new Map:void 0;return y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(l())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var a=new(e.bind.apply(e,r));return n&&h(a,n.prototype),a}(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)},y(e)}function E(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var k,b="4.14.3",C=function(){function e(){r(this,e)}return i(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return b}},{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.SendbirdErrorCode=void 0,(k=e.SendbirdErrorCode||(e.SendbirdErrorCode={}))[k.NON_AUTHORIZED=400108]="NON_AUTHORIZED",k[k.INVALID_TOKEN=400111]="INVALID_TOKEN",k[k.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",k[k.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",k[k.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",k[k.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",k[k.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",k[k.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",k[k.SESSION_REVOKED=400310]="SESSION_REVOKED",k[k.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",k[k.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",k[k.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",k[k.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",k[k.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",k[k.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",k[k.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",k[k.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",k[k.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",k[k.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",k[k.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",k[k.LOST_INSTANCE=700100]="LOST_INSTANCE",k[k.CONNECTION_RENEW=700102]="CONNECTION_RENEW",k[k.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",k[k.INVALID_COMMAND=700700]="INVALID_COMMAND",k[k.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",k[k.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",k[k.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",k[k.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",k[k.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",k[k.INVALID_PARAMETER=800110]="INVALID_PARAMETER",k[k.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",k[k.NETWORK_ERROR=800120]="NETWORK_ERROR",k[k.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",k[k.MALFORMED_DATA=800130]="MALFORMED_DATA",k[k.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",k[k.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",k[k.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",k[k.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",k[k.ACK_TIMEOUT=800180]="ACK_TIMEOUT",k[k.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",k[k.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",k[k.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",k[k.REQUEST_FAILED=800220]="REQUEST_FAILED",k[k.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",k[k.REQUEST_CANCELED=800240]="REQUEST_CANCELED",k[k.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",k[k.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",k[k.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED",k[k.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",k[k.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",k[k.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",k[k.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",k[k.DATABASE_ERROR=800700]="DATABASE_ERROR",k[k.USER_DEACTIVATED=900021]="USER_DEACTIVATED",k[k.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";var w,x,S,T,I,N=function(e){return!(e instanceof A&&!e.shouldThrowOutside)},A=function(t){function a(e){var t,i=e.code,s=void 0===i?0:i,o=e.message,u=void 0===o?"":o;return r(this,a),(t=n(this,a,[u])).shouldThrowOutside=!1,t._detail="",t.name="SendbirdError",t.code=s,Object.setPrototypeOf(t,a.prototype),t}return c(a,t),i(a,[{key:"detail",get:function(){return this._detail}},{key:"setDetail",value:function(e){this._detail=e}},{key:"isInvalidTokenError",get:function(){return this.code===e.SendbirdErrorCode.INVALID_TOKEN}},{key:"isSessionExpiredError",get:function(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}},{key:"isSessionTokenExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_KEY_EXPIRED}},{key:"isSessionInvalidatedError",get:function(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}},{key:"isSessionRevokedError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_REVOKED}},{key:"isUserAuthDeactivedError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DEACTIVATED}},{key:"isUserAuthDeletedOrNotFoundError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}},{key:"isNetworkError",get:function(){return this.code===e.SendbirdErrorCode.NETWORK_ERROR||this.code===e.SendbirdErrorCode.NETWORK_ROUTING_ERROR}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new a({code:e.SendbirdErrorCode.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new a({code:e.SendbirdErrorCode.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"invalidCommand",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new a({code:e.SendbirdErrorCode.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{key:"connectionRenew",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"xmlHttpRequestNotSupported",get:function(){return new a({code:e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}},{key:"connectionRequired",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"channelTypeNotSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}},{key:"networkError",get:function(){return new a({code:e.SendbirdErrorCode.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new a({code:e.SendbirdErrorCode.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new a({code:e.SendbirdErrorCode.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new a({code:e.SendbirdErrorCode.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new a({code:e.SendbirdErrorCode.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new a({code:e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Request failed."})}},{key:"tooManyRequests",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}},{key:"alreadyConnectedAsAnotherUser",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}},{key:"fileUploadCanceled",get:function(){return new a({code:e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new a({code:e.SendbirdErrorCode.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}},{key:"statLogUploadLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}},{key:"malformedDataError",get:function(){return new a({code:e.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}}])}(y(Error)),M=[e.SendbirdErrorCode.CONNECTION_REQUIRED,e.SendbirdErrorCode.NETWORK_ERROR,e.SendbirdErrorCode.ACK_TIMEOUT,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,e.SendbirdErrorCode.REQUEST_CANCELED,e.SendbirdErrorCode.INTERNAL_SERVER_ERROR,e.SendbirdErrorCode.RATE_LIMIT_EXCEEDED,e.SendbirdErrorCode.UNKNOWN_SERVER_ERROR,e.SendbirdErrorCode.USER_DEACTIVATED,e.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],O=[e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.CONNECTION_REQUIRED],U=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},D=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||("string"!=typeof e?"object"===m(e)?R(e,t):L(e,t):m(t)===e)},R=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Object.values(e).includes(t)},L=function(e,t){return t instanceof e},P=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Array.isArray(t)&&t.every((function(t){return D(e,t)}))},F=function(e){return!!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))||"number"==typeof e&&13===e.toString().length},q=function(e){return e>0&&O.indexOf(e)>=0},H=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))return!0;var t="object"===m(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},G=function(e){return null==e},j=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,i=t.typingIndicatorInvalidateTime,s=void 0===i?1e4:i,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,d=t.websocketPayloadDecompression,h=void 0===d||d,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=s,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=h}),[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){D("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){D("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){D("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){D("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){D("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}])}(),V={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){return i((function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}),[{key:"_savePreferenceKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:v(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._version=n,this._keysAddress=e,a="".concat(e,".metadata.version"),r.next=5,this._store.get(a);case 5:return i=r.sent,r.next=8,this._store.get(e);case 8:if(r.t1=t=r.sent,r.t0=null!==r.t1,!r.t0){r.next=12;break}r.t0=void 0!==t;case 12:if(!r.t0){r.next=16;break}r.t2=t,r.next=17;break;case 16:r.t2=[];case 17:if(o=r.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},a=n.maxSize,i=void 0===a?256:a,s=n.clearOrder,o=void 0===s?e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT:s,u=n.customClearOrderComparator,c=n.enableAutoResend,l=void 0===c||c;r(this,t),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(i,64),u?(this._clearOrder=o,this._customClearOrderComparator=u):this._clearOrder=e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=l}),[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var t;return this._clearOrder===e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(t=this._customClearOrderComparator)&&void 0!==t?t:this._clearOrderComparatorUseMessageCollectionAccessedAt}},{key:"enableAutoResend",get:function(){return this._enableAutoResend}}])}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(K||(K={}));var Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue=function(){return i((function e(){r(this,e),this.isRefreshing=!1}),[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"hasChatServicePermission",get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(K.CHAT))}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}])}(),ce=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)}))},le=function(){return i((function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=ce()}),[{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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))}}])}(),de=function(){return i((function e(){r(this,e),this._container={}}),[{key:"on",value:function(e,t){return new le({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new le({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],i=s(n.keys());try{for(i.s();!(r=i.n()).done;){var o=r.value,u=n.get(o);u.handler(t),u.occurence>0&&(u.occurence--,0===u.occurence&&a.push(o))}}catch(e){i.e(e)}finally{i.f()}a.forEach((function(e){return n.delete(e)}))}}}])}(),he=function(){return i((function e(){r(this,e),this._dispatcher=new de}),[{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)}}])}(),fe=i((function e(){r(this,e)})),pe=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},ve=function(e){if(null!=e){if("object"===m(e)){if(Array.isArray(e)){for(var t=v(e),n=0;n3&&void 0!==arguments[3]?arguments[3]:"";return r(this,t),(s=n(this,t))._iid=e,s.code=a,s.payload=i,s.requestId=null!==(o=i.req_id)&&void 0!==o?o:u,s}return c(t,e),i(t,[{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,n){var r=n.substring(0,4),a={};try{a=JSON.parse(n.substring(4))}catch(e){r="NOOP"}finally{return new t(e,r,a)}}}])}(fe),Qe=function(e){function t(e){var a,i,s=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?{}:u;return r(this,t),(a=n(this,t)).code=s,a.payload=c,a.requestId=null!==(i=a.payload.req_id)&&void 0!==i?i:ce(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return c(t,e),i(t,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}])}(fe),We=function(e){function t(e){var a,i=e.userId,s=e.authToken,o=e.services,u=e.expiringSession,c=void 0===u||u;return r(this,t),(a=n(this,t)).path="".concat(ge,"/").concat(i,"/session_key"),a.method=_e.POST,a.params=pe({token:s,services:o,expiring_session:!!c}),a.requireAuth=!1,a}return c(t,e),i(t)}(je),Ye=function(e){function t(e){var a=e.authToken,i=e.expiringSession,s=void 0===i||i,o=e.requestId,u=void 0===o?void 0:o;return r(this,t),n(this,t,[{code:"LOGI",payload:pe({token:a,expiring_session:s?1:0,req_id:u}),ackRequired:!0}])}return c(t,e),i(t)}(Qe),Ze=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.key,o=a.expires_at,u=a.services;return i.key=s,i.expiresAt=o,i.services=u,i}return c(t,e),i(t)}(Ve),Xe=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"LOGI",i])).error=null,s.newKey=null,s.newKey=null!==(o=i.new_key)&&void 0!==o?o:null,s.error=i.error?new A(i):null,s}return c(t,e),i(t)}(Ke),Je=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).statLog=e,a}return c(t,e),i(t)}(fe),$e=function(e){function t(e){var a,i=e.request,s=e.deferred,o=e.error,u=void 0===o?A.requestFailed:o;return r(this,t),(a=n(this,t)).request=i,a.deferred=s,a.error=u,a}return c(t,e),i(t)}(fe);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",e.NOTIFICATION="noti:stats",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Ge||(Ge={}));var et,tt,nt,rt=function(){return i((function e(t){var n=t.type,a=t.data,i=t.ts,s=void 0===i?Date.now():i;r(this,e),this.type=n,this.createdAt=s,this.data=a}),null,[{key:"payloadify",value:function(e){return pe({stat_type:e.type,ts:e.createdAt,data:pe(e.data)})}}])}(),at=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},it=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};e.SendbirdProduct=void 0,(et=e.SendbirdProduct||(e.SendbirdProduct={})).CHAT="chat",et.CALLS="calls",et.DESK="desk",et.LIVE="live",et.UIKIT_CHAT="uikit-chat",et.UIKIT_LIVE="uikit-live",e.SendbirdPlatform=void 0,(tt=e.SendbirdPlatform||(e.SendbirdPlatform={})).ANDROID="android",tt.IOS="ios",tt.JS="js",tt.UNREAL="unreal",tt.UNITY="unity",tt.REACT_NATIVE="react-native",tt.FLUTTER="flutter",e.DeviceOsPlatform=void 0,(nt=e.DeviceOsPlatform||(e.DeviceOsPlatform={})).ANDROID="android",nt.IOS="ios",nt.WEB="web",nt.MOBILE_WEB="mobile_web",nt.WINDOWS="windows";var st=i((function e(){r(this,e)}));st.sendbirdSdkUserAgentWithExtension=function(t){var n=at()?e.SendbirdPlatform.REACT_NATIVE:e.SendbirdPlatform.JS,r={main_sdk_info:"chat/".concat(n,"/").concat(C.SDK_VERSION),device_os_platform:it()?"mobile-web":"web",os_version:C.OS_VERSION};if(t){var a=t.sendbirdExtensions,i=t.deviceOS,s=t.customData,o=void 0===s?{}:s;i.version&&(r.os_version=i.version),i.platform&&(r.device_os_platform=i.platform),a.length>0&&(r.extension_sdk_info=a.map((function(e){var t=e.product,n=e.platform,r=e.version;return"".concat(t,"/").concat(n,"/").concat(r)})).join(",")),Object.keys(r).forEach((function(e){return delete o[e]})),Object.keys(o).length>0&&(r=Object.assign(Object.assign({},r),o))}return Object.entries(r).map((function(e){var t=f(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join("&")},st.userAgentWithExtension=function(e){var t=at()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):it()?"omobile-web":"oweb";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)};var ot=i((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=function(e){n(e)}}))})),ut=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).requestId=e.requestId,a}return c(t,e),i(t)}(fe),ct=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),e.messageToken&&(a.params=pe({mesg_token:e.messageToken})),a}return c(t,e),i(t)}(je),lt=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"DELM",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(o=i.sender_id)&&void 0!==o?o:void 0,s}return c(t,e),i(t)}(Ke),dt=function(){return i((function e(t,n){var a=this,i=n.session,s=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._session=i,this._sdkState=s,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof ze&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}),[{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,i=n.sendbirdRuntimeEnvironment,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":st.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":st.sendbirdSdkUserAgentWithExtension(i)});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(s["Session-Key"]=this._session.sessionKey),s["App-Id"]=r,this._session&&this._session.authToken&&(s["Access-Token"]=this._session.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new Je(new rt({type:Ge.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:"_isBodyRequired",value:function(e){var t=e.method;return t!==_e.GET&&(t!==_e.DELETE||e instanceof ct)}},{key:"send",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=t.path,a=t.method,i=t.uploadProgressHandler,s=this._isBodyRequired(t),o=this._sdkState.api,u="".concat(o.host).concat(r).concat(s?"":t.query),c=s?t.payload:null,l=this._createHeader(t,c instanceof FormData?c:void 0),h=new AbortController,f=h.signal,this._abortControl.set(t.requestId,h),p=Date.now(),n.prev=10,!i){n.next=32;break}return n.next=14,Promise.resolve().then((function(){return pm}));case 14:return v=n.sent,_=v.xmlHttpRequest,n.prev=16,n.next=19,_(this._iid,{requestId:t.requestId,method:t.method,url:u,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i});case 19:return m=n.sent,this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",m);case 25:if(n.prev=25,n.t0=n.catch(16),!(n.t0 instanceof A&&n.t0.code===e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED)){n.next=31;break}this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),n.next=32;break;case 31:throw n.t0;case 32: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){n.next=36;break}return n.next=36,Promise.resolve().then((function(){return vm}));case 36:if("function"==typeof fetch){n.next=39;break}return n.next=39,Promise.resolve().then((function(){return Gm}));case 39:return n.next=41,fetch(u,{method:a,body:c,headers:l,signal:f});case 41:return g=n.sent,n.next=44,g.json();case 44:if(y=n.sent,!g.ok&&!g.redirected){n.next=51;break}return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",new Ve(this._iid,y));case 51:if(!y){n.next=70;break}if(!(E=new A(y)).isSessionExpiredError){n.next=62;break}if(this._dispatcher.dispatch(new Be({reason:E.code,message:E.message})),t instanceof We){n.next=59;break}return k=new ot,this._dispatcher.dispatch(new $e({request:t,deferred:k,error:E})),n.abrupt("return",k.promise);case 59:case 67:throw E;case 62:if(!E.isSessionInvalidatedError){n.next=67;break}throw this._dispatcher.dispatch(new Be({reason:E.code,message:E.message})),E;case 68:n.next=71;break;case 70:throw A.requestFailed;case 71:n.next=87;break;case 73:if(n.prev=73,n.t1=n.catch(10),this._statLogApiResult(t,p,n.t1),!(n.t1 instanceof A)){n.next=81;break}throw this._logger.debug("fail api request",n.t1),n.t1;case 81:if("AbortError"!==(null===n.t1||void 0===n.t1?void 0:n.t1.name)){n.next=85;break}throw A.requestCanceled;case 85:throw this._logger.debug("fail api request",n.t1),A.networkError;case 87:case"end":return n.stop()}}),n,this,[[10,73],[16,25]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new ut({requestId:e}))}},{key:"cancelAll",value:function(){var e,t=s(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(),this._dispatcher.dispatch(new ut({}))}}])}(),ht=function(){};function ft(e){let t=e.length;for(;--t>=0;)e[t]=0}const pt=256,vt=286,_t=30,mt=15,gt=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]),yt=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]),Et=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),kt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bt=new Array(576);ft(bt);const Ct=new Array(60);ft(Ct);const wt=new Array(512);ft(wt);const xt=new Array(256);ft(xt);const St=new Array(29);ft(St);const Tt=new Array(_t);function It(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 Nt,At,Mt;function Ot(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ft(Tt);const Ut=e=>e<256?wt[e]:wt[256+(e>>>7)],Dt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Rt=(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<{Rt(e,n[2*t],n[2*t+1])},Pt=(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,i,s=0;for(a=1;a<=mt;a++)s=s+n[a-1]<<1,r[a]=s;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=Pt(r[t]++,t))}},qt=e=>{let t;for(t=0;t{e.bi_valid>8?Dt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Gt=(e,t,n,r)=>{const a=2*t,i=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,i,s,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?Lt(e,a,t):(i=xt[a],Lt(e,i+pt+1,t),s=gt[i],0!==s&&(a-=St[i],Rt(e,a,s)),r--,i=Ut(r),Lt(e,i,n),s=yt[i],0!==s&&(r-=Tt[i],Rt(e,r,s)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,i=t.stat_desc.elems;let s,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)jt(e,n,s);u=i;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],jt(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,n[2*u]=n[2*s]+n[2*o],e.depth[u]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,n[2*s+1]=n[2*o+1]=u,e.heap[1]=u++,jt(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,i=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,d,h,f,p,v=0;for(h=0;h<=mt;h++)e.bl_count[h]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],h=n[2*n[2*l+1]+1]+1,h>u&&(h=u,v++),n[2*l+1]=h,l>r||(e.bl_count[h]++,f=0,l>=o&&(f=s[l-o]),p=n[2*l],e.opt_len+=p*(h+f),i&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(h=u-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(h=u;0!==h;h--)for(l=e.bl_count[h];0!==l;)d=e.heap[--c],d>r||(n[2*d+1]!==h&&(e.opt_len+=(h-n[2*d+1])*n[2*d],n[2*d+1]=h),l--)}})(e,t),Ft(n,c,e.bl_count)},Bt=(e,t,n)=>{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=s,s=t[2*(r+1)+1],++o{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),r=0;r<=n;r++)if(a=s,s=t[2*(r+1)+1],!(++o{Rt(e,0+(r?1:0),3),Ht(e),Dt(e,n),Dt(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Yt=(e,t,n,r)=>{let a,i,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(Bt(e,e.dyn_ltree,e.l_desc.max_code),Bt(e,e.dyn_dtree,e.d_desc.max_code),zt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*kt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=a&&(a=i)):a=i=n+5,n+4<=a&&-1!==t?Wt(e,t,n,r):4===e.strategy||i===a?(Rt(e,2+(r?1:0),3),Vt(e,bt,Ct)):(Rt(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(Rt(e,t-257,5),Rt(e,n-1,5),Rt(e,r-4,4),a=0;a{Qt||((()=>{let e,t,n,r,a;const i=new Array(16);for(n=0,r=0;r<28;r++)for(St[r]=n,e=0;e<1<>=7;r<_t;r++)for(Tt[r]=a<<7,e=0;e<1<(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*(xt[n]+pt+1)]++,e.dyn_dtree[2*Ut(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Rt(e,2,3),Lt(e,256,bt),(e=>{16===e.bi_valid?(Dt(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 Xt=(e,t,n,r)=>{let a=65535&e,i=e>>>16&65535,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{a=a+t[r++]|0,i=i+a|0}while(--s);a%=65521,i%=65521}return a|i<<16};const Jt=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 $t=(e,t,n,r)=>{const a=Jt,i=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return~e},en={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"},tn={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:nn,_tr_stored_block:rn,_tr_flush_block:an,_tr_tally:sn,_tr_align:on}=Zt,{Z_NO_FLUSH:un,Z_PARTIAL_FLUSH:cn,Z_FULL_FLUSH:ln,Z_FINISH:dn,Z_BLOCK:hn,Z_OK:fn,Z_STREAM_END:pn,Z_STREAM_ERROR:vn,Z_DATA_ERROR:_n,Z_BUF_ERROR:mn,Z_DEFAULT_COMPRESSION:gn,Z_FILTERED:yn,Z_HUFFMAN_ONLY:En,Z_RLE:kn,Z_FIXED:bn,Z_DEFAULT_STRATEGY:Cn,Z_UNKNOWN:wn,Z_DEFLATED:xn}=tn,Sn=258,Tn=262,In=42,Nn=113,An=666,Mn=(e,t)=>(e.msg=en[t],t),On=e=>2*e-(e>4?9:0),Un=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Dn=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 Rn=(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))},Pn=(e,t)=>{an(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Ln(e.strm)},Fn=(e,t)=>{e.pending_buf[e.pending++]=t},qn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Hn=(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=Xt(e.adler,t,a,n):2===e.state.wrap&&(e.adler=$t(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},Gn=(e,t)=>{let n,r,a=e.max_chain_length,i=e.strstart,s=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,d=e.prev,h=e.strstart+Sn;let f=c[i+s-1],p=c[i+s];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+s]===p&&c[n+s-1]===f&&c[n]===c[i]&&c[++n]===c[i+1]){i+=2,n++;do{}while(c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&is){if(e.match_start=t,s=r,r>=o)break;f=c[i+s-1],p=c[i+s]}}}while((t=d[t&l])>u&&0!=--a);return s<=e.lookahead?s:e.lookahead},jn=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),Dn(e),r+=t),0===e.strm.avail_in)break;if(n=Hn(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=Rn(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=Rn(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,i=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Ln(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(Hn(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 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&&(Hn(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,i=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=i||(r||t===dn)&&t!==un&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,s=t===dn&&0===e.strm.avail_in&&n===r?1:0,rn(e,e.block_start,n,s),e.block_start+=n,Ln(e.strm)),s?3:1)},zn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=Rn(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=Gn(e,n)),e.match_length>=3)if(r=sn(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=Rn(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=Rn(e,e.ins_h,e.window[e.strstart+1]);else r=sn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Pn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2},Bn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=Rn(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=sn(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=Rn(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&&(Pn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=sn(e,0,e.window[e.strstart-1]),r&&Pn(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=sn(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2};function Kn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const Qn=[new Kn(0,0,0,0,Vn),new Kn(4,4,8,4,zn),new Kn(4,5,16,8,zn),new Kn(4,6,32,32,zn),new Kn(4,4,16,16,Bn),new Kn(8,16,32,32,Bn),new Kn(8,16,128,128,Bn),new Kn(8,32,128,256,Bn),new Kn(32,128,258,1024,Bn),new Kn(32,258,258,4096,Bn)];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=xn,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 Yn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==In&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Nn&&t.status!==An?1:0},Zn=e=>{if(Yn(e))return Mn(e,vn);e.total_in=e.total_out=0,e.data_type=wn;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?In:Nn,e.adler=2===t.wrap?0:1,t.last_flush=-2,nn(t),fn},Xn=e=>{const t=Zn(e);var n;return t===fn&&((n=e.state).window_size=2*n.w_size,Un(n.head),n.max_lazy_match=Qn[n.level].max_lazy,n.good_match=Qn[n.level].good_length,n.nice_match=Qn[n.level].nice_length,n.max_chain_length=Qn[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},Jn=(e,t,n,r,a,i)=>{if(!e)return vn;let s=1;if(t===gn&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),a<1||a>9||n!==xn||r<8||r>15||t<0||t>9||i<0||i>bn||8===r&&1!==s)return Mn(e,vn);8===r&&(r=9);const o=new Wn;return e.state=o,o.strm=e,o.status=In,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<Jn(e,t,xn,15,8,Cn),deflateInit2:Jn,deflateReset:Xn,deflateResetKeep:Zn,deflateSetHeader:(e,t)=>Yn(e)||2!==e.state.wrap?vn:(e.state.gzhead=t,fn),deflate:(e,t)=>{if(Yn(e)||t>hn||t<0)return e?Mn(e,vn):vn;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===An&&t!==dn)return Mn(e,0===e.avail_out?mn:vn);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Ln(e),0===e.avail_out)return n.last_flush=-1,fn}else if(0===e.avail_in&&On(t)<=On(r)&&t!==dn)return Mn(e,mn);if(n.status===An&&0!==e.avail_in)return Mn(e,mn);if(n.status===In&&0===n.wrap&&(n.status=Nn),n.status===In){let t=xn+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=En||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,qn(n,t),0!==n.strstart&&(qn(n,e.adler>>>16),qn(n,65535&e.adler)),e.adler=1,n.status=Nn,Ln(e),0!==n.pending)return n.last_flush=-1,fn}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>=En||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=$t(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>=En||n.level<2?4:0),Fn(n,3),n.status=Nn,Ln(e),0!==n.pending)return n.last_flush=-1,fn;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=$t(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,Ln(e),0!==n.pending)return n.last_flush=-1,fn;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=$t(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=$t(e.adler,n.pending_buf,n.pending-r,r)),Ln(e),0!==n.pending)return n.last_flush=-1,fn;r=0}t=n.gzindexr&&(e.adler=$t(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=$t(e.adler,n.pending_buf,n.pending-r,r)),Ln(e),0!==n.pending)return n.last_flush=-1,fn;r=0}t=n.gzindexr&&(e.adler=$t(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Ln(e),0!==n.pending))return n.last_flush=-1,fn;Fn(n,255&e.adler),Fn(n,e.adler>>8&255),e.adler=0}if(n.status=Nn,Ln(e),0!==n.pending)return n.last_flush=-1,fn}if(0!==e.avail_in||0!==n.lookahead||t!==un&&n.status!==An){let r=0===n.level?Vn(n,t):n.strategy===En?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(jn(e),0===e.lookahead)){if(t===un)return 1;break}if(e.match_length=0,n=sn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Pn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===kn?((e,t)=>{let n,r,a,i;const s=e.window;for(;;){if(e.lookahead<=Sn){if(jn(e),e.lookahead<=Sn&&t===un)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=s[a],r===s[++a]&&r===s[++a]&&r===s[++a])){i=e.strstart+Sn;do{}while(r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=sn(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=sn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Pn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2})(n,t):Qn[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),fn;if(2===r&&(t===cn?on(n):t!==hn&&(rn(n,0,0,!1),t===ln&&(Un(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Ln(e),0===e.avail_out))return n.last_flush=-1,fn}return t!==dn?fn:n.wrap<=0?pn:(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)):(qn(n,e.adler>>>16),qn(n,65535&e.adler)),Ln(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?fn:pn)},deflateEnd:e=>{if(Yn(e))return vn;const t=e.state.status;return e.state=null,t===Nn?Mn(e,_n):fn},deflateSetDictionary:(e,t)=>{let n=t.length;if(Yn(e))return vn;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==In||r.lookahead)return vn;if(1===a&&(e.adler=Xt(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 i=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,jn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Rn(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,jn(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=o,e.avail_in=i,r.wrap=a,fn},deflateInfo:"pako deflate (from Nodeca project)"};const er=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var tr={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)er(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;rr[254]=rr[254]=1;var ar={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,i,s=e.length,o=0;for(a=0;a>>6,t[i++]=128|63&n):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|63&n):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=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 i=new Array(2*n);for(a=0,r=0;r4)i[a++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?i[a++]=65533:t<65536?i[a++]=t:(t-=65536,i[a++]=55296|t>>10&1023,i[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&nr)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+rr[e[n]]>t?n:t}};var ir=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 sr=Object.prototype.toString,{Z_NO_FLUSH:or,Z_SYNC_FLUSH:ur,Z_FULL_FLUSH:cr,Z_FINISH:lr,Z_OK:dr,Z_STREAM_END:hr,Z_DEFAULT_COMPRESSION:fr,Z_DEFAULT_STRATEGY:pr,Z_DEFLATED:vr}=tn;function _r(e){this.options=tr.assign({level:fr,method:vr,chunkSize:16384,windowBits:15,memLevel:8,strategy:pr},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 ir,this.strm.avail_out=0;let n=$n.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==dr)throw new Error(en[n]);if(t.header&&$n.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?ar.string2buf(t.dictionary):"[object ArrayBuffer]"===sr.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=$n.deflateSetDictionary(this.strm,e),n!==dr)throw new Error(en[n]);this._dict_set=!0}}function mr(e,t){const n=new _r(t);if(n.push(e,!0),n.err)throw n.msg||en[n.err];return n.result}_r.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,i;if(this.ended)return!1;for(i=t===~~t?t:!0===t?lr:or,"string"==typeof e?n.input=ar.string2buf(e):"[object ArrayBuffer]"===sr.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),(i===ur||i===cr)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=$n.deflate(n,i),a===hr)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=$n.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===dr;if(0!==n.avail_out){if(i>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},_r.prototype.onData=function(e){this.chunks.push(e)},_r.prototype.onEnd=function(e){e===dr&&(this.result=tr.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var gr={Deflate:_r,deflate:mr,deflateRaw:function(e,t){return(t=t||{}).raw=!0,mr(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,mr(e,t)},constants:tn};const yr=16209;var Er=function(e,t){let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x;const S=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,i=a-(t-e.avail_out),s=a+(e.avail_out-257),o=S.dmax,u=S.wsize,c=S.whave,l=S.wnext,d=S.window,h=S.hold,f=S.bits,p=S.lencode,v=S.distcode,_=(1<>>24,h>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(64&y){if(32&y){S.mode=16191;break e}e.msg="invalid literal/length code",S.mode=yr;break e}g=p[(65535&g)+(h&(1<>>=y,f-=y),f<15&&(h+=w[n++]<>>24,h>>>=y,f-=y,y=g>>>16&255,16&y){if(k=65535&g,y&=15,fo){e.msg="invalid distance too far back",S.mode=yr;break e}if(h>>>=y,f-=y,y=a-i,k>y){if(y=k-y,y>c&&S.sane){e.msg="invalid distance too far back",S.mode=yr;break e}if(b=0,C=d,0===l){if(b+=u-y,y2;)x[a++]=C[b++],x[a++]=C[b++],x[a++]=C[b++],E-=3;E&&(x[a++]=C[b++],E>1&&(x[a++]=C[b++]))}else{b=a-k;do{x[a++]=x[b++],x[a++]=x[b++],x[a++]=x[b++],E-=3}while(E>2);E&&(x[a++]=x[b++],E>1&&(x[a++]=x[b++]))}break}if(64&y){e.msg="invalid distance code",S.mode=yr;break e}g=v[(65535&g)+(h&(1<>3,n-=E,f-=E<<3,h&=(1<{const u=o.bits;let c,l,d,h,f,p,v=0,_=0,m=0,g=0,y=0,E=0,k=0,b=0,C=0,w=0,x=null;const S=new Uint16Array(16),T=new Uint16Array(16);let I,N,A,M=null;for(v=0;v<=kr;v++)S[v]=0;for(_=0;_=1&&0===S[g];g--);if(y>g&&(y=g),0===g)return a[i++]=20971520,a[i++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(T[1]=0,v=1;v852||2===e&&C>592)return 1;for(;;){I=v-k,s[_]+1=p?(N=M[s[_]-p],A=x[s[_]-p]):(N=96,A=0),c=1<>k)+l]=I<<24|N<<16|A}while(0!==l);for(c=1<>=1;if(0!==c?(w&=c-1,w+=c):w=0,_++,0==--S[v]){if(v===g)break;v=t[n+s[_]]}if(v>y&&(w&h)!==d){for(0===k&&(k=y),f+=m,E=v-k,b=1<852||2===e&&C>592)return 1;d=w&h,a[d]=y<<24|E<<16|f-i}}return 0!==w&&(a[f+w]=v-k<<24|64<<16),o.bits=y,0};const{Z_FINISH:Tr,Z_BLOCK:Ir,Z_TREES:Nr,Z_OK:Ar,Z_STREAM_END:Mr,Z_NEED_DICT:Or,Z_STREAM_ERROR:Ur,Z_DATA_ERROR:Dr,Z_MEM_ERROR:Rr,Z_BUF_ERROR:Lr,Z_DEFLATED:Pr}=tn,Fr=16180,qr=16190,Hr=16191,Gr=16192,jr=16194,Vr=16199,zr=16200,Br=16206,Kr=16209,Qr=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 Yr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Zr=e=>{if(Yr(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,Ar},Xr=e=>{if(Yr(e))return Ur;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Zr(e)},Jr=(e,t)=>{let n;if(Yr(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,Xr(e))},$r=(e,t)=>{if(!e)return Ur;const n=new Wr;e.state=n,n.strm=e,n.window=null,n.mode=Fr;const r=Jr(e,t);return r!==Ar&&(e.state=null),r};let ea,ta,na=!0;const ra=e=>{if(na){ea=new Int32Array(512),ta=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(Sr(1,e.lens,0,288,ea,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Sr(2,e.lens,0,32,ta,0,e.work,{bits:5}),na=!1}e.lencode=ea,e.lenbits=9,e.distcode=ta,e.distbits=5},aa=(e,t,n,r)=>{let a;const i=e.state;return null===i.window&&(i.wsize=1<=i.wsize?(i.window.set(t.subarray(n-i.wsize,n),0),i.wnext=0,i.whave=i.wsize):(a=i.wsize-i.wnext,a>r&&(a=r),i.window.set(t.subarray(n-r,n-r+a),i.wnext),(r-=a)?(i.window.set(t.subarray(n-r,n),0),i.wnext=r,i.whave=i.wsize):(i.wnext+=a,i.wnext===i.wsize&&(i.wnext=0),i.whave$r(e,15),inflateInit2:$r,inflate:(e,t)=>{let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w=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(Yr(e)||!e.output||!e.input&&0!==e.avail_in)return Ur;n=e.state,n.mode===Hr&&(n.mode=Gr),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,d=o,h=u,C=Ar;e:for(;;)switch(n.mode){case Fr:if(0===n.wrap){n.mode=Gr;break}for(;l<16;){if(0===o)break e;o--,c+=r[i++]<>>8&255,n.check=$t(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=Kr;break}if((15&c)!==Pr){e.msg="unknown compression method",n.mode=Kr;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=Kr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=$t(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[i++]<>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=$t(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[i++]<>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=$t(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[i++]<>>8&255,n.check=$t(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(i,i+f),b)),512&n.flags&&4&n.wrap&&(n.check=$t(n.check,r,f,i)),o-=f,i+=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[i+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=Hr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[i++]<>>=7&l,l-=7&l,n.mode=Br;break}for(;l<3;){if(0===o)break e;o--,c+=r[i++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(ra(n),n.mode=Vr,t===Nr){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Kr}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[i++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Kr;break}if(n.length=65535&c,c=0,l=0,n.mode=jr,t===Nr)break e;case jr: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(i,i+f),s),o-=f,i+=f,u-=f,s+=f,n.length-=f;break}n.mode=Hr;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[i++]<>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Kr;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,S={bits:n.lenbits},C=Sr(0,n.lens,0,19,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid code lengths set",n.mode=Kr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=_,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=Kr;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=Kr;break}for(;f--;)n.lens[n.have++]=b}}if(n.mode===Kr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Kr;break}if(n.lenbits=9,S={bits:n.lenbits},C=Sr(1,n.lens,0,n.nlen,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid literal/lengths set",n.mode=Kr;break}if(n.distbits=6,n.distcode=n.distdyn,S={bits:n.distbits},C=Sr(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,S),n.distbits=S.bits,C){e.msg="invalid distances set",n.mode=Kr;break}if(n.mode=Vr,t===Nr)break e;case Vr:n.mode=zr;case zr:if(o>=6&&u>=258){e.next_out=s,e.avail_out=u,e.next_in=i,e.avail_in=o,n.hold=c,n.bits=l,Er(e,h),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===Hr&&(n.back=-1);break}for(n.back=0;w=n.lencode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=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=Hr;break}if(64&m){e.msg="invalid literal/length code",n.mode=Kr;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(T=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;w=n.distcode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=Kr;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(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=Kr;break}n.mode=16204;case 16204:if(0===u)break e;if(f=h-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Kr;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=s-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[s++]=v[p++]}while(--f);0===n.length&&(n.mode=zr);break;case 16205:if(0===u)break e;a[s++]=n.length,u--,n.mode=zr;break;case Br:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[i++]<{if(Yr(e))return Ur;let t=e.state;return t.window&&(t.window=null),e.state=null,Ar},inflateGetHeader:(e,t)=>{if(Yr(e))return Ur;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Ar):Ur},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,i;return Yr(e)?Ur:(r=e.state,0!==r.wrap&&r.mode!==qr?Ur:r.mode===qr&&(a=1,a=Xt(a,t,n,0),a!==r.check)?Dr:(i=aa(e,t,n,n),i?(r.mode=16210,Rr):(r.havedict=1,Ar)))},inflateInfo:"pako inflate (from Nodeca project)"};var sa=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 oa=Object.prototype.toString,{Z_NO_FLUSH:ua,Z_FINISH:ca,Z_OK:la,Z_STREAM_END:da,Z_NEED_DICT:ha,Z_STREAM_ERROR:fa,Z_DATA_ERROR:pa,Z_MEM_ERROR:va}=tn;function _a(e){this.options=tr.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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ir,this.strm.avail_out=0;let n=ia.inflateInit2(this.strm,t.windowBits);if(n!==la)throw new Error(en[n]);if(this.header=new sa,ia.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=ar.string2buf(t.dictionary):"[object ArrayBuffer]"===oa.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ia.inflateSetDictionary(this.strm,t.dictionary),n!==la)))throw new Error(en[n])}function ma(e,t){const n=new _a(t);if(n.push(e),n.err)throw n.msg||en[n.err];return n.result}_a.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let i,s,o;if(this.ended)return!1;for(s=t===~~t?t:!0===t?ca:ua,"[object ArrayBuffer]"===oa.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),i=ia.inflate(n,s),i===ha&&a&&(i=ia.inflateSetDictionary(n,a),i===la?i=ia.inflate(n,s):i===pa&&(i=ha));n.avail_in>0&&i===da&&n.state.wrap>0&&0!==e[n.next_in];)ia.inflateReset(n),i=ia.inflate(n,s);switch(i){case fa:case pa:case ha:case va:return this.onEnd(i),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||i===da))if("string"===this.options.to){let e=ar.utf8border(n.output,n.next_out),t=n.next_out-e,a=ar.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(i!==la||0!==o){if(i===da)return i=ia.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},_a.prototype.onData=function(e){this.chunks.push(e)},_a.prototype.onEnd=function(e){e===la&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=tr.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ga={Inflate:_a,inflate:ma,inflateRaw:function(e,t){return(t=t||{}).raw=!0,ma(e,t)},ungzip:ma,constants:tn};const{Deflate:ya,deflate:Ea,deflateRaw:ka,gzip:ba}=gr,{Inflate:Ca,inflate:wa,inflateRaw:xa,ungzip:Sa}=ga;var Ta,Ia={Deflate:ya,deflate:Ea,deflateRaw:ka,gzip:ba,Inflate:Ca,inflate:wa,inflateRaw:xa,ungzip:Sa,constants:tn},Na=function(e){return E(void 0,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Ia.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,n));case 2:case"end":return t.stop()}}),t)})))};e.ConnectionState=void 0,(Ta=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",Ta.OPEN="OPEN",Ta.CLOSED="CLOSED";var Aa,Ma=function(t){function a(e,t){var i,s=t.sdkState,o=t.dispatcher,u=t.logger;return r(this,a),(i=n(this,a)).lastActive=0,i._iid=e,i._sdkState=s,i._dispatcher=o,i._logger=u,i}return c(a,t),i(a,[{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:"ws",get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ke.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 Be(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return E(this,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){r._logger.debug("websocket open"),r.dispatch("open")},this._ws.onmessage=function(e){return E(r,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)){t.next=23;break}if(!(e.data instanceof Blob)){t.next=7;break}(r=new FileReader).readAsArrayBuffer(e.data),r.onloadend=function(){return E(i,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Na(r.result);case 3:t=e.sent,this._handleMessage(t),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),this.error(e.t0);case 10:case"end":return e.stop()}}),e,this,[[0,7]])})))},t.next=21;break;case 7:if(!(e.data instanceof ArrayBuffer)){t.next=20;break}return t.prev=8,t.next=11,Na(new Uint8Array(e.data));case 11:a=t.sent,this._handleMessage(a),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),this.error(t.t0);case 18:t.next=21;break;case 20:"string"==typeof e.data&&this._handleMessage(e.data);case 21:t.next=24;break;case 23:this._handleMessage(e.data);case 24:case"end":return t.stop()}}),t,this,[[8,15]])})))},this._ws.onerror=function(){r._logger.debug("websocket error"),r.dispatch("error",A.networkError)},this._ws.onclose=function(){r._logger.debug("websocket close"),r.dispatch("close")},this.lastActive=Date.now();case 6:case"end":return n.stop()}}),n,this)})))}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws?(t._ws.onopen=ht,t._ws.onmessage=ht,t._ws.onerror=ht,t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=void 0):n()):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)}}])}(de),Oa=function(e){function t(e){var a,i=e.all,s=e.feed,o=e.custom_types,u=e.ts;return r(this,t),(a=n(this,t)).all=i,a.feed=s,a.customTypes=o,a.ts=u,a}return c(t,e),i(t)}(fe),Ua=function(){return i((function e(t,n){var a=this,i=n.session,s=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=s,this._dispatcher=o,this._logger=u,this.apiClient=new dt(t,{session:i,sdkState:s,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new Ma(t,{sdkState:s,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new Oa(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new A({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(A.connectionClosed)})),a._ackStateMap.clear()}))}),[{key:"_sendApiRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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(n=new ot,e.ackRequired){a=function(t,a){i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),r&&(clearTimeout(r),r=null),t?(i._logger.debug("fail websocket request",e.requestId,t),n.reject(t)):(i._logger.debug("receive websocket ack",e.requestId,e),i._logger.debug("receive websocket ack",a),n.resolve(a)))};try{r=setTimeout((function(){return a(A.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return a(void 0,e)},reject:function(e){return a(e)}}),this.websocketClient.send(e)}catch(e){a(e)}}else try{this.websocketClient.send(e),n.resolve()}catch(e){n.reject(e)}return t.abrupt("return",n.promise);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof je)){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 Qe)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw A.invalidParameters;case 11:case"end":return t.stop()}}),t,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}])}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(Aa||(Aa={}));var Da,Ra,La=function(e){function t(e){var a,i=e.stateType;return r(this,t),(a=n(this,t)).stateType=i,a}return c(t,e),i(t)}(fe),Pa=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Fa=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),qa=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Ha=function(){return i((function e(t){var n,a,i,s;r(this,e),this.isEnabled=null!==(n=t.enabled)&&void 0!==n&&n,this.feedChannels=null!==(a=t.feed_channels)&&void 0!==a?a:{},this.templateListToken=null!==(i=t.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(s=t.settings_updated_at)&&void 0!==s?s:0}),null,[{key:"payloadify",value:function(e){return pe(ve({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}])}(),Ga=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},ja=function(){return i((function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}),null,[{key:"payloadify",value:function(e){return pe(ve({last_updated_at:e.lastUpdatedAt}))}}])}(),Va=function(){return i((function e(t){var n;r(this,e),this.token=null!==(n=t.template_list_token)&&void 0!==n?n:""}),null,[{key:"payloadify",value:function(e){return pe(ve({template_list_token:e.token}))}}])}(),za=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180};r(this,e),this.minStatCount=t.min_stat_count,this.minInterval=1e3*t.min_interval,this.maxStatCountPerRequest=t.max_stat_count_per_request,this.lowerThreshold=t.lower_threshold,this.requestDelayRange=1e3*t.request_delay_range}),null,[{key:"payloadify",value:function(e){return pe(ve({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}])}(),Ba=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}};r(this,e),this.default=new za(t.default),this.realTime=new za(t.realtime)}),null,[{key:"payloadify",value:function(e){return pe(ve({default:za.payloadify(e.default),realtime:za.payloadify(e.realTime)}))}}])}(),Ka=1048576;e.UnreadCountThreadingPolicy=void 0,(Da=e.UnreadCountThreadingPolicy||(e.UnreadCountThreadingPolicy={}))[Da.NONE=0]="NONE",Da[Da.INCLUDE_REPLY=1]="INCLUDE_REPLY",Da[Da.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Da[Da.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",e.LastMessageThreadingPolicy=void 0,(Ra=e.LastMessageThreadingPolicy||(e.LastMessageThreadingPolicy={}))[Ra.NONE=0]="NONE",Ra[Ra.INCLUDE_REPLY=1]="INCLUDE_REPLY",Ra[Ra.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Ra[Ra.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";var Qa,Wa=function(){return i((function t(){var n,a,i,s,o,u,c,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),this.emojiHash=l.emoji_hash||"",this.uploadSizeLimit=l.file_upload_size_limit?l.file_upload_size_limit*Ka:Number.MAX_SAFE_INTEGER,this.useReaction=!!l.use_reaction,this.applicationAttributes=null!==(n=l.application_attributes)&&void 0!==n?n:[],this.premiumFeatureList=null!==(a=l.premium_feature_list)&&void 0!==a?a:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(i=l.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(s=l.allow_sdk_log_ingestion)||void 0===s||s,this.unreadCountThreadingPolicy=null!==(o=l.unread_cnt_threading_policy)&&void 0!==o?o:e.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(u=l.last_msg_threading_policy)&&void 0!==u?u:e.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new ja(null!==(c=l.uikit_config)&&void 0!==c?c:{}),this.notificationInfo=l.notifications?new Ha(l.notifications):null,this.messageTemplateInfo=l.message_template?new Va(l.message_template):null,this.statConfigInfo=l.log_publish_config?new Ba(l.log_publish_config):new Ba}),null,[{key:"payloadify",value:function(e){return pe(ve({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ka,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?ja.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Ha.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Va.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Ba.payloadify(e.statConfigInfo):null}))}}])}(),Ya=function(){return i((function e(t){r(this,e),this._iid="",this._iid=t}),null,[{key:"payloadify",value:function(e){return{}}}])}(),Za=function(e){function t(e){var a,i=e.userId,s=e.metadata;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s},a}return c(t,e),i(t)}(je),Xa=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaData=a,i}return c(t,e),i(t)}(Ve),Ja=function(e){function t(e){var a,i=e.userId,s=e.metadata,o=e.upsert;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s,upsert:o},a}return c(t,e),i(t)}(je),$a=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metadata=a,i}return c(t,e),i(t)}(Ve),ei=function(e){function t(e){var a,i=e.userId,s=e.metadataKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata/").concat(s),a}return c(t,e),i(t)}(je),ti=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata"),a}return c(t,e),i(t)}(je),ni=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},ri=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ai=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(Qa=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",Qa.OFFLINE="offline",Qa.NON_AVAILABLE="nonavailable";var ii,si=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y;return r(this,a),(s=n(this,a,[t])).userId=null!==(u=null!==(o=i.guest_id)&&void 0!==o?o:i.user_id)&&void 0!==u?u:"",s.nickname=null!==(l=null!==(c=i.nickname)&&void 0!==c?c:i.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(h=null!==(d=i.profile_url)&&void 0!==d?d:i.image)&&void 0!==h?h:"",s.requireAuth=null!==(f=i.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=i.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,R(e.UserOnlineState,i.is_online)?s.connectionStatus=i.is_online:D("boolean",i.is_online)&&(s.connectionStatus=i.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(_=i.is_active)||void 0===_||_,s.lastSeenAt=null!==(m=i.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=i.preferred_languages?v(i.preferred_languages):null,s.friendDiscoveryKey=null!==(g=i.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=i.friend_name)&&void 0!==y?y:null,s}return c(a,t),i(a,[{key:"profileUrl",get:function(){var e=es.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return ni(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 D("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,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(this._isValidMetaData(e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Za({userId:r.userId,metadata:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(Xa),u=o.metaData,this._applyMetaData(u),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(this._isValidMetaData(e)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Ja({userId:a.userId,metadata:e,upsert:t}),n.next=5,i.send(s);case 5:return o=n.sent,u=o.as($a),c=u.metadata,this._applyMetaData(c),n.abrupt("return",this.metaData);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ei({userId:r.userId,metadataKey:e}),t.next=5,a.send(i);case 5:return this._applyMetaData((s={},u=!0,(o=_(o=e))in s?Object.defineProperty(s,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):s[o]=u,s),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var s,o,u}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ti({userId:n.userId}),e.next=4,r.send(a);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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})))}}])}(Ya),oi=function(e){function t(e){var a,i=e.userProfile;return r(this,t),(a=n(this,t)).userProfile=i,a}return c(t,e),i(t)}(fe),ui=function(){return i((function e(t,n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new Wa(n),this.user=new si(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=n.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(s=n.pong_timeout)&&void 0!==s?s: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!==(h=null===(d=n.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==h?h: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}),[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=es.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 oi({userProfile:this}))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign(Object.assign({},si.payloadify(e.user)),Wa.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})))}}])}(),ci=function(e){function t(e){var a,i=e.request,s=void 0===i||i,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c,d=e.statConfigInfo;return r(this,t),(a=n(this,t)).request=s,a.features=Object.assign({localCache:!0,notification:!0},u),a.options=Object.assign({ingestion:!0},l),a.statConfigInfo=d,a}return c(t,e),i(t)}(fe),li=function(e){function t(e,a,i){var s,o,u,c,l;return r(this,t),(s=n(this,t,[e,a,i])).error=null,s.services=[],s.userProfile=new ui(e,i),s.deviceTokenLastDeletedAt=null!==(o=i.device_token_last_deleted_at)&&void 0!==o?o:0,s.key=null!==(u=i.key)&&void 0!==u?u:"",s.ekey=null!==(c=i.ekey)&&void 0!==c?c:"",s.error=i.error?new A(i):null,s.services=null!==(l=i.services)&&void 0!==l?l:[],s}return c(t,e),i(t,[{key:"applyTo",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=13;break}if(!(n=es.of(e))){t.next=10;break}return r=n.sessionManager,a=n.dispatcher,t.next=6,r.login(this);case 6:this.userProfile.apply(),a.dispatch(new ci({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),t.next=11;break;case 10:throw A.lostInstance;case 11:t.next=14;break;case 13:throw this.error;case 14:case"end":return t.stop()}}),t,this)})))}}],[{key:"asError",value:function(e){return new t("","LOGI",Object.assign({user_id:"",error:!0},e))}}])}(Ke),di=function(){return i((function e(){r(this,e),this.type=Aa.NONE,this.name="none"}),[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,t){return t.resetReconnectCount,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,t){return t.error,t.autoReconnect,t.cause,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}(),hi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=12;break;case 5:if(t.prev=5,t.t0=t.catch(0),!(t.t0 instanceof A)){t.next=11;break}t.t0.throwOutside(),t.next=12;break;case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,null,[[0,5]])})))},fi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=7;break;case 5:t.prev=5,t.t0=t.catch(0);case 7:case"end":return t.stop()}}),t,null,[[0,5]])})))},pi=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t)).type=Aa.LOGOUT,e.name="logout",e._wasPreviouslyConnected=null===(a=i.wasPreviouslyConnected)||void 0===a||a,e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=e.sdkState.userId,t.next=4,e.logout();case 4:return t.next=6,e.changeState(new Si,n);case 6:this._wasPreviouslyConnected&&hi((function(){return E(a,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(r)}));case 1:case"end":return t.stop()}}),t)})))}));case 7:case"end":return t.stop()}}),t,this)})))}}])}(di),vi=function(e){function t(){var e;return r(this,t),(e=n(this,t)).type=Aa.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),t)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ci({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Ei,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new pi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(di),_i=function(e){function t(e){var a,i=e.autoReconnect;return r(this,t),(a=n(this,t)).type=Aa.INTERNAL_DISCONNECTED,a.name="internaldisconnected",a._autoReconnect=!1,a._autoReconnect=i,a}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new Ei,n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ci({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Ei,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new vi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new pi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(di),mi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),t)})))},gi=function(){return i((function e(){r(this,e)}),[{key:"calcTimeout",value:function(){return 0}}])}(),yi=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new gi;return E(void 0,void 0,void 0,d().mark((function r(){var a,i,s,o,u;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=0,i=null,s=function(e){return i=null!=e?e:new Error("Halted")},o=function(){a=0};case 4:if(!(-1===t||a0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,e&&(this._webSocketClosedCause=ii.ExternalDisconnectWebSocket),t.next=4,n.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause});case 4:case"end":return t.stop()}}),t,this)})))}},{key:"logout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),t.next=4,n.onLogout(this._context,e);case 4:case"end":return t.stop()}}),t,this)})))}}])}(),Ci=function(t){function a(e){var t,i=e.authToken;return r(this,a),(t=n(this,a)).type=Aa.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=i,t}return c(a,t),i(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(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ot,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,yi((function(n){return E(i,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._haltConnect=n,r.prev=1,r.next=4,t.connect(this._authToken);case 4:r.next=16;break;case 6:if(r.prev=6,r.t0=r.catch(1),t.clearLoginTimer(),!(r.t0 instanceof A)){r.next=15;break}r.t1=r.t0.code,r.next=r.t1===e.SendbirdErrorCode.CONNECTION_CANCELED?13:15;break;case 13:return n(r.t0),r.abrupt("return");case 15:throw r.t0;case 16:case"end":return r.stop()}}),r,this,[[1,6]])})))}),t.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,t.changeState(new ki,r);case 8:hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(),t.connectionHandlers.forEach((function(e){e.onConnected&&e.onConnected(t.sdkState.userId)}));case 2:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),N(n.t0)){n.next=23;break}return n.next=16,t.disconnect();case 16:if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===e.SendbirdErrorCode.CONNECTION_CANCELED){n.next=20;break}return n.next=20,t.changeState(new Si,r);case 20:hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new ot,this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){var n=t.error,r=void 0===n?null:n,a=t.autoReconnect,i=void 0!==a&&a,s=t.cause,o=void 0===s?null:s;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Date.now(),this._halt(null!=r?r:wi(o)),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new _i({autoReconnect:i}),n);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new pi,n);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._halt(wi((null==t?void 0:t.cause)||null)),r=Date.now(),!e.hasSession){n.next=7;break}return n.next=5,e.changeState(new vi,r);case 5:n.next=9;break;case 7:return n.next=9,e.changeState(new pi,r);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),this._halt(null!=t?t:A.connectionCanceled),n.next=4,e.changeState(new pi,r);case 4:case"end":return n.stop()}}),n,this)})))}}])}(di);function wi(e){var t=A.connectionCanceled;if(e){var n=null;switch(e){case ii.ExternalSetBackground:n="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case ii.ExternalDisconnectWebSocket:n="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}n&&t.setDetail(n)}return t}var xi,Si=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).type=Aa.INITIALIZED,e.name="initialized",e}return c(t,e),i(t,[{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.changeState(new Ci({authToken:t}),r);case 3:case"end":return n.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new pi({wasPreviouslyConnected:!1}),n);case 3:case"end":return t.stop()}}),t)})))}}])}(di),Ti=function(e){function t(){return r(this,t),n(this,t,[{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1}])}return c(t,e),i(t)}(Qe),Ii=function(){return i((function e(t){var n=t.pingDelegate,a=t.sdkState,i=t.logger;r(this,e),this.pingDelegate=n,this.sdkState=a,this._logger=i}),[{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 Ti;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)}}])}(),Ni=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"],Ai=function(e){function t(e,a){var i,s,o=a.sdkState,u=a.cacheContext,c=a.connectionHandlers,l=a.sessionManager,d=a.websocketClient,h=a.dispatcher,f=a.logger,p=a.entryState,v=void 0===p?new Si:p;return r(this,t),(i=n(this,t))._stateUpdatedAt=0,i._connectingAt=0,i._connectionRequestQueue=[],i._iid=e,i.sdkState=o,i.cacheContext=u,i.connectionHandlers=c,i._sessionManager=l,i._websocketClient=d,i._dispatcher=h,i._logger=f,i._currentState=v,(null===(s=i.sdkState.websocket)||void 0===s?void 0:s.pingerDisabled)||(i._pinger=new Ii({pingDelegate:{send:function(e){return i._websocketClient.send(e)},error:function(e){return i._websocketClient.error(e)}},sdkState:i.sdkState,logger:f})),i._websocketClient.on("open",(function(){i._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)i.clearLoginTimer(),i._dispatcher.dispatch(e.as(li))})).on("ping-refresh",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){i._logiProcessingTimer=setTimeout((function(){i._logiProcessingTimer=void 0,i._unresolvedLogi||i._rejectConnectionRequest(A.networkError)}),500)})),i._dispatcher.on((function(e){e instanceof li&&(i._unresolvedLogi=e,i._tryResolveConnectionRequest())})),i}return c(t,e),i(t,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.session.hasSession}},{key:"changeState",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>=this._stateUpdatedAt)){n.next=8;break}return this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new La({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),n.next=7,this._currentState.run(this);case 7:return n.abrupt("return",!0);case 8:return n.abrupt("return",!1);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._unresolvedLogi,!this._websocketClient.isOpen||!n){t.next=16;break}if(this._unresolvedLogi=void 0,n.error){t.next=13;break}return t.next=6,n.applyTo(this._iid);case 6: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=16;break;case 13:this._sessionManager.session.authToken=void 0,n.error.isSessionExpiredError||n.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Be({reason:n.error.code,message:n.error.message})):this._logger.warn("login failed: ".concat(n.error)),this._rejectConnectionRequest(n.error);case 16:case"end":return t.stop()}}),t,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=this.sdkState,n=t.appId,r=t.appVersion,a=t.userId,i=t.extensions,s=t.sendbirdRuntimeEnvironment,o=this.cacheContext.localCacheEnabled,u=this._sessionManager.session,c=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=i?i:{}).sb_uikit,d=st.userAgentWithExtension(i);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(u.hasSession?"":"&user_id=".concat(encodeURIComponent(a)),"&pmce=").concat(c?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent(st.sendbirdSdkUserAgentWithExtension(s)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(Ni))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new Je(new rt({type:Ge.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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(A.connectionCanceled)),r=new ot,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){s._loginTimer=void 0,s._rejectConnectionRequest(A.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),a=this._sessionManager.session,t&&(a.authToken=t,a.sessionKey=void 0),i=this._url(),a.sessionKey||a.authToken?this._websocketClient.connect(i,JSON.stringify(a.hasSession?{auth:a.sessionKey}:{token:a.authToken})):this._websocketClient.connect(i,JSON.stringify({}))),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(li.asError(A.connectionRenew))}},{key:"disconnect",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){return d().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.disconnect();case 4:return e.next=6,this._sessionManager.clear();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}])}(de),Mi=function(e){function t(e){var a,i=e.appId,s=e.userId,o=e.includeUIKitConfig,u=void 0!==o&&o,c=e.localCacheEnabled,l=void 0===c||c,d=e.expiringSession,h=void 0===d||d;return r(this,t),(a=n(this,t)).path="".concat(ye,"/").concat(s,"/authentication"),a.method=_e.POST,a.params=pe({expiring_session:!!h,include_logi:!0,include_extra_data:String(Ni),uikit_config:u,use_local_cache:l,app_id:i}),a.requireAuth=!1,a}return c(t,e),i(t)}(je),Oi=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).logi=new li(e,"LOGI",a),i}return c(t,e),i(t)}(Ve);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(xi||(xi={}));var Ui,Di,Ri=[We,Mi],Li=function(){return i((function e(t,n){var a=this,i=n.session,o=n.sdkState,u=n.dispatcher,c=n.logger,l=n.useFetchCompat,d=void 0!==l&&l;r(this,e),this._currentConnectionStateType=Aa.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Ua(t,{session:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:d}),this._session=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){var t;if(e instanceof La){var n=e.stateType;switch(a._currentConnectionStateType=n,n){case Aa.CONNECTED:a._resolveLazyCallQueue();break;case Aa.INITIALIZED:case Aa.INTERNAL_DISCONNECTED:case Aa.EXTERNAL_DISCONNECTED:case Aa.LOGOUT:a._rejectLazyCallQueue((null===(t=a._session)||void 0===t?void 0:t.hasSession)?A.connectionClosed:A.connectionRequired)}}else if(e instanceof Pa)a._session.hasChatServicePermission||a._resolveLazyCallQueue(xi.API);else if(e instanceof Fa||e instanceof qa)a._rejectLazyCallQueue(A.connectionClosed);else if(e instanceof $e){var r,i=e.request,o=e.deferred,u=e.error,c=s(Ri);try{for(c.s();!(r=c.n()).done;){if(i instanceof r.value)return void o.reject(u)}}catch(e){c.e(e)}finally{c.f()}a._lazyCallQueue.push({command:i,deferred:o})}}))}),[{key:"isReady",get:function(){return this._currentConnectionStateType===Aa.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===Aa.CONNECTING||this._currentConnectionStateType===Aa.RECONNECTING||this._session.isRefreshing}},{key:"_classifyLazyCallQueueByScope",value:function(e){var t,n=[],r=[];switch(e){case xi.ALL:t=null;break;case xi.WEBSOCKET:t=Qe;break;case xi.API:t=je}var a=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(a=!0),a?r.push(e):n.push(e)})),[n,r]}},{key:"_resolveLazyCallQueue",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xi.ALL,n=f(this._classifyLazyCallQueueByScope(t),2),r=n[0],a=n[1];this._lazyCallQueue=a,r.forEach((function(t){return E(e,void 0,void 0,d().mark((function e(){var n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.command,r=t.deferred,(a=t.timeout)&&clearTimeout(a),e.prev=2,e.next=5,this.send(n);case 5:i=e.sent,r.resolve(i),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),r.reject(e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])})))}))}},{key:"_rejectLazyCallQueue",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:xi.ALL,r=f(this._classifyLazyCallQueueByScope(n),2),a=r[0],i=r[1];this._lazyCallQueue=i,a.forEach((function(n){return E(t,void 0,void 0,d().mark((function t(){var r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n.deferred,a=n.timeout,clearTimeout(a),r.reject(e);case 3:case"end":return t.stop()}}),t)})))}))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Qe)){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:case 31:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),n=new ot,this._lazyCallQueue.push({command:e,deferred:n,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",n.promise);case 15:throw this._logger.debug("fail websocket request"),A.connectionRequired;case 17:case 44:t.next=47;break;case 19:if(!(e instanceof je)){t.next=46;break}if(!this._session.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!e.hasSessionKey){t.next=34;break}return this._logger.debug("send api request with tmp session key",e),t.next=31,this.commandRouter.send(e);case 34:if(!this.isLazyCallActivated){t.next=41;break}return this._logger.debug("wait api request",e),r=new ot,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 41:throw a=A.connectionRequired,this._logger.debug("fail api request",a),a;case 46:throw A.invalidCommand;case 47:case"end":return t.stop()}}),t,this)})))}},{key:"forceSend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._logger.debug("send forced request",e),!(e instanceof Qe||e instanceof je)){t.next=7;break}return t.next=4,this.commandRouter.send(e);case 4:return t.abrupt("return",t.sent);case 7:throw A.invalidCommand;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(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()}}])}(),Pi="sendbird@devicetokens",Fi=function(){return i((function e(t){var n=t.type,a=t.token,i=t.device_os,s=t.device_manufacturer,o=t.system_push_enabled;r(this,e),this.type=n,this.token=a,this.deviceOS=i,this.deviceManufacturer=s,this.systemPushEnabled=o}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}])}(),qi=new WeakMap,Hi=function(t){function a(e){var t,i=e._iid,s=e.session,o=e.cacheContext,u=e.sdkState,c=e.dispatcher,l=e.requestQueue,d=e.logger,h=e.pushNotificationAckManager;return r(this,a),(t=n(this,a))._currentConnectionStateType=Aa.INITIALIZED,t._isRefreshingAuthToken=!1,t.currentUser=null,t.session=s,t._iid=i,t._cacheContext=o,t._sdkState=u,t._dispatcher=c,t._requestQueue=l,t._logger=d,t._pushNotificationAckManager=h,t._deviceTokens=[],t._dispatcher.on((function(e){var n,r,a;if(e instanceof La){var i=e.stateType;t._currentConnectionStateType=i}else if(e instanceof Be&&t.handler&&!t.isSessionKeyRefreshing){if(t._currentConnectionStateType===Aa.CONNECTING)return;(null===(n=e.error)||void 0===n?void 0:n.isSessionInvalidatedError)?t.close():((null===(r=e.error)||void 0===r?void 0:r.isSessionTokenExpiredError)&&t.refreshAuthToken().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e})),(null===(a=e.error)||void 0===a?void 0:a.isSessionKeyExpiredError)&&(t._logger.debug("session expired"),t.handler.onSessionExpired&&t.handler.onSessionExpired(),t.refreshSessionKey().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e}))))}})),t}return c(a,t),i(a,[{key:"ekey",get:function(){return qi.get(this)}},{key:"deviceTokens",get:function(){return this._deviceTokens}},{key:"deviceTokenLastDeletedAt",get:function(){return this._deviceTokenLastDeletedAt}},{key:"indexOfDeviceToken",value:function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))}},{key:"hasDeviceToken",value:function(e,t){return this.indexOfDeviceToken(e,t)>=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new Ye({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(n);case 3:if(r=t.sent,a=r.as(Xe),i=a.newKey,!(s=a.error)){t.next=7;break}throw s;case 7:this.session.sessionKey=null!=i?i:this.session.sessionKey;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new We({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),t.next=3,yi((function(e){return E(r,void 0,void 0,d().mark((function t(){var r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(n);case 3:r=t.sent,a=r.as(Ze),i=a.key,s=a.services,this.session.sessionKey=i,this.session.services=s,t.next=16;break;case 9:if(t.prev=9,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=15;break}e(t.t0),t.next=16;break;case 15:throw t.t0;case 16:case"end":return t.stop()}}),t,this,[[0,9]])})))}),3);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKey",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._currentConnectionStateType!==Aa.CONNECTED){n.next=18;break}return n.prev=1,n.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),n.abrupt("return");case 8:return n.prev=8,n.t0=n.catch(1),n.prev=10,n.next=13,this._handleSessionRefreshError(n.t0,t);case 13:return n.abrupt("return");case 16:n.prev=16,n.t1=n.catch(10);case 18:return n.prev=18,n.next=21,this._refreshSessionKeyByApi(e);case 21:this.complete(),n.next=28;break;case 24:return n.prev=24,n.t2=n.catch(18),n.next=28,this._handleSessionRefreshError(n.t2,t);case 28:case"end":return n.stop()}}),n,this,[[1,8],[10,16],[18,24]])})))}},{key:"_receiveNewAuthToken",value:function(){var e,t=this,n=new ot;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var r=null,a=function(){r&&(clearTimeout(r),r=null)},i=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},s=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};r=setTimeout((function(){return s()}),1e3*this._sdkState.sessionTokenRefreshTimeout),hi((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(i,s);case 1:case"end":return e.stop()}}),e,this)})))}))}else n.resolve(null);return n.promise}},{key:"_handleSessionRefreshError",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(t instanceof A)){r.next=16;break}if(!t.isSessionTokenExpiredError&&t.code!==e.SendbirdErrorCode.APPLICATION_NOT_FOUND){r.next=16;break}if(this.session.authToken=void 0,!n){r.next=16;break}return r.next=6,this._receiveNewAuthToken();case 6:if(!(a=r.sent)){r.next=13;break}return this.session.authToken=a,r.next=11,this._refreshSessionKey(this.session.authToken,!1);case 11:r.next=15;break;case 13:return r.next=15,this.clear();case 15:return r.abrupt("return");case 16:throw t;case 17:case"end":return r.stop()}}),r,this)})))}},{key:"_isSessionRelatedError",value:function(e){return e instanceof A&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}},{key:"isSessionKeyRefreshing",get:function(){return this.session.isRefreshing}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"isSessionExpiring",get:function(){return!!this.handler}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.session.authToken=t,a=new Mi({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!t||this.isSessionExpiring}),r.next=4,this._requestQueue.commandRouter.send(a);case 4:if(i=r.sent,s=i.as(Oi),(o=s.logi).error){r.next=12;break}if(this.session.hasChatServicePermission){r.next=10;break}return r.next=10,o.applyTo(this._iid);case 10:r.next=13;break;case 12:throw o.error;case 13:case"end":return r.stop()}}),r,this)})))}},{key:"login",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=e.key,a=e.ekey,i=e.services,s=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.session.sessionKey=r,this.session.services=i,qi.set(this,a),this._deviceTokenCacheEnabled=null===(t=null==s?void 0:s.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){n.next=21;break}return n.next=9,c.get(Pi);case 9:if((l=n.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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return t=this._cacheContext.preference,e.next=4,t.set(Pi,{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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.session.clear(),this.close(),qi.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:this._pushNotificationAckManager.clear();case 9:case"end":return e.stop()}}),e,this)})))}}])}(de),Gi=function(e,t){if(null!==e&&null!==t){var n,r=Object.keys(e),a=Object.keys(t),i={},o=s(v(new Set([].concat(r,a))));try{for(o.s();!(n=o.n()).done;){var u=n.value,c=m(e[u]),l=m(t[u]);"undefined"===c?i[u]=t[u]:"undefined"===l?i[u]=e[u]:c!==l?i[u]=t[u]:"object"===c&&e[u]&&t[u]?i[u]=Gi(e[u],t[u]):i[u]=t[u]}}catch(e){o.e(e)}finally{o.f()}return i}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"}(Ui||(Ui={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(Di||(Di={}));var ji,Vi=function(e){function t(e){var a,i=e.deviceId,s=e.statLogs;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Oe),a.params={device_id:i,log_entries:s.map((function(e){return rt.payloadify(e)}))},a}return c(t,e),i(t)}(je),zi=function(){return i((function e(t){var n=t.deviceId,a=t.cacheContext,i=t.requestQueue;r(this,e),this.queue=[],this.flushWaitQueue=[],this.enabledState=Ui.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=n,this.cacheContext=a,this.requestQueue=i,this.logInfo={deviceId:n,statLogs:[],generation:1,lastFlushedAt:0},this.limit=100}),[{key:"isEnabled",get:function(){return this.enabledState===Ui.ENABLED}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:(n=t.sent)&&(this.logInfo=n);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_mergeQueue",value:function(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}},{key:"_isDuplicateStat",value:function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}},{key:"_flush",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=!0,!(t.length>0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Vi({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Ui.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ui.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}},{key:"_save",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(v(this.queue),v(this.flushWaitQueue)),e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:t.map((function(e){return rt.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save();case 4:case"end":return e.stop()}}),e,this)})))}}])}(),Bi=function(e){function t(e){var a,i,s,o,u,c=e.type,l=e.data,d=e.ts,h=void 0===d?Date.now():d;return r(this,t),(a=n(this,t,[{type:c,data:l,ts:h}])).date=new Date(h),a.key="".concat((i=a.date,s=i.getFullYear(),o=String(i.getMonth()+1).padStart(2,"0"),u=String(i.getDate()).padStart(2,"0"),"".concat(s).concat(o).concat(u)),"_").concat(c),a}return c(t,e),i(t)}(rt),Ki=function(e){function t(e){var a=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,t),n(this,t,[{deviceId:a,cacheContext:i,requestQueue:s}])}return c(t,e),i(t,[{key:"_isSendable",get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var n=this,r=Object.create(null,{init:{get:function(){return p(t,"init",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.init.call(this,e+".daily");case 2:this.queue=this.logInfo.statLogs.map((function(e){return new rt({type:e.stat_type,ts:e.ts,data:e.data})}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),!t.localCacheStat){n.next=7;break}this.enabledState=t.enabledStat?Ui.ENABLED:Ui.COLLECT_ONLY,n.next=10;break;case 7:return this.enabledState=Ui.DISABLED,n.next=10,this.clear();case 10:if(!this.isEnabled||!this._isSendable){n.next=25;break}return n.next=13,this._getUploadStats();case 13:r=n.sent,a=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),i=0;case 16:if(!(i0&&void 0!==arguments[0]&&arguments[0];if(this.queue.length=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var n=this,r=Object.create(null,{init:{get:function(){return p(t,"init",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.init.call(this,e+".realtime");case 2:this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new rt({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this._mergeQueue(),!t.notificationStat){n.next=6;break}this.enabledState=t.enabledStat?Ui.ENABLED:Ui.COLLECT_ONLY,n.next=9;break;case 6:return this.enabledState=Ui.DISABLED,n.next=9,this.clear();case 9:if(!this.isEnabled||!this._isSendable){n.next=15;break}return r=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),n.next=13,mi(r);case 13:return n.next=15,this._flush(this.queue);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState!==Ui.DISABLED){t.next=2;break}return t.abrupt("return",!0);case 2:if(n=this.enabledState===Ui.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,!this._isDuplicateStat(e)){t.next=5;break}return t.abrupt("return",!0);case 5:if(n.push(e),this.enabledState===Ui.PENDING){t.next=9;break}return t.next=9,this._save();case 9:if(!this.isEnabled){t.next=15;break}if(this._mergeQueue(),!this.isEnabled||!this._isSendable){t.next=15;break}return t.next=14,this._flush(n);case 14:return t.abrupt("return",t.sent);case 15:return t.abrupt("return",!0);case 16:case"end":return t.stop()}}),t,this)})))}}])}(zi),Yi=function(){return i((function e(t){var n=t.cacheContext,a=t.requestQueue,i=t.dispatcher,s=t.logger;r(this,e),this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=ce(),this.cacheContext=n,this.requestQueue=a,this.dispatcher=i,this.logger=s,this._dailyStatCollector=new Ki({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Qi({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._realTimeStatCollector=new Wi({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}),[{key:"_migration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cacheContext.preference.get(this.key);case 2:if(!(t=e.sent)){e.next=18;break}return n=[],t.statLogs.forEach((function(e){e.stat_type===Ge.FEATURE_LOCALCACHE&&n.push(new rt({type:e.stat_type,ts:e.ts,data:e.data}))})),e.next=8,this.cacheContext.preference.set(this.key+".daily",{deviceId:t.deviceId,statLogs:n.map((function(e){return rt.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 8:return r=[],t.statLogs.forEach((function(e){e.stat_type!==Ge.FEATURE_LOCALCACHE&&e.stat_type!==Ge.NOTIFICATION&&(e.stat_type===Ge.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),r.push(new rt({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=12,this.cacheContext.preference.set(this.key+".default",{deviceId:t.deviceId,statLogs:r.map((function(e){return rt.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 12:return a=[],t.statLogs.forEach((function(e){var t;e.stat_type===Ge.NOTIFICATION&&(e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),a.push(new rt({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=16,this.cacheContext.preference.set(this.key+".realtime",{deviceId:t.deviceId,statLogs:a.map((function(e){return rt.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 16:return e.next=18,this.cacheContext.preference.remove(this.key);case 18:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this._migration();case 3:return t.next=5,this._dailyStatCollector.init(this.key);case 5:return t.next=7,this._defaultStatCollector.init(this.key);case 7:return t.next=9,this._realTimeStatCollector.init(this.key);case 9:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e instanceof Je?(r=e.statLog,this.put(r)):e instanceof ci&&(a=e.request,i=e.features,s=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=a,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._realTimeStatCollector.setConfig(null!==(n=this._statConfig.realTime)&&void 0!==n?n:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:s.ingestion}));case 1:case"end":return t.stop()}}),t,this)})))})));case 10:case"end":return t.stop()}}),t,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=!0,!(e instanceof Bi)){t.next=8;break}if(!this._collectFeatureLocalCacheStat){t.next=6;break}return t.next=5,this._dailyStatCollector.put(e);case 5:n=t.sent;case 6:t.next=26;break;case 8:t.t0=e.type,t.next=t.t0===Ge.API_RESULT||t.t0===Ge.WEBSOCKET_CONNECT?11:t.t0===Ge.FEATURE_LOCALCACHE||t.t0===Ge.FEATURE_LOCALCACHE_EVENT?16:t.t0===Ge.NOTIFICATION?21:26;break;case 11:if(!this._collectRequestStat){t.next=15;break}return t.next=14,this._defaultStatCollector.put(e);case 14:n=t.sent;case 15:return t.abrupt("break",26);case 16:if(!this._collectFeatureLocalCacheStat){t.next=20;break}return t.next=19,this._defaultStatCollector.put(e);case 19:n=t.sent;case 20:return t.abrupt("break",26);case 21:if(!this._collectionNotificationStat){t.next=25;break}return t.next=24,this._realTimeStatCollector.put(e);case 24:n=t.sent;case 25:return t.abrupt("break",26);case 26:n?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Ui.COLLECT_ONLY,this._defaultStatCollector.enabledState=Ui.COLLECT_ONLY,this._realTimeStatCollector.enabledState=Ui.COLLECT_ONLY,this.logger.debug(A.statLogUploadLimitExceededError)));case 27:case"end":return t.stop()}}),t,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}])}(),Zi=function(){return i((function e(t){var n=t.limit,a=void 0===n?5:n;r(this,e),this.workersByKey={},this.limit=a}),[{key:"run",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.workersByKey[e]||(this.workersByKey[e]=[]),!(this.workersByKey[e].length0:void 0,i.lastRepliedAt=null!==(c=a.last_replied_at)&&void 0!==c?c:0,i.updatedAt=null!==(l=a.updated_at)&&void 0!==l?l:0,i}return c(t,e),i(t,[{key:"_isUpdateRequired",get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}},{key:"_updateFrom",value:function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((function(e){return si.payloadify(e)})):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}}])}(Ya);e.ReactionEventOperation=void 0,(Xi=e.ReactionEventOperation||(e.ReactionEventOperation={})).ADD="add",Xi.DELETE="delete";var ss,os=i((function t(n){r(this,t),this.messageId=0,this.operation=null,this.updatedAt=0;var a=D("string",n.msg_id)?parseInt(n.msg_id):n.msg_id,i=n.user_id,s=n.operation?n.operation.toLowerCase():null,o=n.reaction,u=n.updated_at;a&&D("string",i)&&D("string",s)&&R(e.ReactionEventOperation,s)&&D("string",o)&&o&&D("number",u)&&(this.messageId=a,this.userId=i,this.key=o,this.operation=s,this.updatedAt=u)})),us=function(){return i((function e(t){var n;r(this,e);var a=t.key,i=null!==(n=v(t.user_ids))&&void 0!==n?n:[],o=t.updated_at;D("string",a)&&a&&P("string",i)&&i.length>0&&D("number",o)&&(this.key=a,this.userIds=i,this.updatedAt=o);var u,c={},l=s(this.userIds);try{for(l.s();!(u=l.n()).done;){c[u.value]=this.updatedAt}}catch(e){l.e(e)}finally{l.f()}this._version=c}),[{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 pe(ve({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}}])}(),cs=function(){return i((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)}),null,[{key:"payloadify",value:function(e){var t,n;return pe(ve({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}))}}])}(),ls=function(){return i((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 cs(t["og:image"]))}),null,[{key:"payloadify",value:function(e){return pe(ve({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?cs.payloadify(e.defaultImage):null}))}}])}(),ds=function(){return i((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}),[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return pe(ve({name:e.name,volume:e.volume}))}}])}();e.FeedbackRating=void 0,(ss=e.FeedbackRating||(e.FeedbackRating={})).GOOD="good",ss.BAD="bad";var hs,fs=function(){function e(t){r(this,e),this.id=t.id,this.rating=t.rating,this.comment=t.comment}return i(e,null,[{key:"_getStatus",value:function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}},{key:"_isSubmitted",value:function(t){return"SUBMITTED"===e._getStatus(t)}},{key:"_getPayloadByStatus",value:function(e){return"NO_FEEDBACK"===e?{}:null}},{key:"payloadify",value:function(e){return pe(ve({id:e.id,rating:e.rating,comment:e.comment}))}}])}(),ps=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i])).isBlockedByMe=!1,s.role=R(e.Role,i.role)?i.role:e.Role.NONE,s.isBlockedByMe=null!==(o=i.is_blocked_by_me)&&void 0!==o&&o,s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}])}(si),vs=function(){return i((function e(t){r(this,e),this.key=t.key,this.value=P("string",t.value)?v(t.value):[]}),null,[{key:"payloadify",value:function(e){var t;return pe(ve({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}])}(),_s=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"}},ms=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;r(this,a),(s=n(this,a,[t])).channelType=e.ChannelType.BASE,s.messageType=e.MessageType.BASE,s.mentionType=null,s.mentionedUsers=null,s.mentionedUserIds=null,s.mentionedMessageTemplate=void 0,s.metaArrays=[],s.extendedMessage={},s.createdAt=0,s.updatedAt=0,s.channelUrl=i.channel_url,s.channelType=R(e.ChannelType,i.channel_type)?i.channel_type:e.ChannelType.GROUP,i.channel&&(i.channel.channel_url&&(s.channelUrl=i.channel.channel_url),i.channel.channel_type&&(s.channelType=i.channel.channel_type)),s.data=null!==(o=i.data)&&void 0!==o?o:"",s.customType=null!==(u=i.custom_type)&&void 0!==u?u:"",s.mentionType=R(e.MentionType,i.mention_type)?i.mention_type:null,s.mentionedUsers=i.mentioned_users?i.mentioned_users.map((function(e){return new si(s._iid,e)})):null,s.mentionedUserIds=null!==(c=i.mentioned_user_ids)&&void 0!==c?c:null,s.mentionedUsers&&!s.mentionedUserIds&&(s.mentionedUserIds=s.mentionedUsers.map((function(e){return e.userId}))),s.mentionedMessageTemplate=i.mentioned_message_template;var _=null!==(l=i.metaarray)&&void 0!==l?l:{},m=null!==(d=i.metaarray_key_order)&&void 0!==d?d:Object.keys(_).sort((function(e,t){return e.localeCompare(t)}));s.metaArrays=[];for(var g=0;g0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,items:e.items.map((function(e){return Bs.payloadify(e)})),version:e.version,is_submitted:e._isSubmitted}))}},{key:"isMessageFormPayload",value:function(e){return Boolean(null==e?void 0:e.message_form)}}])}(),Bs=function(){return i((function e(t){r(this,e);var n=t.id,a=t.name,i=t.required,s=t.sort_order,o=t.placeholder,u=t.style,c=t.item_type,l=t.validators,d=t.value,h=t.values;this.id=n,this.name=a,this.required=i,this.sortOrder=s,this.placeholder=o,0===Object.keys(u).length?this.style={layout:c}:this.style=pe({layout:u.layout,options:u.options,defaultOptions:u.default_options,resultCount:u.result_count}),h?this.submittedValues=h:d&&(this.submittedValues=[d]),this._validators=l}),[{key:"isValid",value:function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case Is.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case Is.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case Is.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case Is.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case Is.DECIMAL_PLACE:if(0===e.length)return!1;var r=Number(e);return!(isNaN(r)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(r,t.max_decimal_place));default:return!0}}))}(e,t._validators);return n}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:pe({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}])}(),Ks=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Re,"/").concat(e.formId,"/submit"),a.params=pe({message_id:e.messageId,items:e.items}),a}return c(t,e),i(t)}(je);e.ScheduledStatus=void 0,(js=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",js.SENT="sent",js.FAILED="failed",js.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Vs||(Vs={}));var Qs,Ws=function(t){function a(e,t){var i,s,o,u,c,l,d,h,f;return r(this,a),(i=n(this,a,[e,t])).parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.threadInfo=null,i.reactions=[],i.appleCriticalAlertOptions=null,i.scheduledInfo=null,i.suggestedReplies=null,i.myFeedback=null,i.myFeedbackStatus="NOT_APPLICABLE",i.messageForm=null,i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(o=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==o?o:0,i.parentMessageId=null!==(u="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==u?u:0,i.threadInfo=t.thread_info?new is(i._iid,t.thread_info):null,i.reactions=t.reactions?t.reactions.map((function(e){return new us(e)})):[],i.ogMetaData=t.og_tag?new ls(t.og_tag):null,i.silent=null!==(c=t.silent)&&void 0!==c&&c,i.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,i.appleCriticalAlertOptions=t.apple_critical_alert_options?new ds(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(i.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},i._scheduledStatus=t.scheduled_status),i._isContinuousMessages=null!==(d=t.is_continuous_messages)&&void 0!==d&&d,i.myFeedback=fs._isSubmitted(t.feedback)?new fs(t.feedback):null,i.myFeedbackStatus=fs._getStatus(t.feedback),i.suggestedReplies=null!==(f=null===(h=t.extended_message_payload)||void 0===h?void 0:h.suggested_replies)&&void 0!==f?f:null,i.messageForm=zs.isMessageFormPayload(t.extended_message_payload)?new zs(i.messageId,t.extended_message_payload.message_form):null,i}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.messageId===e.messageId}},{key:"applyThreadInfoUpdateEvent",value:function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}},{key:"applyReactionEvent",value:function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1}},{key:"_triggerThreadInfoUpdatedEvent",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=es.of(this._iid),(r=n.dispatcher).dispatch(new Gs({channelType:e.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),r.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"markThreadAsRead",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new ks({channelUrl:this.channelUrl,messageId:this.messageId}),e.next=4,n.send(r);case 4:if(!this.threadInfo||0===this.threadInfo.unreadReplyCount){e.next=8;break}return this.threadInfo.unreadReplyCount=0,e.next=8,this._triggerThreadInfoUpdatedEvent();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setPushNotificationEnabled",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new bs({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),t.next=4,r.send(a);case 4:this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"submitMessageForm",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=es.of(this._iid),a=r.requestQueue,i=null,s=null,o=this.messageForm,t||!o){n.next=13;break}if(o.isSubmittable){n.next=7;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});case 7:if(!o.isSubmitted){n.next=9;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});case 9:i=o.id,s=o.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[]),n.next=14;break;case 13:t&&(i=t.formId,s=Object.entries(t.answers).reduce((function(t,n){var r=f(n,2),a=r[0],i=r[1],s=Number(a);if(Number.isNaN(s))throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return t.push({form_item_id:s,value:i}),t}),[]));case 14:if(i&&s){n.next=16;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});case 16:return u=new Ks({messageId:this.messageId,formId:i,items:s}),n.next=19,a.send(u);case 19:case"end":return n.stop()}}),n,this)})))}},{key:"submitFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Cs({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(ws),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new xs({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t.id,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(Ss),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ts({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t}),n.next=4,a.send(s);case 4:this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}));case 7:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?is.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return us.payloadify(e)})),og_tag:e.ogMetaData?ls.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?ds.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(t=e.scheduledInfo)||void 0===t?void 0:t.scheduledMessageId,scheduled_at:null===(n=e.scheduledInfo)||void 0===n?void 0:n.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?fs.payloadify(e.myFeedback):fs._getPayloadByStatus(e.myFeedbackStatus)})))}},{key:"_getParentMessageInfoPayload",value:function(e){return pe(ve({type:_s(e.messageType),ts:e.createdAt,user:e.sender?ps.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Hs.payloadify(e)})):null}))}}])}(ms),Ys=function(t){function a(t,i){var s,o,u,c,l;if(r(this,a),(s=n(this,a,[t,i])).reqId="",s.replyToChannel=!1,s.errorCode=0,s.sender=i.user?new ps(s._iid,i.user):i.sender_id,s.reqId=null!==(u=null!==(o=i.req_id)&&void 0!==o?o:i.request_id)&&void 0!==u?u:"",s.replyToChannel=null!==(c=i.is_reply_to_channel)&&void 0!==c&&c,i.request_state&&R(e.SendingStatus,i.request_state)&&(s.sendingStatus=i.request_state),!s.sendingStatus)if(s.messageId>0)s.sendingStatus=e.SendingStatus.SUCCEEDED;else if(s.scheduledInfo)switch(i.scheduled_status&&(s._scheduledStatus=i.scheduled_status),i.scheduled_status){case Vs.SENT:case Vs.IN_QUEUE:s.sendingStatus=e.SendingStatus.SUCCEEDED;break;case Vs.PENDING:s.sendingStatus=e.SendingStatus.SCHEDULED;break;case Vs.FAILED:case Vs.REMOVED:s.sendingStatus=e.SendingStatus.FAILED;break;case Vs.CANCELED:s.sendingStatus=e.SendingStatus.CANCELED}else s.sendingStatus=e.SendingStatus.PENDING;return s.errorCode=null!==(l=i.error_code)&&void 0!==l?l:0,s._messageToken=i.mesg_token,s}return c(a,t),i(a,[{key:"isResendable",get:function(){return(this.sendingStatus===e.SendingStatus.FAILED||this.sendingStatus===e.SendingStatus.CANCELED)&&((t=this.errorCode)>0&&M.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 pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{user:ps.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}}])}(Ws),Zs={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Xs=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)},Js=function(t){function a(t,i){var s,o,u,c,l;if(r(this,a),(s=n(this,a,[t,i])).translations={},s.message=null!==(o=i.message)&&void 0!==o?o:"",s.messageType=e.MessageType.ADMIN,s.translations=null!==(u=i.translations)&&void 0!==u?u:{},i.parent_message_info){var d=i.parent_message_info;s.parentMessage=ho(t,pe(ve(Object.assign(Object.assign({},d),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:d.file,url:null===(c=d.file)||void 0===c?void 0:c.url,require_auth:null===(l=d.file)||void 0===l?void 0:l.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(Ws),$s=function(){return i((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&&D("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,vendor:e.vendor,detail:e.detail}))}}])}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Qs||(Qs={}));var eo,to="removed",no=function(e){switch(e){case"open":return Qs.OPEN;case"closed":return Qs.CLOSED;default:return null}},ro=function(e){return!e||!!e.text&&D("string",e.text)},ao=function(e){function t(e,a){var i,s,o,u,c,l,d,h;return r(this,t),(i=n(this,t,[e])).pollId=0,i.id=0,i.text=null,i.voteCount=0,i.createdBy=null,i.createdAt=0,i.updatedAt=0,i._lastVotedAt=0,i.pollId=null!==(s=a.poll_id)&&void 0!==s?s:0,i.id=null!==(o=a.id)&&void 0!==o?o:0,i.text=null!==(u=a.text)&&void 0!==u?u:null,i.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,i.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,i.createdAt=null!==(d=a.created_at)&&void 0!==d?d:0,i.updatedAt=null!==(h=a.updated_at)&&void 0!==h?h:0,i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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})))}}])}(Ya),io=function(e){function t(e,a){var i,s,o,u,c,l,d,h,f,p,v,_,m,g;return r(this,t),(i=n(this,t,[e])).id=0,i.title=null,i.createdAt=0,i.updatedAt=0,i.closeAt=-1,i.status=Qs.CLOSED,i.messageId=0,i.data=null,i.voterCount=-1,i.options=[],i.createdBy=null,i.allowUserSuggestion=!1,i.allowMultipleVotes=!1,i.votedPollOptionIds=[],i.id=null!==(s=a.id)&&void 0!==s?s:0,i.title=null!==(o=a.title)&&void 0!==o?o:null,i.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,i.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,i.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,i.status=null!==(d=no(a.status))&&void 0!==d?d:Qs.CLOSED,i.messageId=null!==(h=a.message_id)&&void 0!==h?h:0,i.data=null!==(f=a.data)&&void 0!==f?f:null,i.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,i.options=a.options?a.options.map((function(e){return new ao(i._iid,e)})):[],i.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,i.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,i.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,i.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],i}return c(t,e),i(t,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,i,s,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=no(e.status))&&void 0!==a?a:this.status,this.data=null!==(i=e.data)&&void 0!==i?i:this.data,this.voterCount=null!==(s=e.voter_count)&&void 0!==s?s:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new ao(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var i=t[r];a>=i._lastVotedAt&&(i.voteCount=e.vote_count,i._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0}},{key:"serialize",value:function(){return ni(this)}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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 ao.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}])}(Ya),so=function(){return i((function e(t){r(this,e),this.status=t.status,t.original_message_info&&(this.originalMessageInfo={createdAt:t.original_message_info.ts,messageId:t.original_message_info.id})}),null,[{key:"payloadify",value:function(e){return pe({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}])}(),oo=function(t){function a(t,i){var o,u,c,l,d,h;if(r(this,a),(o=n(this,a,[t,i])).message="",o.messageParams=null,o.translations={},o.translationTargetLanguages=[],o.messageSurvivalSeconds=-1,o.plugins=[],o._poll=null,o.message=i.message,o.messageType=e.MessageType.USER,o.translations=null!==(u=i.translations)&&void 0!==u?u:{},o.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(o.translations).length&&o.translationTargetLanguages.length>0){var f,p=s(o.translationTargetLanguages);try{for(p.s();!(f=p.n()).done;){var v=f.value;o.translations[v]=""}}catch(e){p.e(e)}finally{p.f()}}if(o.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,o.plugins=i.plugins?i.plugins.map((function(e){return new $s(e)})):[],o._poll=i.poll?new io(o._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;o.parentMessage=ho(t,pe(ve(Object.assign(Object.assign({},_),{created_at:_.ts,message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(o.messageReviewInfo=new so(i.review_info)),o}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return $s.payloadify(e)})),poll:e._poll?io.payloadify(e._poll):null,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null,review_info:e.messageReviewInfo?so.payloadify(e.messageReviewInfo):void 0})))}}])}(Ys),uo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p;if(r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.fileInfoList=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE,s.data=null!==(c=null!==(u=null===(o=i.file)||void 0===o?void 0:o.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",s.fileInfoList=null!==(d=null===(l=i.files)||void 0===l?void 0:l.map((function(e){return new Hs(t,e)})))&&void 0!==d?d:[],s.messageSurvivalSeconds=null!==(h=i.message_survival_seconds)&&void 0!==h?h:-1,i.parent_message_info){var v=i.parent_message_info;s.parentMessage=ho(t,pe(ve(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===(f=v.file)||void 0===f?void 0:f.url,require_auth:null===(p=v.file)||void 0===p?void 0:p.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n,r,i,s,o;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{file:{name:null!==(n=null===(t=e.fileInfoList[0])||void 0===t?void 0:t.fileName)&&void 0!==n?n:"",size:null!==(i=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.fileSize)&&void 0!==i?i:0,type:null!==(o=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Hs.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([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)}}])}(Ys);!function(e){e.SENT="SENT",e.READ="READ"}(eo||(eo={}));var co=function(t){function a(t,i){var s,o,u;if(r(this,a),(s=n(this,a,[t,i])).notificationData=null,s.notificationId=i.notification_message_id,s.messageType=e.MessageType.ADMIN,s.messageStatus=null!==(o=i.message_status)&&void 0!==o?o:eo.SENT,s.priority=null!==(u=i.priority)&&void 0!==u?u:se.NORMAL,s.notificationEventDeadline=i.notification_event_deadline,0===s.extendedMessage.sub_type)try{var c=JSON.parse(s.extendedMessage.sub_data),l=c.label,d=c.tags,h=void 0===d?[]:d,f=c.template_key,p=c.template_variables;s.notificationData={label:l,tags:h,templateKey:f,templateVariables:p}}catch(e){}return s}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.notificationId===e.notificationId}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}}])}(ms),lo=function(t){if(t.notificationId)return co.payloadify(t);switch(t.messageType){case e.MessageType.USER:return oo.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?uo.payloadify(t):fo.payloadify(t);case e.MessageType.ADMIN:return Js.payloadify(t);default:throw A.unknown}},ho=function(e,t){if(t.notification_message_id)return new co(e,t);switch(t.type){case"MESG":return new oo(e,t);case"FILE":return uo._isMultipleFilesMessagePayload(t)?new uo(e,t):new fo(e,t);case"ADMM":case"BRDM":return new Js(e,t);default:return null}},fo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var k=i.file;if(s.plainUrl=(null!==(u=null!==(o=null==k?void 0:k.url)&&void 0!==o?o:i.url)&&void 0!==u?u:"").split("?auth=")[0],s.name=null!==(l=null!==(c=null==k?void 0:k.name)&&void 0!==c?c:i.name)&&void 0!==l?l:"File",s.size=null!==(h=null!==(d=null==k?void 0:k.size)&&void 0!==d?d:i.size)&&void 0!==h?h:0,s.data=null!==(p=null!==(f=null==k?void 0:k.data)&&void 0!==f?f:i.custom)&&void 0!==p?p:"",s.type=k?null!==(v=k.type)&&void 0!==v?v:"":null!==(_=i.type)&&void 0!==_?_:"",s.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,s.thumbnails=i.thumbnails?i.thumbnails.map((function(e){var t;return new ns(s._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),s.requireAuth)})):[],s.messageSurvivalSeconds=null!==(g=i.message_survival_seconds)&&void 0!==g?g:-1,i.parent_message_info){var b=i.parent_message_info;s.parentMessage=ho(t,pe(ve(Object.assign(Object.assign({},b),{created_at:b.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:b.file,url:null===(y=b.file)||void 0===y?void 0:y.url,require_auth:null===(E=b.file)||void 0===E?void 0:E.require_auth}))))}return s}return c(a,t),i(a,[{key:"url",get:function(){var e=es.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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.plainUrl,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(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(Ys),po=function(e){function t(e,a){var i,s=a.file,o=a.fileUrl,u=a.fileName,c=a.fileSize,l=a.mimeType,d=a.thumbnailSizes,h=a._uploadedMetaData,f=a._thumbnails;return r(this,t),(i=n(this,t,[e]))._plainUrl=o,i.file=s,i.fileName=u,i.fileSize=c,i.mimeType=l,i.thumbnailSizes=d,i._uploadedMetaData=h,i._thumbnails=f,i}return c(t,e),i(t,[{key:"fileUrl",get:function(){var e,t=es.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e}},{key:"toJSON",value:function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}],[{key:"getPlainUrl",value:function(e){return e instanceof t?e._plainUrl:e.fileUrl}}])}(Ya),vo=function(t){function a(t){var i,s,o,u;r(this,a);var c=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?c=t.mentionedUserIds:t.mentionedUsers&&(c=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FILE",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,files:t.files?yo(t.files):null,url:t.url,name:null!==(i=t.fileName)&&void 0!==i?i:"",type:null!==(s=t.mimeType)&&void 0!==s?s:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:null===(u=t._thumbnails)||void 0===u?void 0:u.map((function(e){return ns.payloadify(e)})),require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:c,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.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 c(a,t),i(a)}(Qe),_o=function(t){function a(t){var i,s,o;r(this,a),i=n(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})))),i.method=_e.POST,i.path="".concat(Le(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),i.params=pe(ve({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?yo(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===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return ns.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return vs.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage})),i}return c(a,t),i(a)}(je),mo=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"FILE",i])).message=i.files&&i.files.length>=2?new uo(e,i):new fo(e,i);var d=es.of(e).sdkState;return s.isMentioned=Fe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),go=function(e){function t(e,a){var i,s,o,u,c;r(this,t),(i=n(this,t,[e,a])).message=a.files&&a.files.length>=2?new uo(e,a):new fo(e,a);var l=es.of(e).sdkState;return i.isMentioned=Fe(i.message.mentionType,null!==(u=null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:null===(o=i.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),i.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,i}return c(t,e),i(t)}(Ve);function yo(e){return e.map((function(e){var t,n;return pe(ve({url:po.getPlainUrl(e),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 ns.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var Eo;!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"}(Eo||(Eo={}));var ko=function(){return i((function e(t,n){var a=this,i=n.sdkState,s=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._iid=t,this._sdkState=i,this._requestQueue=o,this._cacheContext=c,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof La&&(a._connectionState=e.stateType)})),this._onlineDetector=u}),[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===Aa.CONNECTED||this._connectionState===Aa.CONNECTING||this._connectionState===Aa.RECONNECTING}},{key:"_sendFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=this._createSendFileMessageRequestParams(e,t),!this._shouldSendThroughWebSocket){n.next=10;break}return a=new vo(r),n.next=5,this._requestQueue.send(a);case 5:return i=n.sent,s=i.as(mo),o=s.message,n.abrupt("return",o);case 10:return u=new _o(Object.assign(Object.assign({},r),{userId:this._sdkState.userId})),n.next=13,this._requestQueue.send(u);case 13:return c=n.sent,l=c.as(go),h=l.message,n.abrupt("return",h);case 16:case"end":return n.stop()}}),n,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(t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(a=this._queueMap.get(t.url))){r.next=58;break}if(a.isResolving){r.next=57;break}a.isResolving=!0,i=[],o=!0,u=s(a.messageQueue),r.prev=7,u.s();case 9:if((c=u.n()).done){r.next=40;break}l=c.value,r.t0=l.state,r.next=r.t0===Eo.PENDING||r.t0===Eo.UPLOADING?14:r.t0===Eo.UPLOADED?17:r.t0===Eo.FAILED?35:38;break;case 14:return o=!1,i.push(l),r.abrupt("break",38);case 17:if(!o){r.next=33;break}return r.prev=18,l.state=Eo.SENDING,r.next=22,this._sendFileMessage(t,l);case 22:return h=r.sent,l.deferred.resolve(h),r.next=26,mi(100);case 26:r.next=31;break;case 28:r.prev=28,r.t1=r.catch(18),l.deferred.reject(r.t1);case 31:r.next=34;break;case 33:i.push(l);case 34:return r.abrupt("break",38);case 35:return f=null!==(n=l.error)&&void 0!==n?n:A.unknown,l.deferred.reject(f.code===e.SendbirdErrorCode.REQUEST_CANCELED?A.fileUploadCanceled:f),r.abrupt("break",38);case 38:r.next=9;break;case 40:r.next=45;break;case 42:r.prev=42,r.t2=r.catch(7),u.e(r.t2);case 45:return r.prev=45,u.f(),r.finish(45);case 48:if(p=a.isResolveRequestPending,a.messageQueue=i,a.isResolving=!1,a.isResolveRequestPending=!1,!p){r.next=55;break}return r.next=55,this._resolveMessageQueue(t);case 55:r.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return r.stop()}}),r,this,[[7,42,45,48],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(r=this._queueMap.get(e.url))){n.next=30;break}if(!(a=r.messageQueue.find((function(e){return e.state===Eo.PENDING})))){n.next=30;break}if(!a.multipleFileUploadInfo){n.next=19;break}if(i=a.multipleFileUploadInfo,s=i.uploadIndex,o=i.uploadCount,u=i.requestHandler,c=a.params,l=c.fileInfoList[s],!H(l.file)||(null===(t=l._uploadedMetaData)||void 0===t?void 0:t.isUploaded)){n.next=13;break}return n.next=11,this._tryUploadNextItemAndUpdateItemState(e,r,a);case 11:n.next=14;break;case 13:a.state=s=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=new rs({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),s.next=3,this._requestQueue.send(o);case 3:u=s.sent,c=u.as(as),l=c.url,h=c.fileSize,f=void 0===h?n.fileSize:h,p=c.thumbnails,v=void 0===p?[]:p,_=c.requireAuth,m=void 0!==_&&_,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i:n.file.size,n.fileUrl=l,n.fileSize=f,n.requireAuth=m,n._thumbnails=v;case 12:case"end":return s.stop()}}),s,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[o],c=new rs({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),s.next=5,this._requestQueue.send(c);case 5:l=s.sent,h=l.as(as),f=h.url,p=h.fileSize,v=void 0===p?u.fileSize:p,_=h.thumbnails,m=h.requireAuth,g=void 0!==m&&m,u.fileName=null!==(r=u.fileName)&&void 0!==r?r: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=f,u.fileSize=v,u._thumbnails=_,u._uploadedMetaData=Object.assign(Object.assign({},u._uploadedMetaData),{requireAuth:g,isUploaded:!0}),u instanceof po||(n.fileInfoList[o]=new po(this._iid,u));case 16:case"end":return s.stop()}}),s,this)})))}},{key:"request",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),o=new ot,u={requestId:t,params:n,state:Eo.PENDING,deferred:o},bo(n)&&(c=n,l=Object.assign({uploadIndex:0,uploadCount:c.fileInfoList.length},r),u.multipleFileUploadInfo=l),s.messageQueue.push(u),this._uploadNextPendingItem(e),a.abrupt("return",o.promise);case 8:case"end":return a.stop()}}),a,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}))]:v(n.messageQueue),i=s(a);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o)switch(o.state){case Eo.PENDING:if(o.state=Eo.FAILED,o.error=A.requestCanceled,o.multipleFileUploadInfo&&!o.multipleFileUploadInfo.isCopy){var u=o.multipleFileUploadInfo,c=u.uploadIndex,l=u.requestHandler,d=o.params.fileInfoList[c];null==l||l._triggerOnFileUploaded(o.requestId,c,d,A.fileUploadCanceled)}this._resolveMessageQueue(e);break;case Eo.UPLOADING:this._requestQueue.cancel(o.requestId),this._dispatcher.dispatch(new ut({requestId:o.requestId}))}}}catch(e){i.e(e)}finally{i.f()}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new ut({requestId:t})))}}])}();function bo(e){return"fileInfoList"in e}var Co,wo={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},xo=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&R(e.ReplyType,t.replyType)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)&&D("boolean",t.showSubchannelMessagesOnly)},So={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},To=function(t){return R(e.ReplyType,t.replyType)&&D("boolean",t.includeReactions)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)},Io=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:d,include_poll_details:!0},a}return c(t,e),i(t)}(je),No=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?ho(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(Ve),Ao=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,d=e.isInclusive,h=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,E=e.includeThreadInfo,k=e.includeParentMessageInfo,b=e.showSubchannelMessagesOnly,C=e.checkingHasNext,w=e.checkingContinuousMessages;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages"),a.params=pe(ve({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,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:E,include_parent_message_info:k,show_subchannel_message_only:b,include_poll_details:!0,checking_has_next:C,checking_continuous_messages:w})),a}return c(t,e),i(t)}(je),Mo=function(e){function t(e,a){var i;return r(this,t),i=n(this,t,[e,a]),void 0!==a.is_continuous_messages&&(i.isContinuousMessages=a.is_continuous_messages),void 0!==a.has_next&&(i.hasNext=a.has_next),i.messages=a.messages.map((function(t){return ho(e,t)})),i}return c(t,e),i(t)}(Ve),Oo=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,d=e.includeReactions,h=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:d,include_thread_info:h,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return c(t,e),i(t)}(je),Uo=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedMessages=a.updated.map((function(t){return ho(e,t)})),i.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(Ve),Do=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledMessageId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s)),a.params={},a}return c(t,e),i(t)}(je),Ro=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?ho(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(Ve);e.RestrictionType=void 0,(Co=e.RestrictionType||(e.RestrictionType={})).MUTED="muted",Co.BANNED="banned";var Lo=function(){return i((function t(n){var a,i,s,o;r(this,t),this.restrictionType=null,R(e.RestrictionType,n.restriction_type)&&(this.restrictionType=n.restriction_type),this.description=null!==(a=n.description)&&void 0!==a?a:null,this.endAt=null!==(s=null!==(i=n.end_at)&&void 0!==i?i:n.muted_end_at)&&void 0!==s?s:-1,this.remainingDuration=null!==(o=n.remaining_duration)&&void 0!==o?o:-1}),null,[{key:"payloadify",value:function(e){return pe(ve({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}])}(),Po=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).restrictionInfo=new Lo(a),i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),Lo.payloadify(e.restrictionInfo))))}}])}(si),Fo=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.isMuted=null!==(s=a.is_muted)&&void 0!==s&&s,i}return c(t,e),i(t)}(si),qo=function(){return i((function e(){r(this,e),this._onPending=ht,this._onFailed=ht,this._onSucceeded=ht}),[{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}}])}(),Ho={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},Go=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(si,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(vs,t.metaArrays,!0)&&D("number",t.parentMessageId,!0)&&D("boolean",t.isReplyToChannel)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ds,t.appleCriticalAlertOptions,!0)&&D("boolean",t.isPinnedMessage,!0)},jo=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Vo=Object.assign(Object.assign({},Ho),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function zo(t){var n,r,a;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(t.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var Bo,Ko=function(e){var t;return pe(ve({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),extendedMessagePayload:e.extendedMessagePayload}))},Qo=function(e){return Go(e)&&D("string",e.message)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)&&D("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Bo||(Bo={}));var Wo=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Yo=function(e){return e===Bo.BLOB||e===Bo.FILE},Zo=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Xo=Object.assign(Object.assign({},Ho),{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});function Jo(t){var n,r,a,i;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.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,_thumbnails:t.thumbnails}))}var $o,eu=function(e,t){var n;return e.messageParams?(!e.url&&H(t)&&(e.messageParams.file=t),e.messageParams):pe(ve({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}}))}))},tu=function(e){return Go(e)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},nu={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},ru=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(si,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(vs,t.metaArrays,!0)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ds,t.appleCriticalAlertOptions,!0)},au=Object.assign(Object.assign({},nu),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),iu=function(e){return ru(e)&&D("string",e.message,!0)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)},su=Object.assign({},nu),ou=function(e){return ru(e)},uu=function(){return i((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}),[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return D("number",this.limit)&&this.limit>0}}])}(),cu=function(t){function a(e,t,i,s){var o;return r(this,a),(o=n(this,a,[e,s])).channelUrl=t,o.channelType=i,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl)&&R(e.ChannelType,this.channelType)}}])}(uu),lu=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={token:o,limit:u},a}return c(t,e),i(t)}(je),du=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).operators=a.operators.map((function(t){return new si(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(Ve),hu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=es.of(this._iid),r=n.requestQueue,a=new lu(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(du),o=s.operators,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(cu),fu=function(t){function a(t,i,s,o){var u,c,l,d,h,f,p,v,_,m,g;return r(this,a),(u=n(this,a,[t,i,s,o])).reverse=!1,u.messageTypeFilter=e.MessageTypeFilter.ALL,u.customTypesFilter=null,u.senderUserIdsFilter=null,u.replyType=e.ReplyType.NONE,u.includeMetaArray=!1,u.includeReactions=!1,u.includeParentMessageInfo=!1,u.includeThreadInfo=!1,u.showSubchannelMessagesOnly=!1,u._edge=Number.MAX_SAFE_INTEGER,u.reverse=null!==(c=o.reverse)&&void 0!==c&&c,u.messageTypeFilter=null!==(l=o.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,u.customTypesFilter=null!==(d=o.customTypesFilter)&&void 0!==d?d:null,u.senderUserIdsFilter=null!==(h=o.senderUserIdsFilter)&&void 0!==h?h:null,u.replyType=null!==(f=o.replyType)&&void 0!==f?f:e.ReplyType.NONE,u.includeMetaArray=null!==(p=o.includeMetaArray)&&void 0!==p&&p,u.includeReactions=null!==(v=o.includeReactions)&&void 0!==v&&v,u.includeParentMessageInfo=null!==(_=o.includeParentMessageInfo)&&void 0!==_&&_,u.includeThreadInfo=null!==(m=o.includeThreadInfo)&&void 0!==m&&m,u.showSubchannelMessagesOnly=null!==(g=o.showSubchannelMessagesOnly)&&void 0!==g&&g,u}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.reverse)&&R(e.MessageTypeFilter,this.messageTypeFilter)&&R(e.ReplyType,this.replyType)&&P("string",this.customTypesFilter,!0)&&P("string",this.senderUserIdsFilter,!0)&&D("boolean",this.includeMetaArray)&&D("boolean",this.includeReactions)&&D("boolean",this.includeParentMessageInfo)&&D("boolean",this.includeThreadInfo)&&D("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,t=nh.of(this._iid),e.next=7,t.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,ve({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));case 7:return n=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(v(n.map((function(e){return e.createdAt}))))),this._hasNext=n.length>=this.limit,this._isLoading=!1,e.abrupt("return",n);case 12:return e.abrupt("return",[]);case 15:throw A.queryInProgress;case 16:e.next=19;break;case 18:throw A.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}])}(cu),pu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={limit:o,token:u},a}return c(t,e),i(t)}(je),vu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).mutedUsers=[];var s=a.next,o=a.muted_list;return i.token=s,o&&o.length>0&&(i.mutedUsers=o.map((function(t){return new Po(e,t)}))),i}return c(t,e),i(t)}(Ve),_u=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new pu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(vu),s=i.mutedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),mu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({limit:o,token:u}),a}return c(t,e),i(t)}(je),gu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).bannedUsers=[];var s=a.next,o=a.banned_list;return i.token=s,o&&o.length>0&&(i.bannedUsers=o.map((function(t){return new Po(e,t.user)}))),i}return c(t,e),i(t)}(Ve),yu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new mu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(gu),s=i.bannedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu);e.ReportCategory=void 0,($o=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",$o.HARASSING="harassing",$o.SUSPICIOUS="suspicious",$o.INAPPROPRIATE="inappropriate";var Eu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(je),ku=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(je),bu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute/").concat(o),a}return c(t,e),i(t)}(je),Cu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.startAt=0,i.endAt=0;var s=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return i.isMuted=s,i.startAt=o,i.endAt=u,i.remainingDuration=c,i.description=l,i}return c(t,e),i(t)}(Ve),wu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={keys:o,include_ts:!0},a}return c(t,e),i(t)}(je),xu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(Ve),Su=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0},a}return c(t,e),i(t)}(je),Tu=function(e){function t(e,a){var i,s,o;return r(this,t),(i=n(this,t,[e,a])).metaData=null!==(s=a.metadata)&&void 0!==s?s:{},i.ts=null!==(o=a.ts)&&void 0!==o?o:null,i}return c(t,e),i(t)}(Ve),Iu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata,u=e.upsert;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return c(t,e),i(t)}(je),Nu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(Ve),Au=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),Mu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(o),a.params={include_ts:!0},a}return c(t,e),i(t)}(je),Ou=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(Ve),Uu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={include_ts:!0},a}return c(t,e),i(t)}(je),Du=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(Ve),Ru=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={keys:o},a}return c(t,e),i(t)}(je),Lu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(Ve),Pu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o},a}return c(t,e),i(t)}(je),Fu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(Ve),qu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,d=void 0===l?"set":l;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o,upsert:c,mode:d},a}return c(t,e),i(t)}(je),Hu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(Ve),Gu=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),ju=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(o),a.params={},a}return c(t,e),i(t)}(je),Vu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={},a}return c(t,e),i(t)}(je),zu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return c(t,e),i(t)}(je),Bu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),s}return c(t,e),i(t)}(Ke),Ku=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(je),Qu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),s}return c(t,e),i(t)}(Ke),Wu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({user_id:o,seconds:u,description:c}),a}return c(t,e),i(t)}(je),Yu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),i.data.member_count&&(s.memberCount=i.data.member_count),i.data.joined_member_count&&(s.joinedMemberCount=i.data.joined_member_count),s}return c(t,e),i(t)}(Ke),Zu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(je),Xu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),s}return c(t,e),i(t)}(Ke),Ju=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.freezing;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/freeze"),a.params={freeze:o},a}return c(t,e),i(t)}(je),$u=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).freeze=i.data.freeze,s}return c(t,e),i(t)}(Ke),ec=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return c(t,e),i(t)}(je),tc=function(t){function a(t){var i;r(this,a);var s=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,d=t.description;return(i=n(this,a)).method=_e.POST,i.path="".concat(Se,"/users/").concat(l),i.params={channel_url:s,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:d},i}return c(a,t),i(a)}(je),nc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,d=e.description,h=e.messageToken;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/messages/").concat(l),a.params=pe({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),a}return c(t,e),i(t)}(je),rc=function(t){function a(t){r(this,a);var i=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MESG",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:i,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,extended_message_payload:t.extendedMessagePayload}))}])}return c(a,t),i(a)}(Qe),ac=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"MESG",i])).message=new oo(e,i);var d=es.of(e).sdkState;return s.isMentioned=Fe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),ic=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MEDI",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))}])}return c(a,t),i(a)}(Qe),sc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"MEDI",i])).message=new oo(e,i);var h=es.of(e).sdkState;return s.mentionCountChange=qe({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),oc=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FEDI",ackRequired:!0,payload:pe(ve({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:i,apple_critical_alert_options:t.appleCriticalAlertOptions}))}])}return c(a,t),i(a)}(Qe),uc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"FEDI",i])).message=new fo(e,i);var h=es.of(e).sdkState;return s.mentionCountChange=qe({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),cc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(je),lc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new os(a),i}return c(t,e),i(t)}(Ve),dc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(je),hc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new os(Object.assign({},a)),i}return c(t,e),i(t)}(Ve),fc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return c(t,e),i(t)}(je),pc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new oo(e,a),i}return c(t,e),i(t)}(Ve),vc=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.POST,i.path="".concat(Le(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(je),_c=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new oo(e,a),i}return c(t,e),i(t)}(Ve),mc=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl;return i.method=_e.POST,i.path="".concat(Le(c),"/").concat(encodeURIComponent(l),"/scheduled_messages"),i.params=ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return ns.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),i}return c(a,t),i(a)}(je),gc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new fo(e,a),i}return c(t,e),i(t)}(Ve),yc=function(e){return D("string",e.title,!0)&&ro(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0)},Ec=function(e){function t(e){var a,i=e.pollId,s=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a.params={title:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(je),kc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),bc=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(je),Cc=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/close"),a}return c(t,e),i(t)}(je),wc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),xc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.optionText;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:i,channel_type:s,text:u},a}return c(t,e),i(t)}(je),Sc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Tc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId,o=e.optionText;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a.params={text:o},a}return c(t,e),i(t)}(je),Ic=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Nc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),Ac=function(t){function a(t){var i=t.reqId,s=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n(this,a,[{code:"VOTE",ackRequired:!0,payload:pe({req_id:i,channel_type:s===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})}])}return c(a,t),i(a)}(Qe),Mc=i((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})),Oc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"VOTE",i])).event=new Mc(i),s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),Uc=function(e){function t(e){var a,i=e.title,s=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=Ne,a.params={title:i,options:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(je),Dc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Rc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(je),Lc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Pc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(je),Fc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pollOption=new ao(e,a),i}return c(t,e),i(t)}(Ve),qc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/polls/changelogs"),a.params=pe({change_ts:o,token:u}),a}return c(t,e),i(t)}(je),Hc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedPolls=a.updated.map((function(t){return function(e,t){return new io(e,t)}(e,t)})),i.deletedPollIds=a.deleted.map((function(e){return e})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(Ve),Gc={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},jc=function(e){return D("string",e.title)&&(t=e.optionTexts,P("string",t)&&t.every((function(e){return""!==e.trim()})))&&ro(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0);var t},Vc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},zc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)&&t.pollId>0&&D("number",t.pollOptionId)&&t.pollOptionId>0},Bc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},Kc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)},Qc={},Wc=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,u=n.logger;r(this,e),this._iid=t,this._sdkState=a,this._sessionManager=s,this._requestQueue=o,this._dispatcher=i,this._logger=u,Qc[t]=this}),[{key:"buildPollFromSerializedData",value:function(e){var t=ri(e);return new io(this._iid,io.payloadify(t))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(Kc(e)).throw(A.invalidParameters),n=new Rc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Lc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(jc(e)).throw(A.invalidParameters),n=new Uc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Dc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(zc(e)).throw(A.invalidParameters),n=new Pc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Fc),i=a.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogs",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.SYNC_POLL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new qc(ve({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null})),e.next=3,this._requestQueue.send(i);case 3:return s=e.sent,o=s.as(Hc),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,u.length>0&&this._dispatcher.dispatch(new Ps({polls:u,source:a})),e.abrupt("return",{updatedPolls:u,deletedPollIds:c,hasMore:l,token:h});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Qc[e]}}])}(),Yc="GroupChannel",Zc="Message",Xc="NotificationMessage",Jc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=Ne,a.params={channel_url:i,channel_type:s,token:o,limit:u},a}return c(t,e),i(t)}(je),$c=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).polls=(null!==(s=a.polls)&&void 0!==s?s:[]).map((function(t){return new io(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(Ve),el=function(e){function t(e,a){return r(this,t),n(this,t,[e,a.channelUrl,a.channelType,a])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new Jc(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as($c),s=i.polls,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),tl=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:i,channel_type:s,token:c,limit:l},a}return c(t,e),i(t)}(je),nl=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).voters=(null!==(s=a.voters)&&void 0!==s?s:[]).map((function(t){return new si(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(Ve),rl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a.channelUrl,a.channelType,a])).pollId=a.pollId,i.pollOptionId=a.pollOptionId,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("number",this.pollId)&&D("number",this.pollOptionId)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new tl(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(nl),s=i.voters,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu);var al,il=Object.assign(Object.assign({},Ho),{fileInfoList:[]}),sl=function(e){return(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},ol=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._onFileUploaded=ht,e}return c(t,e),i(t,[{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(t,"onPending",this,3)([e]),this}},{key:"onFailed",value:function(e){return p(t,"onFailed",this,3)([e]),this}},{key:"onSucceeded",value:function(e){return p(t,"onSucceeded",this,3)([e]),this}}])}(qo),ul=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e])).message=null,i.message=ho(e,a.message),i}return c(t,e),i(t)}(Ya),cl=function(e){function t(e){var a;r(this,t);var i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,d=e.includeParentMessageInfo,h=e.includeThreadInfo,f=e.includePollDetails;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/pinned_messages"),a.params=pe({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),a}return c(t,e),i(t)}(je),ll=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.pinned_messages,o=a.has_more,u=a.next;return i.pinnedMessages=s.map((function(t){return new ul(e,t)})),i.hasMore=o,i.token=u,i}return c(t,e),i(t)}(Ve),dl=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s])).includeMetaArray=s.includeMetaArray,o.includeReactions=s.includeReactions,o.includeParentMessageInfo=s.includeParentMessageInfo,o.includeThreadInfo=s.includeThreadInfo,o.includePollDetails=s.includePollDetails,o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeMetaArray,!0)&&D("boolean",this.includeReactions,!0)&&D("boolean",this.includeParentMessageInfo,!0)&&D("boolean",this.includeThreadInfo,!0)&&D("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new cl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(ll),s=i.pinnedMessages,o=i.hasMore,u=i.token,this._token=u,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(cu),hl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(je),fl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(je);!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(al||(al={}));var pl,vl=function(t){function a(t,i){var s,o,u,c,l,d,h,f;return r(this,a),(s=n(this,a,[t]))._name="",s._createdAt=0,s.pinnedMessageIds=[],s.channelType=e.ChannelType.BASE,s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s._messageCollectionLastAccessedAt=0,s._url=i.channel_url,s._name=null!==(o=i.name)&&void 0!==o?o:"",s._createdAt=1e3*i.created_at,s.coverUrl=null!==(u=i.cover_url)&&void 0!==u?u:"",s.customType=null!==(c=i.custom_type)&&void 0!==c?c:"",s.data=null!==(l=i.data)&&void 0!==l?l:"",s.isFrozen=null!==(d=i.freeze)&&void 0!==d&&d,s.isEphemeral=null!==(h=i.is_ephemeral)&&void 0!==h&&h,s.creator=i.created_by?new si(s._iid,i.created_by):null,i.metadata&&Object.keys(i.metadata).length>0&&i.ts?(s._cachedMetaData=new Map,Object.keys(i.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:i.metadata[e],isRemoved:!1,updatedAt:i.ts})}))):"string"==typeof i.metadata&&(s._cachedMetaData=new Map(Object.entries(JSON.parse(i.metadata)))),s.pinnedMessageIds=null!==(f=i.pinned_message_ids)&&void 0!==f?f:[],s}return c(a,t),i(a,[{key:"url",get:function(){return this._url}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"createdAt",get:function(){return this._createdAt}},{key:"toJSON",value:function(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}},{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"isFeedChannel",value:function(){return this.channelType===e.ChannelType.FEED}},{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:"_serializeCachedMetaData",value:function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=pe(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:"_updateCachedMetaData",value:function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(a,i){var s;a.updatedAt<=t&&(n._cachedMetaData.set(i,{value:null!==(s=e[i])&&void 0!==s?s:a.value,isRemoved:!e[i],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}}},{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 hu(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new _u(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yu(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new fu(this._iid,this.url,this.channelType,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new dl(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Eu({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"removeOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new ku({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyMutedInfo",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new bu({channelUrl:this.url,channelType:this.channelType,userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Cu),o=s.isMuted,u=s.startAt,c=s.endAt,l=s.remainingDuration,h=s.description,e.abrupt("return",{isMuted:o,startAt:u,endAt:c,remainingDuration:l,description:h});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new wu({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(xu),o=s.metadata,u=s.ts,this._upsertCachedMetaData(o,u),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new wu({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(xu),s=i.metadata,o=i.ts,this._updateCachedMetaData(s,o),e.abrupt("return",s);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Su({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Tu),o=s.metaData,this._upsertCachedMetaData(o,0),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=new Iu({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Nu),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Mu({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:i=t.sent,s=i.as(Ou),o=s.ts,this._removeFromCachedMetaData([e],o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Uu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Du),s=i.ts,this._removeFromCachedMetaData(v(this._cachedMetaData.keys()),s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Ru({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(Lu),o=s.metaCounter,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Ru({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Lu),s=i.metaCounter,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Pu({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Fu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaCounters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=new qu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Hu),u=o.metaCounter,n.abrupt("return",u);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new qu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Hu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new qu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Hu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new ju({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Vu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.muteUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"muteUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new zu({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unmuteUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Ku({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"banUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.banUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"banUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new Wu({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unbanUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unbanUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Zu({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"freeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Ju({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,n.send(r);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Ju({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,n.send(r);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},wo),t),ai(D("number",e)&&xo(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessagesByMessageId(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},wo),t),ai(D("number",e)&&xo(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessagesByTimestamp(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},So),t),ai(D("number",e)&&To(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},So),t),ai(D("string",e)&&To(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,i=es.of(this._iid).sessionManager;return pe(ve({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 vs.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:i.currentUser?ps.payloadify(i.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 si.payloadify(e)}))}))}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var i,o=s(t.translationTargetLanguages);try{for(o.s();!(i=o.n()).done;){a[i.value]=""}}catch(e){o.e(e)}finally{o.f()}}var u=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a,extended_message_payload:t.extendedMessagePayload})),c=new oo(this._iid,u);return c.messageParams=t,c}},{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,i,s,o,u,c,l,d=pe(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===(i=t.file)||void 0===i?void 0:i.name,size:null!==(s=t.fileSize)&&void 0!==s?s: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:null===(l=t._thumbnails)||void 0===l?void 0:l.map((function(e){return ns.payloadify(e)}))})),h=new fo(this._iid,d);return h.messageParams=t,h}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,file:t.fileInfoList.length>0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0})),i=new uo(this._iid,a);return i.messageParams=t,i}},{key:"_validateFailedFileMessageHasFile",value:function(e,t){var n;return Boolean(e.url)||H(t)||H(null===(n=e.messageParams)||void 0===n?void 0:n.file)}},{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.SendbirdErrorCode.REQUEST_CANCELED||n.code===e.SendbirdErrorCode.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({},Vo),e);return ai(Qo(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:al.SEND,a=arguments.length>2?arguments[2]:void 0,i=es.of(this._iid),s=i.dispatcher,o=i.requestQueue,u=null!=a?a:this._generateRequestId(),c=Date.now(),l=new qo;return mi(2).then((function(){var a=n._createPendingUserMessage(t,u,c);s.dispatch(new Os({messages:[a],source:r===al.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a));case 1:case"end":return e.stop()}}),e)})))}));var i=new rc(Object.assign(Object.assign({},t),{channelUrl:n.url,channelType:n.channelType,reqId:u}));o.send(i).then((function(t){var r=t.as(ac).message;s.dispatch(new Os({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().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)})))}))})).catch((function(r){if(N(r))throw r;mi(2).then((function(){var a=n._createPendingUserMessage(t,u,c),i=es.of(n._iid).cacheContext,o=i.localCacheEnabled&&i.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,o),s.dispatch(new Os({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),l}},{key:"_autoResendUserMessage",value:function(e){return ai(e instanceof oo&&!!e.messageParams).throw(A.invalidParameters),this._sendUserMessage(e.messageParams,al.SEND,e.reqId)}},{key:"resendUserMessage",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof oo&&!e.scheduledInfo).throw(A.invalidParameters),r=new ot,a=null!==(t=e.messageParams)&&void 0!==t?t:Ko(e),this._sendUserMessage(a,al.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"updateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},au),t),ai(D("number",e)&&iu(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new ic(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(sc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"copyUserMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ai(t instanceof a&&n instanceof oo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),ai(!n.poll).throw(A.notSupportedError),u=new ot,c=null!==(r=n.messageParams)&&void 0!==r?r:ve(Object.assign(Object.assign({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(s=n.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),t._sendUserMessage(c).onSucceeded((function(e){u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 6:case"end":return o.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof oo&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new fc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(pc),u=o.message,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_createScheduledUserMessage",value:function(e,t){var n=this,r=es.of(this._iid).requestQueue,a=Date.now(),i=this._generateRequestId();mi(2).then((function(){var r=n._createPendingScheduledUserMessage(e,i,a);hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))}));var s=new vc(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(_c).message;hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;mi(2).then((function(){var s=n._createPendingScheduledUserMessage(e,i,a);n._markMessageAsFailed(s,r),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},Xo),e);return ai(tu(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},il),e),r=es.of(this._iid);ai(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return Go(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return sl(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 ai(!a).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:al.SEND,a=arguments.length>2?arguments[2]:void 0,i=es.of(this._iid).dispatcher,s=nh.of(this._iid).fileMessageQueue,o=null!=a?a:this._generateRequestId(),u=Date.now(),c=new qo;return mi(2).then((function(){var a=n._createPendingFileMessage(t,o,u);i.dispatch(new Os({messages:[a],source:r===al.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a));case 1:case"end":return e.stop()}}),e)})))})),s.request(n,o,t).then((function(t){i.dispatch(new Os({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;mi(2).then((function(){var a=n._createPendingFileMessage(t,o,u),s=es.of(n._iid).cacheContext,l=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,l),i.dispatch(new Os({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:r.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_autoResendFileMessage",value:function(e){ai(e instanceof fo&&!!e.messageParams).throw(A.invalidParameters);var t=es.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,al.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(t,n,r){var a=this,i=es.of(this._iid).dispatcher,s=nh.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new ol;return mi(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);i.dispatch(new Os({messages:[r],source:n===al.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(r));case 1:case"end":return e.stop()}}),e)})))})),s.request(a,o,t,{requestHandler:c,isCopy:n===al.COPY}).then((function(t){i.dispatch(new Os({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(n){if(N(n))throw n;mi(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);a._markMessageAsFailed(r,n),i.dispatch(new Os({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(n,r));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_createScheduledFileMessage",value:function(e,t,n,r){var a=this,i=es.of(this._iid).requestQueue,s=new mc(Object.assign(Object.assign({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(s).then((function(e){var n=e.as(gc).message;hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(N(i))throw i;mi(2).then((function(){var s=a._createPendingScheduledFileMessage(e,n,r);a._markMessageAsFailed(s,i),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(i,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){ai(e.every((function(e){return tu(Object.assign(Object.assign({},Xo),e))}))).throw(A.invalidParameters);var t,n=new qo,r=s(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,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._validateFailedFileMessageHasFile(e,t),ai(e instanceof fo&&r&&!e.scheduledInfo).throw(A.invalidParameters),a=new ot,i=eu(e,t),this._sendFileMessage(i,al.RESEND,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),n.abrupt("return",a.promise);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"resendMessage",value:function(e,t){var n,r;if(ai(e instanceof Ys&&!e.scheduledInfo&&e.isResendable).throw(A.invalidParameters),e.isUserMessage()){var a=null!==(n=e.messageParams)&&void 0!==n?n:Ko(e);return this._sendUserMessage(a,al.RESEND,e.reqId)}if(e.isFileMessage()){var i=this._validateFailedFileMessageHasFile(e,t);ai(i).throw(A.invalidParameters);var s=null!==(r=e.messageParams)&&void 0!==r?r:eu(e,t);return this._sendFileMessage(s,al.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"updateFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},su),t),ai(D("number",e)&&ou(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new oc(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(uc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"uploadFile",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=ce(),(i=new rs({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a),t.next=7,r.send(i);case 7:return s=t.sent,o=s.as(as),u=o.url,c=o.thumbnails,t.abrupt("return",{requestId:a,url:u,thumbnails:c});case 10:case"end":return t.stop()}}),t,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=nh.of(this._iid),n.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"copyFileMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ai(t instanceof a&&n instanceof fo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),u=new ot,c=ve(Object.assign(Object.assign({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=n.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),t._sendFileMessage(c).onSucceeded((function(e){return u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 5:case"end":return o.stop()}}),o,this)})))}},{key:"copyMessage",value:function(t,n){ai(t instanceof a&&n instanceof Ys&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters);var r=n,i=t;if(r.isUserMessage()){ai(!r.poll).throw(A.notSupportedError);var s=zo(r);return i._sendUserMessage(s)}if(r.isFileMessage()){var o=Jo(r);return i._sendFileMessage(o)}if(n.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"deleteMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ai(e instanceof Ws).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return n=es.of(this._iid),r=n.requestQueue,a=new ct({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof Ys?e._messageToken:void 0}),t.next=6,r.send(a);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"addReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof Ws&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new cc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(lc),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof Ws&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new dc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(hc),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_updateUserMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=es.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new ic({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(sc),f=h.message,o.dispatch(new Os({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=es.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new oc({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(uc),f=h.message,o.dispatch(new Os({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new vs({key:e})})),!(e instanceof fo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"add",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"add",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new vs({key:e})})),!(e instanceof fo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"remove",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"remove",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&t.every((function(e){return e instanceof vs}))).throw(A.invalidParameters),!(e instanceof fo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"add",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"add",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&t.every((function(e){return e instanceof vs}))).throw(A.invalidParameters),!(e instanceof fo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"remove",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"remove",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"report",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(R(e.ReportCategory,t)&&D("string",n)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new ec({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:t,description:n}),r.next=5,s.send(o);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"reportUser",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ai(t instanceof si&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=es.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new tc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.userId,category:n,description:r}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"reportMessage",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ai(t instanceof Ys&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=es.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new nc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r,messageToken:t._messageToken}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"updatePoll",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("number",e)&&yc(t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new Ec(Object.assign({pollId:e},t)),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(kc),u=o.poll,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deletePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ai(n).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new bc({pollId:e}),t.next=6,a.send(i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"closePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ai(n).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new Cc({pollId:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(wc),u=o.poll,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"addPollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("string",t)&&""!==t.trim(),ai(r).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new xc({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(Sc),c=u.poll,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updatePollOption",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",e)&&D("number",t)&&D("string",n)&&""!==n.trim(),ai(a).throw(A.invalidParameters),i=es.of(this._iid),s=i.requestQueue,o=new Tc({pollId:e,pollOptionId:t,optionText:n}),r.next=6,s.send(o);case 6:return u=r.sent,c=u.as(Ic),l=c.poll,r.abrupt("return",l);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"deletePollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("number",t),ai(r).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new Nc({pollId:e,pollOptionId:t}),n.next=6,i.send(s);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"votePoll",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",t)&&P("number",n),ai(a).throw(A.invalidParameters),i=es.of(this._iid),s=i.requestQueue,o=i.dispatcher,u=new Ac({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:n}),r.next=6,s.send(u);case 6:return c=r.sent,l=c.as(Oc),h=l.event,o.dispatch(new qs({event:h,source:e.CollectionEventSource.EVENT_POLL_VOTED})),r.abrupt("return",h);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("number",e)).throw(A.invalidParameters),n=Wc.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e,!0)),n=Wc.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new el(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 rl(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}},{key:"pinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("number",e)&&e>0).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new hl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unpinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("number",e)&&e>0).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new fl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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?si.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}}])}(Ya),_l=i((function e(t){r(this,e),this.key=t.key,this.url=t.url})),ml=i((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 _l(e)})):[]})),gl=i((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new ml(e)})):[]})),yl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onConnected=ht,this.onReconnectStarted=ht,this.onReconnectSucceeded=ht,this.onReconnectFailed=ht,this.onDisconnected=ht}))),El=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onSessionExpired=ht,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=ht,this.onSessionRefreshed=ht,this.onSessionClosed=ht}))),kl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onFriendsDiscovered=ht,this.onTotalUnreadMessageCountChanged=ht,this.onTotalUnreadMessageCountUpdated=ht}))),bl=function(e){function t(e){var a,i=e.limit,s=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=ge,a.params=pe({limit:i,token:s,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return c(t,e),i(t)}(je),Cl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new si(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(Ve),wl=function(e){function t(e,a){var i,s,o,u;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.metaDataKeyFilter=null,i.metaDataValuesFilter=null,i.nicknameStartsWithFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i.metaDataKeyFilter=null!==(o=a.metaDataKeyFilter)&&void 0!==o?o:null,i.metaDataValuesFilter=null!==(u=a.metaDataValuesFilter)&&void 0!==u?u:null,i.nicknameStartsWithFilter=a.nicknameStartsWithFilter||null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)&&D("string",this.metaDataKeyFilter,!0)&&P("string",this.metaDataValuesFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new bl(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Cl),s=i.users,o=i.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),xl=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token,u=e.userIdsFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/block"),a.params=pe({limit:s,token:o,user_ids:u}),a}return c(t,e),i(t)}(je),Sl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new si(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(Ve),Tl=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new xl(ve(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token}))),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Sl),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),Il=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={limit:s,token:o},a}return c(t,e),i(t)}(je),Nl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).hasMore=a.has_more,i.users=a.users.map((function(t){return new si(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(Ve),Al=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Il(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Nl),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),Ml={},Ol=function(){return i((function e(t){var n=t.dbname,a=t.itemSizeLimit,i=void 0===a?1048576:a,s=t.cacheLimit,o=void 0===s?256:s,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,d=void 0===l?10:l,h=t.blockHashConstant,f=void 0===h?11:h,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),Ml[n]||(this.itemSizeLimit=i,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=d,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,Ml[n]=this),Ml[n]}),null,[{key:"get",value:function(e){return Ml[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"}(pl||(pl={}));var Ul,Dl=function(e){function t(e){var a,i=e.code,s=void 0===i?pl.UNKNOWN_ERROR:i,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,t),(a=n(this,t,[u])).code=s,Object.setPrototypeOf(a,t.prototype),a}return c(t,e),i(t,null,[{key:"storeNotDefined",get:function(){return new t({code:pl.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new t({code:pl.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new t({code:pl.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new t({code:pl.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new t({code:pl.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new t({code:pl.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new t({code:pl.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new t({code:pl.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new t({code:pl.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new t({code:pl.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new t({code:pl.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new t({code:pl.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new t({code:pl.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new t({code:pl.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new t({code:pl.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new t({code:pl.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new t({code:pl.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new t({code:pl.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new t({code:pl.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new t({code:pl.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new t({code:pl.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new t({code:pl.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new t({code:pl.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new t({code:pl.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new t({code:pl.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}])}(y(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ul||(Ul={}));var Rl,Ll=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===m(e)&&null!==e){if(t.has(e))throw Dl.circularReferenceFound;var n;if(t.set(e,!0),Array.isArray(e))n=e.map((function(e){return Ll(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]=Ll(e[r],t);return t.delete(e),n}return e},Pl=function(e,t){if(null==t)return 1;if(null==e)return-1;if(m(e)!==m(t))throw Dl.compareTypesNotMatch;var n=0;switch(m(e)){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Fl=function(e,t){for(var n=0,r=0;r>>0)%t},ql=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Hl=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!Hl(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Hl(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"===m(e[r])){var a=e[r];for(var i in a)switch(i){case"/eq":case"=":if(t[r]!==a[i])return!1;break;case"/neq":case"!=":if(t[r]===a[i])return!1;break;case"/gt":case">":var s=t[r],o=a[i];if(!(Pl(s,o)>0))return!1;break;case"/gte":case">=":var u=t[r],c=a[i];if(!(Pl(u,c)>=0))return!1;break;case"/lt":case"<":var l=t[r],d=a[i];if(!(Pl(l,d)<0))return!1;break;case"/lte":case"<=":var h=t[r],f=a[i];if(!(Pl(h,f)<=0))return!1;break;case"/in":var p=t[r];if(!a[i].includes(p))return!1;break;case"/nin":var v=t[r];if(a[i].includes(v))return!1;break;case"/contain":var _=t[r],g=a[i];if(!_.includes(g))return!1;break;case"/regex":var y=t[r];if(!a[i].test(y))return!1;break;case"/where":var E=t[r];if(!(0,a[i])(E))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)},Gl=function(){},jl=function(){return Promise.resolve()},Vl=function(e){return e},zl=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Rl||(Rl={}));var Bl,Kl,Ql,Wl=function(){return i((function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,i=t.initialNextValue,s=void 0===i?null:i,o=t.iterator,u=t.map,c=void 0===u?Vl:u,l=t.backward,d=void 0===l?jl:l,h=t.forward,f=void 0===h?jl:h,p=t.complete,v=void 0===p?Gl:p;r(this,e),this._prevValue=a,this._nextValue=s,this._error=null,this._map=c,this._backward=d,this._forward=f,this._iterator=o,this._complete=v}),[{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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,t=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,t=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}])}(),Yl=function(){return i((function e(t){var n=t.condition,a=void 0===n?{}:n,i=t.backward,s=void 0!==i&&i,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=s,this._blockManager=o,this._indexer=u}),[{key:"findOptimizedStartPosition",value: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 a in this._indexer.fields){var i=this._indexer.fields[a],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),this.condition[i])if("object"===m(this.condition[i])){var o=s>0?n:t;for(var u in this.condition[i])if(o.includes(u))for(var c=r;c>=0;c--)if(s*Pl(this._indexer.origin[c].columnValues[a],this.condition[i][u])<=0){r=c;break}}else for(var l=r;l>=0;l--)if(s*Pl(this._indexer.origin[l].columnValues[a],this.condition[i])<=0){r=l;break}}return Math.min(r+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var h=function(r){var a=e._indexer.fields[r],i=1;if("-"===a[0]&&(a=a.slice(1),i=-1),e.condition[a])if("object"===m(e.condition[a]))Object.keys(e.condition[a]).forEach((function(s){if((i>0?t:n).includes(s))for(var o=d;o=0){d=o;break}}));else for(var s=d;s=0){d=s;break}},f=0;f0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Math.max(e.offset||0,0),0!==(r="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){t.next=6;break}return t.abrupt("return",[]);case 6:if(!(r<0)){t.next=8;break}throw Dl.collectionQueryNotValid;case 8:return t.prev=8,a=[],t.next=12,this._mutex.lock();case 12:return t.next=14,this._iterator.each((function(e){return E(i,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===n?(a.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(td(e,t)).concat(n,".").concat(r)},rd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=i}),[{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(n=t.sent)){t.next=19;break}if(r=n.data,a=n.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(r);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(s=[],o=atob(r.split(",")[1]),u=0;u1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,new Promise((function(n){var r=nd(o.dbname,o.collectionName,t),a=new FileReader;a.onload=function(){n({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return r=n.sent,a=r.blobId,i=r.data,s=r.type,n.next=8,this.store.set({key:a,value:{data:i,type:s}});case 8:return n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=td(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return n=e.sent,e.next=6,Promise.all(n.filter((function(e){return e.startsWith(t)})).map((function(e){return E(r,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}])}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Bl||(Bl={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Kl||(Kl={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Ql||(Ql={}));var ad,id,sd=[Kl.PENDING,Kl.VOLATILE],od={},ud=function(){return i((function e(t){var n=t.dbname,a=t.limit,i=void 0===a?256:a;return r(this,e),od[n]||(this.dbname=n,this._items=[],this._limit=i,od[n]=this),od[n]}),[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ql.DEFAULT;return E(this,void 0,void 0,d().mark((function r(){var a,i;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=this.get(t)){r.next=8;break}return r.next=4,e.get(t);case 4:(i=r.sent)&&(a={key:t,value:i,state:n===Ql.PERSISTENT?Kl.PERSISTENT:Kl.VOLATILE},this.put(a)),r.next=9;break;case 8:n===Ql.PERSISTENT&&(a.state=Kl.PERSISTENT);case 9:return r.abrupt("return",a);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ql.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===Ql.PERSISTENT&&(r.state=Kl.PERSISTENT),t!==Ql.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)sd.includes(this._items[t].state)&&sd.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===Kl.VOLATILE})),r=n.length-this._limit;if(r>0){var a,i=[],o=s(this._items);try{for(o.s();!(a=o.n()).done;){var u=a.value;u.state===Kl.VOLATILE&&r>0?r--:i.push(u)}}catch(e){o.e(e)}finally{o.f()}this._items=i}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==Kl.VOLATILE}))}}],[{key:"get",value:function(e){return od[e]}}])}(),cd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=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(Jl(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Jl(e,t),"/trans.recordset")}(n,a),this._store=i}),[{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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(n=t.t0).push.apply(n,v(e)),t.abrupt("return",this._reduceRecordSet(n));case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],i=[],s=a.requests.length-1;s>=0;s--){var o=a.requests[s],u=o.data;n[u.key]||(i.unshift(o),n[u.key]=!0)}i.length>0&&(a.requests=i,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ud.get(this.dbname),a=t.generation,i=t.requests,s=null,n.prev=3,n.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:a})})));case 6:for(o=n.sent,u=0;u0)){e.next=20;break}for(n=[],r={},a=t.length-1;a>=0;a--)i=t[a],s=i.data,r[s.key]||(r[s.key]=!0,n.unshift(i));return o={generation:this.generation,requests:n},e.next=8,this._getReducedRecordset([o]);case 8:return u=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:u});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(c=ud.get(this.dbname),l=0;l1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=i,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||Fl)(e,r)}(e,i,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(ed(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=ud.get(this.dbname),r=this.metadata.blockLevel;case 2:if(!(r>0)){t.next=15;break}return a=this.createBlockId(e,r),t.next=6,n.find(this._store,a);case 6:if(!(i=t.sent)){t.next=12;break}if(s=ld.createFromCacheItem(i),!(null==s?void 0:s.getItemByKey(e))){t.next=12;break}return t.abrupt("return",s);case 12:r--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"getFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return n=t.sent,t.abrupt("return",n?n.getItemByKey(e):null);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"putToBlock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Ol.get(this.dbname),a=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/r.itemSizeLimit),s=ud.get(this.dbname),n.next=6,s.find(this._store,a);case 6:if(o=n.sent,!(null==(u=o?ld.createFromCacheItem(o):new ld({blockId:a,keyName:this.keyName,items:[],limit:i}))?void 0:u.add(t))){n.next=11;break}return this._transaction.requestWrite({key:u.blockId,value:u.serialize()}),n.abrupt("return",!0);case 11:return n.abrupt("return",!1);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"removeFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(n=t.sent)){t.next=7;break}if(!n.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:n.blockId,value:n.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"clearAllBlocks",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ed(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return n=e.sent,r=n.filter((function(e){return e.startsWith(t)})),e.next=7,this._store.removeMany(r);case 7:return e.next=9,this._transaction.clear();case 9:ud.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(t)}));case 11:case"end":return e.stop()}}),e,this)})))}}])}(),hd={},fd=function(){return i((function e(t){var n=this,a=t.dbname,i=t.collectionName,s=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(Jl(e,t),"/index.").concat(n)}(a,i,o.join(">"));return hd[l]||(this.dbname=a,this.collectionName=i,this.keyName=s,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Bl.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Bl.ERROR,this.indexerKey,(function(){return n.abort()}))),hd[l]}),[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=f(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=f(this.indexOf(n),2),a=r[0];if(r[1]){var i=this._table[a].keys.indexOf(t);if(i>-1)return this._table[a].keys.splice(i,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,n,r,a=[],i=s(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),n=e[o],r=void 0,r=m(n),null!==n&&"undefined"!==r&&"boolean"!==r&&"number"!==r&&"string"!==r)throw Dl.indexTypesNotMatch;a.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return a}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Pl(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,d().mark((function e(){var t,n,r,a,i,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ud.get(this.dbname),e.next=3,t.find(this._store,this.indexerKey,Ql.PERSISTENT);case 3:if(n=e.sent){e.next=33;break}return r=ed(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:a=e.sent,i=s(a),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=22;break}if(!(u=o.value).startsWith(r)){e.next=20;break}return e.next=17,t.find(this._store,u,Ql.NO_CACHE);case 17:if(c=e.sent,l=ld.createFromCacheItem(c)){h=s(l.items);try{for(h.s();!(f=h.n()).done;)p=f.value,this._addItem(p)}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=n.value,this._table=Ll(this._origin);case 35:hd[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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ud.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete hd[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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=Ll(this._origin)}},{key:"abort",value:function(){this._table=Ll(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 hd)delete hd[e]}}])}(),pd=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},vd=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"}(ad||(ad={})),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"}(id||(id={}));var _d,md={},gd=function(){return i((function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=ad.PROCESSING,this._queue=[],this._activationQueue=[],md[t]&&!a.forceCreate||(this.nodeId=vd(),this.key=t,pd()&&(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;if(null==t?void 0:t.isNestDbMessage){var r=t.nodeId,a=t.requestId,i=t.key,o=t.op,u=t.data;if(r!==n.nodeId&&i===n.key)switch(o){case id.NEWNODE:n._sendSync();break;case id.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case id.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var c,l=u.currentItemRequestId,d=s(u.queue);try{var h=function(){var e=c.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:id.REQUEST_LOCK,ts:e.ts})};for(d.s();!(c=d.n()).done;)h()}catch(e){d.e(e)}finally{d.f()}n._currentItem=n._queue.find((function(e){return e.requestId===l})),n._completeSync()}break;case id.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 id.REQUEST_LOCK:n._requestLock(t);break;case id.ACQUIRE_LOCK:var f=n._queue.find((function(e){return e.requestId===a}));n._acquire(f);break;case id.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(id.REMOVENODE)}))),md[t]=this),md[t]}),[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==ad.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:vd(),key:this.key,op:e,data:n.data,ts:Date.now()};return pd()&&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(id.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(id.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var i in t._queue)if(t._queue[i].ts>r.ts){t._queue.splice(parseInt(i),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(id.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,d().mark((function e(){var t=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){t._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=ad.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(id.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(id.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return t=this._send(id.REQUEST_LOCK),e.next=5,this._requestLock(t);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)}}])}(),yd=function(){function e(t){var n=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=Ul.INIT,this._indexers=[],this.dbname=a,this.name=i,this.keyName=s,this.indexes=[[s]].concat(v(u.filter((function(e){return fd.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new gd(function(e,t){return"".concat(Jl(e,t),".lock")}(a,i)),this._blobContainer=new rd({dbname:a,collectionName:i,store:c}),this._transaction=new cd({dbname:a,collectionName:i,store:c})}return i(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===Ul.READY}},{key:"init",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l,h,f,p,_=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,n=Ol.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return r=t.sent,this._metadata=r||{keyName:this.keyName,blockLevel:1,blockHashBase:n.blockHashBase,blockHashMultiplier:n.blockHashMultiplier,blockHashConstant:n.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new dd({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),a=v(this.indexes),i=[],o=a.map((function(e){return fd.createKey(e)})),u=r?r.indexes.map((function(e){return fd.createKey(e)})):[],c=s(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(fd.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(f=[]).push.apply(f,v(a.map((function(e){var t=new fd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()})))),f.push.apply(f,v(i.map((function(e){return new fd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()})))),t.next=22,Promise.all(f);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return p=$l(this.dbname,this.name),this._metadata.indexes=a,t.next=29,this._store.set({key:p,value:this._metadata});case 29:this._state=Ul.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),t,this,[[2,33]])})))}},{key:"close",value:function(){this._state=Ul.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=fd.createKey(e),r=s(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===fd.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Dl.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=$l(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:t,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:r=s(this._indexers),t.prev=14,r.s();case 16:if((a=r.n()).done){t.next=22;break}return i=a.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),r.e(t.t0);case 27:return t.prev=27,r.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Dl.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),t,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(r=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:a=s(this._indexers),t.prev=14,a.s();case 16:if((i=a.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),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(n,e);case 34:u=s(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(r),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(r);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()}}),t,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(!(r=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:a=s(this._indexers),t.prev=8,a.s();case 10:if((i=a.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(r),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(r);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),a.e(t.t0);case 24:return t.prev=24,a.f(),t.finish(24);case 27:case"end":return t.stop()}}),t,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(n=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:r=s(this._indexers),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return i=a.value,t.next=13,i.removeItem(n);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:case"end":return t.stop()}}),t,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:t=s(this._indexers),e.prev=3,t.s();case 5:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=9,r.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return n=t.sent,this._mutex.unlock(),t.abrupt("return",Ll(n));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Dl.collectionNotReady;case 18:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new Zl({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Dl.collectionNotReady}},{key:"insertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Dl.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Ll(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 Dl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Dl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestInsert(Ll(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Dl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Dl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Ll(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 Dl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Dl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestUpsert(Ll(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Dl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Dl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Ll(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 Dl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"updateIf",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.isReady){n.next=31;break}return n.next=3,this._mutex.lock();case 3:return n.prev=3,r=e.where,a=void 0===r?{}:r,i=e.index,s=void 0===i?null:i,o=e.backward,u=void 0!==o&&o,c=[],l=new Yl({condition:a,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(s)}),n.next=9,l.each((function(e){return E(v,void 0,void 0,d().mark((function n(){var r,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.error){n.next=4;break}if(e.hasNext){if(r=e.nextValue,Hl(a,r)&&t.set){if("function"!=typeof t.set)for(i in t.set)r[i]=t.set[i];else t.set(r);c.push(r)}e.next()}else e.stop();n.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return n.stop()}}),n)})))}));case 9:h=0,f=c;case 10:if(!(h1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return v(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)),i=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(i).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:i}),r}))}},{key:"_resetIfEncryptionChanged",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(this._encryptionCheckKey);case 2:if(t=e.sent,n={encrypted:Cd.map((function(e){var t;return null===(t=s.encryption)||void 0===t?void 0:t.encrypt(e)}))},!t){e.next=22;break}if(!t.encrypted||!Array.isArray(t.encrypted)){e.next=20;break}e.t0=d().keys(t.encrypted);case 7:if((e.t1=e.t0()).done){e.next=18;break}if(r=e.t1.value,a=JSON.stringify(t.encrypted[r]),i=JSON.stringify(n.encrypted[r]),a===i){e.next=16;break}return bd.warning("Encryption algorithm has changed. Stored data would be cleared."),e.next=15,this.clear();case 15:return e.abrupt("break",18);case 16:e.next=7;break;case 18:e.next=22;break;case 20:return e.next=22,this.clear();case 22:return e.next=24,this.set({key:this._encryptionCheckKey,value:n});case 24:case"end":return e.stop()}}),e,this)})))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=0,e.next=3,this._getAllRawKeys();case 3:n=e.sent,r=s(n),e.prev=5,r.s();case 7:if((a=r.n()).done){e.next=15;break}return i=a.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(t+=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),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})).filter((function(e){return!n._reservedKeys.includes(e)})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=21;break}if(t.prev=5,a=r.data,!((null==(i=r.metadata)?void 0:i.shards)&&i.shards>1)){t.next=13;break}return t.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return E(o,void 0,void 0,d().mark((function n(){var r,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>0)){n.next=10;break}return r=this._getRawKey(e,".".concat(t)),n.next=4,this._getRaw(r);case 4:if(i=n.sent){n.next=7;break}throw Dl.storeBrokenIntegrity;case 7:return n.abrupt("return",i.data);case 10:return n.abrupt("return",a);case 11:case"end":return n.stop()}}),n,this)})))})));case 10:t.t0=t.sent,t.next=14;break;case 13:t.t0=[a];case 14:return s=t.t0,t.abrupt("return",this.encryption.decrypt(JSON.parse(s.join(""))));case 18:return t.prev=18,t.t1=t.catch(5),t.abrupt("return",null);case 21:return t.abrupt("return",null);case 22:case"end":return t.stop()}}),t,this,[[5,18]])})))}},{key:"set",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._shardify(e),t.next=3,this._setRaw(n);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[],t.next=3,this._setRaw(n.concat.apply(n,v(e.map((function(e){return r._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=9;break}return a=r.metadata,t.next=8,this._removeRaw(this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return i._getRawKey(e,".".concat(t))})));case 8:return t.abrupt("return",!0);case 9:return t.abrupt("return",!1);case 10:case"end":return t.stop()}}),t,this)})))}},{key:"removeMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=[],r=s(e),t.prev=2,i=d().mark((function e(){var t,r,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.value,r=o._getRawKey(t,".0"),e.next=4,o._getRaw(r);case 4:(i=e.sent)&&(s=i.metadata,n.push.apply(n,v(o._generateShardPostfixArray(null==s?void 0:s.shards).map((function(e){return o._getRawKey(t,".".concat(e))})))));case 6:case"end":return e.stop()}}),e)})),r.s();case 5:if((a=r.n()).done){t.next=9;break}return t.delegateYield(i(),"t0",7);case 7:t.next=5;break;case 9:t.next=14;break;case 11:t.prev=11,t.t1=t.catch(2),r.e(t.t1);case 14:return t.prev=14,r.f(),t.finish(14);case 17:if(!(n.length>0)){t.next=20;break}return t.next=20,this._removeRaw(n);case 20:return t.abrupt("return",e);case 21:case"end":return t.stop()}}),t,this,[[2,11,14,17]])})))}}])}(),xd={},Sd=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:4194304})]);var s=i.delay,o=void 0===s?1:s;return e.delay=o,e.observer={},e}return c(t,e),i(t,[{key:"rawData",get:function(){return xd[this.dbname]},set:function(e){xd[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!xd[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(xd[this.dbname]));case 4:throw Dl.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!xd[this.dbname]){t.next=6;break}return t.next=3,ql(this.delay);case 3:return t.abrupt("return",xd[this.dbname][e]?Object.assign({key:e},xd[this.dbname][e]):null);case 6:throw Dl.storeNotAvailable;case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!xd[this.dbname]){t.next=7;break}return t.next=3,ql(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,i=a.key,o=a.data,u=a.metadata,xd[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Dl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!xd[this.dbname]){t.next=7;break}return t.next=3,ql(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,xd[this.dbname][a]&&delete xd[this.dbname][a]}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Dl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,xd[this.dbname]||(xd[this.dbname]={}),t.next=4,this._resetIfEncryptionChanged();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(t,"set",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=this.observer[e.key])||"function"!=typeof n.set){t.next=5;break}if(!(a=n.set())){t.next=5;break}throw a;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(t,"setMany",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((a=n.n()).done){t.next=12;break}if(i=a.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),n.e(t.t0);case 17:return t.prev=17,n.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),t,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ql(this.delay);case 2:xd[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}])}(wd),Td="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(_d||(_d={}));var Id,Nd=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:104857600})]))._storeName=Td,e._state=_d.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 c(t,e),i(t,[{key:"state",get:function(){return this._state}},{key:"isTransactionInactiveError",value:function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}},{key:"_putToObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.put(t);a.addEventListener("success",(function(e){n(e.target.result)})),a.addEventListener("error",(function(){r("Failed to write.")}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_deleteFromObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.delete(t);a.addEventListener("success",(function(){return n(t)})),a.addEventListener("error",(function(e){return r(e.target.error)}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=_d.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Td,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=_d.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=_d.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=_d.UNINITIALIZED,r(e.target.error)}))}else r(Dl.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().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===_d.UNINITIALIZED||t.t0===_d.OPEN?7:t.t0===_d.OPENING||t.t0===_d.CLOSED?8:9;break;case 7:throw Dl.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){n._openJobQueue.push((function(){return t(n._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()}}),t,this)})))}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readonly");case 2:return t=e.sent,e.next=5,new Promise((function(e,n){var r=t.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return n(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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readonly");case 2:return n=t.sent,t.next=5,new Promise((function(t,r){var a=n.get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return r(e.target.error)}))}));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._putToObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._putToObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._deleteFromObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._deleteFromObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{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,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(t="undefined"!=typeof window?window:null)?void 0:t.indexedDB)||(null==t?void 0:t.mozIndexedDB)||(null==t?void 0:t.webkitIndexedDB)||(null==t?void 0:t.msIndexedDB))){e.next=16;break}if(this._indexedDb=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB,!this._window||!pd()){e.next=13;break}if(!(pd()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!t.PointerEvent&&!t.MSPointerEvent){e.next=7;break}throw Dl.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(n._indexedDb)try{var r=n._indexedDb.open("_testMozilla");r.onerror=function(){return t(Dl.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),n._indexedDb){var a=n._indexedDb.deleteDatabase("_testMozilla");a.onerror=function(){return e()},a.onsuccess=function(){return e()}}else t(Dl.storeNotAvailable)}}catch(e){t(Dl.storeNotAvailableInPrivateBrowsing)}else t(Dl.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Dl.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,d().mark((function t(){return d().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:return t.next=7,this._resetIfEncryptionChanged();case 7:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readwrite");case 2:return t=e.sent,e.next=5,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}}])}(wd),Ad=function(e){function t(e){var a;r(this,t);var i=e.AsyncStorage,s=e.itemSizeLimit,o=void 0===s?2097152:s,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof Ys))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}if(t instanceof Ws)switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof Ys&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}])}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Rd||(Rd={}));var Fd,qd=function(e){switch(e){case Rd.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Rd.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Hd=Object.assign(Object.assign({},Vo),{scheduledAt:void 0}),Gd=Object.assign(Object.assign({},Ho),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),jd="UnsentMessage",Vd={},zd=function(e){function t(e){var a;return r(this,t),(a=n(this,t,[e]))._mutex=new gd("unsendmessagecache.lock"),Vd[e]=a,a}return c(t,e),i(t,[{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(jd);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 oo?(e.messageParams&&(n.messageParams=jo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},jo(t)),{scheduledAt:t.scheduledAt})))):e instanceof fo?(e.messageParams&&(n.messageParams=Zo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},Zo(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof uo&&e.messageParams&&(n.messageParams=function(e){return pe({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)}),nh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(i=nh.of(this._iid),s=this._deserialize(e),!e.messageParams){a.next=32;break}if(!(s instanceof oo)){a.next=8;break}o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),a.next=32;break;case 8:if(!(s instanceof fo)){a.next=26;break}if(!(u=e.messageParams).fileKey||"string"!=typeof u.fileKey||!Yo(null!==(t=u.fileType)&&void 0!==t?t:"")){a.next=23;break}return a.next=13,this.collection.getBlob(u.fileKey);case 13:if(a.t1=n=a.sent,a.t0=null!==a.t1,!a.t0){a.next=17;break}a.t0=void 0!==n;case 17:if(!a.t0){a.next=21;break}a.t2=n,a.next=22;break;case 21:a.t2=void 0;case 22:u.file=a.t2;case 23:s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(u,s),a.next=32;break;case 26:if(!(s instanceof uo)){a.next=32;break}if(!(c=e.messageParams)||!c.fileInfoList){a.next=32;break}return s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(c,s),a.next=32,Promise.all(s.messageParams.fileInfoList.map((function(e){return E(f,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)||!Yo(null!==(a=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==a?a:"")){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()}}),t,this)})))})));case 32:if(!(s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){a.next=54;break}if(!(s instanceof oo)){a.next=38;break}l=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(l,s),a.next=54;break;case 38:if(!(s instanceof fo)){a.next=54;break}if(!(h=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof h.fileKey||"string"!=typeof h.fileType||!Yo(h.fileType)){a.next=53;break}return a.next=43,this.collection.getBlob(h.fileKey);case 43:if(a.t4=r=a.sent,a.t3=null!==a.t4,!a.t3){a.next=47;break}a.t3=void 0!==r;case 47:if(!a.t3){a.next=51;break}a.t5=r,a.next=52;break;case 51:a.t5=void 0;case 52:h.file=a.t5;case 53:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(h,s);case 54:return a.abrupt("return",s);case 55:case"end":return a.stop()}}),a,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new Pd:n,a=e.order,i=void 0===a?Rd.CHANNEL_LATEST:a,s=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return E(this,void 0,void 0,d().mark((function e(){var n,a,o,l,h,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=qd(i),a={"/where":function(e){return!!(i!==Rd.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(f._deserialize(e))}},t&&(a.channelUrl=t),s&&(a.sendingStatus=s),o={where:a,index:n,backward:u},e.next=8,this.collection.query(o);case 8:return l=e.sent,e.next=11,l.fetch({});case 11:return h=e.sent,e.abrupt("return",Promise.all(h.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Pd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({filter:t,order:Rd.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof fo||e instanceof uo)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return n=this._serialize(e),t.next=10,this.collection.upsertOne(n);case 10:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:n=t.sent;case 5:if(!(n.length>0)){t.next=9;break}return n.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(n);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof fo)){t.next=19;break}if(!e.messageParams){t.next=9;break}if(!(n=e.messageParams).file||!Wo(n.file)){t.next=9;break}return t.next=6,this.collection.saveBlob(n.file,e.reqId);case 6:r=t.sent,n.fileKey=r,n.fileType=Bo.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){t.next=17;break}if(!(a=e.scheduledInfo.scheduledMessageParams).file||!Wo(a.file)){t.next=17;break}return t.next=14,this.collection.saveBlob(a.file,e.reqId);case 14:i=t.sent,a.fileKey=i,a.fileType=Bo.BLOB;case 17:t.next=24;break;case 19:if(!(e instanceof uo)){t.next=24;break}if(!((s=e.messageParams)&&s.fileInfoList&&Array.isArray(s.fileInfoList))){t.next=24;break}return t.next=24,Promise.all(s.fileInfoList.map((function(t,n){return E(o,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!t.file||!Wo(t.file)){r.next=7;break}return r.next=3,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n));case 3:a=r.sent,t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=a,t._uploadedMetaData.fileType=Bo.BLOB;case 7:case"end":return r.stop()}}),r,this)})))})));case 24:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Vd[e]&&!n||(Vd[e]=new t(e)),Vd[e]}}])}(Ya),Bd={},Kd=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Bd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return es.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"_unsentMessageCache",get:function(){return zd.of(this._iid)}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ai(!!e).throw(A.databaseError),e.collection(Zc)}},{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)}),nh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new Pd:i,o=e.order,u=void 0===o?Rd.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,h=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,d().mark((function e(){var r,i,o,c,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r=qd(u),i={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Rd.CHANNEL_LATEST:if(_&&e.createdAt!==n)return!1;if(l){if(g&&e.createdAtn||!g&&e.createdAt>=n)return!1;break;case Rd.NEWEST_CHILD_MESSAGE:if(!h||0===e.parentMessageId||e.parentMessageId!==h)return!1}return!(p&&!e._poll)&&s.match(f._deserialize(e))}},index:r,backward:l},e.next=5,this.collection.query(i);case 5:return o=e.sent,e.next=8,o.fetch({limit:null!=a?a:void 0});case 8:return c=e.sent,e.abrupt("return",Promise.all(c.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}))));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Pd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:Rd.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=30;break}return n.next=3,this.saveBlobs(e);case 3:r=s(e),n.prev=4,r.s();case 6:if((a=r.n()).done){n.next=15;break}if(i=a.value,!(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)){n.next=13;break}return n.next=11,this.get(i.messageId);case 11:(null==(o=n.sent)?void 0:o.threadInfo)&&i.threadInfo._updateFrom(o.threadInfo);case 13:n.next=6;break;case 15:n.next=20;break;case 17:n.prev=17,n.t0=n.catch(4),r.e(n.t0);case 20:return n.prev=20,r.f(),n.finish(20);case 23:return u=e.map((function(e){return c._serialize(e)})),n.next=26,this.collection.upsertMany(u);case 26:return n.next=28,this.upsertChildMessages(e);case 28:return n.next=30,this._unsentMessageCache.upsertChildMessages(e);case 30:case"end":return n.stop()}}),n,this,[[4,17,20,23]])})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!((null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)&&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()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove("".concat(a));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:qd(Rd.CHANNEL_LATEST)});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:qd(Rd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=qd(Rd.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof fo&&e.messageParams)){t.next=7;break}if(!(n=e.messageParams).file||!Wo(n.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(n.file,e.reqId);case 5:r=t.sent,n.fileKey=r;case 7:case"end":return t.stop()}}),t,this)})))})));case 2:case"end":return t.stop()}}),t)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=0,r=this._cacheContext.preference,t.next=4,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return a=t.sent,t.next=7,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return s=t.sent,t.next=13,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return o=t.sent,a&&(n+=JSON.stringify(a).length),i&&(n+=JSON.stringify(i).length),s&&(n+=JSON.stringify(s).length),o&&(n+=JSON.stringify(o).length),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Bd[e]&&!n||(Bd[e]=new t(e)),Bd[e]}}])}(Ya),Qd={},Wd=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Qd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return es.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ai(!!e).throw(A.databaseError),e.collection(Xc)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign({},e.serialize())}},{key:"_deserialize",value:function(e){return nh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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(e);case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new Pd:i,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,h=e.inclusive,f=void 0===h||h;return E(this,void 0,void 0,d().mark((function e(){var r,i,o,c=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(f&&e.createdAtn||!f&&e.createdAt>=n)return!1}return s.match(c._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},e.next=5,this.collection.query(r);case 5:return i=e.sent,e.next=8,i.fetch({limit:null!=a?a:void 0});case 8:return o=e.sent,e.abrupt("return",o.map((function(e){return c._deserialize(e)})));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=4;break}return n=e.map((function(e){return r._serialize(e)})),t.next=4,this.collection.upsertMany(n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"markAsReadByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,messageStatus:eo.SENT,createdAt:{"<":t}}},{set:{messageStatus:eo.READ}});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"markAsReadByMessageIds",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=5;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:eo.SENT}},{set:{messageStatus:eo.READ}});case 3:return r=n.sent,n.abrupt("return",r.length);case 5:return n.abrupt("return",0);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:["channelUrl","-createdAt","-notificationId"]});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:qd(Rd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=["channelUrl","-createdAt","-notificationId"],i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Qd[e]&&!n||(Qd[e]=new t(e)),Qd[e]}}])}(Ya),Yd={},Zd=function(t){function a(t){var i;return r(this,a),(i=n(this,a,[t]))._observers=new Map,i._dispatcherContext=i._dispatcher.on((function(t){return E(i,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,N,A,M,O=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof Os)){n.next=19;break}if(r=t.messages,a=t.source,i=t.isWebSocketEventComing,s=r.filter((function(t){return t instanceof Ws&&t.channelType!==e.ChannelType.OPEN&&t.messageId>0})),o=r.filter((function(t){return t instanceof Ws&&t.channelType!==e.ChannelType.OPEN&&0===t.messageId})),u=r.filter((function(e){return e instanceof co})),!(s.length>0)){n.next=9;break}return n.next=8,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(s);case 2:return e.next=4,this._unsentMessageCache.remove(s.map((function(e){return e instanceof Ys?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e,this)})))}));case 8:i||this._broadcastUpdateEvent(s,a);case 9:if(!(o.length>0)){n.next=13;break}return n.next=12,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.upsert(o);case 2:case"end":return e.stop()}}),e,this)})))}));case 12:i||this._broadcastUpdateEvent(o,a);case 13:if(!(u.length>0)){n.next=17;break}return n.next=16,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._notificationCache.upsert(u);case 2:case"end":return e.stop()}}),e,this)})))}));case 16:i||this._broadcastUpdateEvent(u,a);case 17:n.next=71;break;case 19:if(!(t instanceof Us)){n.next=28;break}return c=t.messageIds,l=t.source,h=t.isWebSocketEventComing,f=c.filter((function(e){return"number"==typeof e})),p=c.filter((function(e){return"string"==typeof e})),n.next=25,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(f.length>0)){e.next=3;break}return e.next=3,this._messageCache.remove(f);case 3:if(!(p.length>0)){e.next=6;break}return e.next=6,this._notificationCache.remove(p);case 6:case"end":return e.stop()}}),e,this)})))}));case 25:h||this._broadcastRemoveEvent(c,l),n.next=71;break;case 28:if(!(t instanceof Ls)){n.next=35;break}return v=t.reqId,_=t.source,n.next=32,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.remove([v]);case 2:case"end":return e.stop()}}),e,this)})))}));case 32:this._broadcastRemoveUnsentEvent(v,_),n.next=71;break;case 35:if(!(t instanceof Ps)){n.next=48;break}if(m=t.polls,g=t.source,!this._cacheContext.localCacheEnabled){n.next=45;break}return y=m.map((function(e){return e.messageId})),n.next=41,Promise.all(y.map((function(e){return O._messageCache.get(e)})));case 41:return k=n.sent.filter((function(e){return e})),k.length>0&&m.forEach((function(e){var t=k.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=45,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(k);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 45:this._broadcastPollChangeLogEvent(m,g),n.next=71;break;case 48:if(!(t instanceof Fs)){n.next=59;break}return b=t.event,C=t.source,n.next=52,this._messageCache.get(b.messageId);case 52:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollUpdateEvent(b))){n.next=56;break}return n.next=56,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 56:this._broadcastPollUpdateEvent(b,C),n.next=71;break;case 59:if(!(t instanceof qs)){n.next=70;break}return x=t.event,S=t.source,n.next=63,this._messageCache.get(x.messageId);case 63:if(!((T=n.sent)&&T.isUserMessage()&&T.poll&&T.poll.applyPollVoteEvent(x))){n.next=67;break}return n.next=67,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([T]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 67:this._broadcastPollVoteEvent(x,S),n.next=71;break;case 70:t instanceof Ds?(I=t.event,N=t.source,I.messageId>0&&this._broadcastReactionUpdateEvent(I,N)):t instanceof Rs&&(A=t.event,M=t.source,this._broadcastThreadUpdateEvent(A,M));case 71:case"end":return n.stop()}}),n,this)})))})),i}return c(a,t),i(a,[{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"_dispatcher",get:function(){return es.of(this._iid).dispatcher}},{key:"_messageCache",get:function(){return Kd.of(this._iid)}},{key:"_unsentMessageCache",get:function(){return zd.of(this._iid)}},{key:"_notificationCache",get:function(){return Wd.of(this._iid)}},{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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=s(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=s(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=s(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=s(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=s(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:"_broadcastReactionUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastThreadUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(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()}}],[{key:"of",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Yd[e]&&!n||(Yd[e]&&(null===(t=Yd[e]._dispatcherContext)||void 0===t||t.close()),Yd[e]=new a(e)),Yd[e]}}])}(Ya),Xd=function(e){function t(e){var a;r(this,t);var i=e.reverse,s=void 0!==i&&i,o=e.limit,u=void 0===o?20:o,c=e.keys,l=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ue),a.params=pe({token:l,limit:u,reverse:s,order:oe.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),a}return c(t,e),i(t)}(je),Jd=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.next,o=a.has_more,u=void 0!==o&&o,c=a.templates;return i.nextToken=s,i.hasMore=u,i.templates=c.map((function(e){return{template:JSON.stringify(e)}})),i}return c(t,e),i(t)}(Ve),$d=function(e){function t(e){var a;r(this,t);var i=e.key;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ue,"/").concat(i),a}return c(t,e),i(t)}(je),eh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).template=JSON.stringify(a),i}return c(t,e),i(t)}(Ve),th={},nh=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.requestQueue,o=n.onlineDetector,u=n.cacheContext;r(this,e),this._iid=t,this._sdkState=a,this._requestQueue=s,this._dispatcher=i,this._cacheContext=u,Kd.of(t),zd.of(t),Zd.of(t),this.fileMessageQueue=new ko(t,{sdkState:a,dispatcher:i,requestQueue:s,onlineDetector:o,cacheContext:u}),th[t]=this}),[{key:"buildMessageFromSerializedData",value:function(t){var n=ri(t);if(n.notificationId)return new co(this._iid,co.payloadify(n));switch(n.messageType){case e.MessageType.USER:return new oo(this._iid,oo.payloadify(n));case e.MessageType.FILE:return uo._isMultipleFilesMessageSerializedData(n)?new uo(this._iid,uo.payloadify(n)):new fo(this._iid,fo.payloadify(n));case e.MessageType.ADMIN:return new Js(this._iid,Js.payloadify(n))}throw A.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return pe(ve({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 pe(ve({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){var n=this;return pe({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.map((function(e){return new po(n._iid,e)}))})}},{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=ri(e);return new ps(this._iid,ps.payloadify(t))}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Io(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(No),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Do(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Ro),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessagesByMessageId",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Ao(Object.assign(Object.assign({channelType:n,channelUrl:t,token:String(r)},wo),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Mo),c=u.messages,this._dispatcher.dispatch(new Os({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Ao(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},wo),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Mo),c=u.messages,this._dispatcher.dispatch(new Os({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0;return E(this,void 0,void 0,d().mark((function e(){var u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new Ao(Object.assign(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},wo),a),{checkingHasNext:s,checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.as(Mo),h=l.messages,f=l.isContinuousMessages,p=l.hasNext,this._dispatcher.dispatch(new Os({messages:h,source:i})),e.abrupt("return",{messages:h,isContinuousMessages:f,hasNext:p});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_THREADED_MESSAGE;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=new Ao(Object.assign(Object.assign(Object.assign({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:n},Zs),r),{replyType:e.ReplyType.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),i.next=3,this._requestQueue.send(s);case 3:return o=i.sent,u=o.as(Mo),c=u.messages,(l=c.slice(1)).forEach((function(e){e.parentMessage=t})),this._dispatcher.dispatch(new Os({messages:l,source:a})),i.abrupt("return",{parentMessage:c[0],threadedMessages:l});case 9:case"end":return i.stop()}}),i,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new Xd(Object.assign({token:e},t)),n.next=3,this._requestQueue.send(r);case 3:return a=n.sent,i=a.as(Jd),s=i.hasMore,o=i.nextToken,u=i.templates,n.abrupt("return",{hasMore:s,token:o,templates:u});case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new $d({key:e}),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(eh),i=a.template,t.abrupt("return",{template:i});case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageChangelogs",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Oo(pe(ve(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null},So),a)))),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Uo),c=u.updatedMessages,l=u.deletedMessagesInfo,h=u.hasMore,f=u.nextToken,p=l.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new Os({messages:c,source:i})),p.length>0&&this._dispatcher.dispatch(new Us({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:c,deletedMessageIds:p,hasMore:h,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return th[e]}}])}(),rh=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e])).targetMessageId=0;var s=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return s&&D("object",s)&&D("number",o)&&D("string",u)&&D("string",c)&&(i.threadInfo=new is(e,s),i.targetMessageId=o,i.channelUrl=u,i.channelType=c),i}return c(t,e),i(t)}(Ya),ah={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},ih=function(t){return D("string",t.channelUrl)&&R(e.ChannelType,t.channelType)&&D("number",t.messageId)&&D("boolean",t.includeReactions,!0)&&D("boolean",t.includeMetaArray,!0)&&D("boolean",t.includeParentMessageInfo,!0)&&D("boolean",t.includeThreadInfo,!0)},sh=function(e){function t(e){var a,i=e.channelCustomType,s=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,d=e.order,h=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(xe,"/messages"),a.params={custom_type:i,query:s,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:h,message_ts_to:f,sort_field:d,advanced_query:p,target_fields:v,after:_},a}return c(t,e),i(t)}(je),oh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).messages=a.results.map((function(t){return ho(e,t)})),i.hasNext=a.has_next,i.nextToken=a.end_cursor,i.totalCount=a.total_count,i}return c(t,e),i(t)}(Ve);e.MessageSearchOrder=void 0,(Fd=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",Fd.TIMESTAMP="ts";var uh,ch,lh,dh=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;return r(this,a),(s=n(this,a,[t,i])).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=i.keyword,s.reverse=null!==(o=i.reverse)&&void 0!==o&&o,s.exactMatch=null!==(u=i.exactMatch)&&void 0!==u&&u,s.channelUrl=null!==(c=i.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=i.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(d=i.messageTimestampFrom)&&void 0!==d?d:null,s.messageTimestampTo=null!==(h=i.messageTimestampTo)&&void 0!==h?h:null,s.order=null!==(f=i.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=i.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=i.targetFields)&&void 0!==v?v:null,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.keyword)&&this.keyword.length>0&&D("boolean",this.reverse)&&D("boolean",this.exactMatch)&&D("string",this.channelUrl)&&D("string",this.channelCustomType)&&(D("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(D("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&R(e.MessageSearchOrder,this.order)&&D("boolean",this.advancedQuery)&&P("string",this.targetFields,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new sh(ve(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(oh),s=i.messages,o=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,e.abrupt("return",s);case 15:return e.abrupt("return",[]);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}])}(uu),hh=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/parent_thread_message"),a.params=pe(ve({limit:o,token:u})),a}return c(t,e),i(t)}(je),fh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).token=a.next,i.messages=a.messages.map((function(t){return ho(e,t)})),i}return c(t,e),i(t)}(Ve),ph=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s]))._edge="",o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new hh({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(fh),s=i.messages,o=i.token,this._edge=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(cu),vh={channelUrl:"",scheduledMessageId:0},_h=function(e){return D("string",e.channelUrl)&&""!==e.channelUrl&&D("number",e.scheduledMessageId)&&e.scheduledMessageId>0},mh={reverse:!1,limit:20},gh=function(e){return D("boolean",e.reverse,!0)&&D("number",e.limit,!0)&&P("string",e.keys,!0)},yh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="message",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new nh(e,{sdkState:r,dispatcher:a,requestQueue:s,onlineDetector:u,cacheContext:c})}},{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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},ah),e),ai(ih(n)).throw(A.invalidParameters),t.next=4,this._manager.getMessage(n);case 4:if(!((r=t.sent)instanceof Ws||r instanceof co||null===r)){t.next=7;break}return t.abrupt("return",r);case 7:throw"Unknown message type is given.";case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},vh),e),ai(_h(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},mh),t),ai(D("string",e,!0)&&gh(r)).throw(A.invalidParameters),n.abrupt("return",this._manager.getMessageTemplatesByToken(e,r));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getMessageTemplate(e));case 2:case"end":return t.stop()}}),t,this)})))}}])}(ts),Eh=i((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})),kh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="poll",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new Wc(e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c})}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Gc),e),ai(jc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.create(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Bc),e),ai(Kc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.get(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Vc),e),ai(zc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getOption(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}])}(ts),bh={profileImage:void 0,profileUrl:void 0,nickname:void 0},Ch=function(e){return H(e.profileImage,!0)&&D("string",e.profileUrl,!0)&&D("string",e.nickname,!0)};e.GroupChannelListOrder=void 0,(uh=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",uh.CHRONOLOGICAL="chronological",uh.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",uh.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(ch=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",ch.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",ch.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(lh=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",lh.SCHEDULED_AT="scheduled_at";var wh,xh=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"]}},Sh=function(t){return{v2:function(){return E(void 0,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.commitSchema([{collectionName:Yc,keyName:"url",index:[xh(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),xh(e.GroupChannelListOrder.CHRONOLOGICAL),xh(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Zc,keyName:"messageId",index:[qd(Rd.CHANNEL_LATEST),qd(Rd.NEWEST_CHILD_MESSAGE)]},{collectionName:jd,keyName:"reqId",index:[qd(Rd.CHANNEL_LATEST),qd(Rd.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))},v3:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:"FeedChannel",keyName:"url",index:[["-lastMessageUpdatedAt","-createdAt","syncIndex"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))},v4:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:Xc,keyName:"notificationId",index:[["channelUrl","-createdAt","-notificationId"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}},Th=function(t){return function(n,r){return E(void 0,void 0,void 0,d().mark((function a(){var i,s,o,u,c;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=n,a.next=1===a.t0||2===a.t0||3===a.t0||4===a.t0?3:5===a.t0?5:6===a.t0?9:26;break;case 3:return r(),a.abrupt("break",27);case 5:return a.next=7,t.store.clear();case 7:return r(),a.abrupt("break",27);case 9:return a.prev=9,i=Sh(t),s=i.v2,o=i.v3,u=i.v4,a.next=13,s();case 13:return a.next=15,o();case 15:return a.next=17,u();case 17:return c=t.collection(Zc),a.next=20,c.removeIf({where:{channelType:e.ChannelType.OPEN}});case 20:a.next=24;break;case 22:a.prev=22,a.t1=a.catch(9);case 24:return r(),a.abrupt("break",27);case 26:r();case 27:case"end":return a.stop()}}),a,null,[[9,22]])})))}},Ih=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Nh=function(e){function t(e){var a,i=e.getVisibilityState,s=void 0===i?Ih:i,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,d=e.pauseCheckDelay,h=void 0===d?3e4:d;return r(this,t),(a=n(this,t))._pauseCheckDelay=3e4,a._currentState="visible",a._getVisibilityState=s,a._pauseCheckDelay=h,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(a),a}return c(t,e),i(t,[{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})}}])}(de),Ah=function(){return i((function e(t){var n=this,a=t.logger,i=t.connectionDelegate,s=void 0===i?null:i;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,s&&(this.connectionDelegate=s)}),[{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,d().mark((function e(){return d().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:_e.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}])}(),Mh=function(e){function t(e){var a,i=e.message;return r(this,t),(a=n(this,t)).message=i,a}return c(t,e),i(t)}(fe),Oh={},Uh=function(){return i((function e(t,n){var a=this,i=n.localCacheEnabled,s=n.enableAutoResend,o=n.dispatcher,u=n.sdkState,c=n.logger;r(this,e),this._iid=t,Oh[t]=this,this._localCacheEnabled=i,this._enableAutoResend=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=o,this._logger=c,this._sdkState=u,this._localCacheEnabled&&o.on((function(e){if(e instanceof La)switch(e.stateType){case Aa.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case Aa.INTERNAL_DISCONNECTED:case Aa.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}),[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._enableAutoResend){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this._fetchAllCachedPendingMessages();case 4:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)0===(i=a.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=e.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new Os({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){r.e(e)}finally{r.f()}case 7:case"end":return t.stop()}}),t,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)i=a.value,this._enableAutoResend&&i.errorCode&&q(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,this._enableAutoResend&&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 Os({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return t.stop()}}),t,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&this._enableAutoResend&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!q(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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=zd.of(this._iid),(r=new Pd).replyType=e.ReplyType.ALL,t.next=5,n.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0,filter:r});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&this._enableAutoResend&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),t=this._autoResendQueue[0],this._dispatcher.dispatch(new Mh({message:t})),this._logger.debug("processing auto-resend for message request id: ",t.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Oh[e]}}])}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(wh||(wh={}));var Dh,Rh=function(){return i((function e(t){r(this,e),this.category=t.cat,this.data=t.data}),null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new si(e,r),blockee:new si(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 si(e,t)})):[]}}}])}(),Lh=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Ph=function(e){function t(e,a){var i,s=a.userId;return r(this,t),(i=n(this,t))._iid=e,i.userId=s,i}return c(t,e),i(t)}(fe),Fh=function(e){function t(){return r(this,t),n(this,t)}return c(t,e),i(t)}(fe),qh=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"USEV",i])).event=new Rh(i),s}return c(t,e),i(t)}(Ke),Hh=function(e){function t(e){var a,i=e.userId,s=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i)),a.params=pe(ve({nickname:s,profile_url:o,profile_file:u,preferred_languages:c})),a}return c(t,e),i(t)}(je),Gh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).user=new si(e,Object.assign({},a)),i}return c(t,e),i(t)}(Ve),jh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a.params=pe({apns_device_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(je),Vh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a.params=pe({gcm_reg_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(je),zh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),Bh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),Kh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a}return c(t,e),i(t)}(je),Qh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a}return c(t,e),i(t)}(je),Wh=function(e){function t(e){var a,i=e.userId,s=e.type,o=e.token,u=e.ts;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/").concat(encodeURIComponent(s),"/device_tokens"),a.params={created_ts:u,token:o},a}return c(t,e),i(t)}(je),Yh=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).pushTokens={type:i.type?e.PushTokenType[i.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:i.device_tokens,hasMore:i.has_more,token:i.token},s}return c(a,t),i(a)}(Ve),Zh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a}return c(t,e),i(t)}(je),Xh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(Ve),Jh=function(e){function t(e){var a,i=e.userId,s=e.willAutoAccept;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a.params={auto_accept:s},a}return c(t,e),i(t)}(je),$h=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(Ve),ef=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(je),tf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(Ve),nf=function(e){function t(e){var a,i=e.userId,s=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,d=e.timezone;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={do_not_disturb:s,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:d},a}return c(t,e),i(t)}(je),rf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(Ve),af=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(je),sf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(Ve),of=function(e){function t(e){var a,i=e.userId,s=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={snooze_enabled:s,snooze_start_ts:o,snooze_end_ts:u},a}return c(t,e),i(t)}(je),uf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(Ve),cf=function(e){function t(e){var a,i=e.userId,s=e.blockedUserId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block"),a.params={target_id:s},a}return c(t,e),i(t)}(je),lf=function(e){function t(e){var a,i=e.userId,s=e.unblockedUserId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),df=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(je),hf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(Ve),ff=function(e){function t(e){var a,i=e.userId,s=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={push_trigger_option:s},a}return c(t,e),i(t)}(je),pf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(Ve),vf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a}return c(t,e),i(t)}(je),_f=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(Ve),mf=function(e){function t(e){var a,i=e.userId,s=e.templateName;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a.params={name:s},a}return c(t,e),i(t)}(je),gf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(Ve),yf=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends/changelogs"),a.params={token:s},a}return c(t,e),i(t)}(je),Ef=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).changelogs={addedUsers:a.added.map((function(t){return new si(e,t)})),updatedUsers:a.updated.map((function(t){return new si(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},i}return c(t,e),i(t)}(Ve),kf=function(e){function t(e){var a,i=e.userId,s=e.discoveries;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discoveries:s.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return c(t,e),i(t)}(je),bf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).friendDiscoveryRequestId=a.friend_discovery_request_id,i}return c(t,e),i(t)}(Ve),Cf=function(e){function t(e){var a,i=e.userId,s=e.discoveryKeys;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discovery_keys:s},a}return c(t,e),i(t)}(je),wf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(je),xf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new si(e,t)})),i}return c(t,e),i(t)}(Ve),Sf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(je),Tf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={},a}return c(t,e),i(t)}(je),If=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).allowFriendDiscovery=a.allow_friend_discovery,i}return c(t,e),i(t)}(Ve),Nf=function(e){function t(e){var a,i=e.userId,s=e.allowFriendDiscovery;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={allow_friend_discovery:s},a}return c(t,e),i(t)}(je),Af=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path=Ie,e}return c(t,e),i(t)}(je),Mf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiContainer=new gl(a),i}return c(t,e),i(t)}(Ve),Of=function(e){function t(e){var a,i=e.categoryId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ie,"/").concat(i),a}return c(t,e),i(t)}(je),Uf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiCategory=new ml(a),i}return c(t,e),i(t)}(Ve),Df=function(e){function t(e){var a,i=e.key;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Te,"/").concat(i),a}return c(t,e),i(t)}(je),Rf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emoji=new _l(a),i}return c(t,e),i(t)}(Ve),Lf=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path="".concat(Me),e}return c(t,e),i(t)}(je),Pf=function(e){function t(e,a){var i,s;r(this,t);var o=null!=a?a:{};return(i=n(this,t,[e,a])).uikitConfiguration={string:JSON.stringify(o),json:o},i.updatedAt=null!==(s=null==a?void 0:a.updated_at)&&void 0!==s?s:0,i}return c(t,e),i(t)}(Ve);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(Dh||(Dh={}));var Ff,qf=function(e){function t(e){var a,i=e.deviceToken,s=e.pushTrackingId,o=e.messageId,u=e.allowedPushNotification,c=e.channelKey,l=e.templateKey,d=e.eventType,h=e.notificationEventDeadline;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=De,a.params=pe({device_token:i,push_tracking_id:s,message_id:o,allowed_push_notification:u,channel_key:c,template_key:l,event_type:d,notification_event_deadline:h}),a}return c(t,e),i(t)}(je);var Hf,Gf=function(){function t(e,n,a){var i=this;r(this,t),this._storeInitialized=!1,this._iid=e,this.options=n;var s=es.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,l=s.sessionManager,h=s.requestQueue,f=s.logger,p=s.userEventHandlers,v=s.appStateToggleEnabled;this._onlineDetector=new Ah({logger:f,connectionDelegate:{reconnect:function(){return E(i,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=es.of(e),r=n.sdkState,a=n.connectionManager,(i=n.sessionManager).session.hasSession){t.next=14;break}return t.prev=2,t.next=5,a.connect(i.session.authToken);case 5:t.next=12;break;case 7:if(t.prev=7,t.t0=t.catch(2),!N(t.t0)){t.next=11;break}throw t.t0;case 11:f.debug("connect failed by reconnect event = ",t.t0);case 12:t.next=25;break;case 14:if("foreground"!==r.appState){t.next=25;break}return t.prev=15,t.next=18,a.resetAndReconnect();case 18:t.next=25;break;case 20:if(t.prev=20,t.t1=t.catch(15),!N(t.t1)){t.next=24;break}throw t.t1;case 24:f.debug("resetAndReconnect failed by reconnect event = ",t.t1);case 25:c.dispatch(new Lh);case 26:case"end":return t.stop()}}),t,null,[[2,7],[15,20]])})))},disconnect:function(){fi((function(){return E(i,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(e),r=n.connectionManager,t.next=3,r.disconnect();case 3:case"end":return t.stop()}}),t)})))}))}}});var _=new Uh(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,dispatcher:c,sdkState:o,logger:f});a.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:l,requestQueue:h,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new Nh({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()})),c.on((function(t){var n;if(t instanceof La){if(t.stateType===Aa.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof Ke){if("USEV"===t.code){var r=t.as(qh).event;if(r.category===wh.FRIEND_DISCOVERED){var a=Rh.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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(t instanceof Oa){var s=es.of(i._iid).subscribedUnreadMessageCount,c=!1,l=t.ts;"number"==typeof l&&l>s.ts&&(s.all!==t.all&&(c=!0),s.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){s.customTypes[e]!==t.customTypes[e]&&(c=!0),s.customTypes[e]=t.customTypes[e]})),c=c&&s.ts>0,s.ts=l),c&&hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:s.all,feedChannelCount:s.feed,customTypeUnreadCount:s.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else t instanceof oi?(u.preference.set(i._getUserProfileCacheKey(o.userId),ui.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(Ga(i.appId),{value:!0})):t instanceof Be&&t.error&&t.error.isSessionInvalidatedError&&(f.debug("session revoked."),i._internalDisconnect(t.error))}))}return i(t,[{key:"appId",get:function(){return es.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=es.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=es.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!es.of(this._iid).debugMode}},{key:"logLevel",get:function(){return es.of(this._iid).logger.level},set:function(e){es.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return es.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=es.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return es.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=es.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=es.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=es.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:"_getNestDBVersion",value:function(){return 7}},{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:"_internalDisconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.connectionManager,a=n.sdkState,i=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),t.next=6,r.logout(e);case 6:return t.next=8,this.clearCachedData();case 8:a.appState="foreground";case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getMemoryStoreForDebugging",value:function(){var e=es.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Sd?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=es.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)}},{key:"addSendbirdExtensions",value:function(e,t,n){var r=es.of(this._iid),a=r.logger,i=r.sdkState,s=new RegExp("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");if(0===e.length)return a.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!s.test(e.version)})))return a.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(var o=0,u=Object.entries(n);o2&&void 0!==arguments[2]?arguments[2]:{};return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(ai(D("string",e)&&D("string",t,!0)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,s=a.cacheContext,o=a.connectionManager,u=n.errorForOtherUser,!i.userId||i.userId===e){r.next=10;break}if(u){r.next=9;break}return r.next=7,o.logout();case 7:r.next=10;break;case 9:throw u;case 10:return r.prev=10,r.next=13,this.initializeCache(e);case 13:c=es.of(this._iid),c.dispatcher.dispatch(new Fh),r.next=22;break;case 17:r.prev=17,r.t0=r.catch(10),l=es.of(this._iid),h=l.logger,s.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 22:return r.prev=22,r.next=25,this._setupPreference(e);case 25:return r.finish(22);case 26:case"end":return r.stop()}}),r,this,[[10,17,22,26]])})))}},{key:"authenticateFeed",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.authenticate(e,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=es.of(this._iid),i=a.sessionManager,s=a.connectionManager,r.next=3,this._ready(e,t,{errorForOtherUser:s.isConnected?A.alreadyConnectedAsAnotherUser:void 0});case 3:if(null===(n=i.session.services)||void 0===n?void 0:n.includes(K.CHAT)){r.next=7;break}return t||i.handler||(o=new El,this.setSessionHandler(o)),r.next=7,i.authenticate(e,t);case 7:return r.abrupt("return",this.currentUser);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"connect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._ready(e,t);case 2:return n.prev=2,r=es.of(this._iid),a=r.connectionManager,n.next=6,a.connect(t);case 6:return n.prev=6,this._onlineDetector.start(),this._appStateChangeDetector.start(),n.finish(6);case 10:return n.abrupt("return",this.currentUser);case 11:case"end":return n.stop()}}),n,this,[[2,,6,10]])})))}},{key:"reconnect",value:function(){var e=es.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._internalDisconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.connectionManager,r=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),e.next=6,n.disconnectWebSocket(!0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=es.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().catch((function(e){r.debug("setBackgroundState error = ",e)})))}},{key:"setForegroundState",value:function(){var e=es.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,a=e.logger;"background"===n.appState&&(n.appState="foreground",a.debug("going foreground state"),t.resetAndReconnect().catch((function(e){a.debug("setForgroundState error = ",e)})),r.dispatch(new Lh))}},{key:"setSessionHandler",value:function(e){ai(e instanceof El).throw(A.invalidParameters),es.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){ai(D("string",e)&&t instanceof kl).throw(A.invalidParameters),es.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){es.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){es.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){ai(D("string",e)&&t instanceof yl).throw(A.invalidParameters),es.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){es.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){es.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new wl(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Tl(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Al(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new dh(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new el(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new rl(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=ri(e);return new si(this._iid,si.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Object.assign(Object.assign({},bh),e),ai(Ch(n)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Hh(Object.assign({userId:a.userId},n)),t.next=7,i.send(s);case 7:return o=t.sent,u=o.as(Gh),c=u.user,this.currentUser&&(n.nickname&&(this.currentUser.nickname=c.nickname),(n.profileUrl||n.profileImage)&&(this.currentUser.plainProfileUrl=c.profileUrl)),t.abrupt("return",c);case 13:throw A.connectionRequired;case 14:case"end":return t.stop()}}),t,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ai(P("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Hh({userId:r.userId,preferredLanguages:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Gh),u=o.user,this.currentUser&&(this.currentUser.preferredLanguages=u.preferredLanguages),t.abrupt("return",u);case 12:throw A.connectionRequired;case 13:case"end":return t.stop()}}),t,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ai(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ai(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.ANDROID,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=es.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.FCM,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new Vh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,fi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.FCM,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._fcmPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._fcmPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=es.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Bh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,fi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.FCM,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=es.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Qh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,fi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.FCM),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ai(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ai(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.IOS,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=es.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.APNS,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new jh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,fi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.APNS,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._apnsPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._apnsPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=es.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new zh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,fi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.APNS,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._apnsPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._apnsPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=es.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Kh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,fi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.APNS),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markPushNotificationAsDelivered",value:function(e){var t,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k,b;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=es.of(this._iid),i=a.logger,s=a.sessionManager,o=a.requestQueue,u=a.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=Dh.DELIVERED,l=u.parseData(e),h=l.pushTrackingId,f=l.sessionTopics,p=l.sessionKey,v=l.messageId,_=l.channelKey,m=l.templateKey,g=l.notificationEventDeadline,p){r.next=7;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 7:if(f.includes(ji.PUSH_ACKNOWLEDGEMENT)){r.next=10;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 10:if(!u.isAcked(h,c)){r.next=13;break}return i.info("already delivered push notification:",h),r.abrupt("return");case 13:return y=Boolean(_),E=n&&y,k=null===(t=s.deviceTokens[0])||void 0===t?void 0:t.token,b=new qf({deviceToken:null!=k?k:"",pushTrackingId:h,eventType:c,messageId:v,channelKey:_,templateKey:m,notificationEventDeadline:g,allowedPushNotification:E}),p&&(b.headers["Session-Key"]=p),r.prev=18,r.next=21,o.send(b);case 21:u.markAsAcked(h,c),r.next=28;break;case 24:throw r.prev=24,r.t0=r.catch(18),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(h,". error: ").concat(r.t0)),r.t0;case 28:case"end":return r.stop()}}),r,this,[[18,24]])})))}},{key:"markPushNotificationAsClicked",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=es.of(this._iid),a=r.logger,i=r.sessionManager,s=r.requestQueue,o=r.pushNotificationAckManager,a.debug("markPushNotificationAsClicked:",e),u=Dh.CLICKED,c=o.parseData(e),l=c.pushTrackingId,h=c.sessionTopics,f=c.sessionKey,p=c.messageId,v=c.channelKey,_=c.templateKey,m=c.notificationEventDeadline,f){n.next=7;break}throw a.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 7:if(h.includes(ji.PUSH_ACKNOWLEDGEMENT)){n.next=10;break}throw a.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 10:if(!o.isAcked(l,u)){n.next=13;break}return a.info("already clicked push notification:",l),n.abrupt("return");case 13:return g=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,y=new qf({deviceToken:null!=g?g:"",pushTrackingId:l,eventType:u,messageId:p,channelKey:v,templateKey:_,notificationEventDeadline:m}),f&&(y.headers["Session-Key"]=f),n.prev=16,n.next=19,s.send(y);case 19:o.markAsAcked(l,u),n.next=26;break;case 22:throw n.prev=22,n.t0=n.catch(16),a.debug("failed to mark push notification as clicked. push tracking id: ".concat(l,". error: ").concat(n.t0)),n.t0;case 26:case"end":return n.stop()}}),n,this,[[16,22]])})))}},{key:"getChannelInvitationPreference",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Zh({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Xh),o=s.autoAccept,e.abrupt("return",{autoAccept:o});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("boolean",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Jh({userId:r.userId,willAutoAccept:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as($h),u=o.autoAccept,t.abrupt("return",{autoAccept:u});case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getDoNotDisturb",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ef({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(tf),o=s.preference,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return ai(D("boolean",e)&&D("number",t)&&D("number",n)&&D("number",r)&&D("number",a)&&D("string",i)).throw(A.invalidParameters),o=es.of(this._iid),u=o.sdkState,c=o.requestQueue,l=new nf({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:a,timezone:i}),s.next=5,c.send(l);case 5:return h=s.sent,f=h.as(rf),p=f.preference,s.abrupt("return",p);case 8:case"end":return s.stop()}}),s,this)})))}},{key:"getSnoozePeriod",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new af({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(sf),o=s.snoozePeriod,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("boolean",e)&&D("number",t)&&D("number",n)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new of({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),r.next=5,s.send(o);case 5:return u=r.sent,c=u.as(uf),l=c.snoozePeriod,r.abrupt("return",l);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"getMyPushTokensByToken",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p,v,_;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",t)&&R(e.PushTokenType,n)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,o=a.requestQueue,u=a.sessionManager,c=new Wh({userId:i.userId,type:n,token:t}),r.next=5,o.send(c);case 5:l=r.sent,h=l.as(Yh),f=h.pushTokens,p=s(f.deviceTokens);try{for(p.s();!(v=p.n()).done;)_=v.value,u.setDeviceToken(f.type,_)}catch(e){p.e(e)}finally{p.f()}return r.next=11,u.saveDeviceToken();case 11:return r.abrupt("return",f);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"getPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new df({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(hf).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new ff({userId:a.userId,pushTriggerOption:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(pf).pushTriggerOption);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"getPushTemplate",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new vf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(_f).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.PushTemplate,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new mf({userId:a.userId,templateName:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(gf).name);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"blockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(e instanceof si||D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new cf({userId:r.userId,blockedUserId:e instanceof si?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(e instanceof si||D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new lf({userId:r.userId,unblockedUserId:e instanceof si?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new yf({userId:r.userId,token:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(Ef),u=o.changelogs,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Tf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(If),o=s.allowFriendDiscovery,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("boolean",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Nf({userId:r.userId,allowFriendDiscovery:e}),t.next=5,a.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new kf({userId:r.userId,discoveries:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(bf),u=o.friendDiscoveryRequestId,t.abrupt("return",u);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Cf({userId:r.userId,discoveryKeys:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"addFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new wf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(xf),u=o.users,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Sf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getAllEmoji",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Af,e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Mf),s=i.emojiContainer,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Of({categoryId:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Uf),o=s.emojiCategory,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getEmoji",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Df({key:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Rf),o=s.emoji,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getUIKitConfiguration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),ai(t.hasExtension("sb_uikit")).throw(A.notSupportedError),n=t.requestQueue,r=new Lf,e.next=6,n.send(r);case 6:return a=e.sent,i=a.as(Pf),s=i.uikitConfiguration,e.abrupt("return",s);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(n){var r=n.appId,a=n.appVersion,i=n.modules,s=void 0===i?[]:i,o=n.options,u=void 0===o?new j:o,c=n.debugMode,l=void 0!==c&&c,d=n.customApiHost,h=n.customWebSocketHost,f=n.newInstance,p=void 0!==f&&f,_=n.logLevel,m=n.localCacheEnabled,g=void 0!==m&&m,y=n.localCacheConfig,E=void 0===y?new W:y,k=n.localCacheEncryption,b=n.useAsyncStorageStore,C=void 0===b?null:b,w=n.useMMKVStorageStore,x=void 0===w?null:w,S=n.appStateToggleEnabled,T=void 0===S||S;if(!Ff||p){var I="su-".concat(ce()),N=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},A=new Ld;A.level=null!=_?_:e.LogLevel.WARN;var M=new Sd({encryption:N});l||(at()?x?M=new Md({MMKV:x,encryption:N}):C&&(M=new Ad({AsyncStorage:C,encryption:N}),A.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):M=new Nd({encryption:N})),new es(I,{appId:r,appVersion:a,options:u,apiHost:null!=d?d:"https://api-".concat(r,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(r,".sendbird.com"),store:M,encryption:N,logger:A,localCacheEnabled:g,localCacheConfig:E,debugMode:l,appStateToggleEnabled:T});var O=[new yh,new kh],U=new t(I,u,[].concat(v(s),O));return Ff||(Ff=U),U}return Ff}},{key:"instance",get:function(){return Ff}},{key:"version",get:function(){return b}}])}();e.MemberState=void 0,(Hf=e.MemberState||(e.MemberState={})).NONE="none",Hf.JOINED="joined",Hf.INVITED="invited",Hf.LEFT="left";var jf,Vf,zf,Bf,Kf,Qf,Wf,Yf,Zf=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).state=null,s.role=null,s.isMuted=!1,s.isBlockedByMe=!1,s.isBlockingMe=!1,s.state=R(e.MemberState,i.state)?i.state:null,s.role=R(e.Role,i.role)?i.role:null,"boolean"==typeof i.is_muted&&(s.isMuted=i.is_muted),"boolean"==typeof i.is_blocked_by_me&&(s.isBlockedByMe=i.is_blocked_by_me),"boolean"==typeof i.is_blocking_me&&(s.isBlockingMe=i.is_blocking_me),s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}])}(Po),Xf=function(t){function a(t,i){var s,o,u;return r(this,a),(s=n(this,a,[t])).channelUrl=null!==(o=i.channel_url)&&void 0!==o?o:"",s.channelType=null!==(u=i.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,s.member=new si(s._iid,i.user),s.deliveryAt=i.ts,s}return c(a,t),i(a)}(Ya);e.PublicChannelFilter=void 0,(jf=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",jf.PUBLIC="public",jf.PRIVATE="private",e.MyMemberStateFilter=void 0,(Vf=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",Vf.JOINED="joined_only",Vf.INVITED="invited_only",Vf.INVITED_BY_FRIEND="invited_by_friend",Vf.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(zf=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",zf.SUPER="super",zf.NON_SUPER="nonsuper",zf.BROADCAST_ONLY="broadcast_only",zf.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(Bf=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",Bf.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(Kf=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",Kf.UNHIDDEN="unhidden_only",Kf.HIDDEN="hidden_only",Kf.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Kf.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(Qf=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",Qf.OPERATOR="operator",Qf.NONOPERATOR="nonoperator",e.QueryType=void 0,(Wf=e.QueryType||(e.QueryType={})).AND="AND",Wf.OR="OR",e.GroupChannelSearchField=void 0,(Yf=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",Yf.CHANNEL_NAME="channel_name";var Jf,$f=function(){function t(n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m,g;r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(a=null==n?void 0:n.includeEmpty)&&void 0!==a&&a,this.nicknameContainsFilter=null!==(i=null==n?void 0:n.nicknameContainsFilter)&&void 0!==i?i:null,this.nicknameStartsWithFilter=null!==(s=null==n?void 0:n.nicknameStartsWithFilter)&&void 0!==s?s:null,this.nicknameExactMatchFilter=null!==(o=null==n?void 0:n.nicknameExactMatchFilter)&&void 0!==o?o:null,this.channelNameContainsFilter=null!==(u=null==n?void 0:n.channelNameContainsFilter)&&void 0!==u?u:"",this.myMemberStateFilter=null!==(c=null==n?void 0:n.myMemberStateFilter)&&void 0!==c?c:e.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(l=null==n?void 0:n.customTypesFilter)&&void 0!==l?l:null,this.channelUrlsFilter=null!==(d=null==n?void 0:n.channelUrlsFilter)&&void 0!==d?d:null,this.superChannelFilter=null!==(h=null==n?void 0:n.superChannelFilter)&&void 0!==h?h:e.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(f=null==n?void 0:n.publicChannelFilter)&&void 0!==f?f:e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(p=null==n?void 0:n.customTypeStartsWithFilter)&&void 0!==p?p:null,this.unreadChannelFilter=null!==(v=null==n?void 0:n.unreadChannelFilter)&&void 0!==v?v:e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==n?void 0:n.hiddenChannelFilter)&&void 0!==_?_:e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(m=null==n?void 0:n.includeFrozen)||void 0===m||m,(null==n?void 0:n.createdAfter)&&(this.createdAfter=n.createdAfter),(null==n?void 0:n.createdBefore)&&(this.createdBefore=n.createdBefore),this.includeMetaData=null===(g=null==n?void 0:n.includeMetaData)||void 0===g||g}return i(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,i=r.fields;if(a&&i&&i.length>0&&!i.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var s=this._userIdsFilter,o=s.userIds,u=s.includeMode,c=s.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=v(e).sort(),r=v(t).sort(),a=0;a0&&!this.customTypesFilter.includes("*")&&!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 d=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(d)})))return!1}if(this.nicknameStartsWithFilter){var h=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(h)})))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.ALL:if("none"===t.myMemberState)return!1;break;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!(this.createdAfter&&t.createdAtthis.createdBefore)}}])}(),ep=function(t){function a(e,t){var i,s=t.sdkState,o=t.cacheContext;return r(this,a),(i=n(this,a,[e]))._channels=new Map,i._sdkState=s,i._cacheContext=o,i}return c(a,t),i(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ai(!!e).throw(A.databaseError),e.collection(Yc)}},{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 Cv.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return v(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>n||s&&t.createdAtn||s&&t.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)n._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});n._update(e),r.push(n)}else s._channels.set(e.url,e),r.push(e)})),!this.localCacheEnabled){n.next=7;break}for(a=[],i=0;i0)){r.next=76;break}return r.next=76,this.upsert(a);case 76:case"end":return r.stop()}}),r,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!0);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"unblock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!1);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"markAsRead",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v(this._channels.keys());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=s(t),n.prev=2,a.s();case 4:if((i=a.n()).done){n.next=12;break}return o=i.value,n.next=8,this.get(o);case 8:(null==(u=n.sent)?void 0:u._updateUnreadMemberState(this._sdkState.userId,e))&&(u._updateUnreadCount(0,0),r.push(u));case 10:n.next=4;break;case 12:n.next=17;break;case 14:n.prev=14,n.t0=n.catch(2),a.e(n.t0);case 17:return n.prev=17,a.f(),n.finish(17);case 20:if(!(r.length>0)){n.next=23;break}return n.next=23,this.upsert(r);case 23:case"end":return n.stop()}}),n,this,[[2,14,17,20]])})))}}])}(Ya);!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"}(Jf||(Jf={}));var tp,np=function(){return i((function e(t){var n;r(this,e),this.channelUrl=t.channel_url,this.channelType=t.channel_type,this.category=t.cat,this.data=null!==(n=t.data)&&void 0!==n?n:{},this.ts=t.ts}),[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}])}(),rp={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},ap=function(e){return P("string",e.invitedUserIds,!0)&&D("string",e.channelUrl,!0)&&D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isSuper,!0)&&D("boolean",e.isBroadcast,!0)&&D("boolean",e.isExclusive,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isStrict,!0)&&D("boolean",e.isDiscoverable,!0)&&D("boolean",e.isEphemeral,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},ip={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},sp=function(e){return P("string",e.customTypes,!0)&&D("boolean",e.includeEmpty,!0)&&D("boolean",e.includeFrozen,!0)&&D("boolean",e.includeMetaData,!0)&&D("boolean",e.includeChatNotification,!0)},op={myMemberStateFilter:e.MyMemberStateFilter.ALL},up=function(t){return R(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(tp=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",tp.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",tp.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",tp.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",tp.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",tp.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",tp.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",tp.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",tp.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var cp,lp={keys:[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,e.UnreadItemKey.NONSUPER_INVITATION_COUNT,e.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},dp=function(t){return P(e.UnreadItemKey,t.keys)&&P("string",t.customTypeFilters,!0)&&P("string",t.customTypesFilter,!0)},hp={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},fp=function(t){return P("string",t.channelCustomTypesFilter,!0)&&R(e.SuperChannelFilter,t.superChannelFilter)},pp={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},vp=function(t){return D("string",t.channelUrl,!0)&&P(e.ScheduledStatus,t.scheduledStatus,!0)&&R(e.MessageTypeFilter,t.messageTypeFilter)},_p=Object.assign({},e.CollectionEventSource),mp=function(t){return t.startsWith("EVENT_")||t===e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.CollectionEventSource.REFRESH_CHANNEL},gp=function(e){function t(e){var a,i=e.channels,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.ts;return r(this,t),(a=n(this,t)).channels=i,a.context=s,a.isWebSocketEventComing=u,a.ts=c,a}return c(t,e),i(t)}(fe),yp=function(e){function t(e){var a,i=e.channelUrls,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,t),(a=n(this,t)).channelUrls=i,a.context=s,a.isWebSocketEventComing=u,a}return c(t,e),i(t)}(fe),Ep=function(){return i((function t(n){var a=this,i=n.groupChannelCache,o=n.messageCache,u=n.unsentMessageCache,c=n.dispatcher;r(this,t),this._observers=new Map,c.on((function(t){return E(a,void 0,void 0,d().mark((function n(){var r,a,c,l,h,f,p,v,_,m,g,y,k,b,C,w=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof gp)){n.next=47;break}if(r=t.channels,a=t.context,c=t.isWebSocketEventComing,l=r.filter((function(e){return e instanceof E_})),a.source!==e.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY&&a.source!==e.CollectionEventSource.EVENT_CHANNEL_HIDDEN){n.next=23;break}h=s(l),n.prev=5,h.s();case 7:if((f=h.n()).done){n.next=13;break}return p=f.value,n.next=11,o.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),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:n.next=41;break;case 23:v=i.filterOffsetChanged(l),_=s(v),n.prev=25,_.s();case 27:if((m=_.n()).done){n.next=33;break}return g=m.value,n.next=31,o.removeUnderOffset(g.url,g.messageOffsetTimestamp);case 31:n.next=27;break;case 33:n.next=38;break;case 35:n.prev=35,n.t1=n.catch(25),_.e(n.t1);case 38:return n.prev=38,_.f(),n.finish(38);case 41:return n.next=43,i.upsert(l,t.ts);case 43:y=n.sent,c||this._broadcastUpdateEvent(y,a),n.next=59;break;case 47:if(!(t instanceof yp)){n.next=56;break}return k=t.channelUrls,b=t.context,C=t.isWebSocketEventComing,n.next=51,i.remove(k);case 51:return n.next=53,fi((function(){return E(w,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(k),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=7,o.removeMessagesOfChannel(r);case 7:return e.next=9,u.removeMessagesOfChannel(r);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 53:C||this._broadcastRemoveEvent(k,b),n.next=59;break;case 56:if(!(t instanceof Ph)){n.next=59;break}return n.next=59,i.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 59:case"end":return n.stop()}}),n,this,[[5,15,18,21],[25,35,38,41]])})))}))}),[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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:"_broadcastRemoveEvent",value:function(e,t){var n,r=s(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()}}])}(),kp=function(e){function t(e){var a,i=e.userId,s=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c;r(this,t),a=n(this,t);var d=Object.assign(Object.assign({},ip),u),h=d.customTypes,f=d.includeEmpty,p=d.includeFrozen;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels/changelogs"),a.params=pe(ve({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:s||null,token:o,custom_types:h,show_empty:f,show_frozen:p,include_chat_notification:l})),a}return c(t,e),i(t)}(je),bp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedChannels=a.updated.map((function(t){return new E_(e,Object.assign(t,{ts:a.ts}))})),i.deletedChannelUrls=a.deleted,i.hasMore=a.has_more,i.token=a.next,i.ts=a.ts,i}return c(t,e),i(t)}(Ve),Cp=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall,o=e.showLatestMessage;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?be:ke,"/").concat(encodeURIComponent(i)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=o&&o},a}return c(t,e),i(t)}(je),wp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),xp={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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,createdAfter:void 0,createdBefore:void 0},Sp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,d=e.superChannelFilter,h=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,E=e.customTypeStartsWithFilter,k=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,C=e.metadataKey,w=e.metadataValues,x=e.metadataValueStartsWith,S=e.includeFrozen,T=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter,A=e.includeChatNotification,M=void 0!==A&&A,O=e.includeLeftChannel,U=void 0!==O&&O,D=e.createdAfter,R=e.createdBefore;return(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels"),a.params=pe({token:s,limit:o,order:null!=u?u:xp.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:xp.includeEmpty,member_state_filter:null!=l?l:xp.myMemberStateFilter,super_mode:null!=d?d:xp.superChannelFilter,public_mode:null!=h?h:xp.publicChannelFilter,unread_filter:null!=f?f:xp.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:E,hidden_mode:k,metadata_order_key:b,metadata_key:C,metadata_values:w,metadata_value_startswith:x,show_frozen:S,show_metadata:T,include_chat_notification:M,include_left_channel:U,created_after:D,created_before:R}),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 c(t,e),i(t)}(je),Tp=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new E_(e,t)}))),i.ts=null!=u?u:0,i}return c(t,e),i(t)}(Ve),Ip=function(t){function a(t){var i,s=t.userId,o=t.filter;r(this,a),i=n(this,a);var u=o.myMemberStateFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/group_channel_count"),i.params={state:null!=u?u:e.MyMemberStateFilter.ALL},i}return c(a,t),i(a)}(je),Np=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).groupChannelCount=a.group_channel_count,i}return c(t,e),i(t)}(Ve),Ap=function(e){function t(e){var a,i=e.userId,s=e.filter;r(this,t),a=n(this,t);var o=s.keys,u=s.customTypeFilters,c=s.customTypesFilter;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_item_count"),a.params=pe({item_keys:o,custom_types:null!=c?c:u}),a}return c(t,e),i(t)}(je),Mp=function(t){function a(t,i){var s;return r(this,a),s=n(this,a,[t,i]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=i[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),s}return c(a,t),i(a)}(Ve),Op=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_channel_count"),a}return c(t,e),i(t)}(je),Up=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i}return c(t,e),i(t)}(Ve),Dp=function(t){function a(t){var i,s=t.userId,o=t.filter,u=t.includeFeedChannel,c=void 0!==u&&u;r(this,a),i=n(this,a);var l=o.channelCustomTypesFilter,d=o.superChannelFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/unread_message_count"),i.params={super_mode:null!=d?d:e.SuperChannelFilter.ALL,custom_types:l,include_feed_channel:c},i}return c(a,t),i(a)}(je),Rp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i.unreadFeedCount=a.unread_feed_count,i}return c(t,e),i(t)}(Ve),Lp=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledStatus,o=e.messageTypeFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ae,"/count"),a.params={channel_url:i,status:Fp(s)},o&&(a.params.message_type=o),a}return c(t,e),i(t)}(je),Pp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).count=a.count,i}return c(t,e),i(t)}(Ve),Fp=function(t){if(!t)return[];var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(Vs.PENDING);break;case e.ScheduledStatus.SENT:n.push(Vs.IN_QUEUE),n.push(Vs.SENT);break;case e.ScheduledStatus.CANCELED:n.push(Vs.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(Vs.FAILED)}})),n},qp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,d=e.isBroadcast,h=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,_=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,E=e.data,k=e.customType,b=e.messageSurvivalSeconds,C=e.invitedUserIds,w=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path=ke,a.params=pe({user_ids:[i].concat(v(null!=C?C:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:d,is_exclusive:f,is_public:h,is_discoverable:p,strict:_,is_ephemeral:m,access_code:g,name:y,data:E,custom_type:k,operator_ids:w,message_survival_seconds:b}),a}return c(t,e),i(t)}(je),Hp=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i.isCreated=null===(s=a.is_created)||void 0===s||s,i}return c(t,e),i(t)}(Ve),Gp=function(e){function t(e){var a,i=e.userId,s=e.channelUrls;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/mark_as_read_all"),a.params={channel_urls:s},a}return c(t,e),i(t)}(je),jp=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).event=new np(i),s}return c(t,e),i(t)}(Ke),Vp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/join"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(je),zp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),Bp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.users,f=void 0===h?null:h;return s.memberCount=c,s.joinedMemberCount=d,s.members=Array.isArray(f)?f.map((function(t){return new Zf(e,t)})):[new Zf(e,i.data)],s}return c(t,e),i(t)}(jp),Kp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.shouldRemoveOperatorStatus;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/leave"),a.params={user_id:s,should_remove_operator_status:o},a}return c(t,e),i(t)}(je),Qp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l;return s.memberCount=c,s.joinedMemberCount=d,s.member=new Zf(s._iid,i.data),s}return c(t,e),i(t)}(jp),Wp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/invite"),a.params={user_ids:s},a}return c(t,e),i(t)}(je),Yp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),Zp=function(e){function t(e,a,i){var s;r(this,t),(s=n(this,t,[e,a,i])).inviter=null;var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.inviter,f=o.invitees,p=void 0===f?[]:f;return s.memberCount=c,s.joinedMemberCount=d,h&&Object.keys(h).length>0&&(s.inviter=new si(e,h)),s.invitees=p.map((function(t){return new Zf(e,t)})),s}return c(t,e),i(t)}(jp),Xp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/decline"),a.params={user_id:s},a}return c(t,e),i(t)}(je),Jp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=o.joined_member_count,l=o.inviter,d=o.invitee;return s.memberCount=null!=u?u:0,s.joinedMemberCount=null!=c?c:0,s.inviter=new si(e,l),s.invitee=new Zf(e,d),s}return c(t,e),i(t)}(jp),$p={hidePreviousMessages:!1,allowAutoUnhide:!0},ev=function(e){return D("boolean",e.hidePreviousMessages,!0)&&D("boolean",e.allowAutoUnhide,!0)},tv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a.params={user_id:s,hide_previous_messages:null!=o?o:$p.hidePreviousMessages,allow_auto_unhide:null!=u?u:$p.allowAutoUnhide},a}return c(t,e),i(t)}(je),nv=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(Ve),rv=function(e){function t(e,a,i){var s,o,u,c;return r(this,t),(s=n(this,t,[e,"SYEV",i])).allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,i.data&&(s.allowAutoUnhide=null!==(o=i.data.allow_auto_unhide)&&void 0!==o?o:null,s.hidePreviousMessages=null!==(u=i.data.hide_previous_messages)&&void 0!==u?u:null),s.messageOffsetTimestamp=null!==(c=i.ts_message_offset)&&void 0!==c?c:null,s}return c(t,e),i(t)}(Ke),av=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(Qe),iv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new si(e,i.data),s}return c(t,e),i(t)}(Ke),sv=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(Qe),ov=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new si(e,i.data),s}return c(t,e),i(t)}(Ke),uv=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data.operators,u=void 0===o?[]:o;return s.operators=u.map((function(e){return new si(s._iid,e)})),s}return c(t,e),i(t)}(jp),cv=function(e){function t(e){var a=e.channelUrl,i=e.messageId;return r(this,t),n(this,t,[{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:i}}])}return c(t,e),i(t)}(Qe),lv=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x,S,T,I,N;return r(this,a),(s=n(this,a,[t,i])).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.includeChatNotification=!1,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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.includeChatNotification=null!==(l=i.includeChatNotification)&&void 0!==l&&l,s.channelUrlsFilter=null!==(d=i.channelUrlsFilter)&&void 0!==d?d:null,s.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(f=i.customTypeStartsWithFilter)&&void 0!==f?f:"",s.nicknameContainsFilter=null!==(p=i.nicknameContainsFilter)&&void 0!==p?p:null,s.nicknameStartsWithFilter=null!==(v=i.nicknameStartsWithFilter)&&void 0!==v?v:null,s.nicknameExactMatchFilter=null!==(_=i.nicknameExactMatchFilter)&&void 0!==_?_:null,s.channelNameContainsFilter=null!==(m=i.channelNameContainsFilter)&&void 0!==m?m:"",s.myMemberStateFilter=null!==(g=i.myMemberStateFilter)&&void 0!==g?g:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(y=i.unreadChannelFilter)&&void 0!==y?y:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(E=i.superChannelFilter)&&void 0!==E?E:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=i.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=i.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(C=i.searchFilter)&&void 0!==C?C:{fields:[],query:null},s.userIdsFilter=null!==(w=i.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(x=i.metadataKey)&&void 0!==x?x:null,s.metadataValues=null!==(S=i.metadataValues)&&void 0!==S?S:null,s.metadataOrderKeyFilter=null!==(T=i.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(I=i.metadataValueStartsWith)&&void 0!==I?I:null,s.order=null!==(N=i.order)&&void 0!==N?N:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i.createdAfter&&(s.createdAfter=i.createdAfter),i.createdBefore&&(s.createdBefore=i.createdBefore),s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter)&&D("string",this.nicknameContainsFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)&&D("string",this.nicknameExactMatchFilter,!0)&&R(e.MyMemberStateFilter,this.myMemberStateFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicChannelFilter,this.publicChannelFilter)&&R(e.UnreadChannelFilter,this.unreadChannelFilter)&&R(e.HiddenChannelFilter,this.hiddenChannelFilter)&&P(e.GroupChannelSearchField,this.searchFilter.fields)&&D("string",this.searchFilter.query,!0)&&P("string",this.userIdsFilter.userIds)&&D("boolean",this.userIdsFilter.includeMode)&&R(e.QueryType,this.userIdsFilter.queryType)&&R(e.GroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)&&F(this.createdAfter,!0)&&F(this.createdBefore,!0)}},{key:"serialize",value:function(){return ni(this)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._validate()){t.next=20;break}if(this._isLoading){t.next=17;break}if(!this._hasNext){t.next=14;break}return this._isLoading=!0,n=Cv.of(this._iid),t.next=7,n.getMyGroupChannels(this._token,ve(Object.assign({},this)),this.limit,e.CollectionEventSource.REQUEST_CHANNEL,!0);case 7:return r=t.sent,a=r.channels,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,t.abrupt("return",a);case 14:return t.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:t.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return t.stop()}}),t,this)})))}}])}(uu),dv=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"SYEV",i])).pinnedMessageIds=[],s.latestPinnedMessage=null,s.ts=0,i.data&&(s.pinnedMessageIds=null!==(o=i.data.pinned_message_ids)&&void 0!==o?o:[],s.latestPinnedMessage=i.data.latest_pinned_message?ho(e,Object.assign({},i.data.latest_pinned_message)):null),s.ts=i.ts,s}return c(t,e),i(t)}(Ke),hv=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e]))._logger=a.logger,i._sdkState=a.sdkState,i._sessionManager=a.sessionManager,i._requestQueue=a.requestQueue,i._dispatcher=a.dispatcher,i._cacheContext=a.cacheContext,i._channelType=a.channelType,i}return c(t,e),i(t,[{key:"_messageBroadcast",get:function(){return Zd.of(this._iid)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"getMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null);case 1:case"end":return e.stop()}}),e)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r,a,i){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",0);case 1:case"end":return e.stop()}}),e)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}(Ya),fv=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"ADMM",i])).message=new Js(e,i);var d=es.of(e).sdkState;return s.isMentioned=Fe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),pv=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"AEDI",i])).message=new Js(e,i);var h=es.of(e).sdkState;return s.mentionCountChange=qe({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),vv=function(e){function t(e){var a,i=e.channelUrl,s=e.userId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/messages/mark_as_delivered"),a.params=pe({userId:s}),a}return c(t,e),i(t)}(je),_v=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"DLVR",i])).channelUrl=i.channel_url,s.deliveredStateUpdate=i.updated,s}return c(t,e),i(t)}(Ke),mv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MRCT",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.event=new os(i),s}return c(t,e),i(t)}(Ke),gv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MTHD",i])).event=new rh(e,i),s}return c(t,e),i(t)}(Ke),yv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MCNT",i])).groupChannelMemberCounts=i.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=i.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return c(t,e),i(t)}(Ke),Ev=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"PEDI",i])).event=new Eh(e,i),s.status=no(i.poll.status)||i.poll.status,s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),kv=function(){return i((function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,i=t.bottom,s=void 0===i?0:i;r(this,e),this.top=a,this.bottom=s}),[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0&&r.onMentionReceived&&r.onMentionReceived(T,w)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 63:return a.abrupt("break",344);case 64:if(D=t.as(lt),R=D.channelUrl,L=D.channelType,P=D.messageId,F=D.silent,q=D.messageCreatedAt,H=D.senderId,L!==e.ChannelType.GROUP){a.next=73;break}return a.next=68,this.getChannel(R,!0);case 68:G=a.sent,j=H===this._sdkState.userId,F||j||q>0&&G.myLastRead0&&G._updateUnreadCount(G.unreadMessageCount-1,0),this._dispatcher.dispatch(new Us({messageIds:[P],source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onMessageDeleted&&r.onMessageDeleted(G,P)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 73:return a.abrupt("break",344);case 74:if(V=t.as(Es),(z=V.readStatus).channelType!==e.ChannelType.GROUP){a.next=82;break}return B=this._groupChannelCache.isCachedInMemory(z.channelUrl),a.next=79,this.getChannel(z.channelUrl,!0);case 79:K=a.sent,B&&K._updateUnreadMemberState(z.reader.userId,z.readAt),z.reader.userId===this._sdkState.userId?B?(K.unreadMessageCount>0||K.unreadMentionCount>0)&&(K._updateUnreadCount(0,0),this._dispatcher.dispatch(new gp({channels:[K],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(K)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==K.unreadMessageCount&&0!==K.unreadMentionCount||(this._dispatcher.dispatch(new gp({channels:[K],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(K)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new gp({channels:[K],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUnreadMemberStatusUpdated&&r.onUnreadMemberStatusUpdated(K)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 82:return a.abrupt("break",344);case 83:return Q=t.as(_v),W=Q.channelUrl,Y=Q.deliveredStateUpdate,Z=void 0===Y?{}:Y,X=this._groupChannelCache.isCachedInMemory(W),a.next=87,this.getChannel(W,!0);case 87:return J=a.sent,X&&Object.keys(Z).forEach((function(e){J._updateUndeliveredMemberState(e,Z[e])})),Object.keys(Z).some((function(e){return e!==mn._sdkState.userId}))&&(this._dispatcher.dispatch(new gp({channels:[J],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELIVERED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUndeliveredMemberStatusUpdated&&r.onUndeliveredMemberStatusUpdated(J)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 91:if($=t.as(mv),ee=$.channelUrl,te=$.channelType,ne=$.event,te!==e.ChannelType.GROUP){a.next=101;break}return a.next=95,this.getChannel(ee,!0);case 95:return re=a.sent,a.next=98,this.getMessageFromCache(ne.messageId);case 98:(ae=a.sent)?ae instanceof Ws&&(ae.applyReactionEvent(ne),this._dispatcher.dispatch(new Os({messages:[ae],source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new Ds({event:ne,source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onReactionUpdated&&r.onReactionUpdated(re,ne)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 101:return a.abrupt("break",344);case 102:if(ie=t.as(gv),(se=ie.event).channelType!==e.ChannelType.GROUP){a.next=112;break}return a.next=106,this.getChannel(se.channelUrl,!0);case 106:return oe=a.sent,a.next=109,this.getMessageFromCache(se.targetMessageId);case 109:(ue=a.sent)?ue instanceof Ws&&(ue.applyThreadInfoUpdateEvent(se),this._dispatcher.dispatch(new Os({messages:[ue],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new Rs({event:se,source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onThreadInfoUpdated&&r.onThreadInfoUpdated(oe,se)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 112:return a.abrupt("break",344);case 113:ce=t.as(yv),le=ce.groupChannelMemberCounts,de=[],he=s(le),a.prev=116,he.s();case 118:if((fe=he.n()).done){a.next=127;break}return pe=fe.value,ve=pe.channelUrl,_e=pe.memberCount,me=pe.joinedMemberCount,ge=pe.updatedAt,a.next=123,this.getChannelFromCache(ve);case 123:(ye=a.sent)&&ye._setLatestMemberCount(_e,me,ge)&&de.push(ye);case 125:a.next=118;break;case 127:a.next=132;break;case 129:a.prev=129,a.t2=a.catch(116),he.e(a.t2);case 132:return a.prev=132,he.f(),a.finish(132);case 135:return de.length>0&&(this._dispatcher.dispatch(new gp({channels:de,context:{source:e.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(de)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 137:if(Ee=t.as(Ev),ke=Ee.event,be=Ee.status,Ce=Ee.channelUrl,we=Ee.channelType,!Ce||we!==e.ChannelType.GROUP){a.next=144;break}return a.next=141,this.getChannel(Ce,!0);case 141:xe=a.sent,this._dispatcher.dispatch(new Fs({event:ke,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),hi(be===to?function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(xe,ke.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(xe,ke)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 144:return a.abrupt("break",344);case 145:if(Se=t.as(Oc),Te=Se.event,Ie=Se.channelUrl,Ne=Se.channelType,!Ie||Ne!==e.ChannelType.GROUP){a.next=152;break}return a.next=149,this.getChannel(Ie,!0);case 149:Ae=a.sent,this._dispatcher.dispatch(new qs({event:Te,source:e.CollectionEventSource.EVENT_POLL_VOTED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(Ae,Te)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 152:return a.abrupt("break",344);case 153:if(Me=t.as(jp),!(Oe=Me.event).isGroupChannelEvent){a.next=332;break}a.t3=Oe.category,a.next=a.t3===Jf.CHANNEL_JOIN?158:a.t3===Jf.CHANNEL_LEAVE?167:a.t3===Jf.CHANNEL_OPERATOR_UPDATE?183:a.t3===Jf.CHANNEL_INVITE?194:a.t3===Jf.CHANNEL_DECLINE_INVITE?204:a.t3===Jf.TYPING_START||a.t3===Jf.TYPING_END?212:a.t3===Jf.USER_CHANNEL_MUTE||a.t3===Jf.USER_CHANNEL_UNMUTE?221:a.t3===Jf.USER_CHANNEL_BAN?248:a.t3===Jf.USER_CHANNEL_UNBAN?263:a.t3===Jf.CHANNEL_FREEZE||a.t3===Jf.CHANNEL_UNFREEZE?271:a.t3===Jf.CHANNEL_HIDE?279:a.t3===Jf.CHANNEL_UNHIDE?289:a.t3===Jf.CHANNEL_DELETED?296:a.t3===Jf.CHANNEL_PROP_CHANGED?302:a.t3===Jf.CHANNEL_META_DATA_CHANGED?308:a.t3===Jf.CHANNEL_META_COUNTERS_CHANGED?317:a.t3===Jf.PINNED_MESSAGE_CHANGED?326:332;break;case 158:return a.next=160,this.getChannel(Oe.channelUrl,!0);case 160:return Ue=a.sent,De=t.as(Bp),Re=De.memberCount,Le=De.joinedMemberCount,Pe=De.members,Fe=!1,Pe.forEach((function(t){Ue.isExclusive||Ue.isSuper||Ue.isBroadcast?Fe=Fe||Ue._setLatestMemberCount(Re,Le,Oe.ts):(t.state=e.MemberState.JOINED,Ue.addMember(t,Oe.ts),mn._updateJoinedMemberCount(Ue)),t.userId===mn._sdkState.userId&&(Ue.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new gp({channels:[Ue],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:Pe}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=s(Pe);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ue,r)}}catch(e){n.e(e)}finally{n.f()}Ue.isBroadcast&&Fe&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ue])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 167:if(!(qe=this._leftChannels.get(Oe.channelUrl))){a.next=172;break}a.t4=qe.channel,a.next=175;break;case 172:return a.next=174,this.getChannel(Oe.channelUrl,!0);case 174:a.t4=a.sent;case 175:return He=a.t4,Ge=t.as(Qp),je=Ge.memberCount,Ve=Ge.joinedMemberCount,ze=Ge.member,Be=!1,Ke=es.of(this._iid),Qe=Ke.appInfo,He.isExclusive||He.isSuper||He.isBroadcast?Be=He._setLatestMemberCount(je,Ve,Oe.ts):((null==Qe?void 0:Qe.enabledChannelMemberShipHistory)?((We=He.members.find((function(e){return e.userId===ze.userId})))&&(We.state=e.MemberState.LEFT),He.memberCount=je):He.removeMember(ze),this._updateJoinedMemberCount(He)),ze.userId===this._sdkState.userId?(He.myMemberState=e.MemberState.NONE,He.invitedAt=0,He.joinedAt=0,He._updateUnreadCount(0,0),He.isPublic?this._dispatcher.dispatch(new gp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})):(this._markAsLeave(He),this._dispatcher.dispatch(new yp({channelUrls:[He.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})))):this._dispatcher.dispatch(new gp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(He,ze),He.isBroadcast&&Be&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([He])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 183:return a.next=185,this.getChannel(Oe.channelUrl,!0);case 185:Ye=a.sent,Ze=t.as(uv),Xe=Ze.operators,Je=Xe.map((function(e){return e.userId})),$e=s(Ye.members);try{for($e.s();!(et=$e.n()).done;)(tt=et.value).role=Je.includes(tt.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){$e.e(e)}finally{$e.f()}return Ye.myRole=Je.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new gp({channels:[Ye],context:{source:e.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Xe}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ye,Xe)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 194:return a.next=196,this.getChannel(Oe.channelUrl,!0);case 196:nt=a.sent,rt=t.as(Zp),at=rt.memberCount,it=rt.joinedMemberCount,st=rt.inviter,(ot=rt.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),ut=s(ot);try{for(ut.s();!(ct=ut.n()).done;)dt=ct.value,nt.isExclusive||nt.isSuper||nt.isBroadcast?nt._setLatestMemberCount(at,it,Oe.ts):nt.addMember(dt,Oe.ts),this._sdkState.userId===dt.userId&&(nt.hiddenState=e.HiddenState.UNHIDDEN,nt.myMemberState!==e.MemberState.JOINED&&(nt.myMemberState=e.MemberState.INVITED),nt.invitedAt=Oe.ts)}catch(e){ut.e(e)}finally{ut.f()}return this._dispatcher.dispatch(new gp({channels:[nt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:st,invitees:ot}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(nt,st,ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 204:return a.next=206,this.getChannel(Oe.channelUrl,!0);case 206:return ht=a.sent,ft=t.as(Jp),pt=ft.memberCount,vt=ft.joinedMemberCount,_t=ft.inviter,mt=ft.invitee,ht.isExclusive||ht.isSuper||ht.isBroadcast?ht._setLatestMemberCount(pt,vt,Oe.ts):ht.removeMember(mt),this._sdkState.userId===mt.userId?(ht.invitedAt=0,ht.myMemberState=e.MemberState.NONE,ht.isPublic?this._dispatcher.dispatch(new gp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})):this._dispatcher.dispatch(new yp({channelUrls:[ht.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}}))):this._dispatcher.dispatch(new gp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ht,_t,mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 212:return a.next=214,this.getChannel(Oe.channelUrl,!0);case 214:return gt=a.sent,yt=Oe.category===Jf.TYPING_START,Et=t.as(yt?iv:ov),kt=Et.user,gt._updateTypingStatus(kt,yt?Oe.ts:0),this._dispatcher.dispatch(new gp({channels:[gt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(gt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 221:return a.next=223,this.getChannel(Oe.channelUrl,!0);case 223:bt=a.sent,Ct=Oe.category===Jf.USER_CHANNEL_MUTE,wt=t.as(Ct?Bu:Qu),(xt=wt.user).userId===this._sdkState.userId&&(bt.myMutedState=Ct?e.MutedState.MUTED:e.MutedState.UNMUTED,bt._myMutedRemainingTime=xt.restrictionInfo.remainingDuration),St=s(bt.members),a.prev=228,St.s();case 230:if((Tt=St.n()).done){a.next=237;break}if((It=Tt.value).userId!==xt.userId){a.next=235;break}return It.isMuted=Ct,a.abrupt("break",237);case 235:a.next=230;break;case 237:a.next=242;break;case 239:a.prev=239,a.t5=a.catch(228),St.e(a.t5);case 242:return a.prev=242,St.f(),a.finish(242);case 245:return this._dispatcher.dispatch(new gp({channels:[bt],context:{source:Ct?e.CollectionEventSource.EVENT_CHANNEL_MUTED:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:xt}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ct?e.onUserMuted&&e.onUserMuted(bt,xt):e.onUserUnmuted&&e.onUserUnmuted(bt,xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 248:if(!(Nt=this._leftChannels.get(Oe.channelUrl))){a.next=253;break}a.t6=Nt.channel,a.next=256;break;case 253:return a.next=255,this.getChannel(Oe.channelUrl,!0);case 255:a.t6=a.sent;case 256:return At=a.t6,this._markAsLeave(At),Mt=t.as(Yu),Ot=Mt.user,Ot.userId===this._sdkState.userId&&this._dispatcher.dispatch(new yp({channelUrls:[At.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_BANNED,user:Ot}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(At,Ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 263:return a.next=265,this.getChannel(Oe.channelUrl,!0);case 265:return Ut=a.sent,Dt=t.as(Xu),Rt=Dt.user,Rt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new yp({channelUrls:[Ut.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:Rt}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(Ut,Rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 271:return a.next=273,this.getChannel(Oe.channelUrl,!0);case 273:return Lt=a.sent,Pt=t.as($u),Ft=Pt.freeze,Lt.isFrozen=Ft,this._dispatcher.dispatch(new gp({channels:[Lt],context:{source:Ft?e.CollectionEventSource.EVENT_CHANNEL_FROZEN:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ft?e.onChannelFrozen&&e.onChannelFrozen(Lt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 279:return a.next=281,this.getChannel(Oe.channelUrl,!0);case 281:return qt=a.sent,Ht=t.as(rv),Gt=Ht.allowAutoUnhide,jt=Ht.hidePreviousMessages,Vt=Ht.messageOffsetTimestamp,null!==Gt&&(qt.hiddenState=Gt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==jt&&jt&&qt._updateUnreadCount(0,0),null!==Vt&&(qt.messageOffsetTimestamp=Vt),this._dispatcher.dispatch(new gp({channels:[qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 289:return a.next=291,this.getChannel(Oe.channelUrl,!0);case 291:return(zt=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new gp({channels:[zt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(zt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 296:return a.next=298,this.getChannel(Oe.channelUrl,!0);case 298:return Bt=a.sent,this._dispatcher.dispatch(new yp({channelUrls:[Oe.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Bt.url,Bt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 302:return a.next=304,this.getChannelWithoutCache(Oe.channelUrl,!0);case 304:return Kt=a.sent,this._dispatcher.dispatch(new gp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Kt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 308:return a.next=310,this.getChannel(Oe.channelUrl,!0);case 310:return Qt=a.sent,Wt=t.as(Au),Yt=Wt.created,Zt=Wt.updated,Xt=Wt.deleted,Yt&&(Qt._upsertCachedMetaData(Yt,Oe.ts),this._dispatcher.dispatch(new gp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:Yt},ts:Oe.ts}))),Zt&&(Qt._upsertCachedMetaData(Zt,Oe.ts),this._dispatcher.dispatch(new gp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:Zt},ts:Oe.ts}))),Xt&&(Qt._removeFromCachedMetaData(Xt,Oe.ts),this._dispatcher.dispatch(new gp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:Xt},ts:Oe.ts}))),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Yt&&e.onMetaDataCreated&&e.onMetaDataCreated(Qt,Yt),Zt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Qt,Zt),Xt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Qt,Xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 317:return a.next=319,this.getChannel(Oe.channelUrl,!0);case 319:return Jt=a.sent,$t=t.as(Gu),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&this._dispatcher.dispatch(new gp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:en}})),tn&&this._dispatcher.dispatch(new gp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:tn}})),nn&&this._dispatcher.dispatch(new gp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:nn}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){en&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Jt,en),tn&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Jt,tn),nn&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Jt,nn)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 326:return a.next=328,this.getChannel(Oe.channelUrl,!0);case 328:return rn=a.sent,an=t.as(dv),sn=an.pinnedMessageIds,on=an.latestPinnedMessage,(un=an.ts)>rn._pinnedMessagesUpdatedAt&&(rn.pinnedMessageIds=null!=sn?sn:[],rn.lastPinnedMessage=on,rn._pinnedMessagesUpdatedAt=un,this._dispatcher.dispatch(new gp({channels:[rn],context:{source:e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(rn)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(rn)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",332);case 332:return a.abrupt("break",344);case 333:cn=t.as(qh),ln=cn.event,a.t7=ln.category,a.next=a.t7===wh.USER_BLOCK?337:a.t7===wh.USER_UNBLOCK?340:343;break;case 337:return dn=Rh.getDataAsUserBlockEvent(this._iid,ln),hn=dn.blocker,fn=dn.blockee,this._groupChannelCache.block(hn.userId,fn.userId),a.abrupt("break",343);case 340:return pn=Rh.getDataAsUserBlockEvent(this._iid,ln),vn=pn.blocker,_n=pn.blockee,this._groupChannelCache.unblock(vn.userId,_n.userId),a.abrupt("break",343);case 343:return a.abrupt("break",344);case 344:a.next=350;break;case 346:if(a.prev=346,a.t8=a.catch(0),!N(a.t8)){a.next=350;break}throw a.t8;case 350:case"end":return a.stop()}}),a,this,[[0,346],[18,29,32,35],[116,129,132,135],[228,239,242,245]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",t)).throw(A.invalidParameters),a=new Cp({channelUrl:t,isInternalCall:n}),r.next=4,this._requestQueue.send(a);case 4:i=r.sent,s=i.as(wp),o=s.channel,u=o.unreadMessageCount,c=o.unreadMentionCount,r.t0=o.myCountPreference,r.next=r.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:r.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:r.t0===e.CountPreference.OFF?14:17;break;case 10:return c=0,r.abrupt("break",17);case 12:return u=0,r.abrupt("break",17);case 14:return u=0,c=0,r.abrupt("break",17);case 17:return o._updateUnreadCount(u,c),r.next=20,this.upsertChannelsToCache([o]);case 20:return r.abrupt("return",r.sent[0]);case 21:case"end":return r.stop()}}),r,this)})))}},{key:"refreshChannel",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REFRESH_CHANNEL,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,s=new Cp({channelUrl:t,isInternalCall:n,showLatestMessage:a}),i.next=4,this._requestQueue.send(s);case 4:if(o=i.sent,u=o.as(wp),(c=u.channel).myMemberState!==e.MemberState.NONE){i.next=10;break}this._dispatcher.dispatch(new yp({channelUrls:[c.url],context:{source:r}})),i.next=14;break;case 10:return i.next=12,this.upsertChannelsToCache([c]);case 12:l=i.sent,this._dispatcher.dispatch(new gp({channels:l,context:{source:r}}));case 14:i.next=19;break;case 16:i.prev=16,i.t0=i.catch(0),i.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&i.t0.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new yp({channelUrls:[t],context:{source:r}}));case 19:case"end":return i.stop()}}),i,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_CHANNEL,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p,v;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.createdAfter&&(n.createdAfter=Math.floor(n.createdAfter/1e3)),n.createdBefore&&(n.createdBefore=Math.floor(n.createdBefore/1e3)),s=!1,i&&(o=es.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(s=!0)),l=new Sp(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:r,includeLeftChannel:i&&s})),e.next=7,this._requestQueue.send(l);case 7:return h=e.sent,f=h.as(Tp),p=f.channels,v=f.token,this._dispatcher.dispatch(new gp({channels:p,context:{source:a}})),e.abrupt("return",{channels:p,token:v});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Object.assign(Object.assign({},ip),n),ai((D("string",t)||D("number",t))&&sp(a)).throw(A.invalidParameters),i=new kp(ve({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,filter:a})),e.next=5,this._requestQueue.send(i);case 5:return s=e.sent,o=s.as(bp),u=o.updatedChannels,c=o.deletedChannelUrls,l=o.hasMore,h=o.ts,u.length>0&&this._dispatcher.dispatch(new gp({channels:u,context:{source:r},ts:h})),c.length>0&&this._dispatcher.dispatch(new yp({channelUrls:c,context:{source:r}})),e.abrupt("return",{updatedChannels:u,deletedChannelUrls:c,hasMore:l,token:o.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},op),e),ai(up(n)).throw(A.invalidParameters),r=new Ip({userId:this._sdkState.userId,filter:n}),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Np),s=i.groupChannelCount,t.abrupt("return",s);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},lp),e),ai(dp(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Ap({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Mp),c=u.groupChannelUnreadMentionCount,l=u.groupChannelUnreadMessageCount,h=u.groupChannelInvitationCount,f=u.superGroupChannelUnreadMentionCount,p=u.superGroupChannelUnreadMessageCount,v=u.superGroupChannelInvitationCount,_=u.nonSuperGroupChannelUnreadMentionCount,m=u.nonSuperGroupChannelUnreadMessageCount,g=u.nonSuperGroupChannelInvitationCount,t.abrupt("return",pe({groupChannelUnreadMentionCount:c,groupChannelUnreadMessageCount:l,groupChannelInvitationCount:h,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Op({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Up),o=s.unreadCount,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},hp),e),ai(fp(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Dp({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Rp),c=u.unreadCount,t.abrupt("return",c);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},pp),e),ai(vp(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new Lp(n),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Pp),u=o.count,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=es.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=es.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=es.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},rp),e),ai(ap(n)).throw(A.invalidParameters),n.isPublic||(n.accessCode=void 0),r=new qp(Object.assign({userId:this._sdkState.userId},n)),t.next=6,this._requestQueue.send(r);case 6:return a=t.sent,i=a.as(Hp),s=i.channel,t.next=10,this.upsertChannelsToCache([s]);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Date.now(),ai(t-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Gp({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(n);case 6:r=this._groupChannelCache.channels,a=s(r);try{for(a.s();!(i=a.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0)}catch(e){a.e(e)}finally{a.f()}if(!(r.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(r);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),ai(P("string",e)&&n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new Gp({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,i=[],o=s(a);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,n),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()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return n=t.sent,t.next=5,n.markAsDelivered();case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._messageCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0});case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),r,this)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:100,i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return E(this,void 0,void 0,d().mark((function s(){return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i});case 2:return s.abrupt("return",s.sent);case 3:case"end":return s.stop()}}),s,this)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.countBetween(e,t,new kv({top:n,bottom:r}));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:t});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return bv[e]||(bv[e]=new a(e,es.of(e))),bv[e]}},{key:"clear",value:function(e){bv[e]&&delete bv[e]}}])}(hv),wv=function(e,t){return t instanceof Ys?e.findIndex((function(e){return e instanceof Ys&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},xv=function(e,t){return e.findIndex((function(e){return e instanceof Ws?e.messageId===t:e instanceof co?e.notificationId===t:void 0}))},Sv=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(i<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(cp||(cp={}));var Tv=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t))._state=cp.IDLE,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=a,i}return c(t,e),i(t,[{key:"isIdle",get:function(){return this._state===cp.IDLE}},{key:"isRunning",get:function(){return this._state===cp.RUNNING}},{key:"isDone",get:function(){return this._state===cp.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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:n=t.sent,this._retryCount=0,this.dispatch("progress",n),n.hasNext?this._run(n.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(E=_.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(y=u.range).intersect.apply(y,v(E)))?this.extendRange(_):this._metadata={range:new kv({top:Math.min.apply(Math,v(E)),bottom:Math.max.apply(Math,v(E))}),previousComplete:!1}),h.hasNext=_.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(h.nextToken=this._metadata.range.top,this._metadata.previousComplete=_.length0&&(y=f.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(_=o.range).intersect.apply(_,v(y)))?this.extendRange(f):this._metadata={range:new kv({top:Math.min.apply(Math,v(y)),bottom:Math.max.apply(Math,v(y))}),previousComplete:!1}),l.hasNext=f.length>=this._limit,this._metadata&&(l.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",l),n.next=15,this.saveMetadata();case 15:n.next=21;break;case 17:throw n.prev=17,n.t0=n.catch(4),m.debug("message background next sync error",n.t0),n.t0;case 21:return n.prev=21,g.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:s.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=p.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.finish(21);case 24:return n.abrupt("return",l);case 25:case"end":return n.stop()}}),n,this,[[4,17,21,24]])})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=_.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 kv({})}},{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,v(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,v(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{range:new kv(r.range),previousComplete:r.previousComplete}:{range:new kv({}),previousComplete:!1};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,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.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,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now(),i=es.of(this._iid),s=i.logger,o=i.sessionManager;i.cacheContext.localCacheEnabled&&o.session.hasSession&&(s.debug("message background sync resume()"),this._prevSyncLoopCount=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(){es.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 Iv[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n){return Iv[e]||(Iv[e]={}),Iv[e][n.url]||(Iv[e][n.url]=new t({_iid:e,channel:n})),Iv[e][n.url].ref++,Iv[e][n.url]}},{key:"clear",value:function(e,t){Iv[e]&&Iv[e][t]&&(Iv[e][t].close(),delete Iv[e])}}])}(),Av={},Mv=function(){function t(n){var a=this,i=n._iid,s=n.channel,o=n.includeParams;r(this,t),this.ref=0,this._iid=i,this._channel=s,this._includeParams=o;var u,c,l=es.of(this._iid),h=l.logger,f=l.sdkState,p=l.dispatcher;this._metadataKey=(u=f.userId,c=s.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var v=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(f.userId,this._channel.url);this._sync=new Tv(v,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,a=nh.of(this._iid),t.next=8,a.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:e.ReplyType.ALL},this._includeParams),e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,s=i.updatedMessages,o=i.deletedMessageIds,u=i.hasMore,c=i.token,r.hasNext=u,r.nextToken=c,(s.length>0||o.length>0)&&this._metadata&&(this._metadata.token=c),h.debug("message changelog sync progress",r),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),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",r);case 29:case"end":return t.stop()}}),t,this,[[4,21]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.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=es.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){es.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Av[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n,r){return Av[e]||(Av[e]={}),Av[e][n.url]||(Av[e][n.url]=new t({_iid:e,channel:n,includeParams:r})),Av[e][n.url].ref++,Av[e][n.url]}},{key:"clear",value:function(e,t){Av[e]&&Av[e][t]&&(Av[e][t].close(),delete Av[e])}}])}(),Ov={},Uv=function(){function e(t){var n=this,a=t._iid,i=t.channel,s=t.hasPollMessage;r(this,e),this.ref=0,this._iid=a,this._channel=i;var o,u,c=es.of(this._iid),l=c.logger,h=c.sdkState,f=c.dispatcher;this._metadataKey=(o=h.userId,u=i.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new Tv(p,(function(){return E(n,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o,u,c,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(l.debug("poll changelog sync from",null===(t=this._metadata)||void 0===t?void 0:t.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,s();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return r={hasNext:!1,nextToken:0},e.abrupt("return",r);case 12:return this._metadata||(a=es.of(this._iid),i=a.firstConnectedAt,this._metadata={token:i}),e.prev=13,o=Wc.of(this._iid),e.next=17,o.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return u=e.sent,c=u.hasMore,h=u.token,n.hasNext=c,n.nextToken=h,this._metadata.token=h,l.debug("poll changelog sync progress",n),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),l.debug("poll changelog sync error",e.t1),!(e.t1 instanceof 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",n);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)n.resume();else n.pause()}))}return i(e,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{token:r.token}:void 0;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){es.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){es.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 Ov[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Ov[t]||(Ov[t]={}),Ov[t][n.url]||(Ov[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Ov[t][n.url].ref++,Ov[t][n.url]}}])}(),Dv=function(t){function a(t){var i,s,o,u,c,l,d,h,f,p,v;return r(this,a),(i=n(this,a)).method=_e.GET,i.path="".concat(Le(t.channelType),"/").concat(t.channelUrl,"/messages_gap"),i.params=pe({prev_start_ts:t.prevStart,prev_end_ts:t.prevEnd,prev_cache_count:t.prevCount,next_start_ts:t.nextStart,next_end_ts:t.nextEnd,next_cache_count:t.nextCount,huge_gap_threshold:null!==(s=t.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(o=t.customTypes)&&void 0!==o?o:["*"],message_type:null!==(u=t.messageType)&&void 0!==u?u:null,include_reply_type:null!==(c=t.replyType)&&void 0!==c?c:e.ReplyType.NONE,include_reactions:null===(l=t.includeReactions)||void 0===l||l,include_meta_array:null===(d=t.includeMetaArray)||void 0===d||d,include_thread_info:null===(h=t.includeThreadInfo)||void 0===h||h,include_parent_message_info:null===(f=t.includeParentMessageInfo)||void 0===f||f,with_sorted_meta_array:null===(p=t.includeMetaArray)||void 0===p||p,show_subchannel_messages_only:null!==(v=t.showSubchannelMessagesOnly)&&void 0!==v&&v,include_poll_details:!0,checking_continuous_messages:t.checkingContinuousMessages}),i}return c(a,t),i(a)}(je),Rv=function(e){function t(e,a){var i,s,o,u,c,l,d;return r(this,t),(i=n(this,t,[e,a])).isHugeGap=a.is_huge_gap,i.prevMessages=(null!==(s=a.prev_messages)&&void 0!==s?s:[]).map((function(t){return ho(e,t)})),i.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,i.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,i.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return ho(e,t)})),i.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,i.isContinuousNextMessages=null!==(d=a.is_continuous_next_messages)&&void 0!==d&&d,i}return c(t,e),i(t)}(Ve),Lv={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var Pv,Fv,qv,Hv=function(){return i((function e(){r(this,e),this._onCacheResult=ht,this._onApiResult=ht}),[{key:"_invokeResponse",value:function(e,t,n){var r=this;hi((function(){return E(r,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next="local"===r.t0?3:"remote"===r.t0?5:7;break;case 3:return this._onCacheResult(t,n),r.abrupt("break",7);case 5:return this._onApiResult(t,n),r.abrupt("break",7);case 7:case"end":return r.stop()}}),r,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}])}(),Gv=function(){return i((function t(n,a){var i=this,o=a.filter,u=a.startingPoint,c=a.limit,l=a.prevResultLimit,h=a.nextResultLimit,f=a.channel,p=a.channelManager,_=a.disableBackgroundSync,m=void 0!==_&&_;r(this,t),this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=n,this._key="mc-".concat(ce()),this._isDisposed=!1,this.filter=null!=o?o:new Pd,this._channel=f,this._syncRange=new kv({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof u&&Number.isFinite(u)?u:Number.MAX_SAFE_INTEGER,this._limit=c||100,this._prevResultLimit=null!=l?l:Math.floor(this._limit/2),this._nextResultLimit=null!=h?h:Math.floor(this._limit/2),this._channelManager=p;var g=es.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(t,n){var r=n.source,a=t.findIndex((function(e){return e.isIdentical(i.channel)}));a>=0&&(i._replaceChannelOfCollection(t[a]),i.channel._runIfHandleableWithGroupChannel((function(t){switch(r){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:for(var a=!1,s=0;s=t.messageOffsetTimestamp){a=!0;var o=s;if(o>0){var u=i._messages.splice(0,o);i._removeMessagesFromView(u.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!a&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.CollectionEventSource.EVENT_CHANNEL_UNMUTED:var c=es.of(i._iid).sdkState,l=n.user;c.userId===l.userId&&i._clearCheckMyMutedTimer();break;case e.CollectionEventSource.EVENT_CHANNEL_MUTED:var h=es.of(i._iid).sdkState,f=n.user;h.userId===f.userId&&-1!==t._myMutedRemainingTime&&i._startCheckMyMutedTimer(t._myMutedRemainingTime);break;case e.CollectionEventSource.EVENT_CHANNEL_LEFT:t.isPublic&&i._clearCheckMyMutedTimer()}hi((function(){return E(i,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:mp(r)&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelUpdated)&&this._handler.onChannelUpdated(n,this.channel);case 1:case"end":return e.stop()}}),e,this)})))}))})),i._postprocessChannelUpdateEvent(t[a],r))},onRemove:function(e,t){var n=e.indexOf(i.channel.url);n>=0&&(i._clearCheckMyMutedTimer(),hi((function(){return E(i,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url);case 1:case"end":return e.stop()}}),e,this)})))})),i._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],o=[],u=s(t);try{for(u.s();!(r=u.n()).done;){var c=r.value;c.channelUrl===i._channel.url&&(i.filter.match(c)?a.push(c):o.push(i.keyOf(c)))}}catch(e){u.e(e)}finally{u.f()}if(Ms(n)){if(a.length>0)switch(n){case e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.CollectionEventSource.EVENT_MESSAGE_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.CollectionEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}o.length>0&&i._removeMessagesFromView(o,n)}i._postprocessMessageUpdateEvent(t,n)},onRemove:function(e,t){i._removeMessagesFromView(e,t),i._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:function(e,t){i._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){i._applyThreadInfoEventToView(e,t)}});var y=es.of(this._iid),k=y.cacheContext,b=y.dispatcher,C=y.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),b.dispatch(new gp({channels:[this._channel],context:{source:e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Nv.of(this._iid,this._channel),!m&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=Mv.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Uv.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Tv(this._key,(function(t){return E(i,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,C.run("message-fill-sync-".concat(f.url,"-prev"),(function(){return E(r,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._getRemoteMessages(t,{prevLimit:this._prevResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:k.localCacheEnabled});case 2:if(s=n.sent,o=s.messages,u=s.isContinuousMessages,!(o.length>0)){n.next=10;break}return c=Math.min.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:o.length>=this._prevResultLimit&&this.viewTop0)){n.next=10;break}return c=Math.max.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:!(o.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>c,nextToken:this._syncRange.bottom});case 10:return k.localCacheEnabled&&g.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=k.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:k.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.abrupt("return",{hasNext:!1,nextToken:0});case 12:case"end":return n.stop()}}),n,this)})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=b.on((function(e){if(e instanceof La)switch(e.stateType){case Aa.CONNECTED:fi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._activate();case 1:case"end":return e.stop()}}),e,this)})))}));break;case Aa.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}}))}),[{key:"keyOf",value:function(e){return 0}},{key:"changelogIncludeParams",get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}},{key:"_postprocessChannelUpdateEvent",value:function(e,t){}},{key:"_postprocessChannelRemoveEvent",value:function(e){}},{key:"_postprocessMessageUpdateEvent",value:function(e,t){}},{key:"_postprocessMessageRemoveEvent",value:function(e){}},{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return v(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,v(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,v(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"_activate",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),n.logger.debug("check huge gap"),this._checkHugeGap(),t.next=5,this._refreshChannel(e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_replaceChannelOfCollection",value:function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}},{key:"_shouldStartBackgroundSync",value:function(){var e=es.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}},{key:"_setBaseMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n instanceof Ws&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,t){var n,r=this,a=[],i=s(e);try{for(i.s();!(n=i.n()).done;){var o=n.value,u=xv(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c.isUserMessage()&&c.applyPoll(o),a.push(c)}}}catch(e){i.e(e)}finally{i.f()}return a.length>0&&Ms(t)&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},a.length>0&&(null===(r=(n=this._handler).onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,a));case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_applyPollUpdateEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollUpdateEvent(e)&&Ms(t)&&hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollVoteEvent(e)&&Ms(t)&&hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyReactionEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ms(t)&&(a.applyReactionEvent(e),hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_applyThreadInfoEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.targetMessageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ms(t)&&(a.applyThreadInfoUpdateEvent(e),hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_removeMessagesFromView",value:function(e,t){var n,r=this,a=[],i=[],o=s(e);try{var u=function(){var e=n.value,t=r._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var s=r._messages[t];a.push(r.keyOf(s)),i.push(s),r._messages.splice(t,1)}};for(o.s();!(n=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return Ms(t)&&i.length>0&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===r||r.call(n,s,this.channel,a,i);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,t){var n=t.prevLimit,r=void 0===n?0:n,a=t.nextLimit,i=void 0===a?0:a,s=t.inclusive,o=void 0===s||s;return E(this,void 0,void 0,d().mark((function t(){var n,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!o){t.next=5;break}return t.next=4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter);case 4:n=t.sent;case 5:if(!(r>0)){t.next=11;break}return t.next=8,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r,!1);case 8:t.t0=t.sent,t.next=12;break;case 11:t.t0=[];case 12:if(a=t.t0,!(i>0)){t.next=19;break}return t.next=16,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,i,!1);case 16:t.t1=t.sent,t.next=20;break;case 19:t.t1=[];case 20:return s=t.t1,t.abrupt("return",{messages:[].concat(v(n),v(a),v(s)).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:a.length,nextMessagesCount:s.length});case 22:case"end":return t.stop()}}),t,this)})))}},{key:"_getRemoteMessages",value:function(t,n){var r=n.prevLimit,a=void 0===r?0:r,i=n.nextLimit,s=void 0===i?0:i,o=n.source,u=void 0===o?e.CollectionEventSource.REQUEST_MESSAGE:o,c=n.reverse,l=void 0!==c&&c,h=n.checkingHasNext,f=void 0!==h&&h,p=n.checkingContinuousMessages,v=void 0!==p&&p;return E(this,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=nh.of(this._iid),!(a>0||s>0)){e.next=7;break}return e.next=4,n._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,t,ve(Object.assign(Object.assign(Object.assign({},this.filter),Lv),{isInclusive:!0,reverse:l,prevResultSize:a,nextResultSize:s})),u,f,v);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 t,n,r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,_,m,g,y,k,b,C,w,x,S,T,I,N,M,O,U,D=this;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(o=es.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=o.cacheContext,h=o.statManager,f=o.logger,!(this._messages.length>0)){s.next=25;break}return p=this._syncRange.top,_=this.viewTop,m=this._syncRange.bottom,g=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,s.next=8,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,_,p);case 8:return y=s.sent,s.next=11,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,m,g);case 11:return k=s.sent,s.prev=12,s.next=15,yi((function(){return E(D,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,h,f,b,C,w,x,S,T,I,N,A,M=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Dv(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:_,prevEnd:p,prevCount:y,nextStart:m,nextEnd:g,nextCount:k,checkingContinuousMessages:l.localCacheEnabled},this.filter),Lv)),t.next=3,c.send(r);case 3:a=t.sent,i=a.as(Rv),s=i.isHugeGap,o=i.prevMessages,h=void 0===o?[]:o,f=i.prevHasMore,b=i.isContinuousPrevMessages,C=i.nextMessages,w=void 0===C?[]:C,x=i.nextHasmore,S=i.isContinuousNextMessages,s?hi((function(){return E(M,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this._handler)||void 0===t?void 0:t.onHugeGapDetected)&&this._handler.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(T=this.viewTop,I=this.viewBottom,N=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,T].concat(v(h.map((function(e){return e.createdAt}))))),A=Math.max.apply(Math,[0,I].concat(v(w.map((function(e){return e.createdAt}))))),u.dispatch(new Os({messages:h,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),u.dispatch(new Os({messages:w,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(N,A),(b||S)&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(N,A)),f&&this._prevFill.start(N),x&&this._nextFill.start(A));case 6:case"end":return t.stop()}}),t,this)})))}),1);case 15:s.next=20;break;case 17:s.prev=17,s.t0=s.catch(12),f.debug("Failed HugeGap Check ",s.t0);case 20:return s.prev=20,l.localCacheEnabled&&h.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(t=l.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(20);case 23:s.next=42;break;case 25:return b=Date.now(),s.prev=26,s.next=29,this._getRemoteMessages(b,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled});case 29:if(C=s.sent,w=C.messages,x=C.isContinuousMessages,S=C.hasNext,w.length>0){for(I=w.map((function(e){return e.createdAt})),N=0,M=0,O=0;O=b&&M++;this._hasPrevious=N>=this._prevResultLimit,this._hasNext=null!=S?S:M>=this._nextResultLimit,(T=this._syncRange).extends.apply(T,v(I)),x&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(w,e.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;s.next=39;break;case 36:s.prev=36,s.t1=s.catch(26),s.t1 instanceof A&&s.t1.code===e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 39:return s.prev=39,l.localCacheEnabled&&h.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=l.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(39);case 42:case"end":return s.stop()}}),s,this,[[12,17,20,23],[26,36,39,42]])})))}},{key:"_loadUnsentMessages",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter);case 2:this._unsentMessages=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1);case 2:if(!(e.sent.length>0)){e.next=5;break}return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.logger,n.prev=1,n.next=4,this._channelManager.refreshChannel(this.channel.url,!0,e,t);case 4:n.next=9;break;case 6:n.prev=6,n.t0=n.catch(1),a.warn("Failed to refresh channel",n.t0);case 9:case"end":return n.stop()}}),n,this,[[1,6]])})))}},{key:"_startCheckMyMutedTimer",value:function(t){var n=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=void 0,n=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:r=t.sent,n=!r.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),n=!0;case 12:return t.prev=12,n&&(a=es.of(this._iid),i=a.sessionManager,this.channel._runIfHandleableWithGroupChannel((function(t){var n,r;t.myMutedState=e.MutedState.UNMUTED;var a={source:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i.currentUser};null===(r=null===(n=s._handler)||void 0===n?void 0:n.onChannelUpdated)||void 0===r||r.call(n,a,s.channel)}))),t.finish(12);case 15:case"end":return t.stop()}}),t,this,[[2,9,12,15]])})))}),t+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}},{key:"_setHasNextAndHaePrevious",value:function(e,t){for(var n=e.map((function(e){return e.createdAt})),r=0,a=0,i=0;ithis._startingPoint&&a++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=t?t:a>=this._nextResultLimit}},{key:"initialize",value:function(t){var n=this,r=new Hv;this._messages=[],this._unsentMessages=[],this._syncRange=new kv({}),this._hasNext=!0,this._hasPrevious=!0;var a=[],i={messages:[],prevMessagesCount:0,nextMessagesCount:0};return hi((function(){return E(n,void 0,void 0,d().mark((function n(){var s,o,u,c,l,h=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,null===(s=this._backgroundSync)||void 0===s?void 0:s.loadMetadata();case 2:o=n.sent,u=es.of(this._iid),c=u.cacheContext,l=u.statManager,n.t0=t,n.next=n.t0===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API?7:9;break;case 7:return this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(t){return E(h,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=t,a=this._filterUnderOffsetMessage(i.messages),this._addMessagesToView(a,e.CollectionEventSource.REQUEST_MESSAGE),n.next=5,this._loadUnsentMessages();case 5:r._invokeResponse("local",null,a);case 6:case"end":return n.stop()}}),n,this)})))})).catch((function(e){if(N(e))throw e;r._invokeResponse("local",e,null)})).finally((function(){return E(h,void 0,void 0,d().mark((function n(){var s,u,c,h,f,p,_,m,g=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return c=es.of(this._iid),h=c.cacheContext,f=!0,p=!0,_=!1,h.localCacheEnabled&&a.length>0&&(m=o.range).includes.apply(m,v(a.map((function(e){return e.createdAt}))))&&(!o.previousComplete&&i.prevMessagesCounto.range.bottom||i.nextMessagesCount=e._latestMessageInfo.createdAt&&(p=!1)})),p?(f=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled}).then((function(t){var n,a,i,s=t.messages,o=t.isContinuousMessages,u=t.hasNext,c=g._filterUnderOffsetMessage(s);(g._messages=[],c.length>0)?(g._setHasNextAndHaePrevious(c,u),(i=g._syncRange).extends.apply(i,v(c.map((function(e){return e.createdAt})))),o&&(null===(n=g._backgroundSync)||void 0===n?void 0:n.range.overlap(g._syncRange))&&(null===(a=g._backgroundSync)||void 0===a||a.range.extends(g._syncRange.top,g._syncRange.bottom)),g._addMessagesToView(c,e.CollectionEventSource.REQUEST_MESSAGE)):(g._hasPrevious=!1,g._hasNext=!1);r._invokeResponse("remote",null,c)})).catch((function(e){if(N(e))throw e;r._invokeResponse("remote",e,null)}))):(this._setHasNextAndHaePrevious(a),r._invokeResponse("remote",null,a)),h.localCacheEnabled&&l.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:f?"cache_hit":"cache_miss",max_db_size:null!==(u=null===(s=h.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==u?u:0,message_init_policy:t,use_local_cache:h.localCacheEnabled,collection_id:this._key}}));case 10:case"end":return n.stop()}}),n,this)})))})),n.abrupt("break",9);case 9:l.put(new Bi({type:Ge.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message_init_policy:t,message:!0}}}));case 10:case"end":return n.stop()}}),n,this)})))})),r}},{key:"loadPrevious",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=es.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasPrevious){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingPrevious){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingPrevious=!0,c=this.viewTop,l=[],a.next=13,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{prevLimit:this._prevResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._prevResultLimit,s.localCacheEnabled&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=es.of(this._iid),s=i.cacheContext,e.next=3,this._getRemoteMessages(c,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:s.localCacheEnabled});case 3:u=e.sent,(l=this._filterUnderOffsetMessage(u.messages)).length>0&&((h=this._syncRange).extends.apply(h,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&u.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top))),l=l.filter((function(e){return wv(p._messages,e)<0})),this._hasPrevious=l.length>=this._prevResultLimit,f&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(r=s.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasPrevious=l.length>=this._prevResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingPrevious=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"loadNext",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=es.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasNext){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingNext){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingNext=!0,c=this.viewBottom,l=[],a.next=13,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{nextLimit:this._nextResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._nextResultLimit,s.localCacheEnabled&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p,_=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=es.of(this._iid),u=s.cacheContext,e.next=3,this._getRemoteMessages(c,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:u.localCacheEnabled});case 3:h=e.sent,(l=this._filterUnderOffsetMessage(h.messages)).length>0&&((p=this._syncRange).extends.apply(p,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.bottom))),l=l.filter((function(e){return wv(_._messages,e)<0})),this._hasNext=null!==(r=h.hasNext)&&void 0!==r?r:l.length>=this._nextResultLimit,f&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(i=null===(a=u.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:u.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasNext=l.length>=this._nextResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingNext=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"removeFailedMessage",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:return n.next=4,this._channelManager.removeFailedMessageFromCache(t);case 4:(r=this._unsentMessages.findIndex((function(e){return e.reqId===t})))>-1&&this._unsentMessages.splice(r,1);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=this;if(!this._isDisposed){this._isDisposed=!0;var i=es.of(this._iid),s=i.cacheContext,o=i.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(t){t.myMemberState!==e.MemberState.NONE&&(a._channel._updateMessageCollectionLastAccessedAt(),o.dispatch(new gp({channels:[a._channel],context:{source:e.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}}])}(),jv=function(t){function a(e,t){return r(this,a),n(this,a,[e,Object.assign(Object.assign({},t),{channelManager:Cv.of(e)})])}return c(a,t),i(a,[{key:"keyOf",value:function(e){return e.messageId}},{key:"initialize",value:function(e){var t=this;return fi((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),p(a,"initialize",this,3)([e])}},{key:"setMessageCollectionHandler",value:function(e){this._setBaseMessageCollectionHandler(e)}},{key:"_activate",value:function(){var e=this,t=Object.create(null,{_activate:{get:function(){return p(a,"_activate",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t._activate.call(this);case 2:return e.next=4,fi((function(){return E(n,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_addMessagesToView",value:function(t,n){var r,a=this,i=this._filterUnderOffsetMessage(t),o=[],u=[],c=s(i);try{for(c.s();!(r=c.n()).done;){var l=r.value;if(n===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(wv(this._messages,l)<0){wv(this._unsentMessages,l)<0&&o.push(l);var h=Sv(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ys){wv(this._unsentMessages,l)<0&&wv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var f=wv(this._messages,l);if(f<0){var p=wv(this._unsentMessages,l);p<0?o.push(l):(this._unsentMessages.splice(p,1),u.push(l));var _=Sv(this._messages,l);this._messages.splice(_,0,l)}else u.push(l),this._messages[f]=l;if(l.updatedAt>0){var m=this._updateChildMessagesInView(l);u.push.apply(u,v(m))}}else if(l instanceof Ys){var g=wv(this._unsentMessages,l);g<0?wv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[g]=l)}}}catch(e){c.e(e)}finally{c.f()}Ms(n)&&hi((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:n},o.length>0&&(null===(r=null===(t=this._handler)||void 0===t?void 0:t.onMessagesAdded)||void 0===r||r.call(t,s,this.channel,o)),u.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateMessagesToView",value:function(e,t){var n,r=this,a=[],i=[],o=[],u=s(e);try{for(u.s();!(n=u.n()).done;){var c=n.value;if(c.messageId>0){var l=wv(this._messages,c);if(l>=0)i.push(c),this._messages[l]=c;else{var h=wv(this._unsentMessages,c);if(h>=0){var p=f(this._unsentMessages.splice(h,1),1)[0];if(this.hasNext&&p)o.push(p);else{i.push(c);var _=Sv(this._messages,c);this._messages.splice(_,0,c)}}else{var m=this._messages.map((function(e){return e.createdAt}));(c.createdAtMath.max.apply(Math,v(m))&&!this._hasNext)&&a.push(c)}}}else if(c instanceof Ys){var g=wv(this._unsentMessages,c);g>=0&&(i.push(c),this._unsentMessages[g]=c)}}}catch(e){u.e(e)}finally{u.f()}return Ms(t)&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c={source:t},i.length>0?null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,c,this.channel,i):o.length>0?null===(u=null===(s=this._handler)||void 0===s?void 0:s.onMessagesDeleted)||void 0===u||u.call(s,c,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t);case 2:case"end":return e.stop()}}),e,this)})))})),i}}])}(Gv),Vv={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},zv=function(e){return D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isDiscoverable,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},Bv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,d=e.nicknameStartsWithFilter,h=e.operatorFilter;return(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/members"),a.params={token:s,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:d,operator_filter:h,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return c(t,e),i(t)}(je),Kv=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).members=[];var s=a.next,o=a.members;return i.token=s,o&&o.length>0&&(i.members=o.map((function(t){return new Zf(e,t)}))),i}return c(t,e),i(t)}(Ve);e.MutedMemberFilter=void 0,(Pv=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",Pv.MUTED="muted",Pv.UNMUTED="unmuted",e.MemberListOrder=void 0,(Fv=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",Fv.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(qv=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",qv.JOINED="joined_only",qv.INVITED="invited_only",qv.INVITED_BY_FRIEND="invited_by_friend",qv.INVITED_BY_NON_FRIEND="invited_by_non_friend";var Qv,Wv,Yv=function(t){function a(t,i,s){var o,u,c,l,d;return r(this,a),(o=n(this,a,[t,i,e.ChannelType.GROUP,s])).mutedMemberFilter=e.MutedMemberFilter.ALL,o.memberStateFilter=e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null,o.operatorFilter=e.OperatorFilter.ALL,o.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o.mutedMemberFilter=null!==(u=s.mutedMemberFilter)&&void 0!==u?u:e.MutedMemberFilter.ALL,o.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,o.order=null!==(d=s.order)&&void 0!==d?d:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R(e.MutedMemberFilter,this.mutedMemberFilter)&&R(e.MemberStateFilter,this.memberStateFilter)&&(D("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&R(e.OperatorFilter,this.operatorFilter)&&R(e.MemberListOrder,this.order)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new Bv(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Kv),s=i.members,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),Zv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/accept"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(je),Xv=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).channel=new E_(t,i),s.channel.myMemberState=e.MemberState.JOINED,s}return c(a,t),i(a)}(Ve),Jv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,d=e.accessCode,h=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a.params=pe({is_distinct:s,is_public:o,is_discoverable:u,name:h,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:d,operator_ids:v,message_survival_seconds:_}),a}return c(t,e),i(t)}(je),$v=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),e_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(je),t_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a}return c(t,e),i(t)}(je),n_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.countPreference;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:o},a}return c(t,e),i(t)}(je),r_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).countPreference=a.count_preference,i}return c(t,e),i(t)}(Ve),a_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.locale;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/reset_user_history"),a.params=pe({locale:s}),a}return c(t,e),i(t)}(je),i_=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(Ve),s_=Object.assign(Object.assign({},nu),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),o_=function(e){return ru(e)&&D("number",e.scheduledAt,!0)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},u_=Object.assign(Object.assign({},au),{scheduledAt:void 0}),c_=function(e){return iu(e)&&D("number",e.scheduledAt,!0)},l_=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl,d=t.scheduledMessageId;return i.method=_e.PUT,i.path="".concat(Le(c),"/").concat(encodeURIComponent(l),"/scheduled_messages/").concat(encodeURIComponent(d)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return ns.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(je),d_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new fo(e,a),i}return c(t,e),i(t)}(Ve),h_=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.PUT,i.path="".concat(Le(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(je),f_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.DELETE,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(je),p_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return c(t,e),i(t)}(je),v_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:o},a}return c(t,e),i(t)}(je),__=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(Ve),m_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),g_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(Ve);e.CountPreference=void 0,(Qv=e.CountPreference||(e.CountPreference={})).ALL="all",Qv.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Qv.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Qv.OFF="off",e.HiddenState=void 0,(Wv=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",Wv.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Wv.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var y_,E_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y,E,k,b,C,w,x,S,T;(r(this,a),(s=n(this,a,[t,i]))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s._hasBotInfo={general:!1,ai:!1},s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isChatNotification=!1,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.totalUnreadReplyCount=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.lastPinnedMessage=null,s._latestMessageInfo=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(o=i.is_distinct)&&void 0!==o&&o,s.isSuper=null!==(u=i.is_super)&&void 0!==u&&u,s.isBroadcast=null!==(c=i.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=i.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(d=i.is_public)&&void 0!==d&&d,s.isDiscoverable=null!==(h=i.is_discoverable)&&void 0!==h?h:s.isPublic,s.isChatNotification=null!==(f=i.is_chat_notification)&&void 0!==f&&f,s.isAccessCodeRequired=null!==(p=i.is_access_code_required)&&void 0!==p&&p,s.isPushEnabled=null!==(_=i.is_push_enabled)&&void 0!==_&&_,Array.isArray(i.members))&&(T=s.members).push.apply(T,v(i.members.map((function(e){return new Zf(s._iid,e)}))));return s.memberCount=null!==(m=i.member_count)&&void 0!==m?m:0,s.joinedMemberCount=null!==(g=i.joined_member_count)&&void 0!==g?g:0,s.hiddenState=R(e.HiddenState,i.hidden_state)?i.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(y=i.ts_message_offset)&&void 0!==y?y:0,s.messageSurvivalSeconds=null!==(E=i.message_survival_seconds)&&void 0!==E?E:-1,s.lastMessage=i.last_message?ho(s._iid,Object.assign({channel_type:s.channelType},i.last_message)):null,i.read_receipt&&Object.keys(i.read_receipt).forEach((function(e){D("number",i.read_receipt[e])&&s._updateUnreadMemberState(e,i.read_receipt[e])})),i.delivery_receipt&&Object.keys(i.delivery_receipt).forEach((function(e){D("number",i.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,i.delivery_receipt[e])})),s.myMemberState=R(e.MemberState,i.member_state)?i.member_state:e.MemberState.NONE,s.myRole=R(e.Role,i.my_role)?i.my_role:e.Role.NONE,R(e.MutedState,i.is_muted)?s.myMutedState=i.is_muted:D("boolean",i.is_muted)?s.myMutedState=i.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=R(e.CountPreference,i.count_preference)?i.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=R(e.PushTriggerOption,i.push_trigger_option)?i.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=i.user_last_read)&&void 0!==k?k:0,s.inviter=i.inviter?new si(s._iid,i.inviter):null,s.invitedAt=null!==(b=i.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(C=i.joined_ts)&&void 0!==C?C:0,s._updateUnreadCount(null!==(w=i.unread_message_count)&&void 0!==w?w:0,null!==(x=i.unread_mention_count)&&void 0!==x?x:0),s.totalUnreadReplyCount=null!==(S=i.total_unread_thread_message_count)&&void 0!==S?S:0,s.lastPinnedMessage=i.latest_pinned_message?ho(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,i.latest_message&&(s._latestMessageInfo={messageId:i.latest_message.message_id,createdAt:i.latest_message.created_at}),s._hasBotInfo={general:!!i.has_bot,ai:!!i.has_ai_bot},s}return c(a,t),i(a,[{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=s(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=s(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"hasBot",get:function(){return this._hasBotInfo.general}},{key:"hasAiBot",get:function(){return this._hasBotInfo.ai}},{key:"_shouldUpdateLastMessageWith",value:function(t){if(t.silent)return!1;var n=es.of(this._iid).appInfo;switch(null==n?void 0:n.lastMessageThreadingPolicy){case e.LastMessageThreadingPolicy.NONE:case e.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case e.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(t.parentMessageId>0)return!1;break;case e.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof Ys&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case e.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof Ys&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}},{key:"_updateLastMessage",value:function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}},{key:"_updateUnreadCount",value:function(t,n){if("number"==typeof t&&t>=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=es.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=es.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return ni(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new jv(this._iid,Object.assign(Object.assign({},e),{channel:this}))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Yv(this._iid,this.url,e)}},{key:"createThreadedParentMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ph(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 Zf?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 Ys&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=es.of(this._iid).sdkState,a=t.createdAt,i=0,o=s(this.members);try{for(o.s();!(n=o.n()).done;){var u=n.value;if(r.userId!==u.userId&&u.state===e.MemberState.JOINED&&t.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=es.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ys?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o>=e.createdAt&&i.push(s)}})),i}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=es.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ys?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o0&&void 0!==arguments[0]&&arguments[0],n=es.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 i=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new gs(e._iid,{channel_url:e.url,channel_type:e.channelType,user:Zf.payloadify(a),ts:null!=i?i:0})}})),r}},{key:"getDeliveryStatus",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=es.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 i=e._undeliveredMemberStateMap.get(a.userId);r[a.userId]=new Xf(e._iid,{channel_url:e.url,channel_type:e.channelType,user:Zf.payloadify(a),ts:null!=i?i: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=es.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,i){var s=a.ts;n-s>=t&&(e._typingStatus.delete(i),r=!0)})),r}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._refresh());case 1:case"end":return e.stop()}}),e,this)})))}},{key:"_refresh",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Cp({channelUrl:this.url}),n.next=4,a.send(s);case 4:return o=n.sent,u=o.as(wp),c=u.channel,this._update(c),t||i.dispatch(new gp({channels:[c],context:{source:e.CollectionEventSource.REFRESH_CHANNEL}})),n.abrupt("return",this);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"freeze",value:function(){var t=this,n=Object.create(null,{freeze:{get:function(){return p(a,"freeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.freeze.call(this);case 2:r=es.of(this._iid),r.dispatcher.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"unfreeze",value:function(){var t=this,n=Object.create(null,{unfreeze:{get:function(){return p(a,"unfreeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.unfreeze.call(this);case 2:r=es.of(this._iid),r.dispatcher.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannel",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Vv),t),ai(zv(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new Jv(Object.assign({channelUrl:this.url},r)),n.next=6,s.send(o);case 6:return u=n.sent,c=u.as($v),l=c.channel,this._update(l),i.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(e.every((function(e){return e instanceof si}))).throw(A.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"inviteWithUserIds",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(P("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.requestQueue,s=r.sessionManager,o=new Wp({channelUrl:this.url,userIds:t}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.as(Yp),l=c.channel,this._update(l),a.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:s.currentUser,invitees:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"join",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",t,!0)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Vp({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(zp),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"leave",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Kp({channelUrl:this.url,userId:a.userId,shouldRemoveOperatorStatus:t}),n.next=4,i.send(s);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return n.stop()}}),n,this)})))}},{key:"acceptInvitation",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",t,!0)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Zv({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(Xv),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"declineInvitation",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Xp({channelUrl:this.url,userId:r.userId}),t.next=4,a.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"sendUserMessage",this,3)([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){s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),Cv.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"updateUserMessage",value:function(t,n){var r=this,i=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=es.of(this._iid),s=a.dispatcher,r.next=3,i.updateUserMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Cv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new gp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Cv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Os({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"_autoResendUserMessage",this,3)([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 a=Cv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"sendFileMessage",this,3)([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 a=Cv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new ol,i=es.of(this._iid).dispatcher;return p(a,"sendMultipleFilesMessage",this,3)([t]).onPending((function(e){r._trigger(e)})).onFailed((function(e,t){r._triggerFailed(e,t)})).onSucceeded((function(t){var a=Cv.of(n._iid);n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(t,n){var r=this,i=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=es.of(this._iid),s=a.dispatcher,r.next=3,i.updateFileMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Cv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new gp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Cv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Os({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"_autoResendFileMessage",this,3)([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 a=Cv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"deleteMessage",value:function(t){var n=this,r=Object.create(null,{deleteMessage:{get:function(){return p(a,"deleteMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.deleteMessage.call(this,t);case 2:0===t.messageId&&t instanceof Ys&&(a=es.of(this._iid),a.dispatcher.dispatch(new Ls({reqId:t.reqId,source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"hide",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},$p),t),ai(ev(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new tv(Object.assign({channelUrl:this.url,userId:s.userId},r)),n.next=6,o.send(u);case 6:return c=n.sent,l=c.as(nv),h=l.messageOffsetTimestamp,this.hiddenState=r.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,r.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),i.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),n.abrupt("return",this);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"unhide",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new t_({channelUrl:this.url}),t.next=4,a.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,r.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new e_({channelUrl:this.url}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.sdkState,a=n.dispatcher,i=n.requestQueue,s=new ys({channelUrl:this.url}),t.next=4,i.send(s);case 4:o=t.sent,u=o.as(Es),c=u.readStatus,this._updateUnreadMemberState(r.userId,c.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Cv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)}))),a.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new vv({channelUrl:this.url,userId:n.userId}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=es.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingStarted>=r)){e.next=8;break}return this._typingStarted=a,this._typingEnded=0,i=new av({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=es.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingEnded>=r)){e.next=8;break}return this._typingStarted=0,this._typingEnded=a,i=new sv({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Hd),e),ai(function(e){return Qo(e)&&D("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new qo;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},u_),t),ai(c_(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new h_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(_c),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createScheduledFileMessage",value:function(e){var t=this;e=Object.assign(Object.assign({},Gd),e),ai(function(e){return Go(e)&&D("number",e.scheduledAt)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(A.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new qo;return mi(2).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);hi((function(){return E(t,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a._trigger(i));case 1:case"end":return e.stop()}}),e)})))}))})),H(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a}},{key:"updateScheduledFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Object.assign(Object.assign({},s_),t),ai(o_(r)).throw(A.invalidParameters),!H(r.file)){n.next=5;break}return n.next=5,this._uploadFileAndUpdateParams(r);case 5:return a=new l_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),i=es.of(this._iid),s=i.requestQueue,n.next=9,s.send(a);case 9:return o=n.sent,u=o.as(d_),c=u.message,n.abrupt("return",c);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new f_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=es.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new p_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=es.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new m_({userId:n.userId,channelUrl:this.url}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(g_),o=s.pushTriggerOption,this.myPushTriggerOption=o,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new v_({userId:i.userId,channelUrl:this.url,pushTriggerOption:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(__),l=c.pushTriggerOption,this.myPushTriggerOption=l,a.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"setMyCountPreference",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.CountPreference,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new n_({channelUrl:this.url,userId:i.userId,countPreference:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(r_),l=c.countPreference,this.myCountPreference=l,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),a.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"resetMyHistory",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=n.sdkState,s=new a_({channelUrl:this.url,locale:i.localeForChatbot}),t.next=4,a.send(s);case 4:return o=t.sent,u=o.as(i_),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,this.lastMessage&&this.lastMessage.createdAt=this._limit&&!!b,h.nextToken=b,this._metadata&&(this._metadata.token=b,(C=this._metadata.range).extends.apply(C,v(k.map((function(e){return e.createdAt})))),this._metadata.completed=!h.hasNext),f.debug("channel background sync progress",h),t.next=30,this.saveMetadata();case 30:t.next=39;break;case 32:if(t.prev=32,t.t1=t.catch(6),f.debug("channel background sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=38;break}return t.next=38,this.clearMetaData();case 38:throw t.t1;case 39:return t.prev=39,_.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(o=null===(s=p.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==o?o:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:null!==(c=null===(u=m.order)||void 0===u?void 0:u.toString())&&void 0!==c?c:"",collection_id:l.userId}})),t.finish(39);case 42:t.next=46;break;case 44:h.hasNext=!1,h.nextToken="";case 46:return t.abrupt("return",h);case 47:case"end":return t.stop()}}),t,this,[[6,32,39,42],[8,15]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 kv({})}},{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,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata={token:r?r.token:"",range:new kv(r?r.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!r&&r.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.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=es.of(this._iid),r=n.logger;n.sessionManager.session.hasSession&&(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(){es.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 k_[this._iid])}}],[{key:"of",value:function(e){return k_[e]||(k_[e]=new t({_iid:e})),k_[e].ref++,k_[e]}},{key:"clear",value:function(e){k_[e]&&(k_[e].close(),delete k_[e])}}])}(),C_={},w_=function(){function t(n){var a=this,i=n._iid;r(this,t),this.ref=0,this._iid=i;var s,o=es.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher,h=o.cacheContext,f=o.statManager;this._metadataKey=(s=c.userId,"sendbird:".concat(s,"@groupchannel/changelogs.meta")),this._subscribers=new de;var p=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(c.userId);this._sync=new Tv(p,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,l,p,v,_,m,g;return d().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 u.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,s={includeEmpty:!0,includeMetaData:!0},t.prev=6,t.next=9,h.preference.get(Ga(c.appId));case 9:o=t.sent,s.includeChatNotification=Boolean(o),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(6),s.includeChatNotification=!1;case 16:return l=Cv.of(this._iid),t.next=19,l.getMyGroupChannelChangeLogs(null!==(a=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==a?a:"",s,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 19:return p=t.sent,v=p.updatedChannels,_=p.deletedChannelUrls,m=p.hasMore,g=p.token,this._subscribers.dispatch("progress",{updatedChannels:v,deletedChannelUrls:_,hasMore:m,token:g}),i.hasNext=m,i.nextToken=g,this._metadata&&(this._metadata.token=g),u.debug("channel changelog sync progress",i),t.next=31,this.saveMetadata();case 31:h.localCacheEnabled&&f.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:v.length>0||_.length>0?"cache_miss":"cache_hit",max_db_size:v.length,use_local_cache:h.localCacheEnabled,starting_point:0,message_init_policy:_.length.toString(),collection_id:c.userId}})),t.next=41;break;case 34:if(t.prev=34,t.t1=t.catch(4),u.debug("channel changelog sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=40;break}return t.next=40,this.clearMetadata();case 40:throw t.t1;case 41:return t.abrupt("return",i);case 42:case"end":return t.stop()}}),t,this,[[4,34],[6,13]])})))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=l.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"isRunning",get:function(){return this._sync.isRunning}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"on",value:function(e,t){return this._subscribers.on(e,t)}},{key:"resume",value:function(){es.of(this._iid).sessionManager.session.hasSession&&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 C_[this._iid])}}],[{key:"of",value:function(e){return C_[e]||(C_[e]=new t({_iid:e})),C_[e].ref++,C_[e]}},{key:"clear",value:function(e){C_[e]&&(C_[e].close(),delete C_[e])}}])}(),x_=function(t,n){var r,a,i,s;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!==(s=null===(i=t.lastMessage)||void 0===i?void 0:i.createdAt)&&void 0!==s?s:t.createdAt}},S_=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},T_=function(e,t,n){if(e.length>0){for(var r=S_(e,t),a=0,i=e.length-1,s=Math.floor((a+i)/2);a0)i=s,s=Math.floor((a+i)/2);else{if(!(o<0))return{place:s,oldPosition:r};a=s+1,s=Math.floor((a+i)/2)}}return{place:I_(e[s],t,n)>=0?s:s+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},I_=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(t.lastMessage&&n.lastMessage){var a=n.lastMessage.createdAt-t.lastMessage.createdAt;return 0===a?n.createdAt-t.createdAt:a}return 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 i=t.name.localeCompare(n.name);return 0===i?t.createdAt-n.createdAt:i;default:return 0}},N_=function(){return i((function t(n,a){var i=this,s=a.filter,o=void 0===s?new $f:s,u=a.order,c=void 0===u?e.GroupChannelListOrder.LATEST_LAST_MESSAGE:u,l=a.limit,h=void 0===l?100:l,f=a.includeChangesOnInitialLoad,p=void 0!==f&&f;r(this,t),this.channels=[],this._isInitialized=!1,this._iid=n,this._key="gcc-".concat(ce()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=o,this.order=c,this._hasMore=!0,this._token="",this._limit=h;var v=es.of(this._iid),_=v.sdkState,m=v.cacheContext,g=v.dispatcher;m.localCacheEnabled&&(this._backgroundSync=b_.of(n),this._backgroundSync.resume()),this._changelogSync=w_.of(n),this._changelogSync.resume(),Cv.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(mp(n)){var r=e.filter((function(e){return i.filter.match(e,_.userId)})),a=e.filter((function(e){return!i.filter.match(e,_.userId)})).map((function(e){return e.url}));r.length>0&&i._addChannelsToView(r,t),a.length>0&&i._removeChannelsFromView(a,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),g.on((function(e){e instanceof La&&(e.stateType===Aa.CONNECTED?i._isGetRemoteChannelsSucceeded||E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._revokeLoadMore();case 2:case"end":return e.stop()}}),e,this)}))):e.stateType===Aa.LOGOUT&&i.dispose())}))}),[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(t,n){var r,a=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=s(t);try{for(l.s();!(r=l.n()).done;){var h=r.value,f=S_(this.channels,h);f>=0&&this.channels.splice(f,1);var p=T_(this.channels,h,this.order).place;if(f<0)p===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(p,0,h));else switch(n.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&p===this.channels.length?c.push(h):(this.channels.splice(p,0,h),u.push(h));break;default:this.channels.splice(p,0,h),u.push(h)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var v,_=s(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=S_(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}mp(n.source)&&hi((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsAdded)&&this._handler.onChannelsAdded(n,o),u.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,u),c.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,c.map((function(e){return e.url})));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,t){var n,r=this,a=[],i=s(e);try{var o=function(){var e=n.value,t=r.channels.findIndex((function(t){return t.url===e}));t>=0&&(a.push(r.channels[t].url),r.channels.splice(t,1))};for(i.s();!(n=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return mp(t.source)&&a.length>0&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(t,a);case 1:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_getLocalChannels",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Cv.of(this._iid),n=this.channels.length>0?x_(this.channels[this.channels.length-1],this.order):null,e.next=4,t.getChannelsFromCache(n,this.filter,this.order,this._limit,n?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,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Cv.of(this._iid),e.next=3,t.getMyGroupChannels(this._token,ve(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);case 3:return n=e.sent,r=n.channels,a=n.token,this._token=a,this._hasMore=!!a,e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:n=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(n,{source:e.CollectionEventSource.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()}}),t,this,[[2,10]])})))}},{key:"loadMore",value:function(){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(r=null,!this._includeChangesOnInitialLoad||0!==this.channels.length){n.next=9;break}if(!this._changelogSync.isRunning){n.next=9;break}return n.next=7,new Promise((function(e){C._changelogSyncSubscriberContext=C._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}));case 7:r=n.sent,null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close();case 9:if(a=es.of(this._iid),i=a.cacheContext,o=a.connectionManager,u=a.statManager,this._isInitialized){n.next=16;break}if(this._isInitialized=!0,!i.localCacheEnabled){n.next=15;break}return n.next=15,this._backgroundSync.loadMetadata();case 15:u.put(new Bi({type:Ge.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}}));case 16:if(c=[],!this._hasMore){n.next=35;break}if(!i.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed){n.next=24;break}return n.next=21,fi((function(){return E(C,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:c=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 21:this._hasMore=c.length>=this._limit,n.next=34;break;case 24:return n.prev=24,n.next=27,this._getRemoteChannels();case 27:c=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=34;break;case 31:n.prev=31,n.t0=n.catch(24),this._isGetRemoteChannelsSucceeded=!1;case 34:this._addChannelsToView(c,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0);case 35:if(r){l=s(r.updatedChannels);try{for(l.s();!(h=l.n()).done;)f=h.value,(p=S_(c,f))>=0?c[p]=f:(v=T_(c,f,this.order),_=v.place,c.splice(_,0,f))}catch(e){l.e(e)}finally{l.f()}m=c.map((function(e){return e.url})),g=s(r.deletedChannelUrls);try{for(g.s();!(y=g.n()).done;)k=y.value,(b=m.indexOf(k))>=0&&(c.splice(b,1),m.splice(b,1))}catch(e){g.e(e)}finally{g.f()}}return n.abrupt("return",c);case 37:case"end":return n.stop()}}),n,this,[[24,31]])})))}},{key:"dispose",value:function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),Cv.of(this._iid).unsubscribeChannelEvent(this._key))}}])}(),A_=function(t){function a(t){var i;r(this,a);var s=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,d=t.channelNameContainsFilter,h=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,E=t.includeFrozen,k=t.includeMetaData;return(i=n(this,a)).method=_e.GET,i.path=ke,i.params=pe(ve({token:s,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:d,channel_urls:h,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:E,show_metadata:k})),i}return c(a,t),i(a)}(je),M_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new E_(e,t)}))),i.ts="number"==typeof u?u:0,i}return c(t,e),i(t)}(Ve);e.MembershipFilter=void 0,(y_=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",y_.JOINED="joined";var O_,U_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;return r(this,a),(s=n(this,a,[t,i])).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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=i.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(d=i.customTypesFilter)&&void 0!==d?d:null,s.customTypeStartsWithFilter=null!==(h=i.customTypeStartsWithFilter)&&void 0!==h?h:null,s.channelNameContainsFilter=null!==(f=i.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=i.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=i.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=i.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=i.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=i.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=i.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(E=i.order)&&void 0!==E?E:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter,!0)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter,!0)&&R(e.MembershipFilter,this.membershipFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicGroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=es.of(this._iid),r=n.requestQueue,a=new A_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(M_),o=s.channels,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(uu),D_=i((function e(){r(this,e),this.onUserMuted=ht,this.onUserUnmuted=ht,this.onUserBanned=ht,this.onUserUnbanned=ht,this.onChannelChanged=ht,this.onChannelDeleted=ht,this.onChannelFrozen=ht,this.onChannelUnfrozen=ht,this.onOperatorUpdated=ht,this.onChannelMemberCountChanged=ht,this.onMetaDataCreated=ht,this.onMetaDataUpdated=ht,this.onMetaDataDeleted=ht,this.onMetaCounterCreated=ht,this.onMetaCounterUpdated=ht,this.onMetaCounterDeleted=ht,this.onMessageReceived=ht,this.onMessageUpdated=ht,this.onMessageDeleted=ht,this.onMentionReceived=ht,this.onReactionUpdated=ht,this.onThreadInfoUpdated=ht})),R_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserJoined=ht,e.onUserLeft=ht,e.onUserReceivedInvitation=ht,e.onUserDeclinedInvitation=ht,e.onChannelHidden=ht,e.onUnreadMemberStatusUpdated=ht,e.onUndeliveredMemberStatusUpdated=ht,e.onTypingStatusUpdated=ht,e.onPollUpdated=ht,e.onPollVoted=ht,e.onPollDeleted=ht,e.onPinnedMessageUpdated=ht,e}return c(t,e),i(t)}(D_),L_=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(R_),P_=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,d=e.scheduledStatus;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ae),a.params=pe(ve({token:i,limit:s,reverse:u,channel_url:c,order:o,message_type:l,status:d})),a}return c(t,e),i(t)}(je),F_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).scheduledMessages=[];var s=a.next,o=a.scheduled_messages;return i.token=s,i.scheduledMessages=o.map((function(t){return ho(e,t)})),i}return c(t,e),i(t)}(Ve),q_=function(t){function a(t,i){var s,o,u,c,l,d;return r(this,a),(s=n(this,a,[t,i])).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(o=i.channelUrl)&&void 0!==o?o:null,s.order=null!==(u=i.order)&&void 0!==u?u:null,s.reverse=null!==(c=i.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=i.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(d=i.messageTypeFilter)&&void 0!==d?d:e.MessageTypeFilter.ALL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl,!0)&&(R(e.ScheduledMessageListOrder,this.order)||null===this.order)&&D("boolean",this.reverse)&&(P(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&R(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new P_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(F_),s=i.scheduledMessages,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),H_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="groupChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new Cv(e,{sdkState:r,cacheContext:c,dispatcher:a,sessionManager:i,requestQueue:s,logger:o})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new N_(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new lv(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new U_(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new q_(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){ai(D("string",e)&&t instanceof L_).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){ai(D("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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},ip),t),ai(D("string",e)&&sp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},ip),t),ai(D("number",e)&&sp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},op),e),ai(up(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},rp),e),ai(ap(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.createChannel(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},rp),e),ai(ap(n)).throw(A.invalidParameters),n&&(n.isDistinct=!0),t.abrupt("return",this.createChannel(n));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithUserIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=Object.assign(Object.assign({},rp),{invitedUserIds:e,isDistinct:t,name:n,data:a,customType:i}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,s.abrupt("return",this.createChannel(o));case 3:case"end":return s.stop()}}),s,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:ai(P("string",e)).throw(A.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.next=3,this.getChannel(e);case 3:return n=t.sent,t.next=6,n.markAsDelivered();case 6:case"end":return t.stop()}}),t,this)})))}}])}(ts),G_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return c(t,e),i(t,[{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,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0: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)})),t.abrupt("return",n);case 3:case"end":return t.stop()}}),t)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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)})))}}])}(Ya),j_={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},V_=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&(D("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&D("boolean",e.isEphemeral,!0)},z_=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?we:Ce,"/").concat(encodeURIComponent(i)),a.params={show_pinned_messages:!0},a}return c(t,e),i(t)}(je),B_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new om(e,a),i}return c(t,e),i(t)}(Ve),K_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,d=e.isEphemeral;return(a=n(this,t)).method=_e.POST,a.path=Ce,a.params=pe(ve({channel_url:i,cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:d})),a}return c(t,e),i(t)}(je),Q_=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"ENTR",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(Qe),W_=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new si(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(jp),Y_=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"EXIT",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(Qe),Z_=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"EXIT",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new si(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(jp),X_={},J_=function(t){function a(t,i){var o;return r(this,a),(o=n(this,a,[t,Object.assign(Object.assign({},i),{channelType:e.ChannelType.OPEN})])).subscribeChannelEvent=ht,o.unsubscribeChannelEvent=ht,o.refreshChannel=function(){return E(o,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}}),e)})))},o._openChannelCache=new G_(t),o._openChannelHandlers=new Map,o._dispatcher.on((function(e){if(e instanceof Ke)o._handleEvent(e).catch((function(e){if(N(e)&&"foreground"===o._sdkState.appState)throw e}));else if(e instanceof La&&e.stateType===Aa.CONNECTED){var t,n=s(o._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),X_[t]||(X_[t]=o),o}return c(a,t),i(a,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=ri(e);return new om(this._iid,om.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._openChannelCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((r=n.n()).done){t.next=9;break}return a=r.value,t.next=7,this._openChannelCache.remove(a);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),n.e(t.t0);case 14:return t.prev=14,n.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"handlers",get:function(){return v(this._openChannelHandlers.values())}},{key:"_handleEvent",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,A,M,O,U,D,R,L,P,F,q,H,G,j,V,z,B,K,Q,W,Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue,ce,le,de,he,fe,pe,ve,_e,me,ge,ye,Ee,ke,be,Ce,we,xe,Se,Te,Ie,Ne,Ae,Me,Oe,Ue,De,Re,Le,Pe,Fe,qe,He,Ge,je=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,n.t0=t.code,n.next="MESG"===n.t0||"FILE"===n.t0||"ADMM"===n.t0||"BRDM"===n.t0?4:"MEDI"===n.t0||"FEDI"===n.t0||"AEDI"===n.t0?14:"DELM"===n.t0?26:"MRCT"===n.t0?33:"MTHD"===n.t0?40:"MCNT"===n.t0?47:"PEDI"===n.t0?75:"VOTE"===n.t0?83:"SYEV"===n.t0?91:174;break;case 4:if(r=null,"MESG"===t.code?r=t.as(ac):"FILE"===t.code?r=t.as(mo):"ADMM"!==t.code&&"BRDM"!=t.code||(r=t.as(fv)),!r){n.next=13;break}if(i=(a=r).message,o=a.isMentioned,i.channelType!==e.ChannelType.OPEN){n.next=13;break}return n.next=11,this.getChannel(i.channelUrl,!0);case 11:u=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(u.url)&&(r.onMessageReceived&&r.onMessageReceived(u,i),o&&r.onMentionReceived&&r.onMentionReceived(u,i))}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return n.abrupt("break",174);case 14:if(c=null,"MEDI"===t.code?c=t.as(sc):"FEDI"===t.code?c=t.as(uc):"AEDI"===t.code&&(c=t.as(pv)),!c){n.next=25;break}if(h=(l=c).message,f=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){n.next=25;break}return n.next=21,this.getChannel(h.channelUrl,!0);case 21:p=n.sent,v=!1,p.lastPinnedMessage&&p.lastPinnedMessage.messageId===h.messageId&&p.lastPinnedMessage.updatedAt0&&i.onMentionReceived&&i.onMentionReceived(p,h))}catch(e){r.e(e)}finally{r.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 25:return n.abrupt("break",174);case 26:if(_=t.as(lt),m=_.channelUrl,g=_.channelType,y=_.messageId,g!==e.ChannelType.OPEN){n.next=32;break}return n.next=30,this.getChannel(m,!0);case 30:k=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(k.url)&&r.onMessageDeleted&&r.onMessageDeleted(k,y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 32:return n.abrupt("break",174);case 33:if(b=t.as(mv),C=b.channelUrl,w=b.channelType,x=b.event,w!==e.ChannelType.OPEN){n.next=39;break}return n.next=37,this.getChannel(C,!0);case 37:S=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(S.url)&&r.onReactionUpdated&&r.onReactionUpdated(S,x)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 39:return n.abrupt("break",174);case 40:if(T=t.as(gv),(I=T.event).channelType!==e.ChannelType.OPEN){n.next=46;break}return n.next=44,this.getChannel(I.channelUrl,!0);case 44:A=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(A.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(A,I)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 46:return n.abrupt("break",174);case 47:M=t.as(yv),O=M.openChannelMemberCounts,U=[],D=s(O),n.prev=50,D.s();case 52:if((R=D.n()).done){n.next=61;break}return L=R.value,P=L.channelUrl,F=L.participantCount,q=L.updatedAt,n.next=57,this.getChannelFromCache(P);case 57:(H=n.sent)&&H._updateParticipantCount(F,q)&&U.push(H);case 59:n.next=52;break;case 61:n.next=66;break;case 63:n.prev=63,n.t1=n.catch(50),D.e(n.t1);case 66:return n.prev=66,D.f(),n.finish(66);case 69:if(!(U.length>0)){n.next=74;break}return n.next=72,this.upsertChannelsToCache(U);case 72:G=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(G)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 74:return n.abrupt("break",174);case 75:if(j=t.as(Ev),V=j.event,z=j.status,B=j.channelUrl,K=j.channelType,!B||K!==e.ChannelType.OPEN){n.next=82;break}return n.next=79,this.getChannel(B,!0);case 79:Q=n.sent,this._dispatcher.dispatch(new Fs({event:V,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),hi(z===to?function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(Q,V.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(Q,V)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 82:return n.abrupt("break",174);case 83:if(W=t.as(Oc),Y=W.event,Z=W.channelUrl,X=W.channelType,!Z||X!==e.ChannelType.OPEN){n.next=90;break}return n.next=87,this.getChannel(Z,!0);case 87:J=n.sent,this._dispatcher.dispatch(new qs({event:Y,source:e.CollectionEventSource.EVENT_POLL_VOTED})),hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(J,Y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 90:return n.abrupt("break",174);case 91:if($=t.as(jp),!(ee=$.event).isOpenChannelEvent){n.next=173;break}n.t2=ee.category,n.next=n.t2===Jf.CHANNEL_ENTER?96:n.t2===Jf.CHANNEL_EXIT?103:n.t2===Jf.CHANNEL_OPERATOR_UPDATE?110:n.t2===Jf.USER_CHANNEL_MUTE||n.t2===Jf.USER_CHANNEL_UNMUTE?118:n.t2===Jf.USER_CHANNEL_BAN||n.t2===Jf.USER_CHANNEL_UNBAN?125:n.t2===Jf.CHANNEL_FREEZE||n.t2===Jf.CHANNEL_UNFREEZE?132:n.t2===Jf.CHANNEL_DELETED?140:n.t2===Jf.CHANNEL_PROP_CHANGED?147:n.t2===Jf.CHANNEL_META_DATA_CHANGED?152:n.t2===Jf.CHANNEL_META_COUNTERS_CHANGED?161:n.t2===Jf.PINNED_MESSAGE_CHANGED?167:173;break;case 96:return n.next=98,this.getChannel(ee.channelUrl,!0);case 98:return te=n.sent,ne=t.as(W_),re=ne.participantCount,ae=ne.user,ie=te._updateParticipantCount(re,ee.ts),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(te,ae),ie&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(te)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 103:return n.next=105,this.getChannel(ee.channelUrl,!0);case 105:return se=n.sent,oe=t.as(Z_),ue=oe.participantCount,ce=oe.user,le=se._updateParticipantCount(ue,ee.ts),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(se,ce),le&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 110:return n.next=112,this.getChannel(ee.channelUrl,!0);case 112:return de=n.sent,he=t.as(uv),fe=he.operators,de.operators=fe,this.upsertChannelsToCache([de]),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(de,fe)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 118:return n.next=120,this.getChannel(ee.channelUrl,!0);case 120:return pe=n.sent,ve=ee.category===Jf.USER_CHANNEL_MUTE,_e=t.as(ve?Bu:Qu),me=_e.user,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ve?e.onUserMuted&&e.onUserMuted(pe,me):e.onUserUnmuted&&e.onUserUnmuted(pe,me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 125:return n.next=127,this.getChannel(ee.channelUrl,!0);case 127:return ge=n.sent,ye=ee.category===Jf.USER_CHANNEL_BAN,Ee=t.as(ye?Yu:Xu),ke=Ee.user,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ye?e.onUserBanned&&e.onUserBanned(ge,ke):e.onUserUnbanned&&e.onUserUnbanned(ge,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 132:return n.next=134,this.getChannel(ee.channelUrl,!0);case 134:return be=n.sent,Ce=t.as($u),we=Ce.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().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)})))})),n.abrupt("break",173);case 140:return n.next=142,this.getChannel(ee.channelUrl,!0);case 142:return xe=n.sent,n.next=145,this.removeChannelsFromCache([xe.url]);case 145:return hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(xe.url,xe.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 147:return n.next=149,this.getChannelWithoutCache(ee.channelUrl,!0);case 149:return Se=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 152:return n.next=154,this.getChannel(ee.channelUrl,!0);case 154:return Te=n.sent,Ie=t.as(Au),Ne=Ie.created,Ae=Ie.updated,Me=Ie.deleted,Ne&&Te._upsertCachedMetaData(Ne,ee.ts),Ae&&Te._upsertCachedMetaData(Ae,ee.ts),Me&&Te._removeFromCachedMetaData(Me,ee.ts),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ne&&e.onMetaDataCreated&&e.onMetaDataCreated(Te,Ne),Ae&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Te,Ae),Me&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Te,Me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 161:return n.next=163,this.getChannel(ee.channelUrl,!0);case 163:return Oe=n.sent,Ue=t.as(Gu),De=Ue.created,Re=Ue.updated,Le=Ue.deleted,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){De&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Oe,De),Re&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Oe,Re),Le&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Oe,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 167:return n.next=169,this.getChannel(ee.channelUrl,!0);case 169:return Pe=n.sent,Fe=t.as(dv),qe=Fe.pinnedMessageIds,He=Fe.latestPinnedMessage,(Ge=Fe.ts)>Pe._pinnedMessagesUpdatedAt&&(Pe.pinnedMessageIds=qe,Pe.lastPinnedMessage=He,Pe._pinnedMessagesUpdatedAt=Ge,this.upsertChannelsToCache([Pe]),hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Pe)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(Pe)}));case 1:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",173);case 173:return n.abrupt("break",174);case 174:n.next=180;break;case 176:if(n.prev=176,n.t3=n.catch(0),!N(n.t3)){n.next=180;break}throw n.t3;case 180:case"end":return n.stop()}}),n,this,[[0,176],[50,63,66,69]])})))}},{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){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),r=new z_({channelUrl:e,isInternalCall:t}),n.next=4,this._requestQueue.send(r);case 4:return a=n.sent,i=a.as(B_),s=i.channel,n.next=8,this.upsertChannelsToCache([s]);case 8:return n.abrupt("return",n.sent[0]);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},j_),e),ai(V_(n)).throw(A.invalidParameters),r=new K_(n),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(B_),s=i.channel,this.upsertChannelsToCache([s]),t.abrupt("return",s);case 9:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return X_[e]}}])}(hv),$_={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},em=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)},tm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ce,"/").concat(encodeURIComponent(i),"/participants"),a.params={token:s,limit:o},a}return c(t,e),i(t)}(je),nm=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).participants=[];var s=a.next,o=a.participants;return i.token=s,i.participants=o.map((function(t){return new Fo(e,t)})),i}return c(t,e),i(t)}(Ve),rm=function(t){function a(t,i,s){return r(this,a),n(this,a,[t,i,e.ChannelType.OPEN,s])}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new tm(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(nm),s=i.participants,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),am=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a.params=pe(ve({cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l})),a}return c(t,e),i(t)}(je),im=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new om(e,a),i}return c(t,e),i(t)}(Ve),sm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(je),om=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i]))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(o=i.participant_count)&&void 0!==o?o:0,s.operators=Array.isArray(i.operators)?i.operators.map((function(e){return new si(t,e)})):[],s.lastPinnedMessage=i.latest_pinned_message?ho(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,s}return c(a,t),i(a,[{key:"serialize",value:function(){return ni(this)}},{key:"isOperator",value:function(e){return e instanceof si?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 rm(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=J_.of(this._iid),e.next=3,t.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Q_({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(W_),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),J_.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,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Y_({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Z_),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),J_.of(this._iid).setExitedToCache(this),nh.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,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},$_),e),ai(em(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new am(Object.assign({channelUrl:this.url},n)),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(im),u=o.channel,this._update(u),c=J_.of(this._iid),t.next=12,c.upsertChannelsToCache([u]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=Object.assign(Object.assign({},$_),{name:e,coverUrlOrImage:t,data:n,operatorUserIds:r,customType:a}),i.abrupt("return",this.updateChannel(s));case 2:case"end":return i.stop()}}),i,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new sm({channelUrl:this.url}),e.next=4,n.send(r);case 4:return a=J_.of(this._iid),e.next=7,a.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"updateUserMessage",value:function(e,t){var n=this,r=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateUserMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&J_.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&J_.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFileMessage",value:function(e,t){var n=this,r=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateFileMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&J_.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&J_.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},vl.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return si.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?lo(e.lastPinnedMessage):null})))}}])}(vl),um=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserEntered=ht,e.onUserExited=ht,e.onChannelParticipantCountChanged=ht,e.onPollUpdated=ht,e.onPollVoted=ht,e.onPollDeleted=ht,e.onPinnedMessageUpdated=ht,e}return c(t,e),i(t)}(D_),cm=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(um),lm=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,d=e.includeMetaData;return(a=n(this,t)).method=_e.GET,a.path=Ce,a.params=pe({token:i,limit:s,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:d,show_pinned_messages:!0}),a}return c(t,e),i(t)}(je),dm=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return new om(e,t)}))),i.ts="number"==typeof u?u:null,i}return c(t,e),i(t)}(Ve),hm=function(e){function t(e,a){var i,s,o,u,c,l;return r(this,t),(i=n(this,t,[e,a])).includeFrozen=!0,i.includeMetaData=!0,i.nameKeyword=null,i.urlKeyword=null,i.customTypes=null,i.includeFrozen=null===(s=a.includeFrozen)||void 0===s||s,i.includeMetaData=null===(o=a.includeMetaData)||void 0===o||o,i.nameKeyword=null!==(u=a.nameKeyword)&&void 0!==u?u:null,i.urlKeyword=null!==(c=a.urlKeyword)&&void 0!==c?c:null,i.customTypes=null!==(l=a.customTypes)&&void 0!==l?l:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.nameKeyword,!0)&&D("string",this.urlKeyword,!0)&&P("string",this.customTypes,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new lm(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(dm),s=i.channels,o=i.token,this._token=o,this._hasNext=!!o,u=J_.of(this._iid),e.next=15,u.upsertChannelsToCache(s);case 15:return this._isLoading=!1,e.abrupt("return",s);case 17:return e.abrupt("return",[]);case 20:throw A.queryInProgress;case 21:e.next=24;break;case 23:throw A.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}])}(uu),fm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="openChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new J_(e,{sdkState:r,dispatcher:a,requestQueue:s,logger:o,cacheContext:c,sessionManager:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new hm(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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return(s=Object.assign({},j_)).name=e,s.coverUrlOrImage=t,s.data=n,s.operatorUserIds=r,s.customType=a,i.abrupt("return",this._manager.createChannel(s));case 7:case"end":return i.stop()}}),i,this)})))}}])}(ts),pm=Object.freeze({__proto__:null,xmlHttpRequest:function(e,t){return new Promise((function(n,r){if("undefined"!=typeof XMLHttpRequest){var a=es.of(e),i=a.dispatcher,s=a.logger,o=t.requestId,u=t.method,c=t.url,l=t.headers,d=void 0===l?{}:l,h=t.data,f=void 0===h?"":h,p=t.uploadProgressHandler,v=!1,_=new XMLHttpRequest;_.open(u,c),Object.keys(d).forEach((function(e){_.setRequestHeader(e,d[e])})),p&&_.upload.addEventListener("progress",(function(e){e.lengthComputable?p(o,e.loaded,e.total):s.debug("Progress computing failed: `Content-Length` header is not given.")})),_.onabort=function(){r(A.requestCanceled)},_.onerror=function(e){r(A.networkError)},_.onreadystatechange=function(){if(_.readyState===XMLHttpRequest.DONE&&!v)if(0===_.status||_.status>=200&&_.status<400)try{var t=JSON.parse(_.responseText);n(new Ve(e,t))}catch(s){r(A.networkError)}else try{var a=JSON.parse(_.responseText);if(a){var s=new A(a);if(s.isSessionExpiredError){if(i.dispatch(new Be({reason:s.code,message:s.message})),!(_ instanceof We)){var o=new ot;return i.dispatch(new $e({request:_,deferred:o,error:s})),o.promise}}else s.isSessionInvalidatedError&&i.dispatch(new Be({reason:s.code,message:s.message}));r(s)}else r(A.requestFailed)}catch(s){r(A.requestFailed)}},i.on((function(e){e instanceof ut&&(e.requestId&&e.requestId!==o||(v=!0,_.abort()))})),_.send(f)}else r(A.xmlHttpRequestNotSupported)}))}});O_=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 wm(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 xm(e){return"string"!=typeof e&&(e=String(e)),e}function Sm(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return gm&&(t[Symbol.iterator]=function(){return t}),t}function Tm(e){this.map={},e instanceof Tm?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 Im(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function Nm(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Am(e){var t=new FileReader,n=Nm(t);return t.readAsArrayBuffer(e),n}function Mm(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Om(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:ym&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:Em&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:mm&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():km&&ym&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Mm(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):km&&(ArrayBuffer.prototype.isPrototypeOf(e)||Cm(e))?this._bodyArrayBuffer=Mm(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):mm&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},ym&&(this.blob=function(){var e=Im(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=Im(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(ym)return this.blob().then(Am);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,n,r,a,i=Im(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Nm(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),a=r?r[1]:"utf-8",t.readAsText(e,a),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||function(){if("AbortController"in _m)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 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 Rm(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 Lm(e,t){if(!(this instanceof Lm))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 Tm(t.headers),this.url=t.url||"",this._initBody(e)}Dm.prototype.clone=function(){return new Dm(this,{body:this._bodyInit})},Om.call(Dm.prototype),Om.call(Lm.prototype),Lm.prototype.clone=function(){return new Lm(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Tm(this.headers),url:this.url})},Lm.error=function(){var e=new Lm(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var Pm=[301,302,303,307,308];Lm.redirect=function(e,t){if(-1===Pm.indexOf(t))throw new RangeError("Invalid status code");return new Lm(null,{status:t,headers:{location:e}})};var Fm=_m.DOMException;try{new Fm}catch(Mn){(Fm=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),Fm.prototype.constructor=Fm}function qm(e,t){return new Promise((function(n,r){var a=new Dm(e,t);if(a.signal&&a.signal.aborted)return r(new Fm("Aborted","AbortError"));var i=new XMLHttpRequest;function s(){i.abort()}if(i.onload=function(){var e,t,r={statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new Tm,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();try{t.append(r,a)}catch(e){console.warn("Response "+e.message)}}})),t)};0===a.url.indexOf("file://")&&(i.status<200||i.status>599)?r.status=200:r.status=i.status,r.url="responseURL"in i?i.responseURL:r.headers.get("X-Request-URL");var s="response"in i?i.response:i.responseText;setTimeout((function(){n(new Lm(s,r))}),0)},i.onerror=function(){setTimeout((function(){r(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){r(new TypeError("Network request timed out"))}),0)},i.onabort=function(){setTimeout((function(){r(new Fm("Aborted","AbortError"))}),0)},i.open(a.method,function(e){try{return""===e&&_m.location.href?_m.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?i.withCredentials=!0:"omit"===a.credentials&&(i.withCredentials=!1),"responseType"in i&&(ym?i.responseType="blob":km&&(i.responseType="arraybuffer")),t&&"object"===m(t.headers)&&!(t.headers instanceof Tm||_m.Headers&&t.headers instanceof _m.Headers)){var o=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){o.push(wm(e)),i.setRequestHeader(e,xm(t.headers[e]))})),a.headers.forEach((function(e,t){-1===o.indexOf(t)&&i.setRequestHeader(t,e)}))}else a.headers.forEach((function(e,t){i.setRequestHeader(t,e)}));a.signal&&(a.signal.addEventListener("abort",s),i.onreadystatechange=function(){4===i.readyState&&a.signal.removeEventListener("abort",s)}),i.send(void 0===a._bodyInit?null:a._bodyInit)}))}qm.polyfill=!0,_m.fetch||(_m.fetch=qm,_m.Headers=Tm,_m.Request=Dm,_m.Response=Lm);var Hm="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null};Hm.fetch||(Hm.fetch=qm);var Gm=Object.freeze({__proto__:null});e.AdminMessage=Js,e.AppInfo=Wa,e.AppleCriticalAlertOptions=ds,e.ApplicationUserListQuery=wl,e.BannedUserListQuery=yu,e.BaseChannel=vl,e.BaseMessage=Ws,e.BlockedUserListQuery=Tl,e.CachedChannelInfo=Q,e.ConnectionHandler=yl,e.DeliveryStatus=Xf,e.Emoji=_l,e.EmojiCategory=ml,e.EmojiContainer=gl,e.Feedback=fs,e.FileMessage=fo,e.FriendListQuery=Al,e.GroupChannel=E_,e.GroupChannelCollection=N_,e.GroupChannelEventSource=_p,e.GroupChannelFilter=$f,e.GroupChannelHandler=L_,e.GroupChannelListQuery=lv,e.GroupChannelModule=H_,e.LocalCacheConfig=W,e.Member=Zf,e.MemberListQuery=Yv,e.MemoryStore=Sd,e.MessageCollection=jv,e.MessageCollectionInitHandler=Hv,e.MessageEventSource=As,e.MessageFilter=Pd,e.MessageForm=zs,e.MessageFormItem=Bs,e.MessageMetaArray=vs,e.MessageModule=yh,e.MessageRequestHandler=qo,e.MessageReviewInfo=so,e.MessageSearchQuery=dh,e.MultipleFilesMessage=uo,e.MultipleFilesMessageRequestHandler=ol,e.MutedUserListQuery=_u,e.NotificationInfo=Ha,e.OGImage=cs,e.OGMetaData=ls,e.OpenChannel=om,e.OpenChannelHandler=cm,e.OpenChannelListQuery=hm,e.OpenChannelModule=fm,e.OperatorListQuery=hu,e.Participant=Fo,e.ParticipantListQuery=rm,e.PinnedMessage=ul,e.PinnedMessageListQuery=dl,e.Plugin=$s,e.PreviousMessageListQuery=fu,e.PublicGroupChannelListQuery=U_,e.Reaction=us,e.ReactionEvent=os,e.ReadStatus=gs,e.RestrictedUser=Po,e.RestrictionInfo=Lo,e.ScheduledMessageListQuery=q_,e.SendbirdChat=Gf,e.SendbirdChatOptions=j,e.SendbirdError=A,e.Sender=ps,e.SessionHandler=El,e.ThreadInfo=is,e.ThreadInfoUpdateEvent=rh,e.ThreadedParentMessageListQuery=ph,e.Thumbnail=ns,e.UIKitConfigInfo=ja,e.UploadedFileInfo=Hs,e.User=si,e.UserEventHandler=kl,e.UserMessage=oo,Object.defineProperty(e,"__esModule",{value:!0})})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Sendbird={})}(this,(function(e){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=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 i,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw i}}}}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(r){var a=Object.getOwnPropertyDescriptor(r,t);return a.get?a.get.call(arguments.length<3?e:n):a.value}},o.apply(null,arguments)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function d(){d=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",u=i.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 i=t&&t.prototype instanceof g?t:g,s=Object.create(i.prototype),o=new M(r||[]);return a(s,"_invoke",{value:T(e,n,o)}),s}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var f="suspendedStart",p="suspendedYield",v="executing",_="completed",m={};function g(){}function y(){}function E(){}var k={};c(k,s,(function(){return this}));var b=Object.getPrototypeOf,C=b&&b(b(O([])));C&&C!==n&&r.call(C,s)&&(k=C);var w=E.prototype=g.prototype=Object.create(k);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(a,i,s,o){var u=h(e[a],e,i);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,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var i;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return i=i?i.then(a,a):a()}})}function T(t,n,r){var a=f;return function(i,s){if(a===v)throw Error("Generator is already running");if(a===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var o=r.delegate;if(o){var u=I(o,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===f)throw a=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=v;var c=h(t,n,r);if("normal"===c.type){if(a=r.done?_:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(a=_,r.method="throw",r.arg=c.arg)}}}function I(t,n){var r=n.method,a=t.iterator[r];if(a===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,I(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=h(a,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function N(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 A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function M(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(N,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function n(){for(;++a=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(u&&c){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),A(n),m}},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;A(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:O(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),m}},t}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,s,o=[],u=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(o.push(r.value),o.length!==t);u=!0);}catch(e){c=!0,a=e}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw a}}return o}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t,n,r){var a=o(u(1&r?e.prototype:e),t,n);return 2&r?function(e){return a.apply(n,e)}:a}function v(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){var t=function(e,t){if("object"!=typeof e||!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:t+""}function m(e){return m="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},m(e)}function g(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function y(e){var t="function"==typeof Map?new Map:void 0;return y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(l())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var a=new(e.bind.apply(e,r));return n&&h(a,n.prototype),a}(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)},y(e)}function E(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var k,b="4.14.4",C=function(){function e(){r(this,e)}return i(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return b}},{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.SendbirdErrorCode=void 0,(k=e.SendbirdErrorCode||(e.SendbirdErrorCode={}))[k.NON_AUTHORIZED=400108]="NON_AUTHORIZED",k[k.INVALID_TOKEN=400111]="INVALID_TOKEN",k[k.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",k[k.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",k[k.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",k[k.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",k[k.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",k[k.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",k[k.SESSION_REVOKED=400310]="SESSION_REVOKED",k[k.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",k[k.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",k[k.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",k[k.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",k[k.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",k[k.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",k[k.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",k[k.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",k[k.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",k[k.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",k[k.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",k[k.LOST_INSTANCE=700100]="LOST_INSTANCE",k[k.CONNECTION_RENEW=700102]="CONNECTION_RENEW",k[k.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",k[k.INVALID_COMMAND=700700]="INVALID_COMMAND",k[k.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",k[k.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",k[k.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",k[k.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",k[k.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",k[k.INVALID_PARAMETER=800110]="INVALID_PARAMETER",k[k.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",k[k.NETWORK_ERROR=800120]="NETWORK_ERROR",k[k.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",k[k.MALFORMED_DATA=800130]="MALFORMED_DATA",k[k.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",k[k.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",k[k.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",k[k.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",k[k.ACK_TIMEOUT=800180]="ACK_TIMEOUT",k[k.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",k[k.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",k[k.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",k[k.REQUEST_FAILED=800220]="REQUEST_FAILED",k[k.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",k[k.REQUEST_CANCELED=800240]="REQUEST_CANCELED",k[k.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",k[k.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",k[k.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED",k[k.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",k[k.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",k[k.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",k[k.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",k[k.DATABASE_ERROR=800700]="DATABASE_ERROR",k[k.USER_DEACTIVATED=900021]="USER_DEACTIVATED",k[k.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";var w,x,S,T,I,N=function(e){return!(e instanceof A&&!e.shouldThrowOutside)},A=function(t){function a(e){var t,i=e.code,s=void 0===i?0:i,o=e.message,u=void 0===o?"":o;return r(this,a),(t=n(this,a,[u])).shouldThrowOutside=!1,t._detail="",t.name="SendbirdError",t.code=s,Object.setPrototypeOf(t,a.prototype),t}return c(a,t),i(a,[{key:"detail",get:function(){return this._detail}},{key:"setDetail",value:function(e){this._detail=e}},{key:"isInvalidTokenError",get:function(){return this.code===e.SendbirdErrorCode.INVALID_TOKEN}},{key:"isSessionExpiredError",get:function(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}},{key:"isSessionTokenExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_KEY_EXPIRED}},{key:"isSessionInvalidatedError",get:function(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}},{key:"isSessionRevokedError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_REVOKED}},{key:"isUserAuthDeactivedError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DEACTIVATED}},{key:"isUserAuthDeletedOrNotFoundError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}},{key:"isNetworkError",get:function(){return this.code===e.SendbirdErrorCode.NETWORK_ERROR||this.code===e.SendbirdErrorCode.NETWORK_ROUTING_ERROR}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new a({code:e.SendbirdErrorCode.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new a({code:e.SendbirdErrorCode.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"invalidCommand",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new a({code:e.SendbirdErrorCode.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{key:"connectionRenew",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"xmlHttpRequestNotSupported",get:function(){return new a({code:e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}},{key:"connectionRequired",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"channelTypeNotSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}},{key:"networkError",get:function(){return new a({code:e.SendbirdErrorCode.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new a({code:e.SendbirdErrorCode.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new a({code:e.SendbirdErrorCode.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new a({code:e.SendbirdErrorCode.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new a({code:e.SendbirdErrorCode.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new a({code:e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Request failed."})}},{key:"tooManyRequests",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}},{key:"alreadyConnectedAsAnotherUser",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}},{key:"fileUploadCanceled",get:function(){return new a({code:e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new a({code:e.SendbirdErrorCode.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}},{key:"statLogUploadLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}},{key:"malformedDataError",get:function(){return new a({code:e.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}}])}(y(Error)),M=[e.SendbirdErrorCode.CONNECTION_REQUIRED,e.SendbirdErrorCode.NETWORK_ERROR,e.SendbirdErrorCode.ACK_TIMEOUT,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,e.SendbirdErrorCode.REQUEST_CANCELED,e.SendbirdErrorCode.INTERNAL_SERVER_ERROR,e.SendbirdErrorCode.RATE_LIMIT_EXCEEDED,e.SendbirdErrorCode.UNKNOWN_SERVER_ERROR,e.SendbirdErrorCode.USER_DEACTIVATED,e.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],O=[e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.CONNECTION_REQUIRED],U=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},D=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||("string"!=typeof e?"object"===m(e)?R(e,t):L(e,t):m(t)===e)},R=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Object.values(e).includes(t)},L=function(e,t){return t instanceof e},P=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Array.isArray(t)&&t.every((function(t){return D(e,t)}))},F=function(e){return!!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))||"number"==typeof e&&13===e.toString().length},q=function(e){return e>0&&O.indexOf(e)>=0},H=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))return!0;var t="object"===m(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},G=function(e){return null==e},j=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,i=t.typingIndicatorInvalidateTime,s=void 0===i?1e4:i,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,d=t.websocketPayloadDecompression,h=void 0===d||d,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=s,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=h}),[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){D("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){D("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){D("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){D("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){D("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}])}(),V={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){return i((function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}),[{key:"_savePreferenceKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:v(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._version=n,this._keysAddress=e,a="".concat(e,".metadata.version"),r.next=5,this._store.get(a);case 5:return i=r.sent,r.next=8,this._store.get(e);case 8:if(r.t1=t=r.sent,r.t0=null!==r.t1,!r.t0){r.next=12;break}r.t0=void 0!==t;case 12:if(!r.t0){r.next=16;break}r.t2=t,r.next=17;break;case 16:r.t2=[];case 17:if(o=r.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},a=n.maxSize,i=void 0===a?256:a,s=n.clearOrder,o=void 0===s?e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT:s,u=n.customClearOrderComparator,c=n.enableAutoResend,l=void 0===c||c;r(this,t),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(i,64),u?(this._clearOrder=o,this._customClearOrderComparator=u):this._clearOrder=e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=l}),[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var t;return this._clearOrder===e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(t=this._customClearOrderComparator)&&void 0!==t?t:this._clearOrderComparatorUseMessageCollectionAccessedAt}},{key:"enableAutoResend",get:function(){return this._enableAutoResend}}])}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(K||(K={}));var Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue=function(){return i((function e(){r(this,e),this.isRefreshing=!1}),[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"hasChatServicePermission",get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(K.CHAT))}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}])}(),ce=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)}))},le=function(){return i((function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=ce()}),[{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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))}}])}(),de=function(){return i((function e(){r(this,e),this._container={}}),[{key:"on",value:function(e,t){return new le({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new le({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],i=s(n.keys());try{for(i.s();!(r=i.n()).done;){var o=r.value,u=n.get(o);u.handler(t),u.occurence>0&&(u.occurence--,0===u.occurence&&a.push(o))}}catch(e){i.e(e)}finally{i.f()}a.forEach((function(e){return n.delete(e)}))}}}])}(),he=function(){return i((function e(){r(this,e),this._dispatcher=new de}),[{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)}}])}(),fe=i((function e(){r(this,e)})),pe=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},ve=function(e){if(null!=e){if("object"===m(e)){if(Array.isArray(e)){for(var t=v(e),n=0;n3&&void 0!==arguments[3]?arguments[3]:"";return r(this,t),(s=n(this,t))._iid=e,s.code=a,s.payload=i,s.requestId=null!==(o=i.req_id)&&void 0!==o?o:u,s}return c(t,e),i(t,[{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,n){var r=n.substring(0,4),a={};try{a=JSON.parse(n.substring(4))}catch(e){r="NOOP"}finally{return new t(e,r,a)}}}])}(fe),Qe=function(e){function t(e){var a,i,s=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?{}:u;return r(this,t),(a=n(this,t)).code=s,a.payload=c,a.requestId=null!==(i=a.payload.req_id)&&void 0!==i?i:ce(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return c(t,e),i(t,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}])}(fe),We=function(e){function t(e){var a,i=e.userId,s=e.authToken,o=e.services,u=e.expiringSession,c=void 0===u||u;return r(this,t),(a=n(this,t)).path="".concat(ge,"/").concat(i,"/session_key"),a.method=_e.POST,a.params=pe({token:s,services:o,expiring_session:!!c}),a.requireAuth=!1,a}return c(t,e),i(t)}(je),Ye=function(e){function t(e){var a=e.authToken,i=e.expiringSession,s=void 0===i||i,o=e.requestId,u=void 0===o?void 0:o;return r(this,t),n(this,t,[{code:"LOGI",payload:pe({token:a,expiring_session:s?1:0,req_id:u}),ackRequired:!0}])}return c(t,e),i(t)}(Qe),Ze=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.key,o=a.expires_at,u=a.services;return i.key=s,i.expiresAt=o,i.services=u,i}return c(t,e),i(t)}(Ve),Xe=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"LOGI",i])).error=null,s.newKey=null,s.newKey=null!==(o=i.new_key)&&void 0!==o?o:null,s.error=i.error?new A(i):null,s}return c(t,e),i(t)}(Ke),Je=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).statLog=e,a}return c(t,e),i(t)}(fe),$e=function(e){function t(e){var a,i=e.request,s=e.deferred,o=e.error,u=void 0===o?A.requestFailed:o;return r(this,t),(a=n(this,t)).request=i,a.deferred=s,a.error=u,a}return c(t,e),i(t)}(fe);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",e.NOTIFICATION="noti:stats",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Ge||(Ge={}));var et,tt,nt,rt=function(){return i((function e(t){var n=t.type,a=t.data,i=t.ts,s=void 0===i?Date.now():i;r(this,e),this.type=n,this.createdAt=s,this.data=a}),null,[{key:"payloadify",value:function(e){return pe({stat_type:e.type,ts:e.createdAt,data:pe(e.data)})}}])}(),at=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},it=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};e.SendbirdProduct=void 0,(et=e.SendbirdProduct||(e.SendbirdProduct={})).CHAT="chat",et.CALLS="calls",et.DESK="desk",et.LIVE="live",et.UIKIT_CHAT="uikit-chat",et.UIKIT_LIVE="uikit-live",e.SendbirdPlatform=void 0,(tt=e.SendbirdPlatform||(e.SendbirdPlatform={})).ANDROID="android",tt.IOS="ios",tt.JS="js",tt.UNREAL="unreal",tt.UNITY="unity",tt.REACT_NATIVE="react-native",tt.FLUTTER="flutter",e.DeviceOsPlatform=void 0,(nt=e.DeviceOsPlatform||(e.DeviceOsPlatform={})).ANDROID="android",nt.IOS="ios",nt.WEB="web",nt.MOBILE_WEB="mobile_web",nt.WINDOWS="windows";var st=i((function e(){r(this,e)}));st.sendbirdSdkUserAgentWithExtension=function(t){var n=at()?e.SendbirdPlatform.REACT_NATIVE:e.SendbirdPlatform.JS,r={main_sdk_info:"chat/".concat(n,"/").concat(C.SDK_VERSION),device_os_platform:it()?"mobile-web":"web",os_version:C.OS_VERSION};if(t){var a=t.sendbirdExtensions,i=t.deviceOS,s=t.customData,o=void 0===s?{}:s;i.version&&(r.os_version=i.version),i.platform&&(r.device_os_platform=i.platform),a.length>0&&(r.extension_sdk_info=a.map((function(e){var t=e.product,n=e.platform,r=e.version;return"".concat(t,"/").concat(n,"/").concat(r)})).join(",")),Object.keys(r).forEach((function(e){return delete o[e]})),Object.keys(o).length>0&&(r=Object.assign(Object.assign({},r),o))}return Object.entries(r).map((function(e){var t=f(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join("&")},st.userAgentWithExtension=function(e){var t=at()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):it()?"omobile-web":"oweb";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)};var ot=i((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=function(e){n(e)}}))})),ut=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).requestId=e.requestId,a}return c(t,e),i(t)}(fe),ct=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),e.messageToken&&(a.params=pe({mesg_token:e.messageToken})),a}return c(t,e),i(t)}(je),lt=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"DELM",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(o=i.sender_id)&&void 0!==o?o:void 0,s}return c(t,e),i(t)}(Ke),dt=function(){return i((function e(t,n){var a=this,i=n.session,s=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._session=i,this._sdkState=s,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof ze&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}),[{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,i=n.sendbirdRuntimeEnvironment,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":st.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":st.sendbirdSdkUserAgentWithExtension(i)});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(s["Session-Key"]=this._session.sessionKey),s["App-Id"]=r,this._session&&this._session.authToken&&(s["Access-Token"]=this._session.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new Je(new rt({type:Ge.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:"_isBodyRequired",value:function(e){var t=e.method;return t!==_e.GET&&(t!==_e.DELETE||e instanceof ct)}},{key:"send",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=t.path,a=t.method,i=t.uploadProgressHandler,s=this._isBodyRequired(t),o=this._sdkState.api,u="".concat(o.host).concat(r).concat(s?"":t.query),c=s?t.payload:null,l=this._createHeader(t,c instanceof FormData?c:void 0),h=new AbortController,f=h.signal,this._abortControl.set(t.requestId,h),p=Date.now(),n.prev=10,!i){n.next=32;break}return n.next=14,Promise.resolve().then((function(){return pm}));case 14:return v=n.sent,_=v.xmlHttpRequest,n.prev=16,n.next=19,_(this._iid,{requestId:t.requestId,method:t.method,url:u,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i});case 19:return m=n.sent,this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",m);case 25:if(n.prev=25,n.t0=n.catch(16),!(n.t0 instanceof A&&n.t0.code===e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED)){n.next=31;break}this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),n.next=32;break;case 31:throw n.t0;case 32: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){n.next=36;break}return n.next=36,Promise.resolve().then((function(){return vm}));case 36:if("function"==typeof fetch){n.next=39;break}return n.next=39,Promise.resolve().then((function(){return Gm}));case 39:return n.next=41,fetch(u,{method:a,body:c,headers:l,signal:f});case 41:return g=n.sent,n.next=44,g.json();case 44:if(y=n.sent,!g.ok&&!g.redirected){n.next=51;break}return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",new Ve(this._iid,y));case 51:if(!y){n.next=70;break}if(!(E=new A(y)).isSessionExpiredError){n.next=62;break}if(this._dispatcher.dispatch(new Be({reason:E.code,message:E.message})),t instanceof We){n.next=59;break}return k=new ot,this._dispatcher.dispatch(new $e({request:t,deferred:k,error:E})),n.abrupt("return",k.promise);case 59:case 67:throw E;case 62:if(!E.isSessionInvalidatedError){n.next=67;break}throw this._dispatcher.dispatch(new Be({reason:E.code,message:E.message})),E;case 68:n.next=71;break;case 70:throw A.requestFailed;case 71:n.next=87;break;case 73:if(n.prev=73,n.t1=n.catch(10),this._statLogApiResult(t,p,n.t1),!(n.t1 instanceof A)){n.next=81;break}throw this._logger.debug("fail api request",n.t1),n.t1;case 81:if("AbortError"!==(null===n.t1||void 0===n.t1?void 0:n.t1.name)){n.next=85;break}throw A.requestCanceled;case 85:throw this._logger.debug("fail api request",n.t1),A.networkError;case 87:case"end":return n.stop()}}),n,this,[[10,73],[16,25]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new ut({requestId:e}))}},{key:"cancelAll",value:function(){var e,t=s(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(),this._dispatcher.dispatch(new ut({}))}}])}(),ht=function(){};function ft(e){let t=e.length;for(;--t>=0;)e[t]=0}const pt=256,vt=286,_t=30,mt=15,gt=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]),yt=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]),Et=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),kt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bt=new Array(576);ft(bt);const Ct=new Array(60);ft(Ct);const wt=new Array(512);ft(wt);const xt=new Array(256);ft(xt);const St=new Array(29);ft(St);const Tt=new Array(_t);function It(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 Nt,At,Mt;function Ot(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ft(Tt);const Ut=e=>e<256?wt[e]:wt[256+(e>>>7)],Dt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Rt=(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<{Rt(e,n[2*t],n[2*t+1])},Pt=(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,i,s=0;for(a=1;a<=mt;a++)s=s+n[a-1]<<1,r[a]=s;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=Pt(r[t]++,t))}},qt=e=>{let t;for(t=0;t{e.bi_valid>8?Dt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Gt=(e,t,n,r)=>{const a=2*t,i=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,i,s,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?Lt(e,a,t):(i=xt[a],Lt(e,i+pt+1,t),s=gt[i],0!==s&&(a-=St[i],Rt(e,a,s)),r--,i=Ut(r),Lt(e,i,n),s=yt[i],0!==s&&(r-=Tt[i],Rt(e,r,s)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,i=t.stat_desc.elems;let s,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)jt(e,n,s);u=i;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],jt(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,n[2*u]=n[2*s]+n[2*o],e.depth[u]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,n[2*s+1]=n[2*o+1]=u,e.heap[1]=u++,jt(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,i=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,d,h,f,p,v=0;for(h=0;h<=mt;h++)e.bl_count[h]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],h=n[2*n[2*l+1]+1]+1,h>u&&(h=u,v++),n[2*l+1]=h,l>r||(e.bl_count[h]++,f=0,l>=o&&(f=s[l-o]),p=n[2*l],e.opt_len+=p*(h+f),i&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(h=u-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(h=u;0!==h;h--)for(l=e.bl_count[h];0!==l;)d=e.heap[--c],d>r||(n[2*d+1]!==h&&(e.opt_len+=(h-n[2*d+1])*n[2*d],n[2*d+1]=h),l--)}})(e,t),Ft(n,c,e.bl_count)},Bt=(e,t,n)=>{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=s,s=t[2*(r+1)+1],++o{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),r=0;r<=n;r++)if(a=s,s=t[2*(r+1)+1],!(++o{Rt(e,0+(r?1:0),3),Ht(e),Dt(e,n),Dt(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Yt=(e,t,n,r)=>{let a,i,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(Bt(e,e.dyn_ltree,e.l_desc.max_code),Bt(e,e.dyn_dtree,e.d_desc.max_code),zt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*kt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=a&&(a=i)):a=i=n+5,n+4<=a&&-1!==t?Wt(e,t,n,r):4===e.strategy||i===a?(Rt(e,2+(r?1:0),3),Vt(e,bt,Ct)):(Rt(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(Rt(e,t-257,5),Rt(e,n-1,5),Rt(e,r-4,4),a=0;a{Qt||((()=>{let e,t,n,r,a;const i=new Array(16);for(n=0,r=0;r<28;r++)for(St[r]=n,e=0;e<1<>=7;r<_t;r++)for(Tt[r]=a<<7,e=0;e<1<(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*(xt[n]+pt+1)]++,e.dyn_dtree[2*Ut(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Rt(e,2,3),Lt(e,256,bt),(e=>{16===e.bi_valid?(Dt(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 Xt=(e,t,n,r)=>{let a=65535&e,i=e>>>16&65535,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{a=a+t[r++]|0,i=i+a|0}while(--s);a%=65521,i%=65521}return a|i<<16};const Jt=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 $t=(e,t,n,r)=>{const a=Jt,i=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return~e},en={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"},tn={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:nn,_tr_stored_block:rn,_tr_flush_block:an,_tr_tally:sn,_tr_align:on}=Zt,{Z_NO_FLUSH:un,Z_PARTIAL_FLUSH:cn,Z_FULL_FLUSH:ln,Z_FINISH:dn,Z_BLOCK:hn,Z_OK:fn,Z_STREAM_END:pn,Z_STREAM_ERROR:vn,Z_DATA_ERROR:_n,Z_BUF_ERROR:mn,Z_DEFAULT_COMPRESSION:gn,Z_FILTERED:yn,Z_HUFFMAN_ONLY:En,Z_RLE:kn,Z_FIXED:bn,Z_DEFAULT_STRATEGY:Cn,Z_UNKNOWN:wn,Z_DEFLATED:xn}=tn,Sn=258,Tn=262,In=42,Nn=113,An=666,Mn=(e,t)=>(e.msg=en[t],t),On=e=>2*e-(e>4?9:0),Un=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Dn=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 Rn=(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))},Pn=(e,t)=>{an(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Ln(e.strm)},Fn=(e,t)=>{e.pending_buf[e.pending++]=t},qn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Hn=(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=Xt(e.adler,t,a,n):2===e.state.wrap&&(e.adler=$t(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},Gn=(e,t)=>{let n,r,a=e.max_chain_length,i=e.strstart,s=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,d=e.prev,h=e.strstart+Sn;let f=c[i+s-1],p=c[i+s];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+s]===p&&c[n+s-1]===f&&c[n]===c[i]&&c[++n]===c[i+1]){i+=2,n++;do{}while(c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&is){if(e.match_start=t,s=r,r>=o)break;f=c[i+s-1],p=c[i+s]}}}while((t=d[t&l])>u&&0!=--a);return s<=e.lookahead?s:e.lookahead},jn=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),Dn(e),r+=t),0===e.strm.avail_in)break;if(n=Hn(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=Rn(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=Rn(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,i=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Ln(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(Hn(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 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&&(Hn(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,i=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=i||(r||t===dn)&&t!==un&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,s=t===dn&&0===e.strm.avail_in&&n===r?1:0,rn(e,e.block_start,n,s),e.block_start+=n,Ln(e.strm)),s?3:1)},zn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=Rn(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=Gn(e,n)),e.match_length>=3)if(r=sn(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=Rn(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=Rn(e,e.ins_h,e.window[e.strstart+1]);else r=sn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Pn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2},Bn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=Rn(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=sn(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=Rn(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&&(Pn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=sn(e,0,e.window[e.strstart-1]),r&&Pn(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=sn(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2};function Kn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const Qn=[new Kn(0,0,0,0,Vn),new Kn(4,4,8,4,zn),new Kn(4,5,16,8,zn),new Kn(4,6,32,32,zn),new Kn(4,4,16,16,Bn),new Kn(8,16,32,32,Bn),new Kn(8,16,128,128,Bn),new Kn(8,32,128,256,Bn),new Kn(32,128,258,1024,Bn),new Kn(32,258,258,4096,Bn)];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=xn,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 Yn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==In&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Nn&&t.status!==An?1:0},Zn=e=>{if(Yn(e))return Mn(e,vn);e.total_in=e.total_out=0,e.data_type=wn;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?In:Nn,e.adler=2===t.wrap?0:1,t.last_flush=-2,nn(t),fn},Xn=e=>{const t=Zn(e);var n;return t===fn&&((n=e.state).window_size=2*n.w_size,Un(n.head),n.max_lazy_match=Qn[n.level].max_lazy,n.good_match=Qn[n.level].good_length,n.nice_match=Qn[n.level].nice_length,n.max_chain_length=Qn[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},Jn=(e,t,n,r,a,i)=>{if(!e)return vn;let s=1;if(t===gn&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),a<1||a>9||n!==xn||r<8||r>15||t<0||t>9||i<0||i>bn||8===r&&1!==s)return Mn(e,vn);8===r&&(r=9);const o=new Wn;return e.state=o,o.strm=e,o.status=In,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<Jn(e,t,xn,15,8,Cn),deflateInit2:Jn,deflateReset:Xn,deflateResetKeep:Zn,deflateSetHeader:(e,t)=>Yn(e)||2!==e.state.wrap?vn:(e.state.gzhead=t,fn),deflate:(e,t)=>{if(Yn(e)||t>hn||t<0)return e?Mn(e,vn):vn;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===An&&t!==dn)return Mn(e,0===e.avail_out?mn:vn);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Ln(e),0===e.avail_out)return n.last_flush=-1,fn}else if(0===e.avail_in&&On(t)<=On(r)&&t!==dn)return Mn(e,mn);if(n.status===An&&0!==e.avail_in)return Mn(e,mn);if(n.status===In&&0===n.wrap&&(n.status=Nn),n.status===In){let t=xn+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=En||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,qn(n,t),0!==n.strstart&&(qn(n,e.adler>>>16),qn(n,65535&e.adler)),e.adler=1,n.status=Nn,Ln(e),0!==n.pending)return n.last_flush=-1,fn}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>=En||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=$t(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>=En||n.level<2?4:0),Fn(n,3),n.status=Nn,Ln(e),0!==n.pending)return n.last_flush=-1,fn;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=$t(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,Ln(e),0!==n.pending)return n.last_flush=-1,fn;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=$t(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=$t(e.adler,n.pending_buf,n.pending-r,r)),Ln(e),0!==n.pending)return n.last_flush=-1,fn;r=0}t=n.gzindexr&&(e.adler=$t(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=$t(e.adler,n.pending_buf,n.pending-r,r)),Ln(e),0!==n.pending)return n.last_flush=-1,fn;r=0}t=n.gzindexr&&(e.adler=$t(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Ln(e),0!==n.pending))return n.last_flush=-1,fn;Fn(n,255&e.adler),Fn(n,e.adler>>8&255),e.adler=0}if(n.status=Nn,Ln(e),0!==n.pending)return n.last_flush=-1,fn}if(0!==e.avail_in||0!==n.lookahead||t!==un&&n.status!==An){let r=0===n.level?Vn(n,t):n.strategy===En?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(jn(e),0===e.lookahead)){if(t===un)return 1;break}if(e.match_length=0,n=sn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Pn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===kn?((e,t)=>{let n,r,a,i;const s=e.window;for(;;){if(e.lookahead<=Sn){if(jn(e),e.lookahead<=Sn&&t===un)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=s[a],r===s[++a]&&r===s[++a]&&r===s[++a])){i=e.strstart+Sn;do{}while(r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=sn(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=sn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Pn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2})(n,t):Qn[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),fn;if(2===r&&(t===cn?on(n):t!==hn&&(rn(n,0,0,!1),t===ln&&(Un(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Ln(e),0===e.avail_out))return n.last_flush=-1,fn}return t!==dn?fn:n.wrap<=0?pn:(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)):(qn(n,e.adler>>>16),qn(n,65535&e.adler)),Ln(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?fn:pn)},deflateEnd:e=>{if(Yn(e))return vn;const t=e.state.status;return e.state=null,t===Nn?Mn(e,_n):fn},deflateSetDictionary:(e,t)=>{let n=t.length;if(Yn(e))return vn;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==In||r.lookahead)return vn;if(1===a&&(e.adler=Xt(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 i=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,jn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Rn(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,jn(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=o,e.avail_in=i,r.wrap=a,fn},deflateInfo:"pako deflate (from Nodeca project)"};const er=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var tr={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)er(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;rr[254]=rr[254]=1;var ar={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,i,s=e.length,o=0;for(a=0;a>>6,t[i++]=128|63&n):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|63&n):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=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 i=new Array(2*n);for(a=0,r=0;r4)i[a++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?i[a++]=65533:t<65536?i[a++]=t:(t-=65536,i[a++]=55296|t>>10&1023,i[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&nr)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+rr[e[n]]>t?n:t}};var ir=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 sr=Object.prototype.toString,{Z_NO_FLUSH:or,Z_SYNC_FLUSH:ur,Z_FULL_FLUSH:cr,Z_FINISH:lr,Z_OK:dr,Z_STREAM_END:hr,Z_DEFAULT_COMPRESSION:fr,Z_DEFAULT_STRATEGY:pr,Z_DEFLATED:vr}=tn;function _r(e){this.options=tr.assign({level:fr,method:vr,chunkSize:16384,windowBits:15,memLevel:8,strategy:pr},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 ir,this.strm.avail_out=0;let n=$n.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==dr)throw new Error(en[n]);if(t.header&&$n.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?ar.string2buf(t.dictionary):"[object ArrayBuffer]"===sr.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=$n.deflateSetDictionary(this.strm,e),n!==dr)throw new Error(en[n]);this._dict_set=!0}}function mr(e,t){const n=new _r(t);if(n.push(e,!0),n.err)throw n.msg||en[n.err];return n.result}_r.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,i;if(this.ended)return!1;for(i=t===~~t?t:!0===t?lr:or,"string"==typeof e?n.input=ar.string2buf(e):"[object ArrayBuffer]"===sr.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),(i===ur||i===cr)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=$n.deflate(n,i),a===hr)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=$n.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===dr;if(0!==n.avail_out){if(i>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},_r.prototype.onData=function(e){this.chunks.push(e)},_r.prototype.onEnd=function(e){e===dr&&(this.result=tr.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var gr={Deflate:_r,deflate:mr,deflateRaw:function(e,t){return(t=t||{}).raw=!0,mr(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,mr(e,t)},constants:tn};const yr=16209;var Er=function(e,t){let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x;const S=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,i=a-(t-e.avail_out),s=a+(e.avail_out-257),o=S.dmax,u=S.wsize,c=S.whave,l=S.wnext,d=S.window,h=S.hold,f=S.bits,p=S.lencode,v=S.distcode,_=(1<>>24,h>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(64&y){if(32&y){S.mode=16191;break e}e.msg="invalid literal/length code",S.mode=yr;break e}g=p[(65535&g)+(h&(1<>>=y,f-=y),f<15&&(h+=w[n++]<>>24,h>>>=y,f-=y,y=g>>>16&255,16&y){if(k=65535&g,y&=15,fo){e.msg="invalid distance too far back",S.mode=yr;break e}if(h>>>=y,f-=y,y=a-i,k>y){if(y=k-y,y>c&&S.sane){e.msg="invalid distance too far back",S.mode=yr;break e}if(b=0,C=d,0===l){if(b+=u-y,y2;)x[a++]=C[b++],x[a++]=C[b++],x[a++]=C[b++],E-=3;E&&(x[a++]=C[b++],E>1&&(x[a++]=C[b++]))}else{b=a-k;do{x[a++]=x[b++],x[a++]=x[b++],x[a++]=x[b++],E-=3}while(E>2);E&&(x[a++]=x[b++],E>1&&(x[a++]=x[b++]))}break}if(64&y){e.msg="invalid distance code",S.mode=yr;break e}g=v[(65535&g)+(h&(1<>3,n-=E,f-=E<<3,h&=(1<{const u=o.bits;let c,l,d,h,f,p,v=0,_=0,m=0,g=0,y=0,E=0,k=0,b=0,C=0,w=0,x=null;const S=new Uint16Array(16),T=new Uint16Array(16);let I,N,A,M=null;for(v=0;v<=kr;v++)S[v]=0;for(_=0;_=1&&0===S[g];g--);if(y>g&&(y=g),0===g)return a[i++]=20971520,a[i++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(T[1]=0,v=1;v852||2===e&&C>592)return 1;for(;;){I=v-k,s[_]+1=p?(N=M[s[_]-p],A=x[s[_]-p]):(N=96,A=0),c=1<>k)+l]=I<<24|N<<16|A}while(0!==l);for(c=1<>=1;if(0!==c?(w&=c-1,w+=c):w=0,_++,0==--S[v]){if(v===g)break;v=t[n+s[_]]}if(v>y&&(w&h)!==d){for(0===k&&(k=y),f+=m,E=v-k,b=1<852||2===e&&C>592)return 1;d=w&h,a[d]=y<<24|E<<16|f-i}}return 0!==w&&(a[f+w]=v-k<<24|64<<16),o.bits=y,0};const{Z_FINISH:Tr,Z_BLOCK:Ir,Z_TREES:Nr,Z_OK:Ar,Z_STREAM_END:Mr,Z_NEED_DICT:Or,Z_STREAM_ERROR:Ur,Z_DATA_ERROR:Dr,Z_MEM_ERROR:Rr,Z_BUF_ERROR:Lr,Z_DEFLATED:Pr}=tn,Fr=16180,qr=16190,Hr=16191,Gr=16192,jr=16194,Vr=16199,zr=16200,Br=16206,Kr=16209,Qr=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 Yr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Zr=e=>{if(Yr(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,Ar},Xr=e=>{if(Yr(e))return Ur;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Zr(e)},Jr=(e,t)=>{let n;if(Yr(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,Xr(e))},$r=(e,t)=>{if(!e)return Ur;const n=new Wr;e.state=n,n.strm=e,n.window=null,n.mode=Fr;const r=Jr(e,t);return r!==Ar&&(e.state=null),r};let ea,ta,na=!0;const ra=e=>{if(na){ea=new Int32Array(512),ta=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(Sr(1,e.lens,0,288,ea,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Sr(2,e.lens,0,32,ta,0,e.work,{bits:5}),na=!1}e.lencode=ea,e.lenbits=9,e.distcode=ta,e.distbits=5},aa=(e,t,n,r)=>{let a;const i=e.state;return null===i.window&&(i.wsize=1<=i.wsize?(i.window.set(t.subarray(n-i.wsize,n),0),i.wnext=0,i.whave=i.wsize):(a=i.wsize-i.wnext,a>r&&(a=r),i.window.set(t.subarray(n-r,n-r+a),i.wnext),(r-=a)?(i.window.set(t.subarray(n-r,n),0),i.wnext=r,i.whave=i.wsize):(i.wnext+=a,i.wnext===i.wsize&&(i.wnext=0),i.whave$r(e,15),inflateInit2:$r,inflate:(e,t)=>{let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w=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(Yr(e)||!e.output||!e.input&&0!==e.avail_in)return Ur;n=e.state,n.mode===Hr&&(n.mode=Gr),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,d=o,h=u,C=Ar;e:for(;;)switch(n.mode){case Fr:if(0===n.wrap){n.mode=Gr;break}for(;l<16;){if(0===o)break e;o--,c+=r[i++]<>>8&255,n.check=$t(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=Kr;break}if((15&c)!==Pr){e.msg="unknown compression method",n.mode=Kr;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=Kr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=$t(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[i++]<>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=$t(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[i++]<>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=$t(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[i++]<>>8&255,n.check=$t(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(i,i+f),b)),512&n.flags&&4&n.wrap&&(n.check=$t(n.check,r,f,i)),o-=f,i+=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[i+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=Hr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[i++]<>>=7&l,l-=7&l,n.mode=Br;break}for(;l<3;){if(0===o)break e;o--,c+=r[i++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(ra(n),n.mode=Vr,t===Nr){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Kr}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[i++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Kr;break}if(n.length=65535&c,c=0,l=0,n.mode=jr,t===Nr)break e;case jr: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(i,i+f),s),o-=f,i+=f,u-=f,s+=f,n.length-=f;break}n.mode=Hr;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[i++]<>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Kr;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,S={bits:n.lenbits},C=Sr(0,n.lens,0,19,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid code lengths set",n.mode=Kr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=_,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=Kr;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=Kr;break}for(;f--;)n.lens[n.have++]=b}}if(n.mode===Kr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Kr;break}if(n.lenbits=9,S={bits:n.lenbits},C=Sr(1,n.lens,0,n.nlen,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid literal/lengths set",n.mode=Kr;break}if(n.distbits=6,n.distcode=n.distdyn,S={bits:n.distbits},C=Sr(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,S),n.distbits=S.bits,C){e.msg="invalid distances set",n.mode=Kr;break}if(n.mode=Vr,t===Nr)break e;case Vr:n.mode=zr;case zr:if(o>=6&&u>=258){e.next_out=s,e.avail_out=u,e.next_in=i,e.avail_in=o,n.hold=c,n.bits=l,Er(e,h),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===Hr&&(n.back=-1);break}for(n.back=0;w=n.lencode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=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=Hr;break}if(64&m){e.msg="invalid literal/length code",n.mode=Kr;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(T=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;w=n.distcode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=Kr;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(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=Kr;break}n.mode=16204;case 16204:if(0===u)break e;if(f=h-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Kr;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=s-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[s++]=v[p++]}while(--f);0===n.length&&(n.mode=zr);break;case 16205:if(0===u)break e;a[s++]=n.length,u--,n.mode=zr;break;case Br:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[i++]<{if(Yr(e))return Ur;let t=e.state;return t.window&&(t.window=null),e.state=null,Ar},inflateGetHeader:(e,t)=>{if(Yr(e))return Ur;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Ar):Ur},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,i;return Yr(e)?Ur:(r=e.state,0!==r.wrap&&r.mode!==qr?Ur:r.mode===qr&&(a=1,a=Xt(a,t,n,0),a!==r.check)?Dr:(i=aa(e,t,n,n),i?(r.mode=16210,Rr):(r.havedict=1,Ar)))},inflateInfo:"pako inflate (from Nodeca project)"};var sa=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 oa=Object.prototype.toString,{Z_NO_FLUSH:ua,Z_FINISH:ca,Z_OK:la,Z_STREAM_END:da,Z_NEED_DICT:ha,Z_STREAM_ERROR:fa,Z_DATA_ERROR:pa,Z_MEM_ERROR:va}=tn;function _a(e){this.options=tr.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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ir,this.strm.avail_out=0;let n=ia.inflateInit2(this.strm,t.windowBits);if(n!==la)throw new Error(en[n]);if(this.header=new sa,ia.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=ar.string2buf(t.dictionary):"[object ArrayBuffer]"===oa.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ia.inflateSetDictionary(this.strm,t.dictionary),n!==la)))throw new Error(en[n])}function ma(e,t){const n=new _a(t);if(n.push(e),n.err)throw n.msg||en[n.err];return n.result}_a.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let i,s,o;if(this.ended)return!1;for(s=t===~~t?t:!0===t?ca:ua,"[object ArrayBuffer]"===oa.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),i=ia.inflate(n,s),i===ha&&a&&(i=ia.inflateSetDictionary(n,a),i===la?i=ia.inflate(n,s):i===pa&&(i=ha));n.avail_in>0&&i===da&&n.state.wrap>0&&0!==e[n.next_in];)ia.inflateReset(n),i=ia.inflate(n,s);switch(i){case fa:case pa:case ha:case va:return this.onEnd(i),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||i===da))if("string"===this.options.to){let e=ar.utf8border(n.output,n.next_out),t=n.next_out-e,a=ar.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(i!==la||0!==o){if(i===da)return i=ia.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},_a.prototype.onData=function(e){this.chunks.push(e)},_a.prototype.onEnd=function(e){e===la&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=tr.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ga={Inflate:_a,inflate:ma,inflateRaw:function(e,t){return(t=t||{}).raw=!0,ma(e,t)},ungzip:ma,constants:tn};const{Deflate:ya,deflate:Ea,deflateRaw:ka,gzip:ba}=gr,{Inflate:Ca,inflate:wa,inflateRaw:xa,ungzip:Sa}=ga;var Ta,Ia={Deflate:ya,deflate:Ea,deflateRaw:ka,gzip:ba,Inflate:Ca,inflate:wa,inflateRaw:xa,ungzip:Sa,constants:tn},Na=function(e){return E(void 0,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Ia.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,n));case 2:case"end":return t.stop()}}),t)})))};e.ConnectionState=void 0,(Ta=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",Ta.OPEN="OPEN",Ta.CLOSED="CLOSED";var Aa,Ma=function(t){function a(e,t){var i,s=t.sdkState,o=t.dispatcher,u=t.logger;return r(this,a),(i=n(this,a)).lastActive=0,i._iid=e,i._sdkState=s,i._dispatcher=o,i._logger=u,i}return c(a,t),i(a,[{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:"ws",get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ke.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 Be(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return E(this,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){r._logger.debug("websocket open"),r.dispatch("open")},this._ws.onmessage=function(e){return E(r,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)){t.next=38;break}if(!(e.data instanceof Blob)){t.next=7;break}(r=new FileReader).readAsArrayBuffer(e.data),r.onloadend=function(){return E(u,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Na(r.result);case 3:t=e.sent,this._handleMessage(t),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),this.error(e.t0);case 10:case"end":return e.stop()}}),e,this,[[0,7]])})))},t.next=36;break;case 7:if(!(e.data instanceof ArrayBuffer)){t.next=20;break}return t.prev=8,t.next=11,Na(new Uint8Array(e.data));case 11:a=t.sent,this._handleMessage(a),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),this.error(t.t0);case 18:t.next=36;break;case 20:if(!("undefined"!=typeof Buffer&&e.data instanceof Buffer)){t.next=35;break}return t.prev=21,i=e.data,s=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),t.next=26,Na(s);case 26:o=t.sent,this._handleMessage(o),t.next=33;break;case 30:t.prev=30,t.t1=t.catch(21),this.error(t.t1);case 33:t.next=36;break;case 35:"string"==typeof e.data&&this._handleMessage(e.data);case 36:t.next=39;break;case 38:this._handleMessage(e.data);case 39:case"end":return t.stop()}}),t,this,[[8,15],[21,30]])})))},this._ws.onerror=function(){r._logger.debug("websocket error"),r.dispatch("error",A.networkError)},this._ws.onclose=function(){r._logger.debug("websocket close"),r.dispatch("close")},this.lastActive=Date.now();case 6:case"end":return n.stop()}}),n,this)})))}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws?(t._ws.onopen=ht,t._ws.onmessage=ht,t._ws.onerror=ht,t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=void 0):n()):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)}}])}(de),Oa=function(e){function t(e){var a,i=e.all,s=e.feed,o=e.custom_types,u=e.ts;return r(this,t),(a=n(this,t)).all=i,a.feed=s,a.customTypes=o,a.ts=u,a}return c(t,e),i(t)}(fe),Ua=function(){return i((function e(t,n){var a=this,i=n.session,s=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=s,this._dispatcher=o,this._logger=u,this.apiClient=new dt(t,{session:i,sdkState:s,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new Ma(t,{sdkState:s,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new Oa(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new A({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(A.connectionClosed)})),a._ackStateMap.clear()}))}),[{key:"_sendApiRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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(n=new ot,e.ackRequired){a=function(t,a){i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),r&&(clearTimeout(r),r=null),t?(i._logger.debug("fail websocket request",e.requestId,t),n.reject(t)):(i._logger.debug("receive websocket ack",e.requestId,e),i._logger.debug("receive websocket ack",a),n.resolve(a)))};try{r=setTimeout((function(){return a(A.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return a(void 0,e)},reject:function(e){return a(e)}}),this.websocketClient.send(e)}catch(e){a(e)}}else try{this.websocketClient.send(e),n.resolve()}catch(e){n.reject(e)}return t.abrupt("return",n.promise);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof je)){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 Qe)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw A.invalidParameters;case 11:case"end":return t.stop()}}),t,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}])}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(Aa||(Aa={}));var Da,Ra,La=function(e){function t(e){var a,i=e.stateType;return r(this,t),(a=n(this,t)).stateType=i,a}return c(t,e),i(t)}(fe),Pa=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Fa=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),qa=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Ha=function(){return i((function e(t){var n,a,i,s;r(this,e),this.isEnabled=null!==(n=t.enabled)&&void 0!==n&&n,this.feedChannels=null!==(a=t.feed_channels)&&void 0!==a?a:{},this.templateListToken=null!==(i=t.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(s=t.settings_updated_at)&&void 0!==s?s:0}),null,[{key:"payloadify",value:function(e){return pe(ve({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}])}(),Ga=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},ja=function(){return i((function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}),null,[{key:"payloadify",value:function(e){return pe(ve({last_updated_at:e.lastUpdatedAt}))}}])}(),Va=function(){return i((function e(t){var n;r(this,e),this.token=null!==(n=t.template_list_token)&&void 0!==n?n:""}),null,[{key:"payloadify",value:function(e){return pe(ve({template_list_token:e.token}))}}])}(),za=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180};r(this,e),this.minStatCount=t.min_stat_count,this.minInterval=1e3*t.min_interval,this.maxStatCountPerRequest=t.max_stat_count_per_request,this.lowerThreshold=t.lower_threshold,this.requestDelayRange=1e3*t.request_delay_range}),null,[{key:"payloadify",value:function(e){return pe(ve({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}])}(),Ba=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}};r(this,e),this.default=new za(t.default),this.realTime=new za(t.realtime)}),null,[{key:"payloadify",value:function(e){return pe(ve({default:za.payloadify(e.default),realtime:za.payloadify(e.realTime)}))}}])}(),Ka=1048576;e.UnreadCountThreadingPolicy=void 0,(Da=e.UnreadCountThreadingPolicy||(e.UnreadCountThreadingPolicy={}))[Da.NONE=0]="NONE",Da[Da.INCLUDE_REPLY=1]="INCLUDE_REPLY",Da[Da.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Da[Da.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",e.LastMessageThreadingPolicy=void 0,(Ra=e.LastMessageThreadingPolicy||(e.LastMessageThreadingPolicy={}))[Ra.NONE=0]="NONE",Ra[Ra.INCLUDE_REPLY=1]="INCLUDE_REPLY",Ra[Ra.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Ra[Ra.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";var Qa,Wa=function(){return i((function t(){var n,a,i,s,o,u,c,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),this.emojiHash=l.emoji_hash||"",this.uploadSizeLimit=l.file_upload_size_limit?l.file_upload_size_limit*Ka:Number.MAX_SAFE_INTEGER,this.useReaction=!!l.use_reaction,this.applicationAttributes=null!==(n=l.application_attributes)&&void 0!==n?n:[],this.premiumFeatureList=null!==(a=l.premium_feature_list)&&void 0!==a?a:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(i=l.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(s=l.allow_sdk_log_ingestion)||void 0===s||s,this.unreadCountThreadingPolicy=null!==(o=l.unread_cnt_threading_policy)&&void 0!==o?o:e.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(u=l.last_msg_threading_policy)&&void 0!==u?u:e.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new ja(null!==(c=l.uikit_config)&&void 0!==c?c:{}),this.notificationInfo=l.notifications?new Ha(l.notifications):null,this.messageTemplateInfo=l.message_template?new Va(l.message_template):null,this.statConfigInfo=l.log_publish_config?new Ba(l.log_publish_config):new Ba}),null,[{key:"payloadify",value:function(e){return pe(ve({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ka,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?ja.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Ha.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Va.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Ba.payloadify(e.statConfigInfo):null}))}}])}(),Ya=function(){return i((function e(t){r(this,e),this._iid="",this._iid=t}),null,[{key:"payloadify",value:function(e){return{}}}])}(),Za=function(e){function t(e){var a,i=e.userId,s=e.metadata;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s},a}return c(t,e),i(t)}(je),Xa=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaData=a,i}return c(t,e),i(t)}(Ve),Ja=function(e){function t(e){var a,i=e.userId,s=e.metadata,o=e.upsert;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s,upsert:o},a}return c(t,e),i(t)}(je),$a=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metadata=a,i}return c(t,e),i(t)}(Ve),ei=function(e){function t(e){var a,i=e.userId,s=e.metadataKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata/").concat(s),a}return c(t,e),i(t)}(je),ti=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata"),a}return c(t,e),i(t)}(je),ni=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},ri=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ai=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(Qa=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",Qa.OFFLINE="offline",Qa.NON_AVAILABLE="nonavailable";var ii,si=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y;return r(this,a),(s=n(this,a,[t])).userId=null!==(u=null!==(o=i.guest_id)&&void 0!==o?o:i.user_id)&&void 0!==u?u:"",s.nickname=null!==(l=null!==(c=i.nickname)&&void 0!==c?c:i.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(h=null!==(d=i.profile_url)&&void 0!==d?d:i.image)&&void 0!==h?h:"",s.requireAuth=null!==(f=i.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=i.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,R(e.UserOnlineState,i.is_online)?s.connectionStatus=i.is_online:D("boolean",i.is_online)&&(s.connectionStatus=i.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(_=i.is_active)||void 0===_||_,s.lastSeenAt=null!==(m=i.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=i.preferred_languages?v(i.preferred_languages):null,s.friendDiscoveryKey=null!==(g=i.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=i.friend_name)&&void 0!==y?y:null,s}return c(a,t),i(a,[{key:"profileUrl",get:function(){var e=es.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return ni(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 D("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,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(this._isValidMetaData(e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Za({userId:r.userId,metadata:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(Xa),u=o.metaData,this._applyMetaData(u),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(this._isValidMetaData(e)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Ja({userId:a.userId,metadata:e,upsert:t}),n.next=5,i.send(s);case 5:return o=n.sent,u=o.as($a),c=u.metadata,this._applyMetaData(c),n.abrupt("return",this.metaData);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ei({userId:r.userId,metadataKey:e}),t.next=5,a.send(i);case 5:return this._applyMetaData((s={},u=!0,(o=_(o=e))in s?Object.defineProperty(s,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):s[o]=u,s),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var s,o,u}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ti({userId:n.userId}),e.next=4,r.send(a);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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})))}}])}(Ya),oi=function(e){function t(e){var a,i=e.userProfile;return r(this,t),(a=n(this,t)).userProfile=i,a}return c(t,e),i(t)}(fe),ui=function(){return i((function e(t,n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new Wa(n),this.user=new si(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=n.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(s=n.pong_timeout)&&void 0!==s?s: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!==(h=null===(d=n.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==h?h: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}),[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=es.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 oi({userProfile:this}))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign(Object.assign({},si.payloadify(e.user)),Wa.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})))}}])}(),ci=function(e){function t(e){var a,i=e.request,s=void 0===i||i,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c,d=e.statConfigInfo;return r(this,t),(a=n(this,t)).request=s,a.features=Object.assign({localCache:!0,notification:!0},u),a.options=Object.assign({ingestion:!0},l),a.statConfigInfo=d,a}return c(t,e),i(t)}(fe),li=function(e){function t(e,a,i){var s,o,u,c,l;return r(this,t),(s=n(this,t,[e,a,i])).error=null,s.services=[],s.userProfile=new ui(e,i),s.deviceTokenLastDeletedAt=null!==(o=i.device_token_last_deleted_at)&&void 0!==o?o:0,s.key=null!==(u=i.key)&&void 0!==u?u:"",s.ekey=null!==(c=i.ekey)&&void 0!==c?c:"",s.error=i.error?new A(i):null,s.services=null!==(l=i.services)&&void 0!==l?l:[],s}return c(t,e),i(t,[{key:"applyTo",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=13;break}if(!(n=es.of(e))){t.next=10;break}return r=n.sessionManager,a=n.dispatcher,t.next=6,r.login(this);case 6:this.userProfile.apply(),a.dispatch(new ci({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),t.next=11;break;case 10:throw A.lostInstance;case 11:t.next=14;break;case 13:throw this.error;case 14:case"end":return t.stop()}}),t,this)})))}}],[{key:"asError",value:function(e){return new t("","LOGI",Object.assign({user_id:"",error:!0},e))}}])}(Ke),di=function(){return i((function e(){r(this,e),this.type=Aa.NONE,this.name="none"}),[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,t){return t.resetReconnectCount,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,t){return t.error,t.autoReconnect,t.cause,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}(),hi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=12;break;case 5:if(t.prev=5,t.t0=t.catch(0),!(t.t0 instanceof A)){t.next=11;break}t.t0.throwOutside(),t.next=12;break;case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,null,[[0,5]])})))},fi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=7;break;case 5:t.prev=5,t.t0=t.catch(0);case 7:case"end":return t.stop()}}),t,null,[[0,5]])})))},pi=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t)).type=Aa.LOGOUT,e.name="logout",e._wasPreviouslyConnected=null===(a=i.wasPreviouslyConnected)||void 0===a||a,e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=e.sdkState.userId,t.next=4,e.logout();case 4:return t.next=6,e.changeState(new Si,n);case 6:this._wasPreviouslyConnected&&hi((function(){return E(a,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(r)}));case 1:case"end":return t.stop()}}),t)})))}));case 7:case"end":return t.stop()}}),t,this)})))}}])}(di),vi=function(e){function t(){var e;return r(this,t),(e=n(this,t)).type=Aa.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),t)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ci({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Ei,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new pi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(di),_i=function(e){function t(e){var a,i=e.autoReconnect;return r(this,t),(a=n(this,t)).type=Aa.INTERNAL_DISCONNECTED,a.name="internaldisconnected",a._autoReconnect=!1,a._autoReconnect=i,a}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new Ei,n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ci({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Ei,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new vi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new pi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(di),mi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),t)})))},gi=function(){return i((function e(){r(this,e)}),[{key:"calcTimeout",value:function(){return 0}}])}(),yi=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new gi;return E(void 0,void 0,void 0,d().mark((function r(){var a,i,s,o,u;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=0,i=null,s=function(e){return i=null!=e?e:new Error("Halted")},o=function(){a=0};case 4:if(!(-1===t||a0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,e&&(this._webSocketClosedCause=ii.ExternalDisconnectWebSocket),t.next=4,n.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause});case 4:case"end":return t.stop()}}),t,this)})))}},{key:"logout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),t.next=4,n.onLogout(this._context,e);case 4:case"end":return t.stop()}}),t,this)})))}}])}(),Ci=function(t){function a(e){var t,i=e.authToken;return r(this,a),(t=n(this,a)).type=Aa.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=i,t}return c(a,t),i(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(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ot,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,yi((function(n){return E(i,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._haltConnect=n,r.prev=1,r.next=4,t.connect(this._authToken);case 4:r.next=16;break;case 6:if(r.prev=6,r.t0=r.catch(1),t.clearLoginTimer(),!(r.t0 instanceof A)){r.next=15;break}r.t1=r.t0.code,r.next=r.t1===e.SendbirdErrorCode.CONNECTION_CANCELED?13:15;break;case 13:return n(r.t0),r.abrupt("return");case 15:throw r.t0;case 16:case"end":return r.stop()}}),r,this,[[1,6]])})))}),t.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,t.changeState(new ki,r);case 8:hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(),t.connectionHandlers.forEach((function(e){e.onConnected&&e.onConnected(t.sdkState.userId)}));case 2:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),N(n.t0)){n.next=23;break}return n.next=16,t.disconnect();case 16:if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===e.SendbirdErrorCode.CONNECTION_CANCELED){n.next=20;break}return n.next=20,t.changeState(new Si,r);case 20:hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new ot,this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){var n=t.error,r=void 0===n?null:n,a=t.autoReconnect,i=void 0!==a&&a,s=t.cause,o=void 0===s?null:s;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Date.now(),this._halt(null!=r?r:wi(o)),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new _i({autoReconnect:i}),n);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new pi,n);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._halt(wi((null==t?void 0:t.cause)||null)),r=Date.now(),!e.hasSession){n.next=7;break}return n.next=5,e.changeState(new vi,r);case 5:n.next=9;break;case 7:return n.next=9,e.changeState(new pi,r);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),this._halt(null!=t?t:A.connectionCanceled),n.next=4,e.changeState(new pi,r);case 4:case"end":return n.stop()}}),n,this)})))}}])}(di);function wi(e){var t=A.connectionCanceled;if(e){var n=null;switch(e){case ii.ExternalSetBackground:n="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case ii.ExternalDisconnectWebSocket:n="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}n&&t.setDetail(n)}return t}var xi,Si=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).type=Aa.INITIALIZED,e.name="initialized",e}return c(t,e),i(t,[{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.changeState(new Ci({authToken:t}),r);case 3:case"end":return n.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new pi({wasPreviouslyConnected:!1}),n);case 3:case"end":return t.stop()}}),t)})))}}])}(di),Ti=function(e){function t(){return r(this,t),n(this,t,[{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1}])}return c(t,e),i(t)}(Qe),Ii=function(){return i((function e(t){var n=t.pingDelegate,a=t.sdkState,i=t.logger;r(this,e),this.pingDelegate=n,this.sdkState=a,this._logger=i}),[{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 Ti;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)}}])}(),Ni=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"],Ai=function(e){function t(e,a){var i,s,o=a.sdkState,u=a.cacheContext,c=a.connectionHandlers,l=a.sessionManager,d=a.websocketClient,h=a.dispatcher,f=a.logger,p=a.entryState,v=void 0===p?new Si:p;return r(this,t),(i=n(this,t))._stateUpdatedAt=0,i._connectingAt=0,i._connectionRequestQueue=[],i._iid=e,i.sdkState=o,i.cacheContext=u,i.connectionHandlers=c,i._sessionManager=l,i._websocketClient=d,i._dispatcher=h,i._logger=f,i._currentState=v,(null===(s=i.sdkState.websocket)||void 0===s?void 0:s.pingerDisabled)||(i._pinger=new Ii({pingDelegate:{send:function(e){return i._websocketClient.send(e)},error:function(e){return i._websocketClient.error(e)}},sdkState:i.sdkState,logger:f})),i._websocketClient.on("open",(function(){i._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)i.clearLoginTimer(),i._dispatcher.dispatch(e.as(li))})).on("ping-refresh",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){i._logiProcessingTimer=setTimeout((function(){i._logiProcessingTimer=void 0,i._unresolvedLogi||i._rejectConnectionRequest(A.networkError)}),500)})),i._dispatcher.on((function(e){e instanceof li&&(i._unresolvedLogi=e,i._tryResolveConnectionRequest())})),i}return c(t,e),i(t,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.session.hasSession}},{key:"changeState",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>=this._stateUpdatedAt)){n.next=8;break}return this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new La({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),n.next=7,this._currentState.run(this);case 7:return n.abrupt("return",!0);case 8:return n.abrupt("return",!1);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._unresolvedLogi,!this._websocketClient.isOpen||!n){t.next=16;break}if(this._unresolvedLogi=void 0,n.error){t.next=13;break}return t.next=6,n.applyTo(this._iid);case 6: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=16;break;case 13:this._sessionManager.session.authToken=void 0,n.error.isSessionExpiredError||n.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Be({reason:n.error.code,message:n.error.message})):this._logger.warn("login failed: ".concat(n.error)),this._rejectConnectionRequest(n.error);case 16:case"end":return t.stop()}}),t,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=this.sdkState,n=t.appId,r=t.appVersion,a=t.userId,i=t.extensions,s=t.sendbirdRuntimeEnvironment,o=this.cacheContext.localCacheEnabled,u=this._sessionManager.session,c=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=i?i:{}).sb_uikit,d=st.userAgentWithExtension(i);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(u.hasSession?"":"&user_id=".concat(encodeURIComponent(a)),"&pmce=").concat(c?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent(st.sendbirdSdkUserAgentWithExtension(s)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(Ni))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new Je(new rt({type:Ge.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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(A.connectionCanceled)),r=new ot,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){s._loginTimer=void 0,s._rejectConnectionRequest(A.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),a=this._sessionManager.session,t&&(a.authToken=t,a.sessionKey=void 0),i=this._url(),a.sessionKey||a.authToken?this._websocketClient.connect(i,JSON.stringify(a.hasSession?{auth:a.sessionKey}:{token:a.authToken})):this._websocketClient.connect(i,JSON.stringify({}))),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(li.asError(A.connectionRenew))}},{key:"disconnect",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){return d().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.disconnect();case 4:return e.next=6,this._sessionManager.clear();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}])}(de),Mi=function(e){function t(e){var a,i=e.appId,s=e.userId,o=e.includeUIKitConfig,u=void 0!==o&&o,c=e.localCacheEnabled,l=void 0===c||c,d=e.expiringSession,h=void 0===d||d;return r(this,t),(a=n(this,t)).path="".concat(ye,"/").concat(s,"/authentication"),a.method=_e.POST,a.params=pe({expiring_session:!!h,include_logi:!0,include_extra_data:String(Ni),uikit_config:u,use_local_cache:l,app_id:i}),a.requireAuth=!1,a}return c(t,e),i(t)}(je),Oi=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).logi=new li(e,"LOGI",a),i}return c(t,e),i(t)}(Ve);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(xi||(xi={}));var Ui,Di,Ri=[We,Mi],Li=function(){return i((function e(t,n){var a=this,i=n.session,o=n.sdkState,u=n.dispatcher,c=n.logger,l=n.useFetchCompat,d=void 0!==l&&l;r(this,e),this._currentConnectionStateType=Aa.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Ua(t,{session:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:d}),this._session=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){var t;if(e instanceof La){var n=e.stateType;switch(a._currentConnectionStateType=n,n){case Aa.CONNECTED:a._resolveLazyCallQueue();break;case Aa.INITIALIZED:case Aa.INTERNAL_DISCONNECTED:case Aa.EXTERNAL_DISCONNECTED:case Aa.LOGOUT:a._rejectLazyCallQueue((null===(t=a._session)||void 0===t?void 0:t.hasSession)?A.connectionClosed:A.connectionRequired)}}else if(e instanceof Pa)a._session.hasChatServicePermission||a._resolveLazyCallQueue(xi.API);else if(e instanceof Fa||e instanceof qa)a._rejectLazyCallQueue(A.connectionClosed);else if(e instanceof $e){var r,i=e.request,o=e.deferred,u=e.error,c=s(Ri);try{for(c.s();!(r=c.n()).done;){if(i instanceof r.value)return void o.reject(u)}}catch(e){c.e(e)}finally{c.f()}a._lazyCallQueue.push({command:i,deferred:o})}}))}),[{key:"isReady",get:function(){return this._currentConnectionStateType===Aa.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===Aa.CONNECTING||this._currentConnectionStateType===Aa.RECONNECTING||this._session.isRefreshing}},{key:"_classifyLazyCallQueueByScope",value:function(e){var t,n=[],r=[];switch(e){case xi.ALL:t=null;break;case xi.WEBSOCKET:t=Qe;break;case xi.API:t=je}var a=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(a=!0),a?r.push(e):n.push(e)})),[n,r]}},{key:"_resolveLazyCallQueue",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xi.ALL,n=f(this._classifyLazyCallQueueByScope(t),2),r=n[0],a=n[1];this._lazyCallQueue=a,r.forEach((function(t){return E(e,void 0,void 0,d().mark((function e(){var n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.command,r=t.deferred,(a=t.timeout)&&clearTimeout(a),e.prev=2,e.next=5,this.send(n);case 5:i=e.sent,r.resolve(i),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),r.reject(e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])})))}))}},{key:"_rejectLazyCallQueue",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:xi.ALL,r=f(this._classifyLazyCallQueueByScope(n),2),a=r[0],i=r[1];this._lazyCallQueue=i,a.forEach((function(n){return E(t,void 0,void 0,d().mark((function t(){var r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n.deferred,a=n.timeout,clearTimeout(a),r.reject(e);case 3:case"end":return t.stop()}}),t)})))}))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Qe)){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:case 31:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),n=new ot,this._lazyCallQueue.push({command:e,deferred:n,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",n.promise);case 15:throw this._logger.debug("fail websocket request"),A.connectionRequired;case 17:case 44:t.next=47;break;case 19:if(!(e instanceof je)){t.next=46;break}if(!this._session.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!e.hasSessionKey){t.next=34;break}return this._logger.debug("send api request with tmp session key",e),t.next=31,this.commandRouter.send(e);case 34:if(!this.isLazyCallActivated){t.next=41;break}return this._logger.debug("wait api request",e),r=new ot,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 41:throw a=A.connectionRequired,this._logger.debug("fail api request",a),a;case 46:throw A.invalidCommand;case 47:case"end":return t.stop()}}),t,this)})))}},{key:"forceSend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._logger.debug("send forced request",e),!(e instanceof Qe||e instanceof je)){t.next=7;break}return t.next=4,this.commandRouter.send(e);case 4:return t.abrupt("return",t.sent);case 7:throw A.invalidCommand;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(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()}}])}(),Pi="sendbird@devicetokens",Fi=function(){return i((function e(t){var n=t.type,a=t.token,i=t.device_os,s=t.device_manufacturer,o=t.system_push_enabled;r(this,e),this.type=n,this.token=a,this.deviceOS=i,this.deviceManufacturer=s,this.systemPushEnabled=o}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}])}(),qi=new WeakMap,Hi=function(t){function a(e){var t,i=e._iid,s=e.session,o=e.cacheContext,u=e.sdkState,c=e.dispatcher,l=e.requestQueue,d=e.logger,h=e.pushNotificationAckManager;return r(this,a),(t=n(this,a))._currentConnectionStateType=Aa.INITIALIZED,t._isRefreshingAuthToken=!1,t.currentUser=null,t.session=s,t._iid=i,t._cacheContext=o,t._sdkState=u,t._dispatcher=c,t._requestQueue=l,t._logger=d,t._pushNotificationAckManager=h,t._deviceTokens=[],t._dispatcher.on((function(e){var n,r,a;if(e instanceof La){var i=e.stateType;t._currentConnectionStateType=i}else if(e instanceof Be&&t.handler&&!t.isSessionKeyRefreshing){if(t._currentConnectionStateType===Aa.CONNECTING)return;(null===(n=e.error)||void 0===n?void 0:n.isSessionInvalidatedError)?t.close():((null===(r=e.error)||void 0===r?void 0:r.isSessionTokenExpiredError)&&t.refreshAuthToken().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e})),(null===(a=e.error)||void 0===a?void 0:a.isSessionKeyExpiredError)&&(t._logger.debug("session expired"),t.handler.onSessionExpired&&t.handler.onSessionExpired(),t.refreshSessionKey().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e}))))}})),t}return c(a,t),i(a,[{key:"ekey",get:function(){return qi.get(this)}},{key:"deviceTokens",get:function(){return this._deviceTokens}},{key:"deviceTokenLastDeletedAt",get:function(){return this._deviceTokenLastDeletedAt}},{key:"indexOfDeviceToken",value:function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))}},{key:"hasDeviceToken",value:function(e,t){return this.indexOfDeviceToken(e,t)>=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new Ye({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(n);case 3:if(r=t.sent,a=r.as(Xe),i=a.newKey,!(s=a.error)){t.next=7;break}throw s;case 7:this.session.sessionKey=null!=i?i:this.session.sessionKey;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new We({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),t.next=3,yi((function(e){return E(r,void 0,void 0,d().mark((function t(){var r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(n);case 3:r=t.sent,a=r.as(Ze),i=a.key,s=a.services,this.session.sessionKey=i,this.session.services=s,t.next=16;break;case 9:if(t.prev=9,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=15;break}e(t.t0),t.next=16;break;case 15:throw t.t0;case 16:case"end":return t.stop()}}),t,this,[[0,9]])})))}),3);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKey",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._currentConnectionStateType!==Aa.CONNECTED){n.next=18;break}return n.prev=1,n.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),n.abrupt("return");case 8:return n.prev=8,n.t0=n.catch(1),n.prev=10,n.next=13,this._handleSessionRefreshError(n.t0,t);case 13:return n.abrupt("return");case 16:n.prev=16,n.t1=n.catch(10);case 18:return n.prev=18,n.next=21,this._refreshSessionKeyByApi(e);case 21:this.complete(),n.next=28;break;case 24:return n.prev=24,n.t2=n.catch(18),n.next=28,this._handleSessionRefreshError(n.t2,t);case 28:case"end":return n.stop()}}),n,this,[[1,8],[10,16],[18,24]])})))}},{key:"_receiveNewAuthToken",value:function(){var e,t=this,n=new ot;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var r=null,a=function(){r&&(clearTimeout(r),r=null)},i=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},s=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};r=setTimeout((function(){return s()}),1e3*this._sdkState.sessionTokenRefreshTimeout),hi((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(i,s);case 1:case"end":return e.stop()}}),e,this)})))}))}else n.resolve(null);return n.promise}},{key:"_handleSessionRefreshError",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(t instanceof A)){r.next=16;break}if(!t.isSessionTokenExpiredError&&t.code!==e.SendbirdErrorCode.APPLICATION_NOT_FOUND){r.next=16;break}if(this.session.authToken=void 0,!n){r.next=16;break}return r.next=6,this._receiveNewAuthToken();case 6:if(!(a=r.sent)){r.next=13;break}return this.session.authToken=a,r.next=11,this._refreshSessionKey(this.session.authToken,!1);case 11:r.next=15;break;case 13:return r.next=15,this.clear();case 15:return r.abrupt("return");case 16:throw t;case 17:case"end":return r.stop()}}),r,this)})))}},{key:"_isSessionRelatedError",value:function(e){return e instanceof A&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}},{key:"isSessionKeyRefreshing",get:function(){return this.session.isRefreshing}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"isSessionExpiring",get:function(){return!!this.handler}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.session.authToken=t,a=new Mi({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!t||this.isSessionExpiring}),r.next=4,this._requestQueue.commandRouter.send(a);case 4:if(i=r.sent,s=i.as(Oi),(o=s.logi).error){r.next=12;break}if(this.session.hasChatServicePermission){r.next=10;break}return r.next=10,o.applyTo(this._iid);case 10:r.next=13;break;case 12:throw o.error;case 13:case"end":return r.stop()}}),r,this)})))}},{key:"login",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=e.key,a=e.ekey,i=e.services,s=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.session.sessionKey=r,this.session.services=i,qi.set(this,a),this._deviceTokenCacheEnabled=null===(t=null==s?void 0:s.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){n.next=21;break}return n.next=9,c.get(Pi);case 9:if((l=n.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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return t=this._cacheContext.preference,e.next=4,t.set(Pi,{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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.session.clear(),this.close(),qi.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:this._pushNotificationAckManager.clear();case 9:case"end":return e.stop()}}),e,this)})))}}])}(de),Gi=function(e,t){if(null!==e&&null!==t){var n,r=Object.keys(e),a=Object.keys(t),i={},o=s(v(new Set([].concat(r,a))));try{for(o.s();!(n=o.n()).done;){var u=n.value,c=m(e[u]),l=m(t[u]);"undefined"===c?i[u]=t[u]:"undefined"===l?i[u]=e[u]:c!==l?i[u]=t[u]:"object"===c&&e[u]&&t[u]?i[u]=Gi(e[u],t[u]):i[u]=t[u]}}catch(e){o.e(e)}finally{o.f()}return i}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"}(Ui||(Ui={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(Di||(Di={}));var ji,Vi=function(e){function t(e){var a,i=e.deviceId,s=e.statLogs;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Oe),a.params={device_id:i,log_entries:s.map((function(e){return rt.payloadify(e)}))},a}return c(t,e),i(t)}(je),zi=function(){return i((function e(t){var n=t.deviceId,a=t.cacheContext,i=t.requestQueue;r(this,e),this.queue=[],this.flushWaitQueue=[],this.enabledState=Ui.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=n,this.cacheContext=a,this.requestQueue=i,this.logInfo={deviceId:n,statLogs:[],generation:1,lastFlushedAt:0},this.limit=100}),[{key:"isEnabled",get:function(){return this.enabledState===Ui.ENABLED}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:(n=t.sent)&&(this.logInfo=n);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_mergeQueue",value:function(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}},{key:"_isDuplicateStat",value:function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}},{key:"_flush",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=!0,!(t.length>0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Vi({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Ui.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ui.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}},{key:"_save",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(v(this.queue),v(this.flushWaitQueue)),e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:t.map((function(e){return rt.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save();case 4:case"end":return e.stop()}}),e,this)})))}}])}(),Bi=function(e){function t(e){var a,i,s,o,u,c=e.type,l=e.data,d=e.ts,h=void 0===d?Date.now():d;return r(this,t),(a=n(this,t,[{type:c,data:l,ts:h}])).date=new Date(h),a.key="".concat((i=a.date,s=i.getFullYear(),o=String(i.getMonth()+1).padStart(2,"0"),u=String(i.getDate()).padStart(2,"0"),"".concat(s).concat(o).concat(u)),"_").concat(c),a}return c(t,e),i(t)}(rt),Ki=function(e){function t(e){var a=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,t),n(this,t,[{deviceId:a,cacheContext:i,requestQueue:s}])}return c(t,e),i(t,[{key:"_isSendable",get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var n=this,r=Object.create(null,{init:{get:function(){return p(t,"init",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.init.call(this,e+".daily");case 2:this.queue=this.logInfo.statLogs.map((function(e){return new rt({type:e.stat_type,ts:e.ts,data:e.data})}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),!t.localCacheStat){n.next=7;break}this.enabledState=t.enabledStat?Ui.ENABLED:Ui.COLLECT_ONLY,n.next=10;break;case 7:return this.enabledState=Ui.DISABLED,n.next=10,this.clear();case 10:if(!this.isEnabled||!this._isSendable){n.next=25;break}return n.next=13,this._getUploadStats();case 13:r=n.sent,a=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),i=0;case 16:if(!(i0&&void 0!==arguments[0]&&arguments[0];if(this.queue.length=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var n=this,r=Object.create(null,{init:{get:function(){return p(t,"init",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.init.call(this,e+".realtime");case 2:this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new rt({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this._mergeQueue(),!t.notificationStat){n.next=6;break}this.enabledState=t.enabledStat?Ui.ENABLED:Ui.COLLECT_ONLY,n.next=9;break;case 6:return this.enabledState=Ui.DISABLED,n.next=9,this.clear();case 9:if(!this.isEnabled||!this._isSendable){n.next=15;break}return r=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),n.next=13,mi(r);case 13:return n.next=15,this._flush(this.queue);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState!==Ui.DISABLED){t.next=2;break}return t.abrupt("return",!0);case 2:if(n=this.enabledState===Ui.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,!this._isDuplicateStat(e)){t.next=5;break}return t.abrupt("return",!0);case 5:if(n.push(e),this.enabledState===Ui.PENDING){t.next=9;break}return t.next=9,this._save();case 9:if(!this.isEnabled){t.next=15;break}if(this._mergeQueue(),!this.isEnabled||!this._isSendable){t.next=15;break}return t.next=14,this._flush(n);case 14:return t.abrupt("return",t.sent);case 15:return t.abrupt("return",!0);case 16:case"end":return t.stop()}}),t,this)})))}}])}(zi),Yi=function(){return i((function e(t){var n=t.cacheContext,a=t.requestQueue,i=t.dispatcher,s=t.logger;r(this,e),this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=ce(),this.cacheContext=n,this.requestQueue=a,this.dispatcher=i,this.logger=s,this._dailyStatCollector=new Ki({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Qi({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._realTimeStatCollector=new Wi({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}),[{key:"_migration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cacheContext.preference.get(this.key);case 2:if(!(t=e.sent)){e.next=18;break}return n=[],t.statLogs.forEach((function(e){e.stat_type===Ge.FEATURE_LOCALCACHE&&n.push(new rt({type:e.stat_type,ts:e.ts,data:e.data}))})),e.next=8,this.cacheContext.preference.set(this.key+".daily",{deviceId:t.deviceId,statLogs:n.map((function(e){return rt.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 8:return r=[],t.statLogs.forEach((function(e){e.stat_type!==Ge.FEATURE_LOCALCACHE&&e.stat_type!==Ge.NOTIFICATION&&(e.stat_type===Ge.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),r.push(new rt({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=12,this.cacheContext.preference.set(this.key+".default",{deviceId:t.deviceId,statLogs:r.map((function(e){return rt.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 12:return a=[],t.statLogs.forEach((function(e){var t;e.stat_type===Ge.NOTIFICATION&&(e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),a.push(new rt({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=16,this.cacheContext.preference.set(this.key+".realtime",{deviceId:t.deviceId,statLogs:a.map((function(e){return rt.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 16:return e.next=18,this.cacheContext.preference.remove(this.key);case 18:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this._migration();case 3:return t.next=5,this._dailyStatCollector.init(this.key);case 5:return t.next=7,this._defaultStatCollector.init(this.key);case 7:return t.next=9,this._realTimeStatCollector.init(this.key);case 9:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e instanceof Je?(r=e.statLog,this.put(r)):e instanceof ci&&(a=e.request,i=e.features,s=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=a,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._realTimeStatCollector.setConfig(null!==(n=this._statConfig.realTime)&&void 0!==n?n:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:s.ingestion}));case 1:case"end":return t.stop()}}),t,this)})))})));case 10:case"end":return t.stop()}}),t,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=!0,!(e instanceof Bi)){t.next=8;break}if(!this._collectFeatureLocalCacheStat){t.next=6;break}return t.next=5,this._dailyStatCollector.put(e);case 5:n=t.sent;case 6:t.next=26;break;case 8:t.t0=e.type,t.next=t.t0===Ge.API_RESULT||t.t0===Ge.WEBSOCKET_CONNECT?11:t.t0===Ge.FEATURE_LOCALCACHE||t.t0===Ge.FEATURE_LOCALCACHE_EVENT?16:t.t0===Ge.NOTIFICATION?21:26;break;case 11:if(!this._collectRequestStat){t.next=15;break}return t.next=14,this._defaultStatCollector.put(e);case 14:n=t.sent;case 15:return t.abrupt("break",26);case 16:if(!this._collectFeatureLocalCacheStat){t.next=20;break}return t.next=19,this._defaultStatCollector.put(e);case 19:n=t.sent;case 20:return t.abrupt("break",26);case 21:if(!this._collectionNotificationStat){t.next=25;break}return t.next=24,this._realTimeStatCollector.put(e);case 24:n=t.sent;case 25:return t.abrupt("break",26);case 26:n?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Ui.COLLECT_ONLY,this._defaultStatCollector.enabledState=Ui.COLLECT_ONLY,this._realTimeStatCollector.enabledState=Ui.COLLECT_ONLY,this.logger.debug(A.statLogUploadLimitExceededError)));case 27:case"end":return t.stop()}}),t,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}])}(),Zi=function(){return i((function e(t){var n=t.limit,a=void 0===n?5:n;r(this,e),this.workersByKey={},this.limit=a}),[{key:"run",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.workersByKey[e]||(this.workersByKey[e]=[]),!(this.workersByKey[e].length0:void 0,i.lastRepliedAt=null!==(c=a.last_replied_at)&&void 0!==c?c:0,i.updatedAt=null!==(l=a.updated_at)&&void 0!==l?l:0,i}return c(t,e),i(t,[{key:"_isUpdateRequired",get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}},{key:"_updateFrom",value:function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((function(e){return si.payloadify(e)})):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}}])}(Ya);e.ReactionEventOperation=void 0,(Xi=e.ReactionEventOperation||(e.ReactionEventOperation={})).ADD="add",Xi.DELETE="delete";var ss,os=i((function t(n){r(this,t),this.messageId=0,this.operation=null,this.updatedAt=0;var a=D("string",n.msg_id)?parseInt(n.msg_id):n.msg_id,i=n.user_id,s=n.operation?n.operation.toLowerCase():null,o=n.reaction,u=n.updated_at;a&&D("string",i)&&D("string",s)&&R(e.ReactionEventOperation,s)&&D("string",o)&&o&&D("number",u)&&(this.messageId=a,this.userId=i,this.key=o,this.operation=s,this.updatedAt=u)})),us=function(){return i((function e(t){var n;r(this,e);var a=t.key,i=null!==(n=v(t.user_ids))&&void 0!==n?n:[],o=t.updated_at;D("string",a)&&a&&P("string",i)&&i.length>0&&D("number",o)&&(this.key=a,this.userIds=i,this.updatedAt=o);var u,c={},l=s(this.userIds);try{for(l.s();!(u=l.n()).done;){c[u.value]=this.updatedAt}}catch(e){l.e(e)}finally{l.f()}this._version=c}),[{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 pe(ve({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}}])}(),cs=function(){return i((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)}),null,[{key:"payloadify",value:function(e){var t,n;return pe(ve({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}))}}])}(),ls=function(){return i((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 cs(t["og:image"]))}),null,[{key:"payloadify",value:function(e){return pe(ve({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?cs.payloadify(e.defaultImage):null}))}}])}(),ds=function(){return i((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}),[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return pe(ve({name:e.name,volume:e.volume}))}}])}();e.FeedbackRating=void 0,(ss=e.FeedbackRating||(e.FeedbackRating={})).GOOD="good",ss.BAD="bad";var hs,fs=function(){function e(t){r(this,e),this.id=t.id,this.rating=t.rating,this.comment=t.comment}return i(e,null,[{key:"_getStatus",value:function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}},{key:"_isSubmitted",value:function(t){return"SUBMITTED"===e._getStatus(t)}},{key:"_getPayloadByStatus",value:function(e){return"NO_FEEDBACK"===e?{}:null}},{key:"payloadify",value:function(e){return pe(ve({id:e.id,rating:e.rating,comment:e.comment}))}}])}(),ps=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i])).isBlockedByMe=!1,s.role=R(e.Role,i.role)?i.role:e.Role.NONE,s.isBlockedByMe=null!==(o=i.is_blocked_by_me)&&void 0!==o&&o,s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}])}(si),vs=function(){return i((function e(t){r(this,e),this.key=t.key,this.value=P("string",t.value)?v(t.value):[]}),null,[{key:"payloadify",value:function(e){var t;return pe(ve({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}])}(),_s=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"}},ms=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;r(this,a),(s=n(this,a,[t])).channelType=e.ChannelType.BASE,s.messageType=e.MessageType.BASE,s.mentionType=null,s.mentionedUsers=null,s.mentionedUserIds=null,s.mentionedMessageTemplate=void 0,s.metaArrays=[],s.extendedMessage={},s.createdAt=0,s.updatedAt=0,s.channelUrl=i.channel_url,s.channelType=R(e.ChannelType,i.channel_type)?i.channel_type:e.ChannelType.GROUP,i.channel&&(i.channel.channel_url&&(s.channelUrl=i.channel.channel_url),i.channel.channel_type&&(s.channelType=i.channel.channel_type)),s.data=null!==(o=i.data)&&void 0!==o?o:"",s.customType=null!==(u=i.custom_type)&&void 0!==u?u:"",s.mentionType=R(e.MentionType,i.mention_type)?i.mention_type:null,s.mentionedUsers=i.mentioned_users?i.mentioned_users.map((function(e){return new si(s._iid,e)})):null,s.mentionedUserIds=null!==(c=i.mentioned_user_ids)&&void 0!==c?c:null,s.mentionedUsers&&!s.mentionedUserIds&&(s.mentionedUserIds=s.mentionedUsers.map((function(e){return e.userId}))),s.mentionedMessageTemplate=i.mentioned_message_template;var _=null!==(l=i.metaarray)&&void 0!==l?l:{},m=null!==(d=i.metaarray_key_order)&&void 0!==d?d:Object.keys(_).sort((function(e,t){return e.localeCompare(t)}));s.metaArrays=[];for(var g=0;g0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,items:e.items.map((function(e){return Bs.payloadify(e)})),version:e.version,is_submitted:e._isSubmitted}))}},{key:"isMessageFormPayload",value:function(e){return Boolean(null==e?void 0:e.message_form)}}])}(),Bs=function(){return i((function e(t){r(this,e);var n=t.id,a=t.name,i=t.required,s=t.sort_order,o=t.placeholder,u=t.style,c=t.item_type,l=t.validators,d=t.value,h=t.values;this.id=n,this.name=a,this.required=i,this.sortOrder=s,this.placeholder=o,0===Object.keys(u).length?this.style={layout:c}:this.style=pe({layout:u.layout,options:u.options,defaultOptions:u.default_options,resultCount:u.result_count}),h?this.submittedValues=h:d&&(this.submittedValues=[d]),this._validators=l}),[{key:"isValid",value:function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case Is.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case Is.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case Is.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case Is.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case Is.DECIMAL_PLACE:if(0===e.length)return!1;var r=Number(e);return!(isNaN(r)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(r,t.max_decimal_place));default:return!0}}))}(e,t._validators);return n}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:pe({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}])}(),Ks=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Re,"/").concat(e.formId,"/submit"),a.params=pe({message_id:e.messageId,items:e.items}),a}return c(t,e),i(t)}(je);e.ScheduledStatus=void 0,(js=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",js.SENT="sent",js.FAILED="failed",js.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Vs||(Vs={}));var Qs,Ws=function(t){function a(e,t){var i,s,o,u,c,l,d,h,f;return r(this,a),(i=n(this,a,[e,t])).parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.threadInfo=null,i.reactions=[],i.appleCriticalAlertOptions=null,i.scheduledInfo=null,i.suggestedReplies=null,i.myFeedback=null,i.myFeedbackStatus="NOT_APPLICABLE",i.messageForm=null,i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(o=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==o?o:0,i.parentMessageId=null!==(u="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==u?u:0,i.threadInfo=t.thread_info?new is(i._iid,t.thread_info):null,i.reactions=t.reactions?t.reactions.map((function(e){return new us(e)})):[],i.ogMetaData=t.og_tag?new ls(t.og_tag):null,i.silent=null!==(c=t.silent)&&void 0!==c&&c,i.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,i.appleCriticalAlertOptions=t.apple_critical_alert_options?new ds(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(i.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},i._scheduledStatus=t.scheduled_status),i._isContinuousMessages=null!==(d=t.is_continuous_messages)&&void 0!==d&&d,i.myFeedback=fs._isSubmitted(t.feedback)?new fs(t.feedback):null,i.myFeedbackStatus=fs._getStatus(t.feedback),i.suggestedReplies=null!==(f=null===(h=t.extended_message_payload)||void 0===h?void 0:h.suggested_replies)&&void 0!==f?f:null,i.messageForm=zs.isMessageFormPayload(t.extended_message_payload)?new zs(i.messageId,t.extended_message_payload.message_form):null,i}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.messageId===e.messageId}},{key:"applyThreadInfoUpdateEvent",value:function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}},{key:"applyReactionEvent",value:function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1}},{key:"_triggerThreadInfoUpdatedEvent",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=es.of(this._iid),(r=n.dispatcher).dispatch(new Gs({channelType:e.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),r.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"markThreadAsRead",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new ks({channelUrl:this.channelUrl,messageId:this.messageId}),e.next=4,n.send(r);case 4:if(!this.threadInfo||0===this.threadInfo.unreadReplyCount){e.next=8;break}return this.threadInfo.unreadReplyCount=0,e.next=8,this._triggerThreadInfoUpdatedEvent();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setPushNotificationEnabled",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new bs({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),t.next=4,r.send(a);case 4:this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"submitMessageForm",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=es.of(this._iid),a=r.requestQueue,i=null,s=null,o=this.messageForm,t||!o){n.next=13;break}if(o.isSubmittable){n.next=7;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});case 7:if(!o.isSubmitted){n.next=9;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});case 9:i=o.id,s=o.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[]),n.next=14;break;case 13:t&&(i=t.formId,s=Object.entries(t.answers).reduce((function(t,n){var r=f(n,2),a=r[0],i=r[1],s=Number(a);if(Number.isNaN(s))throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return t.push({form_item_id:s,value:i}),t}),[]));case 14:if(i&&s){n.next=16;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});case 16:return u=new Ks({messageId:this.messageId,formId:i,items:s}),n.next=19,a.send(u);case 19:case"end":return n.stop()}}),n,this)})))}},{key:"submitFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Cs({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(ws),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new xs({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t.id,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(Ss),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ts({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t}),n.next=4,a.send(s);case 4:this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}));case 7:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?is.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return us.payloadify(e)})),og_tag:e.ogMetaData?ls.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?ds.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(t=e.scheduledInfo)||void 0===t?void 0:t.scheduledMessageId,scheduled_at:null===(n=e.scheduledInfo)||void 0===n?void 0:n.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?fs.payloadify(e.myFeedback):fs._getPayloadByStatus(e.myFeedbackStatus)})))}},{key:"_getParentMessageInfoPayload",value:function(e){return pe(ve({type:_s(e.messageType),ts:e.createdAt,user:e.sender?ps.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Hs.payloadify(e)})):null}))}}])}(ms),Ys=function(t){function a(t,i){var s,o,u,c,l;if(r(this,a),(s=n(this,a,[t,i])).reqId="",s.replyToChannel=!1,s.errorCode=0,s.sender=i.user?new ps(s._iid,i.user):i.sender_id,s.reqId=null!==(u=null!==(o=i.req_id)&&void 0!==o?o:i.request_id)&&void 0!==u?u:"",s.replyToChannel=null!==(c=i.is_reply_to_channel)&&void 0!==c&&c,i.request_state&&R(e.SendingStatus,i.request_state)&&(s.sendingStatus=i.request_state),!s.sendingStatus)if(s.messageId>0)s.sendingStatus=e.SendingStatus.SUCCEEDED;else if(s.scheduledInfo)switch(i.scheduled_status&&(s._scheduledStatus=i.scheduled_status),i.scheduled_status){case Vs.SENT:case Vs.IN_QUEUE:s.sendingStatus=e.SendingStatus.SUCCEEDED;break;case Vs.PENDING:s.sendingStatus=e.SendingStatus.SCHEDULED;break;case Vs.FAILED:case Vs.REMOVED:s.sendingStatus=e.SendingStatus.FAILED;break;case Vs.CANCELED:s.sendingStatus=e.SendingStatus.CANCELED}else s.sendingStatus=e.SendingStatus.PENDING;return s.errorCode=null!==(l=i.error_code)&&void 0!==l?l:0,s._messageToken=i.mesg_token,s}return c(a,t),i(a,[{key:"isResendable",get:function(){return(this.sendingStatus===e.SendingStatus.FAILED||this.sendingStatus===e.SendingStatus.CANCELED)&&((t=this.errorCode)>0&&M.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 pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{user:ps.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}}])}(Ws),Zs={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Xs=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)},Js=function(t){function a(t,i){var s,o,u,c,l;if(r(this,a),(s=n(this,a,[t,i])).translations={},s.message=null!==(o=i.message)&&void 0!==o?o:"",s.messageType=e.MessageType.ADMIN,s.translations=null!==(u=i.translations)&&void 0!==u?u:{},i.parent_message_info){var d=i.parent_message_info;s.parentMessage=ho(t,pe(ve(Object.assign(Object.assign({},d),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:d.file,url:null===(c=d.file)||void 0===c?void 0:c.url,require_auth:null===(l=d.file)||void 0===l?void 0:l.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(Ws),$s=function(){return i((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&&D("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,vendor:e.vendor,detail:e.detail}))}}])}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Qs||(Qs={}));var eo,to="removed",no=function(e){switch(e){case"open":return Qs.OPEN;case"closed":return Qs.CLOSED;default:return null}},ro=function(e){return!e||!!e.text&&D("string",e.text)},ao=function(e){function t(e,a){var i,s,o,u,c,l,d,h;return r(this,t),(i=n(this,t,[e])).pollId=0,i.id=0,i.text=null,i.voteCount=0,i.createdBy=null,i.createdAt=0,i.updatedAt=0,i._lastVotedAt=0,i.pollId=null!==(s=a.poll_id)&&void 0!==s?s:0,i.id=null!==(o=a.id)&&void 0!==o?o:0,i.text=null!==(u=a.text)&&void 0!==u?u:null,i.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,i.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,i.createdAt=null!==(d=a.created_at)&&void 0!==d?d:0,i.updatedAt=null!==(h=a.updated_at)&&void 0!==h?h:0,i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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})))}}])}(Ya),io=function(e){function t(e,a){var i,s,o,u,c,l,d,h,f,p,v,_,m,g;return r(this,t),(i=n(this,t,[e])).id=0,i.title=null,i.createdAt=0,i.updatedAt=0,i.closeAt=-1,i.status=Qs.CLOSED,i.messageId=0,i.data=null,i.voterCount=-1,i.options=[],i.createdBy=null,i.allowUserSuggestion=!1,i.allowMultipleVotes=!1,i.votedPollOptionIds=[],i.id=null!==(s=a.id)&&void 0!==s?s:0,i.title=null!==(o=a.title)&&void 0!==o?o:null,i.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,i.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,i.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,i.status=null!==(d=no(a.status))&&void 0!==d?d:Qs.CLOSED,i.messageId=null!==(h=a.message_id)&&void 0!==h?h:0,i.data=null!==(f=a.data)&&void 0!==f?f:null,i.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,i.options=a.options?a.options.map((function(e){return new ao(i._iid,e)})):[],i.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,i.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,i.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,i.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],i}return c(t,e),i(t,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,i,s,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=no(e.status))&&void 0!==a?a:this.status,this.data=null!==(i=e.data)&&void 0!==i?i:this.data,this.voterCount=null!==(s=e.voter_count)&&void 0!==s?s:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new ao(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var i=t[r];a>=i._lastVotedAt&&(i.voteCount=e.vote_count,i._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0}},{key:"serialize",value:function(){return ni(this)}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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 ao.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}])}(Ya),so=function(){return i((function e(t){r(this,e),this.status=t.status,t.original_message_info&&(this.originalMessageInfo={createdAt:t.original_message_info.ts,messageId:t.original_message_info.id})}),null,[{key:"payloadify",value:function(e){return pe({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}])}(),oo=function(t){function a(t,i){var o,u,c,l,d,h;if(r(this,a),(o=n(this,a,[t,i])).message="",o.messageParams=null,o.translations={},o.translationTargetLanguages=[],o.messageSurvivalSeconds=-1,o.plugins=[],o._poll=null,o.message=i.message,o.messageType=e.MessageType.USER,o.translations=null!==(u=i.translations)&&void 0!==u?u:{},o.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(o.translations).length&&o.translationTargetLanguages.length>0){var f,p=s(o.translationTargetLanguages);try{for(p.s();!(f=p.n()).done;){var v=f.value;o.translations[v]=""}}catch(e){p.e(e)}finally{p.f()}}if(o.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,o.plugins=i.plugins?i.plugins.map((function(e){return new $s(e)})):[],o._poll=i.poll?new io(o._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;o.parentMessage=ho(t,pe(ve(Object.assign(Object.assign({},_),{created_at:_.ts,message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(o.messageReviewInfo=new so(i.review_info)),o}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return $s.payloadify(e)})),poll:e._poll?io.payloadify(e._poll):null,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null,review_info:e.messageReviewInfo?so.payloadify(e.messageReviewInfo):void 0})))}}])}(Ys),uo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p;if(r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.fileInfoList=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE,s.data=null!==(c=null!==(u=null===(o=i.file)||void 0===o?void 0:o.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",s.fileInfoList=null!==(d=null===(l=i.files)||void 0===l?void 0:l.map((function(e){return new Hs(t,e)})))&&void 0!==d?d:[],s.messageSurvivalSeconds=null!==(h=i.message_survival_seconds)&&void 0!==h?h:-1,i.parent_message_info){var v=i.parent_message_info;s.parentMessage=ho(t,pe(ve(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===(f=v.file)||void 0===f?void 0:f.url,require_auth:null===(p=v.file)||void 0===p?void 0:p.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n,r,i,s,o;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{file:{name:null!==(n=null===(t=e.fileInfoList[0])||void 0===t?void 0:t.fileName)&&void 0!==n?n:"",size:null!==(i=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.fileSize)&&void 0!==i?i:0,type:null!==(o=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Hs.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([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)}}])}(Ys);!function(e){e.SENT="SENT",e.READ="READ"}(eo||(eo={}));var co=function(t){function a(t,i){var s,o,u;if(r(this,a),(s=n(this,a,[t,i])).notificationData=null,s.notificationId=i.notification_message_id,s.messageType=e.MessageType.ADMIN,s.messageStatus=null!==(o=i.message_status)&&void 0!==o?o:eo.SENT,s.priority=null!==(u=i.priority)&&void 0!==u?u:se.NORMAL,s.notificationEventDeadline=i.notification_event_deadline,0===s.extendedMessage.sub_type)try{var c=JSON.parse(s.extendedMessage.sub_data),l=c.label,d=c.tags,h=void 0===d?[]:d,f=c.template_key,p=c.template_variables;s.notificationData={label:l,tags:h,templateKey:f,templateVariables:p}}catch(e){}return s}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.notificationId===e.notificationId}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}}])}(ms),lo=function(t){if(t.notificationId)return co.payloadify(t);switch(t.messageType){case e.MessageType.USER:return oo.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?uo.payloadify(t):fo.payloadify(t);case e.MessageType.ADMIN:return Js.payloadify(t);default:throw A.unknown}},ho=function(e,t){if(t.notification_message_id)return new co(e,t);switch(t.type){case"MESG":return new oo(e,t);case"FILE":return uo._isMultipleFilesMessagePayload(t)?new uo(e,t):new fo(e,t);case"ADMM":case"BRDM":return new Js(e,t);default:return null}},fo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var k=i.file;if(s.plainUrl=(null!==(u=null!==(o=null==k?void 0:k.url)&&void 0!==o?o:i.url)&&void 0!==u?u:"").split("?auth=")[0],s.name=null!==(l=null!==(c=null==k?void 0:k.name)&&void 0!==c?c:i.name)&&void 0!==l?l:"File",s.size=null!==(h=null!==(d=null==k?void 0:k.size)&&void 0!==d?d:i.size)&&void 0!==h?h:0,s.data=null!==(p=null!==(f=null==k?void 0:k.data)&&void 0!==f?f:i.custom)&&void 0!==p?p:"",s.type=k?null!==(v=k.type)&&void 0!==v?v:"":null!==(_=i.type)&&void 0!==_?_:"",s.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,s.thumbnails=i.thumbnails?i.thumbnails.map((function(e){var t;return new ns(s._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),s.requireAuth)})):[],s.messageSurvivalSeconds=null!==(g=i.message_survival_seconds)&&void 0!==g?g:-1,i.parent_message_info){var b=i.parent_message_info;s.parentMessage=ho(t,pe(ve(Object.assign(Object.assign({},b),{created_at:b.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:b.file,url:null===(y=b.file)||void 0===y?void 0:y.url,require_auth:null===(E=b.file)||void 0===E?void 0:E.require_auth}))))}return s}return c(a,t),i(a,[{key:"url",get:function(){var e=es.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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.plainUrl,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(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(Ys),po=function(e){function t(e,a){var i,s=a.file,o=a.fileUrl,u=a.fileName,c=a.fileSize,l=a.mimeType,d=a.thumbnailSizes,h=a._uploadedMetaData,f=a._thumbnails;return r(this,t),(i=n(this,t,[e]))._plainUrl=o,i.file=s,i.fileName=u,i.fileSize=c,i.mimeType=l,i.thumbnailSizes=d,i._uploadedMetaData=h,i._thumbnails=f,i}return c(t,e),i(t,[{key:"fileUrl",get:function(){var e,t=es.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e}},{key:"toJSON",value:function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}],[{key:"getPlainUrl",value:function(e){return e instanceof t?e._plainUrl:e.fileUrl}}])}(Ya),vo=function(t){function a(t){var i,s,o,u;r(this,a);var c=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?c=t.mentionedUserIds:t.mentionedUsers&&(c=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FILE",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,files:t.files?yo(t.files):null,url:t.url,name:null!==(i=t.fileName)&&void 0!==i?i:"",type:null!==(s=t.mimeType)&&void 0!==s?s:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:null===(u=t._thumbnails)||void 0===u?void 0:u.map((function(e){return ns.payloadify(e)})),require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:c,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.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 c(a,t),i(a)}(Qe),_o=function(t){function a(t){var i,s,o;r(this,a),i=n(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})))),i.method=_e.POST,i.path="".concat(Le(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),i.params=pe(ve({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?yo(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===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return ns.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return vs.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage})),i}return c(a,t),i(a)}(je),mo=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"FILE",i])).message=i.files&&i.files.length>=2?new uo(e,i):new fo(e,i);var d=es.of(e).sdkState;return s.isMentioned=Fe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),go=function(e){function t(e,a){var i,s,o,u,c;r(this,t),(i=n(this,t,[e,a])).message=a.files&&a.files.length>=2?new uo(e,a):new fo(e,a);var l=es.of(e).sdkState;return i.isMentioned=Fe(i.message.mentionType,null!==(u=null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:null===(o=i.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),i.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,i}return c(t,e),i(t)}(Ve);function yo(e){return e.map((function(e){var t,n;return pe(ve({url:po.getPlainUrl(e),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 ns.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var Eo;!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"}(Eo||(Eo={}));var ko=function(){return i((function e(t,n){var a=this,i=n.sdkState,s=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._iid=t,this._sdkState=i,this._requestQueue=o,this._cacheContext=c,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof La&&(a._connectionState=e.stateType)})),this._onlineDetector=u}),[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===Aa.CONNECTED||this._connectionState===Aa.CONNECTING||this._connectionState===Aa.RECONNECTING}},{key:"_sendFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=this._createSendFileMessageRequestParams(e,t),!this._shouldSendThroughWebSocket){n.next=10;break}return a=new vo(r),n.next=5,this._requestQueue.send(a);case 5:return i=n.sent,s=i.as(mo),o=s.message,n.abrupt("return",o);case 10:return u=new _o(Object.assign(Object.assign({},r),{userId:this._sdkState.userId})),n.next=13,this._requestQueue.send(u);case 13:return c=n.sent,l=c.as(go),h=l.message,n.abrupt("return",h);case 16:case"end":return n.stop()}}),n,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(t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(a=this._queueMap.get(t.url))){r.next=58;break}if(a.isResolving){r.next=57;break}a.isResolving=!0,i=[],o=!0,u=s(a.messageQueue),r.prev=7,u.s();case 9:if((c=u.n()).done){r.next=40;break}l=c.value,r.t0=l.state,r.next=r.t0===Eo.PENDING||r.t0===Eo.UPLOADING?14:r.t0===Eo.UPLOADED?17:r.t0===Eo.FAILED?35:38;break;case 14:return o=!1,i.push(l),r.abrupt("break",38);case 17:if(!o){r.next=33;break}return r.prev=18,l.state=Eo.SENDING,r.next=22,this._sendFileMessage(t,l);case 22:return h=r.sent,l.deferred.resolve(h),r.next=26,mi(100);case 26:r.next=31;break;case 28:r.prev=28,r.t1=r.catch(18),l.deferred.reject(r.t1);case 31:r.next=34;break;case 33:i.push(l);case 34:return r.abrupt("break",38);case 35:return f=null!==(n=l.error)&&void 0!==n?n:A.unknown,l.deferred.reject(f.code===e.SendbirdErrorCode.REQUEST_CANCELED?A.fileUploadCanceled:f),r.abrupt("break",38);case 38:r.next=9;break;case 40:r.next=45;break;case 42:r.prev=42,r.t2=r.catch(7),u.e(r.t2);case 45:return r.prev=45,u.f(),r.finish(45);case 48:if(p=a.isResolveRequestPending,a.messageQueue=i,a.isResolving=!1,a.isResolveRequestPending=!1,!p){r.next=55;break}return r.next=55,this._resolveMessageQueue(t);case 55:r.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return r.stop()}}),r,this,[[7,42,45,48],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(r=this._queueMap.get(e.url))){n.next=30;break}if(!(a=r.messageQueue.find((function(e){return e.state===Eo.PENDING})))){n.next=30;break}if(!a.multipleFileUploadInfo){n.next=19;break}if(i=a.multipleFileUploadInfo,s=i.uploadIndex,o=i.uploadCount,u=i.requestHandler,c=a.params,l=c.fileInfoList[s],!H(l.file)||(null===(t=l._uploadedMetaData)||void 0===t?void 0:t.isUploaded)){n.next=13;break}return n.next=11,this._tryUploadNextItemAndUpdateItemState(e,r,a);case 11:n.next=14;break;case 13:a.state=s=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=new rs({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),s.next=3,this._requestQueue.send(o);case 3:u=s.sent,c=u.as(as),l=c.url,h=c.fileSize,f=void 0===h?n.fileSize:h,p=c.thumbnails,v=void 0===p?[]:p,_=c.requireAuth,m=void 0!==_&&_,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i:n.file.size,n.fileUrl=l,n.fileSize=f,n.requireAuth=m,n._thumbnails=v;case 12:case"end":return s.stop()}}),s,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[o],c=new rs({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),s.next=5,this._requestQueue.send(c);case 5:l=s.sent,h=l.as(as),f=h.url,p=h.fileSize,v=void 0===p?u.fileSize:p,_=h.thumbnails,m=h.requireAuth,g=void 0!==m&&m,u.fileName=null!==(r=u.fileName)&&void 0!==r?r: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=f,u.fileSize=v,u._thumbnails=_,u._uploadedMetaData=Object.assign(Object.assign({},u._uploadedMetaData),{requireAuth:g,isUploaded:!0}),u instanceof po||(n.fileInfoList[o]=new po(this._iid,u));case 16:case"end":return s.stop()}}),s,this)})))}},{key:"request",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),o=new ot,u={requestId:t,params:n,state:Eo.PENDING,deferred:o},bo(n)&&(c=n,l=Object.assign({uploadIndex:0,uploadCount:c.fileInfoList.length},r),u.multipleFileUploadInfo=l),s.messageQueue.push(u),this._uploadNextPendingItem(e),a.abrupt("return",o.promise);case 8:case"end":return a.stop()}}),a,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}))]:v(n.messageQueue),i=s(a);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o)switch(o.state){case Eo.PENDING:if(o.state=Eo.FAILED,o.error=A.requestCanceled,o.multipleFileUploadInfo&&!o.multipleFileUploadInfo.isCopy){var u=o.multipleFileUploadInfo,c=u.uploadIndex,l=u.requestHandler,d=o.params.fileInfoList[c];null==l||l._triggerOnFileUploaded(o.requestId,c,d,A.fileUploadCanceled)}this._resolveMessageQueue(e);break;case Eo.UPLOADING:this._requestQueue.cancel(o.requestId),this._dispatcher.dispatch(new ut({requestId:o.requestId}))}}}catch(e){i.e(e)}finally{i.f()}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new ut({requestId:t})))}}])}();function bo(e){return"fileInfoList"in e}var Co,wo={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},xo=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&R(e.ReplyType,t.replyType)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)&&D("boolean",t.showSubchannelMessagesOnly)},So={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},To=function(t){return R(e.ReplyType,t.replyType)&&D("boolean",t.includeReactions)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)},Io=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:d,include_poll_details:!0},a}return c(t,e),i(t)}(je),No=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?ho(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(Ve),Ao=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,d=e.isInclusive,h=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,E=e.includeThreadInfo,k=e.includeParentMessageInfo,b=e.showSubchannelMessagesOnly,C=e.checkingHasNext,w=e.checkingContinuousMessages;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages"),a.params=pe(ve({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,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:E,include_parent_message_info:k,show_subchannel_message_only:b,include_poll_details:!0,checking_has_next:C,checking_continuous_messages:w})),a}return c(t,e),i(t)}(je),Mo=function(e){function t(e,a){var i;return r(this,t),i=n(this,t,[e,a]),void 0!==a.is_continuous_messages&&(i.isContinuousMessages=a.is_continuous_messages),void 0!==a.has_next&&(i.hasNext=a.has_next),i.messages=a.messages.map((function(t){return ho(e,t)})),i}return c(t,e),i(t)}(Ve),Oo=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,d=e.includeReactions,h=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:d,include_thread_info:h,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return c(t,e),i(t)}(je),Uo=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedMessages=a.updated.map((function(t){return ho(e,t)})),i.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(Ve),Do=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledMessageId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s)),a.params={},a}return c(t,e),i(t)}(je),Ro=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?ho(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(Ve);e.RestrictionType=void 0,(Co=e.RestrictionType||(e.RestrictionType={})).MUTED="muted",Co.BANNED="banned";var Lo=function(){return i((function t(n){var a,i,s,o;r(this,t),this.restrictionType=null,R(e.RestrictionType,n.restriction_type)&&(this.restrictionType=n.restriction_type),this.description=null!==(a=n.description)&&void 0!==a?a:null,this.endAt=null!==(s=null!==(i=n.end_at)&&void 0!==i?i:n.muted_end_at)&&void 0!==s?s:-1,this.remainingDuration=null!==(o=n.remaining_duration)&&void 0!==o?o:-1}),null,[{key:"payloadify",value:function(e){return pe(ve({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}])}(),Po=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).restrictionInfo=new Lo(a),i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),Lo.payloadify(e.restrictionInfo))))}}])}(si),Fo=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.isMuted=null!==(s=a.is_muted)&&void 0!==s&&s,i}return c(t,e),i(t)}(si),qo=function(){return i((function e(){r(this,e),this._onPending=ht,this._onFailed=ht,this._onSucceeded=ht}),[{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}}])}(),Ho={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},Go=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(si,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(vs,t.metaArrays,!0)&&D("number",t.parentMessageId,!0)&&D("boolean",t.isReplyToChannel)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ds,t.appleCriticalAlertOptions,!0)&&D("boolean",t.isPinnedMessage,!0)},jo=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Vo=Object.assign(Object.assign({},Ho),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function zo(t){var n,r,a;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(t.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var Bo,Ko=function(e){var t;return pe(ve({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),extendedMessagePayload:e.extendedMessagePayload}))},Qo=function(e){return Go(e)&&D("string",e.message)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)&&D("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Bo||(Bo={}));var Wo=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Yo=function(e){return e===Bo.BLOB||e===Bo.FILE},Zo=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Xo=Object.assign(Object.assign({},Ho),{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});function Jo(t){var n,r,a,i;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.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,_thumbnails:t.thumbnails}))}var $o,eu=function(e,t){var n;return e.messageParams?(!e.url&&H(t)&&(e.messageParams.file=t),e.messageParams):pe(ve({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}}))}))},tu=function(e){return Go(e)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},nu={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},ru=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(si,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(vs,t.metaArrays,!0)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ds,t.appleCriticalAlertOptions,!0)},au=Object.assign(Object.assign({},nu),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),iu=function(e){return ru(e)&&D("string",e.message,!0)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)},su=Object.assign({},nu),ou=function(e){return ru(e)},uu=function(){return i((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}),[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return D("number",this.limit)&&this.limit>0}}])}(),cu=function(t){function a(e,t,i,s){var o;return r(this,a),(o=n(this,a,[e,s])).channelUrl=t,o.channelType=i,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl)&&R(e.ChannelType,this.channelType)}}])}(uu),lu=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={token:o,limit:u},a}return c(t,e),i(t)}(je),du=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).operators=a.operators.map((function(t){return new si(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(Ve),hu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=es.of(this._iid),r=n.requestQueue,a=new lu(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(du),o=s.operators,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(cu),fu=function(t){function a(t,i,s,o){var u,c,l,d,h,f,p,v,_,m,g;return r(this,a),(u=n(this,a,[t,i,s,o])).reverse=!1,u.messageTypeFilter=e.MessageTypeFilter.ALL,u.customTypesFilter=null,u.senderUserIdsFilter=null,u.replyType=e.ReplyType.NONE,u.includeMetaArray=!1,u.includeReactions=!1,u.includeParentMessageInfo=!1,u.includeThreadInfo=!1,u.showSubchannelMessagesOnly=!1,u._edge=Number.MAX_SAFE_INTEGER,u.reverse=null!==(c=o.reverse)&&void 0!==c&&c,u.messageTypeFilter=null!==(l=o.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,u.customTypesFilter=null!==(d=o.customTypesFilter)&&void 0!==d?d:null,u.senderUserIdsFilter=null!==(h=o.senderUserIdsFilter)&&void 0!==h?h:null,u.replyType=null!==(f=o.replyType)&&void 0!==f?f:e.ReplyType.NONE,u.includeMetaArray=null!==(p=o.includeMetaArray)&&void 0!==p&&p,u.includeReactions=null!==(v=o.includeReactions)&&void 0!==v&&v,u.includeParentMessageInfo=null!==(_=o.includeParentMessageInfo)&&void 0!==_&&_,u.includeThreadInfo=null!==(m=o.includeThreadInfo)&&void 0!==m&&m,u.showSubchannelMessagesOnly=null!==(g=o.showSubchannelMessagesOnly)&&void 0!==g&&g,u}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.reverse)&&R(e.MessageTypeFilter,this.messageTypeFilter)&&R(e.ReplyType,this.replyType)&&P("string",this.customTypesFilter,!0)&&P("string",this.senderUserIdsFilter,!0)&&D("boolean",this.includeMetaArray)&&D("boolean",this.includeReactions)&&D("boolean",this.includeParentMessageInfo)&&D("boolean",this.includeThreadInfo)&&D("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,t=nh.of(this._iid),e.next=7,t.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,ve({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));case 7:return n=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(v(n.map((function(e){return e.createdAt}))))),this._hasNext=n.length>=this.limit,this._isLoading=!1,e.abrupt("return",n);case 12:return e.abrupt("return",[]);case 15:throw A.queryInProgress;case 16:e.next=19;break;case 18:throw A.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}])}(cu),pu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={limit:o,token:u},a}return c(t,e),i(t)}(je),vu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).mutedUsers=[];var s=a.next,o=a.muted_list;return i.token=s,o&&o.length>0&&(i.mutedUsers=o.map((function(t){return new Po(e,t)}))),i}return c(t,e),i(t)}(Ve),_u=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new pu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(vu),s=i.mutedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),mu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({limit:o,token:u}),a}return c(t,e),i(t)}(je),gu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).bannedUsers=[];var s=a.next,o=a.banned_list;return i.token=s,o&&o.length>0&&(i.bannedUsers=o.map((function(t){return new Po(e,t.user)}))),i}return c(t,e),i(t)}(Ve),yu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new mu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(gu),s=i.bannedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu);e.ReportCategory=void 0,($o=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",$o.HARASSING="harassing",$o.SUSPICIOUS="suspicious",$o.INAPPROPRIATE="inappropriate";var Eu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(je),ku=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(je),bu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute/").concat(o),a}return c(t,e),i(t)}(je),Cu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.startAt=0,i.endAt=0;var s=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return i.isMuted=s,i.startAt=o,i.endAt=u,i.remainingDuration=c,i.description=l,i}return c(t,e),i(t)}(Ve),wu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={keys:o,include_ts:!0},a}return c(t,e),i(t)}(je),xu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(Ve),Su=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0},a}return c(t,e),i(t)}(je),Tu=function(e){function t(e,a){var i,s,o;return r(this,t),(i=n(this,t,[e,a])).metaData=null!==(s=a.metadata)&&void 0!==s?s:{},i.ts=null!==(o=a.ts)&&void 0!==o?o:null,i}return c(t,e),i(t)}(Ve),Iu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata,u=e.upsert;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return c(t,e),i(t)}(je),Nu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(Ve),Au=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),Mu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(o),a.params={include_ts:!0},a}return c(t,e),i(t)}(je),Ou=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(Ve),Uu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={include_ts:!0},a}return c(t,e),i(t)}(je),Du=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(Ve),Ru=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={keys:o},a}return c(t,e),i(t)}(je),Lu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(Ve),Pu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o},a}return c(t,e),i(t)}(je),Fu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(Ve),qu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,d=void 0===l?"set":l;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o,upsert:c,mode:d},a}return c(t,e),i(t)}(je),Hu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(Ve),Gu=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),ju=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(o),a.params={},a}return c(t,e),i(t)}(je),Vu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={},a}return c(t,e),i(t)}(je),zu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return c(t,e),i(t)}(je),Bu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),s}return c(t,e),i(t)}(Ke),Ku=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(je),Qu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),s}return c(t,e),i(t)}(Ke),Wu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({user_id:o,seconds:u,description:c}),a}return c(t,e),i(t)}(je),Yu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),i.data.member_count&&(s.memberCount=i.data.member_count),i.data.joined_member_count&&(s.joinedMemberCount=i.data.joined_member_count),s}return c(t,e),i(t)}(Ke),Zu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(je),Xu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),s}return c(t,e),i(t)}(Ke),Ju=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.freezing;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/freeze"),a.params={freeze:o},a}return c(t,e),i(t)}(je),$u=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).freeze=i.data.freeze,s}return c(t,e),i(t)}(Ke),ec=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return c(t,e),i(t)}(je),tc=function(t){function a(t){var i;r(this,a);var s=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,d=t.description;return(i=n(this,a)).method=_e.POST,i.path="".concat(Se,"/users/").concat(l),i.params={channel_url:s,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:d},i}return c(a,t),i(a)}(je),nc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,d=e.description,h=e.messageToken;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/messages/").concat(l),a.params=pe({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),a}return c(t,e),i(t)}(je),rc=function(t){function a(t){r(this,a);var i=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MESG",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:i,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,extended_message_payload:t.extendedMessagePayload}))}])}return c(a,t),i(a)}(Qe),ac=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"MESG",i])).message=new oo(e,i);var d=es.of(e).sdkState;return s.isMentioned=Fe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),ic=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MEDI",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))}])}return c(a,t),i(a)}(Qe),sc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"MEDI",i])).message=new oo(e,i);var h=es.of(e).sdkState;return s.mentionCountChange=qe({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),oc=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FEDI",ackRequired:!0,payload:pe(ve({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:i,apple_critical_alert_options:t.appleCriticalAlertOptions}))}])}return c(a,t),i(a)}(Qe),uc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"FEDI",i])).message=new fo(e,i);var h=es.of(e).sdkState;return s.mentionCountChange=qe({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),cc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(je),lc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new os(a),i}return c(t,e),i(t)}(Ve),dc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(je),hc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new os(Object.assign({},a)),i}return c(t,e),i(t)}(Ve),fc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return c(t,e),i(t)}(je),pc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new oo(e,a),i}return c(t,e),i(t)}(Ve),vc=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.POST,i.path="".concat(Le(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(je),_c=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new oo(e,a),i}return c(t,e),i(t)}(Ve),mc=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl;return i.method=_e.POST,i.path="".concat(Le(c),"/").concat(encodeURIComponent(l),"/scheduled_messages"),i.params=ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return ns.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),i}return c(a,t),i(a)}(je),gc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new fo(e,a),i}return c(t,e),i(t)}(Ve),yc=function(e){return D("string",e.title,!0)&&ro(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0)},Ec=function(e){function t(e){var a,i=e.pollId,s=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a.params={title:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(je),kc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),bc=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(je),Cc=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/close"),a}return c(t,e),i(t)}(je),wc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),xc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.optionText;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:i,channel_type:s,text:u},a}return c(t,e),i(t)}(je),Sc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Tc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId,o=e.optionText;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a.params={text:o},a}return c(t,e),i(t)}(je),Ic=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Nc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),Ac=function(t){function a(t){var i=t.reqId,s=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n(this,a,[{code:"VOTE",ackRequired:!0,payload:pe({req_id:i,channel_type:s===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})}])}return c(a,t),i(a)}(Qe),Mc=i((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})),Oc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"VOTE",i])).event=new Mc(i),s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),Uc=function(e){function t(e){var a,i=e.title,s=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=Ne,a.params={title:i,options:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(je),Dc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Rc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(je),Lc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Pc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(je),Fc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pollOption=new ao(e,a),i}return c(t,e),i(t)}(Ve),qc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/polls/changelogs"),a.params=pe({change_ts:o,token:u}),a}return c(t,e),i(t)}(je),Hc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedPolls=a.updated.map((function(t){return function(e,t){return new io(e,t)}(e,t)})),i.deletedPollIds=a.deleted.map((function(e){return e})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(Ve),Gc={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},jc=function(e){return D("string",e.title)&&(t=e.optionTexts,P("string",t)&&t.every((function(e){return""!==e.trim()})))&&ro(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0);var t},Vc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},zc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)&&t.pollId>0&&D("number",t.pollOptionId)&&t.pollOptionId>0},Bc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},Kc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)},Qc={},Wc=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,u=n.logger;r(this,e),this._iid=t,this._sdkState=a,this._sessionManager=s,this._requestQueue=o,this._dispatcher=i,this._logger=u,Qc[t]=this}),[{key:"buildPollFromSerializedData",value:function(e){var t=ri(e);return new io(this._iid,io.payloadify(t))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(Kc(e)).throw(A.invalidParameters),n=new Rc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Lc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(jc(e)).throw(A.invalidParameters),n=new Uc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Dc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(zc(e)).throw(A.invalidParameters),n=new Pc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Fc),i=a.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogs",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.SYNC_POLL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new qc(ve({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null})),e.next=3,this._requestQueue.send(i);case 3:return s=e.sent,o=s.as(Hc),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,u.length>0&&this._dispatcher.dispatch(new Ps({polls:u,source:a})),e.abrupt("return",{updatedPolls:u,deletedPollIds:c,hasMore:l,token:h});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Qc[e]}}])}(),Yc="GroupChannel",Zc="Message",Xc="NotificationMessage",Jc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=Ne,a.params={channel_url:i,channel_type:s,token:o,limit:u},a}return c(t,e),i(t)}(je),$c=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).polls=(null!==(s=a.polls)&&void 0!==s?s:[]).map((function(t){return new io(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(Ve),el=function(e){function t(e,a){return r(this,t),n(this,t,[e,a.channelUrl,a.channelType,a])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new Jc(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as($c),s=i.polls,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),tl=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:i,channel_type:s,token:c,limit:l},a}return c(t,e),i(t)}(je),nl=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).voters=(null!==(s=a.voters)&&void 0!==s?s:[]).map((function(t){return new si(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(Ve),rl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a.channelUrl,a.channelType,a])).pollId=a.pollId,i.pollOptionId=a.pollOptionId,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("number",this.pollId)&&D("number",this.pollOptionId)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new tl(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(nl),s=i.voters,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu);var al,il=Object.assign(Object.assign({},Ho),{fileInfoList:[]}),sl=function(e){return(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},ol=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._onFileUploaded=ht,e}return c(t,e),i(t,[{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(t,"onPending",this,3)([e]),this}},{key:"onFailed",value:function(e){return p(t,"onFailed",this,3)([e]),this}},{key:"onSucceeded",value:function(e){return p(t,"onSucceeded",this,3)([e]),this}}])}(qo),ul=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e])).message=null,i.message=ho(e,a.message),i}return c(t,e),i(t)}(Ya),cl=function(e){function t(e){var a;r(this,t);var i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,d=e.includeParentMessageInfo,h=e.includeThreadInfo,f=e.includePollDetails;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/pinned_messages"),a.params=pe({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),a}return c(t,e),i(t)}(je),ll=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.pinned_messages,o=a.has_more,u=a.next;return i.pinnedMessages=s.map((function(t){return new ul(e,t)})),i.hasMore=o,i.token=u,i}return c(t,e),i(t)}(Ve),dl=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s])).includeMetaArray=s.includeMetaArray,o.includeReactions=s.includeReactions,o.includeParentMessageInfo=s.includeParentMessageInfo,o.includeThreadInfo=s.includeThreadInfo,o.includePollDetails=s.includePollDetails,o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeMetaArray,!0)&&D("boolean",this.includeReactions,!0)&&D("boolean",this.includeParentMessageInfo,!0)&&D("boolean",this.includeThreadInfo,!0)&&D("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new cl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(ll),s=i.pinnedMessages,o=i.hasMore,u=i.token,this._token=u,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(cu),hl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(je),fl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(je);!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(al||(al={}));var pl,vl=function(t){function a(t,i){var s,o,u,c,l,d,h,f;return r(this,a),(s=n(this,a,[t]))._name="",s._createdAt=0,s.pinnedMessageIds=[],s.channelType=e.ChannelType.BASE,s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s._messageCollectionLastAccessedAt=0,s._url=i.channel_url,s._name=null!==(o=i.name)&&void 0!==o?o:"",s._createdAt=1e3*i.created_at,s.coverUrl=null!==(u=i.cover_url)&&void 0!==u?u:"",s.customType=null!==(c=i.custom_type)&&void 0!==c?c:"",s.data=null!==(l=i.data)&&void 0!==l?l:"",s.isFrozen=null!==(d=i.freeze)&&void 0!==d&&d,s.isEphemeral=null!==(h=i.is_ephemeral)&&void 0!==h&&h,s.creator=i.created_by?new si(s._iid,i.created_by):null,i.metadata&&Object.keys(i.metadata).length>0&&i.ts?(s._cachedMetaData=new Map,Object.keys(i.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:i.metadata[e],isRemoved:!1,updatedAt:i.ts})}))):"string"==typeof i.metadata&&(s._cachedMetaData=new Map(Object.entries(JSON.parse(i.metadata)))),s.pinnedMessageIds=null!==(f=i.pinned_message_ids)&&void 0!==f?f:[],s}return c(a,t),i(a,[{key:"url",get:function(){return this._url}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"createdAt",get:function(){return this._createdAt}},{key:"toJSON",value:function(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}},{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"isFeedChannel",value:function(){return this.channelType===e.ChannelType.FEED}},{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:"_serializeCachedMetaData",value:function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=pe(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:"_updateCachedMetaData",value:function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(a,i){var s;a.updatedAt<=t&&(n._cachedMetaData.set(i,{value:null!==(s=e[i])&&void 0!==s?s:a.value,isRemoved:!e[i],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}}},{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 hu(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new _u(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yu(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new fu(this._iid,this.url,this.channelType,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new dl(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Eu({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"removeOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new ku({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyMutedInfo",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new bu({channelUrl:this.url,channelType:this.channelType,userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Cu),o=s.isMuted,u=s.startAt,c=s.endAt,l=s.remainingDuration,h=s.description,e.abrupt("return",{isMuted:o,startAt:u,endAt:c,remainingDuration:l,description:h});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new wu({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(xu),o=s.metadata,u=s.ts,this._upsertCachedMetaData(o,u),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new wu({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(xu),s=i.metadata,o=i.ts,this._updateCachedMetaData(s,o),e.abrupt("return",s);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Su({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Tu),o=s.metaData,this._upsertCachedMetaData(o,0),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=new Iu({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Nu),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Mu({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:i=t.sent,s=i.as(Ou),o=s.ts,this._removeFromCachedMetaData([e],o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Uu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Du),s=i.ts,this._removeFromCachedMetaData(v(this._cachedMetaData.keys()),s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Ru({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(Lu),o=s.metaCounter,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Ru({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Lu),s=i.metaCounter,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Pu({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Fu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaCounters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=new qu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Hu),u=o.metaCounter,n.abrupt("return",u);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new qu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Hu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new qu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Hu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new ju({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Vu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.muteUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"muteUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new zu({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unmuteUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Ku({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"banUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.banUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"banUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new Wu({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unbanUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unbanUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Zu({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"freeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Ju({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,n.send(r);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Ju({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,n.send(r);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},wo),t),ai(D("number",e)&&xo(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessagesByMessageId(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},wo),t),ai(D("number",e)&&xo(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessagesByTimestamp(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},So),t),ai(D("number",e)&&To(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},So),t),ai(D("string",e)&&To(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,i=es.of(this._iid).sessionManager;return pe(ve({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 vs.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:i.currentUser?ps.payloadify(i.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 si.payloadify(e)}))}))}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var i,o=s(t.translationTargetLanguages);try{for(o.s();!(i=o.n()).done;){a[i.value]=""}}catch(e){o.e(e)}finally{o.f()}}var u=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a,extended_message_payload:t.extendedMessagePayload})),c=new oo(this._iid,u);return c.messageParams=t,c}},{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,i,s,o,u,c,l,d=pe(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===(i=t.file)||void 0===i?void 0:i.name,size:null!==(s=t.fileSize)&&void 0!==s?s: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:null===(l=t._thumbnails)||void 0===l?void 0:l.map((function(e){return ns.payloadify(e)}))})),h=new fo(this._iid,d);return h.messageParams=t,h}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,file:t.fileInfoList.length>0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0})),i=new uo(this._iid,a);return i.messageParams=t,i}},{key:"_validateFailedFileMessageHasFile",value:function(e,t){var n;return Boolean(e.url)||H(t)||H(null===(n=e.messageParams)||void 0===n?void 0:n.file)}},{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.SendbirdErrorCode.REQUEST_CANCELED||n.code===e.SendbirdErrorCode.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({},Vo),e);return ai(Qo(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:al.SEND,a=arguments.length>2?arguments[2]:void 0,i=es.of(this._iid),s=i.dispatcher,o=i.requestQueue,u=null!=a?a:this._generateRequestId(),c=Date.now(),l=new qo;return mi(2).then((function(){var a=n._createPendingUserMessage(t,u,c);s.dispatch(new Os({messages:[a],source:r===al.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a));case 1:case"end":return e.stop()}}),e)})))}));var i=new rc(Object.assign(Object.assign({},t),{channelUrl:n.url,channelType:n.channelType,reqId:u}));o.send(i).then((function(t){var r=t.as(ac).message;s.dispatch(new Os({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().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)})))}))})).catch((function(r){if(N(r))throw r;mi(2).then((function(){var a=n._createPendingUserMessage(t,u,c),i=es.of(n._iid).cacheContext,o=i.localCacheEnabled&&i.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,o),s.dispatch(new Os({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),l}},{key:"_autoResendUserMessage",value:function(e){return ai(e instanceof oo&&!!e.messageParams).throw(A.invalidParameters),this._sendUserMessage(e.messageParams,al.SEND,e.reqId)}},{key:"resendUserMessage",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof oo&&!e.scheduledInfo).throw(A.invalidParameters),r=new ot,a=null!==(t=e.messageParams)&&void 0!==t?t:Ko(e),this._sendUserMessage(a,al.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"updateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},au),t),ai(D("number",e)&&iu(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new ic(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(sc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"copyUserMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ai(t instanceof a&&n instanceof oo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),ai(!n.poll).throw(A.notSupportedError),u=new ot,c=null!==(r=n.messageParams)&&void 0!==r?r:ve(Object.assign(Object.assign({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(s=n.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),t._sendUserMessage(c).onSucceeded((function(e){u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 6:case"end":return o.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof oo&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new fc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(pc),u=o.message,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_createScheduledUserMessage",value:function(e,t){var n=this,r=es.of(this._iid).requestQueue,a=Date.now(),i=this._generateRequestId();mi(2).then((function(){var r=n._createPendingScheduledUserMessage(e,i,a);hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))}));var s=new vc(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(_c).message;hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;mi(2).then((function(){var s=n._createPendingScheduledUserMessage(e,i,a);n._markMessageAsFailed(s,r),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},Xo),e);return ai(tu(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},il),e),r=es.of(this._iid);ai(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return Go(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return sl(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 ai(!a).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:al.SEND,a=arguments.length>2?arguments[2]:void 0,i=es.of(this._iid).dispatcher,s=nh.of(this._iid).fileMessageQueue,o=null!=a?a:this._generateRequestId(),u=Date.now(),c=new qo;return mi(2).then((function(){var a=n._createPendingFileMessage(t,o,u);i.dispatch(new Os({messages:[a],source:r===al.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a));case 1:case"end":return e.stop()}}),e)})))})),s.request(n,o,t).then((function(t){i.dispatch(new Os({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;mi(2).then((function(){var a=n._createPendingFileMessage(t,o,u),s=es.of(n._iid).cacheContext,l=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,l),i.dispatch(new Os({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:r.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_autoResendFileMessage",value:function(e){ai(e instanceof fo&&!!e.messageParams).throw(A.invalidParameters);var t=es.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,al.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(t,n,r){var a=this,i=es.of(this._iid).dispatcher,s=nh.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new ol;return mi(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);i.dispatch(new Os({messages:[r],source:n===al.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(r));case 1:case"end":return e.stop()}}),e)})))})),s.request(a,o,t,{requestHandler:c,isCopy:n===al.COPY}).then((function(t){i.dispatch(new Os({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(n){if(N(n))throw n;mi(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);a._markMessageAsFailed(r,n),i.dispatch(new Os({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(n,r));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_createScheduledFileMessage",value:function(e,t,n,r){var a=this,i=es.of(this._iid).requestQueue,s=new mc(Object.assign(Object.assign({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(s).then((function(e){var n=e.as(gc).message;hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(N(i))throw i;mi(2).then((function(){var s=a._createPendingScheduledFileMessage(e,n,r);a._markMessageAsFailed(s,i),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(i,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){ai(e.every((function(e){return tu(Object.assign(Object.assign({},Xo),e))}))).throw(A.invalidParameters);var t,n=new qo,r=s(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,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._validateFailedFileMessageHasFile(e,t),ai(e instanceof fo&&r&&!e.scheduledInfo).throw(A.invalidParameters),a=new ot,i=eu(e,t),this._sendFileMessage(i,al.RESEND,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),n.abrupt("return",a.promise);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"resendMessage",value:function(e,t){var n,r;if(ai(e instanceof Ys&&!e.scheduledInfo&&e.isResendable).throw(A.invalidParameters),e.isUserMessage()){var a=null!==(n=e.messageParams)&&void 0!==n?n:Ko(e);return this._sendUserMessage(a,al.RESEND,e.reqId)}if(e.isFileMessage()){var i=this._validateFailedFileMessageHasFile(e,t);ai(i).throw(A.invalidParameters);var s=null!==(r=e.messageParams)&&void 0!==r?r:eu(e,t);return this._sendFileMessage(s,al.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"updateFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},su),t),ai(D("number",e)&&ou(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new oc(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(uc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"uploadFile",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=ce(),(i=new rs({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a),t.next=7,r.send(i);case 7:return s=t.sent,o=s.as(as),u=o.url,c=o.thumbnails,t.abrupt("return",{requestId:a,url:u,thumbnails:c});case 10:case"end":return t.stop()}}),t,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=nh.of(this._iid),n.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"copyFileMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ai(t instanceof a&&n instanceof fo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),u=new ot,c=ve(Object.assign(Object.assign({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=n.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),t._sendFileMessage(c).onSucceeded((function(e){return u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 5:case"end":return o.stop()}}),o,this)})))}},{key:"copyMessage",value:function(t,n){ai(t instanceof a&&n instanceof Ys&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters);var r=n,i=t;if(r.isUserMessage()){ai(!r.poll).throw(A.notSupportedError);var s=zo(r);return i._sendUserMessage(s)}if(r.isFileMessage()){var o=Jo(r);return i._sendFileMessage(o)}if(n.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"deleteMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ai(e instanceof Ws).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return n=es.of(this._iid),r=n.requestQueue,a=new ct({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof Ys?e._messageToken:void 0}),t.next=6,r.send(a);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"addReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof Ws&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new cc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(lc),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof Ws&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new dc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(hc),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_updateUserMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=es.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new ic({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(sc),f=h.message,o.dispatch(new Os({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=es.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new oc({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(uc),f=h.message,o.dispatch(new Os({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new vs({key:e})})),!(e instanceof fo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"add",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"add",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new vs({key:e})})),!(e instanceof fo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"remove",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"remove",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&t.every((function(e){return e instanceof vs}))).throw(A.invalidParameters),!(e instanceof fo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"add",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"add",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&t.every((function(e){return e instanceof vs}))).throw(A.invalidParameters),!(e instanceof fo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"remove",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"remove",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"report",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(R(e.ReportCategory,t)&&D("string",n)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new ec({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:t,description:n}),r.next=5,s.send(o);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"reportUser",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ai(t instanceof si&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=es.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new tc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.userId,category:n,description:r}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"reportMessage",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ai(t instanceof Ys&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=es.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new nc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r,messageToken:t._messageToken}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"updatePoll",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("number",e)&&yc(t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new Ec(Object.assign({pollId:e},t)),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(kc),u=o.poll,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deletePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ai(n).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new bc({pollId:e}),t.next=6,a.send(i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"closePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ai(n).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new Cc({pollId:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(wc),u=o.poll,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"addPollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("string",t)&&""!==t.trim(),ai(r).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new xc({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(Sc),c=u.poll,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updatePollOption",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",e)&&D("number",t)&&D("string",n)&&""!==n.trim(),ai(a).throw(A.invalidParameters),i=es.of(this._iid),s=i.requestQueue,o=new Tc({pollId:e,pollOptionId:t,optionText:n}),r.next=6,s.send(o);case 6:return u=r.sent,c=u.as(Ic),l=c.poll,r.abrupt("return",l);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"deletePollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("number",t),ai(r).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new Nc({pollId:e,pollOptionId:t}),n.next=6,i.send(s);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"votePoll",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",t)&&P("number",n),ai(a).throw(A.invalidParameters),i=es.of(this._iid),s=i.requestQueue,o=i.dispatcher,u=new Ac({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:n}),r.next=6,s.send(u);case 6:return c=r.sent,l=c.as(Oc),h=l.event,o.dispatch(new qs({event:h,source:e.CollectionEventSource.EVENT_POLL_VOTED})),r.abrupt("return",h);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("number",e)).throw(A.invalidParameters),n=Wc.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e,!0)),n=Wc.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new el(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 rl(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}},{key:"pinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("number",e)&&e>0).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new hl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unpinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("number",e)&&e>0).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new fl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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?si.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}}])}(Ya),_l=i((function e(t){r(this,e),this.key=t.key,this.url=t.url})),ml=i((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 _l(e)})):[]})),gl=i((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new ml(e)})):[]})),yl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onConnected=ht,this.onReconnectStarted=ht,this.onReconnectSucceeded=ht,this.onReconnectFailed=ht,this.onDisconnected=ht}))),El=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onSessionExpired=ht,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=ht,this.onSessionRefreshed=ht,this.onSessionClosed=ht}))),kl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onFriendsDiscovered=ht,this.onTotalUnreadMessageCountChanged=ht,this.onTotalUnreadMessageCountUpdated=ht}))),bl=function(e){function t(e){var a,i=e.limit,s=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=ge,a.params=pe({limit:i,token:s,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return c(t,e),i(t)}(je),Cl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new si(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(Ve),wl=function(e){function t(e,a){var i,s,o,u;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.metaDataKeyFilter=null,i.metaDataValuesFilter=null,i.nicknameStartsWithFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i.metaDataKeyFilter=null!==(o=a.metaDataKeyFilter)&&void 0!==o?o:null,i.metaDataValuesFilter=null!==(u=a.metaDataValuesFilter)&&void 0!==u?u:null,i.nicknameStartsWithFilter=a.nicknameStartsWithFilter||null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)&&D("string",this.metaDataKeyFilter,!0)&&P("string",this.metaDataValuesFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new bl(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Cl),s=i.users,o=i.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),xl=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token,u=e.userIdsFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/block"),a.params=pe({limit:s,token:o,user_ids:u}),a}return c(t,e),i(t)}(je),Sl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new si(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(Ve),Tl=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new xl(ve(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token}))),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Sl),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),Il=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={limit:s,token:o},a}return c(t,e),i(t)}(je),Nl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).hasMore=a.has_more,i.users=a.users.map((function(t){return new si(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(Ve),Al=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Il(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Nl),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),Ml={},Ol=function(){return i((function e(t){var n=t.dbname,a=t.itemSizeLimit,i=void 0===a?1048576:a,s=t.cacheLimit,o=void 0===s?256:s,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,d=void 0===l?10:l,h=t.blockHashConstant,f=void 0===h?11:h,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),Ml[n]||(this.itemSizeLimit=i,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=d,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,Ml[n]=this),Ml[n]}),null,[{key:"get",value:function(e){return Ml[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"}(pl||(pl={}));var Ul,Dl=function(e){function t(e){var a,i=e.code,s=void 0===i?pl.UNKNOWN_ERROR:i,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,t),(a=n(this,t,[u])).code=s,Object.setPrototypeOf(a,t.prototype),a}return c(t,e),i(t,null,[{key:"storeNotDefined",get:function(){return new t({code:pl.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new t({code:pl.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new t({code:pl.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new t({code:pl.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new t({code:pl.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new t({code:pl.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new t({code:pl.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new t({code:pl.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new t({code:pl.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new t({code:pl.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new t({code:pl.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new t({code:pl.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new t({code:pl.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new t({code:pl.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new t({code:pl.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new t({code:pl.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new t({code:pl.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new t({code:pl.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new t({code:pl.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new t({code:pl.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new t({code:pl.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new t({code:pl.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new t({code:pl.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new t({code:pl.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new t({code:pl.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}])}(y(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ul||(Ul={}));var Rl,Ll=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===m(e)&&null!==e){if(t.has(e))throw Dl.circularReferenceFound;var n;if(t.set(e,!0),Array.isArray(e))n=e.map((function(e){return Ll(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]=Ll(e[r],t);return t.delete(e),n}return e},Pl=function(e,t){if(null==t)return 1;if(null==e)return-1;if(m(e)!==m(t))throw Dl.compareTypesNotMatch;var n=0;switch(m(e)){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Fl=function(e,t){for(var n=0,r=0;r>>0)%t},ql=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Hl=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!Hl(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Hl(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"===m(e[r])){var a=e[r];for(var i in a)switch(i){case"/eq":case"=":if(t[r]!==a[i])return!1;break;case"/neq":case"!=":if(t[r]===a[i])return!1;break;case"/gt":case">":var s=t[r],o=a[i];if(!(Pl(s,o)>0))return!1;break;case"/gte":case">=":var u=t[r],c=a[i];if(!(Pl(u,c)>=0))return!1;break;case"/lt":case"<":var l=t[r],d=a[i];if(!(Pl(l,d)<0))return!1;break;case"/lte":case"<=":var h=t[r],f=a[i];if(!(Pl(h,f)<=0))return!1;break;case"/in":var p=t[r];if(!a[i].includes(p))return!1;break;case"/nin":var v=t[r];if(a[i].includes(v))return!1;break;case"/contain":var _=t[r],g=a[i];if(!_.includes(g))return!1;break;case"/regex":var y=t[r];if(!a[i].test(y))return!1;break;case"/where":var E=t[r];if(!(0,a[i])(E))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)},Gl=function(){},jl=function(){return Promise.resolve()},Vl=function(e){return e},zl=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Rl||(Rl={}));var Bl,Kl,Ql,Wl=function(){return i((function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,i=t.initialNextValue,s=void 0===i?null:i,o=t.iterator,u=t.map,c=void 0===u?Vl:u,l=t.backward,d=void 0===l?jl:l,h=t.forward,f=void 0===h?jl:h,p=t.complete,v=void 0===p?Gl:p;r(this,e),this._prevValue=a,this._nextValue=s,this._error=null,this._map=c,this._backward=d,this._forward=f,this._iterator=o,this._complete=v}),[{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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,t=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,t=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}])}(),Yl=function(){return i((function e(t){var n=t.condition,a=void 0===n?{}:n,i=t.backward,s=void 0!==i&&i,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=s,this._blockManager=o,this._indexer=u}),[{key:"findOptimizedStartPosition",value: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 a in this._indexer.fields){var i=this._indexer.fields[a],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),this.condition[i])if("object"===m(this.condition[i])){var o=s>0?n:t;for(var u in this.condition[i])if(o.includes(u))for(var c=r;c>=0;c--)if(s*Pl(this._indexer.origin[c].columnValues[a],this.condition[i][u])<=0){r=c;break}}else for(var l=r;l>=0;l--)if(s*Pl(this._indexer.origin[l].columnValues[a],this.condition[i])<=0){r=l;break}}return Math.min(r+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var h=function(r){var a=e._indexer.fields[r],i=1;if("-"===a[0]&&(a=a.slice(1),i=-1),e.condition[a])if("object"===m(e.condition[a]))Object.keys(e.condition[a]).forEach((function(s){if((i>0?t:n).includes(s))for(var o=d;o=0){d=o;break}}));else for(var s=d;s=0){d=s;break}},f=0;f0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Math.max(e.offset||0,0),0!==(r="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){t.next=6;break}return t.abrupt("return",[]);case 6:if(!(r<0)){t.next=8;break}throw Dl.collectionQueryNotValid;case 8:return t.prev=8,a=[],t.next=12,this._mutex.lock();case 12:return t.next=14,this._iterator.each((function(e){return E(i,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===n?(a.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(td(e,t)).concat(n,".").concat(r)},rd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=i}),[{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(n=t.sent)){t.next=19;break}if(r=n.data,a=n.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(r);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(s=[],o=atob(r.split(",")[1]),u=0;u1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,new Promise((function(n){var r=nd(o.dbname,o.collectionName,t),a=new FileReader;a.onload=function(){n({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return r=n.sent,a=r.blobId,i=r.data,s=r.type,n.next=8,this.store.set({key:a,value:{data:i,type:s}});case 8:return n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=td(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return n=e.sent,e.next=6,Promise.all(n.filter((function(e){return e.startsWith(t)})).map((function(e){return E(r,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}])}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Bl||(Bl={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Kl||(Kl={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Ql||(Ql={}));var ad,id,sd=[Kl.PENDING,Kl.VOLATILE],od={},ud=function(){return i((function e(t){var n=t.dbname,a=t.limit,i=void 0===a?256:a;return r(this,e),od[n]||(this.dbname=n,this._items=[],this._limit=i,od[n]=this),od[n]}),[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ql.DEFAULT;return E(this,void 0,void 0,d().mark((function r(){var a,i;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=this.get(t)){r.next=8;break}return r.next=4,e.get(t);case 4:(i=r.sent)&&(a={key:t,value:i,state:n===Ql.PERSISTENT?Kl.PERSISTENT:Kl.VOLATILE},this.put(a)),r.next=9;break;case 8:n===Ql.PERSISTENT&&(a.state=Kl.PERSISTENT);case 9:return r.abrupt("return",a);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ql.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===Ql.PERSISTENT&&(r.state=Kl.PERSISTENT),t!==Ql.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)sd.includes(this._items[t].state)&&sd.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===Kl.VOLATILE})),r=n.length-this._limit;if(r>0){var a,i=[],o=s(this._items);try{for(o.s();!(a=o.n()).done;){var u=a.value;u.state===Kl.VOLATILE&&r>0?r--:i.push(u)}}catch(e){o.e(e)}finally{o.f()}this._items=i}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clearForDatabase",value:function(e){this.clearByCondition((function(t){return t.key.startsWith(Xl(e))}))}},{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!==Kl.VOLATILE}))}}],[{key:"get",value:function(e){return od[e]}}])}(),cd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=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(Jl(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Jl(e,t),"/trans.recordset")}(n,a),this._store=i}),[{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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(n=t.t0).push.apply(n,v(e)),t.abrupt("return",this._reduceRecordSet(n));case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],i=[],s=a.requests.length-1;s>=0;s--){var o=a.requests[s],u=o.data;n[u.key]||(i.unshift(o),n[u.key]=!0)}i.length>0&&(a.requests=i,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ud.get(this.dbname),a=t.generation,i=t.requests,s=null,n.prev=3,n.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:a})})));case 6:for(o=n.sent,u=0;u0)){e.next=20;break}for(n=[],r={},a=t.length-1;a>=0;a--)i=t[a],s=i.data,r[s.key]||(r[s.key]=!0,n.unshift(i));return o={generation:this.generation,requests:n},e.next=8,this._getReducedRecordset([o]);case 8:return u=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:u});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(c=ud.get(this.dbname),l=0;l1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=i,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||Fl)(e,r)}(e,i,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(ed(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=ud.get(this.dbname),r=this.metadata.blockLevel;case 2:if(!(r>0)){t.next=15;break}return a=this.createBlockId(e,r),t.next=6,n.find(this._store,a);case 6:if(!(i=t.sent)){t.next=12;break}if(s=ld.createFromCacheItem(i),!(null==s?void 0:s.getItemByKey(e))){t.next=12;break}return t.abrupt("return",s);case 12:r--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"getFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return n=t.sent,t.abrupt("return",n?n.getItemByKey(e):null);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"putToBlock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Ol.get(this.dbname),a=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/r.itemSizeLimit),s=ud.get(this.dbname),n.next=6,s.find(this._store,a);case 6:if(o=n.sent,!(null==(u=o?ld.createFromCacheItem(o):new ld({blockId:a,keyName:this.keyName,items:[],limit:i}))?void 0:u.add(t))){n.next=11;break}return this._transaction.requestWrite({key:u.blockId,value:u.serialize()}),n.abrupt("return",!0);case 11:return n.abrupt("return",!1);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"removeFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(n=t.sent)){t.next=7;break}if(!n.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:n.blockId,value:n.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"clearAllBlocks",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ed(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return n=e.sent,r=n.filter((function(e){return e.startsWith(t)})),e.next=7,this._store.removeMany(r);case 7:return e.next=9,this._transaction.clear();case 9:ud.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(t)}));case 11:case"end":return e.stop()}}),e,this)})))}}])}(),hd={},fd=function(){return i((function e(t){var n=this,a=t.dbname,i=t.collectionName,s=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(Jl(e,t),"/index.").concat(n)}(a,i,o.join(">"));return hd[l]||(this.dbname=a,this.collectionName=i,this.keyName=s,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Bl.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Bl.ERROR,this.indexerKey,(function(){return n.abort()}))),hd[l]}),[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=f(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=f(this.indexOf(n),2),a=r[0];if(r[1]){var i=this._table[a].keys.indexOf(t);if(i>-1)return this._table[a].keys.splice(i,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,n,r,a=[],i=s(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),n=e[o],r=void 0,r=m(n),null!==n&&"undefined"!==r&&"boolean"!==r&&"number"!==r&&"string"!==r)throw Dl.indexTypesNotMatch;a.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return a}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Pl(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,d().mark((function e(){var t,n,r,a,i,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ud.get(this.dbname),e.next=3,t.find(this._store,this.indexerKey,Ql.PERSISTENT);case 3:if(n=e.sent){e.next=33;break}return r=ed(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:a=e.sent,i=s(a),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=22;break}if(!(u=o.value).startsWith(r)){e.next=20;break}return e.next=17,t.find(this._store,u,Ql.NO_CACHE);case 17:if(c=e.sent,l=ld.createFromCacheItem(c)){h=s(l.items);try{for(h.s();!(f=h.n()).done;)p=f.value,this._addItem(p)}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=n.value,this._table=Ll(this._origin);case 35:hd[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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ud.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete hd[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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=Ll(this._origin)}},{key:"abort",value:function(){this._table=Ll(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 hd)delete hd[e]}}])}(),pd=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},vd=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"}(ad||(ad={})),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"}(id||(id={}));var _d,md={},gd=function(){return i((function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=ad.PROCESSING,this._queue=[],this._activationQueue=[],md[t]&&!a.forceCreate||(this.nodeId=vd(),this.key=t,pd()&&(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;if(null==t?void 0:t.isNestDbMessage){var r=t.nodeId,a=t.requestId,i=t.key,o=t.op,u=t.data;if(r!==n.nodeId&&i===n.key)switch(o){case id.NEWNODE:n._sendSync();break;case id.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case id.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var c,l=u.currentItemRequestId,d=s(u.queue);try{var h=function(){var e=c.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:id.REQUEST_LOCK,ts:e.ts})};for(d.s();!(c=d.n()).done;)h()}catch(e){d.e(e)}finally{d.f()}n._currentItem=n._queue.find((function(e){return e.requestId===l})),n._completeSync()}break;case id.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 id.REQUEST_LOCK:n._requestLock(t);break;case id.ACQUIRE_LOCK:var f=n._queue.find((function(e){return e.requestId===a}));n._acquire(f);break;case id.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(id.REMOVENODE)}))),md[t]=this),md[t]}),[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==ad.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:vd(),key:this.key,op:e,data:n.data,ts:Date.now()};return pd()&&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(id.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(id.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var i in t._queue)if(t._queue[i].ts>r.ts){t._queue.splice(parseInt(i),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(id.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,d().mark((function e(){var t=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){t._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=ad.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(id.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(id.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return t=this._send(id.REQUEST_LOCK),e.next=5,this._requestLock(t);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)}}])}(),yd=function(){function e(t){var n=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=Ul.INIT,this._indexers=[],this.dbname=a,this.name=i,this.keyName=s,this.indexes=[[s]].concat(v(u.filter((function(e){return fd.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new gd(function(e,t){return"".concat(Jl(e,t),".lock")}(a,i)),this._blobContainer=new rd({dbname:a,collectionName:i,store:c}),this._transaction=new cd({dbname:a,collectionName:i,store:c})}return i(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===Ul.READY}},{key:"init",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l,h,f,p,_=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,n=Ol.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return r=t.sent,this._metadata=r||{keyName:this.keyName,blockLevel:1,blockHashBase:n.blockHashBase,blockHashMultiplier:n.blockHashMultiplier,blockHashConstant:n.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new dd({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),a=v(this.indexes),i=[],o=a.map((function(e){return fd.createKey(e)})),u=r?r.indexes.map((function(e){return fd.createKey(e)})):[],c=s(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(fd.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(f=[]).push.apply(f,v(a.map((function(e){var t=new fd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()})))),f.push.apply(f,v(i.map((function(e){return new fd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()})))),t.next=22,Promise.all(f);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return p=$l(this.dbname,this.name),this._metadata.indexes=a,t.next=29,this._store.set({key:p,value:this._metadata});case 29:this._state=Ul.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),t,this,[[2,33]])})))}},{key:"close",value:function(){this._state=Ul.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=fd.createKey(e),r=s(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===fd.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Dl.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=$l(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:t,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:r=s(this._indexers),t.prev=14,r.s();case 16:if((a=r.n()).done){t.next=22;break}return i=a.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),r.e(t.t0);case 27:return t.prev=27,r.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Dl.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),t,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(r=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:a=s(this._indexers),t.prev=14,a.s();case 16:if((i=a.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),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(n,e);case 34:u=s(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(r),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(r);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()}}),t,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(!(r=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:a=s(this._indexers),t.prev=8,a.s();case 10:if((i=a.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(r),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(r);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),a.e(t.t0);case 24:return t.prev=24,a.f(),t.finish(24);case 27:case"end":return t.stop()}}),t,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(n=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:r=s(this._indexers),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return i=a.value,t.next=13,i.removeItem(n);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:case"end":return t.stop()}}),t,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:t=s(this._indexers),e.prev=3,t.s();case 5:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=9,r.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return n=t.sent,this._mutex.unlock(),t.abrupt("return",Ll(n));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Dl.collectionNotReady;case 18:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new Zl({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Dl.collectionNotReady}},{key:"insertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Dl.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Ll(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 Dl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Dl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestInsert(Ll(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Dl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Dl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Ll(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 Dl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Dl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestUpsert(Ll(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Dl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Dl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Ll(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 Dl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"updateIf",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.isReady){n.next=31;break}return n.next=3,this._mutex.lock();case 3:return n.prev=3,r=e.where,a=void 0===r?{}:r,i=e.index,s=void 0===i?null:i,o=e.backward,u=void 0!==o&&o,c=[],l=new Yl({condition:a,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(s)}),n.next=9,l.each((function(e){return E(v,void 0,void 0,d().mark((function n(){var r,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.error){n.next=4;break}if(e.hasNext){if(r=e.nextValue,Hl(a,r)&&t.set){if("function"!=typeof t.set)for(i in t.set)r[i]=t.set[i];else t.set(r);c.push(r)}e.next()}else e.stop();n.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return n.stop()}}),n)})))}));case 9:h=0,f=c;case 10:if(!(h1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return v(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)),i=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(i).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:i}),r}))}},{key:"_resetIfEncryptionChanged",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(this._encryptionCheckKey);case 2:if(t=e.sent,n={encrypted:Cd.map((function(e){var t;return null===(t=s.encryption)||void 0===t?void 0:t.encrypt(e)}))},!t){e.next=22;break}if(!t.encrypted||!Array.isArray(t.encrypted)){e.next=20;break}e.t0=d().keys(t.encrypted);case 7:if((e.t1=e.t0()).done){e.next=18;break}if(r=e.t1.value,a=JSON.stringify(t.encrypted[r]),i=JSON.stringify(n.encrypted[r]),a===i){e.next=16;break}return bd.warning("Encryption algorithm has changed. Stored data would be cleared."),e.next=15,this.clear();case 15:return e.abrupt("break",18);case 16:e.next=7;break;case 18:e.next=22;break;case 20:return e.next=22,this.clear();case 22:return e.next=24,this.set({key:this._encryptionCheckKey,value:n});case 24:case"end":return e.stop()}}),e,this)})))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=0,e.next=3,this._getAllRawKeys();case 3:n=e.sent,r=s(n),e.prev=5,r.s();case 7:if((a=r.n()).done){e.next=15;break}return i=a.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(t+=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),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})).filter((function(e){return!n._reservedKeys.includes(e)})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=21;break}if(t.prev=5,a=r.data,!((null==(i=r.metadata)?void 0:i.shards)&&i.shards>1)){t.next=13;break}return t.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return E(o,void 0,void 0,d().mark((function n(){var r,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>0)){n.next=10;break}return r=this._getRawKey(e,".".concat(t)),n.next=4,this._getRaw(r);case 4:if(i=n.sent){n.next=7;break}throw Dl.storeBrokenIntegrity;case 7:return n.abrupt("return",i.data);case 10:return n.abrupt("return",a);case 11:case"end":return n.stop()}}),n,this)})))})));case 10:t.t0=t.sent,t.next=14;break;case 13:t.t0=[a];case 14:return s=t.t0,t.abrupt("return",this.encryption.decrypt(JSON.parse(s.join(""))));case 18:return t.prev=18,t.t1=t.catch(5),t.abrupt("return",null);case 21:return t.abrupt("return",null);case 22:case"end":return t.stop()}}),t,this,[[5,18]])})))}},{key:"set",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._shardify(e),t.next=3,this._setRaw(n);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[],t.next=3,this._setRaw(n.concat.apply(n,v(e.map((function(e){return r._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=12;break}return a=r.metadata,i=this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return o._getRawKey(e,".".concat(t))})),t.next=9,this._removeRaw(i);case 9:return null==(s=ud.get(this.dbname))||s.remove(e),t.abrupt("return",!0);case 12:return t.abrupt("return",!1);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"removeMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=ud.get(this.dbname),r=[],a=s(e),t.prev=3,o=d().mark((function e(){var t,a,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.value,a=u._getRawKey(t,".0"),e.next=4,u._getRaw(a);case 4:(s=e.sent)&&(o=s.metadata,r.push.apply(r,v(u._generateShardPostfixArray(null==o?void 0:o.shards).map((function(e){return u._getRawKey(t,".".concat(e))}))))),null==n||n.remove(t);case 7:case"end":return e.stop()}}),e)})),a.s();case 6:if((i=a.n()).done){t.next=10;break}return t.delegateYield(o(),"t0",8);case 8:t.next=6;break;case 10:t.next=15;break;case 12:t.prev=12,t.t1=t.catch(3),a.e(t.t1);case 15:return t.prev=15,a.f(),t.finish(15);case 18:if(!(r.length>0)){t.next=21;break}return t.next=21,this._removeRaw(r);case 21:return t.abrupt("return",e);case 22:case"end":return t.stop()}}),t,this,[[3,12,15,18]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==(t=ud.get(this.dbname))||t.clearForDatabase(this.dbname);case 2:case"end":return e.stop()}}),e,this)})))}}])}(),xd={},Sd=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:4194304})]);var s=i.delay,o=void 0===s?1:s;return e.delay=o,e.observer={},e}return c(t,e),i(t,[{key:"rawData",get:function(){return xd[this.dbname]},set:function(e){xd[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!xd[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(xd[this.dbname]));case 4:throw Dl.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!xd[this.dbname]){t.next=6;break}return t.next=3,ql(this.delay);case 3:return t.abrupt("return",xd[this.dbname][e]?Object.assign({key:e},xd[this.dbname][e]):null);case 6:throw Dl.storeNotAvailable;case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!xd[this.dbname]){t.next=7;break}return t.next=3,ql(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,i=a.key,o=a.data,u=a.metadata,xd[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Dl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!xd[this.dbname]){t.next=7;break}return t.next=3,ql(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,xd[this.dbname][a]&&delete xd[this.dbname][a]}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Dl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,xd[this.dbname]||(xd[this.dbname]={}),t.next=4,this._resetIfEncryptionChanged();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(t,"set",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=this.observer[e.key])||"function"!=typeof n.set){t.next=5;break}if(!(a=n.set())){t.next=5;break}throw a;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(t,"setMany",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((a=n.n()).done){t.next=12;break}if(i=a.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),n.e(t.t0);case 17:return t.prev=17,n.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),t,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,ql(this.delay);case 4:xd[this.dbname]={};case 5:case"end":return e.stop()}}),e,this)})))}}])}(wd),Td="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(_d||(_d={}));var Id,Nd=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:104857600})]))._storeName=Td,e._state=_d.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 c(t,e),i(t,[{key:"state",get:function(){return this._state}},{key:"isTransactionInactiveError",value:function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}},{key:"_putToObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.put(t);a.addEventListener("success",(function(e){n(e.target.result)})),a.addEventListener("error",(function(){r("Failed to write.")}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_deleteFromObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.delete(t);a.addEventListener("success",(function(){return n(t)})),a.addEventListener("error",(function(e){return r(e.target.error)}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=_d.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Td,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=_d.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=_d.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=_d.UNINITIALIZED,r(e.target.error)}))}else r(Dl.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().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===_d.UNINITIALIZED||t.t0===_d.OPEN?7:t.t0===_d.OPENING||t.t0===_d.CLOSED?8:9;break;case 7:throw Dl.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){n._openJobQueue.push((function(){return t(n._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()}}),t,this)})))}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readonly");case 2:return t=e.sent,e.next=5,new Promise((function(e,n){var r=t.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return n(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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readonly");case 2:return n=t.sent,t.next=5,new Promise((function(t,r){var a=n.get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return r(e.target.error)}))}));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._putToObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._putToObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._deleteFromObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._deleteFromObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{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,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(t="undefined"!=typeof window?window:null)?void 0:t.indexedDB)||(null==t?void 0:t.mozIndexedDB)||(null==t?void 0:t.webkitIndexedDB)||(null==t?void 0:t.msIndexedDB))){e.next=16;break}if(this._indexedDb=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB,!this._window||!pd()){e.next=13;break}if(!(pd()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!t.PointerEvent&&!t.MSPointerEvent){e.next=7;break}throw Dl.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(n._indexedDb)try{var r=n._indexedDb.open("_testMozilla");r.onerror=function(){return t(Dl.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),n._indexedDb){var a=n._indexedDb.deleteDatabase("_testMozilla");a.onerror=function(){return e()},a.onsuccess=function(){return e()}}else t(Dl.storeNotAvailable)}}catch(e){t(Dl.storeNotAvailableInPrivateBrowsing)}else t(Dl.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Dl.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,d().mark((function t(){return d().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:return t.next=7,this._resetIfEncryptionChanged();case 7:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,this._getObjectStore("readwrite");case 4:return t=e.sent,e.next=7,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))}}])}(wd),Ad=function(e){function t(e){var a;r(this,t);var i=e.AsyncStorage,s=e.itemSizeLimit,o=void 0===s?2097152:s,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof Ys))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}if(t instanceof Ws)switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof Ys&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}])}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Rd||(Rd={}));var Fd,qd=function(e){switch(e){case Rd.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Rd.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Hd=Object.assign(Object.assign({},Vo),{scheduledAt:void 0}),Gd=Object.assign(Object.assign({},Ho),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),jd="UnsentMessage",Vd={},zd=function(e){function t(e){var a;return r(this,t),(a=n(this,t,[e]))._mutex=new gd("unsendmessagecache.lock"),Vd[e]=a,a}return c(t,e),i(t,[{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(jd);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 oo?(e.messageParams&&(n.messageParams=jo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},jo(t)),{scheduledAt:t.scheduledAt})))):e instanceof fo?(e.messageParams&&(n.messageParams=Zo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},Zo(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof uo&&e.messageParams&&(n.messageParams=function(e){return pe({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)}),nh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(i=nh.of(this._iid),s=this._deserialize(e),!e.messageParams){a.next=32;break}if(!(s instanceof oo)){a.next=8;break}o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),a.next=32;break;case 8:if(!(s instanceof fo)){a.next=26;break}if(!(u=e.messageParams).fileKey||"string"!=typeof u.fileKey||!Yo(null!==(t=u.fileType)&&void 0!==t?t:"")){a.next=23;break}return a.next=13,this.collection.getBlob(u.fileKey);case 13:if(a.t1=n=a.sent,a.t0=null!==a.t1,!a.t0){a.next=17;break}a.t0=void 0!==n;case 17:if(!a.t0){a.next=21;break}a.t2=n,a.next=22;break;case 21:a.t2=void 0;case 22:u.file=a.t2;case 23:s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(u,s),a.next=32;break;case 26:if(!(s instanceof uo)){a.next=32;break}if(!(c=e.messageParams)||!c.fileInfoList){a.next=32;break}return s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(c,s),a.next=32,Promise.all(s.messageParams.fileInfoList.map((function(e){return E(f,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)||!Yo(null!==(a=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==a?a:"")){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()}}),t,this)})))})));case 32:if(!(s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){a.next=54;break}if(!(s instanceof oo)){a.next=38;break}l=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(l,s),a.next=54;break;case 38:if(!(s instanceof fo)){a.next=54;break}if(!(h=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof h.fileKey||"string"!=typeof h.fileType||!Yo(h.fileType)){a.next=53;break}return a.next=43,this.collection.getBlob(h.fileKey);case 43:if(a.t4=r=a.sent,a.t3=null!==a.t4,!a.t3){a.next=47;break}a.t3=void 0!==r;case 47:if(!a.t3){a.next=51;break}a.t5=r,a.next=52;break;case 51:a.t5=void 0;case 52:h.file=a.t5;case 53:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(h,s);case 54:return a.abrupt("return",s);case 55:case"end":return a.stop()}}),a,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new Pd:n,a=e.order,i=void 0===a?Rd.CHANNEL_LATEST:a,s=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return E(this,void 0,void 0,d().mark((function e(){var n,a,o,l,h,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=qd(i),a={"/where":function(e){return!!(i!==Rd.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(f._deserialize(e))}},t&&(a.channelUrl=t),s&&(a.sendingStatus=s),o={where:a,index:n,backward:u},e.next=8,this.collection.query(o);case 8:return l=e.sent,e.next=11,l.fetch({});case 11:return h=e.sent,e.abrupt("return",Promise.all(h.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Pd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({filter:t,order:Rd.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof fo||e instanceof uo)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return n=this._serialize(e),t.next=10,this.collection.upsertOne(n);case 10:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:n=t.sent;case 5:if(!(n.length>0)){t.next=9;break}return n.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(n);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof fo)){t.next=19;break}if(!e.messageParams){t.next=9;break}if(!(n=e.messageParams).file||!Wo(n.file)){t.next=9;break}return t.next=6,this.collection.saveBlob(n.file,e.reqId);case 6:r=t.sent,n.fileKey=r,n.fileType=Bo.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){t.next=17;break}if(!(a=e.scheduledInfo.scheduledMessageParams).file||!Wo(a.file)){t.next=17;break}return t.next=14,this.collection.saveBlob(a.file,e.reqId);case 14:i=t.sent,a.fileKey=i,a.fileType=Bo.BLOB;case 17:t.next=24;break;case 19:if(!(e instanceof uo)){t.next=24;break}if(!((s=e.messageParams)&&s.fileInfoList&&Array.isArray(s.fileInfoList))){t.next=24;break}return t.next=24,Promise.all(s.fileInfoList.map((function(t,n){return E(o,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!t.file||!Wo(t.file)){r.next=7;break}return r.next=3,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n));case 3:a=r.sent,t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=a,t._uploadedMetaData.fileType=Bo.BLOB;case 7:case"end":return r.stop()}}),r,this)})))})));case 24:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Vd[e]&&!n||(Vd[e]=new t(e)),Vd[e]}}])}(Ya),Bd={},Kd=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Bd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return es.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"_unsentMessageCache",get:function(){return zd.of(this._iid)}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ai(!!e).throw(A.databaseError),e.collection(Zc)}},{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)}),nh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new Pd:i,o=e.order,u=void 0===o?Rd.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,h=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,d().mark((function e(){var r,i,o,c,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r=qd(u),i={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Rd.CHANNEL_LATEST:if(_&&e.createdAt!==n)return!1;if(l){if(g&&e.createdAtn||!g&&e.createdAt>=n)return!1;break;case Rd.NEWEST_CHILD_MESSAGE:if(!h||0===e.parentMessageId||e.parentMessageId!==h)return!1}return!(p&&!e._poll)&&s.match(f._deserialize(e))}},index:r,backward:l},e.next=5,this.collection.query(i);case 5:return o=e.sent,e.next=8,o.fetch({limit:null!=a?a:void 0});case 8:return c=e.sent,e.abrupt("return",Promise.all(c.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}))));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Pd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:Rd.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=30;break}return n.next=3,this.saveBlobs(e);case 3:r=s(e),n.prev=4,r.s();case 6:if((a=r.n()).done){n.next=15;break}if(i=a.value,!(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)){n.next=13;break}return n.next=11,this.get(i.messageId);case 11:(null==(o=n.sent)?void 0:o.threadInfo)&&i.threadInfo._updateFrom(o.threadInfo);case 13:n.next=6;break;case 15:n.next=20;break;case 17:n.prev=17,n.t0=n.catch(4),r.e(n.t0);case 20:return n.prev=20,r.f(),n.finish(20);case 23:return u=e.map((function(e){return c._serialize(e)})),n.next=26,this.collection.upsertMany(u);case 26:return n.next=28,this.upsertChildMessages(e);case 28:return n.next=30,this._unsentMessageCache.upsertChildMessages(e);case 30:case"end":return n.stop()}}),n,this,[[4,17,20,23]])})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!((null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)&&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()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove("".concat(a));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:qd(Rd.CHANNEL_LATEST)});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:qd(Rd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=qd(Rd.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof fo&&e.messageParams)){t.next=7;break}if(!(n=e.messageParams).file||!Wo(n.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(n.file,e.reqId);case 5:r=t.sent,n.fileKey=r;case 7:case"end":return t.stop()}}),t,this)})))})));case 2:case"end":return t.stop()}}),t)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=0,r=this._cacheContext.preference,t.next=4,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return a=t.sent,t.next=7,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return s=t.sent,t.next=13,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return o=t.sent,a&&(n+=JSON.stringify(a).length),i&&(n+=JSON.stringify(i).length),s&&(n+=JSON.stringify(s).length),o&&(n+=JSON.stringify(o).length),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Bd[e]&&!n||(Bd[e]=new t(e)),Bd[e]}}])}(Ya),Qd={},Wd=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Qd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return es.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ai(!!e).throw(A.databaseError),e.collection(Xc)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign({},e.serialize())}},{key:"_deserialize",value:function(e){return nh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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(e);case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new Pd:i,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,h=e.inclusive,f=void 0===h||h;return E(this,void 0,void 0,d().mark((function e(){var r,i,o,c=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(f&&e.createdAtn||!f&&e.createdAt>=n)return!1}return s.match(c._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},e.next=5,this.collection.query(r);case 5:return i=e.sent,e.next=8,i.fetch({limit:null!=a?a:void 0});case 8:return o=e.sent,e.abrupt("return",o.map((function(e){return c._deserialize(e)})));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=4;break}return n=e.map((function(e){return r._serialize(e)})),t.next=4,this.collection.upsertMany(n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"markAsReadByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,messageStatus:eo.SENT,createdAt:{"<":t}}},{set:{messageStatus:eo.READ}});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"markAsReadByMessageIds",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=5;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:eo.SENT}},{set:{messageStatus:eo.READ}});case 3:return r=n.sent,n.abrupt("return",r.length);case 5:return n.abrupt("return",0);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:["channelUrl","-createdAt","-notificationId"]});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:qd(Rd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=["channelUrl","-createdAt","-notificationId"],i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Qd[e]&&!n||(Qd[e]=new t(e)),Qd[e]}}])}(Ya),Yd={},Zd=function(t){function a(t){var i;return r(this,a),(i=n(this,a,[t]))._observers=new Map,i._dispatcherContext=i._dispatcher.on((function(t){return E(i,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,N,A,M,O=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof Os)){n.next=19;break}if(r=t.messages,a=t.source,i=t.isWebSocketEventComing,s=r.filter((function(t){return t instanceof Ws&&t.channelType!==e.ChannelType.OPEN&&t.messageId>0})),o=r.filter((function(t){return t instanceof Ws&&t.channelType!==e.ChannelType.OPEN&&0===t.messageId})),u=r.filter((function(e){return e instanceof co})),!(s.length>0)){n.next=9;break}return n.next=8,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(s);case 2:return e.next=4,this._unsentMessageCache.remove(s.map((function(e){return e instanceof Ys?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e,this)})))}));case 8:i||this._broadcastUpdateEvent(s,a);case 9:if(!(o.length>0)){n.next=13;break}return n.next=12,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.upsert(o);case 2:case"end":return e.stop()}}),e,this)})))}));case 12:i||this._broadcastUpdateEvent(o,a);case 13:if(!(u.length>0)){n.next=17;break}return n.next=16,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._notificationCache.upsert(u);case 2:case"end":return e.stop()}}),e,this)})))}));case 16:i||this._broadcastUpdateEvent(u,a);case 17:n.next=71;break;case 19:if(!(t instanceof Us)){n.next=28;break}return c=t.messageIds,l=t.source,h=t.isWebSocketEventComing,f=c.filter((function(e){return"number"==typeof e})),p=c.filter((function(e){return"string"==typeof e})),n.next=25,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(f.length>0)){e.next=3;break}return e.next=3,this._messageCache.remove(f);case 3:if(!(p.length>0)){e.next=6;break}return e.next=6,this._notificationCache.remove(p);case 6:case"end":return e.stop()}}),e,this)})))}));case 25:h||this._broadcastRemoveEvent(c,l),n.next=71;break;case 28:if(!(t instanceof Ls)){n.next=35;break}return v=t.reqId,_=t.source,n.next=32,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.remove([v]);case 2:case"end":return e.stop()}}),e,this)})))}));case 32:this._broadcastRemoveUnsentEvent(v,_),n.next=71;break;case 35:if(!(t instanceof Ps)){n.next=48;break}if(m=t.polls,g=t.source,!this._cacheContext.localCacheEnabled){n.next=45;break}return y=m.map((function(e){return e.messageId})),n.next=41,Promise.all(y.map((function(e){return O._messageCache.get(e)})));case 41:return k=n.sent.filter((function(e){return e})),k.length>0&&m.forEach((function(e){var t=k.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=45,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(k);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 45:this._broadcastPollChangeLogEvent(m,g),n.next=71;break;case 48:if(!(t instanceof Fs)){n.next=59;break}return b=t.event,C=t.source,n.next=52,this._messageCache.get(b.messageId);case 52:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollUpdateEvent(b))){n.next=56;break}return n.next=56,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 56:this._broadcastPollUpdateEvent(b,C),n.next=71;break;case 59:if(!(t instanceof qs)){n.next=70;break}return x=t.event,S=t.source,n.next=63,this._messageCache.get(x.messageId);case 63:if(!((T=n.sent)&&T.isUserMessage()&&T.poll&&T.poll.applyPollVoteEvent(x))){n.next=67;break}return n.next=67,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([T]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 67:this._broadcastPollVoteEvent(x,S),n.next=71;break;case 70:t instanceof Ds?(I=t.event,N=t.source,I.messageId>0&&this._broadcastReactionUpdateEvent(I,N)):t instanceof Rs&&(A=t.event,M=t.source,this._broadcastThreadUpdateEvent(A,M));case 71:case"end":return n.stop()}}),n,this)})))})),i}return c(a,t),i(a,[{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"_dispatcher",get:function(){return es.of(this._iid).dispatcher}},{key:"_messageCache",get:function(){return Kd.of(this._iid)}},{key:"_unsentMessageCache",get:function(){return zd.of(this._iid)}},{key:"_notificationCache",get:function(){return Wd.of(this._iid)}},{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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=s(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=s(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=s(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=s(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=s(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:"_broadcastReactionUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastThreadUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(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()}}],[{key:"of",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Yd[e]&&!n||(Yd[e]&&(null===(t=Yd[e]._dispatcherContext)||void 0===t||t.close()),Yd[e]=new a(e)),Yd[e]}}])}(Ya),Xd=function(e){function t(e){var a;r(this,t);var i=e.reverse,s=void 0!==i&&i,o=e.limit,u=void 0===o?20:o,c=e.keys,l=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ue),a.params=pe({token:l,limit:u,reverse:s,order:oe.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),a}return c(t,e),i(t)}(je),Jd=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.next,o=a.has_more,u=void 0!==o&&o,c=a.templates;return i.nextToken=s,i.hasMore=u,i.templates=c.map((function(e){return{template:JSON.stringify(e)}})),i}return c(t,e),i(t)}(Ve),$d=function(e){function t(e){var a;r(this,t);var i=e.key;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ue,"/").concat(i),a}return c(t,e),i(t)}(je),eh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).template=JSON.stringify(a),i}return c(t,e),i(t)}(Ve),th={},nh=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.requestQueue,o=n.onlineDetector,u=n.cacheContext;r(this,e),this._iid=t,this._sdkState=a,this._requestQueue=s,this._dispatcher=i,this._cacheContext=u,Kd.of(t),zd.of(t),Zd.of(t),this.fileMessageQueue=new ko(t,{sdkState:a,dispatcher:i,requestQueue:s,onlineDetector:o,cacheContext:u}),th[t]=this}),[{key:"buildMessageFromSerializedData",value:function(t){var n=ri(t);if(n.notificationId)return new co(this._iid,co.payloadify(n));switch(n.messageType){case e.MessageType.USER:return new oo(this._iid,oo.payloadify(n));case e.MessageType.FILE:return uo._isMultipleFilesMessageSerializedData(n)?new uo(this._iid,uo.payloadify(n)):new fo(this._iid,fo.payloadify(n));case e.MessageType.ADMIN:return new Js(this._iid,Js.payloadify(n))}throw A.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return pe(ve({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 pe(ve({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){var n=this;return pe({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.map((function(e){return new po(n._iid,e)}))})}},{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=ri(e);return new ps(this._iid,ps.payloadify(t))}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Io(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(No),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Do(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Ro),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessagesByMessageId",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Ao(Object.assign(Object.assign({channelType:n,channelUrl:t,token:String(r)},wo),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Mo),c=u.messages,this._dispatcher.dispatch(new Os({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Ao(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},wo),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Mo),c=u.messages,this._dispatcher.dispatch(new Os({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0;return E(this,void 0,void 0,d().mark((function e(){var u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new Ao(Object.assign(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},wo),a),{checkingHasNext:s,checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.as(Mo),h=l.messages,f=l.isContinuousMessages,p=l.hasNext,this._dispatcher.dispatch(new Os({messages:h,source:i})),e.abrupt("return",{messages:h,isContinuousMessages:f,hasNext:p});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_THREADED_MESSAGE;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=new Ao(Object.assign(Object.assign(Object.assign({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:n},Zs),r),{replyType:e.ReplyType.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),i.next=3,this._requestQueue.send(s);case 3:return o=i.sent,u=o.as(Mo),c=u.messages,(l=c.slice(1)).forEach((function(e){e.parentMessage=t})),this._dispatcher.dispatch(new Os({messages:l,source:a})),i.abrupt("return",{parentMessage:c[0],threadedMessages:l});case 9:case"end":return i.stop()}}),i,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new Xd(Object.assign({token:e},t)),n.next=3,this._requestQueue.send(r);case 3:return a=n.sent,i=a.as(Jd),s=i.hasMore,o=i.nextToken,u=i.templates,n.abrupt("return",{hasMore:s,token:o,templates:u});case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new $d({key:e}),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(eh),i=a.template,t.abrupt("return",{template:i});case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageChangelogs",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Oo(pe(ve(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null},So),a)))),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Uo),c=u.updatedMessages,l=u.deletedMessagesInfo,h=u.hasMore,f=u.nextToken,p=l.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new Os({messages:c,source:i})),p.length>0&&this._dispatcher.dispatch(new Us({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:c,deletedMessageIds:p,hasMore:h,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return th[e]}}])}(),rh=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e])).targetMessageId=0;var s=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return s&&D("object",s)&&D("number",o)&&D("string",u)&&D("string",c)&&(i.threadInfo=new is(e,s),i.targetMessageId=o,i.channelUrl=u,i.channelType=c),i}return c(t,e),i(t)}(Ya),ah={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},ih=function(t){return D("string",t.channelUrl)&&R(e.ChannelType,t.channelType)&&D("number",t.messageId)&&D("boolean",t.includeReactions,!0)&&D("boolean",t.includeMetaArray,!0)&&D("boolean",t.includeParentMessageInfo,!0)&&D("boolean",t.includeThreadInfo,!0)},sh=function(e){function t(e){var a,i=e.channelCustomType,s=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,d=e.order,h=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(xe,"/messages"),a.params={custom_type:i,query:s,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:h,message_ts_to:f,sort_field:d,advanced_query:p,target_fields:v,after:_},a}return c(t,e),i(t)}(je),oh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).messages=a.results.map((function(t){return ho(e,t)})),i.hasNext=a.has_next,i.nextToken=a.end_cursor,i.totalCount=a.total_count,i}return c(t,e),i(t)}(Ve);e.MessageSearchOrder=void 0,(Fd=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",Fd.TIMESTAMP="ts";var uh,ch,lh,dh=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;return r(this,a),(s=n(this,a,[t,i])).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=i.keyword,s.reverse=null!==(o=i.reverse)&&void 0!==o&&o,s.exactMatch=null!==(u=i.exactMatch)&&void 0!==u&&u,s.channelUrl=null!==(c=i.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=i.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(d=i.messageTimestampFrom)&&void 0!==d?d:null,s.messageTimestampTo=null!==(h=i.messageTimestampTo)&&void 0!==h?h:null,s.order=null!==(f=i.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=i.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=i.targetFields)&&void 0!==v?v:null,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.keyword)&&this.keyword.length>0&&D("boolean",this.reverse)&&D("boolean",this.exactMatch)&&D("string",this.channelUrl)&&D("string",this.channelCustomType)&&(D("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(D("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&R(e.MessageSearchOrder,this.order)&&D("boolean",this.advancedQuery)&&P("string",this.targetFields,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new sh(ve(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(oh),s=i.messages,o=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,e.abrupt("return",s);case 15:return e.abrupt("return",[]);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}])}(uu),hh=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/parent_thread_message"),a.params=pe(ve({limit:o,token:u})),a}return c(t,e),i(t)}(je),fh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).token=a.next,i.messages=a.messages.map((function(t){return ho(e,t)})),i}return c(t,e),i(t)}(Ve),ph=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s]))._edge="",o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new hh({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(fh),s=i.messages,o=i.token,this._edge=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(cu),vh={channelUrl:"",scheduledMessageId:0},_h=function(e){return D("string",e.channelUrl)&&""!==e.channelUrl&&D("number",e.scheduledMessageId)&&e.scheduledMessageId>0},mh={reverse:!1,limit:20},gh=function(e){return D("boolean",e.reverse,!0)&&D("number",e.limit,!0)&&P("string",e.keys,!0)},yh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="message",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new nh(e,{sdkState:r,dispatcher:a,requestQueue:s,onlineDetector:u,cacheContext:c})}},{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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},ah),e),ai(ih(n)).throw(A.invalidParameters),t.next=4,this._manager.getMessage(n);case 4:if(!((r=t.sent)instanceof Ws||r instanceof co||null===r)){t.next=7;break}return t.abrupt("return",r);case 7:throw"Unknown message type is given.";case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},vh),e),ai(_h(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},mh),t),ai(D("string",e,!0)&&gh(r)).throw(A.invalidParameters),n.abrupt("return",this._manager.getMessageTemplatesByToken(e,r));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getMessageTemplate(e));case 2:case"end":return t.stop()}}),t,this)})))}}])}(ts),Eh=i((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})),kh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="poll",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new Wc(e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c})}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Gc),e),ai(jc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.create(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Bc),e),ai(Kc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.get(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Vc),e),ai(zc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getOption(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}])}(ts),bh={profileImage:void 0,profileUrl:void 0,nickname:void 0},Ch=function(e){return H(e.profileImage,!0)&&D("string",e.profileUrl,!0)&&D("string",e.nickname,!0)};e.GroupChannelListOrder=void 0,(uh=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",uh.CHRONOLOGICAL="chronological",uh.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",uh.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(ch=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",ch.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",ch.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(lh=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",lh.SCHEDULED_AT="scheduled_at";var wh,xh=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"]}},Sh=function(t){return{v2:function(){return E(void 0,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.commitSchema([{collectionName:Yc,keyName:"url",index:[xh(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),xh(e.GroupChannelListOrder.CHRONOLOGICAL),xh(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Zc,keyName:"messageId",index:[qd(Rd.CHANNEL_LATEST),qd(Rd.NEWEST_CHILD_MESSAGE)]},{collectionName:jd,keyName:"reqId",index:[qd(Rd.CHANNEL_LATEST),qd(Rd.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))},v3:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:"FeedChannel",keyName:"url",index:[["-lastMessageUpdatedAt","-createdAt","syncIndex"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))},v4:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:Xc,keyName:"notificationId",index:[["channelUrl","-createdAt","-notificationId"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}},Th=function(t){return function(n,r){return E(void 0,void 0,void 0,d().mark((function a(){var i,s,o,u,c;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=n,a.next=1===a.t0||2===a.t0||3===a.t0||4===a.t0?3:5===a.t0?5:6===a.t0?9:26;break;case 3:return r(),a.abrupt("break",27);case 5:return a.next=7,t.reset();case 7:return r(),a.abrupt("break",27);case 9:return a.prev=9,i=Sh(t),s=i.v2,o=i.v3,u=i.v4,a.next=13,s();case 13:return a.next=15,o();case 15:return a.next=17,u();case 17:return c=t.collection(Zc),a.next=20,c.removeIf({where:{channelType:e.ChannelType.OPEN}});case 20:a.next=24;break;case 22:a.prev=22,a.t1=a.catch(9);case 24:return r(),a.abrupt("break",27);case 26:r();case 27:case"end":return a.stop()}}),a,null,[[9,22]])})))}},Ih=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Nh=function(e){function t(e){var a,i=e.getVisibilityState,s=void 0===i?Ih:i,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,d=e.pauseCheckDelay,h=void 0===d?3e4:d;return r(this,t),(a=n(this,t))._pauseCheckDelay=3e4,a._currentState="visible",a._getVisibilityState=s,a._pauseCheckDelay=h,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(a),a}return c(t,e),i(t,[{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})}}])}(de),Ah=function(){return i((function e(t){var n=this,a=t.logger,i=t.connectionDelegate,s=void 0===i?null:i;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,s&&(this.connectionDelegate=s)}),[{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,d().mark((function e(){return d().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:_e.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}])}(),Mh=function(e){function t(e){var a,i=e.message;return r(this,t),(a=n(this,t)).message=i,a}return c(t,e),i(t)}(fe),Oh={},Uh=function(){return i((function e(t,n){var a=this,i=n.localCacheEnabled,s=n.enableAutoResend,o=n.dispatcher,u=n.sdkState,c=n.logger;r(this,e),this._iid=t,Oh[t]=this,this._localCacheEnabled=i,this._enableAutoResend=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=o,this._logger=c,this._sdkState=u,this._localCacheEnabled&&o.on((function(e){if(e instanceof La)switch(e.stateType){case Aa.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case Aa.INTERNAL_DISCONNECTED:case Aa.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}),[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._enableAutoResend){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this._fetchAllCachedPendingMessages();case 4:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)0===(i=a.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=e.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new Os({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){r.e(e)}finally{r.f()}case 7:case"end":return t.stop()}}),t,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)i=a.value,this._enableAutoResend&&i.errorCode&&q(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,this._enableAutoResend&&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 Os({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return t.stop()}}),t,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&this._enableAutoResend&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!q(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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=zd.of(this._iid),(r=new Pd).replyType=e.ReplyType.ALL,t.next=5,n.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0,filter:r});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&this._enableAutoResend&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),t=this._autoResendQueue[0],this._dispatcher.dispatch(new Mh({message:t})),this._logger.debug("processing auto-resend for message request id: ",t.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Oh[e]}}])}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(wh||(wh={}));var Dh,Rh=function(){return i((function e(t){r(this,e),this.category=t.cat,this.data=t.data}),null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new si(e,r),blockee:new si(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 si(e,t)})):[]}}}])}(),Lh=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Ph=function(e){function t(e,a){var i,s=a.userId;return r(this,t),(i=n(this,t))._iid=e,i.userId=s,i}return c(t,e),i(t)}(fe),Fh=function(e){function t(){return r(this,t),n(this,t)}return c(t,e),i(t)}(fe),qh=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"USEV",i])).event=new Rh(i),s}return c(t,e),i(t)}(Ke),Hh=function(e){function t(e){var a,i=e.userId,s=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i)),a.params=pe(ve({nickname:s,profile_url:o,profile_file:u,preferred_languages:c})),a}return c(t,e),i(t)}(je),Gh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).user=new si(e,Object.assign({},a)),i}return c(t,e),i(t)}(Ve),jh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a.params=pe({apns_device_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(je),Vh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a.params=pe({gcm_reg_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(je),zh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),Bh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),Kh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a}return c(t,e),i(t)}(je),Qh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a}return c(t,e),i(t)}(je),Wh=function(e){function t(e){var a,i=e.userId,s=e.type,o=e.token,u=e.ts;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/").concat(encodeURIComponent(s),"/device_tokens"),a.params={created_ts:u,token:o},a}return c(t,e),i(t)}(je),Yh=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).pushTokens={type:i.type?e.PushTokenType[i.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:i.device_tokens,hasMore:i.has_more,token:i.token},s}return c(a,t),i(a)}(Ve),Zh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a}return c(t,e),i(t)}(je),Xh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(Ve),Jh=function(e){function t(e){var a,i=e.userId,s=e.willAutoAccept;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a.params={auto_accept:s},a}return c(t,e),i(t)}(je),$h=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(Ve),ef=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(je),tf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(Ve),nf=function(e){function t(e){var a,i=e.userId,s=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,d=e.timezone;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={do_not_disturb:s,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:d},a}return c(t,e),i(t)}(je),rf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(Ve),af=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(je),sf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(Ve),of=function(e){function t(e){var a,i=e.userId,s=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={snooze_enabled:s,snooze_start_ts:o,snooze_end_ts:u},a}return c(t,e),i(t)}(je),uf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(Ve),cf=function(e){function t(e){var a,i=e.userId,s=e.blockedUserId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block"),a.params={target_id:s},a}return c(t,e),i(t)}(je),lf=function(e){function t(e){var a,i=e.userId,s=e.unblockedUserId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),df=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(je),hf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(Ve),ff=function(e){function t(e){var a,i=e.userId,s=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={push_trigger_option:s},a}return c(t,e),i(t)}(je),pf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(Ve),vf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a}return c(t,e),i(t)}(je),_f=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(Ve),mf=function(e){function t(e){var a,i=e.userId,s=e.templateName;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a.params={name:s},a}return c(t,e),i(t)}(je),gf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(Ve),yf=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends/changelogs"),a.params={token:s},a}return c(t,e),i(t)}(je),Ef=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).changelogs={addedUsers:a.added.map((function(t){return new si(e,t)})),updatedUsers:a.updated.map((function(t){return new si(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},i}return c(t,e),i(t)}(Ve),kf=function(e){function t(e){var a,i=e.userId,s=e.discoveries;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discoveries:s.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return c(t,e),i(t)}(je),bf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).friendDiscoveryRequestId=a.friend_discovery_request_id,i}return c(t,e),i(t)}(Ve),Cf=function(e){function t(e){var a,i=e.userId,s=e.discoveryKeys;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discovery_keys:s},a}return c(t,e),i(t)}(je),wf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(je),xf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new si(e,t)})),i}return c(t,e),i(t)}(Ve),Sf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(je),Tf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={},a}return c(t,e),i(t)}(je),If=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).allowFriendDiscovery=a.allow_friend_discovery,i}return c(t,e),i(t)}(Ve),Nf=function(e){function t(e){var a,i=e.userId,s=e.allowFriendDiscovery;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={allow_friend_discovery:s},a}return c(t,e),i(t)}(je),Af=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path=Ie,e}return c(t,e),i(t)}(je),Mf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiContainer=new gl(a),i}return c(t,e),i(t)}(Ve),Of=function(e){function t(e){var a,i=e.categoryId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ie,"/").concat(i),a}return c(t,e),i(t)}(je),Uf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiCategory=new ml(a),i}return c(t,e),i(t)}(Ve),Df=function(e){function t(e){var a,i=e.key;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Te,"/").concat(i),a}return c(t,e),i(t)}(je),Rf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emoji=new _l(a),i}return c(t,e),i(t)}(Ve),Lf=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path="".concat(Me),e}return c(t,e),i(t)}(je),Pf=function(e){function t(e,a){var i,s;r(this,t);var o=null!=a?a:{};return(i=n(this,t,[e,a])).uikitConfiguration={string:JSON.stringify(o),json:o},i.updatedAt=null!==(s=null==a?void 0:a.updated_at)&&void 0!==s?s:0,i}return c(t,e),i(t)}(Ve);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(Dh||(Dh={}));var Ff,qf=function(e){function t(e){var a,i=e.deviceToken,s=e.pushTrackingId,o=e.messageId,u=e.allowedPushNotification,c=e.channelKey,l=e.templateKey,d=e.eventType,h=e.notificationEventDeadline;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=De,a.params=pe({device_token:i,push_tracking_id:s,message_id:o,allowed_push_notification:u,channel_key:c,template_key:l,event_type:d,notification_event_deadline:h}),a}return c(t,e),i(t)}(je);var Hf,Gf=function(){function t(e,n,a){var i=this;r(this,t),this._storeInitialized=!1,this._iid=e,this.options=n;var s=es.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,l=s.sessionManager,h=s.requestQueue,f=s.logger,p=s.userEventHandlers,v=s.appStateToggleEnabled;this._onlineDetector=new Ah({logger:f,connectionDelegate:{reconnect:function(){return E(i,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=es.of(e),r=n.sdkState,a=n.connectionManager,(i=n.sessionManager).session.hasSession){t.next=14;break}return t.prev=2,t.next=5,a.connect(i.session.authToken);case 5:t.next=12;break;case 7:if(t.prev=7,t.t0=t.catch(2),!N(t.t0)){t.next=11;break}throw t.t0;case 11:f.debug("connect failed by reconnect event = ",t.t0);case 12:t.next=25;break;case 14:if("foreground"!==r.appState){t.next=25;break}return t.prev=15,t.next=18,a.resetAndReconnect();case 18:t.next=25;break;case 20:if(t.prev=20,t.t1=t.catch(15),!N(t.t1)){t.next=24;break}throw t.t1;case 24:f.debug("resetAndReconnect failed by reconnect event = ",t.t1);case 25:c.dispatch(new Lh);case 26:case"end":return t.stop()}}),t,null,[[2,7],[15,20]])})))},disconnect:function(){fi((function(){return E(i,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(e),r=n.connectionManager,t.next=3,r.disconnect();case 3:case"end":return t.stop()}}),t)})))}))}}});var _=new Uh(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,dispatcher:c,sdkState:o,logger:f});a.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:l,requestQueue:h,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new Nh({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()})),c.on((function(t){var n;if(t instanceof La){if(t.stateType===Aa.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof Ke){if("USEV"===t.code){var r=t.as(qh).event;if(r.category===wh.FRIEND_DISCOVERED){var a=Rh.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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(t instanceof Oa){var s=es.of(i._iid).subscribedUnreadMessageCount,c=!1,l=t.ts;"number"==typeof l&&l>s.ts&&(s.all!==t.all&&(c=!0),s.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){s.customTypes[e]!==t.customTypes[e]&&(c=!0),s.customTypes[e]=t.customTypes[e]})),c=c&&s.ts>0,s.ts=l),c&&hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:s.all,feedChannelCount:s.feed,customTypeUnreadCount:s.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else t instanceof oi?(u.preference.set(i._getUserProfileCacheKey(o.userId),ui.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(Ga(i.appId),{value:!0})):t instanceof Be&&t.error&&t.error.isSessionInvalidatedError&&(f.debug("session revoked."),i._internalDisconnect(t.error))}))}return i(t,[{key:"appId",get:function(){return es.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=es.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=es.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!es.of(this._iid).debugMode}},{key:"logLevel",get:function(){return es.of(this._iid).logger.level},set:function(e){es.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return es.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=es.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return es.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=es.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=es.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=es.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:"_getNestDBVersion",value:function(){return 7}},{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:"_internalDisconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.connectionManager,a=n.sdkState,i=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),t.next=6,r.logout(e);case 6:return t.next=8,this.clearCachedData();case 8:a.appState="foreground";case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getMemoryStoreForDebugging",value:function(){var e=es.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Sd?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=es.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)}},{key:"addSendbirdExtensions",value:function(e,t,n){var r=es.of(this._iid),a=r.logger,i=r.sdkState,s=new RegExp("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");if(0===e.length)return a.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!s.test(e.version)})))return a.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(var o=0,u=Object.entries(n);o2&&void 0!==arguments[2]?arguments[2]:{};return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(ai(D("string",e)&&D("string",t,!0)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,s=a.cacheContext,o=a.connectionManager,u=n.errorForOtherUser,!i.userId||i.userId===e){r.next=10;break}if(u){r.next=9;break}return r.next=7,o.logout();case 7:r.next=10;break;case 9:throw u;case 10:return r.prev=10,r.next=13,this.initializeCache(e);case 13:c=es.of(this._iid),c.dispatcher.dispatch(new Fh),r.next=22;break;case 17:r.prev=17,r.t0=r.catch(10),l=es.of(this._iid),h=l.logger,s.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 22:case"end":return r.stop()}}),r,this,[[10,17]])})))}},{key:"authenticateFeed",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.authenticate(e,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=es.of(this._iid),i=a.sessionManager,s=a.connectionManager,r.next=3,this._ready(e,t,{errorForOtherUser:s.isConnected?A.alreadyConnectedAsAnotherUser:void 0});case 3:if(null===(n=i.session.services)||void 0===n?void 0:n.includes(K.CHAT)){r.next=7;break}return t||i.handler||(o=new El,this.setSessionHandler(o)),r.next=7,i.authenticate(e,t);case 7:return r.abrupt("return",this.currentUser);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"connect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._ready(e,t);case 2:return n.prev=2,r=es.of(this._iid),a=r.connectionManager,n.next=6,a.connect(t);case 6:return n.prev=6,this._onlineDetector.start(),this._appStateChangeDetector.start(),n.finish(6);case 10:return n.abrupt("return",this.currentUser);case 11:case"end":return n.stop()}}),n,this,[[2,,6,10]])})))}},{key:"reconnect",value:function(){var e=es.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._internalDisconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.connectionManager,r=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),e.next=6,n.disconnectWebSocket(!0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=es.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().catch((function(e){r.debug("setBackgroundState error = ",e)})))}},{key:"setForegroundState",value:function(){var e=es.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,a=e.logger;"background"===n.appState&&(n.appState="foreground",a.debug("going foreground state"),t.resetAndReconnect().catch((function(e){a.debug("setForgroundState error = ",e)})),r.dispatch(new Lh))}},{key:"setSessionHandler",value:function(e){ai(e instanceof El).throw(A.invalidParameters),es.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){ai(D("string",e)&&t instanceof kl).throw(A.invalidParameters),es.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){es.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){es.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){ai(D("string",e)&&t instanceof yl).throw(A.invalidParameters),es.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){es.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){es.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new wl(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Tl(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Al(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new dh(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new el(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new rl(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=ri(e);return new si(this._iid,si.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Object.assign(Object.assign({},bh),e),ai(Ch(n)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Hh(Object.assign({userId:a.userId},n)),t.next=7,i.send(s);case 7:return o=t.sent,u=o.as(Gh),c=u.user,this.currentUser&&(n.nickname&&(this.currentUser.nickname=c.nickname),(n.profileUrl||n.profileImage)&&(this.currentUser.plainProfileUrl=c.profileUrl)),t.abrupt("return",c);case 13:throw A.connectionRequired;case 14:case"end":return t.stop()}}),t,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ai(P("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Hh({userId:r.userId,preferredLanguages:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Gh),u=o.user,this.currentUser&&(this.currentUser.preferredLanguages=u.preferredLanguages),t.abrupt("return",u);case 12:throw A.connectionRequired;case 13:case"end":return t.stop()}}),t,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ai(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ai(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.ANDROID,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=es.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.FCM,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new Vh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,fi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.FCM,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._fcmPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._fcmPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=es.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Bh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,fi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.FCM,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=es.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Qh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,fi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.FCM),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ai(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ai(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.IOS,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=es.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.APNS,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new jh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,fi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.APNS,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._apnsPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._apnsPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=es.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new zh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,fi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.APNS,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._apnsPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._apnsPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=es.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Kh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,fi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.APNS),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markPushNotificationAsDelivered",value:function(e){var t,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k,b;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=es.of(this._iid),i=a.logger,s=a.sessionManager,o=a.requestQueue,u=a.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=Dh.DELIVERED,l=u.parseData(e),h=l.pushTrackingId,f=l.sessionTopics,p=l.sessionKey,v=l.messageId,_=l.channelKey,m=l.templateKey,g=l.notificationEventDeadline,p){r.next=7;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 7:if(f.includes(ji.PUSH_ACKNOWLEDGEMENT)){r.next=10;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 10:if(!u.isAcked(h,c)){r.next=13;break}return i.info("already delivered push notification:",h),r.abrupt("return");case 13:return y=Boolean(_),E=n&&y,k=null===(t=s.deviceTokens[0])||void 0===t?void 0:t.token,b=new qf({deviceToken:null!=k?k:"",pushTrackingId:h,eventType:c,messageId:v,channelKey:_,templateKey:m,notificationEventDeadline:g,allowedPushNotification:E}),p&&(b.headers["Session-Key"]=p),r.prev=18,r.next=21,o.send(b);case 21:u.markAsAcked(h,c),r.next=28;break;case 24:throw r.prev=24,r.t0=r.catch(18),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(h,". error: ").concat(r.t0)),r.t0;case 28:case"end":return r.stop()}}),r,this,[[18,24]])})))}},{key:"markPushNotificationAsClicked",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=es.of(this._iid),a=r.logger,i=r.sessionManager,s=r.requestQueue,o=r.pushNotificationAckManager,a.debug("markPushNotificationAsClicked:",e),u=Dh.CLICKED,c=o.parseData(e),l=c.pushTrackingId,h=c.sessionTopics,f=c.sessionKey,p=c.messageId,v=c.channelKey,_=c.templateKey,m=c.notificationEventDeadline,f){n.next=7;break}throw a.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 7:if(h.includes(ji.PUSH_ACKNOWLEDGEMENT)){n.next=10;break}throw a.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 10:if(!o.isAcked(l,u)){n.next=13;break}return a.info("already clicked push notification:",l),n.abrupt("return");case 13:return g=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,y=new qf({deviceToken:null!=g?g:"",pushTrackingId:l,eventType:u,messageId:p,channelKey:v,templateKey:_,notificationEventDeadline:m}),f&&(y.headers["Session-Key"]=f),n.prev=16,n.next=19,s.send(y);case 19:o.markAsAcked(l,u),n.next=26;break;case 22:throw n.prev=22,n.t0=n.catch(16),a.debug("failed to mark push notification as clicked. push tracking id: ".concat(l,". error: ").concat(n.t0)),n.t0;case 26:case"end":return n.stop()}}),n,this,[[16,22]])})))}},{key:"getChannelInvitationPreference",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Zh({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Xh),o=s.autoAccept,e.abrupt("return",{autoAccept:o});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("boolean",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Jh({userId:r.userId,willAutoAccept:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as($h),u=o.autoAccept,t.abrupt("return",{autoAccept:u});case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getDoNotDisturb",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ef({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(tf),o=s.preference,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return ai(D("boolean",e)&&D("number",t)&&D("number",n)&&D("number",r)&&D("number",a)&&D("string",i)).throw(A.invalidParameters),o=es.of(this._iid),u=o.sdkState,c=o.requestQueue,l=new nf({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:a,timezone:i}),s.next=5,c.send(l);case 5:return h=s.sent,f=h.as(rf),p=f.preference,s.abrupt("return",p);case 8:case"end":return s.stop()}}),s,this)})))}},{key:"getSnoozePeriod",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new af({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(sf),o=s.snoozePeriod,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("boolean",e)&&D("number",t)&&D("number",n)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new of({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),r.next=5,s.send(o);case 5:return u=r.sent,c=u.as(uf),l=c.snoozePeriod,r.abrupt("return",l);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"getMyPushTokensByToken",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p,v,_;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",t)&&R(e.PushTokenType,n)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,o=a.requestQueue,u=a.sessionManager,c=new Wh({userId:i.userId,type:n,token:t}),r.next=5,o.send(c);case 5:l=r.sent,h=l.as(Yh),f=h.pushTokens,p=s(f.deviceTokens);try{for(p.s();!(v=p.n()).done;)_=v.value,u.setDeviceToken(f.type,_)}catch(e){p.e(e)}finally{p.f()}return r.next=11,u.saveDeviceToken();case 11:return r.abrupt("return",f);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"getPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new df({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(hf).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new ff({userId:a.userId,pushTriggerOption:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(pf).pushTriggerOption);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"getPushTemplate",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new vf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(_f).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.PushTemplate,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new mf({userId:a.userId,templateName:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(gf).name);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"blockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(e instanceof si||D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new cf({userId:r.userId,blockedUserId:e instanceof si?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(e instanceof si||D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new lf({userId:r.userId,unblockedUserId:e instanceof si?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new yf({userId:r.userId,token:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(Ef),u=o.changelogs,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Tf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(If),o=s.allowFriendDiscovery,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("boolean",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Nf({userId:r.userId,allowFriendDiscovery:e}),t.next=5,a.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new kf({userId:r.userId,discoveries:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(bf),u=o.friendDiscoveryRequestId,t.abrupt("return",u);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Cf({userId:r.userId,discoveryKeys:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"addFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new wf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(xf),u=o.users,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Sf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getAllEmoji",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Af,e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Mf),s=i.emojiContainer,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Of({categoryId:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Uf),o=s.emojiCategory,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getEmoji",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Df({key:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Rf),o=s.emoji,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getUIKitConfiguration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),ai(t.hasExtension("sb_uikit")).throw(A.notSupportedError),n=t.requestQueue,r=new Lf,e.next=6,n.send(r);case 6:return a=e.sent,i=a.as(Pf),s=i.uikitConfiguration,e.abrupt("return",s);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(n){var r=n.appId,a=n.appVersion,i=n.modules,s=void 0===i?[]:i,o=n.options,u=void 0===o?new j:o,c=n.debugMode,l=void 0!==c&&c,d=n.customApiHost,h=n.customWebSocketHost,f=n.newInstance,p=void 0!==f&&f,_=n.logLevel,m=n.localCacheEnabled,g=void 0!==m&&m,y=n.localCacheConfig,E=void 0===y?new W:y,k=n.localCacheEncryption,b=n.useAsyncStorageStore,C=void 0===b?null:b,w=n.useMMKVStorageStore,x=void 0===w?null:w,S=n.appStateToggleEnabled,T=void 0===S||S;if(!Ff||p){var I="su-".concat(ce()),N=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},A=new Ld;A.level=null!=_?_:e.LogLevel.WARN;var M=new Sd({encryption:N});l||(at()?x?M=new Md({MMKV:x,encryption:N}):C&&(M=new Ad({AsyncStorage:C,encryption:N}),A.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):M=new Nd({encryption:N})),new es(I,{appId:r,appVersion:a,options:u,apiHost:null!=d?d:"https://api-".concat(r,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(r,".sendbird.com"),store:M,encryption:N,logger:A,localCacheEnabled:g,localCacheConfig:E,debugMode:l,appStateToggleEnabled:T});var O=[new yh,new kh],U=new t(I,u,[].concat(v(s),O));return Ff||(Ff=U),U}return Ff}},{key:"instance",get:function(){return Ff}},{key:"version",get:function(){return b}}])}();e.MemberState=void 0,(Hf=e.MemberState||(e.MemberState={})).NONE="none",Hf.JOINED="joined",Hf.INVITED="invited",Hf.LEFT="left";var jf,Vf,zf,Bf,Kf,Qf,Wf,Yf,Zf=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).state=null,s.role=null,s.isMuted=!1,s.isBlockedByMe=!1,s.isBlockingMe=!1,s.state=R(e.MemberState,i.state)?i.state:null,s.role=R(e.Role,i.role)?i.role:null,"boolean"==typeof i.is_muted&&(s.isMuted=i.is_muted),"boolean"==typeof i.is_blocked_by_me&&(s.isBlockedByMe=i.is_blocked_by_me),"boolean"==typeof i.is_blocking_me&&(s.isBlockingMe=i.is_blocking_me),s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}])}(Po),Xf=function(t){function a(t,i){var s,o,u;return r(this,a),(s=n(this,a,[t])).channelUrl=null!==(o=i.channel_url)&&void 0!==o?o:"",s.channelType=null!==(u=i.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,s.member=new si(s._iid,i.user),s.deliveryAt=i.ts,s}return c(a,t),i(a)}(Ya);e.PublicChannelFilter=void 0,(jf=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",jf.PUBLIC="public",jf.PRIVATE="private",e.MyMemberStateFilter=void 0,(Vf=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",Vf.JOINED="joined_only",Vf.INVITED="invited_only",Vf.INVITED_BY_FRIEND="invited_by_friend",Vf.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(zf=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",zf.SUPER="super",zf.NON_SUPER="nonsuper",zf.BROADCAST_ONLY="broadcast_only",zf.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(Bf=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",Bf.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(Kf=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",Kf.UNHIDDEN="unhidden_only",Kf.HIDDEN="hidden_only",Kf.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Kf.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(Qf=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",Qf.OPERATOR="operator",Qf.NONOPERATOR="nonoperator",e.QueryType=void 0,(Wf=e.QueryType||(e.QueryType={})).AND="AND",Wf.OR="OR",e.GroupChannelSearchField=void 0,(Yf=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",Yf.CHANNEL_NAME="channel_name";var Jf,$f=function(){function t(n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m,g;r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(a=null==n?void 0:n.includeEmpty)&&void 0!==a&&a,this.nicknameContainsFilter=null!==(i=null==n?void 0:n.nicknameContainsFilter)&&void 0!==i?i:null,this.nicknameStartsWithFilter=null!==(s=null==n?void 0:n.nicknameStartsWithFilter)&&void 0!==s?s:null,this.nicknameExactMatchFilter=null!==(o=null==n?void 0:n.nicknameExactMatchFilter)&&void 0!==o?o:null,this.channelNameContainsFilter=null!==(u=null==n?void 0:n.channelNameContainsFilter)&&void 0!==u?u:"",this.myMemberStateFilter=null!==(c=null==n?void 0:n.myMemberStateFilter)&&void 0!==c?c:e.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(l=null==n?void 0:n.customTypesFilter)&&void 0!==l?l:null,this.channelUrlsFilter=null!==(d=null==n?void 0:n.channelUrlsFilter)&&void 0!==d?d:null,this.superChannelFilter=null!==(h=null==n?void 0:n.superChannelFilter)&&void 0!==h?h:e.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(f=null==n?void 0:n.publicChannelFilter)&&void 0!==f?f:e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(p=null==n?void 0:n.customTypeStartsWithFilter)&&void 0!==p?p:null,this.unreadChannelFilter=null!==(v=null==n?void 0:n.unreadChannelFilter)&&void 0!==v?v:e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==n?void 0:n.hiddenChannelFilter)&&void 0!==_?_:e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(m=null==n?void 0:n.includeFrozen)||void 0===m||m,(null==n?void 0:n.createdAfter)&&(this.createdAfter=n.createdAfter),(null==n?void 0:n.createdBefore)&&(this.createdBefore=n.createdBefore),this.includeMetaData=null===(g=null==n?void 0:n.includeMetaData)||void 0===g||g}return i(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,i=r.fields;if(a&&i&&i.length>0&&!i.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var s=this._userIdsFilter,o=s.userIds,u=s.includeMode,c=s.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=v(e).sort(),r=v(t).sort(),a=0;a0&&!this.customTypesFilter.includes("*")&&!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 d=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(d)})))return!1}if(this.nicknameStartsWithFilter){var h=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(h)})))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.ALL:if("none"===t.myMemberState)return!1;break;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!(this.createdAfter&&t.createdAtthis.createdBefore)}}])}(),ep=function(t){function a(e,t){var i,s=t.sdkState,o=t.cacheContext;return r(this,a),(i=n(this,a,[e]))._channels=new Map,i._sdkState=s,i._cacheContext=o,i}return c(a,t),i(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ai(!!e).throw(A.databaseError),e.collection(Yc)}},{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 Cv.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return v(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>n||s&&t.createdAtn||s&&t.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)n._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});n._update(e),r.push(n)}else s._channels.set(e.url,e),r.push(e)})),!this.localCacheEnabled){n.next=7;break}for(a=[],i=0;i0)){r.next=76;break}return r.next=76,this.upsert(a);case 76:case"end":return r.stop()}}),r,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!0);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"unblock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!1);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"markAsRead",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v(this._channels.keys());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=s(t),n.prev=2,a.s();case 4:if((i=a.n()).done){n.next=12;break}return o=i.value,n.next=8,this.get(o);case 8:(null==(u=n.sent)?void 0:u._updateUnreadMemberState(this._sdkState.userId,e))&&(u._updateUnreadCount(0,0),r.push(u));case 10:n.next=4;break;case 12:n.next=17;break;case 14:n.prev=14,n.t0=n.catch(2),a.e(n.t0);case 17:return n.prev=17,a.f(),n.finish(17);case 20:if(!(r.length>0)){n.next=23;break}return n.next=23,this.upsert(r);case 23:case"end":return n.stop()}}),n,this,[[2,14,17,20]])})))}}])}(Ya);!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"}(Jf||(Jf={}));var tp,np=function(){return i((function e(t){var n;r(this,e),this.channelUrl=t.channel_url,this.channelType=t.channel_type,this.category=t.cat,this.data=null!==(n=t.data)&&void 0!==n?n:{},this.ts=t.ts}),[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}])}(),rp={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},ap=function(e){return P("string",e.invitedUserIds,!0)&&D("string",e.channelUrl,!0)&&D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isSuper,!0)&&D("boolean",e.isBroadcast,!0)&&D("boolean",e.isExclusive,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isStrict,!0)&&D("boolean",e.isDiscoverable,!0)&&D("boolean",e.isEphemeral,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},ip={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},sp=function(e){return P("string",e.customTypes,!0)&&D("boolean",e.includeEmpty,!0)&&D("boolean",e.includeFrozen,!0)&&D("boolean",e.includeMetaData,!0)&&D("boolean",e.includeChatNotification,!0)},op={myMemberStateFilter:e.MyMemberStateFilter.ALL},up=function(t){return R(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(tp=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",tp.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",tp.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",tp.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",tp.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",tp.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",tp.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",tp.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",tp.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var cp,lp={keys:[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,e.UnreadItemKey.NONSUPER_INVITATION_COUNT,e.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},dp=function(t){return P(e.UnreadItemKey,t.keys)&&P("string",t.customTypeFilters,!0)&&P("string",t.customTypesFilter,!0)},hp={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},fp=function(t){return P("string",t.channelCustomTypesFilter,!0)&&R(e.SuperChannelFilter,t.superChannelFilter)},pp={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},vp=function(t){return D("string",t.channelUrl,!0)&&P(e.ScheduledStatus,t.scheduledStatus,!0)&&R(e.MessageTypeFilter,t.messageTypeFilter)},_p=Object.assign({},e.CollectionEventSource),mp=function(t){return t.startsWith("EVENT_")||t===e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.CollectionEventSource.REFRESH_CHANNEL},gp=function(e){function t(e){var a,i=e.channels,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.ts;return r(this,t),(a=n(this,t)).channels=i,a.context=s,a.isWebSocketEventComing=u,a.ts=c,a}return c(t,e),i(t)}(fe),yp=function(e){function t(e){var a,i=e.channelUrls,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,t),(a=n(this,t)).channelUrls=i,a.context=s,a.isWebSocketEventComing=u,a}return c(t,e),i(t)}(fe),Ep=function(){return i((function t(n){var a=this,i=n.groupChannelCache,o=n.messageCache,u=n.unsentMessageCache,c=n.dispatcher;r(this,t),this._observers=new Map,c.on((function(t){return E(a,void 0,void 0,d().mark((function n(){var r,a,c,l,h,f,p,v,_,m,g,y,k,b,C,w=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof gp)){n.next=47;break}if(r=t.channels,a=t.context,c=t.isWebSocketEventComing,l=r.filter((function(e){return e instanceof E_})),a.source!==e.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY&&a.source!==e.CollectionEventSource.EVENT_CHANNEL_HIDDEN){n.next=23;break}h=s(l),n.prev=5,h.s();case 7:if((f=h.n()).done){n.next=13;break}return p=f.value,n.next=11,o.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),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:n.next=41;break;case 23:v=i.filterOffsetChanged(l),_=s(v),n.prev=25,_.s();case 27:if((m=_.n()).done){n.next=33;break}return g=m.value,n.next=31,o.removeUnderOffset(g.url,g.messageOffsetTimestamp);case 31:n.next=27;break;case 33:n.next=38;break;case 35:n.prev=35,n.t1=n.catch(25),_.e(n.t1);case 38:return n.prev=38,_.f(),n.finish(38);case 41:return n.next=43,i.upsert(l,t.ts);case 43:y=n.sent,c||this._broadcastUpdateEvent(y,a),n.next=59;break;case 47:if(!(t instanceof yp)){n.next=56;break}return k=t.channelUrls,b=t.context,C=t.isWebSocketEventComing,n.next=51,i.remove(k);case 51:return n.next=53,fi((function(){return E(w,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(k),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=7,o.removeMessagesOfChannel(r);case 7:return e.next=9,u.removeMessagesOfChannel(r);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 53:C||this._broadcastRemoveEvent(k,b),n.next=59;break;case 56:if(!(t instanceof Ph)){n.next=59;break}return n.next=59,i.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 59:case"end":return n.stop()}}),n,this,[[5,15,18,21],[25,35,38,41]])})))}))}),[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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:"_broadcastRemoveEvent",value:function(e,t){var n,r=s(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()}}])}(),kp=function(e){function t(e){var a,i=e.userId,s=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c;r(this,t),a=n(this,t);var d=Object.assign(Object.assign({},ip),u),h=d.customTypes,f=d.includeEmpty,p=d.includeFrozen;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels/changelogs"),a.params=pe(ve({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:s||null,token:o,custom_types:h,show_empty:f,show_frozen:p,include_chat_notification:l})),a}return c(t,e),i(t)}(je),bp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedChannels=a.updated.map((function(t){return new E_(e,Object.assign(t,{ts:a.ts}))})),i.deletedChannelUrls=a.deleted,i.hasMore=a.has_more,i.token=a.next,i.ts=a.ts,i}return c(t,e),i(t)}(Ve),Cp=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall,o=e.showLatestMessage;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?be:ke,"/").concat(encodeURIComponent(i)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=o&&o},a}return c(t,e),i(t)}(je),wp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),xp={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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,createdAfter:void 0,createdBefore:void 0},Sp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,d=e.superChannelFilter,h=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,E=e.customTypeStartsWithFilter,k=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,C=e.metadataKey,w=e.metadataValues,x=e.metadataValueStartsWith,S=e.includeFrozen,T=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter,A=e.includeChatNotification,M=void 0!==A&&A,O=e.includeLeftChannel,U=void 0!==O&&O,D=e.createdAfter,R=e.createdBefore;return(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels"),a.params=pe({token:s,limit:o,order:null!=u?u:xp.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:xp.includeEmpty,member_state_filter:null!=l?l:xp.myMemberStateFilter,super_mode:null!=d?d:xp.superChannelFilter,public_mode:null!=h?h:xp.publicChannelFilter,unread_filter:null!=f?f:xp.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:E,hidden_mode:k,metadata_order_key:b,metadata_key:C,metadata_values:w,metadata_value_startswith:x,show_frozen:S,show_metadata:T,include_chat_notification:M,include_left_channel:U,created_after:D,created_before:R}),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 c(t,e),i(t)}(je),Tp=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new E_(e,t)}))),i.ts=null!=u?u:0,i}return c(t,e),i(t)}(Ve),Ip=function(t){function a(t){var i,s=t.userId,o=t.filter;r(this,a),i=n(this,a);var u=o.myMemberStateFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/group_channel_count"),i.params={state:null!=u?u:e.MyMemberStateFilter.ALL},i}return c(a,t),i(a)}(je),Np=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).groupChannelCount=a.group_channel_count,i}return c(t,e),i(t)}(Ve),Ap=function(e){function t(e){var a,i=e.userId,s=e.filter;r(this,t),a=n(this,t);var o=s.keys,u=s.customTypeFilters,c=s.customTypesFilter;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_item_count"),a.params=pe({item_keys:o,custom_types:null!=c?c:u}),a}return c(t,e),i(t)}(je),Mp=function(t){function a(t,i){var s;return r(this,a),s=n(this,a,[t,i]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=i[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),s}return c(a,t),i(a)}(Ve),Op=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_channel_count"),a}return c(t,e),i(t)}(je),Up=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i}return c(t,e),i(t)}(Ve),Dp=function(t){function a(t){var i,s=t.userId,o=t.filter,u=t.includeFeedChannel,c=void 0!==u&&u;r(this,a),i=n(this,a);var l=o.channelCustomTypesFilter,d=o.superChannelFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/unread_message_count"),i.params={super_mode:null!=d?d:e.SuperChannelFilter.ALL,custom_types:l,include_feed_channel:c},i}return c(a,t),i(a)}(je),Rp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i.unreadFeedCount=a.unread_feed_count,i}return c(t,e),i(t)}(Ve),Lp=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledStatus,o=e.messageTypeFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ae,"/count"),a.params={channel_url:i,status:Fp(s)},o&&(a.params.message_type=o),a}return c(t,e),i(t)}(je),Pp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).count=a.count,i}return c(t,e),i(t)}(Ve),Fp=function(t){if(!t)return[];var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(Vs.PENDING);break;case e.ScheduledStatus.SENT:n.push(Vs.IN_QUEUE),n.push(Vs.SENT);break;case e.ScheduledStatus.CANCELED:n.push(Vs.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(Vs.FAILED)}})),n},qp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,d=e.isBroadcast,h=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,_=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,E=e.data,k=e.customType,b=e.messageSurvivalSeconds,C=e.invitedUserIds,w=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path=ke,a.params=pe({user_ids:[i].concat(v(null!=C?C:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:d,is_exclusive:f,is_public:h,is_discoverable:p,strict:_,is_ephemeral:m,access_code:g,name:y,data:E,custom_type:k,operator_ids:w,message_survival_seconds:b}),a}return c(t,e),i(t)}(je),Hp=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i.isCreated=null===(s=a.is_created)||void 0===s||s,i}return c(t,e),i(t)}(Ve),Gp=function(e){function t(e){var a,i=e.userId,s=e.channelUrls;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/mark_as_read_all"),a.params={channel_urls:s},a}return c(t,e),i(t)}(je),jp=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).event=new np(i),s}return c(t,e),i(t)}(Ke),Vp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/join"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(je),zp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),Bp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.users,f=void 0===h?null:h;return s.memberCount=c,s.joinedMemberCount=d,s.members=Array.isArray(f)?f.map((function(t){return new Zf(e,t)})):[new Zf(e,i.data)],s}return c(t,e),i(t)}(jp),Kp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.shouldRemoveOperatorStatus;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/leave"),a.params={user_id:s,should_remove_operator_status:o},a}return c(t,e),i(t)}(je),Qp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l;return s.memberCount=c,s.joinedMemberCount=d,s.member=new Zf(s._iid,i.data),s}return c(t,e),i(t)}(jp),Wp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/invite"),a.params={user_ids:s},a}return c(t,e),i(t)}(je),Yp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),Zp=function(e){function t(e,a,i){var s;r(this,t),(s=n(this,t,[e,a,i])).inviter=null;var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.inviter,f=o.invitees,p=void 0===f?[]:f;return s.memberCount=c,s.joinedMemberCount=d,h&&Object.keys(h).length>0&&(s.inviter=new si(e,h)),s.invitees=p.map((function(t){return new Zf(e,t)})),s}return c(t,e),i(t)}(jp),Xp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/decline"),a.params={user_id:s},a}return c(t,e),i(t)}(je),Jp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=o.joined_member_count,l=o.inviter,d=o.invitee;return s.memberCount=null!=u?u:0,s.joinedMemberCount=null!=c?c:0,s.inviter=new si(e,l),s.invitee=new Zf(e,d),s}return c(t,e),i(t)}(jp),$p={hidePreviousMessages:!1,allowAutoUnhide:!0},ev=function(e){return D("boolean",e.hidePreviousMessages,!0)&&D("boolean",e.allowAutoUnhide,!0)},tv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a.params={user_id:s,hide_previous_messages:null!=o?o:$p.hidePreviousMessages,allow_auto_unhide:null!=u?u:$p.allowAutoUnhide},a}return c(t,e),i(t)}(je),nv=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(Ve),rv=function(e){function t(e,a,i){var s,o,u,c;return r(this,t),(s=n(this,t,[e,"SYEV",i])).allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,i.data&&(s.allowAutoUnhide=null!==(o=i.data.allow_auto_unhide)&&void 0!==o?o:null,s.hidePreviousMessages=null!==(u=i.data.hide_previous_messages)&&void 0!==u?u:null),s.messageOffsetTimestamp=null!==(c=i.ts_message_offset)&&void 0!==c?c:null,s}return c(t,e),i(t)}(Ke),av=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(Qe),iv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new si(e,i.data),s}return c(t,e),i(t)}(Ke),sv=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(Qe),ov=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new si(e,i.data),s}return c(t,e),i(t)}(Ke),uv=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data.operators,u=void 0===o?[]:o;return s.operators=u.map((function(e){return new si(s._iid,e)})),s}return c(t,e),i(t)}(jp),cv=function(e){function t(e){var a=e.channelUrl,i=e.messageId;return r(this,t),n(this,t,[{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:i}}])}return c(t,e),i(t)}(Qe),lv=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x,S,T,I,N;return r(this,a),(s=n(this,a,[t,i])).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.includeChatNotification=!1,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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.includeChatNotification=null!==(l=i.includeChatNotification)&&void 0!==l&&l,s.channelUrlsFilter=null!==(d=i.channelUrlsFilter)&&void 0!==d?d:null,s.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(f=i.customTypeStartsWithFilter)&&void 0!==f?f:"",s.nicknameContainsFilter=null!==(p=i.nicknameContainsFilter)&&void 0!==p?p:null,s.nicknameStartsWithFilter=null!==(v=i.nicknameStartsWithFilter)&&void 0!==v?v:null,s.nicknameExactMatchFilter=null!==(_=i.nicknameExactMatchFilter)&&void 0!==_?_:null,s.channelNameContainsFilter=null!==(m=i.channelNameContainsFilter)&&void 0!==m?m:"",s.myMemberStateFilter=null!==(g=i.myMemberStateFilter)&&void 0!==g?g:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(y=i.unreadChannelFilter)&&void 0!==y?y:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(E=i.superChannelFilter)&&void 0!==E?E:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=i.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=i.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(C=i.searchFilter)&&void 0!==C?C:{fields:[],query:null},s.userIdsFilter=null!==(w=i.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(x=i.metadataKey)&&void 0!==x?x:null,s.metadataValues=null!==(S=i.metadataValues)&&void 0!==S?S:null,s.metadataOrderKeyFilter=null!==(T=i.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(I=i.metadataValueStartsWith)&&void 0!==I?I:null,s.order=null!==(N=i.order)&&void 0!==N?N:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i.createdAfter&&(s.createdAfter=i.createdAfter),i.createdBefore&&(s.createdBefore=i.createdBefore),s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter)&&D("string",this.nicknameContainsFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)&&D("string",this.nicknameExactMatchFilter,!0)&&R(e.MyMemberStateFilter,this.myMemberStateFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicChannelFilter,this.publicChannelFilter)&&R(e.UnreadChannelFilter,this.unreadChannelFilter)&&R(e.HiddenChannelFilter,this.hiddenChannelFilter)&&P(e.GroupChannelSearchField,this.searchFilter.fields)&&D("string",this.searchFilter.query,!0)&&P("string",this.userIdsFilter.userIds)&&D("boolean",this.userIdsFilter.includeMode)&&R(e.QueryType,this.userIdsFilter.queryType)&&R(e.GroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)&&F(this.createdAfter,!0)&&F(this.createdBefore,!0)}},{key:"serialize",value:function(){return ni(this)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._validate()){t.next=20;break}if(this._isLoading){t.next=17;break}if(!this._hasNext){t.next=14;break}return this._isLoading=!0,n=Cv.of(this._iid),t.next=7,n.getMyGroupChannels(this._token,ve(Object.assign({},this)),this.limit,e.CollectionEventSource.REQUEST_CHANNEL,!0);case 7:return r=t.sent,a=r.channels,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,t.abrupt("return",a);case 14:return t.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:t.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return t.stop()}}),t,this)})))}}])}(uu),dv=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"SYEV",i])).pinnedMessageIds=[],s.latestPinnedMessage=null,s.ts=0,i.data&&(s.pinnedMessageIds=null!==(o=i.data.pinned_message_ids)&&void 0!==o?o:[],s.latestPinnedMessage=i.data.latest_pinned_message?ho(e,Object.assign({},i.data.latest_pinned_message)):null),s.ts=i.ts,s}return c(t,e),i(t)}(Ke),hv=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e]))._logger=a.logger,i._sdkState=a.sdkState,i._sessionManager=a.sessionManager,i._requestQueue=a.requestQueue,i._dispatcher=a.dispatcher,i._cacheContext=a.cacheContext,i._channelType=a.channelType,i}return c(t,e),i(t,[{key:"_messageBroadcast",get:function(){return Zd.of(this._iid)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"getMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null);case 1:case"end":return e.stop()}}),e)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r,a,i){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",0);case 1:case"end":return e.stop()}}),e)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}(Ya),fv=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"ADMM",i])).message=new Js(e,i);var d=es.of(e).sdkState;return s.isMentioned=Fe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),pv=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"AEDI",i])).message=new Js(e,i);var h=es.of(e).sdkState;return s.mentionCountChange=qe({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),vv=function(e){function t(e){var a,i=e.channelUrl,s=e.userId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/messages/mark_as_delivered"),a.params=pe({userId:s}),a}return c(t,e),i(t)}(je),_v=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"DLVR",i])).channelUrl=i.channel_url,s.deliveredStateUpdate=i.updated,s}return c(t,e),i(t)}(Ke),mv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MRCT",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.event=new os(i),s}return c(t,e),i(t)}(Ke),gv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MTHD",i])).event=new rh(e,i),s}return c(t,e),i(t)}(Ke),yv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MCNT",i])).groupChannelMemberCounts=i.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=i.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return c(t,e),i(t)}(Ke),Ev=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"PEDI",i])).event=new Eh(e,i),s.status=no(i.poll.status)||i.poll.status,s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),kv=function(){return i((function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,i=t.bottom,s=void 0===i?0:i;r(this,e),this.top=a,this.bottom=s}),[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0&&r.onMentionReceived&&r.onMentionReceived(T,w)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 63:return a.abrupt("break",344);case 64:if(D=t.as(lt),R=D.channelUrl,L=D.channelType,P=D.messageId,F=D.silent,q=D.messageCreatedAt,H=D.senderId,L!==e.ChannelType.GROUP){a.next=73;break}return a.next=68,this.getChannel(R,!0);case 68:G=a.sent,j=H===this._sdkState.userId,F||j||q>0&&G.myLastRead0&&G._updateUnreadCount(G.unreadMessageCount-1,0),this._dispatcher.dispatch(new Us({messageIds:[P],source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onMessageDeleted&&r.onMessageDeleted(G,P)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 73:return a.abrupt("break",344);case 74:if(V=t.as(Es),(z=V.readStatus).channelType!==e.ChannelType.GROUP){a.next=82;break}return B=this._groupChannelCache.isCachedInMemory(z.channelUrl),a.next=79,this.getChannel(z.channelUrl,!0);case 79:K=a.sent,B&&K._updateUnreadMemberState(z.reader.userId,z.readAt),z.reader.userId===this._sdkState.userId?B?(K.unreadMessageCount>0||K.unreadMentionCount>0)&&(K._updateUnreadCount(0,0),this._dispatcher.dispatch(new gp({channels:[K],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(K)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==K.unreadMessageCount&&0!==K.unreadMentionCount||(this._dispatcher.dispatch(new gp({channels:[K],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(K)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new gp({channels:[K],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUnreadMemberStatusUpdated&&r.onUnreadMemberStatusUpdated(K)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 82:return a.abrupt("break",344);case 83:return Q=t.as(_v),W=Q.channelUrl,Y=Q.deliveredStateUpdate,Z=void 0===Y?{}:Y,X=this._groupChannelCache.isCachedInMemory(W),a.next=87,this.getChannel(W,!0);case 87:return J=a.sent,X&&Object.keys(Z).forEach((function(e){J._updateUndeliveredMemberState(e,Z[e])})),Object.keys(Z).some((function(e){return e!==mn._sdkState.userId}))&&(this._dispatcher.dispatch(new gp({channels:[J],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELIVERED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUndeliveredMemberStatusUpdated&&r.onUndeliveredMemberStatusUpdated(J)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 91:if($=t.as(mv),ee=$.channelUrl,te=$.channelType,ne=$.event,te!==e.ChannelType.GROUP){a.next=101;break}return a.next=95,this.getChannel(ee,!0);case 95:return re=a.sent,a.next=98,this.getMessageFromCache(ne.messageId);case 98:(ae=a.sent)?ae instanceof Ws&&(ae.applyReactionEvent(ne),this._dispatcher.dispatch(new Os({messages:[ae],source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new Ds({event:ne,source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onReactionUpdated&&r.onReactionUpdated(re,ne)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 101:return a.abrupt("break",344);case 102:if(ie=t.as(gv),(se=ie.event).channelType!==e.ChannelType.GROUP){a.next=112;break}return a.next=106,this.getChannel(se.channelUrl,!0);case 106:return oe=a.sent,a.next=109,this.getMessageFromCache(se.targetMessageId);case 109:(ue=a.sent)?ue instanceof Ws&&(ue.applyThreadInfoUpdateEvent(se),this._dispatcher.dispatch(new Os({messages:[ue],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new Rs({event:se,source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onThreadInfoUpdated&&r.onThreadInfoUpdated(oe,se)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 112:return a.abrupt("break",344);case 113:ce=t.as(yv),le=ce.groupChannelMemberCounts,de=[],he=s(le),a.prev=116,he.s();case 118:if((fe=he.n()).done){a.next=127;break}return pe=fe.value,ve=pe.channelUrl,_e=pe.memberCount,me=pe.joinedMemberCount,ge=pe.updatedAt,a.next=123,this.getChannelFromCache(ve);case 123:(ye=a.sent)&&ye._setLatestMemberCount(_e,me,ge)&&de.push(ye);case 125:a.next=118;break;case 127:a.next=132;break;case 129:a.prev=129,a.t2=a.catch(116),he.e(a.t2);case 132:return a.prev=132,he.f(),a.finish(132);case 135:return de.length>0&&(this._dispatcher.dispatch(new gp({channels:de,context:{source:e.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(de)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 137:if(Ee=t.as(Ev),ke=Ee.event,be=Ee.status,Ce=Ee.channelUrl,we=Ee.channelType,!Ce||we!==e.ChannelType.GROUP){a.next=144;break}return a.next=141,this.getChannel(Ce,!0);case 141:xe=a.sent,this._dispatcher.dispatch(new Fs({event:ke,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),hi(be===to?function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(xe,ke.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(xe,ke)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 144:return a.abrupt("break",344);case 145:if(Se=t.as(Oc),Te=Se.event,Ie=Se.channelUrl,Ne=Se.channelType,!Ie||Ne!==e.ChannelType.GROUP){a.next=152;break}return a.next=149,this.getChannel(Ie,!0);case 149:Ae=a.sent,this._dispatcher.dispatch(new qs({event:Te,source:e.CollectionEventSource.EVENT_POLL_VOTED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(Ae,Te)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 152:return a.abrupt("break",344);case 153:if(Me=t.as(jp),!(Oe=Me.event).isGroupChannelEvent){a.next=332;break}a.t3=Oe.category,a.next=a.t3===Jf.CHANNEL_JOIN?158:a.t3===Jf.CHANNEL_LEAVE?167:a.t3===Jf.CHANNEL_OPERATOR_UPDATE?183:a.t3===Jf.CHANNEL_INVITE?194:a.t3===Jf.CHANNEL_DECLINE_INVITE?204:a.t3===Jf.TYPING_START||a.t3===Jf.TYPING_END?212:a.t3===Jf.USER_CHANNEL_MUTE||a.t3===Jf.USER_CHANNEL_UNMUTE?221:a.t3===Jf.USER_CHANNEL_BAN?248:a.t3===Jf.USER_CHANNEL_UNBAN?263:a.t3===Jf.CHANNEL_FREEZE||a.t3===Jf.CHANNEL_UNFREEZE?271:a.t3===Jf.CHANNEL_HIDE?279:a.t3===Jf.CHANNEL_UNHIDE?289:a.t3===Jf.CHANNEL_DELETED?296:a.t3===Jf.CHANNEL_PROP_CHANGED?302:a.t3===Jf.CHANNEL_META_DATA_CHANGED?308:a.t3===Jf.CHANNEL_META_COUNTERS_CHANGED?317:a.t3===Jf.PINNED_MESSAGE_CHANGED?326:332;break;case 158:return a.next=160,this.getChannel(Oe.channelUrl,!0);case 160:return Ue=a.sent,De=t.as(Bp),Re=De.memberCount,Le=De.joinedMemberCount,Pe=De.members,Fe=!1,Pe.forEach((function(t){Ue.isExclusive||Ue.isSuper||Ue.isBroadcast?Fe=Fe||Ue._setLatestMemberCount(Re,Le,Oe.ts):(t.state=e.MemberState.JOINED,Ue.addMember(t,Oe.ts),mn._updateJoinedMemberCount(Ue)),t.userId===mn._sdkState.userId&&(Ue.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new gp({channels:[Ue],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:Pe}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=s(Pe);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ue,r)}}catch(e){n.e(e)}finally{n.f()}Ue.isBroadcast&&Fe&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ue])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 167:if(!(qe=this._leftChannels.get(Oe.channelUrl))){a.next=172;break}a.t4=qe.channel,a.next=175;break;case 172:return a.next=174,this.getChannel(Oe.channelUrl,!0);case 174:a.t4=a.sent;case 175:return He=a.t4,Ge=t.as(Qp),je=Ge.memberCount,Ve=Ge.joinedMemberCount,ze=Ge.member,Be=!1,Ke=es.of(this._iid),Qe=Ke.appInfo,He.isExclusive||He.isSuper||He.isBroadcast?Be=He._setLatestMemberCount(je,Ve,Oe.ts):((null==Qe?void 0:Qe.enabledChannelMemberShipHistory)?((We=He.members.find((function(e){return e.userId===ze.userId})))&&(We.state=e.MemberState.LEFT),He.memberCount=je):He.removeMember(ze),this._updateJoinedMemberCount(He)),ze.userId===this._sdkState.userId?(He.myMemberState=e.MemberState.NONE,He.invitedAt=0,He.joinedAt=0,He._updateUnreadCount(0,0),He.isPublic?this._dispatcher.dispatch(new gp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})):(this._markAsLeave(He),this._dispatcher.dispatch(new yp({channelUrls:[He.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})))):this._dispatcher.dispatch(new gp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(He,ze),He.isBroadcast&&Be&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([He])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 183:return a.next=185,this.getChannel(Oe.channelUrl,!0);case 185:Ye=a.sent,Ze=t.as(uv),Xe=Ze.operators,Je=Xe.map((function(e){return e.userId})),$e=s(Ye.members);try{for($e.s();!(et=$e.n()).done;)(tt=et.value).role=Je.includes(tt.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){$e.e(e)}finally{$e.f()}return Ye.myRole=Je.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new gp({channels:[Ye],context:{source:e.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Xe}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ye,Xe)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 194:return a.next=196,this.getChannel(Oe.channelUrl,!0);case 196:nt=a.sent,rt=t.as(Zp),at=rt.memberCount,it=rt.joinedMemberCount,st=rt.inviter,(ot=rt.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),ut=s(ot);try{for(ut.s();!(ct=ut.n()).done;)dt=ct.value,nt.isExclusive||nt.isSuper||nt.isBroadcast?nt._setLatestMemberCount(at,it,Oe.ts):nt.addMember(dt,Oe.ts),this._sdkState.userId===dt.userId&&(nt.hiddenState=e.HiddenState.UNHIDDEN,nt.myMemberState!==e.MemberState.JOINED&&(nt.myMemberState=e.MemberState.INVITED),nt.invitedAt=Oe.ts)}catch(e){ut.e(e)}finally{ut.f()}return this._dispatcher.dispatch(new gp({channels:[nt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:st,invitees:ot}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(nt,st,ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 204:return a.next=206,this.getChannel(Oe.channelUrl,!0);case 206:return ht=a.sent,ft=t.as(Jp),pt=ft.memberCount,vt=ft.joinedMemberCount,_t=ft.inviter,mt=ft.invitee,ht.isExclusive||ht.isSuper||ht.isBroadcast?ht._setLatestMemberCount(pt,vt,Oe.ts):ht.removeMember(mt),this._sdkState.userId===mt.userId?(ht.invitedAt=0,ht.myMemberState=e.MemberState.NONE,ht.isPublic?this._dispatcher.dispatch(new gp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})):this._dispatcher.dispatch(new yp({channelUrls:[ht.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}}))):this._dispatcher.dispatch(new gp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ht,_t,mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 212:return a.next=214,this.getChannel(Oe.channelUrl,!0);case 214:return gt=a.sent,yt=Oe.category===Jf.TYPING_START,Et=t.as(yt?iv:ov),kt=Et.user,gt._updateTypingStatus(kt,yt?Oe.ts:0),this._dispatcher.dispatch(new gp({channels:[gt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(gt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 221:return a.next=223,this.getChannel(Oe.channelUrl,!0);case 223:bt=a.sent,Ct=Oe.category===Jf.USER_CHANNEL_MUTE,wt=t.as(Ct?Bu:Qu),(xt=wt.user).userId===this._sdkState.userId&&(bt.myMutedState=Ct?e.MutedState.MUTED:e.MutedState.UNMUTED,bt._myMutedRemainingTime=xt.restrictionInfo.remainingDuration),St=s(bt.members),a.prev=228,St.s();case 230:if((Tt=St.n()).done){a.next=237;break}if((It=Tt.value).userId!==xt.userId){a.next=235;break}return It.isMuted=Ct,a.abrupt("break",237);case 235:a.next=230;break;case 237:a.next=242;break;case 239:a.prev=239,a.t5=a.catch(228),St.e(a.t5);case 242:return a.prev=242,St.f(),a.finish(242);case 245:return this._dispatcher.dispatch(new gp({channels:[bt],context:{source:Ct?e.CollectionEventSource.EVENT_CHANNEL_MUTED:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:xt}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ct?e.onUserMuted&&e.onUserMuted(bt,xt):e.onUserUnmuted&&e.onUserUnmuted(bt,xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 248:if(!(Nt=this._leftChannels.get(Oe.channelUrl))){a.next=253;break}a.t6=Nt.channel,a.next=256;break;case 253:return a.next=255,this.getChannel(Oe.channelUrl,!0);case 255:a.t6=a.sent;case 256:return At=a.t6,this._markAsLeave(At),Mt=t.as(Yu),Ot=Mt.user,Ot.userId===this._sdkState.userId&&this._dispatcher.dispatch(new yp({channelUrls:[At.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_BANNED,user:Ot}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(At,Ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 263:return a.next=265,this.getChannel(Oe.channelUrl,!0);case 265:return Ut=a.sent,Dt=t.as(Xu),Rt=Dt.user,Rt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new yp({channelUrls:[Ut.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:Rt}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(Ut,Rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 271:return a.next=273,this.getChannel(Oe.channelUrl,!0);case 273:return Lt=a.sent,Pt=t.as($u),Ft=Pt.freeze,Lt.isFrozen=Ft,this._dispatcher.dispatch(new gp({channels:[Lt],context:{source:Ft?e.CollectionEventSource.EVENT_CHANNEL_FROZEN:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ft?e.onChannelFrozen&&e.onChannelFrozen(Lt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 279:return a.next=281,this.getChannel(Oe.channelUrl,!0);case 281:return qt=a.sent,Ht=t.as(rv),Gt=Ht.allowAutoUnhide,jt=Ht.hidePreviousMessages,Vt=Ht.messageOffsetTimestamp,null!==Gt&&(qt.hiddenState=Gt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==jt&&jt&&qt._updateUnreadCount(0,0),null!==Vt&&(qt.messageOffsetTimestamp=Vt),this._dispatcher.dispatch(new gp({channels:[qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 289:return a.next=291,this.getChannel(Oe.channelUrl,!0);case 291:return(zt=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new gp({channels:[zt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(zt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 296:return a.next=298,this.getChannel(Oe.channelUrl,!0);case 298:return Bt=a.sent,this._dispatcher.dispatch(new yp({channelUrls:[Oe.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Bt.url,Bt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 302:return a.next=304,this.getChannelWithoutCache(Oe.channelUrl,!0);case 304:return Kt=a.sent,this._dispatcher.dispatch(new gp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Kt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 308:return a.next=310,this.getChannel(Oe.channelUrl,!0);case 310:return Qt=a.sent,Wt=t.as(Au),Yt=Wt.created,Zt=Wt.updated,Xt=Wt.deleted,Yt&&(Qt._upsertCachedMetaData(Yt,Oe.ts),this._dispatcher.dispatch(new gp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:Yt},ts:Oe.ts}))),Zt&&(Qt._upsertCachedMetaData(Zt,Oe.ts),this._dispatcher.dispatch(new gp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:Zt},ts:Oe.ts}))),Xt&&(Qt._removeFromCachedMetaData(Xt,Oe.ts),this._dispatcher.dispatch(new gp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:Xt},ts:Oe.ts}))),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Yt&&e.onMetaDataCreated&&e.onMetaDataCreated(Qt,Yt),Zt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Qt,Zt),Xt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Qt,Xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 317:return a.next=319,this.getChannel(Oe.channelUrl,!0);case 319:return Jt=a.sent,$t=t.as(Gu),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&this._dispatcher.dispatch(new gp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:en}})),tn&&this._dispatcher.dispatch(new gp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:tn}})),nn&&this._dispatcher.dispatch(new gp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:nn}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){en&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Jt,en),tn&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Jt,tn),nn&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Jt,nn)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 326:return a.next=328,this.getChannel(Oe.channelUrl,!0);case 328:return rn=a.sent,an=t.as(dv),sn=an.pinnedMessageIds,on=an.latestPinnedMessage,(un=an.ts)>rn._pinnedMessagesUpdatedAt&&(rn.pinnedMessageIds=null!=sn?sn:[],rn.lastPinnedMessage=on,rn._pinnedMessagesUpdatedAt=un,this._dispatcher.dispatch(new gp({channels:[rn],context:{source:e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(rn)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(rn)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",332);case 332:return a.abrupt("break",344);case 333:cn=t.as(qh),ln=cn.event,a.t7=ln.category,a.next=a.t7===wh.USER_BLOCK?337:a.t7===wh.USER_UNBLOCK?340:343;break;case 337:return dn=Rh.getDataAsUserBlockEvent(this._iid,ln),hn=dn.blocker,fn=dn.blockee,this._groupChannelCache.block(hn.userId,fn.userId),a.abrupt("break",343);case 340:return pn=Rh.getDataAsUserBlockEvent(this._iid,ln),vn=pn.blocker,_n=pn.blockee,this._groupChannelCache.unblock(vn.userId,_n.userId),a.abrupt("break",343);case 343:return a.abrupt("break",344);case 344:a.next=350;break;case 346:if(a.prev=346,a.t8=a.catch(0),!N(a.t8)){a.next=350;break}throw a.t8;case 350:case"end":return a.stop()}}),a,this,[[0,346],[18,29,32,35],[116,129,132,135],[228,239,242,245]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",t)).throw(A.invalidParameters),a=new Cp({channelUrl:t,isInternalCall:n}),r.next=4,this._requestQueue.send(a);case 4:i=r.sent,s=i.as(wp),o=s.channel,u=o.unreadMessageCount,c=o.unreadMentionCount,r.t0=o.myCountPreference,r.next=r.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:r.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:r.t0===e.CountPreference.OFF?14:17;break;case 10:return c=0,r.abrupt("break",17);case 12:return u=0,r.abrupt("break",17);case 14:return u=0,c=0,r.abrupt("break",17);case 17:return o._updateUnreadCount(u,c),r.next=20,this.upsertChannelsToCache([o]);case 20:return r.abrupt("return",r.sent[0]);case 21:case"end":return r.stop()}}),r,this)})))}},{key:"refreshChannel",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REFRESH_CHANNEL,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,s=new Cp({channelUrl:t,isInternalCall:n,showLatestMessage:a}),i.next=4,this._requestQueue.send(s);case 4:if(o=i.sent,u=o.as(wp),(c=u.channel).myMemberState!==e.MemberState.NONE){i.next=10;break}this._dispatcher.dispatch(new yp({channelUrls:[c.url],context:{source:r}})),i.next=14;break;case 10:return i.next=12,this.upsertChannelsToCache([c]);case 12:l=i.sent,this._dispatcher.dispatch(new gp({channels:l,context:{source:r}}));case 14:i.next=19;break;case 16:i.prev=16,i.t0=i.catch(0),i.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&i.t0.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new yp({channelUrls:[t],context:{source:r}}));case 19:case"end":return i.stop()}}),i,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_CHANNEL,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p,v;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.createdAfter&&(n.createdAfter=Math.floor(n.createdAfter/1e3)),n.createdBefore&&(n.createdBefore=Math.floor(n.createdBefore/1e3)),s=!1,i&&(o=es.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(s=!0)),l=new Sp(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:r,includeLeftChannel:i&&s})),e.next=7,this._requestQueue.send(l);case 7:return h=e.sent,f=h.as(Tp),p=f.channels,v=f.token,this._dispatcher.dispatch(new gp({channels:p,context:{source:a}})),e.abrupt("return",{channels:p,token:v});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Object.assign(Object.assign({},ip),n),ai((D("string",t)||D("number",t))&&sp(a)).throw(A.invalidParameters),i=new kp(ve({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,filter:a})),e.next=5,this._requestQueue.send(i);case 5:return s=e.sent,o=s.as(bp),u=o.updatedChannels,c=o.deletedChannelUrls,l=o.hasMore,h=o.ts,u.length>0&&this._dispatcher.dispatch(new gp({channels:u,context:{source:r},ts:h})),c.length>0&&this._dispatcher.dispatch(new yp({channelUrls:c,context:{source:r}})),e.abrupt("return",{updatedChannels:u,deletedChannelUrls:c,hasMore:l,token:o.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},op),e),ai(up(n)).throw(A.invalidParameters),r=new Ip({userId:this._sdkState.userId,filter:n}),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Np),s=i.groupChannelCount,t.abrupt("return",s);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},lp),e),ai(dp(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Ap({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Mp),c=u.groupChannelUnreadMentionCount,l=u.groupChannelUnreadMessageCount,h=u.groupChannelInvitationCount,f=u.superGroupChannelUnreadMentionCount,p=u.superGroupChannelUnreadMessageCount,v=u.superGroupChannelInvitationCount,_=u.nonSuperGroupChannelUnreadMentionCount,m=u.nonSuperGroupChannelUnreadMessageCount,g=u.nonSuperGroupChannelInvitationCount,t.abrupt("return",pe({groupChannelUnreadMentionCount:c,groupChannelUnreadMessageCount:l,groupChannelInvitationCount:h,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Op({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Up),o=s.unreadCount,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},hp),e),ai(fp(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Dp({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Rp),c=u.unreadCount,t.abrupt("return",c);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},pp),e),ai(vp(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new Lp(n),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Pp),u=o.count,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=es.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=es.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=es.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},rp),e),ai(ap(n)).throw(A.invalidParameters),n.isPublic||(n.accessCode=void 0),r=new qp(Object.assign({userId:this._sdkState.userId},n)),t.next=6,this._requestQueue.send(r);case 6:return a=t.sent,i=a.as(Hp),s=i.channel,t.next=10,this.upsertChannelsToCache([s]);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Date.now(),ai(t-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Gp({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(n);case 6:r=this._groupChannelCache.channels,a=s(r);try{for(a.s();!(i=a.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0)}catch(e){a.e(e)}finally{a.f()}if(!(r.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(r);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),ai(P("string",e)&&n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new Gp({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,i=[],o=s(a);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,n),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()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return n=t.sent,t.next=5,n.markAsDelivered();case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._messageCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0});case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),r,this)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:100,i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return E(this,void 0,void 0,d().mark((function s(){return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i});case 2:return s.abrupt("return",s.sent);case 3:case"end":return s.stop()}}),s,this)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.countBetween(e,t,new kv({top:n,bottom:r}));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:t});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return bv[e]||(bv[e]=new a(e,es.of(e))),bv[e]}},{key:"clear",value:function(e){bv[e]&&delete bv[e]}}])}(hv),wv=function(e,t){return t instanceof Ys?e.findIndex((function(e){return e instanceof Ys&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},xv=function(e,t){return e.findIndex((function(e){return e instanceof Ws?e.messageId===t:e instanceof co?e.notificationId===t:void 0}))},Sv=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(i<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(cp||(cp={}));var Tv=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t))._state=cp.IDLE,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=a,i}return c(t,e),i(t,[{key:"isIdle",get:function(){return this._state===cp.IDLE}},{key:"isRunning",get:function(){return this._state===cp.RUNNING}},{key:"isDone",get:function(){return this._state===cp.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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:n=t.sent,this._retryCount=0,this.dispatch("progress",n),n.hasNext?this._run(n.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(E=_.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(y=u.range).intersect.apply(y,v(E)))?this.extendRange(_):this._metadata={range:new kv({top:Math.min.apply(Math,v(E)),bottom:Math.max.apply(Math,v(E))}),previousComplete:!1}),h.hasNext=_.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(h.nextToken=this._metadata.range.top,this._metadata.previousComplete=_.length0&&(y=f.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(_=o.range).intersect.apply(_,v(y)))?this.extendRange(f):this._metadata={range:new kv({top:Math.min.apply(Math,v(y)),bottom:Math.max.apply(Math,v(y))}),previousComplete:!1}),l.hasNext=f.length>=this._limit,this._metadata&&(l.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",l),n.next=15,this.saveMetadata();case 15:n.next=21;break;case 17:throw n.prev=17,n.t0=n.catch(4),m.debug("message background next sync error",n.t0),n.t0;case 21:return n.prev=21,g.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:s.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=p.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.finish(21);case 24:return n.abrupt("return",l);case 25:case"end":return n.stop()}}),n,this,[[4,17,21,24]])})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=_.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 kv({})}},{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,v(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,v(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{range:new kv(r.range),previousComplete:r.previousComplete}:{range:new kv({}),previousComplete:!1};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,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.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,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now(),i=es.of(this._iid),s=i.logger,o=i.sessionManager;i.cacheContext.localCacheEnabled&&o.session.hasSession&&(s.debug("message background sync resume()"),this._prevSyncLoopCount=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(){es.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 Iv[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n){return Iv[e]||(Iv[e]={}),Iv[e][n.url]||(Iv[e][n.url]=new t({_iid:e,channel:n})),Iv[e][n.url].ref++,Iv[e][n.url]}},{key:"clear",value:function(e,t){Iv[e]&&Iv[e][t]&&(Iv[e][t].close(),delete Iv[e])}}])}(),Av={},Mv=function(){function t(n){var a=this,i=n._iid,s=n.channel,o=n.includeParams;r(this,t),this.ref=0,this._iid=i,this._channel=s,this._includeParams=o;var u,c,l=es.of(this._iid),h=l.logger,f=l.sdkState,p=l.dispatcher;this._metadataKey=(u=f.userId,c=s.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var v=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(f.userId,this._channel.url);this._sync=new Tv(v,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,a=nh.of(this._iid),t.next=8,a.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:e.ReplyType.ALL},this._includeParams),e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,s=i.updatedMessages,o=i.deletedMessageIds,u=i.hasMore,c=i.token,r.hasNext=u,r.nextToken=c,(s.length>0||o.length>0)&&this._metadata&&(this._metadata.token=c),h.debug("message changelog sync progress",r),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),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",r);case 29:case"end":return t.stop()}}),t,this,[[4,21]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.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=es.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){es.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Av[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n,r){return Av[e]||(Av[e]={}),Av[e][n.url]||(Av[e][n.url]=new t({_iid:e,channel:n,includeParams:r})),Av[e][n.url].ref++,Av[e][n.url]}},{key:"clear",value:function(e,t){Av[e]&&Av[e][t]&&(Av[e][t].close(),delete Av[e])}}])}(),Ov={},Uv=function(){function e(t){var n=this,a=t._iid,i=t.channel,s=t.hasPollMessage;r(this,e),this.ref=0,this._iid=a,this._channel=i;var o,u,c=es.of(this._iid),l=c.logger,h=c.sdkState,f=c.dispatcher;this._metadataKey=(o=h.userId,u=i.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new Tv(p,(function(){return E(n,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o,u,c,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(l.debug("poll changelog sync from",null===(t=this._metadata)||void 0===t?void 0:t.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,s();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return r={hasNext:!1,nextToken:0},e.abrupt("return",r);case 12:return this._metadata||(a=es.of(this._iid),i=a.firstConnectedAt,this._metadata={token:i}),e.prev=13,o=Wc.of(this._iid),e.next=17,o.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return u=e.sent,c=u.hasMore,h=u.token,n.hasNext=c,n.nextToken=h,this._metadata.token=h,l.debug("poll changelog sync progress",n),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),l.debug("poll changelog sync error",e.t1),!(e.t1 instanceof 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",n);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)n.resume();else n.pause()}))}return i(e,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{token:r.token}:void 0;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){es.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){es.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 Ov[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Ov[t]||(Ov[t]={}),Ov[t][n.url]||(Ov[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Ov[t][n.url].ref++,Ov[t][n.url]}}])}(),Dv=function(t){function a(t){var i,s,o,u,c,l,d,h,f,p,v;return r(this,a),(i=n(this,a)).method=_e.GET,i.path="".concat(Le(t.channelType),"/").concat(t.channelUrl,"/messages_gap"),i.params=pe({prev_start_ts:t.prevStart,prev_end_ts:t.prevEnd,prev_cache_count:t.prevCount,next_start_ts:t.nextStart,next_end_ts:t.nextEnd,next_cache_count:t.nextCount,huge_gap_threshold:null!==(s=t.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(o=t.customTypes)&&void 0!==o?o:["*"],message_type:null!==(u=t.messageType)&&void 0!==u?u:null,include_reply_type:null!==(c=t.replyType)&&void 0!==c?c:e.ReplyType.NONE,include_reactions:null===(l=t.includeReactions)||void 0===l||l,include_meta_array:null===(d=t.includeMetaArray)||void 0===d||d,include_thread_info:null===(h=t.includeThreadInfo)||void 0===h||h,include_parent_message_info:null===(f=t.includeParentMessageInfo)||void 0===f||f,with_sorted_meta_array:null===(p=t.includeMetaArray)||void 0===p||p,show_subchannel_messages_only:null!==(v=t.showSubchannelMessagesOnly)&&void 0!==v&&v,include_poll_details:!0,checking_continuous_messages:t.checkingContinuousMessages}),i}return c(a,t),i(a)}(je),Rv=function(e){function t(e,a){var i,s,o,u,c,l,d;return r(this,t),(i=n(this,t,[e,a])).isHugeGap=a.is_huge_gap,i.prevMessages=(null!==(s=a.prev_messages)&&void 0!==s?s:[]).map((function(t){return ho(e,t)})),i.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,i.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,i.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return ho(e,t)})),i.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,i.isContinuousNextMessages=null!==(d=a.is_continuous_next_messages)&&void 0!==d&&d,i}return c(t,e),i(t)}(Ve),Lv={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var Pv,Fv,qv,Hv=function(){return i((function e(){r(this,e),this._onCacheResult=ht,this._onApiResult=ht}),[{key:"_invokeResponse",value:function(e,t,n){var r=this;hi((function(){return E(r,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next="local"===r.t0?3:"remote"===r.t0?5:7;break;case 3:return this._onCacheResult(t,n),r.abrupt("break",7);case 5:return this._onApiResult(t,n),r.abrupt("break",7);case 7:case"end":return r.stop()}}),r,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}])}(),Gv=function(){return i((function t(n,a){var i=this,o=a.filter,u=a.startingPoint,c=a.limit,l=a.prevResultLimit,h=a.nextResultLimit,f=a.channel,p=a.channelManager,_=a.disableBackgroundSync,m=void 0!==_&&_;r(this,t),this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=n,this._key="mc-".concat(ce()),this._isDisposed=!1,this.filter=null!=o?o:new Pd,this._channel=f,this._syncRange=new kv({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof u&&Number.isFinite(u)?u:Number.MAX_SAFE_INTEGER,this._limit=c||100,this._prevResultLimit=null!=l?l:Math.floor(this._limit/2),this._nextResultLimit=null!=h?h:Math.floor(this._limit/2),this._channelManager=p;var g=es.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(t,n){var r=n.source,a=t.findIndex((function(e){return e.isIdentical(i.channel)}));a>=0&&(i._replaceChannelOfCollection(t[a]),i.channel._runIfHandleableWithGroupChannel((function(t){switch(r){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:for(var a=!1,s=0;s=t.messageOffsetTimestamp){a=!0;var o=s;if(o>0){var u=i._messages.splice(0,o);i._removeMessagesFromView(u.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!a&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.CollectionEventSource.EVENT_CHANNEL_UNMUTED:var c=es.of(i._iid).sdkState,l=n.user;c.userId===l.userId&&i._clearCheckMyMutedTimer();break;case e.CollectionEventSource.EVENT_CHANNEL_MUTED:var h=es.of(i._iid).sdkState,f=n.user;h.userId===f.userId&&-1!==t._myMutedRemainingTime&&i._startCheckMyMutedTimer(t._myMutedRemainingTime);break;case e.CollectionEventSource.EVENT_CHANNEL_LEFT:t.isPublic&&i._clearCheckMyMutedTimer()}hi((function(){return E(i,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:mp(r)&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelUpdated)&&this._handler.onChannelUpdated(n,this.channel);case 1:case"end":return e.stop()}}),e,this)})))}))})),i._postprocessChannelUpdateEvent(t[a],r))},onRemove:function(e,t){var n=e.indexOf(i.channel.url);n>=0&&(i._clearCheckMyMutedTimer(),hi((function(){return E(i,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url);case 1:case"end":return e.stop()}}),e,this)})))})),i._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],o=[],u=s(t);try{for(u.s();!(r=u.n()).done;){var c=r.value;c.channelUrl===i._channel.url&&(i.filter.match(c)?a.push(c):o.push(i.keyOf(c)))}}catch(e){u.e(e)}finally{u.f()}if(Ms(n)){if(a.length>0)switch(n){case e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.CollectionEventSource.EVENT_MESSAGE_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.CollectionEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}o.length>0&&i._removeMessagesFromView(o,n)}i._postprocessMessageUpdateEvent(t,n)},onRemove:function(e,t){i._removeMessagesFromView(e,t),i._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:function(e,t){i._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){i._applyThreadInfoEventToView(e,t)}});var y=es.of(this._iid),k=y.cacheContext,b=y.dispatcher,C=y.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),b.dispatch(new gp({channels:[this._channel],context:{source:e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Nv.of(this._iid,this._channel),!m&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=Mv.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Uv.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Tv(this._key,(function(t){return E(i,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,C.run("message-fill-sync-".concat(f.url,"-prev"),(function(){return E(r,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._getRemoteMessages(t,{prevLimit:this._prevResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:k.localCacheEnabled});case 2:if(s=n.sent,o=s.messages,u=s.isContinuousMessages,!(o.length>0)){n.next=10;break}return c=Math.min.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:o.length>=this._prevResultLimit&&this.viewTop0)){n.next=10;break}return c=Math.max.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:!(o.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>c,nextToken:this._syncRange.bottom});case 10:return k.localCacheEnabled&&g.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=k.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:k.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.abrupt("return",{hasNext:!1,nextToken:0});case 12:case"end":return n.stop()}}),n,this)})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=b.on((function(e){if(e instanceof La)switch(e.stateType){case Aa.CONNECTED:fi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._activate();case 1:case"end":return e.stop()}}),e,this)})))}));break;case Aa.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}}))}),[{key:"keyOf",value:function(e){return 0}},{key:"changelogIncludeParams",get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}},{key:"_postprocessChannelUpdateEvent",value:function(e,t){}},{key:"_postprocessChannelRemoveEvent",value:function(e){}},{key:"_postprocessMessageUpdateEvent",value:function(e,t){}},{key:"_postprocessMessageRemoveEvent",value:function(e){}},{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return v(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,v(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,v(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"_activate",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),n.logger.debug("check huge gap"),this._checkHugeGap(),t.next=5,this._refreshChannel(e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_replaceChannelOfCollection",value:function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}},{key:"_shouldStartBackgroundSync",value:function(){var e=es.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}},{key:"_setBaseMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n instanceof Ws&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,t){var n,r=this,a=[],i=s(e);try{for(i.s();!(n=i.n()).done;){var o=n.value,u=xv(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c.isUserMessage()&&c.applyPoll(o),a.push(c)}}}catch(e){i.e(e)}finally{i.f()}return a.length>0&&Ms(t)&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},a.length>0&&(null===(r=(n=this._handler).onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,a));case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_applyPollUpdateEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollUpdateEvent(e)&&Ms(t)&&hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollVoteEvent(e)&&Ms(t)&&hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyReactionEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ms(t)&&(a.applyReactionEvent(e),hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_applyThreadInfoEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.targetMessageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ms(t)&&(a.applyThreadInfoUpdateEvent(e),hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_removeMessagesFromView",value:function(e,t){var n,r=this,a=[],i=[],o=s(e);try{var u=function(){var e=n.value,t=r._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var s=r._messages[t];a.push(r.keyOf(s)),i.push(s),r._messages.splice(t,1)}};for(o.s();!(n=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return Ms(t)&&i.length>0&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===r||r.call(n,s,this.channel,a,i);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,t){var n=t.prevLimit,r=void 0===n?0:n,a=t.nextLimit,i=void 0===a?0:a,s=t.inclusive,o=void 0===s||s;return E(this,void 0,void 0,d().mark((function t(){var n,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!o){t.next=5;break}return t.next=4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter);case 4:n=t.sent;case 5:if(!(r>0)){t.next=11;break}return t.next=8,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r,!1);case 8:t.t0=t.sent,t.next=12;break;case 11:t.t0=[];case 12:if(a=t.t0,!(i>0)){t.next=19;break}return t.next=16,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,i,!1);case 16:t.t1=t.sent,t.next=20;break;case 19:t.t1=[];case 20:return s=t.t1,t.abrupt("return",{messages:[].concat(v(n),v(a),v(s)).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:a.length,nextMessagesCount:s.length});case 22:case"end":return t.stop()}}),t,this)})))}},{key:"_getRemoteMessages",value:function(t,n){var r=n.prevLimit,a=void 0===r?0:r,i=n.nextLimit,s=void 0===i?0:i,o=n.source,u=void 0===o?e.CollectionEventSource.REQUEST_MESSAGE:o,c=n.reverse,l=void 0!==c&&c,h=n.checkingHasNext,f=void 0!==h&&h,p=n.checkingContinuousMessages,v=void 0!==p&&p;return E(this,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=nh.of(this._iid),!(a>0||s>0)){e.next=7;break}return e.next=4,n._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,t,ve(Object.assign(Object.assign(Object.assign({},this.filter),Lv),{isInclusive:!0,reverse:l,prevResultSize:a,nextResultSize:s})),u,f,v);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 t,n,r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,_,m,g,y,k,b,C,w,x,S,T,I,N,M,O,U,D=this;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(o=es.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=o.cacheContext,h=o.statManager,f=o.logger,!(this._messages.length>0)){s.next=25;break}return p=this._syncRange.top,_=this.viewTop,m=this._syncRange.bottom,g=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,s.next=8,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,_,p);case 8:return y=s.sent,s.next=11,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,m,g);case 11:return k=s.sent,s.prev=12,s.next=15,yi((function(){return E(D,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,h,f,b,C,w,x,S,T,I,N,A,M=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Dv(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:_,prevEnd:p,prevCount:y,nextStart:m,nextEnd:g,nextCount:k,checkingContinuousMessages:l.localCacheEnabled},this.filter),Lv)),t.next=3,c.send(r);case 3:a=t.sent,i=a.as(Rv),s=i.isHugeGap,o=i.prevMessages,h=void 0===o?[]:o,f=i.prevHasMore,b=i.isContinuousPrevMessages,C=i.nextMessages,w=void 0===C?[]:C,x=i.nextHasmore,S=i.isContinuousNextMessages,s?hi((function(){return E(M,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this._handler)||void 0===t?void 0:t.onHugeGapDetected)&&this._handler.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(T=this.viewTop,I=this.viewBottom,N=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,T].concat(v(h.map((function(e){return e.createdAt}))))),A=Math.max.apply(Math,[0,I].concat(v(w.map((function(e){return e.createdAt}))))),u.dispatch(new Os({messages:h,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),u.dispatch(new Os({messages:w,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(N,A),(b||S)&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(N,A)),f&&this._prevFill.start(N),x&&this._nextFill.start(A));case 6:case"end":return t.stop()}}),t,this)})))}),1);case 15:s.next=20;break;case 17:s.prev=17,s.t0=s.catch(12),f.debug("Failed HugeGap Check ",s.t0);case 20:return s.prev=20,l.localCacheEnabled&&h.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(t=l.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(20);case 23:s.next=42;break;case 25:return b=Date.now(),s.prev=26,s.next=29,this._getRemoteMessages(b,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled});case 29:if(C=s.sent,w=C.messages,x=C.isContinuousMessages,S=C.hasNext,w.length>0){for(I=w.map((function(e){return e.createdAt})),N=0,M=0,O=0;O=b&&M++;this._hasPrevious=N>=this._prevResultLimit,this._hasNext=null!=S?S:M>=this._nextResultLimit,(T=this._syncRange).extends.apply(T,v(I)),x&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(w,e.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;s.next=39;break;case 36:s.prev=36,s.t1=s.catch(26),s.t1 instanceof A&&s.t1.code===e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 39:return s.prev=39,l.localCacheEnabled&&h.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=l.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(39);case 42:case"end":return s.stop()}}),s,this,[[12,17,20,23],[26,36,39,42]])})))}},{key:"_loadUnsentMessages",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter);case 2:this._unsentMessages=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1);case 2:if(!(e.sent.length>0)){e.next=5;break}return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.logger,n.prev=1,n.next=4,this._channelManager.refreshChannel(this.channel.url,!0,e,t);case 4:n.next=9;break;case 6:n.prev=6,n.t0=n.catch(1),a.warn("Failed to refresh channel",n.t0);case 9:case"end":return n.stop()}}),n,this,[[1,6]])})))}},{key:"_startCheckMyMutedTimer",value:function(t){var n=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=void 0,n=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:r=t.sent,n=!r.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),n=!0;case 12:return t.prev=12,n&&(a=es.of(this._iid),i=a.sessionManager,this.channel._runIfHandleableWithGroupChannel((function(t){var n,r;t.myMutedState=e.MutedState.UNMUTED;var a={source:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i.currentUser};null===(r=null===(n=s._handler)||void 0===n?void 0:n.onChannelUpdated)||void 0===r||r.call(n,a,s.channel)}))),t.finish(12);case 15:case"end":return t.stop()}}),t,this,[[2,9,12,15]])})))}),t+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}},{key:"_setHasNextAndHasPrevious",value:function(e,t){for(var n=e.map((function(e){return e.createdAt})),r=0,a=0,i=0;ithis._startingPoint&&a++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=t?t:a>=this._nextResultLimit}},{key:"initialize",value:function(t){var n=this,r=new Hv;this._messages=[],this._unsentMessages=[],this._syncRange=new kv({}),this._hasNext=!0,this._hasPrevious=!0;var a=[],i={messages:[],prevMessagesCount:0,nextMessagesCount:0};return hi((function(){return E(n,void 0,void 0,d().mark((function n(){var s,o,u,c,l,h=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,null===(s=this._backgroundSync)||void 0===s?void 0:s.loadMetadata();case 2:o=n.sent,u=es.of(this._iid),c=u.cacheContext,l=u.statManager,n.t0=t,n.next=n.t0===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API?7:9;break;case 7:return this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(t){return E(h,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=t,a=this._filterUnderOffsetMessage(i.messages),this._addMessagesToView(a,e.CollectionEventSource.REQUEST_MESSAGE),n.next=5,this._loadUnsentMessages();case 5:r._invokeResponse("local",null,a);case 6:case"end":return n.stop()}}),n,this)})))})).catch((function(e){if(N(e))throw e;r._invokeResponse("local",e,null)})).finally((function(){return E(h,void 0,void 0,d().mark((function n(){var s,u,c,h,f,p,_,m,g=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return c=es.of(this._iid),h=c.cacheContext,f=!0,p=!0,_=!1,h.localCacheEnabled&&a.length>0&&(m=o.range).includes.apply(m,v(a.map((function(e){return e.createdAt}))))&&(!o.previousComplete&&i.prevMessagesCounto.range.bottom||i.nextMessagesCount=e._latestMessageInfo.createdAt&&(p=!1)})),p?(f=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled}).then((function(t){var n,a,i,s=t.messages,o=t.isContinuousMessages,u=t.hasNext,c=g._filterUnderOffsetMessage(s);(g._messages=[],c.length>0)?(g._setHasNextAndHasPrevious(c,u),(i=g._syncRange).extends.apply(i,v(c.map((function(e){return e.createdAt})))),o&&(null===(n=g._backgroundSync)||void 0===n?void 0:n.range.overlap(g._syncRange))&&(null===(a=g._backgroundSync)||void 0===a||a.range.extends(g._syncRange.top,g._syncRange.bottom)),g._addMessagesToView(c,e.CollectionEventSource.REQUEST_MESSAGE)):(g._hasPrevious=!1,g._hasNext=!1);r._invokeResponse("remote",null,c)})).catch((function(e){if(N(e))throw e;r._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(a),r._invokeResponse("remote",null,a)),h.localCacheEnabled&&l.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:f?"cache_hit":"cache_miss",max_db_size:null!==(u=null===(s=h.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==u?u:0,message_init_policy:t,use_local_cache:h.localCacheEnabled,collection_id:this._key}}));case 10:case"end":return n.stop()}}),n,this)})))})),n.abrupt("break",9);case 9:l.put(new Bi({type:Ge.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message_init_policy:t,message:!0}}}));case 10:case"end":return n.stop()}}),n,this)})))})),r}},{key:"loadPrevious",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=es.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasPrevious){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingPrevious){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingPrevious=!0,c=this.viewTop,l=[],a.next=13,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{prevLimit:this._prevResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._prevResultLimit,s.localCacheEnabled&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=es.of(this._iid),s=i.cacheContext,e.next=3,this._getRemoteMessages(c,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:s.localCacheEnabled});case 3:u=e.sent,(l=this._filterUnderOffsetMessage(u.messages)).length>0&&((h=this._syncRange).extends.apply(h,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&u.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top))),l=l.filter((function(e){return wv(p._messages,e)<0})),this._hasPrevious=l.length>=this._prevResultLimit,f&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(r=s.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasPrevious=l.length>=this._prevResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingPrevious=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"loadNext",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=es.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasNext){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingNext){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingNext=!0,c=this.viewBottom,l=[],a.next=13,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{nextLimit:this._nextResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._nextResultLimit,s.localCacheEnabled&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p,_=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=es.of(this._iid),u=s.cacheContext,e.next=3,this._getRemoteMessages(c,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:u.localCacheEnabled});case 3:h=e.sent,(l=this._filterUnderOffsetMessage(h.messages)).length>0&&((p=this._syncRange).extends.apply(p,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.bottom))),l=l.filter((function(e){return wv(_._messages,e)<0})),this._hasNext=null!==(r=h.hasNext)&&void 0!==r?r:l.length>=this._nextResultLimit,f&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(i=null===(a=u.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:u.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasNext=l.length>=this._nextResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingNext=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"removeFailedMessage",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:return n.next=4,this._channelManager.removeFailedMessageFromCache(t);case 4:(r=this._unsentMessages.findIndex((function(e){return e.reqId===t})))>-1&&this._unsentMessages.splice(r,1);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=this;if(!this._isDisposed){this._isDisposed=!0;var i=es.of(this._iid),s=i.cacheContext,o=i.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(t){t.myMemberState!==e.MemberState.NONE&&(a._channel._updateMessageCollectionLastAccessedAt(),o.dispatch(new gp({channels:[a._channel],context:{source:e.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}}])}(),jv=function(t){function a(e,t){return r(this,a),n(this,a,[e,Object.assign(Object.assign({},t),{channelManager:Cv.of(e)})])}return c(a,t),i(a,[{key:"keyOf",value:function(e){return e.messageId}},{key:"initialize",value:function(e){var t=this;return fi((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),p(a,"initialize",this,3)([e])}},{key:"setMessageCollectionHandler",value:function(e){this._setBaseMessageCollectionHandler(e)}},{key:"_activate",value:function(){var e=this,t=Object.create(null,{_activate:{get:function(){return p(a,"_activate",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t._activate.call(this);case 2:return e.next=4,fi((function(){return E(n,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_addMessagesToView",value:function(t,n){var r,a=this,i=this._filterUnderOffsetMessage(t),o=[],u=[],c=s(i);try{for(c.s();!(r=c.n()).done;){var l=r.value;if(n===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(wv(this._messages,l)<0){wv(this._unsentMessages,l)<0&&o.push(l);var h=Sv(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ys){wv(this._unsentMessages,l)<0&&wv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var f=wv(this._messages,l);if(f<0){var p=wv(this._unsentMessages,l);p<0?o.push(l):(this._unsentMessages.splice(p,1),u.push(l));var _=Sv(this._messages,l);this._messages.splice(_,0,l)}else u.push(l),this._messages[f]=l;if(l.updatedAt>0){var m=this._updateChildMessagesInView(l);u.push.apply(u,v(m))}}else if(l instanceof Ys){var g=wv(this._unsentMessages,l);g<0?wv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[g]=l)}}}catch(e){c.e(e)}finally{c.f()}Ms(n)&&hi((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:n},o.length>0&&(null===(r=null===(t=this._handler)||void 0===t?void 0:t.onMessagesAdded)||void 0===r||r.call(t,s,this.channel,o)),u.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateMessagesToView",value:function(e,t){var n,r=this,a=[],i=[],o=[],u=s(e);try{for(u.s();!(n=u.n()).done;){var c=n.value;if(c.messageId>0){var l=wv(this._messages,c);if(l>=0)i.push(c),this._messages[l]=c;else{var h=wv(this._unsentMessages,c);if(h>=0){var p=f(this._unsentMessages.splice(h,1),1)[0];if(this.hasNext&&p)o.push(p);else{i.push(c);var _=Sv(this._messages,c);this._messages.splice(_,0,c)}}else{var m=this._messages.map((function(e){return e.createdAt}));(c.createdAtMath.max.apply(Math,v(m))&&!this._hasNext)&&a.push(c)}}}else if(c instanceof Ys){var g=wv(this._unsentMessages,c);g>=0&&(i.push(c),this._unsentMessages[g]=c)}}}catch(e){u.e(e)}finally{u.f()}return Ms(t)&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c={source:t},i.length>0?null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,c,this.channel,i):o.length>0?null===(u=null===(s=this._handler)||void 0===s?void 0:s.onMessagesDeleted)||void 0===u||u.call(s,c,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t);case 2:case"end":return e.stop()}}),e,this)})))})),i}}])}(Gv),Vv={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},zv=function(e){return D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isDiscoverable,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},Bv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,d=e.nicknameStartsWithFilter,h=e.operatorFilter;return(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/members"),a.params={token:s,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:d,operator_filter:h,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return c(t,e),i(t)}(je),Kv=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).members=[];var s=a.next,o=a.members;return i.token=s,o&&o.length>0&&(i.members=o.map((function(t){return new Zf(e,t)}))),i}return c(t,e),i(t)}(Ve);e.MutedMemberFilter=void 0,(Pv=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",Pv.MUTED="muted",Pv.UNMUTED="unmuted",e.MemberListOrder=void 0,(Fv=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",Fv.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(qv=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",qv.JOINED="joined_only",qv.INVITED="invited_only",qv.INVITED_BY_FRIEND="invited_by_friend",qv.INVITED_BY_NON_FRIEND="invited_by_non_friend";var Qv,Wv,Yv=function(t){function a(t,i,s){var o,u,c,l,d;return r(this,a),(o=n(this,a,[t,i,e.ChannelType.GROUP,s])).mutedMemberFilter=e.MutedMemberFilter.ALL,o.memberStateFilter=e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null,o.operatorFilter=e.OperatorFilter.ALL,o.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o.mutedMemberFilter=null!==(u=s.mutedMemberFilter)&&void 0!==u?u:e.MutedMemberFilter.ALL,o.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,o.order=null!==(d=s.order)&&void 0!==d?d:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R(e.MutedMemberFilter,this.mutedMemberFilter)&&R(e.MemberStateFilter,this.memberStateFilter)&&(D("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&R(e.OperatorFilter,this.operatorFilter)&&R(e.MemberListOrder,this.order)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new Bv(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Kv),s=i.members,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),Zv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/accept"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(je),Xv=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).channel=new E_(t,i),s.channel.myMemberState=e.MemberState.JOINED,s}return c(a,t),i(a)}(Ve),Jv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,d=e.accessCode,h=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a.params=pe({is_distinct:s,is_public:o,is_discoverable:u,name:h,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:d,operator_ids:v,message_survival_seconds:_}),a}return c(t,e),i(t)}(je),$v=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),e_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(je),t_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a}return c(t,e),i(t)}(je),n_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.countPreference;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:o},a}return c(t,e),i(t)}(je),r_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).countPreference=a.count_preference,i}return c(t,e),i(t)}(Ve),a_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.locale;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/reset_user_history"),a.params=pe({locale:s}),a}return c(t,e),i(t)}(je),i_=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(Ve),s_=Object.assign(Object.assign({},nu),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),o_=function(e){return ru(e)&&D("number",e.scheduledAt,!0)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},u_=Object.assign(Object.assign({},au),{scheduledAt:void 0}),c_=function(e){return iu(e)&&D("number",e.scheduledAt,!0)},l_=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl,d=t.scheduledMessageId;return i.method=_e.PUT,i.path="".concat(Le(c),"/").concat(encodeURIComponent(l),"/scheduled_messages/").concat(encodeURIComponent(d)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return ns.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(je),d_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new fo(e,a),i}return c(t,e),i(t)}(Ve),h_=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.PUT,i.path="".concat(Le(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(je),f_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.DELETE,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(je),p_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return c(t,e),i(t)}(je),v_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:o},a}return c(t,e),i(t)}(je),__=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(Ve),m_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),g_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(Ve);e.CountPreference=void 0,(Qv=e.CountPreference||(e.CountPreference={})).ALL="all",Qv.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Qv.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Qv.OFF="off",e.HiddenState=void 0,(Wv=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",Wv.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Wv.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var y_,E_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y,E,k,b,C,w,x,S,T;(r(this,a),(s=n(this,a,[t,i]))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s._hasBotInfo={general:!1,ai:!1},s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isChatNotification=!1,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.totalUnreadReplyCount=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.lastPinnedMessage=null,s._latestMessageInfo=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(o=i.is_distinct)&&void 0!==o&&o,s.isSuper=null!==(u=i.is_super)&&void 0!==u&&u,s.isBroadcast=null!==(c=i.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=i.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(d=i.is_public)&&void 0!==d&&d,s.isDiscoverable=null!==(h=i.is_discoverable)&&void 0!==h?h:s.isPublic,s.isChatNotification=null!==(f=i.is_chat_notification)&&void 0!==f&&f,s.isAccessCodeRequired=null!==(p=i.is_access_code_required)&&void 0!==p&&p,s.isPushEnabled=null!==(_=i.is_push_enabled)&&void 0!==_&&_,Array.isArray(i.members))&&(T=s.members).push.apply(T,v(i.members.map((function(e){return new Zf(s._iid,e)}))));return s.memberCount=null!==(m=i.member_count)&&void 0!==m?m:0,s.joinedMemberCount=null!==(g=i.joined_member_count)&&void 0!==g?g:0,s.hiddenState=R(e.HiddenState,i.hidden_state)?i.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(y=i.ts_message_offset)&&void 0!==y?y:0,s.messageSurvivalSeconds=null!==(E=i.message_survival_seconds)&&void 0!==E?E:-1,s.lastMessage=i.last_message?ho(s._iid,Object.assign({channel_type:s.channelType},i.last_message)):null,i.read_receipt&&Object.keys(i.read_receipt).forEach((function(e){D("number",i.read_receipt[e])&&s._updateUnreadMemberState(e,i.read_receipt[e])})),i.delivery_receipt&&Object.keys(i.delivery_receipt).forEach((function(e){D("number",i.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,i.delivery_receipt[e])})),s.myMemberState=R(e.MemberState,i.member_state)?i.member_state:e.MemberState.NONE,s.myRole=R(e.Role,i.my_role)?i.my_role:e.Role.NONE,R(e.MutedState,i.is_muted)?s.myMutedState=i.is_muted:D("boolean",i.is_muted)?s.myMutedState=i.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=R(e.CountPreference,i.count_preference)?i.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=R(e.PushTriggerOption,i.push_trigger_option)?i.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=i.user_last_read)&&void 0!==k?k:0,s.inviter=i.inviter?new si(s._iid,i.inviter):null,s.invitedAt=null!==(b=i.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(C=i.joined_ts)&&void 0!==C?C:0,s._updateUnreadCount(null!==(w=i.unread_message_count)&&void 0!==w?w:0,null!==(x=i.unread_mention_count)&&void 0!==x?x:0),s.totalUnreadReplyCount=null!==(S=i.total_unread_thread_message_count)&&void 0!==S?S:0,s.lastPinnedMessage=i.latest_pinned_message?ho(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,i.latest_message&&(s._latestMessageInfo={messageId:i.latest_message.message_id,createdAt:i.latest_message.created_at}),s._hasBotInfo={general:!!i.has_bot,ai:!!i.has_ai_bot},s}return c(a,t),i(a,[{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=s(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=s(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"hasBot",get:function(){return this._hasBotInfo.general}},{key:"hasAiBot",get:function(){return this._hasBotInfo.ai}},{key:"_shouldUpdateLastMessageWith",value:function(t){if(t.silent)return!1;var n=es.of(this._iid).appInfo;switch(null==n?void 0:n.lastMessageThreadingPolicy){case e.LastMessageThreadingPolicy.NONE:case e.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case e.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(t.parentMessageId>0)return!1;break;case e.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof Ys&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case e.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof Ys&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}},{key:"_updateLastMessage",value:function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}},{key:"_updateUnreadCount",value:function(t,n){if("number"==typeof t&&t>=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=es.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=es.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return ni(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new jv(this._iid,Object.assign(Object.assign({},e),{channel:this}))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Yv(this._iid,this.url,e)}},{key:"createThreadedParentMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ph(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 Zf?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 Ys&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=es.of(this._iid).sdkState,a=t.createdAt,i=0,o=s(this.members);try{for(o.s();!(n=o.n()).done;){var u=n.value;if(r.userId!==u.userId&&u.state===e.MemberState.JOINED&&t.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=es.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ys?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o>=e.createdAt&&i.push(s)}})),i}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=es.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ys?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o0&&void 0!==arguments[0]&&arguments[0],n=es.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 i=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new gs(e._iid,{channel_url:e.url,channel_type:e.channelType,user:Zf.payloadify(a),ts:null!=i?i:0})}})),r}},{key:"getDeliveryStatus",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=es.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 i=e._undeliveredMemberStateMap.get(a.userId);r[a.userId]=new Xf(e._iid,{channel_url:e.url,channel_type:e.channelType,user:Zf.payloadify(a),ts:null!=i?i: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=es.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,i){var s=a.ts;n-s>=t&&(e._typingStatus.delete(i),r=!0)})),r}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._refresh());case 1:case"end":return e.stop()}}),e,this)})))}},{key:"_refresh",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Cp({channelUrl:this.url}),n.next=4,a.send(s);case 4:return o=n.sent,u=o.as(wp),c=u.channel,this._update(c),t||i.dispatch(new gp({channels:[c],context:{source:e.CollectionEventSource.REFRESH_CHANNEL}})),n.abrupt("return",this);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"freeze",value:function(){var t=this,n=Object.create(null,{freeze:{get:function(){return p(a,"freeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.freeze.call(this);case 2:r=es.of(this._iid),r.dispatcher.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"unfreeze",value:function(){var t=this,n=Object.create(null,{unfreeze:{get:function(){return p(a,"unfreeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.unfreeze.call(this);case 2:r=es.of(this._iid),r.dispatcher.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannel",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Vv),t),ai(zv(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new Jv(Object.assign({channelUrl:this.url},r)),n.next=6,s.send(o);case 6:return u=n.sent,c=u.as($v),l=c.channel,this._update(l),i.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(e.every((function(e){return e instanceof si}))).throw(A.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"inviteWithUserIds",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(P("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.requestQueue,s=r.sessionManager,o=new Wp({channelUrl:this.url,userIds:t}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.as(Yp),l=c.channel,this._update(l),a.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:s.currentUser,invitees:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"join",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",t,!0)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Vp({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(zp),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"leave",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Kp({channelUrl:this.url,userId:a.userId,shouldRemoveOperatorStatus:t}),n.next=4,i.send(s);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return n.stop()}}),n,this)})))}},{key:"acceptInvitation",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",t,!0)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Zv({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(Xv),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"declineInvitation",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Xp({channelUrl:this.url,userId:r.userId}),t.next=4,a.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"sendUserMessage",this,3)([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){s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),Cv.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"updateUserMessage",value:function(t,n){var r=this,i=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=es.of(this._iid),s=a.dispatcher,r.next=3,i.updateUserMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Cv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new gp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Cv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Os({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"_autoResendUserMessage",this,3)([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 a=Cv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"sendFileMessage",this,3)([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 a=Cv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new ol,i=es.of(this._iid).dispatcher;return p(a,"sendMultipleFilesMessage",this,3)([t]).onPending((function(e){r._trigger(e)})).onFailed((function(e,t){r._triggerFailed(e,t)})).onSucceeded((function(t){var a=Cv.of(n._iid);n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(t,n){var r=this,i=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=es.of(this._iid),s=a.dispatcher,r.next=3,i.updateFileMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Cv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new gp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Cv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Os({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"_autoResendFileMessage",this,3)([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 a=Cv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"deleteMessage",value:function(t){var n=this,r=Object.create(null,{deleteMessage:{get:function(){return p(a,"deleteMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.deleteMessage.call(this,t);case 2:0===t.messageId&&t instanceof Ys&&(a=es.of(this._iid),a.dispatcher.dispatch(new Ls({reqId:t.reqId,source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"hide",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},$p),t),ai(ev(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new tv(Object.assign({channelUrl:this.url,userId:s.userId},r)),n.next=6,o.send(u);case 6:return c=n.sent,l=c.as(nv),h=l.messageOffsetTimestamp,this.hiddenState=r.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,r.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),i.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),n.abrupt("return",this);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"unhide",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new t_({channelUrl:this.url}),t.next=4,a.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,r.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new e_({channelUrl:this.url}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.sdkState,a=n.dispatcher,i=n.requestQueue,s=new ys({channelUrl:this.url}),t.next=4,i.send(s);case 4:o=t.sent,u=o.as(Es),c=u.readStatus,this._updateUnreadMemberState(r.userId,c.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Cv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)}))),a.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new vv({channelUrl:this.url,userId:n.userId}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=es.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingStarted>=r)){e.next=8;break}return this._typingStarted=a,this._typingEnded=0,i=new av({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=es.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingEnded>=r)){e.next=8;break}return this._typingStarted=0,this._typingEnded=a,i=new sv({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Hd),e),ai(function(e){return Qo(e)&&D("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new qo;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},u_),t),ai(c_(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new h_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(_c),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createScheduledFileMessage",value:function(e){var t=this;e=Object.assign(Object.assign({},Gd),e),ai(function(e){return Go(e)&&D("number",e.scheduledAt)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(A.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new qo;return mi(2).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);hi((function(){return E(t,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a._trigger(i));case 1:case"end":return e.stop()}}),e)})))}))})),H(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a}},{key:"updateScheduledFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Object.assign(Object.assign({},s_),t),ai(o_(r)).throw(A.invalidParameters),!H(r.file)){n.next=5;break}return n.next=5,this._uploadFileAndUpdateParams(r);case 5:return a=new l_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),i=es.of(this._iid),s=i.requestQueue,n.next=9,s.send(a);case 9:return o=n.sent,u=o.as(d_),c=u.message,n.abrupt("return",c);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new f_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=es.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new p_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=es.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new m_({userId:n.userId,channelUrl:this.url}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(g_),o=s.pushTriggerOption,this.myPushTriggerOption=o,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new v_({userId:i.userId,channelUrl:this.url,pushTriggerOption:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(__),l=c.pushTriggerOption,this.myPushTriggerOption=l,a.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"setMyCountPreference",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.CountPreference,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new n_({channelUrl:this.url,userId:i.userId,countPreference:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(r_),l=c.countPreference,this.myCountPreference=l,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),a.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"resetMyHistory",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=n.sdkState,s=new a_({channelUrl:this.url,locale:i.localeForChatbot}),t.next=4,a.send(s);case 4:return o=t.sent,u=o.as(i_),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,this.lastMessage&&this.lastMessage.createdAt=this._limit&&!!b,h.nextToken=b,this._metadata&&(this._metadata.token=b,(C=this._metadata.range).extends.apply(C,v(k.map((function(e){return e.createdAt})))),this._metadata.completed=!h.hasNext),f.debug("channel background sync progress",h),t.next=30,this.saveMetadata();case 30:t.next=39;break;case 32:if(t.prev=32,t.t1=t.catch(6),f.debug("channel background sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=38;break}return t.next=38,this.clearMetaData();case 38:throw t.t1;case 39:return t.prev=39,_.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(o=null===(s=p.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==o?o:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:null!==(c=null===(u=m.order)||void 0===u?void 0:u.toString())&&void 0!==c?c:"",collection_id:l.userId}})),t.finish(39);case 42:t.next=46;break;case 44:h.hasNext=!1,h.nextToken="";case 46:return t.abrupt("return",h);case 47:case"end":return t.stop()}}),t,this,[[6,32,39,42],[8,15]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 kv({})}},{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,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata={token:r?r.token:"",range:new kv(r?r.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!r&&r.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.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=es.of(this._iid),r=n.logger;n.sessionManager.session.hasSession&&(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(){es.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 k_[this._iid])}}],[{key:"of",value:function(e){return k_[e]||(k_[e]=new t({_iid:e})),k_[e].ref++,k_[e]}},{key:"clear",value:function(e){k_[e]&&(k_[e].close(),delete k_[e])}}])}(),C_={},w_=function(){function t(n){var a=this,i=n._iid;r(this,t),this.ref=0,this._iid=i;var s,o=es.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher,h=o.cacheContext,f=o.statManager;this._metadataKey=(s=c.userId,"sendbird:".concat(s,"@groupchannel/changelogs.meta")),this._subscribers=new de;var p=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(c.userId);this._sync=new Tv(p,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,l,p,v,_,m,g;return d().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 u.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,s={includeEmpty:!0,includeMetaData:!0},t.prev=6,t.next=9,h.preference.get(Ga(c.appId));case 9:o=t.sent,s.includeChatNotification=Boolean(o),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(6),s.includeChatNotification=!1;case 16:return l=Cv.of(this._iid),t.next=19,l.getMyGroupChannelChangeLogs(null!==(a=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==a?a:"",s,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 19:return p=t.sent,v=p.updatedChannels,_=p.deletedChannelUrls,m=p.hasMore,g=p.token,this._subscribers.dispatch("progress",{updatedChannels:v,deletedChannelUrls:_,hasMore:m,token:g}),i.hasNext=m,i.nextToken=g,this._metadata&&(this._metadata.token=g),u.debug("channel changelog sync progress",i),t.next=31,this.saveMetadata();case 31:h.localCacheEnabled&&f.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:v.length>0||_.length>0?"cache_miss":"cache_hit",max_db_size:v.length,use_local_cache:h.localCacheEnabled,starting_point:0,message_init_policy:_.length.toString(),collection_id:c.userId}})),t.next=41;break;case 34:if(t.prev=34,t.t1=t.catch(4),u.debug("channel changelog sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=40;break}return t.next=40,this.clearMetadata();case 40:throw t.t1;case 41:return t.abrupt("return",i);case 42:case"end":return t.stop()}}),t,this,[[4,34],[6,13]])})))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=l.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"isRunning",get:function(){return this._sync.isRunning}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"on",value:function(e,t){return this._subscribers.on(e,t)}},{key:"resume",value:function(){es.of(this._iid).sessionManager.session.hasSession&&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 C_[this._iid])}}],[{key:"of",value:function(e){return C_[e]||(C_[e]=new t({_iid:e})),C_[e].ref++,C_[e]}},{key:"clear",value:function(e){C_[e]&&(C_[e].close(),delete C_[e])}}])}(),x_=function(t,n){var r,a,i,s;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!==(s=null===(i=t.lastMessage)||void 0===i?void 0:i.createdAt)&&void 0!==s?s:t.createdAt}},S_=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},T_=function(e,t,n){if(e.length>0){for(var r=S_(e,t),a=0,i=e.length-1,s=Math.floor((a+i)/2);a0)i=s,s=Math.floor((a+i)/2);else{if(!(o<0))return{place:s,oldPosition:r};a=s+1,s=Math.floor((a+i)/2)}}return{place:I_(e[s],t,n)>=0?s:s+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},I_=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(t.lastMessage&&n.lastMessage){var a=n.lastMessage.createdAt-t.lastMessage.createdAt;return 0===a?n.createdAt-t.createdAt:a}return 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 i=t.name.localeCompare(n.name);return 0===i?t.createdAt-n.createdAt:i;default:return 0}},N_=function(){return i((function t(n,a){var i=this,s=a.filter,o=void 0===s?new $f:s,u=a.order,c=void 0===u?e.GroupChannelListOrder.LATEST_LAST_MESSAGE:u,l=a.limit,h=void 0===l?100:l,f=a.includeChangesOnInitialLoad,p=void 0!==f&&f;r(this,t),this.channels=[],this._isInitialized=!1,this._iid=n,this._key="gcc-".concat(ce()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=o,this.order=c,this._hasMore=!0,this._token="",this._limit=h;var v=es.of(this._iid),_=v.sdkState,m=v.cacheContext,g=v.dispatcher;m.localCacheEnabled&&(this._backgroundSync=b_.of(n),this._backgroundSync.resume()),this._changelogSync=w_.of(n),this._changelogSync.resume(),Cv.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(mp(n)){var r=e.filter((function(e){return i.filter.match(e,_.userId)})),a=e.filter((function(e){return!i.filter.match(e,_.userId)})).map((function(e){return e.url}));r.length>0&&i._addChannelsToView(r,t),a.length>0&&i._removeChannelsFromView(a,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),g.on((function(e){e instanceof La&&(e.stateType===Aa.CONNECTED?i._isGetRemoteChannelsSucceeded||E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._revokeLoadMore();case 2:case"end":return e.stop()}}),e,this)}))):e.stateType===Aa.LOGOUT&&i.dispose())}))}),[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(t,n){var r,a=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=s(t);try{for(l.s();!(r=l.n()).done;){var h=r.value,f=S_(this.channels,h);f>=0&&this.channels.splice(f,1);var p=T_(this.channels,h,this.order).place;if(f<0)p===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(p,0,h));else switch(n.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&p===this.channels.length?c.push(h):(this.channels.splice(p,0,h),u.push(h));break;default:this.channels.splice(p,0,h),u.push(h)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var v,_=s(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=S_(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}mp(n.source)&&hi((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsAdded)&&this._handler.onChannelsAdded(n,o),u.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,u),c.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,c.map((function(e){return e.url})));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,t){var n,r=this,a=[],i=s(e);try{var o=function(){var e=n.value,t=r.channels.findIndex((function(t){return t.url===e}));t>=0&&(a.push(r.channels[t].url),r.channels.splice(t,1))};for(i.s();!(n=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return mp(t.source)&&a.length>0&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(t,a);case 1:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_getLocalChannels",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Cv.of(this._iid),n=this.channels.length>0?x_(this.channels[this.channels.length-1],this.order):null,e.next=4,t.getChannelsFromCache(n,this.filter,this.order,this._limit,n?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,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Cv.of(this._iid),e.next=3,t.getMyGroupChannels(this._token,ve(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);case 3:return n=e.sent,r=n.channels,a=n.token,this._token=a,this._hasMore=!!a,e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:n=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(n,{source:e.CollectionEventSource.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()}}),t,this,[[2,10]])})))}},{key:"loadMore",value:function(){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(r=null,!this._includeChangesOnInitialLoad||0!==this.channels.length){n.next=9;break}if(!this._changelogSync.isRunning){n.next=9;break}return n.next=7,new Promise((function(e){C._changelogSyncSubscriberContext=C._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}));case 7:r=n.sent,null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close();case 9:if(a=es.of(this._iid),i=a.cacheContext,o=a.connectionManager,u=a.statManager,this._isInitialized){n.next=16;break}if(this._isInitialized=!0,!i.localCacheEnabled){n.next=15;break}return n.next=15,this._backgroundSync.loadMetadata();case 15:u.put(new Bi({type:Ge.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}}));case 16:if(c=[],!this._hasMore){n.next=35;break}if(!i.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed){n.next=24;break}return n.next=21,fi((function(){return E(C,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:c=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 21:this._hasMore=c.length>=this._limit,n.next=34;break;case 24:return n.prev=24,n.next=27,this._getRemoteChannels();case 27:c=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=34;break;case 31:n.prev=31,n.t0=n.catch(24),this._isGetRemoteChannelsSucceeded=!1;case 34:this._addChannelsToView(c,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0);case 35:if(r){l=s(r.updatedChannels);try{for(l.s();!(h=l.n()).done;)f=h.value,(p=S_(c,f))>=0?c[p]=f:(v=T_(c,f,this.order),_=v.place,c.splice(_,0,f))}catch(e){l.e(e)}finally{l.f()}m=c.map((function(e){return e.url})),g=s(r.deletedChannelUrls);try{for(g.s();!(y=g.n()).done;)k=y.value,(b=m.indexOf(k))>=0&&(c.splice(b,1),m.splice(b,1))}catch(e){g.e(e)}finally{g.f()}}return n.abrupt("return",c);case 37:case"end":return n.stop()}}),n,this,[[24,31]])})))}},{key:"dispose",value:function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),Cv.of(this._iid).unsubscribeChannelEvent(this._key))}}])}(),A_=function(t){function a(t){var i;r(this,a);var s=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,d=t.channelNameContainsFilter,h=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,E=t.includeFrozen,k=t.includeMetaData;return(i=n(this,a)).method=_e.GET,i.path=ke,i.params=pe(ve({token:s,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:d,channel_urls:h,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:E,show_metadata:k})),i}return c(a,t),i(a)}(je),M_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new E_(e,t)}))),i.ts="number"==typeof u?u:0,i}return c(t,e),i(t)}(Ve);e.MembershipFilter=void 0,(y_=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",y_.JOINED="joined";var O_,U_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;return r(this,a),(s=n(this,a,[t,i])).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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=i.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(d=i.customTypesFilter)&&void 0!==d?d:null,s.customTypeStartsWithFilter=null!==(h=i.customTypeStartsWithFilter)&&void 0!==h?h:null,s.channelNameContainsFilter=null!==(f=i.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=i.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=i.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=i.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=i.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=i.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=i.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(E=i.order)&&void 0!==E?E:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter,!0)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter,!0)&&R(e.MembershipFilter,this.membershipFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicGroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=es.of(this._iid),r=n.requestQueue,a=new A_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(M_),o=s.channels,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(uu),D_=i((function e(){r(this,e),this.onUserMuted=ht,this.onUserUnmuted=ht,this.onUserBanned=ht,this.onUserUnbanned=ht,this.onChannelChanged=ht,this.onChannelDeleted=ht,this.onChannelFrozen=ht,this.onChannelUnfrozen=ht,this.onOperatorUpdated=ht,this.onChannelMemberCountChanged=ht,this.onMetaDataCreated=ht,this.onMetaDataUpdated=ht,this.onMetaDataDeleted=ht,this.onMetaCounterCreated=ht,this.onMetaCounterUpdated=ht,this.onMetaCounterDeleted=ht,this.onMessageReceived=ht,this.onMessageUpdated=ht,this.onMessageDeleted=ht,this.onMentionReceived=ht,this.onReactionUpdated=ht,this.onThreadInfoUpdated=ht})),R_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserJoined=ht,e.onUserLeft=ht,e.onUserReceivedInvitation=ht,e.onUserDeclinedInvitation=ht,e.onChannelHidden=ht,e.onUnreadMemberStatusUpdated=ht,e.onUndeliveredMemberStatusUpdated=ht,e.onTypingStatusUpdated=ht,e.onPollUpdated=ht,e.onPollVoted=ht,e.onPollDeleted=ht,e.onPinnedMessageUpdated=ht,e}return c(t,e),i(t)}(D_),L_=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(R_),P_=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,d=e.scheduledStatus;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ae),a.params=pe(ve({token:i,limit:s,reverse:u,channel_url:c,order:o,message_type:l,status:d})),a}return c(t,e),i(t)}(je),F_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).scheduledMessages=[];var s=a.next,o=a.scheduled_messages;return i.token=s,i.scheduledMessages=o.map((function(t){return ho(e,t)})),i}return c(t,e),i(t)}(Ve),q_=function(t){function a(t,i){var s,o,u,c,l,d;return r(this,a),(s=n(this,a,[t,i])).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(o=i.channelUrl)&&void 0!==o?o:null,s.order=null!==(u=i.order)&&void 0!==u?u:null,s.reverse=null!==(c=i.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=i.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(d=i.messageTypeFilter)&&void 0!==d?d:e.MessageTypeFilter.ALL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl,!0)&&(R(e.ScheduledMessageListOrder,this.order)||null===this.order)&&D("boolean",this.reverse)&&(P(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&R(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new P_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(F_),s=i.scheduledMessages,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),H_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="groupChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new Cv(e,{sdkState:r,cacheContext:c,dispatcher:a,sessionManager:i,requestQueue:s,logger:o})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new N_(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new lv(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new U_(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new q_(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){ai(D("string",e)&&t instanceof L_).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){ai(D("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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},ip),t),ai(D("string",e)&&sp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},ip),t),ai(D("number",e)&&sp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},op),e),ai(up(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},rp),e),ai(ap(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.createChannel(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},rp),e),ai(ap(n)).throw(A.invalidParameters),n&&(n.isDistinct=!0),t.abrupt("return",this.createChannel(n));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithUserIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=Object.assign(Object.assign({},rp),{invitedUserIds:e,isDistinct:t,name:n,data:a,customType:i}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,s.abrupt("return",this.createChannel(o));case 3:case"end":return s.stop()}}),s,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:ai(P("string",e)).throw(A.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.next=3,this.getChannel(e);case 3:return n=t.sent,t.next=6,n.markAsDelivered();case 6:case"end":return t.stop()}}),t,this)})))}}])}(ts),G_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return c(t,e),i(t,[{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,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0: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)})),t.abrupt("return",n);case 3:case"end":return t.stop()}}),t)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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)})))}}])}(Ya),j_={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},V_=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&(D("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&D("boolean",e.isEphemeral,!0)},z_=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?we:Ce,"/").concat(encodeURIComponent(i)),a.params={show_pinned_messages:!0},a}return c(t,e),i(t)}(je),B_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new om(e,a),i}return c(t,e),i(t)}(Ve),K_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,d=e.isEphemeral;return(a=n(this,t)).method=_e.POST,a.path=Ce,a.params=pe(ve({channel_url:i,cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:d})),a}return c(t,e),i(t)}(je),Q_=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"ENTR",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(Qe),W_=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new si(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(jp),Y_=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"EXIT",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(Qe),Z_=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"EXIT",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new si(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(jp),X_={},J_=function(t){function a(t,i){var o;return r(this,a),(o=n(this,a,[t,Object.assign(Object.assign({},i),{channelType:e.ChannelType.OPEN})])).subscribeChannelEvent=ht,o.unsubscribeChannelEvent=ht,o.refreshChannel=function(){return E(o,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}}),e)})))},o._openChannelCache=new G_(t),o._openChannelHandlers=new Map,o._dispatcher.on((function(e){if(e instanceof Ke)o._handleEvent(e).catch((function(e){if(N(e)&&"foreground"===o._sdkState.appState)throw e}));else if(e instanceof La&&e.stateType===Aa.CONNECTED){var t,n=s(o._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),X_[t]||(X_[t]=o),o}return c(a,t),i(a,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=ri(e);return new om(this._iid,om.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._openChannelCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((r=n.n()).done){t.next=9;break}return a=r.value,t.next=7,this._openChannelCache.remove(a);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),n.e(t.t0);case 14:return t.prev=14,n.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"handlers",get:function(){return v(this._openChannelHandlers.values())}},{key:"_handleEvent",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,A,M,O,U,D,R,L,P,F,q,H,G,j,V,z,B,K,Q,W,Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue,ce,le,de,he,fe,pe,ve,_e,me,ge,ye,Ee,ke,be,Ce,we,xe,Se,Te,Ie,Ne,Ae,Me,Oe,Ue,De,Re,Le,Pe,Fe,qe,He,Ge,je=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,n.t0=t.code,n.next="MESG"===n.t0||"FILE"===n.t0||"ADMM"===n.t0||"BRDM"===n.t0?4:"MEDI"===n.t0||"FEDI"===n.t0||"AEDI"===n.t0?14:"DELM"===n.t0?26:"MRCT"===n.t0?33:"MTHD"===n.t0?40:"MCNT"===n.t0?47:"PEDI"===n.t0?75:"VOTE"===n.t0?83:"SYEV"===n.t0?91:174;break;case 4:if(r=null,"MESG"===t.code?r=t.as(ac):"FILE"===t.code?r=t.as(mo):"ADMM"!==t.code&&"BRDM"!=t.code||(r=t.as(fv)),!r){n.next=13;break}if(i=(a=r).message,o=a.isMentioned,i.channelType!==e.ChannelType.OPEN){n.next=13;break}return n.next=11,this.getChannel(i.channelUrl,!0);case 11:u=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(u.url)&&(r.onMessageReceived&&r.onMessageReceived(u,i),o&&r.onMentionReceived&&r.onMentionReceived(u,i))}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return n.abrupt("break",174);case 14:if(c=null,"MEDI"===t.code?c=t.as(sc):"FEDI"===t.code?c=t.as(uc):"AEDI"===t.code&&(c=t.as(pv)),!c){n.next=25;break}if(h=(l=c).message,f=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){n.next=25;break}return n.next=21,this.getChannel(h.channelUrl,!0);case 21:p=n.sent,v=!1,p.lastPinnedMessage&&p.lastPinnedMessage.messageId===h.messageId&&p.lastPinnedMessage.updatedAt0&&i.onMentionReceived&&i.onMentionReceived(p,h))}catch(e){r.e(e)}finally{r.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 25:return n.abrupt("break",174);case 26:if(_=t.as(lt),m=_.channelUrl,g=_.channelType,y=_.messageId,g!==e.ChannelType.OPEN){n.next=32;break}return n.next=30,this.getChannel(m,!0);case 30:k=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(k.url)&&r.onMessageDeleted&&r.onMessageDeleted(k,y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 32:return n.abrupt("break",174);case 33:if(b=t.as(mv),C=b.channelUrl,w=b.channelType,x=b.event,w!==e.ChannelType.OPEN){n.next=39;break}return n.next=37,this.getChannel(C,!0);case 37:S=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(S.url)&&r.onReactionUpdated&&r.onReactionUpdated(S,x)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 39:return n.abrupt("break",174);case 40:if(T=t.as(gv),(I=T.event).channelType!==e.ChannelType.OPEN){n.next=46;break}return n.next=44,this.getChannel(I.channelUrl,!0);case 44:A=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(A.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(A,I)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 46:return n.abrupt("break",174);case 47:M=t.as(yv),O=M.openChannelMemberCounts,U=[],D=s(O),n.prev=50,D.s();case 52:if((R=D.n()).done){n.next=61;break}return L=R.value,P=L.channelUrl,F=L.participantCount,q=L.updatedAt,n.next=57,this.getChannelFromCache(P);case 57:(H=n.sent)&&H._updateParticipantCount(F,q)&&U.push(H);case 59:n.next=52;break;case 61:n.next=66;break;case 63:n.prev=63,n.t1=n.catch(50),D.e(n.t1);case 66:return n.prev=66,D.f(),n.finish(66);case 69:if(!(U.length>0)){n.next=74;break}return n.next=72,this.upsertChannelsToCache(U);case 72:G=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(G)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 74:return n.abrupt("break",174);case 75:if(j=t.as(Ev),V=j.event,z=j.status,B=j.channelUrl,K=j.channelType,!B||K!==e.ChannelType.OPEN){n.next=82;break}return n.next=79,this.getChannel(B,!0);case 79:Q=n.sent,this._dispatcher.dispatch(new Fs({event:V,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),hi(z===to?function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(Q,V.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(Q,V)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 82:return n.abrupt("break",174);case 83:if(W=t.as(Oc),Y=W.event,Z=W.channelUrl,X=W.channelType,!Z||X!==e.ChannelType.OPEN){n.next=90;break}return n.next=87,this.getChannel(Z,!0);case 87:J=n.sent,this._dispatcher.dispatch(new qs({event:Y,source:e.CollectionEventSource.EVENT_POLL_VOTED})),hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(J,Y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 90:return n.abrupt("break",174);case 91:if($=t.as(jp),!(ee=$.event).isOpenChannelEvent){n.next=173;break}n.t2=ee.category,n.next=n.t2===Jf.CHANNEL_ENTER?96:n.t2===Jf.CHANNEL_EXIT?103:n.t2===Jf.CHANNEL_OPERATOR_UPDATE?110:n.t2===Jf.USER_CHANNEL_MUTE||n.t2===Jf.USER_CHANNEL_UNMUTE?118:n.t2===Jf.USER_CHANNEL_BAN||n.t2===Jf.USER_CHANNEL_UNBAN?125:n.t2===Jf.CHANNEL_FREEZE||n.t2===Jf.CHANNEL_UNFREEZE?132:n.t2===Jf.CHANNEL_DELETED?140:n.t2===Jf.CHANNEL_PROP_CHANGED?147:n.t2===Jf.CHANNEL_META_DATA_CHANGED?152:n.t2===Jf.CHANNEL_META_COUNTERS_CHANGED?161:n.t2===Jf.PINNED_MESSAGE_CHANGED?167:173;break;case 96:return n.next=98,this.getChannel(ee.channelUrl,!0);case 98:return te=n.sent,ne=t.as(W_),re=ne.participantCount,ae=ne.user,ie=te._updateParticipantCount(re,ee.ts),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(te,ae),ie&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(te)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 103:return n.next=105,this.getChannel(ee.channelUrl,!0);case 105:return se=n.sent,oe=t.as(Z_),ue=oe.participantCount,ce=oe.user,le=se._updateParticipantCount(ue,ee.ts),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(se,ce),le&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 110:return n.next=112,this.getChannel(ee.channelUrl,!0);case 112:return de=n.sent,he=t.as(uv),fe=he.operators,de.operators=fe,this.upsertChannelsToCache([de]),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(de,fe)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 118:return n.next=120,this.getChannel(ee.channelUrl,!0);case 120:return pe=n.sent,ve=ee.category===Jf.USER_CHANNEL_MUTE,_e=t.as(ve?Bu:Qu),me=_e.user,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ve?e.onUserMuted&&e.onUserMuted(pe,me):e.onUserUnmuted&&e.onUserUnmuted(pe,me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 125:return n.next=127,this.getChannel(ee.channelUrl,!0);case 127:return ge=n.sent,ye=ee.category===Jf.USER_CHANNEL_BAN,Ee=t.as(ye?Yu:Xu),ke=Ee.user,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ye?e.onUserBanned&&e.onUserBanned(ge,ke):e.onUserUnbanned&&e.onUserUnbanned(ge,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 132:return n.next=134,this.getChannel(ee.channelUrl,!0);case 134:return be=n.sent,Ce=t.as($u),we=Ce.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().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)})))})),n.abrupt("break",173);case 140:return n.next=142,this.getChannel(ee.channelUrl,!0);case 142:return xe=n.sent,n.next=145,this.removeChannelsFromCache([xe.url]);case 145:return hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(xe.url,xe.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 147:return n.next=149,this.getChannelWithoutCache(ee.channelUrl,!0);case 149:return Se=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 152:return n.next=154,this.getChannel(ee.channelUrl,!0);case 154:return Te=n.sent,Ie=t.as(Au),Ne=Ie.created,Ae=Ie.updated,Me=Ie.deleted,Ne&&Te._upsertCachedMetaData(Ne,ee.ts),Ae&&Te._upsertCachedMetaData(Ae,ee.ts),Me&&Te._removeFromCachedMetaData(Me,ee.ts),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ne&&e.onMetaDataCreated&&e.onMetaDataCreated(Te,Ne),Ae&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Te,Ae),Me&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Te,Me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 161:return n.next=163,this.getChannel(ee.channelUrl,!0);case 163:return Oe=n.sent,Ue=t.as(Gu),De=Ue.created,Re=Ue.updated,Le=Ue.deleted,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){De&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Oe,De),Re&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Oe,Re),Le&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Oe,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 167:return n.next=169,this.getChannel(ee.channelUrl,!0);case 169:return Pe=n.sent,Fe=t.as(dv),qe=Fe.pinnedMessageIds,He=Fe.latestPinnedMessage,(Ge=Fe.ts)>Pe._pinnedMessagesUpdatedAt&&(Pe.pinnedMessageIds=qe,Pe.lastPinnedMessage=He,Pe._pinnedMessagesUpdatedAt=Ge,this.upsertChannelsToCache([Pe]),hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Pe)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(Pe)}));case 1:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",173);case 173:return n.abrupt("break",174);case 174:n.next=180;break;case 176:if(n.prev=176,n.t3=n.catch(0),!N(n.t3)){n.next=180;break}throw n.t3;case 180:case"end":return n.stop()}}),n,this,[[0,176],[50,63,66,69]])})))}},{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){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),r=new z_({channelUrl:e,isInternalCall:t}),n.next=4,this._requestQueue.send(r);case 4:return a=n.sent,i=a.as(B_),s=i.channel,n.next=8,this.upsertChannelsToCache([s]);case 8:return n.abrupt("return",n.sent[0]);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},j_),e),ai(V_(n)).throw(A.invalidParameters),r=new K_(n),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(B_),s=i.channel,this.upsertChannelsToCache([s]),t.abrupt("return",s);case 9:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return X_[e]}}])}(hv),$_={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},em=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)},tm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ce,"/").concat(encodeURIComponent(i),"/participants"),a.params={token:s,limit:o},a}return c(t,e),i(t)}(je),nm=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).participants=[];var s=a.next,o=a.participants;return i.token=s,i.participants=o.map((function(t){return new Fo(e,t)})),i}return c(t,e),i(t)}(Ve),rm=function(t){function a(t,i,s){return r(this,a),n(this,a,[t,i,e.ChannelType.OPEN,s])}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new tm(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(nm),s=i.participants,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),am=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a.params=pe(ve({cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l})),a}return c(t,e),i(t)}(je),im=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new om(e,a),i}return c(t,e),i(t)}(Ve),sm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(je),om=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i]))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(o=i.participant_count)&&void 0!==o?o:0,s.operators=Array.isArray(i.operators)?i.operators.map((function(e){return new si(t,e)})):[],s.lastPinnedMessage=i.latest_pinned_message?ho(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,s}return c(a,t),i(a,[{key:"serialize",value:function(){return ni(this)}},{key:"isOperator",value:function(e){return e instanceof si?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 rm(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=J_.of(this._iid),e.next=3,t.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Q_({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(W_),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),J_.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,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Y_({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Z_),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),J_.of(this._iid).setExitedToCache(this),nh.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,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},$_),e),ai(em(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new am(Object.assign({channelUrl:this.url},n)),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(im),u=o.channel,this._update(u),c=J_.of(this._iid),t.next=12,c.upsertChannelsToCache([u]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=Object.assign(Object.assign({},$_),{name:e,coverUrlOrImage:t,data:n,operatorUserIds:r,customType:a}),i.abrupt("return",this.updateChannel(s));case 2:case"end":return i.stop()}}),i,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new sm({channelUrl:this.url}),e.next=4,n.send(r);case 4:return a=J_.of(this._iid),e.next=7,a.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"updateUserMessage",value:function(e,t){var n=this,r=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateUserMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&J_.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&J_.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFileMessage",value:function(e,t){var n=this,r=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateFileMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&J_.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&J_.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},vl.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return si.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?lo(e.lastPinnedMessage):null})))}}])}(vl),um=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserEntered=ht,e.onUserExited=ht,e.onChannelParticipantCountChanged=ht,e.onPollUpdated=ht,e.onPollVoted=ht,e.onPollDeleted=ht,e.onPinnedMessageUpdated=ht,e}return c(t,e),i(t)}(D_),cm=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(um),lm=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,d=e.includeMetaData;return(a=n(this,t)).method=_e.GET,a.path=Ce,a.params=pe({token:i,limit:s,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:d,show_pinned_messages:!0}),a}return c(t,e),i(t)}(je),dm=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return new om(e,t)}))),i.ts="number"==typeof u?u:null,i}return c(t,e),i(t)}(Ve),hm=function(e){function t(e,a){var i,s,o,u,c,l;return r(this,t),(i=n(this,t,[e,a])).includeFrozen=!0,i.includeMetaData=!0,i.nameKeyword=null,i.urlKeyword=null,i.customTypes=null,i.includeFrozen=null===(s=a.includeFrozen)||void 0===s||s,i.includeMetaData=null===(o=a.includeMetaData)||void 0===o||o,i.nameKeyword=null!==(u=a.nameKeyword)&&void 0!==u?u:null,i.urlKeyword=null!==(c=a.urlKeyword)&&void 0!==c?c:null,i.customTypes=null!==(l=a.customTypes)&&void 0!==l?l:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.nameKeyword,!0)&&D("string",this.urlKeyword,!0)&&P("string",this.customTypes,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new lm(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(dm),s=i.channels,o=i.token,this._token=o,this._hasNext=!!o,u=J_.of(this._iid),e.next=15,u.upsertChannelsToCache(s);case 15:return this._isLoading=!1,e.abrupt("return",s);case 17:return e.abrupt("return",[]);case 20:throw A.queryInProgress;case 21:e.next=24;break;case 23:throw A.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}])}(uu),fm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="openChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new J_(e,{sdkState:r,dispatcher:a,requestQueue:s,logger:o,cacheContext:c,sessionManager:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new hm(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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return(s=Object.assign({},j_)).name=e,s.coverUrlOrImage=t,s.data=n,s.operatorUserIds=r,s.customType=a,i.abrupt("return",this._manager.createChannel(s));case 7:case"end":return i.stop()}}),i,this)})))}}])}(ts),pm=Object.freeze({__proto__:null,xmlHttpRequest:function(e,t){return new Promise((function(n,r){if("undefined"!=typeof XMLHttpRequest){var a=es.of(e),i=a.dispatcher,s=a.logger,o=t.requestId,u=t.method,c=t.url,l=t.headers,d=void 0===l?{}:l,h=t.data,f=void 0===h?"":h,p=t.uploadProgressHandler,v=!1,_=new XMLHttpRequest;_.open(u,c),Object.keys(d).forEach((function(e){_.setRequestHeader(e,d[e])})),p&&_.upload.addEventListener("progress",(function(e){e.lengthComputable?p(o,e.loaded,e.total):s.debug("Progress computing failed: `Content-Length` header is not given.")})),_.onabort=function(){r(A.requestCanceled)},_.onerror=function(e){r(A.networkError)},_.onreadystatechange=function(){if(_.readyState===XMLHttpRequest.DONE&&!v)if(0===_.status||_.status>=200&&_.status<400)try{var t=JSON.parse(_.responseText);n(new Ve(e,t))}catch(s){r(A.networkError)}else try{var a=JSON.parse(_.responseText);if(a){var s=new A(a);if(s.isSessionExpiredError){if(i.dispatch(new Be({reason:s.code,message:s.message})),!(_ instanceof We)){var o=new ot;return i.dispatch(new $e({request:_,deferred:o,error:s})),o.promise}}else s.isSessionInvalidatedError&&i.dispatch(new Be({reason:s.code,message:s.message}));r(s)}else r(A.requestFailed)}catch(s){r(A.requestFailed)}},i.on((function(e){e instanceof ut&&(e.requestId&&e.requestId!==o||(v=!0,_.abort()))})),_.send(f)}else r(A.xmlHttpRequestNotSupported)}))}});O_=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 wm(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 xm(e){return"string"!=typeof e&&(e=String(e)),e}function Sm(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return gm&&(t[Symbol.iterator]=function(){return t}),t}function Tm(e){this.map={},e instanceof Tm?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 Im(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function Nm(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Am(e){var t=new FileReader,n=Nm(t);return t.readAsArrayBuffer(e),n}function Mm(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Om(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:ym&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:Em&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:mm&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():km&&ym&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Mm(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):km&&(ArrayBuffer.prototype.isPrototypeOf(e)||Cm(e))?this._bodyArrayBuffer=Mm(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):mm&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},ym&&(this.blob=function(){var e=Im(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=Im(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(ym)return this.blob().then(Am);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,n,r,a,i=Im(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Nm(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),a=r?r[1]:"utf-8",t.readAsText(e,a),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||function(){if("AbortController"in _m)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 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 Rm(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 Lm(e,t){if(!(this instanceof Lm))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 Tm(t.headers),this.url=t.url||"",this._initBody(e)}Dm.prototype.clone=function(){return new Dm(this,{body:this._bodyInit})},Om.call(Dm.prototype),Om.call(Lm.prototype),Lm.prototype.clone=function(){return new Lm(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Tm(this.headers),url:this.url})},Lm.error=function(){var e=new Lm(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var Pm=[301,302,303,307,308];Lm.redirect=function(e,t){if(-1===Pm.indexOf(t))throw new RangeError("Invalid status code");return new Lm(null,{status:t,headers:{location:e}})};var Fm=_m.DOMException;try{new Fm}catch(Mn){(Fm=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),Fm.prototype.constructor=Fm}function qm(e,t){return new Promise((function(n,r){var a=new Dm(e,t);if(a.signal&&a.signal.aborted)return r(new Fm("Aborted","AbortError"));var i=new XMLHttpRequest;function s(){i.abort()}if(i.onload=function(){var e,t,r={statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new Tm,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();try{t.append(r,a)}catch(e){console.warn("Response "+e.message)}}})),t)};0===a.url.indexOf("file://")&&(i.status<200||i.status>599)?r.status=200:r.status=i.status,r.url="responseURL"in i?i.responseURL:r.headers.get("X-Request-URL");var s="response"in i?i.response:i.responseText;setTimeout((function(){n(new Lm(s,r))}),0)},i.onerror=function(){setTimeout((function(){r(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){r(new TypeError("Network request timed out"))}),0)},i.onabort=function(){setTimeout((function(){r(new Fm("Aborted","AbortError"))}),0)},i.open(a.method,function(e){try{return""===e&&_m.location.href?_m.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?i.withCredentials=!0:"omit"===a.credentials&&(i.withCredentials=!1),"responseType"in i&&(ym?i.responseType="blob":km&&(i.responseType="arraybuffer")),t&&"object"===m(t.headers)&&!(t.headers instanceof Tm||_m.Headers&&t.headers instanceof _m.Headers)){var o=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){o.push(wm(e)),i.setRequestHeader(e,xm(t.headers[e]))})),a.headers.forEach((function(e,t){-1===o.indexOf(t)&&i.setRequestHeader(t,e)}))}else a.headers.forEach((function(e,t){i.setRequestHeader(t,e)}));a.signal&&(a.signal.addEventListener("abort",s),i.onreadystatechange=function(){4===i.readyState&&a.signal.removeEventListener("abort",s)}),i.send(void 0===a._bodyInit?null:a._bodyInit)}))}qm.polyfill=!0,_m.fetch||(_m.fetch=qm,_m.Headers=Tm,_m.Request=Dm,_m.Response=Lm);var Hm="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null};Hm.fetch||(Hm.fetch=qm);var Gm=Object.freeze({__proto__:null});e.AdminMessage=Js,e.AppInfo=Wa,e.AppleCriticalAlertOptions=ds,e.ApplicationUserListQuery=wl,e.BannedUserListQuery=yu,e.BaseChannel=vl,e.BaseMessage=Ws,e.BlockedUserListQuery=Tl,e.CachedChannelInfo=Q,e.ConnectionHandler=yl,e.DeliveryStatus=Xf,e.Emoji=_l,e.EmojiCategory=ml,e.EmojiContainer=gl,e.Feedback=fs,e.FileMessage=fo,e.FriendListQuery=Al,e.GroupChannel=E_,e.GroupChannelCollection=N_,e.GroupChannelEventSource=_p,e.GroupChannelFilter=$f,e.GroupChannelHandler=L_,e.GroupChannelListQuery=lv,e.GroupChannelModule=H_,e.LocalCacheConfig=W,e.Member=Zf,e.MemberListQuery=Yv,e.MemoryStore=Sd,e.MessageCollection=jv,e.MessageCollectionInitHandler=Hv,e.MessageEventSource=As,e.MessageFilter=Pd,e.MessageForm=zs,e.MessageFormItem=Bs,e.MessageMetaArray=vs,e.MessageModule=yh,e.MessageRequestHandler=qo,e.MessageReviewInfo=so,e.MessageSearchQuery=dh,e.MultipleFilesMessage=uo,e.MultipleFilesMessageRequestHandler=ol,e.MutedUserListQuery=_u,e.NotificationInfo=Ha,e.OGImage=cs,e.OGMetaData=ls,e.OpenChannel=om,e.OpenChannelHandler=cm,e.OpenChannelListQuery=hm,e.OpenChannelModule=fm,e.OperatorListQuery=hu,e.Participant=Fo,e.ParticipantListQuery=rm,e.PinnedMessage=ul,e.PinnedMessageListQuery=dl,e.Plugin=$s,e.PreviousMessageListQuery=fu,e.PublicGroupChannelListQuery=U_,e.Reaction=us,e.ReactionEvent=os,e.ReadStatus=gs,e.RestrictedUser=Po,e.RestrictionInfo=Lo,e.ScheduledMessageListQuery=q_,e.SendbirdChat=Gf,e.SendbirdChatOptions=j,e.SendbirdError=A,e.Sender=ps,e.SessionHandler=El,e.ThreadInfo=is,e.ThreadInfoUpdateEvent=rh,e.ThreadedParentMessageListQuery=ph,e.Thumbnail=ns,e.UIKitConfigInfo=ja,e.UploadedFileInfo=Hs,e.User=si,e.UserEventHandler=kl,e.UserMessage=oo,Object.defineProperty(e,"__esModule",{value:!0})})); From fd57af0253e8816be6021ab592ff07c6a98ecf42 Mon Sep 17 00:00:00 2001 From: sendbird-sdk-deployment Date: Mon, 14 Oct 2024 01:32:11 +0000 Subject: [PATCH 2/3] Release - 4.14.5 --- CHANGELOG.md | 4 ++++ cjs/feedChannel.cjs | 2 +- cjs/groupChannel.cjs | 2 +- cjs/index.cjs | 2 +- cjs/lib/__bundle-0486c467.cjs | 2 ++ .../{__bundle-c127c886.cjs => __bundle-05f697db.cjs} | 2 +- .../{__bundle-2ad218ff.cjs => __bundle-0f6b8ff3.cjs} | 2 +- cjs/lib/__bundle-0fbd5934.cjs | 1 + .../{__bundle-d3673ecc.cjs => __bundle-12c1cdf9.cjs} | 2 +- cjs/lib/__bundle-165fd6e1.cjs | 1 - cjs/lib/__bundle-1a495950.cjs | 2 -- .../{__bundle-552fe22f.cjs => __bundle-2e006691.cjs} | 2 +- cjs/lib/__bundle-4bcf4070.cjs | 1 + .../{__bundle-611abb88.cjs => __bundle-947cb619.cjs} | 2 +- cjs/lib/__bundle-ca16c7ed.cjs | 1 - cjs/lib/__bundle-d1419fd1.cjs | 1 + .../{__bundle-bfe2e997.cjs => __bundle-d349e14c.cjs} | 2 +- cjs/lib/__bundle-dcf4d0c3.cjs | 1 - cjs/lib/__definition.d.cts | 10 ++++++---- cjs/message.cjs | 2 +- cjs/node.cjs | 2 +- cjs/openChannel.cjs | 2 +- cjs/poll.cjs | 2 +- feedChannel.js | 2 +- groupChannel.js | 2 +- index.js | 2 +- lib/__bundle-03052043.js | 1 + lib/{__bundle-24f017be.js => __bundle-1a7e946b.js} | 2 +- lib/__bundle-1db3fd0b.js | 1 - lib/__bundle-45809bc9.js | 1 + lib/{__bundle-e53b9010.js => __bundle-5dbd9d35.js} | 2 +- lib/{__bundle-31d4ecef.js => __bundle-5f5bca4c.js} | 2 +- lib/{__bundle-123134d8.js => __bundle-75f48c2c.js} | 2 +- lib/{__bundle-4b40b3a8.js => __bundle-b5ef7de4.js} | 2 +- lib/__bundle-c03282ec.js | 1 + lib/__bundle-cc71b396.js | 1 - lib/__bundle-e1a5e3f1.js | 1 - lib/__definition.d.ts | 10 ++++++---- message.js | 2 +- node.js | 2 +- openChannel.js | 2 +- package.json | 2 +- poll.js | 2 +- sendbird.min.js | 2 +- 44 files changed, 51 insertions(+), 43 deletions(-) create mode 100644 cjs/lib/__bundle-0486c467.cjs rename cjs/lib/{__bundle-c127c886.cjs => __bundle-05f697db.cjs} (65%) rename cjs/lib/{__bundle-2ad218ff.cjs => __bundle-0f6b8ff3.cjs} (97%) create mode 100644 cjs/lib/__bundle-0fbd5934.cjs rename cjs/lib/{__bundle-d3673ecc.cjs => __bundle-12c1cdf9.cjs} (93%) delete mode 100644 cjs/lib/__bundle-165fd6e1.cjs delete mode 100644 cjs/lib/__bundle-1a495950.cjs rename cjs/lib/{__bundle-552fe22f.cjs => __bundle-2e006691.cjs} (95%) create mode 100644 cjs/lib/__bundle-4bcf4070.cjs rename cjs/lib/{__bundle-611abb88.cjs => __bundle-947cb619.cjs} (91%) delete mode 100644 cjs/lib/__bundle-ca16c7ed.cjs create mode 100644 cjs/lib/__bundle-d1419fd1.cjs rename cjs/lib/{__bundle-bfe2e997.cjs => __bundle-d349e14c.cjs} (89%) delete mode 100644 cjs/lib/__bundle-dcf4d0c3.cjs create mode 100644 lib/__bundle-03052043.js rename lib/{__bundle-24f017be.js => __bundle-1a7e946b.js} (85%) delete mode 100644 lib/__bundle-1db3fd0b.js create mode 100644 lib/__bundle-45809bc9.js rename lib/{__bundle-e53b9010.js => __bundle-5dbd9d35.js} (97%) rename lib/{__bundle-31d4ecef.js => __bundle-5f5bca4c.js} (73%) rename lib/{__bundle-123134d8.js => __bundle-75f48c2c.js} (89%) rename lib/{__bundle-4b40b3a8.js => __bundle-b5ef7de4.js} (86%) create mode 100644 lib/__bundle-c03282ec.js delete mode 100644 lib/__bundle-cc71b396.js delete mode 100644 lib/__bundle-e1a5e3f1.js diff --git a/CHANGELOG.md b/CHANGELOG.md index bcce086..12e1f23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v4.14.5 (Oct 14, 2024) +### **Improvements** +- Added `message` property in `FileMessageCreateParams` +- Added `message` property in `FileMessage` ## v4.14.4 (Sep 27, 2024) ### **Improvements** - Fixed a bug that local cache data is broken in a certain condition diff --git a/cjs/feedChannel.cjs b/cjs/feedChannel.cjs index a793924..20aab54 100644 --- a/cjs/feedChannel.cjs +++ b/cjs/feedChannel.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),t=require("./lib/__bundle-165fd6e1.cjs"),n=require("./lib/__bundle-dcf4d0c3.cjs"),s=require("./lib/__bundle-ca16c7ed.cjs"),i=require("./lib/__bundle-2ad218ff.cjs"),a=require("./lib/__bundle-d3673ecc.cjs");require("./lib/__bundle-bfe2e997.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class o{constructor(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}static payloadify(t){return e.deundefined(e.undefineNullProps({id:t.id,name:t.name,is_default:t.isDefault}))}get customType(){return this.isDefault?"*":String(this.id)}}class r extends e.InstancedObject{constructor(e,{sdkState:t,cacheContext:n,channelManager:s}){super(e),this._channels=new Map,this._sdkState=t,this._cacheContext=n,this._channelManager=s}get collection(){const{nestdb:n}=this._cacheContext;return e.unless(!!n).throw(e.SendbirdError.databaseError),n.collection(t.NESTDB_FEEDCHANNEL_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 this._channelManager.buildFeedChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}get(t){return e.__awaiter(this,void 0,void 0,(function*(){if(this._channels.has(t))return this._channels.get(t);if(this.localCacheEnabled){const e=yield this.collection.getByKey(t);if(e)return this._channels.set(t,this._deserialize(e)),this._channels.get(t)}}))}fetch({token:n,limit:i=t.DEFAULT_FEED_LIMIT,backward:a=!1,order:o="latest_last_message",borderlineChannelUrl:r}){return e.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const e={where:e=>{if(n&&"latest_last_message"===o)if(!a&&e.lastMessageUpdatedAt>n||a&&e.lastMessageUpdatedAtthis._deserialize(e)));return l.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),l}return[]}))}upsert(t){return e.__awaiter(this,void 0,void 0,(function*(){const n=[];if(t.forEach((t=>{if(this._channels.has(t.url)){const s=this._channels.get(t.url),i=e.deundefined(t);Object.assign(s,i,{_iid:this._iid}),n.push(s)}else this._channels.set(t.url,t),n.push(t)})),this.localCacheEnabled){const e=[];for(let t=0;te.__awaiter(this,void 0,void 0,(function*(){if(s instanceof l){const{channels:e,context:i,isWebSocketEventComing:a}=s,o=e.filter((e=>e instanceof x)),r=yield t.upsert(o);yield Promise.all(o.map((e=>n.markAsReadByTimestamp(e.url,e.myLastRead)))),a||this._broadcastUpdateEvent(r,i)}else if(s instanceof d){const{channelUrls:i,context:a,isWebSocketEventComing:o}=s;yield t.remove(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of i)yield n.removeMessagesOfChannel(e)})))),o||this._broadcastRemoveEvent(i,a)}else s instanceof i.DatabaseOpenCommand&&(yield t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const n of this._observers.values())n.onUpdate&&n.onUpdate(e,t)}_broadcastRemoveEvent(e,t){for(const n of this._observers.values())n.onRemove&&n.onRemove(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const h=!1;class u extends e.APIRequestCommand{constructor(t){super();const{userId:n,token:s,limit:i,includeEmpty:a}=t;this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(n)}/my_group_channels`,this.params=e.deundefined({token:s,limit:i,show_empty:null!=a?a:h,show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0,is_feed_channel:!0,order:"latest_last_message"})}}class _ extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:n,channels:s,ts:i}=t;this.token=n,this.ts=null!=i?i:0,this.channels=(null!=s?s:[]).map((t=>(t.ts=i,new x(e,t))))}}class g extends e.APIRequestCommand{constructor({channelUrl:t,isInternalCall:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${n?e.API_PATH_GROUP_CHANNELS_INTERNAL:e.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,is_feed_channel:!0}}}class f extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new x(e,t)}}const C={includeEmpty:!0},m=t=>e.isTypeOf("boolean",t.includeEmpty);class p extends e.APIRequestCommand{constructor({userId:t,ts:n,token:s,params:i}){super();const{includeEmpty:a}=Object.assign(Object.assign({},C),i);this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels/changelogs`,this.params=e.deundefined(e.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,is_feed_channel:!0,show_empty:a,change_ts:n||null,token:s}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((t=>new x(e,t))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next}}class E extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/settings`}}class y extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}const b=20;class M extends e.APIRequestCommand{constructor(t){const{reverse:n=!1,keys:s,limit:i=b,token:a}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates`,this.params=e.deundefined({token:a,keys:s,limit:i,reverse:n,order:"updated_at",show_ui_template:!0,show_color_variables:!0})}}class w extends e.APIResponseCommand{constructor(t,n){super(t,n);const{next:s,has_more:i=!1}=n,a=e.__rest(n,["next","has_more"]);this.nextToken=s,this.hasMore=i,this.notificationTemplateList={jsonString:JSON.stringify(a)}}}const T={reverse:!1,keys:void 0,limit:20};class S extends e.APIRequestCommand{constructor(t){const{key:n}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates/${n}`,this.params=e.deundefined({key:n})}}class I extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}class N extends e.WebSocketEventCommand{constructor(n,s,i){var a,o,r;super(n,"ADMM",i),this.message=new t.NotificationMessage(n,i);const{sdkState:l}=e.Vault.of(n);this.isMentioned=e.checkIfMentioned(this.message.mentionType,null!==(r=null!==(a=this.message.mentionedUserIds)&&void 0!==a?a:null===(o=this.message.mentionedUsers)||void 0===o?void 0:o.map((e=>e.userId)))&&void 0!==r?r:[],l.userId)}}class A extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS_USERS}/${encodeURIComponent(t)}/unread_message_count`}}const O={};class k extends a.BaseChannelManager{get _notificationMessageCache(){return t.NotificationMessageCache.of(this._iid)}constructor(n,s){super(n,Object.assign(Object.assign({},s),{channelType:e.ChannelType.FEED})),this._feedChannelHandlers=new Map,this._feedChannelCache=new r(this._iid,{sdkState:this._sdkState,cacheContext:this._cacheContext,channelManager:this}),this._feedChannelBroadcast=new c({feedChannelCache:this._feedChannelCache,dispatcher:this._dispatcher,notificationMessageCache:t.NotificationMessageCache.of(n)}),this._dispatcher.on((t=>{t instanceof e.WebSocketEventCommand&&this._handleEvent(t).catch((t=>{if(e.isThrowingOutside(t))throw t}))})),O[n]||(O[n]=this)}static of(t){return O[t]||(O[t]=new k(t,e.Vault.of(t))),O[t]}static clear(e){O[e]&&delete O[e]}get handlers(){return[...this._feedChannelHandlers.values()]}buildFeedChannelFromSerializedData(t){const n=e.deserialize(t);return new x(this._iid,x.payloadify(n))}addHandler(e,t){this._feedChannelHandlers.set(e,t)}removeHandler(e){this._feedChannelHandlers.delete(e)}clearHandler(){this._feedChannelHandlers.clear()}getMyFeedChannels(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){const e=new u(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:s})),i=yield this._requestQueue.send(e),{channels:a,token:o}=i.as(_);return{channels:a,token:o}}))}getChannel(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(t);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(t,n)}))}getChannelFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),null!==(n=yield this._feedChannelCache.get(t))&&void 0!==n?n:null}))}getChannelWithoutCache(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const s=new g({channelUrl:t,isInternalCall:n}),i=yield this._requestQueue.send(s),{channel:a}=i.as(f),[o]=yield this.upsertChannelsToCache([a]);return o}))}getMyFeedChannelChangeLogs(t,n,s=e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},C),n);e.unless((e.isTypeOf("string",t)||e.isTypeOf("number",t))&&m(i)).throw(e.SendbirdError.invalidParameters);const a=new p(e.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,params:i})),o=yield this._requestQueue.send(a),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}=o.as(v);return r.length>0&&this._dispatcher.dispatch(new l({channels:r,context:{source:s}})),c.length>0&&this._dispatcher.dispatch(new d({channelUrls:c,context:{source:s}})),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}}))}getTotalUnreadMessageCount(t){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},n.TotalUnreadMessageCountParamsDefault),t);e.unless(n.validateTotalUnreadMessageCountParams(s)).throw(e.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:a}=e.Vault.of(this._iid),o=new n.GetTotalUnreadMessageCountRequestCommand({userId:i.userId,filter:s,includeFeedChannel:!0}),r=yield a.send(o),{unreadFeedCount:l=0}=r.as(n.GetTotalUnreadMessageCountResponseCommand);return l}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),i=new A({userId:t.userId}),a=yield s.send(i),{unreadFeedCount:o=0}=a.as(n.GetTotalUnreadMessageCountResponseCommand);return o}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){const e=new E,t=yield this._requestQueue.send(e),{jsonString:n}=t.as(y);return{jsonString:n}}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},T),n);e.unless(e.isTypeOf("string",t)&&(t=>e.isTypeOf("boolean",t.reverse,!0)&&e.isArrayOf("string",t.keys,!0)&&e.isTypeOf("number",t.limit,!0))(s)).throw(e.SendbirdError.invalidParameters);const i=new M({token:t,keys:s.keys,reverse:s.reverse,limit:s.limit}),a=yield this._requestQueue.send(i),{hasMore:o,nextToken:r,notificationTemplateList:l}=a.as(w);return{hasMore:o,token:r,notificationTemplateList:l}}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=new S({key:t}),s=yield this._requestQueue.send(n),{jsonString:i}=s.as(I);return{jsonString:i}}))}upsertChannelsToCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._feedChannelCache.upsert(t)}))}removeChannelsFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this._feedChannelCache.remove(t)}))}getNotificationMessageFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.get(t)}))}refreshChannel(t,s=!0,i=e.CollectionEventSource.REFRESH_CHANNEL){return e.__awaiter(this,void 0,void 0,(function*(){try{const e=new g({channelUrl:t,isInternalCall:s}),a=yield this._requestQueue.send(e),{channel:o}=a.as(f);if(o.myMemberState===n.MemberState.NONE)this._dispatcher.dispatch(new d({channelUrls:[o.url],context:{source:i}}));else{const e=yield this.upsertChannelsToCache([o]);this._dispatcher.dispatch(new l({channels:e,context:{source:i}}))}}catch(n){n.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&n.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new d({channelUrls:[t],context:{source:i}}))}}))}refreshNotificationCollections(){this._dispatcher.dispatch(new s.NotificationCollectionRefreshCommand)}subscribeChannelEvent(e,t){this._feedChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._feedChannelBroadcast.unsubscribe(e)}_handleEvent(n){return e.__awaiter(this,void 0,void 0,(function*(){switch(n.code){case"ADMM":case"BRDM":{const s="ADMM"===n.code||"BRDM"===n.code?n.as(N):null;if(s&&s.message.channelType===this._channelType){const{message:n,isMentioned:i}=s,a=yield this.getChannel(n.channelUrl,!0);a._runIfHandleableWithGroupChannel((s=>{var o;n instanceof t.NotificationMessage&&i&&(null===(o=n.mentionedUsers)||void 0===o||o.forEach((e=>{for(const t of s.members)if(e.userId===t.userId){e.nickname=t.nickname,e.plainProfileUrl=t.plainProfileUrl,e.metaData=t.metaData;break}}))),this._dispatcher.dispatch(new l({channels:[a],context:{source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),this._dispatcher.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageReceived&&e.onMessageReceived(a,n),i&&e.onMentionReceived&&e.onMentionReceived(a,n)}))))}))}break}case"READ":{const s="READ"===n.code?n.as(t.ReadEventCommand):null;if(s&&s.readStatus.channelType===this._channelType){const{readStatus:t}=s,n=this._feedChannelCache.isCachedInMemory(t.channelUrl),i=yield this.getChannel(t.channelUrl,!0);i._runIfHandleableWithGroupChannel((s=>{n&&s._updateUnreadMemberState(t.reader.userId,t.readAt),t.reader.userId===this._sdkState.userId&&(n?(s.unreadMessageCount>0||s.unreadMentionCount>0)&&(s._updateUnreadCount(0,0),this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))):0!==s.unreadMessageCount&&0!==s.unreadMentionCount||(this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))))}))}break}case"SYEV":{const t="SYEV"===n.code?n.as(a.ChannelEventCommand):null;if(t&&t.event.channelType===this._channelType){const{event:n}=t;switch(n.category){case a.ChannelEventCategory.CHANNEL_DELETED:{const t=yield this.getChannel(n.channelUrl,!0);this._dispatcher.dispatch(new d({channelUrls:[n.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(t.url,t.channelType)}))}))));break}case a.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const t=yield this.getChannelWithoutCache(n.channelUrl,!0);this._dispatcher.dispatch(new l({channels:[t],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(t)}))}))));break}}}break}}}))}getMessageFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(n=yield this._notificationMessageCache.get(t))&&void 0!==n?n:null}))}getExactlyMatchingMessagesForTokenFromCache(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:t,token:n,filter:s,exactMatch:!0})}))}getMessagesFromCache(n,s,i,a,o=t.DEFAULT_NOTIFICATION_LIMIT,r=!0){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:n,token:s,limit:o,filter:a,backward:"next"===i,inclusive:r})}))}}class R extends n.BaseMessageCollection{keyOf(e){return e.notificationId}get changelogIncludeParams(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}constructor(t,n){super(t,Object.assign(Object.assign({},n),{channelManager:k.of(t)}));const{connectionManager:i,dispatcher:a}=e.Vault.of(this._iid);this._notificationCollectionEventContext=a.on((t=>{t instanceof s.NotificationCollectionRefreshCommand&&e.sleep(10).then((()=>{i.isConnected||i.isConnecting||this.refresh()}))}))}dispose(){super.dispose(),this._notificationCollectionEventContext.close()}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_postprocessChannelUpdateEvent(e,n){const s=this._messages.filter((n=>n.messageStatus===t.NotificationMessageStatus.SENT&&n.createdAt<=e.myLastRead));if(s.length>0){for(const e of s)e.messageStatus=t.NotificationMessageStatus.READ;this._updateMessagesToView(s,n)}}_postprocessMessageUpdateEvent(n,s){switch(s){case e.CollectionEventSource.EVENT_CHANNEL_READ:{const e=[],i=this._messages.map((e=>e.notificationId));for(const{notificationId:s}of n){const n=i.indexOf(s);n>=0&&(this._messages[n].messageStatus=t.NotificationMessageStatus.READ,e.push(this._messages[n]))}e.length>0&&this._updateMessagesToView(e,s);break}}}_addMessagesToView(t,s){const i=this._filterUnderOffsetMessage(t),a=[],o=[];for(const t of i)if(s===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(n.indexOfMessage(this._messages,t)<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}}else{const e=n.indexOfMessage(this._messages,t);if(e<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}else this._messages[e]=t,o.push(t)}e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n,i;const r={source:s};a.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===t||t.call(e,r,this.channel,a)),o.length>0&&(null===(i=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===i||i.call(n,r,this.channel,o))}))))}_updateMessagesToView(t,s){const i=[];for(const e of t){const t=n.indexOfMessage(this._messages,e);t>=0&&(i.push(e),this._messages[t]=e)}return e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t;const n={source:s};i.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===t||t.call(e,n,this.channel,i))})))),i}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._activate()}))}}class x extends t.BaseChannel{static payloadify(e){var s;return Object.assign(Object.assign({},n.GroupChannel.payloadify(null!==(s=e._groupChannel)&&void 0!==s?s:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((e=>o.payloadify(e))),last_message:e.lastMessage?t.NotificationMessage.payloadify(e.lastMessage):null})}constructor(s,i){var a,r;super(s,i),this.channelType=e.ChannelType.FEED,this._groupChannel=new n.GroupChannel(s,i),this.isCategoryFilterEnabled=null!==(a=i.is_category_filter_enabled)&&void 0!==a&&a,this.isTemplateLabelEnabled=null===(r=i.is_template_label_enabled)||void 0===r||r,this.notificationCategories=i.categories?i.categories.map((e=>new o(e))):[],this.lastMessage=i.last_message?t.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},i.last_message)):null}get groupChannel(){return this._groupChannel}get url(){return this._groupChannel.url}get name(){return this._groupChannel.name}set name(e){this._groupChannel.name=e}get createdAt(){return this._groupChannel.createdAt}get members(){return this._groupChannel.members}get memberCount(){return this._groupChannel.memberCount}get myMemberState(){return this._groupChannel.myMemberState}get myLastRead(){return this._groupChannel.myLastRead}get unreadMessageCount(){return this._groupChannel.unreadMessageCount}serialize(){var t,n;return Object.assign(Object.assign({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((t=>e.serialize(t))),lastMessage:null!==(n=null===(t=this.lastMessage)||void 0===t?void 0:t.serialize())&&void 0!==n?n:null})}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannel._refresh(!0),this}))}markAsRead(n){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,dispatcher:i,requestQueue:a}=e.Vault.of(this._iid),o=null==n?void 0:n.filter((e=>!e||e.messageStatus===t.NotificationMessageStatus.SENT)).map((e=>e.notificationId));if(!o||o.length>0){const r=new t.ReadAPIRequestCommand({userId:s.userId,channelUrl:this.url,channelType:e.ChannelType.FEED,notificationIds:o}),d=yield a.send(r),{unreadMessageCount:c,readAt:h}=d.as(t.ReadAPIResponseCommand);if(n){if("number"==typeof c){this._groupChannel._updateUnreadCount(c,this._groupChannel.unreadMentionCount);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}n.forEach((e=>{e.messageStatus=t.NotificationMessageStatus.READ})),i.dispatch(new e.MessageUpdateEventCommand({messages:n,source:e.CollectionEventSource.EVENT_CHANNEL_READ}))}else if(this._groupChannel._updateUnreadMemberState(s.userId,h),this._groupChannel.unreadMessageCount!==c){this._groupChannel._updateUnreadCount(c,0);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}i.dispatch(new l({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}))}}))}markAsClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this.logClicked(t)}))}logClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30)for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}))}))}logImpression(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.logViewed(t)}))}logViewed(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30){for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}));return!0}return!1}))}logCustom(t,n){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:s}=e.Vault.of(this._iid);if(0{Object.prototype.hasOwnProperty.call(this,t)&&(this[t]=e[t])}))}}class D extends e.BaseListQuery{constructor(e,t){var n;super(e,t),this.includeEmpty=h,this.includeEmpty=null!==(n=t.includeEmpty)&&void 0!==n?n:h}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)}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 t=k.of(this._iid),n=e.undefineNullProps(Object.assign({},this)),{channels:s,token:i}=yield t.getMyFeedChannels(this._token,n,this.limit);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class F extends e.Module{constructor(){super(...arguments),this.name="feedChannel"}init(e,t){super.init(e,t),this._manager=new k(e,t)}buildFeedChannelFromSerializedData(e){return this._manager.buildFeedChannelFromSerializedData(e)}createMyFeedChannelListQuery(e={}){return new D(this._iid,e)}addFeedChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof P).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeFeedChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}removeAllFeedChannelHandlers(){this._manager.clearHandler()}getChannel(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getMyFeedChannelChangeLogsByTimestamp(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("number",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getMyFeedChannelChangeLogsByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("string",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.getTotalUnreadNotificationCount()}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadNotificationCount()}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getGlobalNotificationChannelSetting()}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplateListByToken(t,n)}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplate(t)}))}refreshNotificationCollections(){this._manager.refreshNotificationCollections()}}exports.NotificationMessage=t.NotificationMessage,Object.defineProperty(exports,"NotificationMessageStatus",{enumerable:!0,get:function(){return t.NotificationMessageStatus}}),exports.FeedChannel=x,exports.FeedChannelHandler=P,exports.FeedChannelListQuery=D,exports.FeedChannelModule=F,exports.NotificationCategory=o,exports.NotificationCollection=R; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),t=require("./lib/__bundle-4bcf4070.cjs"),n=require("./lib/__bundle-0fbd5934.cjs"),s=require("./lib/__bundle-d1419fd1.cjs"),i=require("./lib/__bundle-0f6b8ff3.cjs"),a=require("./lib/__bundle-12c1cdf9.cjs");require("./lib/__bundle-d349e14c.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class o{constructor(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}static payloadify(t){return e.deundefined(e.undefineNullProps({id:t.id,name:t.name,is_default:t.isDefault}))}get customType(){return this.isDefault?"*":String(this.id)}}class r extends e.InstancedObject{constructor(e,{sdkState:t,cacheContext:n,channelManager:s}){super(e),this._channels=new Map,this._sdkState=t,this._cacheContext=n,this._channelManager=s}get collection(){const{nestdb:n}=this._cacheContext;return e.unless(!!n).throw(e.SendbirdError.databaseError),n.collection(t.NESTDB_FEEDCHANNEL_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 this._channelManager.buildFeedChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}get(t){return e.__awaiter(this,void 0,void 0,(function*(){if(this._channels.has(t))return this._channels.get(t);if(this.localCacheEnabled){const e=yield this.collection.getByKey(t);if(e)return this._channels.set(t,this._deserialize(e)),this._channels.get(t)}}))}fetch({token:n,limit:i=t.DEFAULT_FEED_LIMIT,backward:a=!1,order:o="latest_last_message",borderlineChannelUrl:r}){return e.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const e={where:e=>{if(n&&"latest_last_message"===o)if(!a&&e.lastMessageUpdatedAt>n||a&&e.lastMessageUpdatedAtthis._deserialize(e)));return l.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),l}return[]}))}upsert(t){return e.__awaiter(this,void 0,void 0,(function*(){const n=[];if(t.forEach((t=>{if(this._channels.has(t.url)){const s=this._channels.get(t.url),i=e.deundefined(t);Object.assign(s,i,{_iid:this._iid}),n.push(s)}else this._channels.set(t.url,t),n.push(t)})),this.localCacheEnabled){const e=[];for(let t=0;te.__awaiter(this,void 0,void 0,(function*(){if(s instanceof l){const{channels:e,context:i,isWebSocketEventComing:a}=s,o=e.filter((e=>e instanceof x)),r=yield t.upsert(o);yield Promise.all(o.map((e=>n.markAsReadByTimestamp(e.url,e.myLastRead)))),a||this._broadcastUpdateEvent(r,i)}else if(s instanceof d){const{channelUrls:i,context:a,isWebSocketEventComing:o}=s;yield t.remove(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of i)yield n.removeMessagesOfChannel(e)})))),o||this._broadcastRemoveEvent(i,a)}else s instanceof i.DatabaseOpenCommand&&(yield t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const n of this._observers.values())n.onUpdate&&n.onUpdate(e,t)}_broadcastRemoveEvent(e,t){for(const n of this._observers.values())n.onRemove&&n.onRemove(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const h=!1;class u extends e.APIRequestCommand{constructor(t){super();const{userId:n,token:s,limit:i,includeEmpty:a}=t;this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(n)}/my_group_channels`,this.params=e.deundefined({token:s,limit:i,show_empty:null!=a?a:h,show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0,is_feed_channel:!0,order:"latest_last_message"})}}class _ extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:n,channels:s,ts:i}=t;this.token=n,this.ts=null!=i?i:0,this.channels=(null!=s?s:[]).map((t=>(t.ts=i,new x(e,t))))}}class g extends e.APIRequestCommand{constructor({channelUrl:t,isInternalCall:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${n?e.API_PATH_GROUP_CHANNELS_INTERNAL:e.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,is_feed_channel:!0}}}class f extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new x(e,t)}}const C={includeEmpty:!0},m=t=>e.isTypeOf("boolean",t.includeEmpty);class p extends e.APIRequestCommand{constructor({userId:t,ts:n,token:s,params:i}){super();const{includeEmpty:a}=Object.assign(Object.assign({},C),i);this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels/changelogs`,this.params=e.deundefined(e.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,is_feed_channel:!0,show_empty:a,change_ts:n||null,token:s}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((t=>new x(e,t))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next}}class E extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/settings`}}class y extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}const b=20;class M extends e.APIRequestCommand{constructor(t){const{reverse:n=!1,keys:s,limit:i=b,token:a}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates`,this.params=e.deundefined({token:a,keys:s,limit:i,reverse:n,order:"updated_at",show_ui_template:!0,show_color_variables:!0})}}class w extends e.APIResponseCommand{constructor(t,n){super(t,n);const{next:s,has_more:i=!1}=n,a=e.__rest(n,["next","has_more"]);this.nextToken=s,this.hasMore=i,this.notificationTemplateList={jsonString:JSON.stringify(a)}}}const T={reverse:!1,keys:void 0,limit:20};class S extends e.APIRequestCommand{constructor(t){const{key:n}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates/${n}`,this.params=e.deundefined({key:n})}}class I extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}class N extends e.WebSocketEventCommand{constructor(n,s,i){var a,o,r;super(n,"ADMM",i),this.message=new t.NotificationMessage(n,i);const{sdkState:l}=e.Vault.of(n);this.isMentioned=e.checkIfMentioned(this.message.mentionType,null!==(r=null!==(a=this.message.mentionedUserIds)&&void 0!==a?a:null===(o=this.message.mentionedUsers)||void 0===o?void 0:o.map((e=>e.userId)))&&void 0!==r?r:[],l.userId)}}class A extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS_USERS}/${encodeURIComponent(t)}/unread_message_count`}}const O={};class k extends a.BaseChannelManager{get _notificationMessageCache(){return t.NotificationMessageCache.of(this._iid)}constructor(n,s){super(n,Object.assign(Object.assign({},s),{channelType:e.ChannelType.FEED})),this._feedChannelHandlers=new Map,this._feedChannelCache=new r(this._iid,{sdkState:this._sdkState,cacheContext:this._cacheContext,channelManager:this}),this._feedChannelBroadcast=new c({feedChannelCache:this._feedChannelCache,dispatcher:this._dispatcher,notificationMessageCache:t.NotificationMessageCache.of(n)}),this._dispatcher.on((t=>{t instanceof e.WebSocketEventCommand&&this._handleEvent(t).catch((t=>{if(e.isThrowingOutside(t))throw t}))})),O[n]||(O[n]=this)}static of(t){return O[t]||(O[t]=new k(t,e.Vault.of(t))),O[t]}static clear(e){O[e]&&delete O[e]}get handlers(){return[...this._feedChannelHandlers.values()]}buildFeedChannelFromSerializedData(t){const n=e.deserialize(t);return new x(this._iid,x.payloadify(n))}addHandler(e,t){this._feedChannelHandlers.set(e,t)}removeHandler(e){this._feedChannelHandlers.delete(e)}clearHandler(){this._feedChannelHandlers.clear()}getMyFeedChannels(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){const e=new u(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:s})),i=yield this._requestQueue.send(e),{channels:a,token:o}=i.as(_);return{channels:a,token:o}}))}getChannel(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(t);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(t,n)}))}getChannelFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),null!==(n=yield this._feedChannelCache.get(t))&&void 0!==n?n:null}))}getChannelWithoutCache(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const s=new g({channelUrl:t,isInternalCall:n}),i=yield this._requestQueue.send(s),{channel:a}=i.as(f),[o]=yield this.upsertChannelsToCache([a]);return o}))}getMyFeedChannelChangeLogs(t,n,s=e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},C),n);e.unless((e.isTypeOf("string",t)||e.isTypeOf("number",t))&&m(i)).throw(e.SendbirdError.invalidParameters);const a=new p(e.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,params:i})),o=yield this._requestQueue.send(a),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}=o.as(v);return r.length>0&&this._dispatcher.dispatch(new l({channels:r,context:{source:s}})),c.length>0&&this._dispatcher.dispatch(new d({channelUrls:c,context:{source:s}})),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}}))}getTotalUnreadMessageCount(t){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},n.TotalUnreadMessageCountParamsDefault),t);e.unless(n.validateTotalUnreadMessageCountParams(s)).throw(e.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:a}=e.Vault.of(this._iid),o=new n.GetTotalUnreadMessageCountRequestCommand({userId:i.userId,filter:s,includeFeedChannel:!0}),r=yield a.send(o),{unreadFeedCount:l=0}=r.as(n.GetTotalUnreadMessageCountResponseCommand);return l}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),i=new A({userId:t.userId}),a=yield s.send(i),{unreadFeedCount:o=0}=a.as(n.GetTotalUnreadMessageCountResponseCommand);return o}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){const e=new E,t=yield this._requestQueue.send(e),{jsonString:n}=t.as(y);return{jsonString:n}}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},T),n);e.unless(e.isTypeOf("string",t)&&(t=>e.isTypeOf("boolean",t.reverse,!0)&&e.isArrayOf("string",t.keys,!0)&&e.isTypeOf("number",t.limit,!0))(s)).throw(e.SendbirdError.invalidParameters);const i=new M({token:t,keys:s.keys,reverse:s.reverse,limit:s.limit}),a=yield this._requestQueue.send(i),{hasMore:o,nextToken:r,notificationTemplateList:l}=a.as(w);return{hasMore:o,token:r,notificationTemplateList:l}}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=new S({key:t}),s=yield this._requestQueue.send(n),{jsonString:i}=s.as(I);return{jsonString:i}}))}upsertChannelsToCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._feedChannelCache.upsert(t)}))}removeChannelsFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this._feedChannelCache.remove(t)}))}getNotificationMessageFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.get(t)}))}refreshChannel(t,s=!0,i=e.CollectionEventSource.REFRESH_CHANNEL){return e.__awaiter(this,void 0,void 0,(function*(){try{const e=new g({channelUrl:t,isInternalCall:s}),a=yield this._requestQueue.send(e),{channel:o}=a.as(f);if(o.myMemberState===n.MemberState.NONE)this._dispatcher.dispatch(new d({channelUrls:[o.url],context:{source:i}}));else{const e=yield this.upsertChannelsToCache([o]);this._dispatcher.dispatch(new l({channels:e,context:{source:i}}))}}catch(n){n.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&n.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new d({channelUrls:[t],context:{source:i}}))}}))}refreshNotificationCollections(){this._dispatcher.dispatch(new s.NotificationCollectionRefreshCommand)}subscribeChannelEvent(e,t){this._feedChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._feedChannelBroadcast.unsubscribe(e)}_handleEvent(n){return e.__awaiter(this,void 0,void 0,(function*(){switch(n.code){case"ADMM":case"BRDM":{const s="ADMM"===n.code||"BRDM"===n.code?n.as(N):null;if(s&&s.message.channelType===this._channelType){const{message:n,isMentioned:i}=s,a=yield this.getChannel(n.channelUrl,!0);a._runIfHandleableWithGroupChannel((s=>{var o;n instanceof t.NotificationMessage&&i&&(null===(o=n.mentionedUsers)||void 0===o||o.forEach((e=>{for(const t of s.members)if(e.userId===t.userId){e.nickname=t.nickname,e.plainProfileUrl=t.plainProfileUrl,e.metaData=t.metaData;break}}))),this._dispatcher.dispatch(new l({channels:[a],context:{source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),this._dispatcher.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageReceived&&e.onMessageReceived(a,n),i&&e.onMentionReceived&&e.onMentionReceived(a,n)}))))}))}break}case"READ":{const s="READ"===n.code?n.as(t.ReadEventCommand):null;if(s&&s.readStatus.channelType===this._channelType){const{readStatus:t}=s,n=this._feedChannelCache.isCachedInMemory(t.channelUrl),i=yield this.getChannel(t.channelUrl,!0);i._runIfHandleableWithGroupChannel((s=>{n&&s._updateUnreadMemberState(t.reader.userId,t.readAt),t.reader.userId===this._sdkState.userId&&(n?(s.unreadMessageCount>0||s.unreadMentionCount>0)&&(s._updateUnreadCount(0,0),this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))):0!==s.unreadMessageCount&&0!==s.unreadMentionCount||(this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))))}))}break}case"SYEV":{const t="SYEV"===n.code?n.as(a.ChannelEventCommand):null;if(t&&t.event.channelType===this._channelType){const{event:n}=t;switch(n.category){case a.ChannelEventCategory.CHANNEL_DELETED:{const t=yield this.getChannel(n.channelUrl,!0);this._dispatcher.dispatch(new d({channelUrls:[n.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(t.url,t.channelType)}))}))));break}case a.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const t=yield this.getChannelWithoutCache(n.channelUrl,!0);this._dispatcher.dispatch(new l({channels:[t],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(t)}))}))));break}}}break}}}))}getMessageFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(n=yield this._notificationMessageCache.get(t))&&void 0!==n?n:null}))}getExactlyMatchingMessagesForTokenFromCache(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:t,token:n,filter:s,exactMatch:!0})}))}getMessagesFromCache(n,s,i,a,o=t.DEFAULT_NOTIFICATION_LIMIT,r=!0){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:n,token:s,limit:o,filter:a,backward:"next"===i,inclusive:r})}))}}class R extends n.BaseMessageCollection{keyOf(e){return e.notificationId}get changelogIncludeParams(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}constructor(t,n){super(t,Object.assign(Object.assign({},n),{channelManager:k.of(t)}));const{connectionManager:i,dispatcher:a}=e.Vault.of(this._iid);this._notificationCollectionEventContext=a.on((t=>{t instanceof s.NotificationCollectionRefreshCommand&&e.sleep(10).then((()=>{i.isConnected||i.isConnecting||this.refresh()}))}))}dispose(){super.dispose(),this._notificationCollectionEventContext.close()}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_postprocessChannelUpdateEvent(e,n){const s=this._messages.filter((n=>n.messageStatus===t.NotificationMessageStatus.SENT&&n.createdAt<=e.myLastRead));if(s.length>0){for(const e of s)e.messageStatus=t.NotificationMessageStatus.READ;this._updateMessagesToView(s,n)}}_postprocessMessageUpdateEvent(n,s){switch(s){case e.CollectionEventSource.EVENT_CHANNEL_READ:{const e=[],i=this._messages.map((e=>e.notificationId));for(const{notificationId:s}of n){const n=i.indexOf(s);n>=0&&(this._messages[n].messageStatus=t.NotificationMessageStatus.READ,e.push(this._messages[n]))}e.length>0&&this._updateMessagesToView(e,s);break}}}_addMessagesToView(t,s){const i=this._filterUnderOffsetMessage(t),a=[],o=[];for(const t of i)if(s===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(n.indexOfMessage(this._messages,t)<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}}else{const e=n.indexOfMessage(this._messages,t);if(e<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}else this._messages[e]=t,o.push(t)}e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n,i;const r={source:s};a.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===t||t.call(e,r,this.channel,a)),o.length>0&&(null===(i=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===i||i.call(n,r,this.channel,o))}))))}_updateMessagesToView(t,s){const i=[];for(const e of t){const t=n.indexOfMessage(this._messages,e);t>=0&&(i.push(e),this._messages[t]=e)}return e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t;const n={source:s};i.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===t||t.call(e,n,this.channel,i))})))),i}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._activate()}))}}class x extends t.BaseChannel{static payloadify(e){var s;return Object.assign(Object.assign({},n.GroupChannel.payloadify(null!==(s=e._groupChannel)&&void 0!==s?s:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((e=>o.payloadify(e))),last_message:e.lastMessage?t.NotificationMessage.payloadify(e.lastMessage):null})}constructor(s,i){var a,r;super(s,i),this.channelType=e.ChannelType.FEED,this._groupChannel=new n.GroupChannel(s,i),this.isCategoryFilterEnabled=null!==(a=i.is_category_filter_enabled)&&void 0!==a&&a,this.isTemplateLabelEnabled=null===(r=i.is_template_label_enabled)||void 0===r||r,this.notificationCategories=i.categories?i.categories.map((e=>new o(e))):[],this.lastMessage=i.last_message?t.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},i.last_message)):null}get groupChannel(){return this._groupChannel}get url(){return this._groupChannel.url}get name(){return this._groupChannel.name}set name(e){this._groupChannel.name=e}get createdAt(){return this._groupChannel.createdAt}get members(){return this._groupChannel.members}get memberCount(){return this._groupChannel.memberCount}get myMemberState(){return this._groupChannel.myMemberState}get myLastRead(){return this._groupChannel.myLastRead}get unreadMessageCount(){return this._groupChannel.unreadMessageCount}serialize(){var t,n;return Object.assign(Object.assign({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((t=>e.serialize(t))),lastMessage:null!==(n=null===(t=this.lastMessage)||void 0===t?void 0:t.serialize())&&void 0!==n?n:null})}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannel._refresh(!0),this}))}markAsRead(n){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,dispatcher:i,requestQueue:a}=e.Vault.of(this._iid),o=null==n?void 0:n.filter((e=>!e||e.messageStatus===t.NotificationMessageStatus.SENT)).map((e=>e.notificationId));if(!o||o.length>0){const r=new t.ReadAPIRequestCommand({userId:s.userId,channelUrl:this.url,channelType:e.ChannelType.FEED,notificationIds:o}),d=yield a.send(r),{unreadMessageCount:c,readAt:h}=d.as(t.ReadAPIResponseCommand);if(n){if("number"==typeof c){this._groupChannel._updateUnreadCount(c,this._groupChannel.unreadMentionCount);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}n.forEach((e=>{e.messageStatus=t.NotificationMessageStatus.READ})),i.dispatch(new e.MessageUpdateEventCommand({messages:n,source:e.CollectionEventSource.EVENT_CHANNEL_READ}))}else if(this._groupChannel._updateUnreadMemberState(s.userId,h),this._groupChannel.unreadMessageCount!==c){this._groupChannel._updateUnreadCount(c,0);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}i.dispatch(new l({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}))}}))}markAsClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this.logClicked(t)}))}logClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30)for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}))}))}logImpression(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.logViewed(t)}))}logViewed(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30){for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}));return!0}return!1}))}logCustom(t,n){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:s}=e.Vault.of(this._iid);if(0{Object.prototype.hasOwnProperty.call(this,t)&&(this[t]=e[t])}))}}class D extends e.BaseListQuery{constructor(e,t){var n;super(e,t),this.includeEmpty=h,this.includeEmpty=null!==(n=t.includeEmpty)&&void 0!==n?n:h}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)}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 t=k.of(this._iid),n=e.undefineNullProps(Object.assign({},this)),{channels:s,token:i}=yield t.getMyFeedChannels(this._token,n,this.limit);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class F extends e.Module{constructor(){super(...arguments),this.name="feedChannel"}init(e,t){super.init(e,t),this._manager=new k(e,t)}buildFeedChannelFromSerializedData(e){return this._manager.buildFeedChannelFromSerializedData(e)}createMyFeedChannelListQuery(e={}){return new D(this._iid,e)}addFeedChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof P).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeFeedChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}removeAllFeedChannelHandlers(){this._manager.clearHandler()}getChannel(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getMyFeedChannelChangeLogsByTimestamp(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("number",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getMyFeedChannelChangeLogsByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("string",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.getTotalUnreadNotificationCount()}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadNotificationCount()}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getGlobalNotificationChannelSetting()}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplateListByToken(t,n)}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplate(t)}))}refreshNotificationCollections(){this._manager.refreshNotificationCollections()}}exports.NotificationMessage=t.NotificationMessage,Object.defineProperty(exports,"NotificationMessageStatus",{enumerable:!0,get:function(){return t.NotificationMessageStatus}}),exports.FeedChannel=x,exports.FeedChannelHandler=P,exports.FeedChannelListQuery=D,exports.FeedChannelModule=F,exports.NotificationCategory=o,exports.NotificationCollection=R; diff --git a/cjs/groupChannel.cjs b/cjs/groupChannel.cjs index a9f559c..11b4918 100644 --- a/cjs/groupChannel.cjs +++ b/cjs/groupChannel.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),t=require("./lib/__bundle-dcf4d0c3.cjs"),n=require("./lib/__bundle-165fd6e1.cjs"),i=require("./lib/__bundle-2ad218ff.cjs"),s=require("./lib/__bundle-611abb88.cjs");require("./lib/__bundle-d3673ecc.cjs"),require("./lib/__bundle-dae7bdf2.cjs"),require("./lib/__bundle-bfe2e997.cjs");const r={};class a{constructor({_iid:n,limit:s=100}){this.ref=0,this._iid=n,this._limit=s;const{sdkState:r,dispatcher:a,logger:o,cacheContext:l,statManager:d}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${r.userId}@groupchannel/sync.meta`;const h=(e=>`sendbird:${e}@groupchannel/sync`)(r.userId);this._sync=new t.Sync(h,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,s,a,h,u,c,p,_;const g={hasNext:!0,nextToken:""};if(yield this.loadMetadata(),o.debug("channel background sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),null===(s=this._metadata)||void 0===s?void 0:s.completed)g.hasNext=!1,g.nextToken="";else{const n={includeEmpty:!0,includeMetaData:!0,order:i.GroupChannelListOrder.CHRONOLOGICAL};try{if(n.order===i.GroupChannelListOrder.LATEST_LAST_MESSAGE)try{const t=yield l.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(r.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const s=t.GroupChannelManager.of(this._iid),{channels:d,token:u}=yield s.getMyGroupChannels(null!==(h=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==h?h:"",n,this._limit,e.CollectionEventSource.SYNC_CHANNEL_BACKGROUND);g.hasNext=d.length>=this._limit&&!!u,g.nextToken=u,this._metadata&&(this._metadata.token=u,this._metadata.range.extends(...d.map((e=>e.createdAt))),this._metadata.completed=!g.hasNext),o.debug("channel background sync progress",g),yield this.saveMetadata()}catch(t){throw o.debug("channel background sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetaData()),t}finally{d.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=l.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:null!==(_=null===(p=n.order)||void 0===p?void 0:p.toString())&&void 0!==_?_:"",collection_id:r.userId}}))}}return g})))),this._connectionEventContext=a.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return r[e]||(r[e]=new a({_iid:e})),r[e].ref++,r[e]}static clear(e){r[e]&&(r[e].close(),delete r[e])}get range(){var e,n;return null!==(n=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==n?n:new t.TimeRange({})}get completed(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:n}=e.Vault.of(this._iid),i=yield n.preference.get(this._metadataKey);this._metadata={token:i?i.token:"",range:new t.TimeRange(i?i.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!i&&i.completed}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetaData(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){var t,n;const{logger:i,sessionManager:s}=e.Vault.of(this._iid);s.session.hasSession&&(i.debug("channel background sync resume()"),this._sync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.token)&&void 0!==n?n:""))}pause(){const{logger:t}=e.Vault.of(this._iid);t.debug("channel background sync stop()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete r[this._iid])}}const o={};class l{constructor({_iid:n}){this.ref=0,this._iid=n;const{logger:i,sdkState:s,dispatcher:r,cacheContext:a,statManager:o}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${s.userId}@groupchannel/changelogs.meta`,this._subscribers=new e.EventDispatcher;const l=(e=>`sendbird:${e}@groupchannel/changelogs`)(s.userId);this._sync=new t.Sync(l,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,r,l;const d={hasNext:!0,nextToken:0};yield this.loadMetadata(),i.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token);try{const n={includeEmpty:!0,includeMetaData:!0};try{const t=yield a.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(s.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const h=t.GroupChannelManager.of(this._iid),{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}=yield h.getMyGroupChannelChangeLogs(null!==(l=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==l?l:"",n,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);this._subscribers.dispatch("progress",{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}),d.hasNext=p,d.nextToken=_,this._metadata&&(this._metadata.token=_),i.debug("channel changelog sync progress",d),yield this.saveMetadata(),a.localCacheEnabled&&o.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:u.length>0||c.length>0?"cache_miss":"cache_hit",max_db_size:u.length,use_local_cache:a.localCacheEnabled,starting_point:0,message_init_policy:c.length.toString(),collection_id:s.userId}}))}catch(t){throw i.debug("channel changelog sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetadata()),t}return d})))),this._sync.on("stop",(()=>{this._subscribers.dispatch("pause")})),this._connectionEventContext=r.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return o[e]||(o[e]=new l({_iid:e})),o[e].ref++,o[e]}static clear(e){o[e]&&(o[e].close(),delete o[e])}get isRunning(){return this._sync.isRunning}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t,firstConnectedAt:n}=e.Vault.of(this._iid),i=yield t.preference.get(this._metadataKey);this._metadata={token:i?i.token:n}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}on(e,t){return this._subscribers.on(e,t)}resume(){const{sessionManager:t}=e.Vault.of(this._iid);t.session.hasSession&&this._sync.start(0)}pause(){this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete o[this._iid])}}const d=(e,t)=>e.findIndex((e=>e.isIdentical(t))),h=(e,t,n)=>{if(e.length>0){const i=d(e,t);let s=0,r=e.length-1,a=Math.floor((s+r)/2);for(;s0)r=a,a=Math.floor((s+r)/2);else{if(!(o<0))return{place:a,oldPosition:i};s=a+1,a=Math.floor((s+r)/2)}}return{place:u(e[a],t,n)>=0?a:a+1,oldPosition:i}}return{place:e.length,oldPosition:-1}},u=(e,t,n)=>{switch(n){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(e.lastMessage&&t.lastMessage){const n=t.lastMessage.createdAt-e.lastMessage.createdAt;return 0===n?t.createdAt-e.createdAt:n}return e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:{const n=e.name.localeCompare(t.name);return 0===n?e.createdAt-t.createdAt:n}default:return 0}};class c{constructor(s,{filter:r=new t.GroupChannelFilter,order:o=i.GroupChannelListOrder.LATEST_LAST_MESSAGE,limit:d=n.DEFAULT_GROUPCHANNEL_LIMIT,includeChangesOnInitialLoad:h=!1}){this.channels=[],this._isInitialized=!1,this._iid=s,this._key=`gcc-${e.uuid()}`,this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=h,this.filter=r,this.order=o,this._hasMore=!0,this._token="",this._limit=d;const{sdkState:u,cacheContext:c,dispatcher:p}=e.Vault.of(this._iid);c.localCacheEnabled&&(this._backgroundSync=a.of(s),this._backgroundSync.resume()),this._changelogSync=l.of(s),this._changelogSync.resume();t.GroupChannelManager.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:(e,n)=>{const{source:i}=n;if(t.shouldGiveEvent(i)){const t=e.filter((e=>this.filter.match(e,u.userId))),i=e.filter((e=>!this.filter.match(e,u.userId))).map((e=>e.url));t.length>0&&this._addChannelsToView(t,n),i.length>0&&this._removeChannelsFromView(i,n)}},onRemove:(e,t)=>{this._removeChannelsFromView(e,t)}}),p.on((t=>{t instanceof e.ConnectionStateChangeCommand&&(t.stateType===e.ConnectionStateType.CONNECTED?this._isGetRemoteChannelsSucceeded||(()=>{e.__awaiter(this,void 0,void 0,(function*(){yield this._revokeLoadMore()}))})():t.stateType===e.ConnectionStateType.LOGOUT&&this.dispose())}))}get hasMore(){return!this._isDisposed&&this._hasMore}setGroupChannelCollectionHandler(e){this._handler=e}_addChannelsToView(n,s,r=!1){const a=[],o=[],l=[];for(const t of n){const n=d(this.channels,t);n>=0&&this.channels.splice(n,1);const{place:u}=h(this.channels,t,this.order);if(n<0)u===this.channels.length?!r&&this._hasMore||(a.push(t),this.channels.push(t)):(a.push(t),this.channels.splice(u,0,t));else switch(s.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&u===this.channels.length?l.push(t):(this.channels.splice(u,0,t),o.push(t));break;default:this.channels.splice(u,0,t),o.push(t)}}if(l.length>0)for(const e of l){const t=d(this.channels,e);-1!==t&&this.channels.splice(t,1)}t.shouldGiveEvent(s.source)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n;a.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(s,a),o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(s,o),l.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(s,l.map((e=>e.url)))}))))}_removeChannelsFromView(n,i){const s=[];for(const e of n){const t=this.channels.findIndex((t=>t.url===e));t>=0&&(s.push(this.channels[t].url),this.channels.splice(t,1))}return t.shouldGiveEvent(i.source)&&s.length>0&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,s)})))),s}_getLocalChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.GroupChannelManager.of(this._iid),n=this.channels.length>0?((e,t)=>{var n,s,r,a;switch(t){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(s=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==s?s:e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(a=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:e.createdAt}})(this.channels[this.channels.length-1],this.order):null;return yield e.getChannelsFromCache(n,this.filter,this.order,this._limit,n?this.channels[this.channels.length-1].url:void 0)}))}_getRemoteChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const n=t.GroupChannelManager.of(this._iid),{channels:i,token:s}=yield n.getMyGroupChannels(this._token,e.undefineNullProps(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);return this._token=s,this._hasMore=!!s,i}))}_revokeLoadMore(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._isDisposed)try{const t=yield this._getRemoteChannels();this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(t,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}catch(e){this._isGetRemoteChannelsSucceeded=!1}}))}loadMore(){var t;return e.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new e.SendbirdError({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});let n=null;this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning&&(n=yield new Promise((e=>{this._changelogSyncSubscriberContext=this._changelogSync.on("progress",(t=>e(t))).on("pause",(()=>e(null)))})),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close());const{cacheContext:i,connectionManager:s,statManager:r}=e.Vault.of(this._iid);this._isInitialized||(this._isInitialized=!0,i.localCacheEnabled&&(yield this._backgroundSync.loadMetadata()),r.put(new e.DailyRecordStatLog({type:e.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}})));let a=[];if(this._hasMore){if(!i.localCacheEnabled||s.isConnected&&!this._backgroundSync.completed)try{a=yield this._getRemoteChannels(),this._isGetRemoteChannelsSucceeded=!0}catch(e){this._isGetRemoteChannelsSucceeded=!1}else yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){a=yield this._getLocalChannels()})))),this._hasMore=a.length>=this._limit;this._addChannelsToView(a,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}if(n){for(const e of n.updatedChannels){const t=d(a,e);if(t>=0)a[t]=e;else{const{place:t}=h(a,e,this.order);a.splice(t,0,e)}}const e=a.map((e=>e.url));for(const t of n.deletedChannelUrls){const n=e.indexOf(t);n>=0&&(a.splice(n,1),e.splice(n,1))}}return a}))}dispose(){var e,n,i;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===(n=this._changelogSync)||void 0===n||n.close(),null===(i=this._changelogSyncSubscriberContext)||void 0===i||i.close();t.GroupChannelManager.of(this._iid).unsubscribeChannelEvent(this._key)}}class p extends e.APIRequestCommand{constructor(n){const{token:i,limit:s,order:r,includeEmpty:a,membershipFilter:o,channelNameContainsFilter:l,channelUrlsFilter:d,customTypesFilter:h,customTypeStartsWithFilter:u,superChannelFilter:c,metadataOrderKeyFilter:p,metadataKey:_,metadataValues:g,metadataValueStartsWith:m,includeFrozen:C,includeMetaData:f}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_GROUP_CHANNELS,this.params=e.deundefined(e.undefineNullProps({token:i,limit:s,order:r,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:a,public_mode:t.PublicChannelFilter.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:d,custom_types:h,custom_type_startswith:u,super_mode:c,metadata_order_key:p,metadata_key:_,metadata_values:g,metadata_value_startswith:m,show_frozen:C,show_metadata:f}))}}class _ extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:i,channels:s,ts:r}=n;this.token=i,s&&s.length>0&&(this.channels=s.map((n=>(n.ts=r,new t.GroupChannel(e,n))))),this.ts="number"==typeof r?r:0}}var g;exports.MembershipFilter=void 0,(g=exports.MembershipFilter||(exports.MembershipFilter={})).ALL="all",g.JOINED="joined";class m extends e.BaseListQuery{constructor(e,n){var s,r,a,o,l,d,h,u,c,p,_,g,m,C;super(e,n),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=t.SuperChannelFilter.ALL,this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=i.PublicGroupChannelListOrder.CHRONOLOGICAL,this.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,this.customTypesFilter=null!==(l=n.customTypesFilter)&&void 0!==l?l:null,this.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,this.channelNameContainsFilter=null!==(h=n.channelNameContainsFilter)&&void 0!==h?h:null,this.membershipFilter=null!==(u=n.membershipFilter)&&void 0!==u?u:exports.MembershipFilter.ALL,this.superChannelFilter=null!==(c=n.superChannelFilter)&&void 0!==c?c:t.SuperChannelFilter.ALL,this.metadataKey=null!==(p=n.metadataKey)&&void 0!==p?p:null,this.metadataValues=null!==(_=n.metadataValues)&&void 0!==_?_:null,this.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,this.metadataValueStartsWith=null!==(m=n.metadataValueStartsWith)&&void 0!==m?m:null,this.order=null!==(C=n.order)&&void 0!==C?C:i.PublicGroupChannelListOrder.CHRONOLOGICAL}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.channelNameContainsFilter,!0)&&e.isArrayOf("string",this.channelUrlsFilter,!0)&&e.isArrayOf("string",this.customTypesFilter,!0)&&e.isTypeOf("string",this.customTypeStartsWithFilter,!0)&&e.isEnumOf(exports.MembershipFilter,this.membershipFilter)&&e.isEnumOf(t.SuperChannelFilter,this.superChannelFilter)&&e.isEnumOf(i.PublicGroupChannelListOrder,this.order)&&e.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&e.isTypeOf("string",this.metadataKey,!0)&&e.isArrayOf("string",this.metadataValues,!0)&&e.isTypeOf("string",this.metadataValueStartsWith,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;{const t=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),n=new p(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{channels:s,token:r}=i.as(_);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return t}}throw e.SendbirdError.invalidParameters}))}}class C extends s.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserJoined=e.noop,this.onUserLeft=e.noop,this.onUserReceivedInvitation=e.noop,this.onUserDeclinedInvitation=e.noop,this.onChannelHidden=e.noop,this.onUnreadMemberStatusUpdated=e.noop,this.onUndeliveredMemberStatusUpdated=e.noop,this.onTypingStatusUpdated=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop,this.onPinnedMessageUpdated=e.noop}}class f extends C{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class y extends e.APIRequestCommand{constructor(t){const{token:n,limit:i,order:s,reverse:r,channelUrl:a,messageTypeFilter:o,scheduledStatus:l}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_SCHEDULED_MESSAGES}`,this.params=e.deundefined(e.undefineNullProps({token:n,limit:i,reverse:r,channel_url:a,order:s,message_type:o,status:l}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.scheduledMessages=[];const{next:i,scheduled_messages:s}=t;this.token=i,this.scheduledMessages=s.map((t=>n.parseMessagePayload(e,t)))}}class b extends e.BaseListQuery{constructor(t,n){var i,s,r,a,o;super(t,n),this.channelUrl=null,this.order=null,this.reverse=!1,this.scheduledStatus=null,this.messageTypeFilter=e.MessageTypeFilter.ALL,this.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,this.order=null!==(s=n.order)&&void 0!==s?s:null,this.reverse=null!==(r=n.reverse)&&void 0!==r&&r,this.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,this.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:e.MessageTypeFilter.ALL}_validate(){return super._validate()&&e.isTypeOf("string",this.channelUrl,!0)&&(e.isEnumOf(i.ScheduledMessageListOrder,this.order)||null===this.order)&&e.isTypeOf("boolean",this.reverse)&&(e.isArrayOf(n.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&e.isEnumOf(e.MessageTypeFilter,this.messageTypeFilter)}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),n=new y(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{scheduledMessages:s,token:r}=i.as(v);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class S extends e.Module{constructor(){super(...arguments),this.name="groupChannel"}init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}){super.init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}),this._manager=new t.GroupChannelManager(e,{sdkState:n,cacheContext:l,dispatcher:i,sessionManager:s,requestQueue:r,logger:a})}createGroupChannelCollection(e={}){return new c(this._iid,e)}createMyGroupChannelListQuery(e={}){return new t.GroupChannelListQuery(this._iid,e)}createPublicGroupChannelListQuery(e={}){return new m(this._iid,e)}createScheduledMessageListQuery(e={}){return new b(this._iid,e)}addGroupChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof f).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeGroupChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}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(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getChannelWithoutCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannelWithoutCache(t)}))}getMyGroupChannelChangeLogsByToken(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("string",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getMyGroupChannelChangeLogsByTimestamp(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("number",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getGroupChannelCount(n){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCountParamsDefault),n);return e.unless(t.validateGroupChannelCountParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.getGroupChannelCount(i)}))}getUnreadItemCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getUnreadItemCount(t)}))}getTotalUnreadChannelCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadChannelCount()}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadMessageCount(t)}))}getTotalScheduledMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalScheduledMessageCount(t)}))}getSubscribedTotalUnreadMessageCount(){return this._manager.getSubscribedTotalUnreadMessageCount()}getSubscribedCustomTypeTotalUnreadMessageCount(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}getSubscribedCustomTypeUnreadMessageCount(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.createChannel(i)}))}createDistinctChannelIfNotExist(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),i&&(i.isDistinct=!0),this.createChannel(i)}))}createChannelWithUserIds(n,i=!1,s,r,a="",o=""){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),{invitedUserIds:n,isDistinct:i,name:s,data:a,customType:o});return"string"==typeof r?e.coverUrl=r:e.coverImage=r,this.createChannel(e)}))}markAsReadAll(){return e.__awaiter(this,void 0,void 0,(function*(){this._manager.markAsReadAll()}))}markAsReadWithChannelUrls(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.markAsReadWithChannelUrls(t)}))}markAsDelivered(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=yield this.getChannel(t);yield n.markAsDelivered()}))}}exports.MessageEventSource=e.MessageEventSource,Object.defineProperty(exports,"MutedState",{enumerable:!0,get:function(){return e.MutedState}}),Object.defineProperty(exports,"CountPreference",{enumerable:!0,get:function(){return t.CountPreference}}),exports.DeliveryStatus=t.DeliveryStatus,exports.GroupChannel=t.GroupChannel,exports.GroupChannelEventSource=t.GroupChannelEventSource,exports.GroupChannelFilter=t.GroupChannelFilter,exports.GroupChannelListQuery=t.GroupChannelListQuery,Object.defineProperty(exports,"GroupChannelSearchField",{enumerable:!0,get:function(){return t.GroupChannelSearchField}}),Object.defineProperty(exports,"HiddenChannelFilter",{enumerable:!0,get:function(){return t.HiddenChannelFilter}}),Object.defineProperty(exports,"HiddenState",{enumerable:!0,get:function(){return t.HiddenState}}),exports.Member=t.Member,Object.defineProperty(exports,"MemberListOrder",{enumerable:!0,get:function(){return t.MemberListOrder}}),exports.MemberListQuery=t.MemberListQuery,Object.defineProperty(exports,"MemberState",{enumerable:!0,get:function(){return t.MemberState}}),Object.defineProperty(exports,"MemberStateFilter",{enumerable:!0,get:function(){return t.MemberStateFilter}}),exports.MessageCollection=t.MessageCollection,exports.MessageCollectionInitHandler=t.MessageCollectionInitHandler,Object.defineProperty(exports,"MessageCollectionInitPolicy",{enumerable:!0,get:function(){return t.MessageCollectionInitPolicy}}),Object.defineProperty(exports,"MutedMemberFilter",{enumerable:!0,get:function(){return t.MutedMemberFilter}}),Object.defineProperty(exports,"MyMemberStateFilter",{enumerable:!0,get:function(){return t.MyMemberStateFilter}}),Object.defineProperty(exports,"OperatorFilter",{enumerable:!0,get:function(){return t.OperatorFilter}}),Object.defineProperty(exports,"PublicChannelFilter",{enumerable:!0,get:function(){return t.PublicChannelFilter}}),Object.defineProperty(exports,"QueryType",{enumerable:!0,get:function(){return t.QueryType}}),Object.defineProperty(exports,"SuperChannelFilter",{enumerable:!0,get:function(){return t.SuperChannelFilter}}),Object.defineProperty(exports,"UnreadChannelFilter",{enumerable:!0,get:function(){return t.UnreadChannelFilter}}),Object.defineProperty(exports,"UnreadItemKey",{enumerable:!0,get:function(){return t.UnreadItemKey}}),exports.MessageFilter=n.MessageFilter,exports.PinnedMessage=n.PinnedMessage,exports.PinnedMessageListQuery=n.PinnedMessageListQuery,exports.ReadStatus=n.ReadStatus,Object.defineProperty(exports,"ScheduledStatus",{enumerable:!0,get:function(){return n.ScheduledStatus}}),Object.defineProperty(exports,"GroupChannelListOrder",{enumerable:!0,get:function(){return i.GroupChannelListOrder}}),Object.defineProperty(exports,"PublicGroupChannelListOrder",{enumerable:!0,get:function(){return i.PublicGroupChannelListOrder}}),Object.defineProperty(exports,"ScheduledMessageListOrder",{enumerable:!0,get:function(){return i.ScheduledMessageListOrder}}),exports.GroupChannelCollection=c,exports.GroupChannelHandler=f,exports.GroupChannelModule=S,exports.PublicGroupChannelListQuery=m,exports.ScheduledMessageListQuery=b; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),t=require("./lib/__bundle-0fbd5934.cjs"),n=require("./lib/__bundle-4bcf4070.cjs"),i=require("./lib/__bundle-0f6b8ff3.cjs"),s=require("./lib/__bundle-947cb619.cjs");require("./lib/__bundle-12c1cdf9.cjs"),require("./lib/__bundle-dae7bdf2.cjs"),require("./lib/__bundle-d349e14c.cjs");const r={};class a{constructor({_iid:n,limit:s=100}){this.ref=0,this._iid=n,this._limit=s;const{sdkState:r,dispatcher:a,logger:o,cacheContext:l,statManager:d}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${r.userId}@groupchannel/sync.meta`;const h=(e=>`sendbird:${e}@groupchannel/sync`)(r.userId);this._sync=new t.Sync(h,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,s,a,h,u,c,p,_;const g={hasNext:!0,nextToken:""};if(yield this.loadMetadata(),o.debug("channel background sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),null===(s=this._metadata)||void 0===s?void 0:s.completed)g.hasNext=!1,g.nextToken="";else{const n={includeEmpty:!0,includeMetaData:!0,order:i.GroupChannelListOrder.CHRONOLOGICAL};try{if(n.order===i.GroupChannelListOrder.LATEST_LAST_MESSAGE)try{const t=yield l.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(r.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const s=t.GroupChannelManager.of(this._iid),{channels:d,token:u}=yield s.getMyGroupChannels(null!==(h=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==h?h:"",n,this._limit,e.CollectionEventSource.SYNC_CHANNEL_BACKGROUND);g.hasNext=d.length>=this._limit&&!!u,g.nextToken=u,this._metadata&&(this._metadata.token=u,this._metadata.range.extends(...d.map((e=>e.createdAt))),this._metadata.completed=!g.hasNext),o.debug("channel background sync progress",g),yield this.saveMetadata()}catch(t){throw o.debug("channel background sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetaData()),t}finally{d.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=l.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:null!==(_=null===(p=n.order)||void 0===p?void 0:p.toString())&&void 0!==_?_:"",collection_id:r.userId}}))}}return g})))),this._connectionEventContext=a.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return r[e]||(r[e]=new a({_iid:e})),r[e].ref++,r[e]}static clear(e){r[e]&&(r[e].close(),delete r[e])}get range(){var e,n;return null!==(n=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==n?n:new t.TimeRange({})}get completed(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:n}=e.Vault.of(this._iid),i=yield n.preference.get(this._metadataKey);this._metadata={token:i?i.token:"",range:new t.TimeRange(i?i.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!i&&i.completed}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetaData(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){var t,n;const{logger:i,sessionManager:s}=e.Vault.of(this._iid);s.session.hasSession&&(i.debug("channel background sync resume()"),this._sync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.token)&&void 0!==n?n:""))}pause(){const{logger:t}=e.Vault.of(this._iid);t.debug("channel background sync stop()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete r[this._iid])}}const o={};class l{constructor({_iid:n}){this.ref=0,this._iid=n;const{logger:i,sdkState:s,dispatcher:r,cacheContext:a,statManager:o}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${s.userId}@groupchannel/changelogs.meta`,this._subscribers=new e.EventDispatcher;const l=(e=>`sendbird:${e}@groupchannel/changelogs`)(s.userId);this._sync=new t.Sync(l,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,r,l;const d={hasNext:!0,nextToken:0};yield this.loadMetadata(),i.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token);try{const n={includeEmpty:!0,includeMetaData:!0};try{const t=yield a.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(s.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const h=t.GroupChannelManager.of(this._iid),{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}=yield h.getMyGroupChannelChangeLogs(null!==(l=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==l?l:"",n,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);this._subscribers.dispatch("progress",{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}),d.hasNext=p,d.nextToken=_,this._metadata&&(this._metadata.token=_),i.debug("channel changelog sync progress",d),yield this.saveMetadata(),a.localCacheEnabled&&o.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:u.length>0||c.length>0?"cache_miss":"cache_hit",max_db_size:u.length,use_local_cache:a.localCacheEnabled,starting_point:0,message_init_policy:c.length.toString(),collection_id:s.userId}}))}catch(t){throw i.debug("channel changelog sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetadata()),t}return d})))),this._sync.on("stop",(()=>{this._subscribers.dispatch("pause")})),this._connectionEventContext=r.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return o[e]||(o[e]=new l({_iid:e})),o[e].ref++,o[e]}static clear(e){o[e]&&(o[e].close(),delete o[e])}get isRunning(){return this._sync.isRunning}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t,firstConnectedAt:n}=e.Vault.of(this._iid),i=yield t.preference.get(this._metadataKey);this._metadata={token:i?i.token:n}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}on(e,t){return this._subscribers.on(e,t)}resume(){const{sessionManager:t}=e.Vault.of(this._iid);t.session.hasSession&&this._sync.start(0)}pause(){this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete o[this._iid])}}const d=(e,t)=>e.findIndex((e=>e.isIdentical(t))),h=(e,t,n)=>{if(e.length>0){const i=d(e,t);let s=0,r=e.length-1,a=Math.floor((s+r)/2);for(;s0)r=a,a=Math.floor((s+r)/2);else{if(!(o<0))return{place:a,oldPosition:i};s=a+1,a=Math.floor((s+r)/2)}}return{place:u(e[a],t,n)>=0?a:a+1,oldPosition:i}}return{place:e.length,oldPosition:-1}},u=(e,t,n)=>{switch(n){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(e.lastMessage&&t.lastMessage){const n=t.lastMessage.createdAt-e.lastMessage.createdAt;return 0===n?t.createdAt-e.createdAt:n}return e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:{const n=e.name.localeCompare(t.name);return 0===n?e.createdAt-t.createdAt:n}default:return 0}};class c{constructor(s,{filter:r=new t.GroupChannelFilter,order:o=i.GroupChannelListOrder.LATEST_LAST_MESSAGE,limit:d=n.DEFAULT_GROUPCHANNEL_LIMIT,includeChangesOnInitialLoad:h=!1}){this.channels=[],this._isInitialized=!1,this._iid=s,this._key=`gcc-${e.uuid()}`,this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=h,this.filter=r,this.order=o,this._hasMore=!0,this._token="",this._limit=d;const{sdkState:u,cacheContext:c,dispatcher:p}=e.Vault.of(this._iid);c.localCacheEnabled&&(this._backgroundSync=a.of(s),this._backgroundSync.resume()),this._changelogSync=l.of(s),this._changelogSync.resume();t.GroupChannelManager.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:(e,n)=>{const{source:i}=n;if(t.shouldGiveEvent(i)){const t=e.filter((e=>this.filter.match(e,u.userId))),i=e.filter((e=>!this.filter.match(e,u.userId))).map((e=>e.url));t.length>0&&this._addChannelsToView(t,n),i.length>0&&this._removeChannelsFromView(i,n)}},onRemove:(e,t)=>{this._removeChannelsFromView(e,t)}}),p.on((t=>{t instanceof e.ConnectionStateChangeCommand&&(t.stateType===e.ConnectionStateType.CONNECTED?this._isGetRemoteChannelsSucceeded||(()=>{e.__awaiter(this,void 0,void 0,(function*(){yield this._revokeLoadMore()}))})():t.stateType===e.ConnectionStateType.LOGOUT&&this.dispose())}))}get hasMore(){return!this._isDisposed&&this._hasMore}setGroupChannelCollectionHandler(e){this._handler=e}_addChannelsToView(n,s,r=!1){const a=[],o=[],l=[];for(const t of n){const n=d(this.channels,t);n>=0&&this.channels.splice(n,1);const{place:u}=h(this.channels,t,this.order);if(n<0)u===this.channels.length?!r&&this._hasMore||(a.push(t),this.channels.push(t)):(a.push(t),this.channels.splice(u,0,t));else switch(s.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&u===this.channels.length?l.push(t):(this.channels.splice(u,0,t),o.push(t));break;default:this.channels.splice(u,0,t),o.push(t)}}if(l.length>0)for(const e of l){const t=d(this.channels,e);-1!==t&&this.channels.splice(t,1)}t.shouldGiveEvent(s.source)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n;a.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(s,a),o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(s,o),l.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(s,l.map((e=>e.url)))}))))}_removeChannelsFromView(n,i){const s=[];for(const e of n){const t=this.channels.findIndex((t=>t.url===e));t>=0&&(s.push(this.channels[t].url),this.channels.splice(t,1))}return t.shouldGiveEvent(i.source)&&s.length>0&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,s)})))),s}_getLocalChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.GroupChannelManager.of(this._iid),n=this.channels.length>0?((e,t)=>{var n,s,r,a;switch(t){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(s=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==s?s:e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(a=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:e.createdAt}})(this.channels[this.channels.length-1],this.order):null;return yield e.getChannelsFromCache(n,this.filter,this.order,this._limit,n?this.channels[this.channels.length-1].url:void 0)}))}_getRemoteChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const n=t.GroupChannelManager.of(this._iid),{channels:i,token:s}=yield n.getMyGroupChannels(this._token,e.undefineNullProps(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);return this._token=s,this._hasMore=!!s,i}))}_revokeLoadMore(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._isDisposed)try{const t=yield this._getRemoteChannels();this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(t,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}catch(e){this._isGetRemoteChannelsSucceeded=!1}}))}loadMore(){var t;return e.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new e.SendbirdError({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});let n=null;this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning&&(n=yield new Promise((e=>{this._changelogSyncSubscriberContext=this._changelogSync.on("progress",(t=>e(t))).on("pause",(()=>e(null)))})),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close());const{cacheContext:i,connectionManager:s,statManager:r}=e.Vault.of(this._iid);this._isInitialized||(this._isInitialized=!0,i.localCacheEnabled&&(yield this._backgroundSync.loadMetadata()),r.put(new e.DailyRecordStatLog({type:e.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}})));let a=[];if(this._hasMore){if(!i.localCacheEnabled||s.isConnected&&!this._backgroundSync.completed)try{a=yield this._getRemoteChannels(),this._isGetRemoteChannelsSucceeded=!0}catch(e){this._isGetRemoteChannelsSucceeded=!1}else yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){a=yield this._getLocalChannels()})))),this._hasMore=a.length>=this._limit;this._addChannelsToView(a,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}if(n){for(const e of n.updatedChannels){const t=d(a,e);if(t>=0)a[t]=e;else{const{place:t}=h(a,e,this.order);a.splice(t,0,e)}}const e=a.map((e=>e.url));for(const t of n.deletedChannelUrls){const n=e.indexOf(t);n>=0&&(a.splice(n,1),e.splice(n,1))}}return a}))}dispose(){var e,n,i;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===(n=this._changelogSync)||void 0===n||n.close(),null===(i=this._changelogSyncSubscriberContext)||void 0===i||i.close();t.GroupChannelManager.of(this._iid).unsubscribeChannelEvent(this._key)}}class p extends e.APIRequestCommand{constructor(n){const{token:i,limit:s,order:r,includeEmpty:a,membershipFilter:o,channelNameContainsFilter:l,channelUrlsFilter:d,customTypesFilter:h,customTypeStartsWithFilter:u,superChannelFilter:c,metadataOrderKeyFilter:p,metadataKey:_,metadataValues:g,metadataValueStartsWith:m,includeFrozen:C,includeMetaData:f}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_GROUP_CHANNELS,this.params=e.deundefined(e.undefineNullProps({token:i,limit:s,order:r,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:a,public_mode:t.PublicChannelFilter.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:d,custom_types:h,custom_type_startswith:u,super_mode:c,metadata_order_key:p,metadata_key:_,metadata_values:g,metadata_value_startswith:m,show_frozen:C,show_metadata:f}))}}class _ extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:i,channels:s,ts:r}=n;this.token=i,s&&s.length>0&&(this.channels=s.map((n=>(n.ts=r,new t.GroupChannel(e,n))))),this.ts="number"==typeof r?r:0}}var g;exports.MembershipFilter=void 0,(g=exports.MembershipFilter||(exports.MembershipFilter={})).ALL="all",g.JOINED="joined";class m extends e.BaseListQuery{constructor(e,n){var s,r,a,o,l,d,h,u,c,p,_,g,m,C;super(e,n),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=t.SuperChannelFilter.ALL,this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=i.PublicGroupChannelListOrder.CHRONOLOGICAL,this.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,this.customTypesFilter=null!==(l=n.customTypesFilter)&&void 0!==l?l:null,this.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,this.channelNameContainsFilter=null!==(h=n.channelNameContainsFilter)&&void 0!==h?h:null,this.membershipFilter=null!==(u=n.membershipFilter)&&void 0!==u?u:exports.MembershipFilter.ALL,this.superChannelFilter=null!==(c=n.superChannelFilter)&&void 0!==c?c:t.SuperChannelFilter.ALL,this.metadataKey=null!==(p=n.metadataKey)&&void 0!==p?p:null,this.metadataValues=null!==(_=n.metadataValues)&&void 0!==_?_:null,this.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,this.metadataValueStartsWith=null!==(m=n.metadataValueStartsWith)&&void 0!==m?m:null,this.order=null!==(C=n.order)&&void 0!==C?C:i.PublicGroupChannelListOrder.CHRONOLOGICAL}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.channelNameContainsFilter,!0)&&e.isArrayOf("string",this.channelUrlsFilter,!0)&&e.isArrayOf("string",this.customTypesFilter,!0)&&e.isTypeOf("string",this.customTypeStartsWithFilter,!0)&&e.isEnumOf(exports.MembershipFilter,this.membershipFilter)&&e.isEnumOf(t.SuperChannelFilter,this.superChannelFilter)&&e.isEnumOf(i.PublicGroupChannelListOrder,this.order)&&e.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&e.isTypeOf("string",this.metadataKey,!0)&&e.isArrayOf("string",this.metadataValues,!0)&&e.isTypeOf("string",this.metadataValueStartsWith,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;{const t=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),n=new p(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{channels:s,token:r}=i.as(_);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return t}}throw e.SendbirdError.invalidParameters}))}}class C extends s.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserJoined=e.noop,this.onUserLeft=e.noop,this.onUserReceivedInvitation=e.noop,this.onUserDeclinedInvitation=e.noop,this.onChannelHidden=e.noop,this.onUnreadMemberStatusUpdated=e.noop,this.onUndeliveredMemberStatusUpdated=e.noop,this.onTypingStatusUpdated=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop,this.onPinnedMessageUpdated=e.noop}}class f extends C{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class y extends e.APIRequestCommand{constructor(t){const{token:n,limit:i,order:s,reverse:r,channelUrl:a,messageTypeFilter:o,scheduledStatus:l}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_SCHEDULED_MESSAGES}`,this.params=e.deundefined(e.undefineNullProps({token:n,limit:i,reverse:r,channel_url:a,order:s,message_type:o,status:l}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.scheduledMessages=[];const{next:i,scheduled_messages:s}=t;this.token=i,this.scheduledMessages=s.map((t=>n.parseMessagePayload(e,t)))}}class b extends e.BaseListQuery{constructor(t,n){var i,s,r,a,o;super(t,n),this.channelUrl=null,this.order=null,this.reverse=!1,this.scheduledStatus=null,this.messageTypeFilter=e.MessageTypeFilter.ALL,this.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,this.order=null!==(s=n.order)&&void 0!==s?s:null,this.reverse=null!==(r=n.reverse)&&void 0!==r&&r,this.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,this.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:e.MessageTypeFilter.ALL}_validate(){return super._validate()&&e.isTypeOf("string",this.channelUrl,!0)&&(e.isEnumOf(i.ScheduledMessageListOrder,this.order)||null===this.order)&&e.isTypeOf("boolean",this.reverse)&&(e.isArrayOf(n.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&e.isEnumOf(e.MessageTypeFilter,this.messageTypeFilter)}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),n=new y(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{scheduledMessages:s,token:r}=i.as(v);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class S extends e.Module{constructor(){super(...arguments),this.name="groupChannel"}init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}){super.init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}),this._manager=new t.GroupChannelManager(e,{sdkState:n,cacheContext:l,dispatcher:i,sessionManager:s,requestQueue:r,logger:a})}createGroupChannelCollection(e={}){return new c(this._iid,e)}createMyGroupChannelListQuery(e={}){return new t.GroupChannelListQuery(this._iid,e)}createPublicGroupChannelListQuery(e={}){return new m(this._iid,e)}createScheduledMessageListQuery(e={}){return new b(this._iid,e)}addGroupChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof f).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeGroupChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}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(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getChannelWithoutCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannelWithoutCache(t)}))}getMyGroupChannelChangeLogsByToken(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("string",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getMyGroupChannelChangeLogsByTimestamp(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("number",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getGroupChannelCount(n){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCountParamsDefault),n);return e.unless(t.validateGroupChannelCountParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.getGroupChannelCount(i)}))}getUnreadItemCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getUnreadItemCount(t)}))}getTotalUnreadChannelCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadChannelCount()}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadMessageCount(t)}))}getTotalScheduledMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalScheduledMessageCount(t)}))}getSubscribedTotalUnreadMessageCount(){return this._manager.getSubscribedTotalUnreadMessageCount()}getSubscribedCustomTypeTotalUnreadMessageCount(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}getSubscribedCustomTypeUnreadMessageCount(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.createChannel(i)}))}createDistinctChannelIfNotExist(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),i&&(i.isDistinct=!0),this.createChannel(i)}))}createChannelWithUserIds(n,i=!1,s,r,a="",o=""){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),{invitedUserIds:n,isDistinct:i,name:s,data:a,customType:o});return"string"==typeof r?e.coverUrl=r:e.coverImage=r,this.createChannel(e)}))}markAsReadAll(){return e.__awaiter(this,void 0,void 0,(function*(){this._manager.markAsReadAll()}))}markAsReadWithChannelUrls(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.markAsReadWithChannelUrls(t)}))}markAsDelivered(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=yield this.getChannel(t);yield n.markAsDelivered()}))}}exports.MessageEventSource=e.MessageEventSource,Object.defineProperty(exports,"MutedState",{enumerable:!0,get:function(){return e.MutedState}}),Object.defineProperty(exports,"CountPreference",{enumerable:!0,get:function(){return t.CountPreference}}),exports.DeliveryStatus=t.DeliveryStatus,exports.GroupChannel=t.GroupChannel,exports.GroupChannelEventSource=t.GroupChannelEventSource,exports.GroupChannelFilter=t.GroupChannelFilter,exports.GroupChannelListQuery=t.GroupChannelListQuery,Object.defineProperty(exports,"GroupChannelSearchField",{enumerable:!0,get:function(){return t.GroupChannelSearchField}}),Object.defineProperty(exports,"HiddenChannelFilter",{enumerable:!0,get:function(){return t.HiddenChannelFilter}}),Object.defineProperty(exports,"HiddenState",{enumerable:!0,get:function(){return t.HiddenState}}),exports.Member=t.Member,Object.defineProperty(exports,"MemberListOrder",{enumerable:!0,get:function(){return t.MemberListOrder}}),exports.MemberListQuery=t.MemberListQuery,Object.defineProperty(exports,"MemberState",{enumerable:!0,get:function(){return t.MemberState}}),Object.defineProperty(exports,"MemberStateFilter",{enumerable:!0,get:function(){return t.MemberStateFilter}}),exports.MessageCollection=t.MessageCollection,exports.MessageCollectionInitHandler=t.MessageCollectionInitHandler,Object.defineProperty(exports,"MessageCollectionInitPolicy",{enumerable:!0,get:function(){return t.MessageCollectionInitPolicy}}),Object.defineProperty(exports,"MutedMemberFilter",{enumerable:!0,get:function(){return t.MutedMemberFilter}}),Object.defineProperty(exports,"MyMemberStateFilter",{enumerable:!0,get:function(){return t.MyMemberStateFilter}}),Object.defineProperty(exports,"OperatorFilter",{enumerable:!0,get:function(){return t.OperatorFilter}}),Object.defineProperty(exports,"PublicChannelFilter",{enumerable:!0,get:function(){return t.PublicChannelFilter}}),Object.defineProperty(exports,"QueryType",{enumerable:!0,get:function(){return t.QueryType}}),Object.defineProperty(exports,"SuperChannelFilter",{enumerable:!0,get:function(){return t.SuperChannelFilter}}),Object.defineProperty(exports,"UnreadChannelFilter",{enumerable:!0,get:function(){return t.UnreadChannelFilter}}),Object.defineProperty(exports,"UnreadItemKey",{enumerable:!0,get:function(){return t.UnreadItemKey}}),exports.MessageFilter=n.MessageFilter,exports.PinnedMessage=n.PinnedMessage,exports.PinnedMessageListQuery=n.PinnedMessageListQuery,exports.ReadStatus=n.ReadStatus,Object.defineProperty(exports,"ScheduledStatus",{enumerable:!0,get:function(){return n.ScheduledStatus}}),Object.defineProperty(exports,"GroupChannelListOrder",{enumerable:!0,get:function(){return i.GroupChannelListOrder}}),Object.defineProperty(exports,"PublicGroupChannelListOrder",{enumerable:!0,get:function(){return i.PublicGroupChannelListOrder}}),Object.defineProperty(exports,"ScheduledMessageListOrder",{enumerable:!0,get:function(){return i.ScheduledMessageListOrder}}),exports.GroupChannelCollection=c,exports.GroupChannelHandler=f,exports.GroupChannelModule=S,exports.PublicGroupChannelListQuery=m,exports.ScheduledMessageListQuery=b; diff --git a/cjs/index.cjs b/cjs/index.cjs index 005fe9e..4da2e74 100644 --- a/cjs/index.cjs +++ b/cjs/index.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),t=require("./message.cjs"),s=require("./poll.cjs"),n=require("./lib/__bundle-165fd6e1.cjs"),i=require("./lib/__bundle-2ad218ff.cjs"),r=require("./lib/__bundle-ca16c7ed.cjs"),o=require("./lib/__bundle-c127c886.cjs");require("./lib/__bundle-bfe2e997.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class a{constructor(e){this.key=e.key,this.url=e.url}}class d{constructor(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((e=>new a(e))):[]}}class u{constructor(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((e=>new d(e))):[]}}class c{constructor(){this.onConnected=e.noop,this.onReconnectStarted=e.noop,this.onReconnectSucceeded=e.noop,this.onReconnectFailed=e.noop,this.onDisconnected=e.noop}}class l extends c{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class h{constructor(){this.onSessionExpired=e.noop,this.onSessionTokenRequired=e=>e(null),this.onSessionError=e.noop,this.onSessionRefreshed=e.noop,this.onSessionClosed=e.noop}}class p extends h{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class _{constructor(){this.onFriendsDiscovered=e.noop,this.onTotalUnreadMessageCountChanged=e.noop,this.onTotalUnreadMessageCountUpdated=e.noop}}class f extends _{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class m extends e.APIRequestCommand{constructor({limit:t,token:s,userIdsFilter:n,metaDataKeyFilter:i,metaDataValuesFilter:r,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:i,metadatavalues_in:r,nickname_startswith:o})}}class g 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 v extends e.BaseListQuery{constructor(e,t){var s,n,i;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!==(i=t.metaDataValuesFilter)&&void 0!==i?i: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.nicknameStartsWithFilter,!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 m(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),n=yield t.send(s),{users:i,next:r}=n.as(g);return this._token=r,this._hasNext=!!r,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}class y extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n,userIdsFilter:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/block`,this.params=e.deundefined({limit:s,token:n,user_ids:i})}}class S 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 I 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 y(e.undefineNullProps(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token}))),i=yield s.send(n),{users:r,next:o}=i.as(S);return this._token=o,this._hasNext=!!o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}class P 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 C 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 E 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 P(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token})),i=yield s.send(n),{users:r,hasMore:o,next:a}=i.as(C);return this._token=a,this._hasNext=o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}const b=2097152;class T extends n.BaseStore{constructor(t){var{AsyncStorage:s,itemSizeLimit:n=b}=t,i=e.__rest(t,["AsyncStorage","itemSizeLimit"]);super(Object.assign(Object.assign({},i),{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 n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){const t=Object.create(null,{clear:{get:()=>super.clear}});return e.__awaiter(this,void 0,void 0,(function*(){yield t.clear.call(this);const e=yield this.getAllKeys();yield this.removeMany(e)}))}}class A extends n.BaseStore{constructor(e){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:6291456})),this._mmkv=e.MMKV}_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._mmkv.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._mmkv.getString(this._getActualKey(t));return e?JSON.parse(e):null}))}_setRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t){const{key:t,data:s}=e;s.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(t),JSON.stringify(e))}}))}_removeRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t)this._mmkv.delete(this._getActualKey(e))}))}checkAvailability(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._mmkv)throw n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){const t=Object.create(null,{clear:{get:()=>super.clear}});return e.__awaiter(this,void 0,void 0,(function*(){yield t.clear.call(this);const e=yield this.getAllKeys();yield this.removeMany(e)}))}}const w={profileImage:void 0,profileUrl:void 0,nickname:void 0},k=t=>(s,o)=>e.__awaiter(void 0,void 0,void 0,(function*(){switch(s){case 1:case 2:case 3:case 4:default:o();break;case 5:yield t.reset(),o();break;case 6:try{const{v2:s,v3:o,v4:a}=(t=>({v2:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_GROUPCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_GROUPCHANNEL_COLLECTION_KEY,index:[i.getGroupChannelIndexBy(i.GroupChannelListOrder.LATEST_LAST_MESSAGE),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHRONOLOGICAL),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:n.NESTDB_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_POLL_COLLECTION_NAME,keyName:n.NESTDB_POLL_COLLECTION_KEY}])})),v3:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_FEEDCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_FEEDCHANNEL_COLLECTION_KEY,index:[r.getFeedChannelIndexBy("latest_last_message")]}])})),v4:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_NOTIFICATION_COLLECTION_NAME,keyName:n.NESTDB_NOTIFICATION_COLLECTION_KEY,index:[n.getNotificationMessageIndexBy()]}])}))}))(t);yield s(),yield o(),yield a();const d=t.collection(n.NESTDB_MESSAGE_COLLECTION_NAME);yield d.removeIf({where:{channelType:e.ChannelType.OPEN}})}catch(e){}o()}})),O=()=>"undefined"!=typeof document?document.visibilityState:"visible";class R extends e.EventDispatcher{constructor({getVisibilityState:e=O,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 U{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 D extends e.APIRequestCommand{constructor({userId:t,nickname:s,profileUrl:n,profileImage:i,preferredLanguages:r}){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:i,preferred_languages:r}))}}class M extends e.APIResponseCommand{constructor(t,s){super(t,s),this.user=new e.User(t,Object.assign({},s))}}class x extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`,this.params=e.deundefined({apns_device_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class N extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`,this.params=e.deundefined({gcm_reg_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class L 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 q 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 V extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`}}class $ extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`}}class H extends e.APIRequestCommand{constructor({userId:t,type:s,token:n,ts:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/${encodeURIComponent(s)}/device_tokens`,this.params={created_ts:i,token:n}}}class F 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 j extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`}}class K extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class z 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 Q extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class B extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class G 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 W extends e.APIRequestCommand{constructor({userId:t,doNotDisturbOn:s,startHour:n,startMin:i,endHour:r,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:i,end_hour:r,end_min:o,timezone:a}}}class J 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 Y extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class X 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 Z extends e.APIRequestCommand{constructor({userId:t,snoozeOn:s,startTs:n,endTs:i}){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:i}}}class ee 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 te 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 se 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 ne extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class ie extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class re 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 oe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class ae extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`}}class de extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class ue 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 ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class le 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 he 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 pe 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 _e extends e.APIResponseCommand{constructor(e,t){super(e,t),this.friendDiscoveryRequestId=t.friend_discovery_request_id}}class fe 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 me 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 ge extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s)))}}class ve 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 ye 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 Se extends e.APIResponseCommand{constructor(e,t){super(e,t),this.allowFriendDiscovery=t.allow_friend_discovery}}class Ie 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 Pe extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_EMOJI_CATEGORIES}}class Ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiContainer=new u(t)}}class Ee extends e.APIRequestCommand{constructor({categoryId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJI_CATEGORIES}/${t}`}}class be extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiCategory=new d(t)}}class Te extends e.APIRequestCommand{constructor({key:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJIS}/${t}`}}class Ae extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emoji=new a(t)}}class we extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_UIKIT_CONFIGURATION}`}}class ke 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}}var Oe;!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(Oe||(Oe={}));class Re extends e.APIRequestCommand{constructor({deviceToken:t,pushTrackingId:s,messageId:n,allowedPushNotification:i,channelKey:r,templateKey:o,eventType:a,notificationEventDeadline:d}){super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_PUSH_DELIVERY,this.params=e.deundefined({device_token:t,push_tracking_id:s,message_id:n,allowed_push_notification:i,channel_key:r,template_key:o,event_type:a,notification_event_deadline:d})}}let Ue;class De{constructor(t,s,n){this._storeInitialized=!1,this._iid=t,this.options=s;const{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,userEventHandlers:h,appStateToggleEnabled:p}=e.Vault.of(t);this._onlineDetector=new U({logger:l,connectionDelegate:{reconnect:()=>e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,connectionManager:n,sessionManager:i}=e.Vault.of(t);if(i.session.hasSession){if("foreground"===s.appState)try{yield n.resetAndReconnect()}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("resetAndReconnect failed by reconnect event = ",t)}}else try{yield n.connect(i.session.authToken)}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("connect failed by reconnect event = ",t)}d.dispatch(new r.NotificationCollectionRefreshCommand)})),disconnect:()=>{e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s}=e.Vault.of(t);yield s.disconnect()}))))}}});const _=new i.AutoResendManager(t,{localCacheEnabled:a.localCacheEnabled,enableAutoResend:a.localCacheConfig.enableAutoResend,dispatcher:d,sdkState:o,logger:l});n.forEach((e=>{e.init(t,{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,onlineDetector:this._onlineDetector}),this[e.name]=e})),this._appStateChangeDetector=new R({isEnabled:p}),this._appStateChangeDetector.on("resume",(()=>{l.debug("the page resumes from freeze"),this.setForegroundState()})).on("pause",(()=>{l.debug("the page freezes"),this.setBackgroundState()})),d.on((s=>{var n;if(s instanceof e.ConnectionStateChangeCommand){if(s.stateType===e.ConnectionStateType.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(s instanceof e.WebSocketEventCommand)switch(s.code){case"USEV":{const{event:n}=s.as(i.UserEventCommand);switch(n.category){case i.UserEventCategory.FRIEND_DISCOVERED:{const{friendDiscoveries:s}=i.UserEvent.getDataAsFriendDiscoveredEvent(t,n);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.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 i=s.ts;"number"==typeof i&&i>t.ts&&(t.all!==s.all&&(n=!0),t.all=s.all>=0?s.all:0,s.customTypes&&Object.keys(s.customTypes).forEach((e=>{t.customTypes[e]!==s.customTypes[e]&&(n=!0),t.customTypes[e]=s.customTypes[e]})),n=n&&t.ts>0,t.ts=i),n&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.forEach((e=>{e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:t.all,feedChannelCount:t.feed,customTypeUnreadCount:t.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(t.all,t.customTypes)}))}))))}else s instanceof e.UserProfileUpdateCommand?(a.preference.set(this._getUserProfileCacheKey(o.userId),e.UserProfile.payloadify(s.userProfile)),(null===(n=s.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&a.preference.set(e.createChangelogIncludeChatNotificationsCacheKey(this.appId),{value:!0})):s instanceof e.SessionExpiredCommand&&s.error&&s.error.isSessionInvalidatedError&&(l.debug("session revoked."),this._internalDisconnect(s.error))}))}static init(i){const{appId:r,appVersion:o,modules:a=[],options:d=new e.SendbirdChatOptions,debugMode:u=!1,customApiHost:c,customWebSocketHost:l,newInstance:h=!1,logLevel:p,localCacheEnabled:_=!1,localCacheConfig:f=new e.LocalCacheConfig,localCacheEncryption:m,useAsyncStorageStore:g=null,useMMKVStorageStore:v=null,appStateToggleEnabled:y=!0}=i;if(!Ue||h){const i=`su-${e.uuid()}`,h=null!=m?m:{encrypt:e=>e,decrypt:e=>e},S=new n.Logger;S.level=null!=p?p:n.LogLevel.WARN;let I=new n.MemoryStore({encryption:h});u||(e.isReactNative()?v?I=new A({MMKV:v,encryption:h}):g&&(I=new T({AsyncStorage:g,encryption:h}),S.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):I=new n.IndexedDbStore({encryption:h})),new e.Vault(i,{appId:r,appVersion:o,options:d,apiHost:null!=c?c:`https://api-${r}.sendbird.com`,websocketHost:null!=l?l:`wss://ws-${r}.sendbird.com`,store:I,encryption:h,logger:S,localCacheEnabled:_,localCacheConfig:f,debugMode:u,appStateToggleEnabled:y});const P=[new t.MessageModule,new s.PollModule],C=new De(i,d,[...a,...P]);return Ue||(Ue=C),C}return Ue}static get instance(){return Ue}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}_getNestDBVersion(){return 7}_getPreferenceCacheKey(e){return`sendbird@${this.appId}/${e}.pref`}_getUserProfileCacheKey(e){return`sendbird@${this.appId}/${e}.profile`}_internalDisconnect(t){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),yield s.logout(t),yield this.clearCachedData(),n.appState="foreground"}))}getMemoryStoreForDebugging(){const{debugMode:t,cacheContext:s}=e.Vault.of(this._iid);if(t)return s.store instanceof n.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)}addSendbirdExtensions(t,s,n){const{logger:i,sdkState:r}=e.Vault.of(this._iid),o=new RegExp(e.SEMVER_REGEX_STRING);if(0===t.length)return i.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(t.find((e=>!o.test(e.version))))return i.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(const[e,t]of Object.entries(n))if(/&|=/.test(e)||/&|=/.test(t))return i.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1;return r.sendbirdRuntimeEnvironment={sendbirdExtensions:t,deviceOS:s,customData:n},!0}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 n.MemoryStore),yield this._safeInitializeStore(t)}}))}setLocaleForChatbot(t){const{sdkState:s}=e.Vault.of(this._iid),n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(t.trim());n&&(s.localeForChatbot=n)}initializeCache(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:r,dispatcher:o,logger:a}=e.Vault.of(this._iid);if(!s.userId||s.userId!==t){const d=`sendbird@${s.appId}/${t}.db`;try{if(r.localCacheEnabled){if(r.nestdb&&r.nestdb.state!==n.NestDBState.CLOSED&&r.nestdb.name===d)yield this._safeInitializeStore(d);else{const e=`sendbird@${s.appId}/${t}.db`,a=r.nestdb=new n.NestDB({name:e,version:this._getNestDBVersion(),store:r.store,config:new n.Config({dbname:e,itemSizeLimit:61440})});a.on("upgrade",k(a)),a.on("storeReplaced",(e=>{r.replaceStore(e),r.localCacheEnabled=!1,a.on("upgrade",k(a))})),yield a.open(),this._storeInitialized=!0,o.dispatch(new i.DatabaseOpenCommand(this._iid,{userId:t}))}s.userId=t}else yield this._safeInitializeStore(d),s.userId=t}catch(i){throw a.warn("Nest DB Open Failed. ",i),r.store instanceof n.MemoryStore||(r.replaceStore(new n.MemoryStore),r.localCacheEnabled=!1),yield this._safeInitializeStore(d),s.userId=t,e.SendbirdError.databaseError}finally{yield this._setupPreference(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=n.MessageCache.of(this._iid),i=n.UnsentMessageCache.of(this._iid);s&&i&&(yield Promise.all(t.map((t=>e.__awaiter(this,void 0,void 0,(function*(){yield s.removeMessagesOfChannel(t),yield i.removeMessagesOfChannel(t)}))))))}))}_setupPreference(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:n,statManager:i}=e.Vault.of(this._iid);yield n.preference.init(this._getPreferenceCacheKey(t),this._getNestDBVersion());const r=yield n.preference.get(this._getUserProfileCacheKey(t));if(r){new e.UserProfile(this._iid,r).apply()}yield i.init(`sendbird@${s.appId}/${t}.statlog`)}))}_ready(t,s,n={}){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:r,cacheContext:o,connectionManager:a}=e.Vault.of(this._iid),{errorForOtherUser:d}=n;if(r.userId&&r.userId!==t){if(d)throw d;yield a.logout()}try{yield this.initializeCache(t);const{dispatcher:s}=e.Vault.of(this._iid);s.dispatch(new i.ReduceDBSizeEventCommand)}catch(t){const{logger:s}=e.Vault.of(this._iid);o.localCacheEnabled=!1,s.warn("Cache initialization failed - cache is not available.")}}))}authenticateFeed(t,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.authenticate(t,s)}))}authenticate(t,s){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{sessionManager:i,connectionManager:r}=e.Vault.of(this._iid);if(yield this._ready(t,s,{errorForOtherUser:r.isConnected?e.SendbirdError.alreadyConnectedAsAnotherUser:void 0}),!(null===(n=i.session.services)||void 0===n?void 0:n.includes(e.SessionService.CHAT))){if(!s&&!i.handler){const e=new p;this.setSessionHandler(e)}yield i.authenticate(t,s)}return this.currentUser}))}connect(t,s){return e.__awaiter(this,void 0,void 0,(function*(){yield this._ready(t,s);try{const{connectionManager:t}=e.Vault.of(this._iid);yield t.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),i=n.session.hasSession;return i&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((()=>{s.appState="foreground"})).catch((()=>{}))),i}disconnect(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._internalDisconnect()}))}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(!0)}))}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().catch((e=>{n.debug("setBackgroundState error = ",e)})))}setForegroundState(){const{connectionManager:t,sdkState:s,dispatcher:n,logger:i}=e.Vault.of(this._iid);"background"===s.appState&&(s.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((e=>{i.debug("setForgroundState error = ",e)})),n.dispatch(new r.NotificationCollectionRefreshCommand))}setSessionHandler(t){e.unless(t instanceof p).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 f).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 l).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 v(this._iid,e)}createBlockedUserListQuery(e={}){return new I(this._iid,e)}createFriendListQuery(e={}){return new E(this._iid,e)}createMessageSearchQuery(e){return new n.MessageSearchQuery(this._iid,e)}createPollListQuery(t){return new e.PollListQuery(this._iid,Object.assign({},t))}createPollVoterListQuery(t){return new e.PollVoterListQuery(this._iid,Object.assign({},t))}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({},w),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),i=new D(Object.assign({userId:t.userId},s)),r=yield n.send(i),{user:o}=r.as(M);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),i=new D({userId:s.userId,preferredLanguages:t}),r=yield n.send(i),{user:o}=r.as(M);return this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),o}throw e.SendbirdError.connectionRequired}))}registerFCMPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.ANDROID}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.FCM,t))return e.PushTokenRegistrationState.SUCCESS;const o=new N({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.FCM,t,r),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:i}=e.Vault.of(this._iid),r=new q({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new $({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.FCM),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}registerAPNSPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.IOS}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.APNS,t))return e.PushTokenRegistrationState.SUCCESS;const o=new x({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.APNS,t,r),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:i}=e.Vault.of(this._iid),r=new L({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new V({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.APNS),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}markPushNotificationAsDelivered(t,s=!0){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:i,sessionManager:r,requestQueue:o,pushNotificationAckManager:a}=e.Vault.of(this._iid);i.debug("markPushNotificationAsDelivered:",t);const d=Oe.DELIVERED,{pushTrackingId:u,sessionTopics:c,sessionKey:l,messageId:h,channelKey:p,templateKey:_,notificationEventDeadline:f}=a.parseData(t);if(!l)throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(!c.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(a.isAcked(u,d))return void i.info("already delivered push notification:",u);const m=Boolean(p),g=s&&m,v=null===(n=r.deviceTokens[0])||void 0===n?void 0:n.token,y=new Re({deviceToken:null!=v?v:"",pushTrackingId:u,eventType:d,messageId:h,channelKey:p,templateKey:_,notificationEventDeadline:f,allowedPushNotification:g});l&&(y.headers["Session-Key"]=l);try{yield o.send(y),a.markAsAcked(u,d)}catch(e){throw i.debug(`failed to mark push notification as delivered. push tracking id: ${u}. error: ${e}`),e}}))}markPushNotificationAsClicked(t){var s;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:n,sessionManager:i,requestQueue:r,pushNotificationAckManager:o}=e.Vault.of(this._iid);n.debug("markPushNotificationAsClicked:",t);const a=Oe.CLICKED,{pushTrackingId:d,sessionTopics:u,sessionKey:c,messageId:l,channelKey:h,templateKey:p,notificationEventDeadline:_}=o.parseData(t);if(!c)throw n.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(!u.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw n.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(o.isAcked(d,a))return void n.info("already clicked push notification:",d);const f=null===(s=i.deviceTokens[0])||void 0===s?void 0:s.token,m=new Re({deviceToken:null!=f?f:"",pushTrackingId:d,eventType:a,messageId:l,channelKey:h,templateKey:p,notificationEventDeadline:_});c&&(m.headers["Session-Key"]=c);try{yield r.send(m),o.markAsAcked(d,a)}catch(e){throw n.debug(`failed to mark push notification as clicked. push tracking id: ${d}. error: ${e}`),e}}))}getChannelInvitationPreference(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new j({userId:t.userId}),i=yield s.send(n),{autoAccept:r}=i.as(K);return{autoAccept:r}}))}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),i=new z({userId:s.userId,willAutoAccept:t}),r=yield n.send(i),{autoAccept:o}=r.as(Q);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 B({userId:t.userId}),i=yield s.send(n),{preference:r}=i.as(G);return r}))}setDoNotDisturb(t,s=0,n=0,i=0,r=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",i)&&e.isTypeOf("number",r)&&e.isTypeOf("string",o)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:d}=e.Vault.of(this._iid),u=new W({userId:a.userId,doNotDisturbOn:t,startHour:s,startMin:n,endHour:i,endMin:r,timezone:o}),c=yield d.send(u),{preference:l}=c.as(J);return l}))}getSnoozePeriod(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new Y({userId:t.userId}),i=yield s.send(n),{snoozePeriod:r}=i.as(X);return r}))}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:i,requestQueue:r}=e.Vault.of(this._iid),o=new Z({userId:i.userId,snoozeOn:t,startTs:s,endTs:n}),a=yield r.send(o),{snoozePeriod:d}=a.as(ee);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:i,sessionManager:r}=e.Vault.of(this._iid),o=new H({userId:n.userId,type:s,token:t}),a=yield i.send(o),{pushTokens:d}=a.as(F);for(const e of d.deviceTokens)r.setDeviceToken(d.type,e);return yield r.saveDeviceToken(),d}))}getPushTriggerOption(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ne({userId:t.userId});return(yield s.send(n)).as(ie).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),i=new re({userId:s.userId,pushTriggerOption:t});return(yield n.send(i)).as(oe).pushTriggerOption}))}getPushTemplate(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ae({userId:t.userId});return(yield s.send(n)).as(de).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),i=new ue({userId:s.userId,templateName:t});return(yield n.send(i)).as(ce).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),i=new te({userId:s.userId,blockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new se({userId:s.userId,unblockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new le({userId:s.userId,token:t}),r=yield n.send(i),{changelogs:o}=r.as(he);return o}))}getAllowFriendDiscovery(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ye({userId:t.userId}),i=yield s.send(n),{allowFriendDiscovery:r}=i.as(Se);return r}))}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),i=new Ie({userId:s.userId,allowFriendDiscovery:t});return yield n.send(i),t}))}uploadFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),i=new pe({userId:s.userId,discoveries:t}),r=yield n.send(i),{friendDiscoveryRequestId:o}=r.as(_e);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),i=new fe({userId:s.userId,discoveryKeys:t});yield n.send(i)}))}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),i=new me({userId:s.userId,userIds:t}),r=yield n.send(i),{users:o}=r.as(ge);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),i=new ve({userId:s.userId,userIds:t});yield n.send(i)}))}getAllEmoji(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),s=new Pe,n=yield t.send(s),{emojiContainer:i}=n.as(Ce);return i}))}getEmojiCategory(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Ee({categoryId:t}),i=yield s.send(n),{emojiCategory:r}=i.as(be);return r}))}getEmoji(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Te({key:t}),i=yield s.send(n),{emoji:r}=i.as(Ae);return r}))}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 we,i=yield s.send(n),{uikitConfiguration:r}=i.as(ke);return r}))}}exports.AppInfo=e.AppInfo,exports.CachedChannelInfo=e.CachedChannelInfo,Object.defineProperty(exports,"CachedDataClearOrder",{enumerable:!0,get:function(){return e.CachedDataClearOrder}}),Object.defineProperty(exports,"ChannelType",{enumerable:!0,get:function(){return e.ChannelType}}),Object.defineProperty(exports,"CollectionEventSource",{enumerable:!0,get:function(){return e.CollectionEventSource}}),Object.defineProperty(exports,"ConnectionState",{enumerable:!0,get:function(){return e.ConnectionState}}),Object.defineProperty(exports,"DeviceOsPlatform",{enumerable:!0,get:function(){return e.DeviceOsPlatform}}),Object.defineProperty(exports,"LastMessageThreadingPolicy",{enumerable:!0,get:function(){return e.LastMessageThreadingPolicy}}),exports.LocalCacheConfig=e.LocalCacheConfig,exports.NotificationInfo=e.NotificationInfo,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,Object.defineProperty(exports,"SendbirdErrorCode",{enumerable:!0,get:function(){return e.SendbirdErrorCode}}),Object.defineProperty(exports,"SendbirdPlatform",{enumerable:!0,get:function(){return e.SendbirdPlatform}}),Object.defineProperty(exports,"SendbirdProduct",{enumerable:!0,get:function(){return e.SendbirdProduct}}),exports.UIKitConfigInfo=e.UIKitConfigInfo,Object.defineProperty(exports,"UnreadCountThreadingPolicy",{enumerable:!0,get:function(){return e.UnreadCountThreadingPolicy}}),exports.User=e.User,Object.defineProperty(exports,"UserOnlineState",{enumerable:!0,get:function(){return e.UserOnlineState}}),exports.BannedUserListQuery=n.BannedUserListQuery,exports.BaseChannel=n.BaseChannel,Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return n.LogLevel}}),exports.MemoryStore=n.MemoryStore,exports.MutedUserListQuery=n.MutedUserListQuery,exports.OperatorListQuery=n.OperatorListQuery,exports.Plugin=n.Plugin,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.Participant=o.Participant,exports.ApplicationUserListQuery=v,exports.BlockedUserListQuery=I,exports.ConnectionHandler=l,exports.Emoji=a,exports.EmojiCategory=d,exports.EmojiContainer=u,exports.FriendListQuery=E,exports.SessionHandler=p,exports.UserEventHandler=f,exports.default=De; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),t=require("./message.cjs"),s=require("./poll.cjs"),n=require("./lib/__bundle-4bcf4070.cjs"),i=require("./lib/__bundle-0f6b8ff3.cjs"),r=require("./lib/__bundle-d1419fd1.cjs"),o=require("./lib/__bundle-05f697db.cjs");require("./lib/__bundle-d349e14c.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class a{constructor(e){this.key=e.key,this.url=e.url}}class d{constructor(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((e=>new a(e))):[]}}class u{constructor(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((e=>new d(e))):[]}}class c{constructor(){this.onConnected=e.noop,this.onReconnectStarted=e.noop,this.onReconnectSucceeded=e.noop,this.onReconnectFailed=e.noop,this.onDisconnected=e.noop}}class l extends c{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class h{constructor(){this.onSessionExpired=e.noop,this.onSessionTokenRequired=e=>e(null),this.onSessionError=e.noop,this.onSessionRefreshed=e.noop,this.onSessionClosed=e.noop}}class p extends h{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class _{constructor(){this.onFriendsDiscovered=e.noop,this.onTotalUnreadMessageCountChanged=e.noop,this.onTotalUnreadMessageCountUpdated=e.noop}}class f extends _{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class m extends e.APIRequestCommand{constructor({limit:t,token:s,userIdsFilter:n,metaDataKeyFilter:i,metaDataValuesFilter:r,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:i,metadatavalues_in:r,nickname_startswith:o})}}class g 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 v extends e.BaseListQuery{constructor(e,t){var s,n,i;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!==(i=t.metaDataValuesFilter)&&void 0!==i?i: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.nicknameStartsWithFilter,!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 m(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),n=yield t.send(s),{users:i,next:r}=n.as(g);return this._token=r,this._hasNext=!!r,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}class y extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n,userIdsFilter:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/block`,this.params=e.deundefined({limit:s,token:n,user_ids:i})}}class S 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 I 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 y(e.undefineNullProps(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token}))),i=yield s.send(n),{users:r,next:o}=i.as(S);return this._token=o,this._hasNext=!!o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}class P 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 C 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 E 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 P(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token})),i=yield s.send(n),{users:r,hasMore:o,next:a}=i.as(C);return this._token=a,this._hasNext=o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}const b=2097152;class T extends n.BaseStore{constructor(t){var{AsyncStorage:s,itemSizeLimit:n=b}=t,i=e.__rest(t,["AsyncStorage","itemSizeLimit"]);super(Object.assign(Object.assign({},i),{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 n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){const t=Object.create(null,{clear:{get:()=>super.clear}});return e.__awaiter(this,void 0,void 0,(function*(){yield t.clear.call(this);const e=yield this.getAllKeys();yield this.removeMany(e)}))}}class A extends n.BaseStore{constructor(e){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:6291456})),this._mmkv=e.MMKV}_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._mmkv.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._mmkv.getString(this._getActualKey(t));return e?JSON.parse(e):null}))}_setRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t){const{key:t,data:s}=e;s.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(t),JSON.stringify(e))}}))}_removeRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t)this._mmkv.delete(this._getActualKey(e))}))}checkAvailability(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._mmkv)throw n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){const t=Object.create(null,{clear:{get:()=>super.clear}});return e.__awaiter(this,void 0,void 0,(function*(){yield t.clear.call(this);const e=yield this.getAllKeys();yield this.removeMany(e)}))}}const w={profileImage:void 0,profileUrl:void 0,nickname:void 0},k=t=>(s,o)=>e.__awaiter(void 0,void 0,void 0,(function*(){switch(s){case 1:case 2:case 3:case 4:default:o();break;case 5:yield t.reset(),o();break;case 6:try{const{v2:s,v3:o,v4:a}=(t=>({v2:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_GROUPCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_GROUPCHANNEL_COLLECTION_KEY,index:[i.getGroupChannelIndexBy(i.GroupChannelListOrder.LATEST_LAST_MESSAGE),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHRONOLOGICAL),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:n.NESTDB_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_POLL_COLLECTION_NAME,keyName:n.NESTDB_POLL_COLLECTION_KEY}])})),v3:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_FEEDCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_FEEDCHANNEL_COLLECTION_KEY,index:[r.getFeedChannelIndexBy("latest_last_message")]}])})),v4:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_NOTIFICATION_COLLECTION_NAME,keyName:n.NESTDB_NOTIFICATION_COLLECTION_KEY,index:[n.getNotificationMessageIndexBy()]}])}))}))(t);yield s(),yield o(),yield a();const d=t.collection(n.NESTDB_MESSAGE_COLLECTION_NAME);yield d.removeIf({where:{channelType:e.ChannelType.OPEN}})}catch(e){}o()}})),O=()=>"undefined"!=typeof document?document.visibilityState:"visible";class R extends e.EventDispatcher{constructor({getVisibilityState:e=O,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 U{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 D extends e.APIRequestCommand{constructor({userId:t,nickname:s,profileUrl:n,profileImage:i,preferredLanguages:r}){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:i,preferred_languages:r}))}}class M extends e.APIResponseCommand{constructor(t,s){super(t,s),this.user=new e.User(t,Object.assign({},s))}}class x extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`,this.params=e.deundefined({apns_device_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class N extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`,this.params=e.deundefined({gcm_reg_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class L 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 q 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 V extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`}}class $ extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`}}class H extends e.APIRequestCommand{constructor({userId:t,type:s,token:n,ts:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/${encodeURIComponent(s)}/device_tokens`,this.params={created_ts:i,token:n}}}class F 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 j extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`}}class K extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class z 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 Q extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class B extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class G 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 W extends e.APIRequestCommand{constructor({userId:t,doNotDisturbOn:s,startHour:n,startMin:i,endHour:r,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:i,end_hour:r,end_min:o,timezone:a}}}class J 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 Y extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class X 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 Z extends e.APIRequestCommand{constructor({userId:t,snoozeOn:s,startTs:n,endTs:i}){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:i}}}class ee 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 te 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 se 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 ne extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class ie extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class re 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 oe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class ae extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`}}class de extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class ue 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 ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class le 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 he 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 pe 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 _e extends e.APIResponseCommand{constructor(e,t){super(e,t),this.friendDiscoveryRequestId=t.friend_discovery_request_id}}class fe 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 me 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 ge extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s)))}}class ve 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 ye 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 Se extends e.APIResponseCommand{constructor(e,t){super(e,t),this.allowFriendDiscovery=t.allow_friend_discovery}}class Ie 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 Pe extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_EMOJI_CATEGORIES}}class Ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiContainer=new u(t)}}class Ee extends e.APIRequestCommand{constructor({categoryId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJI_CATEGORIES}/${t}`}}class be extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiCategory=new d(t)}}class Te extends e.APIRequestCommand{constructor({key:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJIS}/${t}`}}class Ae extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emoji=new a(t)}}class we extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_UIKIT_CONFIGURATION}`}}class ke 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}}var Oe;!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(Oe||(Oe={}));class Re extends e.APIRequestCommand{constructor({deviceToken:t,pushTrackingId:s,messageId:n,allowedPushNotification:i,channelKey:r,templateKey:o,eventType:a,notificationEventDeadline:d}){super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_PUSH_DELIVERY,this.params=e.deundefined({device_token:t,push_tracking_id:s,message_id:n,allowed_push_notification:i,channel_key:r,template_key:o,event_type:a,notification_event_deadline:d})}}let Ue;class De{constructor(t,s,n){this._storeInitialized=!1,this._iid=t,this.options=s;const{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,userEventHandlers:h,appStateToggleEnabled:p}=e.Vault.of(t);this._onlineDetector=new U({logger:l,connectionDelegate:{reconnect:()=>e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,connectionManager:n,sessionManager:i}=e.Vault.of(t);if(i.session.hasSession){if("foreground"===s.appState)try{yield n.resetAndReconnect()}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("resetAndReconnect failed by reconnect event = ",t)}}else try{yield n.connect(i.session.authToken)}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("connect failed by reconnect event = ",t)}d.dispatch(new r.NotificationCollectionRefreshCommand)})),disconnect:()=>{e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s}=e.Vault.of(t);yield s.disconnect()}))))}}});const _=new i.AutoResendManager(t,{localCacheEnabled:a.localCacheEnabled,enableAutoResend:a.localCacheConfig.enableAutoResend,dispatcher:d,sdkState:o,logger:l});n.forEach((e=>{e.init(t,{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,onlineDetector:this._onlineDetector}),this[e.name]=e})),this._appStateChangeDetector=new R({isEnabled:p}),this._appStateChangeDetector.on("resume",(()=>{l.debug("the page resumes from freeze"),this.setForegroundState()})).on("pause",(()=>{l.debug("the page freezes"),this.setBackgroundState()})),d.on((s=>{var n;if(s instanceof e.ConnectionStateChangeCommand){if(s.stateType===e.ConnectionStateType.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(s instanceof e.WebSocketEventCommand)switch(s.code){case"USEV":{const{event:n}=s.as(i.UserEventCommand);switch(n.category){case i.UserEventCategory.FRIEND_DISCOVERED:{const{friendDiscoveries:s}=i.UserEvent.getDataAsFriendDiscoveredEvent(t,n);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.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 i=s.ts;"number"==typeof i&&i>t.ts&&(t.all!==s.all&&(n=!0),t.all=s.all>=0?s.all:0,s.customTypes&&Object.keys(s.customTypes).forEach((e=>{t.customTypes[e]!==s.customTypes[e]&&(n=!0),t.customTypes[e]=s.customTypes[e]})),n=n&&t.ts>0,t.ts=i),n&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.forEach((e=>{e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:t.all,feedChannelCount:t.feed,customTypeUnreadCount:t.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(t.all,t.customTypes)}))}))))}else s instanceof e.UserProfileUpdateCommand?(a.preference.set(this._getUserProfileCacheKey(o.userId),e.UserProfile.payloadify(s.userProfile)),(null===(n=s.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&a.preference.set(e.createChangelogIncludeChatNotificationsCacheKey(this.appId),{value:!0})):s instanceof e.SessionExpiredCommand&&s.error&&s.error.isSessionInvalidatedError&&(l.debug("session revoked."),this._internalDisconnect(s.error))}))}static init(i){const{appId:r,appVersion:o,modules:a=[],options:d=new e.SendbirdChatOptions,debugMode:u=!1,customApiHost:c,customWebSocketHost:l,newInstance:h=!1,logLevel:p,localCacheEnabled:_=!1,localCacheConfig:f=new e.LocalCacheConfig,localCacheEncryption:m,useAsyncStorageStore:g=null,useMMKVStorageStore:v=null,appStateToggleEnabled:y=!0}=i;if(!Ue||h){const i=`su-${e.uuid()}`,h=null!=m?m:{encrypt:e=>e,decrypt:e=>e},S=new n.Logger;S.level=null!=p?p:n.LogLevel.WARN;let I=new n.MemoryStore({encryption:h});u||(e.isReactNative()?v?I=new A({MMKV:v,encryption:h}):g&&(I=new T({AsyncStorage:g,encryption:h}),S.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):I=new n.IndexedDbStore({encryption:h})),new e.Vault(i,{appId:r,appVersion:o,options:d,apiHost:null!=c?c:`https://api-${r}.sendbird.com`,websocketHost:null!=l?l:`wss://ws-${r}.sendbird.com`,store:I,encryption:h,logger:S,localCacheEnabled:_,localCacheConfig:f,debugMode:u,appStateToggleEnabled:y});const P=[new t.MessageModule,new s.PollModule],C=new De(i,d,[...a,...P]);return Ue||(Ue=C),C}return Ue}static get instance(){return Ue}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}_getNestDBVersion(){return 7}_getPreferenceCacheKey(e){return`sendbird@${this.appId}/${e}.pref`}_getUserProfileCacheKey(e){return`sendbird@${this.appId}/${e}.profile`}_internalDisconnect(t){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),yield s.logout(t),yield this.clearCachedData(),n.appState="foreground"}))}getMemoryStoreForDebugging(){const{debugMode:t,cacheContext:s}=e.Vault.of(this._iid);if(t)return s.store instanceof n.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)}addSendbirdExtensions(t,s,n){const{logger:i,sdkState:r}=e.Vault.of(this._iid),o=new RegExp(e.SEMVER_REGEX_STRING);if(0===t.length)return i.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(t.find((e=>!o.test(e.version))))return i.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(const[e,t]of Object.entries(n))if(/&|=/.test(e)||/&|=/.test(t))return i.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1;return r.sendbirdRuntimeEnvironment={sendbirdExtensions:t,deviceOS:s,customData:n},!0}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 n.MemoryStore),yield this._safeInitializeStore(t)}}))}setLocaleForChatbot(t){const{sdkState:s}=e.Vault.of(this._iid),n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(t.trim());n&&(s.localeForChatbot=n)}initializeCache(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:r,dispatcher:o,logger:a}=e.Vault.of(this._iid);if(!s.userId||s.userId!==t){const d=`sendbird@${s.appId}/${t}.db`;try{if(r.localCacheEnabled){if(r.nestdb&&r.nestdb.state!==n.NestDBState.CLOSED&&r.nestdb.name===d)yield this._safeInitializeStore(d);else{const e=`sendbird@${s.appId}/${t}.db`,a=r.nestdb=new n.NestDB({name:e,version:this._getNestDBVersion(),store:r.store,config:new n.Config({dbname:e,itemSizeLimit:61440})});a.on("upgrade",k(a)),a.on("storeReplaced",(e=>{r.replaceStore(e),r.localCacheEnabled=!1,a.on("upgrade",k(a))})),yield a.open(),this._storeInitialized=!0,o.dispatch(new i.DatabaseOpenCommand(this._iid,{userId:t}))}s.userId=t}else yield this._safeInitializeStore(d),s.userId=t}catch(i){throw a.warn("Nest DB Open Failed. ",i),r.store instanceof n.MemoryStore||(r.replaceStore(new n.MemoryStore),r.localCacheEnabled=!1),yield this._safeInitializeStore(d),s.userId=t,e.SendbirdError.databaseError}finally{yield this._setupPreference(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=n.MessageCache.of(this._iid),i=n.UnsentMessageCache.of(this._iid);s&&i&&(yield Promise.all(t.map((t=>e.__awaiter(this,void 0,void 0,(function*(){yield s.removeMessagesOfChannel(t),yield i.removeMessagesOfChannel(t)}))))))}))}_setupPreference(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:n,statManager:i}=e.Vault.of(this._iid);yield n.preference.init(this._getPreferenceCacheKey(t),this._getNestDBVersion());const r=yield n.preference.get(this._getUserProfileCacheKey(t));if(r){new e.UserProfile(this._iid,r).apply()}yield i.init(`sendbird@${s.appId}/${t}.statlog`)}))}_ready(t,s,n={}){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:r,cacheContext:o,connectionManager:a}=e.Vault.of(this._iid),{errorForOtherUser:d}=n;if(r.userId&&r.userId!==t){if(d)throw d;yield a.logout()}try{yield this.initializeCache(t);const{dispatcher:s}=e.Vault.of(this._iid);s.dispatch(new i.ReduceDBSizeEventCommand)}catch(t){const{logger:s}=e.Vault.of(this._iid);o.localCacheEnabled=!1,s.warn("Cache initialization failed - cache is not available.")}}))}authenticateFeed(t,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.authenticate(t,s)}))}authenticate(t,s){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{sessionManager:i,connectionManager:r}=e.Vault.of(this._iid);if(yield this._ready(t,s,{errorForOtherUser:r.isConnected?e.SendbirdError.alreadyConnectedAsAnotherUser:void 0}),!(null===(n=i.session.services)||void 0===n?void 0:n.includes(e.SessionService.CHAT))){if(!s&&!i.handler){const e=new p;this.setSessionHandler(e)}yield i.authenticate(t,s)}return this.currentUser}))}connect(t,s){return e.__awaiter(this,void 0,void 0,(function*(){yield this._ready(t,s);try{const{connectionManager:t}=e.Vault.of(this._iid);yield t.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),i=n.session.hasSession;return i&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((()=>{s.appState="foreground"})).catch((()=>{}))),i}disconnect(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._internalDisconnect()}))}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(!0)}))}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().catch((e=>{n.debug("setBackgroundState error = ",e)})))}setForegroundState(){const{connectionManager:t,sdkState:s,dispatcher:n,logger:i}=e.Vault.of(this._iid);"background"===s.appState&&(s.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((e=>{i.debug("setForgroundState error = ",e)})),n.dispatch(new r.NotificationCollectionRefreshCommand))}setSessionHandler(t){e.unless(t instanceof p).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 f).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 l).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 v(this._iid,e)}createBlockedUserListQuery(e={}){return new I(this._iid,e)}createFriendListQuery(e={}){return new E(this._iid,e)}createMessageSearchQuery(e){return new n.MessageSearchQuery(this._iid,e)}createPollListQuery(t){return new e.PollListQuery(this._iid,Object.assign({},t))}createPollVoterListQuery(t){return new e.PollVoterListQuery(this._iid,Object.assign({},t))}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({},w),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),i=new D(Object.assign({userId:t.userId},s)),r=yield n.send(i),{user:o}=r.as(M);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),i=new D({userId:s.userId,preferredLanguages:t}),r=yield n.send(i),{user:o}=r.as(M);return this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),o}throw e.SendbirdError.connectionRequired}))}registerFCMPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.ANDROID}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.FCM,t))return e.PushTokenRegistrationState.SUCCESS;const o=new N({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.FCM,t,r),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:i}=e.Vault.of(this._iid),r=new q({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new $({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.FCM),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}registerAPNSPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.IOS}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.APNS,t))return e.PushTokenRegistrationState.SUCCESS;const o=new x({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.APNS,t,r),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:i}=e.Vault.of(this._iid),r=new L({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new V({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.APNS),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}markPushNotificationAsDelivered(t,s=!0){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:i,sessionManager:r,requestQueue:o,pushNotificationAckManager:a}=e.Vault.of(this._iid);i.debug("markPushNotificationAsDelivered:",t);const d=Oe.DELIVERED,{pushTrackingId:u,sessionTopics:c,sessionKey:l,messageId:h,channelKey:p,templateKey:_,notificationEventDeadline:f}=a.parseData(t);if(!l)throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(!c.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(a.isAcked(u,d))return void i.info("already delivered push notification:",u);const m=Boolean(p),g=s&&m,v=null===(n=r.deviceTokens[0])||void 0===n?void 0:n.token,y=new Re({deviceToken:null!=v?v:"",pushTrackingId:u,eventType:d,messageId:h,channelKey:p,templateKey:_,notificationEventDeadline:f,allowedPushNotification:g});l&&(y.headers["Session-Key"]=l);try{yield o.send(y),a.markAsAcked(u,d)}catch(e){throw i.debug(`failed to mark push notification as delivered. push tracking id: ${u}. error: ${e}`),e}}))}markPushNotificationAsClicked(t){var s;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:n,sessionManager:i,requestQueue:r,pushNotificationAckManager:o}=e.Vault.of(this._iid);n.debug("markPushNotificationAsClicked:",t);const a=Oe.CLICKED,{pushTrackingId:d,sessionTopics:u,sessionKey:c,messageId:l,channelKey:h,templateKey:p,notificationEventDeadline:_}=o.parseData(t);if(!c)throw n.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(!u.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw n.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(o.isAcked(d,a))return void n.info("already clicked push notification:",d);const f=null===(s=i.deviceTokens[0])||void 0===s?void 0:s.token,m=new Re({deviceToken:null!=f?f:"",pushTrackingId:d,eventType:a,messageId:l,channelKey:h,templateKey:p,notificationEventDeadline:_});c&&(m.headers["Session-Key"]=c);try{yield r.send(m),o.markAsAcked(d,a)}catch(e){throw n.debug(`failed to mark push notification as clicked. push tracking id: ${d}. error: ${e}`),e}}))}getChannelInvitationPreference(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new j({userId:t.userId}),i=yield s.send(n),{autoAccept:r}=i.as(K);return{autoAccept:r}}))}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),i=new z({userId:s.userId,willAutoAccept:t}),r=yield n.send(i),{autoAccept:o}=r.as(Q);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 B({userId:t.userId}),i=yield s.send(n),{preference:r}=i.as(G);return r}))}setDoNotDisturb(t,s=0,n=0,i=0,r=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",i)&&e.isTypeOf("number",r)&&e.isTypeOf("string",o)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:d}=e.Vault.of(this._iid),u=new W({userId:a.userId,doNotDisturbOn:t,startHour:s,startMin:n,endHour:i,endMin:r,timezone:o}),c=yield d.send(u),{preference:l}=c.as(J);return l}))}getSnoozePeriod(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new Y({userId:t.userId}),i=yield s.send(n),{snoozePeriod:r}=i.as(X);return r}))}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:i,requestQueue:r}=e.Vault.of(this._iid),o=new Z({userId:i.userId,snoozeOn:t,startTs:s,endTs:n}),a=yield r.send(o),{snoozePeriod:d}=a.as(ee);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:i,sessionManager:r}=e.Vault.of(this._iid),o=new H({userId:n.userId,type:s,token:t}),a=yield i.send(o),{pushTokens:d}=a.as(F);for(const e of d.deviceTokens)r.setDeviceToken(d.type,e);return yield r.saveDeviceToken(),d}))}getPushTriggerOption(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ne({userId:t.userId});return(yield s.send(n)).as(ie).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),i=new re({userId:s.userId,pushTriggerOption:t});return(yield n.send(i)).as(oe).pushTriggerOption}))}getPushTemplate(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ae({userId:t.userId});return(yield s.send(n)).as(de).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),i=new ue({userId:s.userId,templateName:t});return(yield n.send(i)).as(ce).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),i=new te({userId:s.userId,blockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new se({userId:s.userId,unblockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new le({userId:s.userId,token:t}),r=yield n.send(i),{changelogs:o}=r.as(he);return o}))}getAllowFriendDiscovery(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ye({userId:t.userId}),i=yield s.send(n),{allowFriendDiscovery:r}=i.as(Se);return r}))}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),i=new Ie({userId:s.userId,allowFriendDiscovery:t});return yield n.send(i),t}))}uploadFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),i=new pe({userId:s.userId,discoveries:t}),r=yield n.send(i),{friendDiscoveryRequestId:o}=r.as(_e);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),i=new fe({userId:s.userId,discoveryKeys:t});yield n.send(i)}))}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),i=new me({userId:s.userId,userIds:t}),r=yield n.send(i),{users:o}=r.as(ge);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),i=new ve({userId:s.userId,userIds:t});yield n.send(i)}))}getAllEmoji(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),s=new Pe,n=yield t.send(s),{emojiContainer:i}=n.as(Ce);return i}))}getEmojiCategory(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Ee({categoryId:t}),i=yield s.send(n),{emojiCategory:r}=i.as(be);return r}))}getEmoji(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Te({key:t}),i=yield s.send(n),{emoji:r}=i.as(Ae);return r}))}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 we,i=yield s.send(n),{uikitConfiguration:r}=i.as(ke);return r}))}}exports.AppInfo=e.AppInfo,exports.CachedChannelInfo=e.CachedChannelInfo,Object.defineProperty(exports,"CachedDataClearOrder",{enumerable:!0,get:function(){return e.CachedDataClearOrder}}),Object.defineProperty(exports,"ChannelType",{enumerable:!0,get:function(){return e.ChannelType}}),Object.defineProperty(exports,"CollectionEventSource",{enumerable:!0,get:function(){return e.CollectionEventSource}}),Object.defineProperty(exports,"ConnectionState",{enumerable:!0,get:function(){return e.ConnectionState}}),Object.defineProperty(exports,"DeviceOsPlatform",{enumerable:!0,get:function(){return e.DeviceOsPlatform}}),Object.defineProperty(exports,"LastMessageThreadingPolicy",{enumerable:!0,get:function(){return e.LastMessageThreadingPolicy}}),exports.LocalCacheConfig=e.LocalCacheConfig,exports.NotificationInfo=e.NotificationInfo,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,Object.defineProperty(exports,"SendbirdErrorCode",{enumerable:!0,get:function(){return e.SendbirdErrorCode}}),Object.defineProperty(exports,"SendbirdPlatform",{enumerable:!0,get:function(){return e.SendbirdPlatform}}),Object.defineProperty(exports,"SendbirdProduct",{enumerable:!0,get:function(){return e.SendbirdProduct}}),exports.UIKitConfigInfo=e.UIKitConfigInfo,Object.defineProperty(exports,"UnreadCountThreadingPolicy",{enumerable:!0,get:function(){return e.UnreadCountThreadingPolicy}}),exports.User=e.User,Object.defineProperty(exports,"UserOnlineState",{enumerable:!0,get:function(){return e.UserOnlineState}}),exports.BannedUserListQuery=n.BannedUserListQuery,exports.BaseChannel=n.BaseChannel,Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return n.LogLevel}}),exports.MemoryStore=n.MemoryStore,exports.MutedUserListQuery=n.MutedUserListQuery,exports.OperatorListQuery=n.OperatorListQuery,exports.Plugin=n.Plugin,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.Participant=o.Participant,exports.ApplicationUserListQuery=v,exports.BlockedUserListQuery=I,exports.ConnectionHandler=l,exports.Emoji=a,exports.EmojiCategory=d,exports.EmojiContainer=u,exports.FriendListQuery=E,exports.SessionHandler=p,exports.UserEventHandler=f,exports.default=De; diff --git a/cjs/lib/__bundle-0486c467.cjs b/cjs/lib/__bundle-0486c467.cjs new file mode 100644 index 0000000..bbf88cd --- /dev/null +++ b/cjs/lib/__bundle-0486c467.cjs @@ -0,0 +1,2 @@ +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.14.5";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.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.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",t[t.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",t[t.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",t[t.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",t[t.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",t[t.SESSION_REVOKED=400310]="SESSION_REVOKED",t[t.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",t[t.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",t[t.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",t[t.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",t[t.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",t[t.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",t[t.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",t[t.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",t[t.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",t[t.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",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.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",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.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_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",t[t.USER_DEACTIVATED=900021]="USER_DEACTIVATED",t[t.CHANNEL_IS_FROZEN=900050]="CHANNEL_IS_FROZEN",t[t.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";const n=e=>!(e instanceof o&&!e.shouldThrowOutside);class o extends Error{constructor({code:e=0,message:t=""}){super(t),this.shouldThrowOutside=!1,this._detail="",this.name="SendbirdError",this.code=e,Object.setPrototypeOf(this,o.prototype)}get detail(){return this._detail}setDetail(e){this._detail=e}get isInvalidTokenError(){return this.code===exports.SendbirdErrorCode.INVALID_TOKEN}get isSessionExpiredError(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}get isSessionTokenExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}get isSessionKeyExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}get isSessionInvalidatedError(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}get isSessionRevokedError(){return this.code===exports.SendbirdErrorCode.SESSION_REVOKED}get isUserAuthDeactivedError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED}get isUserAuthDeletedOrNotFoundError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}get isNetworkError(){return this.code===exports.SendbirdErrorCode.NETWORK_ERROR||this.code===exports.SendbirdErrorCode.NETWORK_ROUTING_ERROR}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 xmlHttpRequestNotSupported(){return new o({code:exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}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 channelTypeNotSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}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 tooManyRequests(){return new o({code:exports.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}static get alreadyConnectedAsAnotherUser(){return new o({code:exports.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}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."})}static get statLogUploadLimitExceededError(){return new o({code:exports.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}static get malformedDataError(){return new o({code:exports.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}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,exports.SendbirdErrorCode.USER_DEACTIVATED,exports.SendbirdErrorCode.CHANNEL_IS_FROZEN,exports.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],a=[exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.CONNECTION_REQUIRED,exports.SendbirdErrorCode.CHANNEL_IS_FROZEN],l=(e,t,s=!1)=>!(!s||!_(t))||("string"!=typeof e?"object"==typeof e?d(e,t):c(e,t):typeof t===e),d=(e,t,s=!1)=>!(!s||!_(t))||Object.values(e).includes(t),c=(e,t)=>t instanceof e,h=(e,t,s=!1)=>!(!s||!_(t))||Array.isArray(t)&&t.every((t=>l(e,t))),u=(e,t=!1)=>{if(t&&_(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},_=e=>null==e;class p{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 E={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=exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=i}get maxSize(){return this._maxSize}get clearOrder(){return this._clearOrder}get clearOrderComparator(){var e;return this._clearOrder===exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}get enableAutoResend(){return this._enableAutoResend}}var A;exports.SessionService=void 0,(A=exports.SessionService||(exports.SessionService={})).FEED="feed",A.CHAT="chat",A.CHAT_API="chat_api";class N{constructor(){this.isRefreshing=!1}get hasSession(){return!!this.sessionKey}get hasChatServicePermission(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(exports.SessionService.CHAT))}clear(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}const w=()=>{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 b{constructor({container:e}){this._container={},this._container=e,this.key=w()}_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(){Object.keys(this._container).forEach((e=>{var t;null===(t=this._container[e])||void 0===t||t.delete(this.key)}))}}class I{constructor(){this._container={}}on(e,t){return new b({container:this._container}).on(e,t)}once(e,t){return new b({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 I}on(e){return this._dispatcher.on("event",e)}once(e){return this._dispatcher.once("event",e)}dispatch(e){this._dispatcher.dispatch("event",e)}}class R{}const O=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},k=e=>{if(null!=e){if("object"==typeof e){if(Array.isArray(e)){const t=[...e];for(let e=0;e{null===e[t]&&delete e[t]})),e}return e}};var D,L,P,U,M,q,F,H,V,z,G,K,B;exports.ChannelType=void 0,(D=exports.ChannelType||(exports.ChannelType={})).BASE="base",D.GROUP="group",D.OPEN="open",D.FEED="feed",exports.Role=void 0,(L=exports.Role||(exports.Role={})).OPERATOR="operator",L.NONE="none",exports.MutedState=void 0,(P=exports.MutedState||(exports.MutedState={})).MUTED="muted",P.UNMUTED="unmuted",exports.MessageType=void 0,(U=exports.MessageType||(exports.MessageType={})).BASE="base",U.USER="user",U.FILE="file",U.ADMIN="admin",exports.MessageTypeFilter=void 0,(M=exports.MessageTypeFilter||(exports.MessageTypeFilter={})).ALL="",M.USER="MESG",M.FILE="FILE",M.ADMIN="ADMM",exports.ServerSideMessageType=void 0,(q=exports.ServerSideMessageType||(exports.ServerSideMessageType={})).USER="MESG",q.FILE="FILE",q.ADMIN="ADMM",exports.MentionType=void 0,(F=exports.MentionType||(exports.MentionType={})).USERS="users",F.CHANNEL="channel",exports.ReplyType=void 0,(H=exports.ReplyType||(exports.ReplyType={})).ALL="all",H.NONE="none",H.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",exports.PushNotificationDeliveryOption=void 0,(V=exports.PushNotificationDeliveryOption||(exports.PushNotificationDeliveryOption={})).DEFAULT="default",V.SUPPRESS="suppress",exports.SendingStatus=void 0,(z=exports.SendingStatus||(exports.SendingStatus={})).PENDING="pending",z.SCHEDULED="scheduled",z.SUCCEEDED="succeeded",z.FAILED="failed",z.CANCELED="canceled",exports.MessageReviewStatus=void 0,(G=exports.MessageReviewStatus||(exports.MessageReviewStatus={})).INREVIEW="InReview",G.APPROVED="Approved",exports.NotificationPriority=void 0,(K=exports.NotificationPriority||(exports.NotificationPriority={})).HIGH="high",K.NORMAL="normal",K.LOW="low",exports.MessageTemplateListOrder=void 0,(B=exports.MessageTemplateListOrder||(exports.MessageTemplateListOrder={})).CREATED_AT="created_at",B.UPDATED_AT="updated_at";const Q="v3",W=`/${Q}/users`,j=`/${Q}/sdk/users`,$=`/${Q}/storage/file`,Z=`/${Q}/group_channels`,Y=`/${Q}/sdk/group_channels`,X=`/${Q}/open_channels`,J=`/${Q}/sdk/open_channels`,ee=`/${Q}/search`,te=`/${Q}/report`,se=`/${Q}/emojis`,ie=`/${Q}/emoji_categories`,ne=`/${Q}/polls`,oe=`/${Q}/scheduled_messages`,re=`/${Q}/sdk/ui_kit/configuration`,ae=`/${Q}/sdk/statistics`,le=`/${Q}/sdk/statistics/notification_statistics`,de=`/${Q}/notifications`,ce=`/${Q}/notifications/users`,he=`/${Q}/message_templates`,ue=`/${Q}/sdk/push_delivery`,_e=`/${Q}/forms`,pe=e=>{switch(e){case exports.ChannelType.FEED:case exports.ChannelType.GROUP:return Z;case exports.ChannelType.OPEN:return X;default:return null}},Ee=(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},ge=(e,t,s)=>{var i;let n=t||new FormData;for(const t in e){if(!e.hasOwnProperty(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=ge(o,n,r)}return n};var fe;exports.APIRequestMethod=void 0,(fe=exports.APIRequestMethod||(exports.APIRequestMethod={})).GET="GET",fe.POST="POST",fe.PUT="PUT",fe.DELETE="DELETE";class ve extends R{constructor(){super(...arguments),this.params={},this.requireAuth=!0,this.headers={},this.requestId=w()}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=O(this.params);return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${this.encodeParams(e[t])}`)).join("&")}`}get payload(){const e=O(this.params);return Object.keys(e).some((t=>u(e[t])))?ge(e):JSON.stringify(e)}get hasSessionKey(){return void 0!==this.headers["Session-Key"]}}class Se extends R{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 me extends R{constructor(e){super(),this.requestId=e}}class Ce extends R{constructor({expires_in:e,reason:t=exports.SendbirdErrorCode.SESSION_KEY_EXPIRED,message:s=""}){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:case exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED:case exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND:this.error=new o({code:t,message:s})}}get invalidateSessionToken(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}class Te extends R{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 Te(e,s,i)}}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}as(e){return new e(this._iid,this.code,this.payload)}}class ye extends R{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:w(),this.ackRequired=t,this.payload.req_id=this.requestId}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}}class Ae extends ve{constructor({userId:e,authToken:t,services:s,expiringSession:i=!0}){super(),this.path=`${W}/${e}/session_key`,this.method=exports.APIRequestMethod.POST,this.params=O({token:t,services:s,expiring_session:!!i}),this.requireAuth=!1}}class Ne extends ye{constructor({authToken:e,expiringSession:t=!0,requestId:s}){super({code:"LOGI",payload:O({token:e,expiring_session:t?1:0,req_id:s}),ackRequired:!0})}}class we extends Se{constructor(e,t){super(e,t);const{key:s,expires_at:i,services:n}=t;this.key=s,this.expiresAt=i,this.services=n}}class be extends Te{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):null}}class Ie extends R{constructor(e){super(),this.statLog=e}}class xe extends R{constructor({request:e,deferred:t,error:s=o.requestFailed}){super(),this.request=e,this.deferred=t,this.error=s}}var Re;exports.StatType=void 0,(Re=exports.StatType||(exports.StatType={})).FEATURE_LOCALCACHE="feature:local_cache",Re.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",Re.NOTIFICATION="noti:stats",Re.WEBSOCKET_CONNECT="ws:connect",Re.API_RESULT="api:result";class Oe{constructor({type:e,data:t,ts:s=Date.now()}){this.type=e,this.createdAt=s,this.data=t}static payloadify(e){return O({stat_type:e.type,ts:e.createdAt,data:O(e.data)})}}const ke=()=>"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product,De=()=>!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent));var Le,Pe,Ue;exports.SendbirdProduct=void 0,(Le=exports.SendbirdProduct||(exports.SendbirdProduct={})).CHAT="chat",Le.CALLS="calls",Le.DESK="desk",Le.LIVE="live",Le.UIKIT_CHAT="uikit-chat",Le.UIKIT_LIVE="uikit-live",exports.SendbirdPlatform=void 0,(Pe=exports.SendbirdPlatform||(exports.SendbirdPlatform={})).ANDROID="android",Pe.IOS="ios",Pe.JS="js",Pe.UNREAL="unreal",Pe.UNITY="unity",Pe.REACT_NATIVE="react-native",Pe.FLUTTER="flutter",exports.DeviceOsPlatform=void 0,(Ue=exports.DeviceOsPlatform||(exports.DeviceOsPlatform={})).ANDROID="android",Ue.IOS="ios",Ue.WEB="web",Ue.MOBILE_WEB="mobile_web",Ue.WINDOWS="windows";class Me{}Me.sendbirdSdkUserAgentWithExtension=e=>{let t={main_sdk_info:`chat/${ke()?exports.SendbirdPlatform.REACT_NATIVE:exports.SendbirdPlatform.JS}/${i.SDK_VERSION}`,device_os_platform:De()?"mobile-web":"web",os_version:i.OS_VERSION};if(e){const{sendbirdExtensions:s,deviceOS:i,customData:n={}}=e;i.version&&(t.os_version=i.version),i.platform&&(t.device_os_platform=i.platform),s.length>0&&(t.extension_sdk_info=s.map((({product:e,platform:t,version:s})=>`${e}/${t}/${s}`)).join(",")),Object.keys(t).forEach((e=>delete n[e])),Object.keys(n).length>0&&(t=Object.assign(Object.assign({},t),n))}return Object.entries(t).map((([e,t])=>`${e}=${t}`)).join("&")},Me.userAgentWithExtension=e=>{const t=ke()?"reactnative":"JS",s=e.sb_syncmanager?`s${e.sb_syncmanager}`:"",n=e.sb_uikit?`u${e.sb_uikit}`:"",o=e["device-os-platform"]?`o${e["device-os-platform"]}`:De()?"omobile-web":"oweb";return`${t}/c${i.SDK_VERSION}/${s}/${n}/${o}`};class qe{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=e=>{t(e)}}))}}class Fe extends R{constructor(e){super(),this.requestId=e.requestId}}class He extends ve{constructor(e){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${pe(e.channelType)}/${e.channelUrl}/messages/${e.messageId}`,e.messageToken&&(this.params=O({mesg_token:e.messageToken}))}}class Ve{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:o=!1}){this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=t,this._sdkState=s,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof me&&this.cancel(e.requestId)})),this._logger=n,this._shouldImportFetchCompat=o}_createHeader(e,t){const{appId:s,appVersion:n,sendbirdRuntimeEnvironment:o}=this._sdkState,r=Object.assign(Object.assign({},e.headers),{SendBird:`JS,${i.OS_VERSION},${i.SDK_VERSION},${s}${n?`,${n}`:""}`,"SB-User-Agent":Me.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":Me.sendbirdSdkUserAgentWithExtension(o)});return t||(r["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(r["Session-Key"]=this._session.sessionKey),r["App-Id"]=s,this._session&&this._session.authToken&&(r["Access-Token"]=this._session.authToken),r}_statLogApiResult(e,t,s){e.path.includes("/sdk/statistics")||this._dispatcher.dispatch(new Ie(new Oe({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}})))}_isBodyRequired(e){const{method:t}=e;return t!==exports.APIRequestMethod.GET&&(t!==exports.APIRequestMethod.DELETE||e instanceof He)}send(t){return e(this,void 0,void 0,(function*(){const{path:e,method:s,uploadProgressHandler:i}=t,n=this._isBodyRequired(t),{api:r}=this._sdkState,a=`${r.host}${e}${n?"":t.query}`,l=n?t.payload:null,d=this._createHeader(t,l instanceof FormData?l:void 0),c=new AbortController,{signal:h}=c;this._abortControl.set(t.requestId,c);const u=Date.now();try{if(i){const{xmlHttpRequest:e}=yield Promise.resolve().then((function(){return require("./__bundle-2e006691.cjs")}));try{const s=yield e(this._iid,{requestId:t.requestId,method:t.method,url:a,headers:d,data:null!=l?l:void 0,uploadProgressHandler:i});return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),s}catch(e){if(!(e instanceof o&&e.code===exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED))throw e;this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored.")}}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-6301b3ce.cjs")}))),"function"!=typeof fetch&&(yield Promise.resolve().then((function(){return require("./__bundle-38c66c0d.cjs")})));const e=yield fetch(a,{method:s,body:l,headers:d,signal:h}),n=yield e.json();if(e.ok||e.redirected)return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),new Se(this._iid,n);if(n){const e=new o(n);if(e.isSessionExpiredError){if(this._dispatcher.dispatch(new Ce({reason:e.code,message:e.message})),!(t instanceof Ae)){const s=new qe;return this._dispatcher.dispatch(new xe({request:t,deferred:s,error:e})),s.promise}throw e}throw e.isSessionInvalidatedError?(this._dispatcher.dispatch(new Ce({reason:e.code,message:e.message})),e):e}throw o.requestFailed}catch(e){throw this._statLogApiResult(t,u,e),e instanceof o?(this._logger.debug("fail api request",e),e):"AbortError"===(null==e?void 0:e.name)?o.requestCanceled:(this._logger.debug("fail api request",e),o.networkError)}}))}cancel(e){if(this._abortControl.has(e)){this._abortControl.get(e).abort(),this._abortControl.delete(e)}this._dispatcher.dispatch(new Fe({requestId:e}))}cancelAll(){for(const e of this._abortControl.values())e.abort();this._abortControl.clear(),this._dispatcher.dispatch(new Fe({}))}}const ze=()=>{}; +/*! 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 Ke=256,Be=286,Qe=30,We=15,je=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]),$e=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]),Ye=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xe=new Array(576);Ge(Xe);const Je=new Array(60);Ge(Je);const et=new Array(512);Ge(et);const tt=new Array(256);Ge(tt);const st=new Array(29);Ge(st);const it=new Array(Qe);function nt(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 ot,rt,at;function lt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ge(it);const dt=e=>e<256?et[e]:et[256+(e>>>7)],ct=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ht=(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<{ht(e,s[2*t],s[2*t+1])},_t=(e,t)=>{let s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1},pt=(e,t,s)=>{const i=new Array(16);let n,o,r=0;for(n=1;n<=We;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]=_t(i[t]++,t))}},Et=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},ft=(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?ut(e,n,t):(o=tt[n],ut(e,o+Ke+1,t),r=je[o],0!==r&&(n-=st[o],ht(e,n,r)),i--,o=dt(i),ut(e,o,s),r=$e[o],0!==r&&(i-=it[o],ht(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--)vt(e,s,r);l=o;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],vt(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++,vt(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,E=0;for(u=0;u<=We;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,E++),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!==E){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]--,E-=2}while(E>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),pt(s,d,e.bl_count)},Ct=(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{ht(e,0+(i?1:0),3),gt(e),ct(e,s),ct(e,~s),s&&e.pending_buf.set(e.window.subarray(t,t+s),e.pending),e.pending+=s};var Nt=(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(Ct(e,e.dyn_ltree,e.l_desc.max_code),Ct(e,e.dyn_dtree,e.d_desc.max_code),mt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Ye[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),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?At(e,t,s,i):4===e.strategy||o===n?(ht(e,2+(i?1:0),3),St(e,Xe,Je)):(ht(e,4+(i?1:0),3),((e,t,s,i)=>{let n;for(ht(e,t-257,5),ht(e,s-1,5),ht(e,i-4,4),n=0;n{yt||((()=>{let e,t,s,i,n;const o=new Array(16);for(s=0,i=0;i<28;i++)for(st[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*(tt[s]+Ke+1)]++,e.dyn_dtree[2*dt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ht(e,2,3),ut(e,256,Xe),(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 bt=(e,t,s,i)=>{let n=65535&e,o=e>>>16&65535,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};const It=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 xt=(e,t,s,i)=>{const n=It,o=i+s;e^=-1;for(let s=i;s>>8^n[255&(e^t[s])];return~e},Rt={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"},Ot={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:kt,_tr_stored_block:Dt,_tr_flush_block:Lt,_tr_tally:Pt,_tr_align:Ut}=wt,{Z_NO_FLUSH:Mt,Z_PARTIAL_FLUSH:qt,Z_FULL_FLUSH:Ft,Z_FINISH:Ht,Z_BLOCK:Vt,Z_OK:zt,Z_STREAM_END:Gt,Z_STREAM_ERROR:Kt,Z_DATA_ERROR:Bt,Z_BUF_ERROR:Qt,Z_DEFAULT_COMPRESSION:Wt,Z_FILTERED:jt,Z_HUFFMAN_ONLY:$t,Z_RLE:Zt,Z_FIXED:Yt,Z_DEFAULT_STRATEGY:Xt,Z_UNKNOWN:Jt,Z_DEFLATED:es}=Ot,ts=258,ss=262,is=42,ns=113,os=666,rs=(e,t)=>(e.msg=Rt[t],t),as=e=>2*e-(e>4?9:0),ls=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ds=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 cs=(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))},us=(e,t)=>{Lt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,hs(e.strm)},_s=(e,t)=>{e.pending_buf[e.pending++]=t},ps=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Es=(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=bt(e.adler,t,n,s):2===e.state.wrap&&(e.adler=xt(e.adler,t,n,s)),e.next_in+=n,e.total_in+=n,n)},gs=(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-ss?e.strstart-(e.w_size-ss):0,d=e.window,c=e.w_mask,h=e.prev,u=e.strstart+ts;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},fs=e=>{const t=e.w_size;let s,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ss)&&(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),ds(e),i+=t),0===e.strm.avail_in)break;if(s=Es(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=cs(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=cs(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,hs(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&&(Es(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&&(Es(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===Ht)&&t!==Mt&&0===e.strm.avail_in&&i<=n)&&(s=i>n?n:i,r=t===Ht&&0===e.strm.avail_in&&s===i?1:0,Dt(e,e.block_start,s,r),e.block_start+=s,hs(e.strm)),r?3:1)},Ss=(e,t)=>{let s,i;for(;;){if(e.lookahead=3&&(e.ins_h=cs(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-ss&&(e.match_length=gs(e,s)),e.match_length>=3)if(i=Pt(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=cs(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=cs(e,e.ins_h,e.window[e.strstart+1]);else i=Pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(us(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2},ms=(e,t)=>{let s,i,n;for(;;){if(e.lookahead=3&&(e.ins_h=cs(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=Pt(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=cs(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&&(us(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Pt(e,0,e.window[e.strstart-1]),i&&us(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=Pt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2};function Cs(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 Ts=[new Cs(0,0,0,0,vs),new Cs(4,4,8,4,Ss),new Cs(4,5,16,8,Ss),new Cs(4,6,32,32,Ss),new Cs(4,4,16,16,ms),new Cs(8,16,32,32,ms),new Cs(8,16,128,128,ms),new Cs(8,32,128,256,ms),new Cs(32,128,258,1024,ms),new Cs(32,258,258,4096,ms)];function ys(){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=es,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),ls(this.dyn_ltree),ls(this.dyn_dtree),ls(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),ls(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ls(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 As=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==is&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==ns&&t.status!==os?1:0},Ns=e=>{if(As(e))return rs(e,Kt);e.total_in=e.total_out=0,e.data_type=Jt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?is:ns,e.adler=2===t.wrap?0:1,t.last_flush=-2,kt(t),zt},ws=e=>{const t=Ns(e);var s;return t===zt&&((s=e.state).window_size=2*s.w_size,ls(s.head),s.max_lazy_match=Ts[s.level].max_lazy,s.good_match=Ts[s.level].good_length,s.nice_match=Ts[s.level].nice_length,s.max_chain_length=Ts[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},bs=(e,t,s,i,n,o)=>{if(!e)return Kt;let r=1;if(t===Wt&&(t=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||s!==es||i<8||i>15||t<0||t>9||o<0||o>Yt||8===i&&1!==r)return rs(e,Kt);8===i&&(i=9);const a=new ys;return e.state=a,a.strm=e,a.status=is,a.wrap=r,a.gzhead=null,a.w_bits=i,a.w_size=1<bs(e,t,es,15,8,Xt),deflateInit2:bs,deflateReset:ws,deflateResetKeep:Ns,deflateSetHeader:(e,t)=>As(e)||2!==e.state.wrap?Kt:(e.state.gzhead=t,zt),deflate:(e,t)=>{if(As(e)||t>Vt||t<0)return e?rs(e,Kt):Kt;const s=e.state;if(!e.output||0!==e.avail_in&&!e.input||s.status===os&&t!==Ht)return rs(e,0===e.avail_out?Qt:Kt);const i=s.last_flush;if(s.last_flush=t,0!==s.pending){if(hs(e),0===e.avail_out)return s.last_flush=-1,zt}else if(0===e.avail_in&&as(t)<=as(i)&&t!==Ht)return rs(e,Qt);if(s.status===os&&0!==e.avail_in)return rs(e,Qt);if(s.status===is&&0===s.wrap&&(s.status=ns),s.status===is){let t=es+(s.w_bits-8<<4)<<8,i=-1;if(i=s.strategy>=$t||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,ps(s,t),0!==s.strstart&&(ps(s,e.adler>>>16),ps(s,65535&e.adler)),e.adler=1,s.status=ns,hs(e),0!==s.pending)return s.last_flush=-1,zt}if(57===s.status)if(e.adler=0,_s(s,31),_s(s,139),_s(s,8),s.gzhead)_s(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)),_s(s,255&s.gzhead.time),_s(s,s.gzhead.time>>8&255),_s(s,s.gzhead.time>>16&255),_s(s,s.gzhead.time>>24&255),_s(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),_s(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(_s(s,255&s.gzhead.extra.length),_s(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=xt(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69;else if(_s(s,0),_s(s,0),_s(s,0),_s(s,0),_s(s,0),_s(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),_s(s,3),s.status=ns,hs(e),0!==s.pending)return s.last_flush=-1,zt;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=xt(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex+=n,hs(e),0!==s.pending)return s.last_flush=-1,zt;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=xt(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=xt(e.adler,s.pending_buf,s.pending-i,i)),hs(e),0!==s.pending)return s.last_flush=-1,zt;i=0}t=s.gzindexi&&(e.adler=xt(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=xt(e.adler,s.pending_buf,s.pending-i,i)),hs(e),0!==s.pending)return s.last_flush=-1,zt;i=0}t=s.gzindexi&&(e.adler=xt(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&&(hs(e),0!==s.pending))return s.last_flush=-1,zt;_s(s,255&e.adler),_s(s,e.adler>>8&255),e.adler=0}if(s.status=ns,hs(e),0!==s.pending)return s.last_flush=-1,zt}if(0!==e.avail_in||0!==s.lookahead||t!==Mt&&s.status!==os){let i=0===s.level?vs(s,t):s.strategy===$t?((e,t)=>{let s;for(;;){if(0===e.lookahead&&(fs(e),0===e.lookahead)){if(t===Mt)return 1;break}if(e.match_length=0,s=Pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(us(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2})(s,t):s.strategy===Zt?((e,t)=>{let s,i,n,o;const r=e.window;for(;;){if(e.lookahead<=ts){if(fs(e),e.lookahead<=ts&&t===Mt)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+ts;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=Pt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=Pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(us(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2})(s,t):Ts[s.level].func(s,t);if(3!==i&&4!==i||(s.status=os),1===i||3===i)return 0===e.avail_out&&(s.last_flush=-1),zt;if(2===i&&(t===qt?Ut(s):t!==Vt&&(Dt(s,0,0,!1),t===Ft&&(ls(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),hs(e),0===e.avail_out))return s.last_flush=-1,zt}return t!==Ht?zt:s.wrap<=0?Gt:(2===s.wrap?(_s(s,255&e.adler),_s(s,e.adler>>8&255),_s(s,e.adler>>16&255),_s(s,e.adler>>24&255),_s(s,255&e.total_in),_s(s,e.total_in>>8&255),_s(s,e.total_in>>16&255),_s(s,e.total_in>>24&255)):(ps(s,e.adler>>>16),ps(s,65535&e.adler)),hs(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?zt:Gt)},deflateEnd:e=>{if(As(e))return Kt;const t=e.state.status;return e.state=null,t===ns?rs(e,Bt):zt},deflateSetDictionary:(e,t)=>{let s=t.length;if(As(e))return Kt;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==is||i.lookahead)return Kt;if(1===n&&(e.adler=bt(e.adler,t,s,0)),i.wrap=0,s>=i.w_size){0===n&&(ls(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,fs(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=cs(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,fs(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,zt},deflateInfo:"pako deflate (from Nodeca project)"};const xs=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Rs=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)xs(s,t)&&(e[t]=s[t])}}return e},Os=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;Ds[254]=Ds[254]=1;var Ls=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},Ps=(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&&ks)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+Ds[e[s]]>t?s:t};var Ms=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 qs=Object.prototype.toString,{Z_NO_FLUSH:Fs,Z_SYNC_FLUSH:Hs,Z_FULL_FLUSH:Vs,Z_FINISH:zs,Z_OK:Gs,Z_STREAM_END:Ks,Z_DEFAULT_COMPRESSION:Bs,Z_DEFAULT_STRATEGY:Qs,Z_DEFLATED:Ws}=Ot;function js(e){this.options=Rs({level:Bs,method:Ws,chunkSize:16384,windowBits:15,memLevel:8,strategy:Qs},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 Ms,this.strm.avail_out=0;let s=Is.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(s!==Gs)throw new Error(Rt[s]);if(t.header&&Is.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Ls(t.dictionary):"[object ArrayBuffer]"===qs.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,s=Is.deflateSetDictionary(this.strm,e),s!==Gs)throw new Error(Rt[s]);this._dict_set=!0}}function $s(e,t){const s=new js(t);if(s.push(e,!0),s.err)throw s.msg||Rt[s.err];return s.result}js.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?zs:Fs,"string"==typeof e?s.input=Ls(e):"[object ArrayBuffer]"===qs.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===Hs||o===Vs)&&s.avail_out<=6)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else{if(n=Is.deflate(s,o),n===Ks)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),n=Is.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Gs;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},js.prototype.onData=function(e){this.chunks.push(e)},js.prototype.onEnd=function(e){e===Gs&&(this.result=Os(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Zs={Deflate:js,deflate:$s,deflateRaw:function(e,t){return(t=t||{}).raw=!0,$s(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,$s(e,t)},constants:Ot};const Ys=16209;var Xs=function(e,t){let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A,N;const w=e.state;s=e.next_in,A=e.input,i=s+(e.avail_in-5),n=e.next_out,N=e.output,o=n-(t-e.avail_out),r=n+(e.avail_out-257),a=w.dmax,l=w.wsize,d=w.whave,c=w.wnext,h=w.window,u=w.hold,_=w.bits,p=w.lencode,E=w.distcode,g=(1<>>24,u>>>=S,_-=S,S=v>>>16&255,0===S)N[n++]=65535&v;else{if(!(16&S)){if(64&S){if(32&S){w.mode=16191;break e}e.msg="invalid literal/length code",w.mode=Ys;break e}v=p[(65535&v)+(u&(1<>>=S,_-=S),_<15&&(u+=A[s++]<<_,_+=8,u+=A[s++]<<_,_+=8),v=E[u&f];;){if(S=v>>>24,u>>>=S,_-=S,S=v>>>16&255,16&S){if(C=65535&v,S&=15,_a){e.msg="invalid distance too far back",w.mode=Ys;break e}if(u>>>=S,_-=S,S=n-o,C>S){if(S=C-S,S>d&&w.sane){e.msg="invalid distance too far back",w.mode=Ys;break e}if(T=0,y=h,0===c){if(T+=l-S,S2;)N[n++]=y[T++],N[n++]=y[T++],N[n++]=y[T++],m-=3;m&&(N[n++]=y[T++],m>1&&(N[n++]=y[T++]))}else{T=n-C;do{N[n++]=N[T++],N[n++]=N[T++],N[n++]=N[T++],m-=3}while(m>2);m&&(N[n++]=N[T++],m>1&&(N[n++]=N[T++]))}break}if(64&S){e.msg="invalid distance code",w.mode=Ys;break e}v=E[(65535&v)+(u&(1<>3,s-=m,_-=m<<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,E=0,g=0,f=0,v=0,S=0,m=0,C=0,T=0,y=0,A=0,N=null;const w=new Uint16Array(16),b=new Uint16Array(16);let I,x,R,O=null;for(E=0;E<=Js;E++)w[E]=0;for(g=0;g=1&&0===w[v];v--);if(S>v&&(S=v),0===v)return n[o++]=20971520,n[o++]=20971520,a.bits=1,0;for(f=1;f0&&(0===e||1!==v))return-1;for(b[1]=0,E=1;E852||2===e&&y>592)return 1;for(;;){I=E-C,r[g]+1=p?(x=O[r[g]-p],R=N[r[g]-p]):(x=96,R=0),d=1<>C)+c]=I<<24|x<<16|R}while(0!==c);for(d=1<>=1;if(0!==d?(A&=d-1,A+=d):A=0,g++,0==--w[E]){if(E===v)break;E=t[s+r[g]]}if(E>S&&(A&u)!==h){for(0===C&&(C=S),_+=f,m=E-C,T=1<852||2===e&&y>592)return 1;h=A&u,n[h]=S<<24|m<<16|_-o}}return 0!==A&&(n[_+A]=E-C<<24|64<<16),a.bits=S,0};const{Z_FINISH:oi,Z_BLOCK:ri,Z_TREES:ai,Z_OK:li,Z_STREAM_END:di,Z_NEED_DICT:ci,Z_STREAM_ERROR:hi,Z_DATA_ERROR:ui,Z_MEM_ERROR:_i,Z_BUF_ERROR:pi,Z_DEFLATED:Ei}=Ot,gi=16180,fi=16190,vi=16191,Si=16192,mi=16194,Ci=16199,Ti=16200,yi=16206,Ai=16209,Ni=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function wi(){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 bi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Ii=e=>{if(bi(e))return hi;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=gi,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,li},xi=e=>{if(bi(e))return hi;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ii(e)},Ri=(e,t)=>{let s;if(bi(e))return hi;const i=e.state;return t<0?(s=0,t=-t):(s=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?hi:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=s,i.wbits=t,xi(e))},Oi=(e,t)=>{if(!e)return hi;const s=new wi;e.state=s,s.strm=e,s.window=null,s.mode=gi;const i=Ri(e,t);return i!==li&&(e.state=null),i};let ki,Di,Li=!0;const Pi=e=>{if(Li){ki=new Int32Array(512),Di=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(ni(1,e.lens,0,288,ki,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ni(2,e.lens,0,32,Di,0,e.work,{bits:5}),Li=!1}e.lencode=ki,e.lenbits=9,e.distcode=Di,e.distbits=5},Ui=(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.whaveOi(e,15),inflateInit2:Oi,inflate:(e,t)=>{let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A=0;const N=new Uint8Array(4);let w,b;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(bi(e)||!e.output||!e.input&&0!==e.avail_in)return hi;s=e.state,s.mode===vi&&(s.mode=Si),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,y=li;e:for(;;)switch(s.mode){case gi:if(0===s.wrap){s.mode=Si;break}for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>>8&255,s.check=xt(s.check,N,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=Ai;break}if((15&d)!==Ei){e.msg="unknown compression method",s.mode=Ai;break}if(d>>>=4,c-=4,T=8+(15&d),0===s.wbits&&(s.wbits=T),T>15||T>s.wbits){e.msg="invalid window size",s.mode=Ai;break}s.dmax=1<>8&1),512&s.flags&&4&s.wrap&&(N[0]=255&d,N[1]=d>>>8&255,s.check=xt(s.check,N,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,N[2]=d>>>16&255,N[3]=d>>>24&255,s.check=xt(s.check,N,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&&(N[0]=255&d,N[1]=d>>>8&255,s.check=xt(s.check,N,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=xt(s.check,N,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&&(T=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+_),T)),512&s.flags&&4&s.wrap&&(s.check=xt(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{T=i[o+_++],s.head&&T&&s.length<65536&&(s.head.name+=String.fromCharCode(T))}while(T&&_>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=vi;break;case 16189:for(;c<32;){if(0===a)break e;a--,d+=i[o++]<>>=7&c,c-=7&c,s.mode=yi;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(Pi(s),s.mode=Ci,t===ai){d>>>=2,c-=2;break e}break;case 2:s.mode=16196;break;case 3:e.msg="invalid block type",s.mode=Ai}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=Ai;break}if(s.length=65535&d,d=0,c=0,s.mode=mi,t===ai)break e;case mi: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=vi;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=Ai;break}s.have=0,s.mode=16197;case 16197:for(;s.have>>=3,c-=3}for(;s.have<19;)s.lens[I[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,w={bits:s.lenbits},y=ni(0,s.lens,0,19,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid code lengths set",s.mode=Ai;break}s.have=0,s.mode=16198;case 16198:for(;s.have>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=g,c-=g,s.lens[s.have++]=v;else{if(16===v){for(b=g+2;c>>=g,c-=g,0===s.have){e.msg="invalid bit length repeat",s.mode=Ai;break}T=s.lens[s.have-1],_=3+(3&d),d>>>=2,c-=2}else if(17===v){for(b=g+3;c>>=g,c-=g,T=0,_=3+(7&d),d>>>=3,c-=3}else{for(b=g+7;c>>=g,c-=g,T=0,_=11+(127&d),d>>>=7,c-=7}if(s.have+_>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=Ai;break}for(;_--;)s.lens[s.have++]=T}}if(s.mode===Ai)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=Ai;break}if(s.lenbits=9,w={bits:s.lenbits},y=ni(1,s.lens,0,s.nlen,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid literal/lengths set",s.mode=Ai;break}if(s.distbits=6,s.distcode=s.distdyn,w={bits:s.distbits},y=ni(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,w),s.distbits=w.bits,y){e.msg="invalid distances set",s.mode=Ai;break}if(s.mode=Ci,t===ai)break e;case Ci:s.mode=Ti;case Ti: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,Xs(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===vi&&(s.back=-1);break}for(s.back=0;A=s.lencode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,s.length=v,0===f){s.mode=16205;break}if(32&f){s.back=-1,s.mode=vi;break}if(64&f){e.msg="invalid literal/length code",s.mode=Ai;break}s.extra=15&f,s.mode=16201;case 16201:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=16202;case 16202:for(;A=s.distcode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,64&f){e.msg="invalid distance code",s.mode=Ai;break}s.offset=v,s.extra=15&f,s.mode=16203;case 16203:if(s.extra){for(b=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=Ai;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=Ai;break}_>s.wnext?(_-=s.wnext,p=s.wsize-_):p=s.wnext-_,_>s.length&&(_=s.length),E=s.window}else E=n,p=r-s.offset,_=s.length;_>l&&(_=l),l-=_,s.length-=_;do{n[r++]=E[p++]}while(--_);0===s.length&&(s.mode=Ti);break;case 16205:if(0===l)break e;n[r++]=s.length,l--,s.mode=Ti;break;case yi:if(s.wrap){for(;c<32;){if(0===a)break e;a--,d|=i[o++]<{if(bi(e))return hi;let t=e.state;return t.window&&(t.window=null),e.state=null,li},inflateGetHeader:(e,t)=>{if(bi(e))return hi;const s=e.state;return 2&s.wrap?(s.head=t,t.done=!1,li):hi},inflateSetDictionary:(e,t)=>{const s=t.length;let i,n,o;return bi(e)?hi:(i=e.state,0!==i.wrap&&i.mode!==fi?hi:i.mode===fi&&(n=1,n=bt(n,t,s,0),n!==i.check)?ui:(o=Ui(e,t,s,s),o?(i.mode=16210,_i):(i.havedict=1,li)))},inflateInfo:"pako inflate (from Nodeca project)"};var qi=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 Fi=Object.prototype.toString,{Z_NO_FLUSH:Hi,Z_FINISH:Vi,Z_OK:zi,Z_STREAM_END:Gi,Z_NEED_DICT:Ki,Z_STREAM_ERROR:Bi,Z_DATA_ERROR:Qi,Z_MEM_ERROR:Wi}=Ot;function ji(e){this.options=Rs({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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ms,this.strm.avail_out=0;let s=Mi.inflateInit2(this.strm,t.windowBits);if(s!==zi)throw new Error(Rt[s]);if(this.header=new qi,Mi.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Ls(t.dictionary):"[object ArrayBuffer]"===Fi.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=Mi.inflateSetDictionary(this.strm,t.dictionary),s!==zi)))throw new Error(Rt[s])}function $i(e,t){const s=new ji(t);if(s.push(e),s.err)throw s.msg||Rt[s.err];return s.result}ji.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?Vi:Hi,"[object ArrayBuffer]"===Fi.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=Mi.inflate(s,r),o===Ki&&n&&(o=Mi.inflateSetDictionary(s,n),o===zi?o=Mi.inflate(s,r):o===Qi&&(o=Ki));s.avail_in>0&&o===Gi&&s.state.wrap>0&&0!==e[s.next_in];)Mi.inflateReset(s),o=Mi.inflate(s,r);switch(o){case Bi:case Qi:case Ki:case Wi:return this.onEnd(o),this.ended=!0,!1}if(a=s.avail_out,s.next_out&&(0===s.avail_out||o===Gi))if("string"===this.options.to){let e=Us(s.output,s.next_out),t=s.next_out-e,n=Ps(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!==zi||0!==a){if(o===Gi)return o=Mi.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},ji.prototype.onData=function(e){this.chunks.push(e)},ji.prototype.onEnd=function(e){e===zi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Os(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Zi={Inflate:ji,inflate:$i,inflateRaw:function(e,t){return(t=t||{}).raw=!0,$i(e,t)},ungzip:$i,constants:Ot};const{Deflate:Yi,deflate:Xi,deflateRaw:Ji,gzip:en}=Zs,{Inflate:tn,inflate:sn,inflateRaw:nn,ungzip:on}=Zi;var rn={Deflate:Yi,deflate:Xi,deflateRaw:Ji,gzip:en,Inflate:tn,inflate:sn,inflateRaw:nn,ungzip:on,constants:Ot};const an=t=>e(void 0,void 0,void 0,(function*(){const e=rn.ungzip(t);return String.fromCharCode.apply(null,e)}));var ln,dn;exports.ConnectionState=void 0,(ln=exports.ConnectionState||(exports.ConnectionState={})).CONNECTING="CONNECTING",ln.OPEN="OPEN",ln.CLOSED="CLOSED";class cn extends I{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}get ws(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}_handleMessage(e){e.split("\n").forEach((e=>{if(e){const t=Te.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 Ce(t.payload);e.expiresIn>=0&&this._dispatcher.dispatch(e)}}else"NOOP"===t.code||this.dispatch("message",t)}}))}connect(t,s=""){return e(this,void 0,void 0,(function*(){this._ws=new WebSocket(t,encodeURIComponent(s)),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*(){try{const e=yield an(s.result);this._handleMessage(e)}catch(e){this.error(e)}}))}else if(t.data instanceof ArrayBuffer)try{const e=yield an(new Uint8Array(t.data));this._handleMessage(e)}catch(e){this.error(e)}else if("undefined"!=typeof Buffer&&t.data instanceof Buffer)try{const e=t.data,s=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),i=yield an(s);this._handleMessage(i)}catch(e){this.error(e)}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._ws.onopen=ze,this._ws.onmessage=ze,this._ws.onerror=ze,this.connectionState!==exports.ConnectionState.CLOSED?(this._ws.onclose=()=>{this.dispatch("close"),e()},this._ws.close(),this._ws=void 0):e()):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 hn extends R{constructor({all:e,feed:t,custom_types:s,ts:i}){super(),this.all=e,this.feed=t,this.customTypes=s,this.ts=i}}class un{constructor(e,{session: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 Ve(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this.websocketClient=new cn(e,{sdkState:s,dispatcher:i,logger:n}),this.websocketClient.on("message",(e=>{if(e.payload.unread_cnt&&this._dispatcher.dispatch(new hn(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 qe;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",t.requestId,i),e.reject(i)):(this._logger.debug("receive websocket ack",t.requestId,t),this._logger.debug("receive websocket ack",n),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 ve)return yield this._sendApiRequest(t);if(t instanceof ye)return yield this._sendWebsocketRequest(t);throw o.invalidParameters}))}cancel(e){this.apiClient.cancel(e)}cancelAll(){this.apiClient.cancelAll()}}exports.ConnectionStateType=void 0,(dn=exports.ConnectionStateType||(exports.ConnectionStateType={}))[dn.NONE=0]="NONE",dn[dn.INITIALIZED=1]="INITIALIZED",dn[dn.CONNECTING=2]="CONNECTING",dn[dn.CONNECTED=3]="CONNECTED",dn[dn.RECONNECTING=4]="RECONNECTING",dn[dn.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",dn[dn.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",dn[dn.LOGOUT=7]="LOGOUT";class _n extends R{constructor({stateType:e}){super(),this.stateType=e}}class pn extends R{}class En extends R{}class gn extends R{}class fn{constructor(e){var t,s,i,n;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(s=e.feed_channels)&&void 0!==s?s:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(n=e.settings_updated_at)&&void 0!==n?n:0}static payloadify(e){return O(k({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}class vn{constructor(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}static payloadify(e){return O(k({last_updated_at:e.lastUpdatedAt}))}}class Sn{constructor(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}static payloadify(e){return O(k({template_list_token:e.token}))}}class mn{constructor(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}){this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}static payloadify(e){return O(k({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}class Cn{constructor(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}){this.default=new mn(e.default),this.realTime=new mn(e.realtime)}static payloadify(e){return O(k({default:mn.payloadify(e.default),realtime:mn.payloadify(e.realTime)}))}}const Tn=1048576;var yn,An;exports.UnreadCountThreadingPolicy=void 0,(yn=exports.UnreadCountThreadingPolicy||(exports.UnreadCountThreadingPolicy={}))[yn.NONE=0]="NONE",yn[yn.INCLUDE_REPLY=1]="INCLUDE_REPLY",yn[yn.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",yn[yn.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",exports.LastMessageThreadingPolicy=void 0,(An=exports.LastMessageThreadingPolicy||(exports.LastMessageThreadingPolicy={}))[An.NONE=0]="NONE",An[An.INCLUDE_REPLY=1]="INCLUDE_REPLY",An[An.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",An[An.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";class Nn{constructor(e={}){var t,s,i,n,o,r,a;this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Tn: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.unreadCountThreadingPolicy=null!==(o=e.unread_cnt_threading_policy)&&void 0!==o?o:exports.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(r=e.last_msg_threading_policy)&&void 0!==r?r:exports.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new vn(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new fn(e.notifications):null,this.messageTemplateInfo=e.message_template?new Sn(e.message_template):null,this.statConfigInfo=e.log_publish_config?new Cn(e.log_publish_config):new Cn}static payloadify(e){return O(k({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Tn,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?vn.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?fn.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Sn.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Cn.payloadify(e.statConfigInfo):null}))}}class wn{constructor(e){this._iid="",this._iid=e}static payloadify(e){return{}}}class bn extends ve{constructor({userId:e,metadata:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${W}/${e}/metadata`,this.params={metadata:t}}}class In extends Se{constructor(e,t){super(e,t),this.metaData=t}}class xn extends ve{constructor({userId:e,metadata:t,upsert:s}){super(),this.method=exports.APIRequestMethod.PUT,this.path=`${W}/${e}/metadata`,this.params={metadata:t,upsert:s}}}class Rn extends Se{constructor(e,t){super(e,t),this.metadata=t}}class On extends ve{constructor({userId:e,metadataKey:t}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${W}/${e}/metadata/${t}`}}class kn extends ve{constructor({userId:e}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${W}/${e}/metadata`}}const Dn=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return s._iid&&delete s._iid,t&&t(s),s},Ln=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return t&&t(s),s},Pn=e=>({do:t=>{e||t()},throw:t=>{if(!e)throw t}});var Un;exports.UserOnlineState=void 0,(Un=exports.UserOnlineState||(exports.UserOnlineState={})).ONLINE="online",Un.OFFLINE="offline",Un.NON_AVAILABLE="nonavailable";class Mn extends wn{constructor(e,t){var s,i,n,o,r,a,c,h,u,_,p,E;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!==(E=t.friend_name)&&void 0!==E?E:null}static payloadify(e){return O(k(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}=Lo.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainProfileUrl}?auth=${e.ekey}`:this.plainProfileUrl}serialize(){return Dn(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*(){Pn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Lo.of(this._iid),i=new bn({userId:e.userId,metadata:t}),n=yield s.send(i),{metaData:r}=n.as(In);return this._applyMetaData(r),this.metaData}))}updateMetaData(t,s=!1){return e(this,void 0,void 0,(function*(){Pn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:i}=Lo.of(this._iid),n=new xn({userId:e.userId,metadata:t,upsert:s}),r=yield i.send(n),{metadata:a}=r.as(Rn);return this._applyMetaData(a),this.metaData}))}deleteMetaData(t){return e(this,void 0,void 0,(function*(){Pn(l("string",t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Lo.of(this._iid),i=new On({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}=Lo.of(this._iid),s=new kn({userId:e.userId});yield t.send(s),this.metaData={}}))}}class qn extends R{constructor({userProfile:e}){super(),this.userProfile=e}}class Fn{constructor(e,t){var s,i,n,o,r,a,l,d,c,h,u,_,p,E;this._iid=e,this.appInfo=new Nn(t),this.user=new Mn(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!==(E=t.back_off_delay)&&void 0!==E?E:100}static payloadify(e){return O(k(Object.assign(Object.assign(Object.assign({},Mn.payloadify(e.user)),Nn.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=Lo.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 qn({userProfile:this}))}}class Hn extends R{constructor({request:e=!0,features:t={},options:s={},statConfigInfo:i}){super(),this.request=e,this.features=Object.assign({localCache:!0,notification:!0},t),this.options=Object.assign({ingestion:!0},s),this.statConfigInfo=i}}class Vn extends Te{constructor(e,t,s){var i,n,r,a;super(e,t,s),this.error=null,this.services=[],this.userProfile=new Fn(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,this.services=null!==(a=s.services)&&void 0!==a?a:[]}static asError(e){return new Vn("","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=Lo.of(t);if(!e)throw o.lostInstance;{const{sessionManager:t,dispatcher:s}=e;yield t.login(this),this.userProfile.apply(),s.dispatch(new Hn({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo}))}}}))}}class zn{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,cause:n=null}){return e(this,void 0,void 0,(function*(){}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){}))}}const Gn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){if(!(e instanceof o))throw e;e.throwOutside()}})),Kn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){}}));class Bn extends zn{constructor(e={}){var t;super(),this.type=exports.ConnectionStateType.LOGOUT,this.name="logout",this._wasPreviouslyConnected=null===(t=e.wasPreviouslyConnected)||void 0===t||t}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 io,s),this._wasPreviouslyConnected&&Gn((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onDisconnected&&e.onDisconnected(i)}))}))))}))}}class Qn extends zn{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 to({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Yn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn,e)}))}}class Wn extends zn{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 Yn,e))}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new to({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Yn,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Qn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn,e)}))}}const jn=t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}));class $n{calcTimeout(){return 0}}const Zn=(t,s,i=new $n)=>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||et(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=new qe;this._callbacks.push((e=>e?i.reject(e):i.resolve())),Gn((()=>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 Zn(((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){if(e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);if(e.isSessionExpiredError||e.isSessionInvalidatedError)return void s(e)}throw e}}))),i,n),yield t.changeState(new Xn,s),this._flushCallbacks(),Gn((()=>e(this,void 0,void 0,(function*(){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 Wn({autoReconnect:!1}),s)),this._flushCallbacks(i),Gn((()=>e(this,void 0,void 0,(function*(){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 qe;return this._halt(o.connectionCanceled),t.cancelConnectForRetry(),this._callbacks.push((()=>{const i=Date.now();t.changeState(new to({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 qe;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 Wn({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 Qn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Bn,e)}))}}class Xn extends zn{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 Yn,e)}))}onDisconnect(t,{autoReconnect:s}){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Wn({autoReconnect:s}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Qn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn,e)}))}}var Jn;!function(e){e.ExternalSetBackground="ExternalSetBackground",e.ExternalDisconnectWebSocket="ExternalDisconnectWebSocket"}(Jn||(Jn={}));class eo{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:o,dispatcher:r,logger:a,disableWebSocketCloseEventHandling:l=!1}){this._disableWebSocketCloseEventHandling=!1,this._webSocketClosedCause=null,this._logger=a,this._disableWebSocketCloseEventHandling=l,this._context=new ao(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",(()=>{this.isConnecting||this.isConnected||(this._logger.debug("try reconnect by session key refresh"),Kn((()=>e(this,void 0,void 0,(function*(){yield this.reconnect()})))))})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(()=>{"foreground"!==this._sdkState.appState||this._webSocketClosedCause||Kn((()=>e(this,void 0,void 0,(function*(){this._sessionManager.isSessionKeyRefreshing?yield this.disconnectWebSocket():(this._logger.debug("try reconnect by websocket connection closed"),yield 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}get websocketClient(){return this._websocketClient}connect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onConnect(this._context,t),this._registerEventDispatcher()}))}reconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{})}))}resetAndReconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{resetReconnectCount:!0})}))}background(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=Jn.ExternalSetBackground,yield e.onDisconnect(this._context,{autoReconnect:!1,cause:this._webSocketClosedCause})}))}disconnect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;yield e.onDisconnect(this._context,{error:t,autoReconnect:!0,cause:this._webSocketClosedCause})}))}disconnectWebSocket(t=!1){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;t&&(this._webSocketClosedCause=Jn.ExternalDisconnectWebSocket),yield e.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause})}))}logout(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._clearEventDispatcher(),yield e.onLogout(this._context,t)}))}}class to extends zn{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 qe;this._callbacks.push((e=>e?i.reject(e):i.resolve()));try{yield Zn((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 Xn,s),Gn((()=>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 io,s)),Gn((()=>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 qe;return this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:i=!1,cause:n=null}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:so(n)),t.hasSession?yield t.changeState(new Wn({autoReconnect:i}),e):yield t.changeState(new Bn,e)}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){this._halt(so((null==s?void 0:s.cause)||null));const e=Date.now();t.hasSession?yield t.changeState(new Qn,e):yield t.changeState(new Bn,e)}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:o.connectionCanceled),yield t.changeState(new Bn,e)}))}}function so(e){const t=o.connectionCanceled;if(e){let s=null;switch(e){case Jn.ExternalSetBackground:s="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case Jn.ExternalDisconnectWebSocket:s="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}s&&t.setDetail(s)}return t}class io extends zn{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 to({authToken:s}),e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn({wasPreviouslyConnected:!1}),e)}))}}class no extends ye{constructor(){super({code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}}class oo{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 no;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)}}const ro=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"];class ao extends I{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:r,dispatcher:a,logger:l,entryState:d=new io}){var c;super(),this._stateUpdatedAt=0,this._connectingAt=0,this._connectedAt=0,this._logiReceivedAt=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 oo({pingDelegate:{send:e=>this._websocketClient.send(e),error:e=>this._websocketClient.error(e)},sdkState:this.sdkState,logger:l})),this._websocketClient.on("open",(()=>{this._connectedAt=Date.now(),this._tryResolveConnectionRequest()})).on("message",(e=>{if("LOGI"===e.code)this.clearLoginTimer(),this._dispatcher.dispatch(e.as(Vn))})).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 Vn&&(this._unresolvedLogi=e,this._tryResolveConnectionRequest())}))}get currentState(){return this._currentState}get hasSession(){return this._sessionManager.session.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 _n({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;this._websocketClient.isOpen&&e&&(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),e.error?(this._sessionManager.session.authToken=void 0,e.error.isSessionExpiredError||e.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Ce({reason:e.error.code,message:e.error.message})):this._logger.warn(`login failed: ${e.error}`),this._rejectConnectionRequest(e.error)):(yield e.applyTo(this._iid),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(){var e;const{appId:t,appVersion:s,userId:n,extensions:o,sendbirdRuntimeEnvironment:r}=this.sdkState,{localCacheEnabled:a}=this.cacheContext,{session:l}=this._sessionManager,d=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,c=!!(null!=o?o:{}).sb_uikit,h=Me.userAgentWithExtension(o);return`${this.sdkState.websocket.host}/?p=JS&pv=${encodeURIComponent(i.OS_VERSION)}&sv=${encodeURIComponent(i.SDK_VERSION)}&ai=${t}${s?`&av=${s}`:""}${l.hasSession?"":`&user_id=${encodeURIComponent(n)}`}&pmce=${d?1:0}&active=1&device_token_types=${encodeURIComponent(["gcm","huawei","apns"].join(","))}&SB-User-Agent=${h}&SB-SDK-User-Agent=${encodeURIComponent(Me.sendbirdSdkUserAgentWithExtension(r))}&Request-Sent-Timestamp=${Date.now().toString()}&include_extra_data=${encodeURIComponent(String(ro))}${this._sessionManager.handler?"&expiring_session=1":""}&use_local_cache=${a?1:0}&include_poll_details=1${c?"&uikit_config=1":""}`}_statLogConnection(e){var t;this._dispatcher.dispatch(new Ie(new Oe({type:exports.StatType.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:this._connectedAt>0?this._connectedAt-this._connectingAt:0,logi_latency:this._logiReceivedAt>0?this._logiReceivedAt-this._connectedAt:void 0,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=new qe;if(this._connectionRequestQueue.push(e),1===this._connectionRequestQueue.length){this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout((()=>{this._loginTimer=void 0,this._rejectConnectionRequest(o.loginTimeout)}),null===(s=this.sdkState.websocket)||void 0===s?void 0:s.responseTimeout);const{session:e}=this._sessionManager;t&&(e.authToken=t,e.sessionKey=void 0);const i=this._url();e.sessionKey||e.authToken?this._websocketClient.connect(i,JSON.stringify(e.hasSession?{auth:e.sessionKey}:{token:e.authToken})):this._websocketClient.connect(i,JSON.stringify({}))}return e.promise}))}cancelConnectForRetry(){this._dispatcher.dispatch(Vn.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.disconnect(),yield this._sessionManager.clear()}))}clearLoginTimer(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}class lo extends ve{constructor({appId:e,userId:t,includeUIKitConfig:s=!1,localCacheEnabled:i=!0,expiringSession:n=!0}){super(),this.path=`${j}/${t}/authentication`,this.method=exports.APIRequestMethod.POST,this.params=O({expiring_session:!!n,include_logi:!0,include_extra_data:String(ro),uikit_config:s,use_local_cache:i,app_id:e}),this.requireAuth=!1}}class co extends Se{constructor(e,t){super(e,t),this.logi=new Vn(e,"LOGI",t)}}var ho;!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(ho||(ho={}));const uo=[Ae,lo];class _o{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r=!1}){this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new un(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this._session=t,this._logger=n,this._dispatcher=i,this._dispatcher.on((e=>{var t;if(e instanceof _n){const{stateType:s}=e;switch(this._currentConnectionStateType=s,s){case exports.ConnectionStateType.CONNECTED:this._resolveLazyCallQueue();break;case exports.ConnectionStateType.INITIALIZED:case exports.ConnectionStateType.INTERNAL_DISCONNECTED:case exports.ConnectionStateType.EXTERNAL_DISCONNECTED:case exports.ConnectionStateType.LOGOUT:this._rejectLazyCallQueue((null===(t=this._session)||void 0===t?void 0:t.hasSession)?o.connectionClosed:o.connectionRequired)}}else if(e instanceof pn)this._session.hasChatServicePermission||this._resolveLazyCallQueue(ho.API);else if(e instanceof En||e instanceof gn)this._rejectLazyCallQueue(o.connectionClosed);else if(e instanceof xe){const{request:t,deferred:s,error:i}=e;for(const e of uo)if(t instanceof e)return void s.reject(i);this._lazyCallQueue.push({command:t,deferred:s})}}))}get isReady(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED}get isLazyCallActivated(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING||this._currentConnectionStateType===exports.ConnectionStateType.RECONNECTING||this._session.isRefreshing}_classifyLazyCallQueueByScope(e){const t=[],s=[];let i;switch(e){case ho.ALL:i=null;break;case ho.WEBSOCKET:i=ye;break;case ho.API:i=ve}let n=!1;return this._lazyCallQueue.forEach((e=>{!i||e.command instanceof i||(n=!0),n?s.push(e):t.push(e)})),[t,s]}_resolveLazyCallQueue(t=ho.ALL){const[s,i]=this._classifyLazyCallQueueByScope(t);this._lazyCallQueue=i,s.forEach((t=>e(this,void 0,void 0,(function*(){const{command:e,deferred:s,timeout:i}=t;i&&clearTimeout(i);try{const t=yield this.send(e);s.resolve(t)}catch(e){s.reject(e)}}))))}_rejectLazyCallQueue(t,s=ho.ALL){const[i,n]=this._classifyLazyCallQueueByScope(s);this._lazyCallQueue=n,i.forEach((s=>e(this,void 0,void 0,(function*(){const{deferred:e,timeout:i}=s;clearTimeout(i),e.reject(t)}))))}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof ye){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 qe;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 ve){if(this._session.hasSession)return this._logger.debug("send api request",t),yield this.commandRouter.send(t);if(t.hasSessionKey)return this._logger.debug("send api request with tmp session key",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait api request",t);const e=new qe;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*(){if(this._logger.debug("send forced request",t),t instanceof ye||t instanceof ve)return yield this.commandRouter.send(t);throw o.invalidCommand}))}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 po="sendbird@devicetokens";class Eo{constructor({type:e,token:t,device_os:s,device_manufacturer:i,system_push_enabled:n}){this.type=e,this.token=t,this.deviceOS=s,this.deviceManufacturer=i,this.systemPushEnabled=n}static payloadify(e){return O(k({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}const go=new WeakMap;class fo extends I{constructor({_iid:e,session:t,cacheContext:s,sdkState:i,dispatcher:o,requestQueue:r,logger:a,pushNotificationAckManager:l}){super(),this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._isRefreshingAuthToken=!1,this.currentUser=null,this.session=t,this._iid=e,this._cacheContext=s,this._sdkState=i,this._dispatcher=o,this._requestQueue=r,this._logger=a,this._pushNotificationAckManager=l,this._deviceTokens=[],this._dispatcher.on((e=>{var t,s,i;if(e instanceof _n){const{stateType:t}=e;this._currentConnectionStateType=t}else if(e instanceof Ce&&this.handler&&!this.isSessionKeyRefreshing){if(this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?this.close():((null===(s=e.error)||void 0===s?void 0:s.isSessionTokenExpiredError)&&this.refreshAuthToken().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(this._logger.debug("session expired"),this.handler.onSessionExpired&&this.handler.onSessionExpired(),this.refreshSessionKey().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e}))))}}))}get ekey(){return go.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 Ne({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(be);if(n)throw n;this.session.sessionKey=null!=i?i:this.session.sessionKey}))}_refreshSessionKeyByApi(t){return e(this,void 0,void 0,(function*(){const s=new Ae({userId:this._sdkState.userId,authToken:t,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0});yield Zn((t=>e(this,void 0,void 0,(function*(){try{const e=yield this._requestQueue.forceSend(s),{key:t,services:i}=e.as(we);this.session.sessionKey=t,this.session.services=i}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){try{return void(yield this._handleSessionRefreshError(e,s))}catch(e){}}try{yield this._refreshSessionKeyByApi(t),this.complete()}catch(e){yield this._handleSessionRefreshError(e,s)}}))}_receiveNewAuthToken(){var t;const s=new qe;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired){let t=null;const i=()=>{t&&(clearTimeout(t),t=null)},n=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.resolve(e))},o=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.reject(e))};t=setTimeout((()=>o()),1e3*this._sdkState.sessionTokenRefreshTimeout),Gn((()=>e(this,void 0,void 0,(function*(){var e;(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(n,o)}))))}else s.resolve(null);return s.promise}_handleSessionRefreshError(t,s=!1){return e(this,void 0,void 0,(function*(){if(!(t instanceof o&&(t.isSessionTokenExpiredError||t.code===exports.SendbirdErrorCode.APPLICATION_NOT_FOUND)&&(this.session.authToken=void 0,s)))throw t;{const e=yield this._receiveNewAuthToken();e?(this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken,!1)):yield this.clear()}}))}_isSessionRelatedError(e){return e instanceof o&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}get isSessionKeyRefreshing(){return this.session.isRefreshing}get isRefreshingAuthToken(){return this._isRefreshingAuthToken}get isSessionExpiring(){return!!this.handler}authenticate(t,s){var i;return e(this,void 0,void 0,(function*(){this.session.authToken=s;const e=new lo({appId:this._sdkState.appId,userId:t,includeUIKitConfig:!!(null!==(i=this._sdkState.extensions)&&void 0!==i?i:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!s||this.isSessionExpiring}),n=yield this._requestQueue.commandRouter.send(e),{logi:o}=n.as(co);if(o.error)throw o.error;this.session.hasChatServicePermission||(yield o.applyTo(this._iid))}))}login(t){var s;return e(this,void 0,void 0,(function*(){const{key:e,ekey:i,services:n,userProfile:o,deviceTokenLastDeletedAt:r=0}=t;this.session.sessionKey=e,this.session.services=n,go.set(this,i),this._deviceTokenCacheEnabled=null===(s=null==o?void 0:o.appInfo)||void 0===s?void 0:s.deviceTokenCache;const{preference:a}=this._cacheContext;if(this._deviceTokenCacheEnabled){const e=yield a.get(po);!e||e.lastDeletedAtnew Eo(Eo.payloadify(e)))),this._deviceTokenLastDeletedAt=e.lastDeletedAt)}else yield a.remove(po)}))}complete(){this.dispatch("refresh"),this._dispatcher.dispatch(new pn),Gn((()=>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){Gn((()=>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"),this._dispatcher.dispatch(new gn),Gn((()=>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()}))))}refreshAuthToken(){return e(this,void 0,void 0,(function*(){let e=null;if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{e=yield this._receiveNewAuthToken(),e?(this._logger.debug("session refreshing.."),this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken)):yield this.clear()}catch(t){const s=e?o.sessionTokenRefreshFailed:o.sessionTokenRequestFailed;throw this._dispatcher.dispatch(new En),this.error(s),this._logger.debug("refresh auth token error = ",s),s}finally{this.session.isRefreshing=!1}}}))}refreshSessionKey(){return e(this,void 0,void 0,(function*(){if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{yield this._refreshSessionKey(this.session.authToken)}catch(e){const t=o.sessionTokenRefreshFailed;throw this._dispatcher.dispatch(new En),this.error(t),t}finally{this.session.isRefreshing=!1}}}))}setDeviceToken(e,t,s){if(this._deviceTokenCacheEnabled){if(this.indexOfDeviceToken(e,t)<0){const i=new Eo({type:e,token:t,device_os:null==s?void 0:s.deviceOS,device_manufacturer:null==s?void 0:s.deviceManufacturer,system_push_enabled:null==s?void 0:s.systemPushEnabled});return this._deviceTokens.push(i),!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(po,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})}}))}clear(){return e(this,void 0,void 0,(function*(){this.currentUser=null,this.session.clear(),this.close(),go.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,yield this.saveDeviceToken(),this._pushNotificationAckManager.clear()}))}}const vo=(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]=vo(e[s],t[s]):o[s]=t[s]}return o}return t};var So,mo;!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(So||(So={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(mo||(mo={}));const Co=100;class To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){this.queue=[],this.flushWaitQueue=[],this.enabledState=So.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=e,this.cacheContext=t,this.requestQueue=s,this.logInfo={deviceId:e,statLogs:[],generation:1,lastFlushedAt:0},this.limit=Co}get isEnabled(){return this.enabledState===So.ENABLED}init(t){return e(this,void 0,void 0,(function*(){this.key=t;const e=yield this.cacheContext.preference.get(this.key);e&&(this.logInfo=e)}))}_mergeQueue(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}_isDuplicateStat(e){const t=this._sentLogStats.find((t=>{var s;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(s=e.data.notificationId)&&void 0!==s?s:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}_save(){return e(this,void 0,void 0,(function*(){const e=[...this.queue,...this.flushWaitQueue];yield this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((e=>Oe.payloadify(e))),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})}))}clear(){return e(this,void 0,void 0,(function*(){this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save()}))}}class yo extends Oe{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 Ao extends ve{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${ae}`,this.params={device_id:e,log_entries:t.map((e=>Oe.payloadify(e)))}}}class No extends To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".daily"),this.queue=this.logInfo.statLogs.map((e=>new Oe({type:e.stat_type,ts:e.ts,data:e.data})))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this.statConfig.minInterval=864e5,this._mergeQueue(),s.localCacheStat?this.enabledState=s.enabledStat?So.ENABLED:So.COLLECT_ONLY:(this.enabledState=So.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=yield this._getUploadStats(),t=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);for(let s=0;se instanceof yo&&e.key===t.key));if(s?s.data=vo(s.data,t.data):e.push(t),this.enabledState!==So.PENDING&&(yield this._save()),this.isEnabled&&(this._mergeQueue(),this._isSendable)){const e=yield this._getUploadStats();return yield this._flush(e)}return!0}))}_getUploadStats(){return e(this,void 0,void 0,(function*(){return this.queue.filter((e=>{if(e instanceof yo){const t=new Date,[s,i]=[e.date.getFullYear(),t.getFullYear()];if(s0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new Ao({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Co,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=So.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=So.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}}class wo extends To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}_isSendable(e=!1){if(this.queue.lengthe.type!==exports.StatType.FEATURE_LOCALCACHE_EVENT)):t.filter((e=>e.type===exports.StatType.FEATURE_LOCALCACHE_EVENT))}))}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".default"),this.queue=this.logInfo.statLogs.map((e=>(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data),new Oe({type:e.stat_type,ts:e.ts,data:e.data}))))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.requestStat||s.localCacheStat){let e;this.enabledState=s.enabledStat?So.ENABLED:So.COLLECT_ONLY,s.requestStat||(e=!1),s.localCacheStat||(e=!0),void 0!==e&&(this.queue=yield this._filterQueueByType(this.queue,e),this.flushWaitQueue=yield this._filterQueueByType(this.flushWaitQueue,e),this._save())}else this.enabledState=So.DISABLED,yield this.clear();if(this.isEnabled&&this._isSendable(!0)){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield jn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===So.DISABLED)return!0;const e=this.enabledState===So.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return e.push(t),this.enabledState!==So.PENDING&&(yield this._save()),!this.isEnabled||(this._mergeQueue(),!this._isSendable())||(yield this._flush(e))}))}_flush(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t.length>0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new Ao({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Co,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=So.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=So.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}}class bo extends ve{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${le}`,this.params={device_id:e,log_entries:t.map((e=>Oe.payloadify(e)))}}}class Io extends To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".realtime"),this.queue=this.logInfo.statLogs.map((e=>{var t;return e.data=O(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Oe({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((e=>{var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.notificationStat?this.enabledState=s.enabledStat?So.ENABLED:So.COLLECT_ONLY:(this.enabledState=So.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield jn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===So.DISABLED)return!0;const e=this.enabledState===So.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return!!this._isDuplicateStat(t)||(e.push(t),this.enabledState!==So.PENDING&&(yield this._save()),!(this.isEnabled&&(this._mergeQueue(),this.isEnabled&&this._isSendable))||(yield this._flush(e)))}))}_flush(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t.length>0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new bo({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Co,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=So.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=So.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}}class xo{constructor({cacheContext:e,requestQueue:t,dispatcher:s,logger:i}){this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=w(),this.cacheContext=e,this.requestQueue=t,this.dispatcher=s,this.logger=i,this._dailyStatCollector=new No({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new wo({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new Io({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}_migration(){return e(this,void 0,void 0,(function*(){const e=yield this.cacheContext.preference.get(this.key);if(e){const t=[];e.statLogs.forEach((e=>{e.stat_type===exports.StatType.FEATURE_LOCALCACHE&&t.push(new Oe({type:e.stat_type,ts:e.ts,data:e.data}))})),yield this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((e=>Oe.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const s=[];e.statLogs.forEach((e=>{e.stat_type!==exports.StatType.FEATURE_LOCALCACHE&&e.stat_type!==exports.StatType.NOTIFICATION&&(e.stat_type===exports.StatType.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),s.push(new Oe({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:s.map((e=>Oe.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const i=[];e.statLogs.forEach((e=>{var t;e.stat_type===exports.StatType.NOTIFICATION&&(e.data=O(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),i.push(new Oe({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:i.map((e=>Oe.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt}),yield this.cacheContext.preference.remove(this.key)}}))}init(t){return e(this,void 0,void 0,(function*(){this.key=t,yield this._migration(),yield this._dailyStatCollector.init(this.key),yield this._defaultStatCollector.init(this.key),yield this._notificationStatCollector.init(this.key),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((t=>e(this,void 0,void 0,(function*(){var e;if(t instanceof Ie){const{statLog:e}=t;this.put(e)}else if(t instanceof Hn){const{request:s,features:i,options:n,statConfigInfo:o}=t;this._retryCount=0,this._collectRequestStat=s,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._notificationStatCollector.setConfig(null!==(e=this._statConfig.realTime)&&void 0!==e?e:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:n.ingestion})}})))))}))}put(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t instanceof yo)this._collectFeatureLocalCacheStat&&(e=yield this._dailyStatCollector.put(t));else switch(t.type){case exports.StatType.API_RESULT:case exports.StatType.WEBSOCKET_CONNECT:this._collectRequestStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.FEATURE_LOCALCACHE:case exports.StatType.FEATURE_LOCALCACHE_EVENT:this._collectFeatureLocalCacheStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.NOTIFICATION:this._collectionNotificationStat&&(e=yield this._notificationStatCollector.put(t))}e?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=So.COLLECT_ONLY,this._defaultStatCollector.enabledState=So.COLLECT_ONLY,this._notificationStatCollector.enabledState=So.COLLECT_ONLY,this.logger.debug(o.statLogUploadLimitExceededError)))}))}close(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}class Ro{constructor({limit:e=5}){this.workersByKey={},this.limit=e}run(t,s){return e(this,void 0,void 0,(function*(){if(this.workersByKey[t]||(this.workersByKey[t]=[]),this.workersByKey[t].length{switch(e){case"open":return exports.PollStatus.OPEN;case"closed":return exports.PollStatus.CLOSED;default:return null}},Ho=e=>!e||!!e.text&&l("string",e.text);class Vo extends wn{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 O(k(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})))}}class zo extends wn{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=Fo(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 Vo(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=Fo(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 Vo(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 O(k(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=>Vo.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 Dn(this)}}class Go{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}}class Ko extends Go{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)}}class Bo extends ve{constructor({title:e,optionTexts:t,data:s,allowUserSuggestion:i,allowMultipleVotes:n,closeAt:o}){super(),this.method=exports.APIRequestMethod.POST,this.path=ne,this.params={title:e,options:t,data:s,allow_user_suggestion:i,allow_multiple_votes:n,close_at:o}}}class Qo extends Se{constructor(e,t){super(e,t),this.poll=new zo(e,t)}}class Wo extends ve{constructor({channelUrl:e,channelType:t,pollId:s}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}`,this.params={channel_url:e,channel_type:t}}}class jo extends Se{constructor(e,t){super(e,t),this.poll=new zo(e,t)}}class $o extends ve{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}`,this.params={channel_url:e,channel_type:t}}}class Zo extends Se{constructor(e,t){super(e,t),this.pollOption=new Vo(e,t)}}class Yo extends ve{constructor({channelType:e,channelUrl:t,timestamp:s,token:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${pe(e)}/${encodeURIComponent(t)}/polls/changelogs`,this.params=O({change_ts:s,token:i})}}class Xo extends Se{constructor(e,t){super(e,t),this.updatedPolls=t.updated.map((t=>((e,t)=>new zo(e,t))(e,t))),this.deletedPollIds=t.deleted.map((e=>e)),this.hasMore=t.has_more,this.nextToken=t.next}}const Jo={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},er=e=>{return l("string",e.title)&&(t=e.optionTexts,h("string",t)&&t.every((e=>""!==e.trim())))&&Ho(e.data)&&l("boolean",e.allowUserSuggestion,!0)&&l("boolean",e.allowMultipleVotes,!0)&&l("number",e.closeAt,!0);var t},tr={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0,pollOptionId:0},sr=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId)&&e.pollId>0&&l("number",e.pollOptionId)&&e.pollOptionId>0,ir={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0},nr=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId),or={};class rr extends ve{constructor({channelUrl:e,channelType:t,token:s,limit:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=ne,this.params={channel_url:e,channel_type:t,token:s,limit:i}}}class ar extends Se{constructor(e,t){var s;super(e,t),this.polls=(null!==(s=t.polls)&&void 0!==s?s:[]).map((t=>new zo(e,t))),this.token=t.next}}class lr extends ve{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i,token:n,limit:o}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}/voters`,this.params={channel_url:e,channel_type:t,token:n,limit:o}}}class dr extends Se{constructor(e,t){var s;super(e,t),this.voters=(null!==(s=t.voters)&&void 0!==s?s:[]).map((t=>new Mn(e,t))),this.token=t.next}}exports.APIRequestCommand=ve,exports.APIResponseCommand=Se,exports.API_PATH_EMOJIS=se,exports.API_PATH_EMOJI_CATEGORIES=ie,exports.API_PATH_FORMS=_e,exports.API_PATH_GROUP_CHANNELS=Z,exports.API_PATH_GROUP_CHANNELS_INTERNAL=Y,exports.API_PATH_MESSAGE_TEMPLATE=he,exports.API_PATH_NOTIFICATIONS=de,exports.API_PATH_NOTIFICATIONS_USERS=ce,exports.API_PATH_OPEN_CHANNELS=X,exports.API_PATH_OPEN_CHANNELS_INTERNAL=J,exports.API_PATH_POLLS=ne,exports.API_PATH_PUSH_DELIVERY=ue,exports.API_PATH_REPORT=te,exports.API_PATH_SCHEDULED_MESSAGES=oe,exports.API_PATH_SEARCH=ee,exports.API_PATH_UIKIT_CONFIGURATION=re,exports.API_PATH_UPLOAD=$,exports.API_PATH_USERS=W,exports.AppInfo=Nn,exports.BaseCommand=R,exports.BaseListQuery=Go,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.CancelXMLHttpRequestCommand=Fe,exports.ChannelDataListQuery=Ko,exports.ConnectionStateChangeCommand=_n,exports.DEFAULT_ENCRYPTION=E,exports.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT=5,exports.DailyRecordStatLog=yo,exports.Deferred=qe,exports.DeleteMessageEventCommand=class extends Te{constructor(e,t,s){var i;super(e,"DELM",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.messageId=Number(s.msg_id),this.silent=s.silent,this.messageCreatedAt=s.message_created_at?Number(s.message_created_at):-1,this.senderId=null!==(i=s.sender_id)&&void 0!==i?i:void 0}},exports.DeleteMessageRequestCommand=He,exports.EventDispatcher=I,exports.InstancedObject=wn,exports.LocalCacheConfig=y,exports.MessageEventSource=Uo,exports.MessageRemoveEventCommand=class extends R{constructor({messageIds:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messageIds=e,this.source=t,this.isWebSocketEventComing=s}},exports.MessageUpdateEventCommand=class extends R{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.NotificationInfo=fn,exports.POLL_REMOVED_STATUS="removed",exports.Poll=zo,exports.PollChangeLogEventCommand=Mo,exports.PollCreateParamsDefault=Jo,exports.PollListQuery=class extends Ko{constructor(e,t){super(e,t.channelUrl,t.channelType,t)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Lo.of(this._iid),t=new rr(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{polls:i,token:n}=s.as(ar);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.PollManager=class{constructor(e,{sdkState:t,dispatcher:s,sessionManager:i,requestQueue:n,logger:o}){this._iid=e,this._sdkState=t,this._sessionManager=i,this._requestQueue=n,this._dispatcher=s,this._logger=o,or[e]=this}static of(e){return or[e]}buildPollFromSerializedData(e){const t=Ln(e);return new zo(this._iid,zo.payloadify(t))}get(t){return e(this,void 0,void 0,(function*(){Pn(nr(t)).throw(o.invalidParameters);const e=new Wo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(jo);return i}))}create(t){return e(this,void 0,void 0,(function*(){Pn(er(t)).throw(o.invalidParameters);const e=new Bo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(Qo);return i}))}getOption(t){return e(this,void 0,void 0,(function*(){Pn(sr(t)).throw(o.invalidParameters);const e=new $o(Object.assign({},t)),s=yield this._requestQueue.send(e),{pollOption:i}=s.as(Zo);return i}))}getPollChangeLogs(t,s,i,n=exports.CollectionEventSource.SYNC_POLL_CHANGELOGS){return e(this,void 0,void 0,(function*(){const e=new Yo(k({channelType:s,channelUrl:t,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null})),o=yield this._requestQueue.send(e),{updatedPolls:r,deletedPollIds:a,hasMore:l,nextToken:d}=o.as(Xo);return r.length>0&&this._dispatcher.dispatch(new Mo({polls:r,source:n})),{updatedPolls:r,deletedPollIds:a,hasMore:l,token:d}}))}},exports.PollOption=Vo,exports.PollOptionRetrievalParamsDefault=tr,exports.PollRetrievalParamsDefault=ir,exports.PollUpdateInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=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.PollVoteInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoterListQuery=class extends Ko{constructor(e,t){super(e,t.channelUrl,t.channelType,t),this.pollId=t.pollId,this.pollOptionId=t.pollOptionId}_validate(){return super._validate()&&l("number",this.pollId)&&l("number",this.pollOptionId)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Lo.of(this._iid),t=new lr(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),s=yield e.send(t),{voters:i,token:n}=s.as(dr);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.ReactionUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.RequestResendCommand=xe,exports.SEMVER_REGEX_STRING="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",exports.SendbirdChatOptions=p,exports.SendbirdError=o,exports.SessionExpiredCommand=Ce,exports.SessionRefreshAPICommand=Ae,exports.StatLog=Oe,exports.SubscribedUnreadMessageCountUpdateCommand=hn,exports.ThreadUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.UIKitConfigInfo=vn,exports.UnsentMessageRemoveEventCommand=class extends R{constructor({reqId:e,source:t}){super(),this.reqId=e,this.source=t}},exports.User=Mn,exports.UserProfile=Fn,exports.UserProfileUpdateCommand=qn,exports.Vault=Lo,exports.WebSocketEventCommand=Te,exports.WebSocketRequestCommand=ye,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=Ee(null!==(i=e.mentionType)&&void 0!==i?i:null,null!==(n=e.mentionedUserIds)&&void 0!==n?n:[],s),l=Ee(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=Ee,exports.createChangelogIncludeChatNotificationsCacheKey=e=>`sendbird@${e}/changelog_include_chat_notifications`,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=Ln,exports.deundefined=O,exports.getChannelApiPathByType=pe,exports.getReportApiPathByType=e=>{switch(e){case exports.ChannelType.GROUP:return`${te}/group_channels`;case exports.ChannelType.OPEN:return`${te}/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.isMilliSecondOf=(e,t=!1)=>!(!t||!_(e))||"number"==typeof e&&13===e.toString().length,exports.isReactNative=ke,exports.isResendableError=e=>e>0&&r.indexOf(e)>=0,exports.isThrowingOutside=n,exports.isTypeOf=l,exports.noop=ze,exports.parsePollStatusPayload=Fo,exports.runAsCallback=Gn,exports.runOrNothing=Kn,exports.serialize=Dn,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===exports.CollectionEventSource.SYNC_MESSAGE_FILL||e===exports.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||e===exports.CollectionEventSource.SYNC_POLL_CHANGELOGS,exports.sleep=jn,exports.undefineNullProps=k,exports.unless=Pn,exports.uuid=w,exports.validatePollCreateParams=er,exports.validatePollData=Ho,exports.validatePollOptionRetrievalParams=sr,exports.validatePollRetrievalParams=nr,exports.version=s; diff --git a/cjs/lib/__bundle-c127c886.cjs b/cjs/lib/__bundle-05f697db.cjs similarity index 65% rename from cjs/lib/__bundle-c127c886.cjs rename to cjs/lib/__bundle-05f697db.cjs index a08ea8f..e71801b 100644 --- a/cjs/lib/__bundle-c127c886.cjs +++ b/cjs/lib/__bundle-05f697db.cjs @@ -1 +1 @@ -var s=require("./__bundle-1a495950.cjs");class e extends s.User{constructor(s,e){var t;super(s,e),this.isMuted=!1,this.isMuted=null!==(t=e.is_muted)&&void 0!==t&&t}}exports.Participant=e; +var s=require("./__bundle-0486c467.cjs");class e extends s.User{constructor(s,e){var t;super(s,e),this.isMuted=!1,this.isMuted=null!==(t=e.is_muted)&&void 0!==t&&t}}exports.Participant=e; diff --git a/cjs/lib/__bundle-2ad218ff.cjs b/cjs/lib/__bundle-0f6b8ff3.cjs similarity index 97% rename from cjs/lib/__bundle-2ad218ff.cjs rename to cjs/lib/__bundle-0f6b8ff3.cjs index 24dd903..b4b61a3 100644 --- a/cjs/lib/__bundle-2ad218ff.cjs +++ b/cjs/lib/__bundle-0f6b8ff3.cjs @@ -1 +1 @@ -var e,s,t,n=require("./__bundle-1a495950.cjs"),r=require("./__bundle-165fd6e1.cjs");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,(s=exports.PublicGroupChannelListOrder||(exports.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",s.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",s.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.ScheduledMessageListOrder=void 0,(t=exports.ScheduledMessageListOrder||(exports.ScheduledMessageListOrder={})).CREATED_AT="created_at",t.SCHEDULED_AT="scheduled_at";class a extends n.BaseCommand{constructor({message:e}){super(),this.message=e}}const o={};var i;exports.UserEventCategory=void 0,(i=exports.UserEventCategory||(exports.UserEventCategory={}))[i.USER_BLOCK=20001]="USER_BLOCK",i[i.USER_UNBLOCK=2e4]="USER_UNBLOCK",i[i.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED";class d{constructor(e){this.category=e.cat,this.data=e.data}static getDataAsUserBlockEvent(e,s){const{blocker:t,blockee:r}=s.data;return{blocker:new n.User(e,t),blockee:new n.User(e,r)}}static getDataAsFriendDiscoveredEvent(e,s){const{friend_discoveries:t}=s.data;return{friendDiscoveries:Array.isArray(t)?t.map((s=>new n.User(e,s))):[]}}}class c extends n.BaseCommand{constructor(e,{userId:s}){super(),this._iid=e,this.userId=s}}class u extends n.BaseCommand{constructor(){super()}}class h extends n.WebSocketEventCommand{constructor(e,s,t){super(e,"USEV",t),this.event=new d(t)}}exports.AutoResendManager=class{constructor(e,{localCacheEnabled:s,enableAutoResend:t,dispatcher:r,sdkState:a,logger:i}){this._iid=e,o[e]=this,this._localCacheEnabled=s,this._enableAutoResend=t,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=i,this._sdkState=a,this._localCacheEnabled&&r.on((e=>{if(e instanceof n.ConnectionStateChangeCommand)switch(e.stateType){case n.ConnectionStateType.CONNECTED:this._isProcessingAutoResend||this.processAutoResendRegisteredPendingMessages().then((()=>this._processNextAutoResend()));break;case n.ConnectionStateType.INTERNAL_DISCONNECTED:case n.ConnectionStateType.EXTERNAL_DISCONNECTED:this._isProcessingAutoResend=!1}}))}static of(e){return o[e]}processNonAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){if(!this._enableAutoResend)return;const e=yield this._fetchAllCachedPendingMessages();for(const s of e)0===s.errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=n.SendingStatus.FAILED,s.errorCode=n.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}))}processAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const s of e)if(this._enableAutoResend&&s.errorCode&&n.isAutoResendableError(s.errorCode)){const e=(new Date).getTime(),t=s.createdAt+2592e5;this._enableAutoResend&&e<=t?this._autoResendQueue.map((e=>e.reqId)).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(t).toLocaleString()),s.sendingStatus=n.SendingStatus.FAILED,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}}))}completeCurrentAndProcessNextAutoResend(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===n.SendingStatus.SUCCEEDED||e.sendingStatus===n.SendingStatus.FAILED&&!n.isAutoResendableError(e.errorCode))){const s=this.indexOf(e);s>=0&&this._autoResendQueue.splice(s,1),0===s&&this._processNextAutoResend()}}_fetchAllCachedPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=r.UnsentMessageCache.of(this._iid),s=new r.MessageFilter;return s.replyType=n.ReplyType.ALL,yield e.fetch({sendingStatus:n.SendingStatus.PENDING,backward:!0,filter:s})}))}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 n.__awaiter(this,void 0,void 0,(function*(){if(this._localCacheEnabled&&this._enableAutoResend&&"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 a({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=a,exports.DatabaseOpenCommand=c,exports.ReduceDBSizeEventCommand=u,exports.UserEvent=d,exports.UserEventCommand=h,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"]}}; +var e,s,t,n=require("./__bundle-0486c467.cjs"),r=require("./__bundle-4bcf4070.cjs");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,(s=exports.PublicGroupChannelListOrder||(exports.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",s.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",s.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.ScheduledMessageListOrder=void 0,(t=exports.ScheduledMessageListOrder||(exports.ScheduledMessageListOrder={})).CREATED_AT="created_at",t.SCHEDULED_AT="scheduled_at";class a extends n.BaseCommand{constructor({message:e}){super(),this.message=e}}const o={};var i;exports.UserEventCategory=void 0,(i=exports.UserEventCategory||(exports.UserEventCategory={}))[i.USER_BLOCK=20001]="USER_BLOCK",i[i.USER_UNBLOCK=2e4]="USER_UNBLOCK",i[i.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED";class d{constructor(e){this.category=e.cat,this.data=e.data}static getDataAsUserBlockEvent(e,s){const{blocker:t,blockee:r}=s.data;return{blocker:new n.User(e,t),blockee:new n.User(e,r)}}static getDataAsFriendDiscoveredEvent(e,s){const{friend_discoveries:t}=s.data;return{friendDiscoveries:Array.isArray(t)?t.map((s=>new n.User(e,s))):[]}}}class c extends n.BaseCommand{constructor(e,{userId:s}){super(),this._iid=e,this.userId=s}}class u extends n.BaseCommand{constructor(){super()}}class h extends n.WebSocketEventCommand{constructor(e,s,t){super(e,"USEV",t),this.event=new d(t)}}exports.AutoResendManager=class{constructor(e,{localCacheEnabled:s,enableAutoResend:t,dispatcher:r,sdkState:a,logger:i}){this._iid=e,o[e]=this,this._localCacheEnabled=s,this._enableAutoResend=t,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=i,this._sdkState=a,this._localCacheEnabled&&r.on((e=>{if(e instanceof n.ConnectionStateChangeCommand)switch(e.stateType){case n.ConnectionStateType.CONNECTED:this._isProcessingAutoResend||this.processAutoResendRegisteredPendingMessages().then((()=>this._processNextAutoResend()));break;case n.ConnectionStateType.INTERNAL_DISCONNECTED:case n.ConnectionStateType.EXTERNAL_DISCONNECTED:this._isProcessingAutoResend=!1}}))}static of(e){return o[e]}processNonAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){if(!this._enableAutoResend)return;const e=yield this._fetchAllCachedPendingMessages();for(const s of e)0===s.errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=n.SendingStatus.FAILED,s.errorCode=n.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}))}processAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const s of e)if(this._enableAutoResend&&s.errorCode&&n.isAutoResendableError(s.errorCode)){const e=(new Date).getTime(),t=s.createdAt+2592e5;this._enableAutoResend&&e<=t?this._autoResendQueue.map((e=>e.reqId)).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(t).toLocaleString()),s.sendingStatus=n.SendingStatus.FAILED,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}}))}completeCurrentAndProcessNextAutoResend(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===n.SendingStatus.SUCCEEDED||e.sendingStatus===n.SendingStatus.FAILED&&!n.isAutoResendableError(e.errorCode))){const s=this.indexOf(e);s>=0&&this._autoResendQueue.splice(s,1),0===s&&this._processNextAutoResend()}}_fetchAllCachedPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=r.UnsentMessageCache.of(this._iid),s=new r.MessageFilter;return s.replyType=n.ReplyType.ALL,yield e.fetch({sendingStatus:n.SendingStatus.PENDING,backward:!0,filter:s})}))}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 n.__awaiter(this,void 0,void 0,(function*(){if(this._localCacheEnabled&&this._enableAutoResend&&"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 a({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=a,exports.DatabaseOpenCommand=c,exports.ReduceDBSizeEventCommand=u,exports.UserEvent=d,exports.UserEventCommand=h,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"]}}; diff --git a/cjs/lib/__bundle-0fbd5934.cjs b/cjs/lib/__bundle-0fbd5934.cjs new file mode 100644 index 0000000..5446c07 --- /dev/null +++ b/cjs/lib/__bundle-0fbd5934.cjs @@ -0,0 +1 @@ +var e,t,s,n,i,a,r,o,l,d=require("./__bundle-0486c467.cjs"),h=require("./__bundle-4bcf4070.cjs"),c=require("./__bundle-0f6b8ff3.cjs"),u=require("./__bundle-12c1cdf9.cjs"),_=require("./__bundle-d349e14c.cjs");exports.MemberState=void 0,(e=exports.MemberState||(exports.MemberState={})).NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left";class p 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 m 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.member=new d.User(this._iid,t.user),this.deliveryAt=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 g{constructor(e){var t,s,n,i,a,r,o,l,d,h,c,u,_,p,m;this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(t=null==e?void 0:e.includeEmpty)&&void 0!==t&&t,this.nicknameContainsFilter=null!==(s=null==e?void 0:e.nicknameContainsFilter)&&void 0!==s?s:null,this.nicknameStartsWithFilter=null!==(n=null==e?void 0:e.nicknameStartsWithFilter)&&void 0!==n?n:null,this.nicknameExactMatchFilter=null!==(i=null==e?void 0:e.nicknameExactMatchFilter)&&void 0!==i?i:null,this.channelNameContainsFilter=null!==(a=null==e?void 0:e.channelNameContainsFilter)&&void 0!==a?a:"",this.myMemberStateFilter=null!==(r=null==e?void 0:e.myMemberStateFilter)&&void 0!==r?r:exports.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(o=null==e?void 0:e.customTypesFilter)&&void 0!==o?o:null,this.channelUrlsFilter=null!==(l=null==e?void 0:e.channelUrlsFilter)&&void 0!==l?l:null,this.superChannelFilter=null!==(d=null==e?void 0:e.superChannelFilter)&&void 0!==d?d:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(h=null==e?void 0:e.publicChannelFilter)&&void 0!==h?h:exports.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(c=null==e?void 0:e.customTypeStartsWithFilter)&&void 0!==c?c:null,this.unreadChannelFilter=null!==(u=null==e?void 0:e.unreadChannelFilter)&&void 0!==u?u:exports.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==e?void 0:e.hiddenChannelFilter)&&void 0!==_?_:exports.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(p=null==e?void 0:e.includeFrozen)||void 0===p||p,(null==e?void 0:e.createdAfter)&&(this.createdAfter=e.createdAfter),(null==e?void 0:e.createdBefore)&&(this.createdBefore=e.createdBefore),this.includeMetaData=null===(m=null==e?void 0:e.includeMetaData)||void 0===m||m}_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 g;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("*")&&!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.ALL:if("none"===e.myMemberState)return!1;break;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!(this.createdAfter&&e.createdAtthis.createdBefore)}}class C 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 be.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 c.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!s&&t.name.localeCompare(e)<0||s&&t.name.localeCompare(e)>0)return!1;break;case c.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>e||s&&t.createdAte||s&&t.lastMessageUpdatedAtthis._deserialize(e)));return d.forEach((e=>{!n.includeMetaData&&e.cachedMetaData&&e._clearCachedMetaData(),this._channels.has(e.url)||this._channels.set(e.url,e)})),d}return[]}))}upsert(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];if(e.forEach((e=>{if(this._channels.has(e.url)){const n=this._channels.get(e.url);if(n._pinnedMessagesUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t){const{isUpdated:s}=n._updateCachedMetaData(e.cachedMetaData,t);s||Object.assign(e,{_cachedMetaData:void 0})}n._update(e),s.push(n)}else this._channels.set(e.url,e),s.push(e)})),this.localCacheEnabled){const e=[];for(let t=0;t0&&(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},v=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),f={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},M=e=>d.isArrayOf("string",e.customTypes,!0)&&d.isTypeOf("boolean",e.includeEmpty,!0)&&d.isTypeOf("boolean",e.includeFrozen,!0)&&d.isTypeOf("boolean",e.includeMetaData,!0)&&d.isTypeOf("boolean",e.includeChatNotification,!0),y={myMemberStateFilter:exports.MyMemberStateFilter.ALL},S=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 b={keys:[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,exports.UnreadItemKey.NONSUPER_INVITATION_COUNT,exports.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},N={channelCustomTypesFilter:void 0,superChannelFilter:exports.SuperChannelFilter.ALL},T=e=>d.isArrayOf("string",e.channelCustomTypesFilter,!0)&&d.isEnumOf(exports.SuperChannelFilter,e.superChannelFilter),U={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:d.MessageTypeFilter.ALL},I=Object.assign({},d.CollectionEventSource),x=e=>e.startsWith("EVENT_")||e===d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||e===d.CollectionEventSource.REFRESH_CHANNEL;class P extends d.BaseCommand{constructor({channels:e,context:t,isWebSocketEventComing:s=!1,ts:n}){super(),this.channels=e,this.context=t,this.isWebSocketEventComing=s,this.ts=n}}class R extends d.BaseCommand{constructor({channelUrls:e,context:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.context=t,this.isWebSocketEventComing=s}}class O{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 P){const{channels:s,context:i,isWebSocketEventComing:a}=n,r=s.filter((e=>e instanceof vt));if(i.source===d.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY||i.source===d.CollectionEventSource.EVENT_CHANNEL_HIDDEN)for(const e of r)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp);else{const s=e.filterOffsetChanged(r);for(const e of s)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp)}const o=yield e.upsert(r,n.ts);a||this._broadcastUpdateEvent(o,i)}else if(n instanceof R){const{channelUrls:i,context: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 c.DatabaseOpenCommand&&(yield e.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,t)}_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 w extends d.APIRequestCommand{constructor({userId:e,ts:t,token:s,filter:n,includeChatNotification:i=!1}){super();const{customTypes:a,includeEmpty:r,includeFrozen:o}=Object.assign(Object.assign({},f),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:a,show_empty:r,show_frozen:o,include_chat_notification:i}))}}class L extends d.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((s=>new vt(e,Object.assign(s,{ts:t.ts})))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next,this.ts=t.ts}}class F extends d.APIRequestCommand{constructor({channelUrl:e,isInternalCall:t,showLatestMessage:s}){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,show_latest_message:null!=s&&s}}}class D extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}const k={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0};class H 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:c,nicknameStartsWithFilter:u,nicknameExactMatchFilter:_,channelNameContainsFilter:p,channelUrlsFilter:m,customTypesFilter:g,customTypeStartsWithFilter:C,hiddenChannelFilter:E,metadataOrderKeyFilter:v,metadataKey:f,metadataValues:M,metadataValueStartsWith:y,includeFrozen:S,includeMetaData:A,searchFilter:b,userIdsFilter:N,includeChatNotification:T=!1,includeLeftChannel:U=!1,createdAfter:I,createdBefore:x}=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:k.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=a?a:k.includeEmpty,member_state_filter:null!=r?r:k.myMemberStateFilter,super_mode:null!=o?o:k.superChannelFilter,public_mode:null!=l?l:k.publicChannelFilter,unread_filter:null!=h?h:k.unreadChannelFilter,members_nickname_contains:c,members_nickname_startswith:u,members_nickname:_,name_contains:p,channel_urls:m,custom_types:g,custom_type_startswith:C,hidden_mode:E,metadata_order_key:v,metadata_key:f,metadata_values:M,metadata_value_startswith:y,show_frozen:S,show_metadata:A,include_chat_notification:T,include_left_channel:U,created_after:I,created_before:x}),b&&b.query&&b.fields&&(this.params.search_query=b.query,this.params.search_fields=b.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(this.params.members_include_in=N.userIds,this.params.query_type=N.queryType.toUpperCase()):this.params.members_exactly_in=N.userIds)}}class V 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 vt(e,t))))),this.ts=null!=i?i:0}}class G 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 q extends d.APIResponseCommand{constructor(e,t){super(e,t),this.groupChannelCount=t.group_channel_count}}class B extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{keys:s,customTypeFilters:n,customTypesFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_item_count`,this.params=d.deundefined({item_keys:s,custom_types:null!=i?i:n})}}class j 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 z extends d.APIRequestCommand{constructor({userId:e}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_channel_count`}}class W extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class $ extends d.APIRequestCommand{constructor({userId:e,filter:t,includeFeedChannel:s=!1}){super();const{channelCustomTypesFilter:n,superChannelFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_message_count`,this.params={super_mode:null!=i?i:exports.SuperChannelFilter.ALL,custom_types:n,include_feed_channel:s}}}class K extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count,this.unreadFeedCount=t.unread_feed_count}}class Q 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:J(t)},s&&(this.params.message_type=s)}}class Y extends d.APIResponseCommand{constructor(e,t){super(e,t),this.count=t.count}}const J=e=>{if(!e)return[];const t=[];return e.forEach((e=>{switch(e){case h.ScheduledStatus.PENDING:t.push(h.InternalScheduledStatus.PENDING);break;case h.ScheduledStatus.SENT:t.push(h.InternalScheduledStatus.IN_QUEUE),t.push(h.InternalScheduledStatus.SENT);break;case h.ScheduledStatus.CANCELED:t.push(h.InternalScheduledStatus.CANCELED);break;case h.ScheduledStatus.FAILED:t.push(h.InternalScheduledStatus.FAILED)}})),t};class X 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:c,isStrict:u,isEphemeral:_,accessCode:p,name:m,data:g,customType:C,messageSurvivalSeconds:E,invitedUserIds:v,operatorUserIds:f}=e;super(),this.method=d.APIRequestMethod.POST,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined({user_ids:[t,...null!=v?v:[]].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:c,strict:u,is_ephemeral:_,access_code:p,name:m,data:g,custom_type:C,operator_ids:f,message_survival_seconds:E})}}class Z extends d.APIResponseCommand{constructor(e,t){var s;super(e,t),this.channel=new vt(e,t),this.isCreated=null===(s=t.is_created)||void 0===s||s}}class ee 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 te 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 se extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class ne extends u.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 p(e,t))):[new p(e,s.data)]}}class ie 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 ae extends u.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 p(this._iid,s.data)}}class re 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 oe extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class le extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s),this.inviter=null;const{member_count:n=0,joined_member_count:i=0,inviter:a,invitees:r=[]}=s.data;this.memberCount=n,this.joinedMemberCount=i,a&&Object.keys(a).length>0&&(this.inviter=new d.User(e,a)),this.invitees=r.map((t=>new p(e,t)))}}class de 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 he extends u.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 p(e,r)}}const ce={hidePreviousMessages:!1,allowAutoUnhide:!0};class ue 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 _e extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}class pe 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 me extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPST",ackRequired:!1,payload:{channel_url:e,time:t}})}}class ge extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class Ce 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 ve extends d.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"MACK",ackRequired:!1,payload:{channel_url:e,msg_id:t}})}}class fe extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,u,_,p,m,g,C,E,v,f,M,y,S,A,b;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.includeChatNotification=!1,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=c.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.includeChatNotification=null!==(a=t.includeChatNotification)&&void 0!==a&&a,this.channelUrlsFilter=null!==(r=t.channelUrlsFilter)&&void 0!==r?r:null,this.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,this.customTypeStartsWithFilter=null!==(l=t.customTypeStartsWithFilter)&&void 0!==l?l:"",this.nicknameContainsFilter=null!==(d=t.nicknameContainsFilter)&&void 0!==d?d:null,this.nicknameStartsWithFilter=null!==(h=t.nicknameStartsWithFilter)&&void 0!==h?h:null,this.nicknameExactMatchFilter=null!==(u=t.nicknameExactMatchFilter)&&void 0!==u?u:null,this.channelNameContainsFilter=null!==(_=t.channelNameContainsFilter)&&void 0!==_?_:"",this.myMemberStateFilter=null!==(p=t.myMemberStateFilter)&&void 0!==p?p:exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=null!==(m=t.unreadChannelFilter)&&void 0!==m?m:exports.UnreadChannelFilter.ALL,this.superChannelFilter=null!==(g=t.superChannelFilter)&&void 0!==g?g:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(C=t.publicChannelFilter)&&void 0!==C?C:exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=null!==(E=t.hiddenChannelFilter)&&void 0!==E?E:exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter=null!==(v=t.searchFilter)&&void 0!==v?v:{fields:[],query:null},this.userIdsFilter=null!==(f=t.userIdsFilter)&&void 0!==f?f:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null!==(M=t.metadataKey)&&void 0!==M?M:null,this.metadataValues=null!==(y=t.metadataValues)&&void 0!==y?y:null,this.metadataOrderKeyFilter=null!==(S=t.metadataOrderKeyFilter)&&void 0!==S?S:null,this.metadataValueStartsWith=null!==(A=t.metadataValueStartsWith)&&void 0!==A?A:null,this.order=null!==(b=t.order)&&void 0!==b?b:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,t.createdAfter&&(this.createdAfter=t.createdAfter),t.createdBefore&&(this.createdBefore=t.createdBefore)}_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(c.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)&&d.isMilliSecondOf(this.createdAfter,!0)&&d.isMilliSecondOf(this.createdBefore,!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=be.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign({},this)),this.limit,d.CollectionEventSource.REQUEST_CHANNEL,!0);return this._token=s,this._hasNext=!!s,this._isLoading=!1,t}return[]}throw d.SendbirdError.invalidParameters}))}}class Me extends d.APIRequestCommand{constructor({channelUrl:e,userId:t}){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 ye extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"DLVR",s),this.channelUrl=s.channel_url,this.deliveredStateUpdate=s.updated}}class Se{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)}}const Ae={};class be extends u.BaseChannelManager{get _messageCache(){return h.MessageCache.of(this._iid)}get _unsentMessageCache(){return h.UnsentMessageCache.of(this._iid)}constructor(e,t){var s;super(e,Object.assign(Object.assign({},t),{channelType:d.ChannelType.GROUP})),this._leftChannels=new Map,this._disableMack=!1,this._markAsReadAllLastSentAt=0,this._disableMack=null!==(s=t.disableMack)&&void 0!==s&&s,this._groupChannelHandlers=new Map,this._groupChannelCache=new C(this._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),this._groupChannelBroadcast=new O({dispatcher:t.dispatcher,groupChannelCache:this._groupChannelCache,messageCache:h.MessageCache.of(this._iid),unsentMessageCache:h.UnsentMessageCache.of(this._iid)}),setInterval((()=>{for(const e of this._groupChannelCache.channels)e.invalidateTypingStatus()&&(this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.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).catch((e=>{if(d.isThrowingOutside(e)&&"foreground"===this._sdkState.appState)throw e})):e instanceof c.AutoResendRequestCommand?(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{message:t}=e,s=yield this.getChannel(t.channelUrl,!0);s.isFrozen||(t instanceof h.UserMessage?s._autoResendUserMessage(t):t instanceof h.FileMessage&&s._autoResendFileMessage(t))}))})():e instanceof c.ReduceDBSizeEventCommand?this.reduceDBSize():e instanceof h.MessageThreadInfoUpdatedEventCommand&&(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{channelUrl:t,channelType:s,parentMessage:n}=e,i=new h.ThreadInfoUpdateEvent(this._iid,{channel_type:d.ChannelType.GROUP,channel_url:t,parent_message_id:n.messageId,thread_info:h.ThreadInfo.payloadify(n.threadInfo)});if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onThreadInfoUpdated&&t.onThreadInfoUpdated(e,i)}))))}}))})()})),Ae[e]||(Ae[e]=this)}static of(e){return Ae[e]||(Ae[e]=new be(e,d.Vault.of(e))),Ae[e]}static clear(e){Ae[e]&&delete Ae[e]}get handlers(){return[...this._groupChannelHandlers.values()]}buildGroupChannelFromSerializedData(e){const t=d.deserialize(e);return new vt(this._iid,vt.payloadify(t))}buildGroupChannelListQueryFromSerializedData(e){const t=d.deserialize(e);return new fe(this._iid,t)}buildMemberFromSerializedData(e){const t=d.deserialize(e);return new p(this._iid,p.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 e=h.MessageCache.of(this._iid),{cacheContext:t}=d.Vault.of(this._iid),{localCacheConfig:s,nestdb:n}=t;if(!t.localCacheEnabled||!n||n.state!=h.NestDBState.OPENED)return;const i=1024*s.maxSize*1024;let a=yield n.estimateUsage();if(ad.__awaiter(this,void 0,void 0,(function*(){const t=new ve(e);this._requestQueue.send(t)}))));const s=this._groupChannelCache.isCachedInMemory(e.channelUrl),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId,r=yield this.getChannel(e.channelUrl,!0),{useMemberInfoInMessage:o}=d.Vault.of(this._iid);if(e instanceof h.SendableMessage){for(const t of r.members)if(t.userId===e.sender.userId){o||(e.sender.nickname=t.nickname,e.sender.plainProfileUrl=t.plainProfileUrl,e.sender.metaData=t.metaData,e.sender.isBlockedByMe=t.isBlockedByMe);break}if(!o&&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._updateLastMessage(e),a||r._shouldUpdateUnreadCountWith(e)&&r._updateUnreadCount(r.unreadMessageCount+1,r.unreadMentionCount+(n?1:0))),i&&r._updateLastMessage(e),this._dispatcher.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),e.silent&&!a||d.runAsCallback((()=>d.__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.CollectionEventSource.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(u.UpdateAdminMessageEventCommand)),t){const{message:e,mentionCountChange:n}=t;if(e.threadInfo&&(e.threadInfo.unreadReplyCount=void 0),e.channelType===d.ChannelType.GROUP){const t=this._groupChannelCache.isCachedInMemory(e.channelUrl),i=yield this.getChannel(e.channelUrl,!0),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId;let r=!1;if(a){const t=e.sender,{currentUser:s}=this._sessionManager;s&&(s.nickname=t.nickname,s.plainProfileUrl=t.plainProfileUrl,s.metaData=t.metaData)}else i.isReadMessage(e)||0!==n&&!e.silent&&t&&(i._updateUnreadCount(i.unreadMessageCount,i.unreadMentionCount+n),r=!0);i._updateLastMessage(e)?r=!0:(null===(s=i.lastMessage)||void 0===s?void 0:s.isIdentical(e))&&(t?i._updateLastMessage(e)&&(r=!0):r=!0);let o=!1;i.lastPinnedMessage&&i.lastPinnedMessage.messageId===e.messageId&&(i.lastPinnedMessage=e,r=!0,o=!0),r&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:o?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}})),e.silent&&!a||d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)})))),o&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)}))))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageUpdated&&t.onMessageUpdated(i,e),n>0&&t.onMentionReceived&&t.onMentionReceived(i,e)}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:n,silent:i,messageCreatedAt:a,senderId:r}=e.as(d.DeleteMessageEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=r===this._sdkState.userId;i||s||a>0&&e.myLastRead0&&e._updateUnreadCount(e.unreadMessageCount-1,0),this._dispatcher.dispatch(new d.MessageRemoveEventCommand({messageIds:[n],source:d.CollectionEventSource.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(h.ReadEventCommand);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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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(ye),n=this._groupChannelCache.isCachedInMemory(t),i=yield this.getChannel(t,!0);n&&Object.keys(s).forEach((e=>{i._updateUndeliveredMemberState(e,s[e])})),Object.keys(s).some((e=>e!==this._sdkState.userId))&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:d.CollectionEventSource.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(u.ReactionEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=yield this.getMessageFromCache(n.messageId);s?s instanceof h.BaseMessage&&(s.applyReactionEvent(n),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new d.ReactionUpdateEventCommand({event:n,source:d.CollectionEventSource.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(u.ThreadInfoUpdateEventCommand);if(t.channelType===d.ChannelType.GROUP){const e=yield this.getChannel(t.channelUrl,!0),s=yield this.getMessageFromCache(t.targetMessageId);s?s instanceof h.BaseMessage&&(s.applyThreadInfoUpdateEvent(t),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new d.ThreadUpdateEventCommand({event:t,source:d.CollectionEventSource.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(u.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 P({channels:s,context:{source:d.CollectionEventSource.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(u.PollUpdateEventCommand);if(n&&i===d.ChannelType.GROUP){const e=yield this.getChannel(n,!0);this._dispatcher.dispatch(new d.PollUpdateInternalEventCommand({event:t,source:d.CollectionEventSource.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.CollectionEventSource.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(u.ChannelEventCommand);if(t.isGroupChannelEvent)switch(t.category){case u.ChannelEventCategory.CHANNEL_JOIN:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,members:a}=e.as(ne);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:a}})),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 u.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(ae);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((e=>e.userId===r.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 P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})):(this._markAsLeave(n),this._dispatcher.dispatch(new R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})))):this._dispatcher.dispatch(new P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})),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 u.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const s=yield this.getChannel(t.channelUrl,!0),{operators:n}=e.as(u.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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitees:r}=e.as(le);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:a,invitees:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserReceivedInvitation&&e.onUserReceivedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitee:r}=e.as(he);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})):this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}}))):this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.TYPING_START:case u.ChannelEventCategory.TYPING_END:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.TYPING_START,{user:i}=e.as(n?ge:Ee);s._updateTypingStatus(i,n?t.ts:0),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.USER_CHANNEL_MUTE:case u.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.USER_CHANNEL_MUTE,{user:i}=e.as(n?h.MuteUserEventCommand:h.UnmuteUserEventCommand);i.userId===this._sdkState.userId&&(s.myMutedState=n?d.MutedState.MUTED:d.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 P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_MUTED:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i}})),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 u.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 R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_BANNED,user:i}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserBanned&&e.onUserBanned(n,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_UNBAN:{const s=yield this.getChannel(t.channelUrl,!0),{user:n}=e.as(h.UnbanUserEventCommand);n.userId===this._sdkState.userId&&this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserUnbanned&&e.onUserUnbanned(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_FREEZE:case u.ChannelEventCategory.CHANNEL_UNFREEZE:{const s=yield this.getChannel(t.channelUrl,!0),{freeze:n}=e.as(h.FreezeEventCommand);s.isFrozen=n,this._dispatcher.dispatch(new P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_FROZEN:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_HIDE:{const s=yield this.getChannel(t.channelUrl,!0),{allowAutoUnhide:n,hidePreviousMessages:i,messageOffsetTimestamp:a}=e.as(pe);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onChannelHidden&&e.onChannelHidden(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_UNHIDE:{const e=yield this.getChannel(t.channelUrl,!0);e.hiddenState=exports.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_DELETED:{const e=yield this.getChannel(t.channelUrl,!0);this._dispatcher.dispatch(new R({channelUrls:[t.channelUrl],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const e=yield this.getChannelWithoutCache(t.channelUrl,!0);this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.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),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:n},ts:t.ts}))),i&&(s._upsertCachedMetaData(i,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:i},ts:t.ts}))),a&&(s._removeFromCachedMetaData(a,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:a},ts: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 u.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaCounterEventCommand);n&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:n}})),i&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:i}})),a&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:a}})),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 u.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:n,latestPinnedMessage:i,ts:a}=e.as(u.UpdatePinnedMessageEventCommand);a>s._pinnedMessagesUpdatedAt&&(s.pinnedMessageIds=null!=n?n:[],s.lastPinnedMessage=i,s._pinnedMessagesUpdatedAt=a,this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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(c.UserEventCommand);switch(t.category){case c.UserEventCategory.USER_BLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.block(e.userId,s.userId);break}case c.UserEventCategory.USER_UNBLOCK:{const{blocker:e,blockee:s}=c.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()}subscribeChannelEvent(e,t){this._groupChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._groupChannelBroadcast.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 F({channelUrl:e,isInternalCall:t}),n=yield this._requestQueue.send(s),{channel:i}=n.as(D);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=d.CollectionEventSource.REFRESH_CHANNEL,n=!1){return d.__awaiter(this,void 0,void 0,(function*(){try{const i=new F({channelUrl:e,isInternalCall:t,showLatestMessage:n}),a=yield this._requestQueue.send(i),{channel:r}=a.as(D);if(r.myMemberState===exports.MemberState.NONE)this._dispatcher.dispatch(new R({channelUrls:[r.url],context:{source:s}}));else{const e=yield this.upsertChannelsToCache([r]);this._dispatcher.dispatch(new P({channels:e,context:{source:s}}))}}catch(t){t.code!==d.SendbirdErrorCode.NON_AUTHORIZED&&t.code!==d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new R({channelUrls:[e],context:{source:s}}))}}))}getMyGroupChannels(e,t,s,n=d.CollectionEventSource.REQUEST_CHANNEL,i=!1){return d.__awaiter(this,void 0,void 0,(function*(){t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3));let a=!1;if(i){const{appInfo:e,cacheContext:t}=d.Vault.of(this._iid);t&&!t.localCacheEnabled&&(null==e?void 0:e.enabledChannelMemberShipHistory)&&(null==e?void 0:e.applicationAttributes.includes("left_user_view_support"))&&(a=!0)}const r=new H(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:e,limit:s,includeLeftChannel:i&&a})),o=yield this._requestQueue.send(r),{channels:l,token:h}=o.as(V);return this._dispatcher.dispatch(new P({channels:l,context:{source:n}})),{channels:l,token:h}}))}getMyGroupChannelChangeLogs(e,t,s=d.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return d.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},f),t);d.unless((d.isTypeOf("string",e)||d.isTypeOf("number",e))&&M(n)).throw(d.SendbirdError.invalidParameters);const i=new w(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(L),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,ts:h}=a;return r.length>0&&this._dispatcher.dispatch(new P({channels:r,context:{source:s},ts:h})),o.length>0&&this._dispatcher.dispatch(new R({channelUrls:o,context:{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({},y),e);d.unless(S(t)).throw(d.SendbirdError.invalidParameters);const s=new G({userId:this._sdkState.userId,filter:t}),n=yield this._requestQueue.send(s),{groupChannelCount:i}=n.as(q);return i}))}getUnreadItemCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},b),e);d.unless((e=>d.isArrayOf(exports.UnreadItemKey,e.keys)&&d.isArrayOf("string",e.customTypeFilters,!0)&&d.isArrayOf("string",e.customTypesFilter,!0))(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),{groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m}=a.as(j);return d.deundefined({groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,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 z({userId:e.userId}),n=yield t.send(s),{unreadCount:i}=n.as(W);return i}))}getTotalUnreadMessageCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},N),e);d.unless(T(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new $({userId:s.userId,filter:t}),a=yield n.send(i),{unreadCount:r}=a.as(K);return r}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},U),e);d.unless((e=>d.isTypeOf("string",e.channelUrl,!0)&&d.isArrayOf(h.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 Q(t),i=yield s.send(n),{count:a}=i.as(Y);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);return Object.keys(t.customTypes).forEach((s=>{e+=t.customTypes[s]})),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(v(t)).throw(d.SendbirdError.invalidParameters),t.isPublic||(t.accessCode=void 0);const s=new X(Object.assign({userId:this._sdkState.userId},t)),n=yield this._requestQueue.send(s),{channel:i}=n.as(Z);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 ee({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 ee({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()}))}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){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})}))}getCachedMessageCountBetween(e,t,s,n){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.countBetween(e,t,new Se({top:s,bottom:n}))}))}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])}))}}const Ne=(e,t)=>t instanceof h.SendableMessage?e.findIndex((e=>e instanceof h.SendableMessage&&t.isIdentical(e))):e.findIndex((e=>e.isIdentical(t))),Te=(e,t)=>e.findIndex((e=>e instanceof h.BaseMessage?e.messageId===t:e instanceof h.NotificationMessage?e.notificationId===t:void 0)),Ue=(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};var Ie;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Ie||(Ie={}));class xe extends d.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=Ie.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===Ie.IDLE}get isRunning(){return this._state===Ie.RUNNING}get isDone(){return this._state===Ie.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 xe(_,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u,_;const p={hasNext:!0,nextToken:0};if(this._prevSyncLoopCount++,yield this.loadMetadata(),r.debug("message background prev sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.top),null===(n=this._metadata)||void 0===n?void 0:n.previousComplete)p.hasNext=!1;else try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(l=null===(a=this._metadata)||void 0===a?void 0:a.range)||void 0===l?void 0:l.top)?this._metadata.range.top:e,{prevResultSize:this._limit,nextResultSize:0,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(c=this._metadata)||void 0===c?void 0:c.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}p.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(p.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.lengthd.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u;const _={hasNext:!0,nextToken:0};yield this.loadMetadata(),r.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom);try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(a=null===(n=this._metadata)||void 0===n?void 0:n.range)||void 0===a?void 0:a.bottom)?this._metadata.range.bottom:e,{prevResultSize:0,nextResultSize:this._limit,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(l=this._metadata)||void 0===l?void 0:l.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}_.hasNext=s.length>=this._limit,this._metadata&&(_.nextToken=this._metadata.range.bottom),r.debug("message background next sync progress",_),yield this.saveMetadata()}catch(e){throw r.debug("message background next sync error",e),e}finally{o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:t.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(u=null===(c=i.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==u?u:0,use_local_cache:i.localCacheEnabled,starting_point:0,message_init_policy:""}}))}return _}))))})))),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){return Pe[e]||(Pe[e]={}),Pe[e][t.url]||(Pe[e][t.url]=new Re({_iid:e,channel:t})),Pe[e][t.url].ref++,Pe[e][t.url]}static clear(e,t){Pe[e]&&Pe[e][t]&&(Pe[e][t].close(),delete Pe[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 Se({})}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(){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?{range:new Se(t.range),previousComplete:t.previousComplete}:{range:new Se({}),previousComplete:!1}}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(e=Date.now()){var t,s,n,i;const{logger:a,sessionManager:r,cacheContext:o}=d.Vault.of(this._iid);o.localCacheEnabled&&r.session.hasSession&&(a.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(s=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==s?s:e),this._nextSync.start(null!==(i=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==i?i:e))}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid][this._channel.url])}}const Oe={};class we{constructor({_iid:e,channel:t,includeParams:s}){this.ref=0,this._iid=e,this._channel=t,this._includeParams=s;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}/message/changelogs.meta`);const l=((e,t)=>`sendbird:${e}@groupchannel/${t}/message/changelogs`)(i.userId,this._channel.url);this._sync=new xe(l,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};yield this.loadMetadata(),n.debug("message changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=h.MessageManager.of(this._iid),{updatedMessages:s,deletedMessageIds:i,hasMore:a,token:r}=yield e.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:d.ReplyType.ALL},this._includeParams),d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);t.hasNext=a,t.nextToken=r,(s.length>0||i.length>0)&&this._metadata&&(this._metadata.token=r),n.debug("message changelog sync progress",t),yield this.saveMetadata()}catch(e){throw n.debug("message 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 Oe[e]||(Oe[e]={}),Oe[e][t.url]||(Oe[e][t.url]=new we({_iid:e,channel:t,includeParams:s})),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])}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,sessionManager:t}=d.Vault.of(this._iid);t.session.hasSession&&(e.debug("message changelog sync resume()"),this._sync.start(0))}pause(){const{logger:e}=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 Oe[this._iid][this._channel.url])}}const Le={};class Fe{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 xe(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=d.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 Le[e]||(Le[e]={}),Le[e][t.url]||(Le[e][t.url]=new Fe({_iid:e,channel:t,hasPollMessage:s})),Le[e][t.url].ref++,Le[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 Le[this._iid][this._channel.url])}}class De extends d.APIRequestCommand{constructor(e){var t,s,n,i,a,r,o,l,h,c;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_reply_type:null!==(i=e.replyType)&&void 0!==i?i:d.ReplyType.NONE,include_reactions:null===(a=e.includeReactions)||void 0===a||a,include_meta_array:null===(r=e.includeMetaArray)||void 0===r||r,include_thread_info:null===(o=e.includeThreadInfo)||void 0===o||o,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(c=e.showSubchannelMessagesOnly)&&void 0!==c&&c,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=>h.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=>h.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 He={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};exports.MessageCollectionInitPolicy=void 0,(exports.MessageCollectionInitPolicy||(exports.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";class Ve{constructor(){this._onCacheResult=d.noop,this._onApiResult=d.noop}_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 Ge{keyOf(e){return 0}get changelogIncludeParams(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}_postprocessChannelUpdateEvent(e,t){}_postprocessChannelRemoveEvent(e){}_postprocessMessageUpdateEvent(e,t){}_postprocessMessageRemoveEvent(e){}constructor(e,{filter:t,startingPoint:s,limit:n,prevResultLimit:i,nextResultLimit:a,channel:r,channelManager:o,disableBackgroundSync:l=!1}){this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key=`mc-${d.uuid()}`,this._isDisposed=!1,this.filter=null!=t?t:new h.MessageFilter,this._channel=r,this._syncRange=new Se({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=n||h.DEFAULT_MESSAGE_LIMIT,this._prevResultLimit=null!=i?i:Math.floor(this._limit/2),this._nextResultLimit=null!=a?a:Math.floor(this._limit/2),this._channelManager=o;const{statManager:c}=d.Vault.of(this._iid);this._channelManager.subscribeChannelEvent(this._key,{onUpdate:(e,t)=>{const{source:s}=t,n=e.findIndex((e=>e.isIdentical(this.channel)));n>=0&&(this._replaceChannelOfCollection(e[n]),this.channel._runIfHandleableWithGroupChannel((e=>{switch(s){case d.CollectionEventSource.EVENT_CHANNEL_UPDATED:{let t=!1;for(let s=0;s=e.messageOffsetTimestamp){t=!0;const e=s;if(e>0){const t=this._messages.splice(0,e);this._removeMessagesFromView(t.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!t&&this._messages.length>0&&this._removeMessagesFromView(this._messages.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break}case d.CollectionEventSource.EVENT_CHANNEL_UNMUTED:{const{sdkState:e}=d.Vault.of(this._iid),{user:s}=t;e.userId===s.userId&&this._clearCheckMyMutedTimer();break}case d.CollectionEventSource.EVENT_CHANNEL_MUTED:{const{sdkState:s}=d.Vault.of(this._iid),{user:n}=t;s.userId===n.userId&&-1!==e._myMutedRemainingTime&&this._startCheckMyMutedTimer(e._myMutedRemainingTime);break}case d.CollectionEventSource.EVENT_CHANNEL_LEFT:e.isPublic&&this._clearCheckMyMutedTimer()}d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;x(s)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel)}))))})),this._postprocessChannelUpdateEvent(e[n],s))},onRemove:(e,t)=>{const s=e.indexOf(this.channel.url);s>=0&&(this._clearCheckMyMutedTimer(),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url)})))),this._postprocessChannelRemoveEvent(e[s]))}}),this._channelManager.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(this.keyOf(t)));if(d.shouldGiveEvent(t)){if(s.length>0)switch(t){case d.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case d.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case d.CollectionEventSource.EVENT_MESSAGE_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:this._updateMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:this._addMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_RECEIVED:this.hasNext||this._addMessagesToView(s,t);break;case d.CollectionEventSource.SYNC_MESSAGE_FILL:this._addMessagesToView(s,t)}n.length>0&&this._removeMessagesFromView(n,t)}this._postprocessMessageUpdateEvent(e,t)},onRemove:(e,t)=>{this._removeMessagesFromView(e,t),this._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:(e,t)=>{this._applyReactionEventToView(e,t)},onThreadInfoUpdate:(e,t)=>{this._applyThreadInfoEventToView(e,t)}});const{cacheContext:u,dispatcher:_,messageBackgroundSyncThrottleController:p}=d.Vault.of(this._iid);this._channel._updateMessageCollectionLastAccessedAt(),_.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Re.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=we.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Fe.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new xe(this._key,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.min(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:i.length>=this._prevResultLimit&&this.viewTopd.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.max(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:!(i.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>e,nextToken:this._syncRange.bottom}}return u.localCacheEnabled&&c.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(s=u.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==n?n:0,use_local_cache:u.localCacheEnabled,starting_point:0,message_init_policy:""}})),{hasNext:!1,nextToken:0}}))))})))),this._connectionEventContext=_.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)switch(e.stateType){case d.ConnectionStateType.CONNECTED:d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){this._activate()}))));break;case d.ConnectionStateType.LOGOUT:this.dispose();break;default:this._clearCheckMyMutedTimer(),this._prevFill.stop(),this._nextFill.stop()}}))}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)}_activate(){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:e}=d.Vault.of(this._iid);e.debug("check huge gap"),this._checkHugeGap(),yield this._refreshChannel(d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS)}))}_replaceChannelOfCollection(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}_shouldStartBackgroundSync(){const{cacheContext:e}=d.Vault.of(this._iid);return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}_setBaseMessageCollectionHandler(e){this._handler=e}_filterUnderOffsetMessage(e){return e}_updateChildMessagesInView(e){const t=[];return this._messages.forEach((s=>{s instanceof h.BaseMessage&&s.parentMessageId===e.messageId&&s.applyParentMessage(e)&&t.push(s)})),t}_updatePollsToView(e,t){const s=[];for(const t of e){const e=Te(this._messages,t.messageId);if(e>=0){const n=this._messages[e];n.isUserMessage()&&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,n;const i={source:t};s.length>0&&(null===(n=(e=this._handler).onMessagesUpdated)||void 0===n||n.call(e,i,this.channel,s))})))),s}_applyPollUpdateEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyPollVoteEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyReactionEventToView(e,t){const s=Te(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyReactionEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_applyThreadInfoEventToView(e,t){const s=Te(this._messages,e.targetMessageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyThreadInfoUpdateEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_removeMessagesFromView(e,t){const s=[],n=[];for(const t of e){const e=this._messages.findIndex((e=>this.keyOf(e)===t));if(e>=0){const t=this._messages[e];s.push(this.keyOf(t)),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,i;const a={source:t};null===(i=null===(e=this._handler)||void 0===e?void 0:e.onMessagesDeleted)||void 0===i||i.call(e,a,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*(){let i=[];n&&(i=yield this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter));const a=t>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,t,!1):[],r=s>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1):[];return{messages:[...i,...a,...r].sort(((e,t)=>t.createdAt-e.createdAt)),prevMessagesCount:a.length,nextMessagesCount:r.length}}))}_getRemoteMessages(e,{prevLimit:t=0,nextLimit:s=0,source:n=d.CollectionEventSource.REQUEST_MESSAGE,reverse:i=!1,checkingHasNext:a=!1,checkingContinuousMessages:r=!1}){return d.__awaiter(this,void 0,void 0,(function*(){const o=h.MessageManager.of(this._iid);return t>0||s>0?yield o._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,d.undefineNullProps(Object.assign(Object.assign(Object.assign({},this.filter),He),{isInclusive:!0,reverse:i,prevResultSize:t,nextResultSize:s})),n,a,r):{messages:[],isContinuousMessages:!1}}))}_checkHugeGap(){var e,t,s,n,i;return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r,cacheContext:o,statManager:l,logger:h}=d.Vault.of(this._iid);if(this._messages.length>0){const s=this._syncRange.top,n=this.viewTop,i=this._syncRange.bottom,c=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,n,s),_=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,i,c);try{yield d.asyncRetry((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t=new De(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:s,prevCount:u,nextStart:i,nextEnd:c,nextCount:_,checkingContinuousMessages:o.localCacheEnabled},this.filter),He)),l=yield r.send(t),{isHugeGap:h,prevMessages:p=[],prevHasMore:m,isContinuousPrevMessages:g,nextMessages:C=[],nextHasmore:E,isContinuousNextMessages:v}=l.as(ke);if(h)d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected()}))));else{const t=this.viewTop,s=this.viewBottom,n=Math.min(Number.MAX_SAFE_INTEGER,t,...p.map((e=>e.createdAt))),i=Math.max(0,s,...C.map((e=>e.createdAt)));a.dispatch(new d.MessageUpdateEventCommand({messages:p,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),a.dispatch(new d.MessageUpdateEventCommand({messages:C,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(n,i),(g||v)&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(n,i)),m&&this._prevFill.start(n),E&&this._nextFill.start(i)}}))),1)}catch(e){h.debug("Failed HugeGap Check ",e)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}else{const e=Date.now();try{const{messages:t,isContinuousMessages:n,hasNext:i}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:o.localCacheEnabled});if(t.length>0){const a=t.map((e=>e.createdAt));let r=0,o=0;for(let t=0;t=e&&o++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=i?i:o>=this._nextResultLimit,this._syncRange.extends(...a),n&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(t,d.CollectionEventSource.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)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(n=o.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==i?i:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}}))}_loadUnsentMessages(){return d.__awaiter(this,void 0,void 0,(function*(){this._unsentMessages=yield this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)}))}_hasPollMessage(){return d.__awaiter(this,void 0,void 0,(function*(){return(yield this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)).length>0}))}_refreshChannel(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:s}=d.Vault.of(this._iid);try{yield this._channelManager.refreshChannel(this.channel.url,!0,e,t)}catch(e){s.warn("Failed to refresh channel",e)}}))}_startCheckMyMutedTimer(e){this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((()=>d.__awaiter(this,void 0,void 0,(function*(){this._checkMyMutedStateTimer=void 0;let e=!0;try{e=!(yield this._channel.getMyMutedInfo()).isMuted}catch(t){e=!0}finally{if(e){const{sessionManager:e}=d.Vault.of(this._iid);this.channel._runIfHandleableWithGroupChannel((t=>{var s,n;t.myMutedState=d.MutedState.UNMUTED;const i={source:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:e.currentUser};null===(n=null===(s=this._handler)||void 0===s?void 0:s.onChannelUpdated)||void 0===n||n.call(s,i,this.channel)}))}}}))),e+1e3)}_clearCheckMyMutedTimer(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}_setHasNextAndHasPrevious(e,t){const s=e.map((e=>e.createdAt));let n=0,i=0;for(let e=0;ethis._startingPoint&&i++}this._hasPrevious=n>=this._prevResultLimit,this._hasNext=null!=t?t:i>=this._nextResultLimit}initialize(e){const t=new Ve;this._messages=[],this._unsentMessages=[],this._syncRange=new Se({}),this._hasNext=!0,this._hasPrevious=!0;let s=[],n={messages:[],prevMessagesCount:0,nextMessagesCount:0};return d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var i;const a=yield null===(i=this._backgroundSync)||void 0===i?void 0:i.loadMetadata(),{cacheContext:r,statManager:o}=d.Vault.of(this._iid);if(e===exports.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((e=>d.__awaiter(this,void 0,void 0,(function*(){n=e,s=this._filterUnderOffsetMessage(n.messages),this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE),yield this._loadUnsentMessages(),t._invokeResponse("local",null,s)})))).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("local",e,null)})).finally((()=>d.__awaiter(this,void 0,void 0,(function*(){var i,r;const{cacheContext:l}=d.Vault.of(this._iid);let h=!0,c=!0,u=!1;l.localCacheEnabled&&s.length>0&&a.range.includes(...s.map((e=>e.createdAt)))&&(!a.previousComplete&&n.prevMessagesCounta.range.bottom||n.nextMessagesCount{const t=Math.max(...s.map((e=>e.createdAt)));e._latestMessageInfo&&t>=e._latestMessageInfo.createdAt&&(c=!1)})),c?(h=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled}).then((({messages:e,isContinuousMessages:s,hasNext:n})=>{var i,a;const r=this._filterUnderOffsetMessage(e);this._messages=[],r.length>0?(this._setHasNextAndHasPrevious(r,n),this._syncRange.extends(...r.map((e=>e.createdAt))),s&&(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(r,d.CollectionEventSource.REQUEST_MESSAGE)):(this._hasPrevious=!1,this._hasNext=!1),t._invokeResponse("remote",null,r)})).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(s),t._invokeResponse("remote",null,s)),l.localCacheEnabled&&o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:h?"cache_hit":"cache_miss",max_db_size:null!==(r=null===(i=l.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==r?r:0,message_init_policy:e,use_local_cache:l.localCacheEnabled,collection_id:this._key}}))}))));o.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}}))})))),t}loadPrevious(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasPrevious)return[];if(this._isLoadingPrevious)return a.warn("Messages are already fetching."),[];this._isLoadingPrevious=!0;const r=this.viewTop;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{prevLimit:this._prevResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._prevResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasPrevious=o.length>=this._prevResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a;const{cacheContext:l}=d.Vault.of(this._iid),h=yield this._getRemoteMessages(r,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:l.localCacheEnabled});o=this._filterUnderOffsetMessage(h.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasPrevious=o.length>=this._prevResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(n=l.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==a?a:0,use_local_cache:l.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingPrevious=!1,o}))}loadNext(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasNext)return[];if(this._isLoadingNext)return a.warn("Messages are already fetching."),[];this._isLoadingNext=!0;const r=this.viewBottom;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{nextLimit:this._nextResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._nextResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasNext=o.length>=this._nextResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a,l;const{cacheContext:h}=d.Vault.of(this._iid),c=yield this._getRemoteMessages(r,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled});o=this._filterUnderOffsetMessage(c.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&c.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.bottom))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasNext=null!==(n=c.hasNext)&&void 0!==n?n:o.length>=this._nextResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(l=null===(a=h.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==l?l:0,use_local_cache:h.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingNext=!1,o}))}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."});yield this._channelManager.removeFailedMessageFromCache(e);const t=this._unsentMessages.findIndex((t=>t.reqId===e));t>-1&&this._unsentMessages.splice(t,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._runIfHandleableWithGroupChannel((e=>{e.myMemberState!==exports.MemberState.NONE&&(this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}class qe extends Ge{keyOf(e){return e.messageId}constructor(e,t){super(e,Object.assign(Object.assign({},t),{channelManager:be.of(e)}))}initialize(e){return 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)})))),super.initialize(e)}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_activate(){const e=Object.create(null,{_activate:{get:()=>super._activate}});return d.__awaiter(this,void 0,void 0,(function*(){yield e._activate.call(this),yield 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)}))))}))}_addMessagesToView(e,t){const s=this._filterUnderOffsetMessage(e),n=[],i=[];for(const e of s)if(t===d.CollectionEventSource.SYNC_MESSAGE_FILL){if(e.messageId>0){if(Ne(this._messages,e)<0){Ne(this._unsentMessages,e)<0&&n.push(e);const t=Ue(this._messages,e);this._messages.splice(t,0,e)}}else if(e instanceof h.SendableMessage){Ne(this._unsentMessages,e)<0&&Ne(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e))}}else if(e.messageId>0){const t=Ne(this._messages,e);if(t<0){const t=Ne(this._unsentMessages,e);t<0?n.push(e):(this._unsentMessages.splice(t,1),i.push(e));const s=Ue(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 h.SendableMessage){const t=Ne(this._unsentMessages,e);t<0?Ne(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,a,r;const o={source:t};n.length>0&&(null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===s||s.call(e,o,this.channel,n)),i.length>0&&(null===(r=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===r||r.call(a,o,this.channel,i))}))))}_updateMessagesToView(e,t){const s=[],n=[],i=[];for(const t of e)if(t.messageId>0){const e=Ne(this._messages,t);if(e>=0)n.push(t),this._messages[e]=t;else{const e=Ne(this._unsentMessages,t);if(e>=0){const[s]=this._unsentMessages.splice(e,1);if(this.hasNext&&s)i.push(s);else{n.push(t);const e=Ue(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 h.SendableMessage){const e=Ne(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,r,o;const l={source:t};n.length>0?null===(a=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===a||a.call(e,l,this.channel,n):i.length>0?null===(o=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===o||o.call(r,l,this.channel,[],i):s.length>0&&this._addMessagesToView(s,t)})))),n}}const Be={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 je 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 ze 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 p(e,t))))}}var We,$e,Ke;exports.MutedMemberFilter=void 0,(We=exports.MutedMemberFilter||(exports.MutedMemberFilter={})).ALL="all",We.MUTED="muted",We.UNMUTED="unmuted",exports.MemberListOrder=void 0,($e=exports.MemberListOrder||(exports.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",$e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",exports.MemberStateFilter=void 0,(Ke=exports.MemberStateFilter||(exports.MemberStateFilter={})).ALL="all",Ke.JOINED="joined_only",Ke.INVITED="invited_only",Ke.INVITED_BY_FRIEND="invited_by_friend",Ke.INVITED_BY_NON_FRIEND="invited_by_non_friend";class Qe 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 je(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{members:n,token:i}=s.as(ze);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class Ye 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 Je extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t),this.channel.myMemberState=exports.MemberState.JOINED}}class Xe 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:c,operatorUserIds:u,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:c,cover_url:a,cover_file:r,access_code:o,operator_ids:u,message_survival_seconds:_})}}class Ze extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class et 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 tt 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 st 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 nt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.countPreference=t.count_preference}}class it extends d.APIRequestCommand{constructor(e){const{channelUrl:t,locale:s}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/reset_user_history`,this.params=d.deundefined({locale:s})}}class at extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}const rt=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}),ot=Object.assign(Object.assign({},h.UserMessageUpdateParamsDefault),{scheduledAt:void 0});class lt extends d.APIRequestCommand{constructor(e){var t,s;super();let n=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((e=>e.userId))));const{channelType:i,channelUrl:a,scheduledMessageId:r}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(i)}/${encodeURIComponent(a)}/scheduled_messages/${encodeURIComponent(r)}`,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:null===(t=e._thumbnails)||void 0===t?void 0:t.map((e=>h.Thumbnail.payloadify(e))),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:n,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}))}}class dt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.message=new h.FileMessage(e,t)}}class ht 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=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class ct 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 ut 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 _t 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 pt 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({userId:e,channelUrl:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`}}class gt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}var Ct,Et;exports.CountPreference=void 0,(Ct=exports.CountPreference||(exports.CountPreference={})).ALL="all",Ct.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Ct.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Ct.OFF="off",exports.HiddenState=void 0,(Et=exports.HiddenState||(exports.HiddenState={})).UNHIDDEN="unhidden",Et.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Et.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";class vt extends h.BaseChannel{constructor(e,t){var s,n,i,a,r,o,l,c,u,_,m,g,C,E,v,f,M,y,S;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._hasBotInfo={general:!1,ai:!1},this.isDistinct=!1,this.isSuper=!1,this.isBroadcast=!1,this.isExclusive=!1,this.isPublic=!1,this.isDiscoverable=!0,this.isChatNotification=!1,this.isAccessCodeRequired=!1,this.isPushEnabled=!1,this.unreadMessageCount=0,this.unreadMentionCount=0,this.totalUnreadReplyCount=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=d.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.lastPinnedMessage=null,this._latestMessageInfo=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.isChatNotification=null!==(l=t.is_chat_notification)&&void 0!==l&&l,this.isAccessCodeRequired=null!==(c=t.is_access_code_required)&&void 0!==c&&c,this.isPushEnabled=null!==(u=t.is_push_enabled)&&void 0!==u&&u,Array.isArray(t.members)&&this.members.push(...t.members.map((e=>new p(this._iid,e)))),this.memberCount=null!==(_=t.member_count)&&void 0!==_?_:0,this.joinedMemberCount=null!==(m=t.joined_member_count)&&void 0!==m?m:0,this.hiddenState=d.isEnumOf(exports.HiddenState,t.hidden_state)?t.hidden_state:exports.HiddenState.UNHIDDEN,this.messageOffsetTimestamp=null!==(g=t.ts_message_offset)&&void 0!==g?g:0,this.messageSurvivalSeconds=null!==(C=t.message_survival_seconds)&&void 0!==C?C:-1,this.lastMessage=t.last_message?h.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(d.MutedState,t.is_muted)?this.myMutedState=t.is_muted:d.isTypeOf("boolean",t.is_muted)?this.myMutedState=t.is_muted?d.MutedState.MUTED:d.MutedState.UNMUTED:this.myMutedState=d.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!==(E=t.user_last_read)&&void 0!==E?E: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!==(f=t.joined_ts)&&void 0!==f?f:0,this._updateUnreadCount(null!==(M=t.unread_message_count)&&void 0!==M?M:0,null!==(y=t.unread_mention_count)&&void 0!==y?y:0),this.totalUnreadReplyCount=null!==(S=t.total_unread_thread_message_count)&&void 0!==S?S:0,this.lastPinnedMessage=t.latest_pinned_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.latest_pinned_message)):null,t.latest_message&&(this._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),this._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot}}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}get hasBot(){return this._hasBotInfo.general}get hasAiBot(){return this._hasBotInfo.ai}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,total_unread_thread_message_count:e.totalUnreadReplyCount,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=>p.payloadify(e))),last_message:e.lastMessage?h.payloadifyMessage(e.lastMessage):null,inviter:e.inviter?d.User.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?h.payloadifyMessage(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))}_shouldUpdateLastMessageWith(e){if(e.silent)return!1;const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.lastMessageThreadingPolicy){case d.LastMessageThreadingPolicy.NONE:case d.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case d.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt{t.onChannelChanged&&t.onChannelChanged(e)})),s.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}}))}_shouldUpdateUnreadCountWith(e){const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.unreadCountThreadingPolicy){case d.UnreadCountThreadingPolicy.NONE:case d.UnreadCountThreadingPolicy.INCLUDE_REPLY:break;case d.UnreadCountThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}_updateLastMessage(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}_updateUnreadCount(e,t){if("number"==typeof e&&e>=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,Object.assign(e,this._serializeCachedMetaData())}))}createMessageCollection(e={}){return new qe(this._iid,Object.assign(Object.assign({},e),{channel:this}))}createMemberListQuery(e={}){return new Qe(this._iid,this.url,e)}createThreadedParentMessageListQuery(e={}){return new _.ThreadedParentMessageListQuery(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 p?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 h.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 h.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 h.ReadStatus(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.payloadify(n),ts:null!=e?e:0})}})),s}getDeliveryStatus(e=!0){const{sdkState:t}=d.Vault.of(this._iid);if(!t.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;const s={};return this.members.forEach((n=>{if(e||n.userId!==t.userId){const e=this._undeliveredMemberStateMap.get(n.userId);s[n.userId]=new m(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.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*(){return this._refresh()}))}_refresh(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t,dispatcher:s}=d.Vault.of(this._iid),n=new F({channelUrl:this.url}),i=yield t.send(n),{channel:a}=i.as(D);return this._update(a),e||s.dispatch(new P({channels:[a],context:{source:d.CollectionEventSource.REFRESH_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 P({channels:[this],context:{source:d.CollectionEventSource.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 P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}))}))}updateChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},Be),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 Xe(Object.assign({channelUrl:this.url},t)),a=yield n.send(i),{channel:r}=a.as(Ze);return this._update(r),s.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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,sessionManager:n}=d.Vault.of(this._iid),i=new re({channelUrl:this.url,userIds:e}),a=yield s.send(i),{channel:r}=a.as(oe);return this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:n.currentUser,invitees:[]},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 te({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(se);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},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 ie({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 Ye({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(Je);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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 de({channelUrl:this.url,userId:e.userId});return yield t.send(s),this.myMemberState=exports.MemberState.NONE,this}))}sendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=>{n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendMultipleFilesMessage(e){const t=new h.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=be.of(this._iid);this._updateLastMessage(e),n.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 h.SendableMessage){const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new d.UnsentMessageRemoveEventCommand({reqId:e.reqId,source:d.CollectionEventSource.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 ue(Object.assign({channelUrl:this.url,userId:n.userId},t)),r=yield i.send(a),{messageOffsetTimestamp:o}=r.as(_e);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 P({channels:[this],context:{source:d.CollectionEventSource.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 tt({channelUrl:this.url});return yield t.send(s),this.hiddenState=exports.HiddenState.UNHIDDEN,e.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 et({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 h.ReadRequestCommand({channelUrl:this.url}),i=yield s.send(n),{readStatus:a}=i.as(h.ReadEventCommand);if(this._updateUnreadMemberState(e.userId,a.readAt),this.unreadMessageCount>0||this.unreadMentionCount>0){this._updateUnreadCount(0,0);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 Me({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 me({channelUrl:this.url,time:this._typingStarted});yield 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 Ce({channelUrl:this.url,time:this._typingStarted});yield e.send(t)}}))}createScheduledUserMessage(e){e=Object.assign(Object.assign({},h.ScheduledUserMessageCreateParamsDefault),e),d.unless(h.validateScheduledUserMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=new h.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({},ot),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 ht(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({},h.ScheduledFileMessageCreateParamsDefault),e),d.unless(h.validateScheduledFileMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=Date.now(),s=this._generateRequestId(),n=new h.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({},rt),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 lt(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(dt);return r}))}cancelScheduledMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new ct({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 ut({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 mt({userId:e.userId,channelUrl:this.url}),n=yield t.send(s),{pushTriggerOption:i}=n.as(gt);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 _t({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),a=yield n.send(i),{pushTriggerOption:r}=a.as(pt);return this.myPushTriggerOption=r,t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 st({channelUrl:this.url,userId:s.userId,countPreference:e}),a=yield n.send(i),{countPreference:r}=a.as(nt);return this.myCountPreference=r,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),r}))}resetMyHistory(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t,sdkState:s}=d.Vault.of(this._iid),n=new it({channelUrl:this.url,locale:s.localeForChatbot}),i=yield t.send(n),{messageOffsetTimestamp:a}=i.as(at);return this.messageOffsetTimestamp=a,this.lastMessage&&this.lastMessage.createdAt{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),n._trigger(e)})),n}if(e.isFileMessage()){const s=this._validateFailedFileMessageHasFile(e,t);d.unless(s).throw(d.SendbirdError.invalidParameters);const n=h.createFileMessageCreateParamsFromFailedFileMessage(e,t),i=new h.MessageRequestHandler;return this._sendFileMessage(n,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{i._trigger(e)})).onFailed(((e,t)=>{i._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),i._trigger(e)})),i}if(e.isMultipleFilesMessage()){const t=e.messageParams,s=new h.MultipleFilesMessageRequestHandler;return this._sendMultipleFilesMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{s._trigger(e)})).onFailed(((e,t)=>{s._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),s._trigger(e)})).onFileUploaded(((e,t,n,i)=>{s._triggerOnFileUploaded(e,t,n,i)})),s}}copyMessage(e,t){if(d.unless(e instanceof h.BaseChannel&&t instanceof h.SendableMessage&&t.sendingStatus===d.SendingStatus.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(d.SendbirdError.invalidParameters),t.isUserMessage()){d.unless(!t.poll).throw(d.SendbirdError.notSupportedError);const s=h.createUserMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendUserMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isFileMessage()){const s=h.createFileMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendFileMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isMultipleFilesMessage()){if(e.isGroupChannel()){const s=h.createMultipleFilesMessageCreateParams(t),n=new h.MultipleFilesMessageRequestHandler;return e._sendMultipleFilesMessage(s,h.SendMessageRequestType.COPY).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})).onFileUploaded(((e,t,s,i)=>{n._triggerOnFileUploaded(e,t,s,i)})),n}throw d.SendbirdError.channelTypeNotSupportedError}}}exports.BaseMessageCollection=Ge,exports.DeliveryStatus=m,exports.GetTotalUnreadMessageCountRequestCommand=$,exports.GetTotalUnreadMessageCountResponseCommand=K,exports.GroupChannel=vt,exports.GroupChannelChangeLogsParamsDefault=f,exports.GroupChannelCountParamsDefault=y,exports.GroupChannelCreateParamsDefault=E,exports.GroupChannelEventSource=I,exports.GroupChannelFilter=g,exports.GroupChannelListQuery=fe,exports.GroupChannelManager=be,exports.Member=p,exports.MemberListQuery=Qe,exports.MessageCollection=qe,exports.MessageCollectionInitHandler=Ve,exports.Sync=xe,exports.TimeRange=Se,exports.TotalUnreadMessageCountParamsDefault=N,exports.indexOfMessage=Ne,exports.placeOfMessage=Ue,exports.shouldGiveEvent=x,exports.validateGroupChannelChangeLogsParams=M,exports.validateGroupChannelCountParams=S,exports.validateGroupChannelCreateParams=v,exports.validateTotalUnreadMessageCountParams=T; diff --git a/cjs/lib/__bundle-d3673ecc.cjs b/cjs/lib/__bundle-12c1cdf9.cjs similarity index 93% rename from cjs/lib/__bundle-d3673ecc.cjs rename to cjs/lib/__bundle-12c1cdf9.cjs index 49708aa..a8ea61b 100644 --- a/cjs/lib/__bundle-d3673ecc.cjs +++ b/cjs/lib/__bundle-12c1cdf9.cjs @@ -1 +1 @@ -var e,t=require("./__bundle-1a495950.cjs"),s=require("./__bundle-165fd6e1.cjs"),n=require("./__bundle-dae7bdf2.cjs");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 a{constructor(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===t.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===t.ChannelType.OPEN}}class o extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.event=new a(s)}}class r extends t.WebSocketEventCommand{constructor(e,t,n){var a;super(e,"SYEV",n),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,n.data&&(this.pinnedMessageIds=null!==(a=n.data.pinned_message_ids)&&void 0!==a?a:[],this.latestPinnedMessage=n.data.latest_pinned_message?s.parseMessagePayload(e,Object.assign({},n.data.latest_pinned_message)):null),this.ts=n.ts}}class i extends t.InstancedObject{get _messageBroadcast(){return s.MessageBroadcast.of(this._iid)}constructor(e,t){super(e),this._logger=t.logger,this._sdkState=t.sdkState,this._sessionManager=t.sessionManager,this._requestQueue=t.requestQueue,this._dispatcher=t.dispatcher,this._cacheContext=t.cacheContext,this._channelType=t.channelType}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}getMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){return null}))}getExactlyMatchingMessagesForTokenFromCache(e,s,n){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getMessagesFromCache(e,s,n,a,o,r){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getPollMessagesFromCache(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getCachedMessageCountBetween(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return 0}))}getUnsentMessagesFromCache(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}removeFailedMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){}))}}class E extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E;super(e,"ADMM",a),this.message=new s.AdminMessage(e,a);const{sdkState:d}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(i=null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(r=this.message.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)))&&void 0!==i?i:[],d.userId),this.forceUpdateLastMessage=null!==(E=a.force_update_last_message)&&void 0!==E&&E}}class d extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E,d;super(e,"AEDI",a),this.message=new s.AdminMessage(e,a);const{sdkState:_}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(o=a.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(i=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==i?i:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(E=this.message.mentionedUserIds)&&void 0!==E?E:null===(d=this.message.mentionedUsers)||void 0===d?void 0:d.map((e=>e.userId))}),_.userId)}}class _ extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MRCT",n),this.channelUrl=n.channel_url,this.channelType=n.channel_type,this.event=new s.ReactionEvent(n)}}class N extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MTHD",n),this.event=new s.ThreadInfoUpdateEvent(e,n)}}class l extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MCNT",s),this.groupChannelMemberCounts=s.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=s.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class c extends t.WebSocketEventCommand{constructor(e,s,a){super(e,"PEDI",a),this.event=new n.PollUpdateEvent(e,a),this.status=t.parsePollStatusPayload(a.poll.status)||a.poll.status,this.channelUrl=a.channel_url,this.channelType=a.channel_type}}exports.AdminMessageEventCommand=E,exports.BaseChannelManager=i,exports.ChannelEventCommand=o,exports.MemberCountUpdateEventCommand=l,exports.OperatorUpdateEventCommand=class extends o{constructor(e,s,n){super(e,s,n);const{operators:a=[]}=n.data;this.operators=a.map((e=>new t.User(this._iid,e)))}},exports.PollUpdateEventCommand=c,exports.ReactionEventCommand=_,exports.ThreadInfoUpdateEventCommand=N,exports.UpdateAdminMessageEventCommand=d,exports.UpdatePinnedMessageEventCommand=r; +var e,t=require("./__bundle-0486c467.cjs"),s=require("./__bundle-4bcf4070.cjs"),n=require("./__bundle-dae7bdf2.cjs");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 a{constructor(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===t.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===t.ChannelType.OPEN}}class o extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.event=new a(s)}}class r extends t.WebSocketEventCommand{constructor(e,t,n){var a;super(e,"SYEV",n),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,n.data&&(this.pinnedMessageIds=null!==(a=n.data.pinned_message_ids)&&void 0!==a?a:[],this.latestPinnedMessage=n.data.latest_pinned_message?s.parseMessagePayload(e,Object.assign({},n.data.latest_pinned_message)):null),this.ts=n.ts}}class i extends t.InstancedObject{get _messageBroadcast(){return s.MessageBroadcast.of(this._iid)}constructor(e,t){super(e),this._logger=t.logger,this._sdkState=t.sdkState,this._sessionManager=t.sessionManager,this._requestQueue=t.requestQueue,this._dispatcher=t.dispatcher,this._cacheContext=t.cacheContext,this._channelType=t.channelType}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}getMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){return null}))}getExactlyMatchingMessagesForTokenFromCache(e,s,n){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getMessagesFromCache(e,s,n,a,o,r){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getPollMessagesFromCache(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getCachedMessageCountBetween(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return 0}))}getUnsentMessagesFromCache(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}removeFailedMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){}))}}class E extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E;super(e,"ADMM",a),this.message=new s.AdminMessage(e,a);const{sdkState:d}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(i=null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(r=this.message.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)))&&void 0!==i?i:[],d.userId),this.forceUpdateLastMessage=null!==(E=a.force_update_last_message)&&void 0!==E&&E}}class d extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E,d;super(e,"AEDI",a),this.message=new s.AdminMessage(e,a);const{sdkState:_}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(o=a.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(i=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==i?i:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(E=this.message.mentionedUserIds)&&void 0!==E?E:null===(d=this.message.mentionedUsers)||void 0===d?void 0:d.map((e=>e.userId))}),_.userId)}}class _ extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MRCT",n),this.channelUrl=n.channel_url,this.channelType=n.channel_type,this.event=new s.ReactionEvent(n)}}class N extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MTHD",n),this.event=new s.ThreadInfoUpdateEvent(e,n)}}class c extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MCNT",s),this.groupChannelMemberCounts=s.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=s.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class l extends t.WebSocketEventCommand{constructor(e,s,a){super(e,"PEDI",a),this.event=new n.PollUpdateEvent(e,a),this.status=t.parsePollStatusPayload(a.poll.status)||a.poll.status,this.channelUrl=a.channel_url,this.channelType=a.channel_type}}exports.AdminMessageEventCommand=E,exports.BaseChannelManager=i,exports.ChannelEventCommand=o,exports.MemberCountUpdateEventCommand=c,exports.OperatorUpdateEventCommand=class extends o{constructor(e,s,n){super(e,s,n);const{operators:a=[]}=n.data;this.operators=a.map((e=>new t.User(this._iid,e)))}},exports.PollUpdateEventCommand=l,exports.ReactionEventCommand=_,exports.ThreadInfoUpdateEventCommand=N,exports.UpdateAdminMessageEventCommand=d,exports.UpdatePinnedMessageEventCommand=r; diff --git a/cjs/lib/__bundle-165fd6e1.cjs b/cjs/lib/__bundle-165fd6e1.cjs deleted file mode 100644 index 722b90e..0000000 --- a/cjs/lib/__bundle-165fd6e1.cjs +++ /dev/null @@ -1 +0,0 @@ -var e,t=require("./__bundle-1a495950.cjs");class s{constructor(e,t,s){var i,n;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(i=t.real_width)&&void 0!==i?i:t.width,this.realHeight=null!==(n=t.real_height)&&void 0!==n?n:t.height,this._requireAuth=s}static payloadify(e){return e instanceof s?t.deundefined(t.undefineNullProps({url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight})):t.deundefined(t.undefineNullProps({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class i extends t.APIRequestCommand{constructor(e){if(super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_UPLOAD}`,this.params=t.deundefined({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(let t=0;tnew s(e,t,!1))))&&void 0!==a?a:[],this.requireAuth=null!==(r=t.require_auth)&&void 0!==r&&r}}class a extends t.InstancedObject{constructor(e,s){var i,n,a,r,o;super(e),this.replyCount=0,this.memberCount=0,this.lastRepliedAt=0,this.updatedAt=0,this.replyCount=null!==(i=s.reply_count)&&void 0!==i?i:0,this.memberCount=null!==(n=s.member_count)&&void 0!==n?n:0,this.mostRepliedUsers=s.most_replies&&t.isArrayOf("object",s.most_replies)?s.most_replies.map((e=>new t.User(this._iid,e))):[],this.unreadReplyCount=null!==(a=s.unread_message_count)&&void 0!==a?a:0,this.isPushNotificationEnabled="number"==typeof s.push_enabled?s.push_enabled>0:void 0,this.lastRepliedAt=null!==(r=s.last_replied_at)&&void 0!==r?r:0,this.updatedAt=null!==(o=s.updated_at)&&void 0!==o?o:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((e=>t.User.payloadify(e))):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}get _isUpdateRequired(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}_updateFrom(e){var t,s;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(s=e.isPushNotificationEnabled)&&void 0!==s?s:this.isPushNotificationEnabled}}exports.ReactionEventOperation=void 0,(e=exports.ReactionEventOperation||(exports.ReactionEventOperation={})).ADD="add",e.DELETE="delete";class r{constructor(e){this.messageId=0,this.operation=null,this.updatedAt=0;const s=t.isTypeOf("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,n=e.operation?e.operation.toLowerCase():null,a=e.reaction,r=e.updated_at;s&&t.isTypeOf("string",i)&&t.isTypeOf("string",n)&&t.isEnumOf(exports.ReactionEventOperation,n)&&t.isTypeOf("string",a)&&a&&t.isTypeOf("number",r)&&(this.messageId=s,this.userId=i,this.key=a,this.operation=n,this.updatedAt=r)}}class o{constructor(e){var s;const i=e.key,n=null!==(s=[...e.user_ids])&&void 0!==s?s:[],a=e.updated_at;t.isTypeOf("string",i)&&i&&t.isArrayOf("string",n)&&n.length>0&&t.isTypeOf("number",a)&&(this.key=i,this.userIds=n,this.updatedAt=a);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 t.deundefined(t.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 t=this.userIds.indexOf(e.userId);switch(e.operation){case exports.ReactionEventOperation.ADD:t<0&&this.userIds.push(e.userId);break;case exports.ReactionEventOperation.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}}}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 s,i;return t.deundefined(t.undefineNullProps({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(s=e.width)&&void 0!==s?s: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 t.deundefined(t.undefineNullProps({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?l.payloadify(e.defaultImage):null}))}}class u{constructor(e){var t,s;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(s=e.volume)&&void 0!==s?s:1}serialize(){return{name:this.name,volume:this.volume}}static payloadify(e){return t.deundefined(t.undefineNullProps({name:e.name,volume:e.volume}))}}var c;exports.FeedbackRating=void 0,(c=exports.FeedbackRating||(exports.FeedbackRating={})).GOOD="good",c.BAD="bad";class h{constructor(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}static _getStatus(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}static _isSubmitted(e){return"SUBMITTED"===h._getStatus(e)}static _getPayloadByStatus(e){return"NO_FEEDBACK"===e?{}:null}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,rating:e.rating,comment:e.comment}))}}class p extends t.User{constructor(e,s){var i;super(e,s),this.isBlockedByMe=!1,this.role=t.isEnumOf(t.Role,s.role)?s.role:t.Role.NONE,this.isBlockedByMe=null!==(i=s.is_blocked_by_me)&&void 0!==i&&i}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}class m{constructor(e){this.key=e.key,this.value=t.isArrayOf("string",e.value)?[...e.value]:[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:e.key,value:null!==(s=e.value)&&void 0!==s?s:[]}))}}const _=e=>{switch(e){case t.MessageType.BASE:return"";case t.MessageType.USER:return"MESG";case t.MessageType.FILE:return"FILE";case t.MessageType.ADMIN:return"ADMM"}};class g extends t.InstancedObject{constructor(e,s){var i,n,a,r,o,l,d,u,c;super(e),this.channelType=t.ChannelType.BASE,this.messageType=t.MessageType.BASE,this.mentionType=null,this.mentionedUsers=null,this.mentionedUserIds=null,this.mentionedMessageTemplate=void 0,this.metaArrays=[],this.extendedMessage={},this.createdAt=0,this.updatedAt=0,this.channelUrl=s.channel_url,this.channelType=t.isEnumOf(t.ChannelType,s.channel_type)?s.channel_type:t.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(this.channelUrl=s.channel.channel_url),s.channel.channel_type&&(this.channelType=s.channel.channel_type)),this.data=null!==(i=s.data)&&void 0!==i?i:"",this.customType=null!==(n=s.custom_type)&&void 0!==n?n:"",this.mentionType=t.isEnumOf(t.MentionType,s.mention_type)?s.mention_type:null,this.mentionedUsers=s.mentioned_users?s.mentioned_users.map((e=>new t.User(this._iid,e))):null,this.mentionedUserIds=null!==(a=s.mentioned_user_ids)&&void 0!==a?a:null,this.mentionedUsers&&!this.mentionedUserIds&&(this.mentionedUserIds=this.mentionedUsers.map((e=>e.userId))),this.mentionedMessageTemplate=s.mentioned_message_template;const h=null!==(r=s.metaarray)&&void 0!==r?r:{},p=null!==(o=s.metaarray_key_order)&&void 0!==o?o:Object.keys(h).sort(((e,t)=>e.localeCompare(t)));this.metaArrays=[];for(let e=0;enew m(e)))),this.extendedMessage=null!==(l=s.extended_message)&&void 0!==l?l:{},this.extendedMessagePayload=s.extended_message_payload,this.createdAt=null!==(u=null!==(d=s.created_at)&&void 0!==d?d:s.ts)&&void 0!==u?u:0,this.updatedAt=null!==(c=s.updated_at)&&void 0!==c?c:0}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.channelUrl,channel_type:e.channelType,type:_(e.messageType),data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(s=e.mentionedUsers)||void 0===s?void 0:s.map((e=>t.User.payloadify(e))),mentioned_message_template:e.mentionedMessageTemplate,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>m.payloadify(e))),extended_message:e.extendedMessage,extended_message_payload:e.extendedMessagePayload,created_at:e.createdAt,updated_at:e.updatedAt})))}isIdentical(e){return!0}isEqual(e){return t.deepEqual(this,e)}isUserMessage(){return this.messageType===t.MessageType.USER}isFileMessage(){return this.messageType===t.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isMultipleFilesMessage(){return this.messageType===t.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isAdminMessage(){return this.messageType===t.MessageType.ADMIN}serialize(){return t.serialize(this)}getMetaArraysByKeys(e){return this.metaArrays.filter((t=>e.includes(t.key)))}}class y extends t.InstancedObject{constructor(e,s){var i,n;super(e),this.channelUrl=null!==(i=s.channel_url)&&void 0!==i?i:"",this.channelType=null!==(n=s.channel_type)&&void 0!==n?n:t.ChannelType.GROUP,this.reader=new t.User(this._iid,s.user),this.readAt=s.ts}}class f extends t.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class v extends t.APIRequestCommand{constructor(e){super();const{channelUrl:s,channelType:i,userId:n,notificationIds:a}=e;this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/messages/mark_as_read`,this.params=t.deundefined(t.undefineNullProps({user_id:n,message_ids:a}))}}class I extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new y(e,s)}}class E extends t.APIResponseCommand{constructor(e,t){super(e,t),this.readAt=t.ts,this.unreadMessageCount=t.unread_message_count}}class T extends t.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"READ",ackRequired:!0,payload:{channel_url:e,parent_message_id:t}})}}class b extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,pushEnabled:n}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/thread_push`,this.params={push_enabled:n}}}class M extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,rating:n,comment:a}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks`,this.params={rating:n,comment:a}}}class S extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class O extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n,rating:a,comment:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`,this.params={rating:a,comment:r}}}class A extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class C extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`}}class w extends t.InstancedObject{constructor(e,t){var i,n,a,r,o;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!==(n=t.file_name)&&void 0!==n?n:null,this.mimeType=null!==(a=t.file_type)&&void 0!==a?a:null,this.fileSize=null!==(r=t.file_size)&&void 0!==r?r:0,this._requireAuth=null!==(o=t.require_auth)&&void 0!==o&&o,this.thumbnails=t.thumbnails?t.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this._requireAuth)})):[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>{var t;return{url:(null!==(t=e.plainUrl)&&void 0!==t?t:"").split("auth=")[0],width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class N{constructor({channelUrl:e,channelType:t,parentMessage:s}){this.channelUrl=e,this.channelType=t,this.parentMessage=s}}var P,U,R,x;!function(e){e.NUMBER="number",e.ENUM="enum",e.TEXT="text",e.REGEX="regex",e.DECIMAL_PLACE="decimal_place"}(P||(P={})),exports.MessageFormItemLayout=void 0,(U=exports.MessageFormItemLayout||(exports.MessageFormItemLayout={})).TEXT="text",U.TEXTAREA="textarea",U.NUMBER="number",U.PHONE="phone",U.EMAIL="email",U.CHIP="chip";class k{constructor(e,t){const{id:s,name:i,items:n,version:a,is_submitted:r}=t;this.messageId=e,this.id=s,this.name=i,this.items=n.map((e=>new L(e))).sort(((e,t)=>e.sortOrder-t.sortOrder)),this.version=null!=a?a:1,this._isSubmitted=r}get isSubmitted(){var e;return null!==(e=this._isSubmitted)&&void 0!==e?e:this.items.some((e=>Array.isArray(e.submittedValues)))}get isSubmittable(){return this.items.every((e=>e.required?!!(Array.isArray(e.draftValues)&&e.draftValues.length>0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,items:e.items.map((e=>L.payloadify(e))),version:e.version,is_submitted:e._isSubmitted}))}static isMessageFormPayload(e){return Boolean(null==e?void 0:e.message_form)}}class L{constructor(e){const{id:s,name:i,required:n,sort_order:a,placeholder:r,style:o,item_type:l,validators:d,value:u,values:c}=e;this.id=s,this.name=i,this.required=n,this.sortOrder=a,this.placeholder=r,0===Object.keys(o).length?this.style={layout:l}:this.style=t.deundefined({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),c?this.submittedValues=c:u&&(this.submittedValues=[u]),this._validators=d}isValid(e){return e.every((e=>{const t=function(e,t){return t.every((t=>{switch(t.key){case P.NUMBER:{const s=Number(e);return!(isNaN(s)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&st.max)}case P.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case P.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case P.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case P.DECIMAL_PLACE:{if(0===e.length)return!1;const s=Number(e);return!(isNaN(s)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){const s=e.toString(),i=s.indexOf(".");return-1===i||s.slice(i+1).length<=t}(s,t.max_decimal_place))}default:return!0}}))}(e,this._validators);return t}))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:t.deundefined({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}class D extends t.APIRequestCommand{constructor(e){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_FORMS}/${e.formId}/submit`,this.params=t.deundefined({message_id:e.messageId,items:e.items})}}exports.ScheduledStatus=void 0,(R=exports.ScheduledStatus||(exports.ScheduledStatus={})).PENDING="pending",R.SENT="sent",R.FAILED="failed",R.CANCELED="canceled",exports.InternalScheduledStatus=void 0,(x=exports.InternalScheduledStatus||(exports.InternalScheduledStatus={})).PENDING="pending",x.IN_QUEUE="in_queue",x.SENT="sent",x.FAILED="failed",x.CANCELED="canceled",x.REMOVED="removed";class q extends g{constructor(e,t){var s,i,n,r,l,c,p,m;super(e,t),this.parentMessage=null,this.silent=!1,this.isOperatorMessage=!1,this.threadInfo=null,this.reactions=[],this.appleCriticalAlertOptions=null,this.scheduledInfo=null,this.suggestedReplies=null,this.myFeedback=null,this.myFeedbackStatus="NOT_APPLICABLE",this.messageForm=null,this._isContinuousMessages=!1,this._scheduledStatus=null,this.messageId=null!==(i=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==i?i:0,this.parentMessageId=null!==(n="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==n?n:0,this.threadInfo=t.thread_info?new a(this._iid,t.thread_info):null,this.reactions=t.reactions?t.reactions.map((e=>new o(e))):[],this.ogMetaData=t.og_tag?new d(t.og_tag):null,this.silent=null!==(r=t.silent)&&void 0!==r&&r,this.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,this.appleCriticalAlertOptions=t.apple_critical_alert_options?new u(t.apple_critical_alert_options):null,"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._isContinuousMessages=null!==(c=t.is_continuous_messages)&&void 0!==c&&c,this.myFeedback=h._isSubmitted(t.feedback)?new h(t.feedback):null,this.myFeedbackStatus=h._getStatus(t.feedback),this.suggestedReplies=null!==(m=null===(p=t.extended_message_payload)||void 0===p?void 0:p.suggested_replies)&&void 0!==m?m:null,this.messageForm=k.isMessageFormPayload(t.extended_message_payload)?new k(this.messageId,t.extended_message_payload.message_form):null}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?a.payloadify(e.threadInfo):null,reactions:e.reactions.map((e=>o.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?u.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledMessageId,scheduled_at:null===(i=e.scheduledInfo)||void 0===i?void 0:i.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?h.payloadify(e.myFeedback):h._getPayloadByStatus(e.myFeedbackStatus)})))}static _getParentMessageInfoPayload(e){return t.deundefined(t.undefineNullProps({type:_(e.messageType),ts:e.createdAt,user:e.sender?p.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null}))}isIdentical(e){return this.messageId===e.messageId}applyThreadInfoUpdateEvent(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}applyReactionEvent(e){if(this.messageId===e.messageId){let t=!1;for(let s=0;s=t)return this.parentMessage=e,!0}return!1}_triggerThreadInfoUpdatedEvent(){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e}=t.Vault.of(this._iid);e.dispatch(new N({channelType:t.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))}))}markThreadAsRead(){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=t.Vault.of(this._iid),s=new T({channelUrl:this.channelUrl,messageId:this.messageId});yield e.send(s),this.threadInfo&&0!==this.threadInfo.unreadReplyCount&&(this.threadInfo.unreadReplyCount=0,yield this._triggerThreadInfoUpdatedEvent())}))}setPushNotificationEnabled(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),i=new b({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e});yield s.send(i),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e)}))}submitMessageForm(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid);let i=null,n=null;const a=this.messageForm;if(!e&&a){if(!a.isSubmittable)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(a.isSubmitted)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});i=a.id,n=a.items.reduce(((e,t)=>(e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e)),[])}else e&&(i=e.formId,n=Object.entries(e.answers).reduce(((e,[s,i])=>{const n=Number(s);if(Number.isNaN(n))throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:n,value:i}),e}),[]));if(!i||!n)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});const r=new D({messageId:this.messageId,formId:i,items:n});yield s.send(r)}))}submitFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new M({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(S);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}))}))}updateFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new O({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(A);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}))}))}deleteFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new C({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e});yield s.send(n),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}))}))}}class F extends q{constructor(e,s){var i,n,a,r;if(super(e,s),this.reqId="",this.replyToChannel=!1,this.errorCode=0,this.sender=s.user?new p(this._iid,s.user):s.sender_id,this.reqId=null!==(n=null!==(i=s.req_id)&&void 0!==i?i:s.request_id)&&void 0!==n?n:"",this.replyToChannel=null!==(a=s.is_reply_to_channel)&&void 0!==a&&a,s.request_state&&t.isEnumOf(t.SendingStatus,s.request_state)&&(this.sendingStatus=s.request_state),!this.sendingStatus)if(this.messageId>0)this.sendingStatus=t.SendingStatus.SUCCEEDED;else if(this.scheduledInfo)switch(s.scheduled_status&&(this._scheduledStatus=s.scheduled_status),s.scheduled_status){case exports.InternalScheduledStatus.SENT:case exports.InternalScheduledStatus.IN_QUEUE:this.sendingStatus=t.SendingStatus.SUCCEEDED;break;case exports.InternalScheduledStatus.PENDING:this.sendingStatus=t.SendingStatus.SCHEDULED;break;case exports.InternalScheduledStatus.FAILED:case exports.InternalScheduledStatus.REMOVED:this.sendingStatus=t.SendingStatus.FAILED;break;case exports.InternalScheduledStatus.CANCELED:this.sendingStatus=t.SendingStatus.CANCELED}else this.sendingStatus=t.SendingStatus.PENDING;this.errorCode=null!==(r=s.error_code)&&void 0!==r?r:0,this._messageToken=s.mesg_token}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{user:p.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}get isResendable(){return(this.sendingStatus===t.SendingStatus.FAILED||this.sendingStatus===t.SendingStatus.CANCELED)&&t.isResendableError(this.errorCode)}isIdentical(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}const B={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},j=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo);class V extends q{constructor(e,s){var i,n,a,r;if(super(e,s),this.translations={},this.message=null!==(i=s.message)&&void 0!==i?i:"",this.messageType=t.MessageType.ADMIN,this.translations=null!==(n=s.translations)&&void 0!==n?n:{},s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(a=i.file)||void 0===a?void 0:a.url,require_auth:null===(r=i.file)||void 0===r?void 0:r.require_auth}))))}}static payloadify(e){return t.deundefined(t.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,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class z{constructor(e){var s,i;this.detail={},this.type=null!==(s=e.type)&&void 0!==s?s:"",this.vendor=null!==(i=e.vendor)&&void 0!==i?i:"",e.detail&&t.isTypeOf("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}static payloadify(e){return t.deundefined(t.undefineNullProps({type:e.type,vendor:e.vendor,detail:e.detail}))}}class ${constructor(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}static payloadify(e){return t.deundefined({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}class Q extends F{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.message="",this.messageParams=null,this.translations={},this.translationTargetLanguages=[],this.messageSurvivalSeconds=-1,this.plugins=[],this._poll=null,this.message=s.message,this.messageType=t.MessageType.USER,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},this.translationTargetLanguages=null!==(n=s.target_langs)&&void 0!==n?n:[],0===Object.keys(this.translations).length&&this.translationTargetLanguages.length>0)for(const e of this.translationTargetLanguages)this.translations[e]="";if(this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,this.plugins=s.plugins?s.plugins.map((e=>new z(e))):[],this._poll=s.poll?new t.Poll(this._iid,s.poll):null,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(o=i.file)||void 0===o?void 0:o.require_auth}))))}s.review_info&&(this.messageReviewInfo=new $(s.review_info))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((e=>z.payloadify(e))),poll:e._poll?t.Poll.payloadify(e._poll):null,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null,review_info:e.messageReviewInfo?$.payloadify(e.messageReviewInfo):void 0})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.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 G extends F{constructor(e,s){var i,n,a,r,o,l,d,u;if(super(e,s),this.messageParams=null,this.fileInfoList=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE,this.data=null!==(a=null!==(n=null===(i=s.file)||void 0===i?void 0:i.data)&&void 0!==n?n:s.custom)&&void 0!==a?a:"",this.fileInfoList=null!==(o=null===(r=s.files)||void 0===r?void 0:r.map((t=>new w(e,t))))&&void 0!==o?o:[],this.messageSurvivalSeconds=null!==(l=s.message_survival_seconds)&&void 0!==l?l:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(d=i.file)||void 0===d?void 0:d.url,require_auth:null===(u=i.file)||void 0===u?void 0:u.require_auth}))))}}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}static payloadify(e){var s,i,n,a,r,o;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{file:{name:null!==(i=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.fileName)&&void 0!==i?i:"",size:null!==(a=null===(n=e.fileInfoList[0])||void 0===n?void 0:n.fileSize)&&void 0!==a?a:0,type:null!==(o=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}static _isMultipleFilesMessagePayload(e){const t=e.files;return Array.isArray(t)&&t.length>=2}static _isMultipleFilesMessageSerializedData(e){const t=e.fileInfoList;return Array.isArray(t)}}var K;exports.NotificationMessageStatus=void 0,(K=exports.NotificationMessageStatus||(exports.NotificationMessageStatus={})).SENT="SENT",K.READ="READ";class H extends g{constructor(e,s){var i,n;if(super(e,s),this.notificationData=null,this.notificationId=s.notification_message_id,this.messageType=t.MessageType.ADMIN,this.messageStatus=null!==(i=s.message_status)&&void 0!==i?i:exports.NotificationMessageStatus.SENT,this.priority=null!==(n=s.priority)&&void 0!==n?n:t.NotificationPriority.NORMAL,this.notificationEventDeadline=s.notification_event_deadline,0===this.extendedMessage.sub_type)try{const{label:e,tags:t=[],template_key:s,template_variables:i}=JSON.parse(this.extendedMessage.sub_data);this.notificationData={label:e,tags:t,templateKey:s,templateVariables:i}}catch(e){}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}isIdentical(e){return this.notificationId===e.notificationId}}const W=(e,t)=>{if(t.notification_message_id)return new H(e,t);switch(t.type){case"MESG":return new Q(e,t);case"FILE":return G._isMultipleFilesMessagePayload(t)?new G(e,t):new Y(e,t);case"ADMM":case"BRDM":return new V(e,t);default:return null}};class Y extends F{constructor(e,i){var n,a,r,o,l,d,u,c,h,p,m,_,g,y;super(e,i),this.messageParams=null,this.plainUrl="",this.requireAuth=!1,this.thumbnails=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE;const f=i.file;if(this.plainUrl=(null!==(a=null!==(n=null==f?void 0:f.url)&&void 0!==n?n:i.url)&&void 0!==a?a:"").split("?auth=")[0],this.name=null!==(o=null!==(r=null==f?void 0:f.name)&&void 0!==r?r:i.name)&&void 0!==o?o:"File",this.size=null!==(d=null!==(l=null==f?void 0:f.size)&&void 0!==l?l:i.size)&&void 0!==d?d:0,this.data=null!==(c=null!==(u=null==f?void 0:f.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",this.type=f?null!==(h=f.type)&&void 0!==h?h:"":null!==(p=i.type)&&void 0!==p?p:"",this.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,this.thumbnails=i.thumbnails?i.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this.requireAuth)})):[],this.messageSurvivalSeconds=null!==(_=i.message_survival_seconds)&&void 0!==_?_:-1,i.parent_message_info){const s=i.parent_message_info;this.parentMessage=W(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},s),{created_at:s.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:s.file,url:null===(g=s.file)||void 0===g?void 0:g.url,require_auth:null===(y=s.file)||void 0===y?void 0:y.require_auth}))))}}static payloadify(e){var s;return t.deundefined(t.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===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.plainUrl,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}=t.Vault.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=$i.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class J extends t.InstancedObject{static getPlainUrl(e){return e instanceof J?e._plainUrl:e.fileUrl}constructor(e,{file:t,fileUrl:s,fileName:i,fileSize:n,mimeType:a,thumbnailSizes:r,_uploadedMetaData:o,_thumbnails:l}){super(e),this._plainUrl=s,this.file=t,this.fileName=i,this.fileSize=n,this.mimeType=a,this.thumbnailSizes=r,this._uploadedMetaData=o,this._thumbnails=l}get fileUrl(){var e;const{sessionManager:s}=t.Vault.of(this._iid);return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&s.ekey?`${this._plainUrl}?auth=${s.ekey}`:this._plainUrl}set fileUrl(e){this._plainUrl=e}toJSON(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}class X extends t.WebSocketRequestCommand{constructor(e){var i,n,a,r;let o=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((e=>e.userId)))),super({code:"FILE",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,files:e.files?se(e.files):null,url:e.url,name:null!==(i=e.fileName)&&void 0!==i?i:"",type:null!==(n=e.mimeType)&&void 0!==n?n:"",size:null!==(a=e.fileSize)&&void 0!==a?a:0,custom:e.data,custom_type:e.customType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((e=>s.payloadify(e))),require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:o,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?u.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 Z extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId)))),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e.channelType)}/${encodeURIComponent(e.channelUrl)}/messages`,this.params=t.deundefined(t.undefineNullProps({message_type:t.MessageType.FILE,user_id:e.userId,files:e.files?se(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===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:e.requireAuth,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((e=>m.payloadify(e))),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}))}}class ee extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"FILE",i),this.message=i.files&&i.files.length>=2?new G(e,i):new Y(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class te extends t.APIResponseCommand{constructor(e,s){var i,n,a,r;super(e,s),this.message=s.files&&s.files.length>=2?new G(e,s):new Y(e,s);const{sdkState:o}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(a=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(n=this.message.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)))&&void 0!==a?a:[],o.userId),this.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r}}function se(e){return e.map((e=>{var i,n;return t.deundefined(t.undefineNullProps({url:J.getPlainUrl(e),file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var ie;!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"}(ie||(ie={}));class ne{constructor(e,{sdkState:s,dispatcher:i,requestQueue:n,onlineDetector:a,cacheContext:r}){this._queueMap=new Map,this._iid=e,this._sdkState=s,this._requestQueue=n,this._cacheContext=r,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof t.ConnectionStateChangeCommand&&(this._connectionState=e.stateType)})),this._onlineDetector=a}get _shouldSendThroughWebSocket(){return this._connectionState===t.ConnectionStateType.CONNECTED||this._connectionState===t.ConnectionStateType.CONNECTING||this._connectionState===t.ConnectionStateType.RECONNECTING}_sendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._createSendFileMessageRequestParams(e,s);if(this._shouldSendThroughWebSocket){const e=new X(t),s=yield this._requestQueue.send(e),{message:i}=s.as(ee);return i}{const e=new Z(Object.assign(Object.assign({},t),{userId:this._sdkState.userId})),s=yield this._requestQueue.send(e),{message:i}=s.as(te);return i}}))}_createSendFileMessageRequestParams(e,t){const s=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){const e=t.params;s.files=e.fileInfoList}else{const e=t.params;s.url=e.fileUrl,s.requireAuth=e.requireAuth}return s}_resolveMessageQueue(e){var s;return t.__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 n=[];let a=!0;for(const r of i.messageQueue)switch(r.state){case ie.PENDING:case ie.UPLOADING:a=!1,n.push(r);break;case ie.UPLOADED:if(a)try{r.state=ie.SENDING;const s=yield this._sendFileMessage(e,r);r.deferred.resolve(s),yield t.sleep(100)}catch(e){r.deferred.reject(e)}else n.push(r);break;case ie.FAILED:{const e=null!==(s=r.error)&&void 0!==s?s:t.SendbirdError.unknown;r.deferred.reject(e.code===t.SendbirdErrorCode.REQUEST_CANCELED?t.SendbirdError.fileUploadCanceled:e);break}}const r=i.isResolveRequestPending;i.messageQueue=n,i.isResolving=!1,i.isResolveRequestPending=!1,r&&(yield this._resolveMessageQueue(e))}}))}_uploadNextPendingItem(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i){const n=i.messageQueue.find((e=>e.state===ie.PENDING));if(n){if(n.multipleFileUploadInfo){const{uploadIndex:a,uploadCount:r,requestHandler:o}=n.multipleFileUploadInfo,l=n.params,d=l.fileInfoList[a];t.isFile(d.file)&&!(null===(s=d._uploadedMetaData)||void 0===s?void 0:s.isUploaded)?yield this._tryUploadNextItemAndUpdateItemState(e,i,n):n.state=ae.requestId===t.requestId));s>=0&&e.uploadQueue.splice(s,1)}_uploadNextFileForSingleFileItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const t=new i({file:a.file,channelUrl:e.url,thumbnailSizes:a.thumbnailSizes,requestId:s.requestId}),d=yield this._requestQueue.send(t),{url:u,fileSize:c=a.fileSize,thumbnails:h=[],requireAuth:p=!1}=d.as(n);a.fileName=null!==(r=a.fileName)&&void 0!==r?r:a.file.name,a.mimeType=null!==(o=a.mimeType)&&void 0!==o?o:a.file.type,a.fileSize=null!==(l=a.fileSize)&&void 0!==l?l:a.file.size,a.fileUrl=u,a.fileSize=c,a.requireAuth=p,a._thumbnails=h}))}_uploadNextFileForMultipleFilesItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const{uploadIndex:t}=s.multipleFileUploadInfo,d=a.fileInfoList[t],u=new i({file:d.file,channelUrl:e.url,thumbnailSizes:d.thumbnailSizes,requestId:s.requestId}),c=yield this._requestQueue.send(u),{url:h,fileSize:p=d.fileSize,thumbnails:m,requireAuth:_=!1}=c.as(n);d.fileName=null!==(r=d.fileName)&&void 0!==r?r:d.file.name,d.mimeType=null!==(o=d.mimeType)&&void 0!==o?o:d.file.type,d.fileSize=null!==(l=d.fileSize)&&void 0!==l?l:d.file.size,d.file=void 0,d.fileUrl=h,d.fileSize=p,d._thumbnails=m,d._uploadedMetaData=Object.assign(Object.assign({},d._uploadedMetaData),{requireAuth:_,isUploaded:!0}),d instanceof J||(a.fileInfoList[t]=new J(this._iid,d))}))}request(e,s,i,n={}){return t.__awaiter(this,void 0,void 0,(function*(){if(!this._queueMap.has(e.url)){const t={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1};this._queueMap.set(e.url,t)}const a=this._queueMap.get(e.url),r=new t.Deferred,o={requestId:s,params:i,state:ie.PENDING,deferred:r};if(function(e){return"fileInfoList"in e}(i)){const e=i,t=Object.assign({uploadIndex:0,uploadCount:e.fileInfoList.length},n);o.multipleFileUploadInfo=t}return a.messageQueue.push(o),this._uploadNextPendingItem(e),r.promise}))}cancel(e,s){const i=this._queueMap.get(e.url);if(i){const n=s?[i.messageQueue.find((e=>e.requestId===s))]:[...i.messageQueue];for(const s of n)if(s)switch(s.state){case ie.PENDING:if(s.state=ie.FAILED,s.error=t.SendbirdError.requestCanceled,s.multipleFileUploadInfo&&!s.multipleFileUploadInfo.isCopy){const{uploadIndex:e,requestHandler:i}=s.multipleFileUploadInfo,n=s.params.fileInfoList[e];null==i||i._triggerOnFileUploaded(s.requestId,e,n,t.SendbirdError.fileUploadCanceled)}this._resolveMessageQueue(e);break;case ie.UPLOADING:this._requestQueue.cancel(s.requestId),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s.requestId}))}}else s&&(this._requestQueue.cancel(s),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s})))}}const ae={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:t.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},re=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo)&&t.isTypeOf("boolean",e.showSubchannelMessagesOnly),oe={replyType:t.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},le=e=>t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo);class de extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,includeMetaArray:n,includeReactions:a,includeThreadInfo:r,includeParentMessageInfo:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}`,this.params={is_sdk:!0,with_sorted_meta_array:n,include_reactions:a,include_thread_info:r,include_parent_message_info:o,include_poll_details:!0}}}class ue extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}class ce extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,prevResultSize:a,nextResultSize:r,isInclusive:o,reverse:l,messageTypeFilter:d,customTypesFilter:u,senderUserIdsFilter:c,replyType:h,includeMetaArray:p,includeReactions:m,parentMessageId:_,includeThreadInfo:g,includeParentMessageInfo:y,showSubchannelMessagesOnly:f,checkingHasNext:v,checkingContinuousMessages:I}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages`,this.params=t.deundefined(t.undefineNullProps({is_sdk:!0,prev_limit:a,next_limit:r,include:o,reverse:l,message_ts:i,message_id:n,message_type:null!=d?d:null,custom_types:u,sender_ids:c,include_reply_type:h,with_sorted_meta_array:p,include_reactions:m,parent_message_id:_,include_thread_info:g,include_parent_message_info:y,show_subchannel_message_only:f,include_poll_details:!0,checking_has_next:v,checking_continuous_messages:I}))}}class he extends t.APIResponseCommand{constructor(e,t){super(e,t),void 0!==t.is_continuous_messages&&(this.isContinuousMessages=t.is_continuous_messages),void 0!==t.has_next&&(this.hasNext=t.has_next),this.messages=t.messages.map((t=>W(e,t)))}}class pe extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,replyType:a,includeMetaArray:r,includeReactions:o,includeThreadInfo:l,includeParentMessageInfo:d}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/changelogs`,this.params={change_ts:i,token:n,with_sorted_meta_array:r,include_reactions:o,include_thread_info:l,include_reply_type:a,include_parent_message_info:d,include_poll_details:!0}}}class me extends t.APIResponseCommand{constructor(e,t){super(e,t),this.updatedMessages=t.updated.map((t=>W(e,t))),this.deletedMessagesInfo=t.deleted.map((e=>({messageId:e.message_id,deletedAt:e.deleted_at}))),this.hasMore=t.has_more,this.nextToken=t.next}}class _e extends t.APIRequestCommand{constructor({channelUrl:e,scheduledMessageId:s}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/scheduled_messages/${encodeURIComponent(s)}`,this.params={}}}class ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}var ye;exports.RestrictionType=void 0,(ye=exports.RestrictionType||(exports.RestrictionType={})).MUTED="muted",ye.BANNED="banned";class fe{constructor(e){var s,i,n,a;this.restrictionType=null,t.isEnumOf(exports.RestrictionType,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(s=e.description)&&void 0!==s?s:null,this.endAt=null!==(n=null!==(i=e.end_at)&&void 0!==i?i:e.muted_end_at)&&void 0!==n?n:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}static payloadify(e){return t.deundefined(t.undefineNullProps({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}class ve extends t.User{constructor(e,t){super(e,t),this.restrictionInfo=new fe(t)}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),fe.payloadify(e.restrictionInfo))))}}class Ie{constructor(){this._onPending=t.noop,this._onFailed=t.noop,this._onSucceeded=t.noop}_trigger(e){switch(null==e?void 0:e.sendingStatus){case t.SendingStatus.PENDING:0===e.errorCode&&this._onPending(e);break;case t.SendingStatus.SCHEDULED:case t.SendingStatus.SUCCEEDED:this._onSucceeded(e)}}_triggerFailed(e,s){switch(null==s?void 0:s.sendingStatus){case t.SendingStatus.FAILED:case t.SendingStatus.CANCELED:this._onFailed(e,s.scheduledInfo?null:s)}}onPending(e){return this._onPending=e,this}onFailed(e){return this._onFailed=e,this}onSucceeded(e){return this._onSucceeded=e,this}}const Ee={data:void 0,customType:void 0,mentionType:t.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},Te=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isTypeOf("number",e.parentMessageId,!0)&&t.isTypeOf("boolean",e.isReplyToChannel)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0)&&t.isTypeOf("boolean",e.isPinnedMessage,!0),be=e=>({isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}),Me=Object.assign(Object.assign({},Ee),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function Se(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}const Oe=e=>{var s;return t.deundefined(t.undefineNullProps({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(s=e.poll)||void 0===s?void 0:s.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations),extendedMessagePayload:e.extendedMessagePayload}))},Ae=e=>Te(e)&&t.isTypeOf("string",e.message)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0)&&t.isTypeOf("object",e.extendedMessagePayload,!0);var Ce;!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Ce||(Ce={}));const we=e=>"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob,Ne=e=>e===Ce.BLOB||e===Ce.FILE,Pe=e=>({file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}),Ue=Object.assign(Object.assign({},Ee),{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});function Re(e){var s,i,n,a;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=e.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails}))}const xe=(e,s)=>{var i;return e.messageParams?(!e.url&&t.isFile(s)&&(e.messageParams.file=s),e.messageParams):t.deundefined(t.undefineNullProps({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:s,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height})))}))},ke=e=>Te(e)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),Le={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},De=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0),qe=Object.assign(Object.assign({},Le),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Fe=e=>De(e)&&t.isTypeOf("string",e.message,!0)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0),Be=Object.assign({},Le);class je extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,token:i,limit:n}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(e)}/operators`,this.params={token:i,limit:n}}}class Ve extends t.APIResponseCommand{constructor(e,s){super(e,s),this.operators=s.operators.map((s=>new t.User(e,s))),this.token=s.next}}class ze extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;{const e=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new je(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),i=yield e.send(s),{operators:n,token:a}=i.as(Ve);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return e}}throw t.SendbirdError.invalidParameters}))}}class $e extends t.ChannelDataListQuery{constructor(e,s,i,n){var a,r,o,l,d,u,c,h,p,m;super(e,s,i,n),this.reverse=!1,this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.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!==(a=n.reverse)&&void 0!==a&&a,this.messageTypeFilter=null!==(r=n.messageTypeFilter)&&void 0!==r?r:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,this.senderUserIdsFilter=null!==(l=n.senderUserIdsFilter)&&void 0!==l?l:null,this.replyType=null!==(d=n.replyType)&&void 0!==d?d:t.ReplyType.NONE,this.includeMetaArray=null!==(u=n.includeMetaArray)&&void 0!==u&&u,this.includeReactions=null!==(c=n.includeReactions)&&void 0!==c&&c,this.includeParentMessageInfo=null!==(h=n.includeParentMessageInfo)&&void 0!==h&&h,this.includeThreadInfo=null!==(p=n.includeThreadInfo)&&void 0!==p&&p,this.showSubchannelMessagesOnly=null!==(m=n.showSubchannelMessagesOnly)&&void 0!==m&&m}_validate(){return super._validate()&&t.isTypeOf("boolean",this.reverse)&&t.isEnumOf(t.MessageTypeFilter,this.messageTypeFilter)&&t.isEnumOf(t.ReplyType,this.replyType)&&t.isArrayOf("string",this.customTypesFilter,!0)&&t.isArrayOf("string",this.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",this.includeMetaArray)&&t.isTypeOf("boolean",this.includeReactions)&&t.isTypeOf("boolean",this.includeParentMessageInfo)&&t.isTypeOf("boolean",this.includeThreadInfo)&&t.isTypeOf("boolean",this.showSubchannelMessagesOnly)}load(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=$i.of(this._iid),s=yield e.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t.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,...s.map((e=>e.createdAt))),this._hasNext=s.length>=this.limit,this._isLoading=!1,s}return[]}throw t.SendbirdError.invalidParameters}))}}class Qe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={limit:n,token:a}}}class Ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.mutedUsers=[];const{next:s,muted_list:i}=t;this.token=s,i&&i.length>0&&(this.mutedUsers=i.map((t=>new ve(e,t))))}}class Ke extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Qe(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{mutedUsers:n,token:a}=i.as(Ge);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class He extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({limit:n,token:a})}}class We extends t.APIResponseCommand{constructor(e,t){super(e,t),this.bannedUsers=[];const{next:s,banned_list:i}=t;this.token=s,i&&i.length>0&&(this.bannedUsers=i.map((t=>new ve(e,t.user))))}}class Ye extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new He(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{bannedUsers:n,token:a}=i.as(We);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}var Je;exports.ReportCategory=void 0,(Je=exports.ReportCategory||(exports.ReportCategory={})).SPAM="spam",Je.HARASSING="harassing",Je.SUSPICIOUS="suspicious",Je.INAPPROPRIATE="inappropriate";class Xe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class Ze extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${n}`}}class tt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.isMuted=!1,this.startAt=0,this.endAt=0;const{is_muted:s,start_at:i,end_at:n,remaining_duration:a,description:r}=t;this.isMuted=s,this.startAt=i,this.endAt=n,this.remainingDuration=a,this.description=r}}class st extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={keys:n,include_ts:!0}}}class it extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0}}}class at extends t.APIResponseCommand{constructor(e,t){var s,i;super(e,t),this.metaData=null!==(s=t.metadata)&&void 0!==s?s:{},this.ts=null!==(i=t.ts)&&void 0!==i?i:null}}class rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n,upsert:a}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0,upsert:null!=a&&a}}}class ot extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class lt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class dt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata/${n}`,this.params={include_ts:!0}}}class ut extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={include_ts:!0}}}class ht extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class pt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={keys:n}}}class mt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class _t extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n}}}class gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class yt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n,upsert:a=!1,mode:r="set"}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n,upsert:a,mode:r}}}class ft extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class vt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class It extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter/${n}`,this.params={}}}class Et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={}}}class Tt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={user_id:n,seconds:a,description:r}}}class bt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Mt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${encodeURIComponent(n)}`}}class St extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Ot extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({user_id:n,seconds:a,description:r})}}class At extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data),s.data.member_count&&(this.memberCount=s.data.member_count),s.data.joined_member_count&&(this.joinedMemberCount=s.data.joined_member_count)}}class Ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban/${encodeURIComponent(n)}`}}class wt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,freezing:n}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/freeze`,this.params={freeze:n}}}class Pt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.freeze=s.data.freeze}}class Ut extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}`,this.params={report_category:n,reporting_user_id:a,report_description:r}}}class Rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,description:o}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_REPORT}/users/${r}`,this.params={channel_url:s,channel_type:i===t.ChannelType.OPEN?"open_channels":"group_channels",report_category:n,reporting_user_id:a,report_description:o}}}class xt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,messageId:o,description:l,messageToken:d}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}/messages/${o}`,this.params=t.deundefined({report_category:n,reporting_user_id:a,report_description:l,offending_user_id:r,mesg_token:d})}}class kt extends t.WebSocketRequestCommand{constructor(e){let s=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MESG",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage,extended_message_payload:e.extendedMessagePayload}))})}}class Lt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"MESG",i),this.message=new Q(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class Dt extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,poll_id:e.pollId}))})}}class qt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"MEDI",i),this.message=new Q(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class Ft extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"FEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,apple_critical_alert_options:e.appleCriticalAlertOptions}))})}}class Bt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"FEDI",i),this.message=new Y(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class jt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class Vt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(t)}}class zt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class $t extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(Object.assign({},t))}}class Qt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,translationTargetLanguages:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}/translation`,this.params={target_langs:n}}}class Gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Kt extends t.APIRequestCommand{constructor(e){var s;super();let i=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:a}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(n)}/${encodeURIComponent(a)}/scheduled_messages`,this.params=t.deundefined(t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class Ht extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Wt extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId))));const{channelType:r,channelUrl:o}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(r)}/${encodeURIComponent(o)}/scheduled_messages`,this.params=t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.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((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})}}class Yt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Y(e,t)}}class Jt extends t.APIRequestCommand{constructor({pollId:e,title:s,data:i,allowUserSuggestion:n,allowMultipleVotes:a,closeAt:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`,this.params={title:s,data:i,allow_user_suggestion:n,allow_multiple_votes:a,close_at:r}}}class Xt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Zt extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`}}class es extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/close`}}class ts extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ss extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,pollId:i,optionText:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(i)}/options`,this.params={channel_url:e,channel_type:s,text:n}}}class is extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ns extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s,optionText:i}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`,this.params={text:i}}}class as extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class rs extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`}}class os extends t.WebSocketRequestCommand{constructor({reqId:e,channelType:s,channelUrl:i,pollId:n,pollOptionIds:a}){super({code:"VOTE",ackRequired:!0,payload:t.deundefined({req_id:e,channel_type:s===t.ChannelType.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:n,option_ids:a})})}}class ls extends t.WebSocketEventCommand{constructor(e,s,i){super(e,"VOTE",i),this.event=new t.PollVoteEvent(i),this.channelUrl=i.channel_url,this.channelType=i.channel_type}}const ds="Message",us="NotificationMessage";const cs=Object.assign(Object.assign({},Ee),{fileInfoList:[]}),hs=e=>(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>e.maxWidth>0&&e.maxHeight>0)));class ps extends Ie{constructor(){super(...arguments),this._onFileUploaded=t.noop}_triggerOnFileUploaded(e,t,s,i){this._onFileUploaded(e,t,s,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}}class ms extends t.InstancedObject{constructor(e,t){super(e),this.message=null,this.message=W(e,t.message)}}class _s extends t.APIRequestCommand{constructor(e){const{channelType:s,channelUrl:i,limit:n,token:a,includeReactions:r,includeMetaArray:o,includeParentMessageInfo:l,includeThreadInfo:d,includePollDetails:u}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(i)}/pinned_messages`,this.params=t.deundefined({limit:n,token:a,include_reactions:r,with_sorted_meta_array:o,include_thread_info:d,include_parent_message_info:l,include_poll_details:u})}}class gs extends t.APIResponseCommand{constructor(e,t){super(e,t);const{pinned_messages:s,has_more:i,next:n}=t;this.pinnedMessages=s.map((t=>new ms(e,t))),this.hasMore=i,this.token=n}}class ys extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i),this.includeMetaArray=i.includeMetaArray,this.includeReactions=i.includeReactions,this.includeParentMessageInfo=i.includeParentMessageInfo,this.includeThreadInfo=i.includeThreadInfo,this.includePollDetails=i.includePollDetails}_validate(){return super._validate()&&t.isTypeOf("boolean",this.includeMetaArray,!0)&&t.isTypeOf("boolean",this.includeReactions,!0)&&t.isTypeOf("boolean",this.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",this.includeThreadInfo,!0)&&t.isTypeOf("boolean",this.includePollDetails,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new _s(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{pinnedMessages:n,hasMore:a,token:r}=i.as(gs);return this._token=r,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class fs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}class vs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}var Is;exports.SendMessageRequestType=void 0,(Is=exports.SendMessageRequestType||(exports.SendMessageRequestType={})).SEND="send",Is.RESEND="resend",Is.COPY="copy";class Es extends t.InstancedObject{get url(){return this._url}get name(){return this._name}set name(e){this._name=e}get createdAt(){return this._createdAt}toJSON(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}constructor(e,s){var i,n,a,r,o,l,d;super(e),this._name="",this._createdAt=0,this.pinnedMessageIds=[],this.channelType=t.ChannelType.BASE,this.coverUrl="",this.customType="",this.data="",this.isFrozen=!1,this.isEphemeral=!1,this.creator=null,this._messageCollectionLastAccessedAt=0,this._url=s.channel_url,this._name=null!==(i=s.name)&&void 0!==i?i:"",this._createdAt=1e3*s.created_at,this.coverUrl=null!==(n=s.cover_url)&&void 0!==n?n:"",this.customType=null!==(a=s.custom_type)&&void 0!==a?a:"",this.data=null!==(r=s.data)&&void 0!==r?r:"",this.isFrozen=null!==(o=s.freeze)&&void 0!==o&&o,this.isEphemeral=null!==(l=s.is_ephemeral)&&void 0!==l&&l,this.creator=s.created_by?new t.User(this._iid,s.created_by):null,s.metadata&&Object.keys(s.metadata).length>0&&s.ts?(this._cachedMetaData=new Map,Object.keys(s.metadata).forEach((e=>{this._cachedMetaData.set(e,{value:s.metadata[e],isRemoved:!1,updatedAt:s.ts})}))):"string"==typeof s.metadata&&(this._cachedMetaData=new Map(Object.entries(JSON.parse(s.metadata)))),this.pinnedMessageIds=null!==(d=s.pinned_message_ids)&&void 0!==d?d:[]}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(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?t.User.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}isGroupChannel(){return this.channelType===t.ChannelType.GROUP}isOpenChannel(){return this.channelType===t.ChannelType.OPEN}isFeedChannel(){return this.channelType===t.ChannelType.FEED}get cachedMetaData(){const e={};return this._cachedMetaData?(this._cachedMetaData.forEach(((t,s)=>{t.isRemoved||(e[s]=t.value)})),e):e}get messageCollectionLastAccessedAt(){return this._messageCollectionLastAccessedAt}_serializeCachedMetaData(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}_updateMessageCollectionLastAccessedAt(){this._messageCollectionLastAccessedAt=Date.now()}_update(e){const s=t.deundefined(e);Object.assign(this,s)}_upsertCachedMetaData(e,t){Object.keys(e).forEach((s=>{this._cachedMetaData||(this._cachedMetaData=new Map);const i=this._cachedMetaData.get(s);(!i||i.updatedAt<=t)&&this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})}))}_updateCachedMetaData(e,t){let s=!1;return this._cachedMetaData?this._cachedMetaData.forEach(((i,n)=>{var a;i.updatedAt<=t&&(this._cachedMetaData.set(n,{value:null!==(a=e[n])&&void 0!==a?a:i.value,isRemoved:!e[n],updatedAt:t}),s=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((s=>{this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})})),s=!0),{isUpdated:s}}_removeFromCachedMetaData(e,t){this._cachedMetaData&&e.forEach((e=>{const s=this._cachedMetaData.get(e);s&&s.updatedAtm.payloadify(e))):null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,created_at:i,user:a.currentUser?p.payloadify(a.currentUser):null,req_id:s,request_state:t.SendingStatus.PENDING,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>t.User.payloadify(e)))}))}_createPendingUserMessage(e,s,i){const n={};if(e.translationTargetLanguages)for(const t of e.translationTargetLanguages)n[t]="";const a=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.USER,message:e.message,translations:n,extended_message_payload:e.extendedMessagePayload})),r=new Q(this._iid,a);return r.messageParams=e,r}_createPendingScheduledUserMessage(e,t,s){const i=this._createPendingUserMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_createPendingFileMessage(e,i,n){var a,r,o,l,d,u,c;const h=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,i,n)),{type:t.MessageType.FILE,url:e.fileUrl,file:{name:null!==(a=e.fileName)&&void 0!==a?a:null===(r=e.file)||void 0===r?void 0:r.name,size:null!==(o=e.fileSize)&&void 0!==o?o:null===(l=e.file)||void 0===l?void 0:l.size,type:null!==(d=e.mimeType)&&void 0!==d?d:null===(u=e.file)||void 0===u?void 0:u.type,data:e.data},thumbnails:null===(c=e._thumbnails)||void 0===c?void 0:c.map((e=>s.payloadify(e)))})),p=new Y(this._iid,h);return p.messageParams=e,p}_createPendingMultipleFilesMessage(e,s,i){const n=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.FILE,file:e.fileInfoList.length>0?{name:e.fileInfoList[0].fileName,size:e.fileInfoList[0].fileSize,type:e.fileInfoList[0].mimeType,data:e.data}:void 0})),a=new G(this._iid,n);return a.messageParams=e,a}_validateFailedFileMessageHasFile(e,s){var i;return Boolean(e.url)||t.isFile(s)||t.isFile(null===(i=e.messageParams)||void 0===i?void 0:i.file)}_createPendingScheduledFileMessage(e,t,s){const i=this._createPendingFileMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_markMessageAsFailed(e,s,i=!1){e.errorCode=s.code,s.code===t.SendbirdErrorCode.REQUEST_CANCELED||s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=t.SendingStatus.CANCELED:i||(e.sendingStatus=t.SendingStatus.FAILED)}sendUserMessage(e){const s=Object.assign(Object.assign({},Me),e);return t.unless(Ae(s)).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(s)}_sendUserMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n,requestQueue:a}=t.Vault.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)}))));const d=new kt(Object.assign(Object.assign({},e),{channelUrl:this.url,channelType:this.channelType,reqId:r}));a.send(d).then((e=>{const{message:s}=e.as(Lt);n.dispatch(new t.MessageUpdateEventCommand({messages:[s],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(s)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendUserMessage(e){return t.unless(e instanceof Q&&!!e.messageParams).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId)}resendUserMessage(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=new t.Deferred,n=null!==(s=e.messageParams)&&void 0!==s?s:Oe(e);return this._sendUserMessage(n,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>i.reject(e))).onSucceeded((e=>i.resolve(e))),i.promise}))}updateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},qe),s);t.unless(t.isTypeOf("number",e)&&Fe(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Dt(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(qt);return o}))}copyUserMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Q&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters),t.unless(!s.poll).throw(t.SendbirdError.notSupportedError);const r=new t.Deferred,o=null!==(i=s.messageParams)&&void 0!==i?i:t.undefineNullProps(Object.assign(Object.assign({},s),{mentionType:s.mentionType,mentionedUserIds:null!==(n=s.mentionedUserIds)&&void 0!==n?n:null===(a=s.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)),translationTargetLanguages:Object.keys(s.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}));return e._sendUserMessage(o).onSucceeded((e=>{r.resolve(e)})).onFailed((e=>r.reject(e))),r.promise}))}translateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Qt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:s}),a=yield i.send(n),{message:r}=a.as(Gt);return r}))}_createScheduledUserMessage(e,s){const{requestQueue:i}=t.Vault.of(this._iid),n=Date.now(),a=this._generateRequestId();t.sleep(2).then((()=>{const i=this._createPendingScheduledUserMessage(e,a,n);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))}));const r=new Kt(Object.assign({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(r).then((e=>{const{message:i}=e.as(Ht);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((i=>{if(t.isThrowingOutside(i))throw i;t.sleep(2).then((()=>{const r=this._createPendingScheduledUserMessage(e,a,n);this._markMessageAsFailed(r,i),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(i,r)}))))}))}))}sendFileMessage(e){const s=Object.assign(Object.assign({},Ue),e);return t.unless(ke(s)).throw(t.SendbirdError.invalidParameters),this._sendFileMessage(s)}sendMultipleFilesMessage(e){var s;const i=Object.assign(Object.assign({},cs),e),n=t.Vault.of(this._iid);t.unless(((e,s=t.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT)=>Te(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=s&&e.fileInfoList.every((e=>hs(e))))(i,null===(s=n.appInfo)||void 0===s?void 0:s.multipleFilesMessageFileCountLimit)).throw(t.SendbirdError.invalidParameters);const a=!!e.fileInfoList.find((e=>{const t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return t.unless(!a).throw(t.SendbirdError.fileSizeLimitExceededError),this._sendMultipleFilesMessage(i)}_sendFileMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=$i.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?t.CollectionEventSource.LOCAL_MESSAGE_CANCELED:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendFileMessage(e){t.unless(e instanceof Y&&!!e.messageParams).throw(t.SendbirdError.invalidParameters);const{logger:s}=t.Vault.of(this._iid);return s.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId).onFailed((e=>{s.debug("autoResendFileMessage failed",e)})).onSucceeded((e=>{s.debug("autoResendFileMessage success",e)}))}_sendMultipleFilesMessage(e,s,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=$i.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new ps;return t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e,{requestHandler:l,isCopy:s===exports.SendMessageRequestType.COPY}).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);this._markMessageAsFailed(i,s),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_createScheduledFileMessage(e,s,i,n){const{requestQueue:a}=t.Vault.of(this._iid),r=new Wt(Object.assign(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(r).then((e=>{const{message:i}=e.as(Yt);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((a=>{if(t.isThrowingOutside(a))throw a;t.sleep(2).then((()=>{const r=this._createPendingScheduledFileMessage(e,i,n);this._markMessageAsFailed(r,a),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(a,r)}))))}))}))}sendFileMessages(e){t.unless(e.every((e=>ke(Object.assign(Object.assign({},Ue),e))))).throw(t.SendbirdError.invalidParameters);const s=new Ie;for(const t of e)this.sendFileMessage(t).onPending((e=>s._trigger(e))).onFailed(((e,t)=>s._triggerFailed(e,t))).onSucceeded((e=>s._trigger(e)));return s}resendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(e instanceof Y&&i&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const n=new t.Deferred,a=xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>n.reject(e))).onSucceeded((e=>n.resolve(e))),n.promise}))}resendMessage(e,s){var i,n;if(t.unless(e instanceof F&&!e.scheduledInfo&&e.isResendable).throw(t.SendbirdError.invalidParameters),e.isUserMessage()){const t=null!==(i=e.messageParams)&&void 0!==i?i:Oe(e);return this._sendUserMessage(t,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isFileMessage()){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(i).throw(t.SendbirdError.invalidParameters);const a=null!==(n=e.messageParams)&&void 0!==n?n:xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}updateFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},Be),s);t.unless(t.isTypeOf("number",e)&&(e=>De(e))(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Ft(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(Bt);return o}))}uploadFile(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),a=t.uuid(),r=new i({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a});r.uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a);const o=yield s.send(r),{url:l,thumbnails:d}=o.as(n);return{requestId:a,url:l,thumbnails:d}}))}cancelUploadingFileMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e)).throw(t.SendbirdError.invalidParameters);const{fileMessageQueue:s}=$i.of(this._iid);return s.cancel(this,e),!0}))}copyFileMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Y&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const r=new t.Deferred,o=t.undefineNullProps(Object.assign(Object.assign({},s),{fileUrl:s.url,fileName:s.name,fileSize:s.size,mimeType:s.type,mentionType:s.mentionType,mentionedUserIds:null!==(i=s.mentionedUserIds)&&void 0!==i?i:null===(n=s.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=s.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:s.requireAuth,isPinnedMessage:!1}));return e._sendFileMessage(o).onSucceeded((e=>r.resolve(e))).onFailed((e=>r.reject(e))),r.promise}))}copyMessage(e,s){t.unless(e instanceof Es&&s instanceof F&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=s,n=e;if(i.isUserMessage()){t.unless(!i.poll).throw(t.SendbirdError.notSupportedError);const e=Se(i);return n._sendUserMessage(e)}if(i.isFileMessage()){const e=Re(i);return n._sendFileMessage(e)}if(s.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}deleteMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){if(t.unless(e instanceof q).throw(t.SendbirdError.invalidParameters),e.messageId>0){const{requestQueue:s}=t.Vault.of(this._iid),i=new t.DeleteMessageRequestCommand({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof F?e._messageToken:void 0});yield s.send(i)}}))}addReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new jt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as(Vt);return r}))}deleteReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new zt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as($t);return r}))}_updateUserMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Dt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(qt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}_updateFileMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Ft({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(Bt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}createMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"add",!0):this._updateUserMessageMetaArray(e.messageId,i,"add",!0)}))}deleteMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"remove",!0):this._updateUserMessageMetaArray(e.messageId,i,"remove",!0)}))}addMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"add",!0):this._updateUserMessageMetaArray(e.messageId,s,"add",!0)}))}removeMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"remove",!0):this._updateUserMessageMetaArray(e.messageId,s,"remove",!0)}))}report(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isEnumOf(exports.ReportCategory,e)&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:n}=t.Vault.of(this._iid),a=new Ut({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:s});yield n.send(a)}))}reportUser(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof t.User&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new Rt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.userId,category:s,description:i});yield a.send(r)}))}reportMessage(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof F&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new xt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:s,description:i,messageToken:e._messageToken});yield a.send(r)}))}updatePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&(e=>t.isTypeOf("string",e.title,!0)&&t.validatePollData(e.data)&&t.isTypeOf("boolean",e.allowUserSuggestion,!0)&&t.isTypeOf("boolean",e.allowMultipleVotes,!0)&&t.isTypeOf("number",e.closeAt,!0))(s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Jt(Object.assign({pollId:e},s)),a=yield i.send(n),{poll:r}=a.as(Xt);return r}))}deletePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Zt({pollId:e});yield i.send(n)}))}closePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new es({pollId:e}),a=yield i.send(n),{poll:r}=a.as(ts);return r}))}addPollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("string",s)&&""!==s.trim();t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new ss({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:s}),r=yield n.send(a),{poll:o}=r.as(is);return o}))}updatePollOption(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const n=t.isTypeOf("number",e)&&t.isTypeOf("number",s)&&t.isTypeOf("string",i)&&""!==i.trim();t.unless(n).throw(t.SendbirdError.invalidParameters);const{requestQueue:a}=t.Vault.of(this._iid),r=new ns({pollId:e,pollOptionId:s,optionText:i}),o=yield a.send(r),{poll:l}=o.as(as);return l}))}deletePollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new rs({pollId:e,pollOptionId:s});yield n.send(a)}))}votePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isArrayOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n,dispatcher:a}=t.Vault.of(this._iid),r=new os({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:s}),o=yield n.send(r),{event:l}=o.as(ls);return a.dispatch(new t.PollVoteInternalEventCommand({event:l,source:t.CollectionEventSource.EVENT_POLL_VOTED})),l}))}getPollChangeLogsSinceTimestamp(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)).throw(t.SendbirdError.invalidParameters);const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}getPollChangeLogsSinceToken(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e,!0));const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}createPollListQuery(e=10){return new t.PollListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}createPollVoterListQuery(e,s,i=20){return new t.PollVoterListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:s,limit:i})}pinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new fs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}unpinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new vs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}}const Ts={};class bs{constructor({dbname:e,itemSizeLimit:t=1048576,cacheLimit:s=256,blockHashBase:i=2,blockHashMultiplier:n=10,blockHashConstant:a=11,transactionApplyDelay:r=200,disableLogger:o=!1}){return Ts[e]||(this.itemSizeLimit=t,this.cacheLimit=s,this.blockHashBase=i,this.blockHashMultiplier=n,this.blockHashConstant=a,this.transactionApplyDelay=r,this.disableLogger=o,Ts[e]=this),Ts[e]}static get(e){return Ts[e]}}var Ms,Ss;!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"}(Ms||(Ms={}));class Os extends Error{constructor({code:e=Ms.UNKNOWN_ERROR,message:t="Unknown error occurred."}){super(t),this.code=e,Object.setPrototypeOf(this,Os.prototype)}static get storeNotDefined(){return new Os({code:Ms.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}static get storeNotAvailable(){return new Os({code:Ms.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}static get storeNotAvailableInPrivateBrowsing(){return new Os({code:Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}static get storeIsFull(){return new Os({code:Ms.STORE_IS_FULL,message:"Store is full."})}static get storeNotInitialized(){return new Os({code:Ms.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}static get storeKeyTypeIsInvalid(){return new Os({code:Ms.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}static get storeBrokenIntegrity(){return new Os({code:Ms.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}static get storeBrokenBlob(){return new Os({code:Ms.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}static get storeEncryptionInvalid(){return new Os({code:Ms.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}static get storeItemSizeExceeded(){return new Os({code:Ms.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}static get storeReadFailed(){return new Os({code:Ms.STORE_READ_FAILED,message:"Failed to read from store."})}static get storeWriteFailed(){return new Os({code:Ms.STORE_WRITE_FAILED,message:"Failed to write to store."})}static get databaseSchemaNotOnUpgrade(){return new Os({code:Ms.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}static get collectionNotReady(){return new Os({code:Ms.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}static get collectionKeyNotMatch(){return new Os({code:Ms.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}static get collectionQueryNotValid(){return new Os({code:Ms.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}static get collectionInsertDuplicate(){return new Os({code:Ms.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}static get collectionKeyNotFound(){return new Os({code:Ms.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}static get collectionKeyNotGiven(){return new Os({code:Ms.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}static get collectionWriteFailed(){return new Os({code:Ms.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}static get collectionItemSizeExceeded(){return new Os({code:Ms.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}static get indexTableIsRequired(){return new Os({code:Ms.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}static get indexTypesNotMatch(){return new Os({code:Ms.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}static get compareTypesNotMatch(){return new Os({code:Ms.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}static get circularReferenceFound(){return new Os({code:Ms.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ss||(Ss={}));const As=(e,t=new WeakMap)=>{if("object"==typeof e&&null!==e){if(t.has(e))throw Os.circularReferenceFound;{let s;if(t.set(e,!0),Array.isArray(e))s=e.map((e=>As(e,t)));else if(e instanceof RegExp)s=e;else if(e instanceof Date)s=e;else{s={};for(const i in e)s[i]=As(e[i],t)}return t.delete(e),s}}return e},Cs=(e,t)=>{if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Os.compareTypesNotMatch;let s=0;switch(typeof e){case"boolean":case"number":s=e-t;break;case"string":s=e.localeCompare(t)}return s},ws=(e,t)=>{let s=0;for(let t=0;t>>0)%t},Ns=e=>new Promise((t=>{setTimeout((()=>t()),e)})),Ps=(e,t)=>{if(!t)return!1;if("function"!=typeof e){for(const s in e)if(["/and","&&"].includes(s)){if(e[s].some((e=>!Ps(e,t))))return!1}else if(["/or","||"].includes(s)){if(e[s].every((e=>!Ps(e,t))))return!1}else if("/where"===s){if(!(0,e[s])(t))return!1}else{const i=s;if("object"==typeof e[i]){const s=e[i];for(const e in s)switch(e){case"/eq":case"=":if(t[i]!==s[e])return!1;break;case"/neq":case"!=":if(t[i]===s[e])return!1;break;case"/gt":case">":{const n=t[i],a=s[e];if(!(Cs(n,a)>0))return!1;break}case"/gte":case">=":{const n=t[i],a=s[e];if(!(Cs(n,a)>=0))return!1;break}case"/lt":case"<":{const n=t[i],a=s[e];if(!(Cs(n,a)<0))return!1;break}case"/lte":case"<=":{const n=t[i],a=s[e];if(!(Cs(n,a)<=0))return!1;break}case"/in":{const n=t[i];if(!s[e].includes(n))return!1;break}case"/nin":{const n=t[i];if(s[e].includes(n))return!1;break}case"/contain":{const n=t[i],a=s[e];if(!n.includes(a))return!1;break}case"/regex":{const n=t[i];if(!s[e].test(n))return!1;break}case"/where":{const n=t[i];if(!(0,s[e])(n))return!1;break}}}else if("function"==typeof e[i]){if(!e[i](t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}return e(t)},Us=()=>{},Rs=()=>Promise.resolve(),xs=e=>e,ks=(e,t)=>{t()};var Ls;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Ls||(Ls={}));class Ds{constructor({initialPrevValue:e=null,initialNextValue:t=null,iterator:s,map:i=xs,backward:n=Rs,forward:a=Rs,complete:r=Us}){this._prevValue=e,this._nextValue=t,this._error=null,this._map=i,this._backward=n,this._forward=a,this._iterator=s,this._complete=r}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 t.__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 t.__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 qs{constructor({condition:e={},backward:t=!1,blockManager:s,indexer:i}){this.condition=e,this.backward=t,this._blockManager=s,this._indexer=i}findOptimizedStartPosition(){const e=["=","/eq",">",">=","/gt","/gte"],t=["=","/eq","<","<=","/lt","/lte"];if(this.backward){let s=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(const i in this._indexer.fields){let n=this._indexer.fields[i],a=1;if("-"===n[0]&&(n=n.slice(1),a=-1),this.condition[n])if("object"==typeof this.condition[n]){const r=a>0?t:e;for(const e in this.condition[n])if(r.includes(e))for(let t=s;t>=0;t--)if(a*Cs(this._indexer.origin[t].columnValues[i],this.condition[n][e])<=0){s=t;break}}else for(let e=s;e>=0;e--)if(a*Cs(this._indexer.origin[e].columnValues[i],this.condition[n])<=0){s=e;break}}return Math.min(s+1,this._indexer.origin.length-1)}{let s=0;if("function"!=typeof this.condition)for(let i=0;i{if((a>0?e:t).includes(r))for(let e=s;e=0){s=e;break}}));else for(let e=s;e=0){s=e;break}}return Math.max(s-1,0)}}each(e){return t.__awaiter(this,void 0,void 0,(function*(){let s=this.findOptimizedStartPosition(),i=0;this.backward&&this._indexer.origin[s]&&(i=this._indexer.origin[s].keys.length-1);const n=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[++i]){if(!this._indexer.origin[++s])return!1;i=0}return!0}return!1},a=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[--i]){if(!this._indexer.origin[--s])return!1;i=this._indexer.origin[s].keys.length-1}return!0}return!1};let r=null;if(this._indexer.origin[s]){const e=this.backward?a:n;do{const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e)){r=e;break}}while(e())}return yield new Promise((o=>{const l=new Ds({initialNextValue:As(r),iterator:e,forward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?a:n;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return As(e)}return null})),backward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?n:a;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return As(e)}return null})),complete:o});e(l)}))}))}}class Fs{constructor({condition:e={},backward:t=!1,mutex:s,blockManager:i,indexer:n}){this._mutex=s,this._iterator=new qs({condition:e,backward:t,blockManager:i,indexer:n})}fetch(e={}){return t.__awaiter(this,void 0,void 0,(function*(){let s=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 Os.collectionQueryNotValid;try{const e=[];return yield this._mutex.lock(),yield this._iterator.each((n=>t.__awaiter(this,void 0,void 0,(function*(){n.error?n.stop():n.hasNext?0===s?(e.push(n.nextValue),0t.__awaiter(this,void 0,void 0,(function*(){s.error?s.stop():s.hasNext?(e++,s.next()):s.stop()})))),this._mutex.unlock(),e}catch(e){throw this._mutex.unlock(),e}}))}}const Bs=e=>`nest@${e}`,js=(e,t)=>`${Bs(e)}/${t}`,Vs=(e,t)=>`${js(e,t)}.metadata`,zs=(e,t)=>`${js(e,t)}/block.`,$s=(e,t)=>`${js(e,t)}/blob.`;class Qs{constructor({dbname:e,collectionName:t,store:s}){this.dbname=e,this.collectionName=t,this.store=s}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.store.get(e);if(t){const{data:e,type:s}=t;if("undefined"!=typeof fetch){const t=yield fetch(e);return yield t.blob()}{const t=512,i=[],n=atob(e.split(",")[1]);for(let e=0;e{const i=((e,t,s,i=0)=>`${$s(e,t)}${s}.${i}`)(this.dbname,this.collectionName,s),n=new FileReader;n.onload=()=>{t({blobId:i,data:n.result,type:e.type})},n.readAsDataURL(e)}));return yield this.store.set({key:t,value:{data:i,type:n}}),t}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this.store.remove(e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=$s(this.dbname,this.collectionName),s=yield this.store.getAllKeys();yield Promise.all(s.filter((t=>t.startsWith(e))).map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this.store.remove(e)})))))}))}}var Gs,Ks,Hs;!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Gs||(Gs={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Ks||(Ks={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Hs||(Hs={}));const Ws=[Ks.PENDING,Ks.VOLATILE],Ys={};class Js{constructor({dbname:e,limit:t=256}){return Ys[e]||(this.dbname=e,this._items=[],this._limit=t,Ys[e]=this),Ys[e]}static get(e){return Ys[e]}get items(){return this._items}find(e,s,i=Hs.DEFAULT){return t.__awaiter(this,void 0,void 0,(function*(){let t=this.get(s);if(t)i===Hs.PERSISTENT&&(t.state=Ks.PERSISTENT);else{const n=yield e.get(s);n&&(t={key:s,value:n,state:i===Hs.PERSISTENT?Ks.PERSISTENT:Ks.VOLATILE},this.put(t))}return t}))}get(e,t=Hs.DEFAULT){const s=this._items.map((e=>e.key)).indexOf(e);if(s>-1){const e=this._items[s];return t===Hs.PERSISTENT&&(e.state=Ks.PERSISTENT),t!==Hs.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)Ws.includes(this._items[t].state)&&Ws.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===Ks.VOLATILE));let s=t.length-this._limit;if(s>0){const e=[];for(const t of this._items)t.state===Ks.VOLATILE&&s>0?s--: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)))}clearForDatabase(e){this.clearByCondition((t=>t.key.startsWith(Bs(e))))}clear(e=!1){this._items=e?[]:this._items.filter((e=>e.state!==Ks.VOLATILE))}}class Xs{constructor({dbname:e,collectionName:t,store:s}){this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=e,this.collectionName=t,this.metadataKey=((e,t)=>`${js(e,t)}/trans.metadata`)(e,t),this.recordsetKey=((e,t)=>`${js(e,t)}/trans.recordset`)(e,t),this._store=s}get generation(){return this._metadata?this._metadata.generation:0}get requestCount(){return this._requests.length}_getReducedRecordset(e=[]){return t.__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=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=[];for(let e=n.requests.length-1;e>=0;e--){const t=n.requests[e],i=t.data;s[i.key]||(a.unshift(t),s[i.key]=!0)}a.length>0&&(n.requests=a,t.unshift(n))}return t}_applyRecord(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname),{generation:i,requests:n}=s;let a=null;try{const e=yield this._store.setMany(n.map((e=>Object.assign(Object.assign({},e.data),{generation:i}))));for(let s=0;s{a&&e(a)}));else{const t=e.filter((e=>e.generation!==i));yield this._store.set({key:this.recordsetKey,value:t}),this._onWrite.forEach((e=>{e(n.map((e=>e.data)))}))}}))}init(){return t.__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,s){switch(e){case Gs.COMMIT:this._onCommit.set(t,s);break;case Gs.WRITE:this._onWrite.set(t,s);break;case Gs.ERROR:this._onError.set(t,s)}}requestWrite(e,t){this._requests.push({data:e,options:t});Js.get(this.dbname).put(Object.assign({state:Ks.PENDING},e))}requestMultipleWrite(e,t){const s=Js.get(this.dbname);for(const i of e)this._requests.push({data:i,options:t}),s.put(Object.assign({state:Ks.PENDING},i))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).clearByCondition((e=>e.state===Ks.PENDING)),this._requests=[]}))}commit(){return t.__awaiter(this,void 0,void 0,(function*(){const e=this._requests;if(e.length>0){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=n.data;s[a.key]||(s[a.key]=!0,t.unshift(n))}const i={generation:this.generation,requests:t},n=yield this._getReducedRecordset([i]);yield this._store.set({key:this.recordsetKey,value:n}),this._metadata.generation++,yield this._store.set({key:this.metadataKey,value:this._metadata});const a=Js.get(this.dbname);for(let e=0;e{t(e.map((e=>e.data)))}));const r=bs.get(this.dbname);setTimeout((()=>{try{this._applyRecord(n,i)}catch(e){this._onError.forEach((t=>t(e)))}}),r.transactionApplyDelay)}}))}}class Zs{constructor({blockId:e,keyName:t,items:s=[],limit:i}){this.blockId=e,this.keyName=t,this.limit=i,this._items=[...s]}static createFromCacheItem(e){return e?new Zs(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 s=t[this.keyName];return e===s}));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 i=s.base*Math.pow(s.multiplier,t)+s.constant;return(s.hashFunction||ws)(e,i)})(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})}`,`${zs(s,i)}${n}.${a}`;var s,i,n,a}_findBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname);for(let s=this.metadata.blockLevel;s>0;s--){const i=this.createBlockId(e,s),n=yield t.find(this._store,i);if(n){const t=Zs.createFromCacheItem(n);if(null==t?void 0:t.getItemByKey(e))return t}}return null}))}getFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return t?t.getItemByKey(e):null}))}putToBlock(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=bs.get(this.dbname),i=this.createBlockId(e),n=Math.floor(this._store.itemSizeLimit/t.itemSizeLimit),a=Js.get(this.dbname),r=yield a.find(this._store,i),o=r?Zs.createFromCacheItem(r):new Zs({blockId:i,keyName:this.keyName,items:[],limit:n});return!!(null==o?void 0:o.add(s))&&(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),!0)}))}removeFromBlock(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const e=zs(this.dbname,this.collectionName),t=(yield this._store.getAllKeys()).filter((t=>t.startsWith(e)));yield this._store.removeMany(t),yield this._transaction.clear();Js.get(this.dbname).clearByCondition((t=>t.key.startsWith(e)))}))}}const ti=e=>{const t=typeof e;return null===e||"undefined"===t||"boolean"===t||"number"===t||"string"===t},si={};class ii{constructor({dbname:e,collectionName:t,keyName:s,fields:i,transaction:n,store:a}){this._origin=[],this._table=[];const r=((e,t,s)=>`${js(e,t)}/index.${s}`)(e,t,i.join(">"));return si[r]||(this.dbname=e,this.collectionName=t,this.keyName=s,this.fields=i,this.indexerKey=r,this._transaction=n,this._store=a,this._transaction.on(Gs.COMMIT,this.indexerKey,(()=>this.commit())),this._transaction.on(Gs.ERROR,this.indexerKey,(()=>this.abort()))),si[r]}static createKey(e){return e.join(">")}static parseKey(e){return e.split(">")}static clearIndexerMap(){for(const e in si)delete si[e]}_addItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);return n?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:s,keys:[t]}),!0)}_removeItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);if(n){const e=this._table[i].keys.indexOf(t);if(e>-1)return this._table[i].keys.splice(e,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1}get origin(){return this._origin}get table(){return this._table}getColumnValues(e){const t=[];for(let s of this.fields){if("-"===s[0]&&(s=s.slice(1)),!ti(e[s]))throw Os.indexTypesNotMatch;t.push(e[s])}return t}diff(e,t){for(const s in this.fields){const i="-"===this.fields[s][0]?-1:1,n=Cs(e[s],t[s]);if(0!==n)return i*n}return 0}indexOf(e){if(this._table.length>0){let t=0,s=this._table.length-1;for(;t<=s;){const i=Math.floor((t+s)/2),n=this.diff(e,this._table[i].columnValues);if(n>0)t=i+1;else{if(!(n<0))return[i,!0];s=i-1}}return[t,!1]}return[0,!1]}ensure(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.dbname),t=yield e.find(this._store,this.indexerKey,Hs.PERSISTENT);if(t)this._origin=t.value,this._table=As(this._origin);else{const t=zs(this.dbname,this.collectionName),s=yield this._store.getAllKeys();for(const i of s)if(i.startsWith(t)){const t=yield e.find(this._store,i,Hs.NO_CACHE),s=Zs.createFromCacheItem(t);if(s)for(const e of s.items)this._addItem(e)}this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}si[this.indexerKey]=this}))}drop(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).remove(this.indexerKey),yield this._store.remove(this.indexerKey),delete si[this.indexerKey]}))}addItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}removeItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}clear(){return t.__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=As(this._origin)}abort(){this._table=As(this._origin)}}const ni=()=>"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product,ai=()=>{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)}))};var ri,oi;!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(ri||(ri={})),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"}(oi||(oi={}));const li={};class di{constructor(e,t={}){return this._state=ri.PROCESSING,this._queue=[],this._activationQueue=[],li[e]&&!t.forceCreate||(this.nodeId=ai(),this.key=e,ni()&&(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;if(!(null==t?void 0:t.isNestDbMessage))return;const{nodeId:s,requestId:i,key:n,op:a,data:r}=t;if(s!==this.nodeId&&n===this.key)switch(a){case oi.NEWNODE:this._sendSync();break;case oi.CLAIM_HOST:this._sendSync(),this._hostId=s;break;case oi.SYNC_HOST:if(!this.isInSync){this._activationTimeout&&clearTimeout(this._activationTimeout);const{currentItemRequestId:e,queue:t}=r;for(const e of t){this._queue.findIndex((t=>t.requestId===e.requestId))<0&&this._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:this.key,op:oi.REQUEST_LOCK,ts:e.ts})}this._currentItem=this._queue.find((t=>t.requestId===e)),this._completeSync()}break;case oi.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 oi.REQUEST_LOCK:this._requestLock(t);break;case oi.ACQUIRE_LOCK:{const e=this._queue.find((e=>e.requestId===i));this._acquire(e);break}case oi.RELEASE_LOCK:this._release(i)}})),window.addEventListener("beforeunload",(()=>{this._send(oi.REMOVENODE)}))),li[e]=this),li[e]}get locked(){return!!this._currentItem}get isHost(){return this._hostId===this.nodeId}get isInSync(){return this._state==ri.DONE}_send(e,t={}){var s;const i={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(s=null==t?void 0:t.requestId)&&void 0!==s?s:ai(),key:this.key,op:e,data:t.data,ts:Date.now()};return ni()&&window.postMessage(i,"*"),i}_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(oi.RELEASE_LOCK,{requestId:t.requestId});const s=this._queue.findIndex((t=>t.requestId===e));s>-1&&this._queue.splice(s,1),t.onReleased&&t.onReleased(e)}}_requestLock(e){return new Promise((t=>{const s={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:e=>{this.isHost&&this._send(oi.ACQUIRE_LOCK,{requestId:e}),t()},onReleased:()=>{this._acquire(this._queue[0])}};let i=!1;for(const e in this._queue)if(this._queue[e].ts>s.ts){this._queue.splice(parseInt(e),0,s),i=!0;break}i||this._queue.push(s),this._currentItem||this._acquire(this._queue[0])}))}_sendSync(){var e;this.isHost&&this._send(oi.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 t.__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=ri.DONE,this._activationQueue.forEach((e=>e())),this._activationQueue=[])}registerNode(){this._send(oi.NEWNODE),this._waitSync()}claimHost(){this._hostId=this.nodeId,this._send(oi.CLAIM_HOST),this._waitSync()}lock(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._waitUntilSyncCompleted();const e=this._send(oi.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)}}class ui{constructor({dbname:e,collectionName:t,keyName:s,keyHash:i,indexes:n,store:a}){this._state=Ss.INIT,this._indexers=[],this.dbname=e,this.name=t,this.keyName=s,this.indexes=[[s],...n.filter((e=>ii.createKey(e)!==this.keyName))],this._keyHash=i,this._store=a,this._mutex=new di(((e,t)=>`${js(e,t)}.lock`)(e,t)),this._blobContainer=new Qs({dbname:e,collectionName:t,store:a}),this._transaction=new Xs({dbname:e,collectionName:t,store:a})}static metadataOf(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const t=Vs(e,s);return yield i.get(t)}))}get state(){return this._state}get isReady(){return this._state===Ss.READY}init(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._mutex.lock();try{const e=bs.get(this.dbname),t=yield ui.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 ei({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store});const s=[...this.indexes],i=[],n=s.map((e=>ii.createKey(e))),a=t?t.indexes.map((e=>ii.createKey(e))):[];for(const e of a)n.includes(e)||i.push(ii.parseKey(e));const r=[];if(r.push(...s.map((e=>{const t=new ii({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store});return this._indexers.push(t),t.ensure()}))),r.push(...i.map((e=>new ii({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store}).drop()))),yield Promise.all(r),yield this._transaction.commit(),n.sort().join(",")!==a.sort().join(",")){const e=Vs(this.dbname,this.name);this._metadata.indexes=s,yield this._store.set({key:e,value:this._metadata})}this._state=Ss.READY,this._mutex.unlock()}catch(e){throw this._mutex.unlock(),e}}))}close(){this._state=Ss.CLOSED}_hasPropertyOfKeyName(e){const t=e[this.keyName];return"string"==typeof t&&!!t}_getIndexerBy(e=null){e||(e=[this.keyName]);const t=ii.createKey(e);for(const e of this._indexers)if(t===ii.createKey(e.fields))return e;throw Os.indexTableIsRequired}_upgradeBlockLevel(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Vs(this.dbname,this.name);this._metadata.blockLevel++,yield this._store.set({key:e,value:this._metadata})}))}_requestInsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName];if(yield this._blockManager.getFromBlock(t))throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}}))}_requestRemove(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){yield this._blockManager.clearAllBlocks();for(const e of this._indexers)yield e.clear()}))}getByKey(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{const t=yield this._blockManager.getFromBlock(e);return this._mutex.unlock(),As(t)}catch(e){throw this._mutex.unlock(),e}}))}query(e={}){if(this.isReady)return new Fs({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Os.collectionNotReady}insertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestInsert(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}insertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Os.collectionKeyNotGiven;for(const t of e)yield this._requestInsert(As(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestUpsert(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Os.collectionKeyNotGiven;for(const t of e)yield this._requestUpsert(As(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}update(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestUpdate(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}updateIf(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Os.collectionNotReady;yield this._mutex.lock();try{const{where:i={},index:n=null,backward:a=!1}=e,r=[],o=new qs({condition:i,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(n)});yield o.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(Ps(i,t)&&s.set){if("function"!=typeof s.set)for(const e in s.set)t[e]=s.set[e];else s.set(t);r.push(t)}e.next()}else e.stop()}))));for(const e of r)yield this._requestUpdate(As(e));return yield this._transaction.commit(),this._mutex.unlock(),r}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Os.collectionNotReady;yield this._mutex.lock();try{const{where:s={},index:i=null,backward:n=!1}=e,a=[],r=new qs({condition:s,blockManager:this._blockManager,backward:n,indexer:this._getIndexerBy(i)});yield r.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(Ps(s,t)){const e=t[this.keyName];a.push(e)}e.next()}else e.stop()}))));for(const e of a)yield this._requestRemove(e);return yield this._transaction.commit(),this._mutex.unlock(),a}catch(e){throw this._mutex.unlock(),e}}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.get(e)}))}saveBlob(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.save(e,s)}))}removeBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.remove(e)}))}removeAllBlobs(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.clear()}))}}const ci="[NESTDB]";let hi=!0;class pi{static off(){hi=!1}static log(...e){hi&&console.log(`${ci}[LOG]`,...e)}static warning(...e){hi&&console.warn(`${ci}[WARNING]`,...e)}static error(...e){hi&&console.error(`${ci}[ERROR]`,...e)}}const mi=[{},{a:700400,n:"error"}];class _i{constructor(e){var s,i,n;this.encryption=null!==(s=e.encryption)&&void 0!==s?s:t.DEFAULT_ENCRYPTION,this.itemSizeLimit=null!==(i=e.itemSizeLimit)&&void 0!==i?i:4194304,this.metadataBuffer=null!==(n=e.metadataBuffer)&&void 0!==n?n:256}get _encryptionCheckKey(){return`${this.dbname}.encrypt`}get _reservedKeys(){return[this._encryptionCheckKey]}_getRawKey(e,t=""){return`${e}${t}`}_generateShardPostfixArray(e=1){return[...Array(e).keys()]}_shardify(e){const{key:t,value:s}=e,i=JSON.stringify(this.encryption.encrypt(s)),n=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(n).map((e=>{const s={key:this._getRawKey(t,`.${e}`),data:i.substring(e*this.adjustedItemSizeLimit,(e+1)*this.adjustedItemSizeLimit)};return 0===e&&(s.metadata={shards:n}),s}))}_resetIfEncryptionChanged(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.get(this._encryptionCheckKey),t={encrypted:mi.map((e=>{var t;return null===(t=this.encryption)||void 0===t?void 0:t.encrypt(e)}))};if(e)if(e.encrypted&&Array.isArray(e.encrypted))for(const s in e.encrypted){if(JSON.stringify(e.encrypted[s])!==JSON.stringify(t.encrypted[s])){pi.warning("Encryption algorithm has changed. Stored data would be cleared."),yield this.clear();break}}else yield this.clear();yield this.set({key:this._encryptionCheckKey,value:t})}))}get adjustedItemSizeLimit(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}usage(){return t.__awaiter(this,void 0,void 0,(function*(){let e=0;const t=yield this._getAllRawKeys();for(const s of t){const t=yield this._getRaw(s);t&&(e+=JSON.stringify(t).length)}return e}))}getAllKeys(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this._getAllRawKeys()).filter((e=>e.endsWith(".0"))).map((e=>e.replace(/\.0$/,""))).filter((e=>!this._reservedKeys.includes(e)))}))}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=this._getRawKey(e,".0"),i=yield this._getRaw(s);if(i)try{const{data:s,metadata:n}=i,a=(null==n?void 0:n.shards)&&n.shards>1?yield Promise.all(this._generateShardPostfixArray(null==n?void 0:n.shards).map((i=>t.__awaiter(this,void 0,void 0,(function*(){if(i>0){const t=this._getRawKey(e,`.${i}`),s=yield this._getRaw(t);if(!s)throw Os.storeBrokenIntegrity;return s.data}return s}))))):[s];return this.encryption.decrypt(JSON.parse(a.join("")))}catch(e){return null}return null}))}set(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._shardify(e);return yield this._setRaw(t),Object.assign({},e.value)}))}setMany(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const t=this._getRawKey(e,".0"),s=yield this._getRaw(t);if(s){const{metadata:t}=s,i=this._generateShardPostfixArray(null==t?void 0:t.shards).map((t=>this._getRawKey(e,`.${t}`)));yield this._removeRaw(i);const n=Js.get(this.dbname);return null==n||n.remove(e),!0}return!1}))}removeMany(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname),s=[];for(const i of e){const e=this._getRawKey(i,".0"),n=yield this._getRaw(e);if(n){const{metadata:e}=n;s.push(...this._generateShardPostfixArray(null==e?void 0:e.shards).map((e=>this._getRawKey(i,`.${e}`))))}null==t||t.remove(i)}return s.length>0&&(yield this._removeRaw(s)),e}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.dbname);null==e||e.clearForDatabase(this.dbname)}))}}const gi=1,yi={};class fi extends _i{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:4194304}));const{delay:s=gi}=e;this.delay=s,this.observer={}}get rawData(){return yi[this.dbname]}set rawData(e){yi[this.dbname]=e}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){if(yi[this.dbname])return Object.keys(yi[this.dbname]);throw Os.storeNotAvailable}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(yi[this.dbname])return yield Ns(this.delay),yi[this.dbname][e]?Object.assign({key:e},yi[this.dbname][e]):null;throw Os.storeNotAvailable}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!yi[this.dbname])throw Os.storeNotAvailable;yield Ns(this.delay);for(const t of e){const{key:e,data:s,metadata:i}=t;yi[this.dbname][e]=Object.freeze({data:s,metadata:i})}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!yi[this.dbname])throw Os.storeNotAvailable;yield Ns(this.delay);for(const t of e)yi[this.dbname][t]&&delete yi[this.dbname][t]}))}observe(e,t,s){this.observer[e]||(this.observer[e]={}),t.forEach((t=>this.observer[e][t]=s))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yi[this.dbname]||(yi[this.dbname]={}),yield this._resetIfEncryptionChanged()}))}set(e){const s=Object.create(null,{set:{get:()=>super.set}});return t.__awaiter(this,void 0,void 0,(function*(){const t=this.observer[e.key];if(t&&"function"==typeof t.set){const e=t.set();if(e)throw e}return s.set.call(this,e)}))}setMany(e){const s=Object.create(null,{setMany:{get:()=>super.setMany}});return t.__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 s.setMany.call(this,e)}))}clear(){const e=Object.create(null,{clear:{get:()=>super.clear}});return t.__awaiter(this,void 0,void 0,(function*(){yield e.clear.call(this),yield Ns(this.delay),yi[this.dbname]={}}))}}const vi="NestDBStore";var Ii;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Ii||(Ii={}));var Ei,Ti,bi;exports.NestDBState=void 0,(Ei=exports.NestDBState||(exports.NestDBState={})).INIT="INIT",Ei.OPENING="OPENING",Ei.OPENED="OPENED",Ei.CLOSED="CLOSED";exports.LogLevel=void 0,(Ti=exports.LogLevel||(exports.LogLevel={}))[Ti.VERBOSE=0]="VERBOSE",Ti[Ti.DEBUG=1]="DEBUG",Ti[Ti.INFO=2]="INFO",Ti[Ti.WARN=3]="WARN",Ti[Ti.ERROR=4]="ERROR",Ti[Ti.NONE=5]="NONE";class Mi{constructor(e){var s,i,n,a;this.messageTypeFilter=null!==(s=null==e?void 0:e.messageTypeFilter)&&void 0!==s?s:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(i=null==e?void 0:e.customTypesFilter)&&void 0!==i?i:null,this.senderUserIdsFilter=null!==(n=null==e?void 0:e.senderUserIdsFilter)&&void 0!==n?n:null,this.replyType=null!==(a=null==e?void 0:e.replyType)&&void 0!==a?a:t.ReplyType.NONE}clone(){const e=new Mi,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((s=>{e[s]=t[s]})),e}match(e){switch(this.messageTypeFilter){case t.MessageTypeFilter.USER:if(e.messageType!==t.MessageType.USER)return!1;break;case t.MessageTypeFilter.FILE:if(e.messageType!==t.MessageType.FILE)return!1;break;case t.MessageTypeFilter.ADMIN:if(e.messageType!==t.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof F))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof q)switch(this.replyType){case t.ReplyType.NONE:if(e.parentMessageId>0)return!1;break;case t.ReplyType.ONLY_REPLY_TO_CHANNEL:if(e instanceof F&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}}exports.MessageListOrder=void 0,(bi=exports.MessageListOrder||(exports.MessageListOrder={})).CHANNEL_LATEST="channel_latest",bi.NEWEST_CHILD_MESSAGE="newest_child_message";const Si=e=>{switch(e){case exports.MessageListOrder.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Oi=()=>["channelUrl","-createdAt","-notificationId"],Ai=Object.assign(Object.assign({},Me),{scheduledAt:void 0}),Ci=Object.assign(Object.assign({},Ee),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),wi="UnsentMessage",Ni={};class Pi extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),this._mutex=new di("unsendmessagecache.lock"),Ni[e]=this}static of(e,t=!1){return Ni[e]&&!t||(Ni[e]=new Pi(e)),Ni[e]}get collection(){const{nestdb:e}=this._cacheContext,s=null==e?void 0:e.collection(wi);if(!s)throw t.SendbirdError.databaseError;return s}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){if(e.messageId>0)throw t.SendbirdError.invalidParameters;const s=Object.assign({},e.serialize());var i;return e instanceof Q?(e.messageParams&&(s.messageParams=be(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(i=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},be(i)),{scheduledAt:i.scheduledAt})))):e instanceof Y?(e.messageParams&&(s.messageParams=Pe(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(e=>Object.assign(Object.assign({},Pe(e)),{scheduledAt:e.scheduledAt}))(e.scheduledInfo.scheduledMessageParams))):e instanceof G&&e.messageParams&&(s.messageParams=(e=>t.deundefined({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}))(e.messageParams)),s}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return $i.of(this._iid).buildMessageFromSerializedData(e)}_deserializeWithMessageCreateParams(e){var s,i,n;return t.__awaiter(this,void 0,void 0,(function*(){const a=$i.of(this._iid),r=this._deserialize(e);if(e.messageParams)if(r instanceof Q){const t=e.messageParams;r.messageParams=a.buildUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.messageParams;t.fileKey&&"string"==typeof t.fileKey&&Ne(null!==(s=t.fileType)&&void 0!==s?s:"")&&(t.file=null!==(i=yield this.collection.getBlob(t.fileKey))&&void 0!==i?i:void 0),r.messageParams=a.buildFileMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof G){const s=e.messageParams;s&&s.fileInfoList&&(r.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(s,r),yield Promise.all(r.messageParams.fileInfoList.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t,s,i,n;"string"==typeof(null===(t=e._uploadedMetaData)||void 0===t?void 0:t.fileKey)&&Ne(null!==(i=null===(s=e._uploadedMetaData)||void 0===s?void 0:s.fileType)&&void 0!==i?i:"")&&(e.file=null!==(n=yield this.collection.getBlob(e._uploadedMetaData.fileKey))&&void 0!==n?n:void 0)}))))))}if(r.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)if(r instanceof Q){const t=e.scheduledInfo.scheduledMessageParams;r.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.scheduledInfo.scheduledMessageParams;t.fileKey&&"string"==typeof t.fileKey&&"string"==typeof t.fileType&&Ne(t.fileType)&&(t.file=null!==(n=yield this.collection.getBlob(t.fileKey))&&void 0!==n?n:void 0),r.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(t,r)}return r}))}_getFileInfoBlobKey(e,t){return`${e}.${t}`}get(e){return t.__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:s=new Mi,order:i=exports.MessageListOrder.CHANNEL_LATEST,sendingStatus:n,backward:a=!1,parentMessageId:r}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const o=Si(i),l={"/where":e=>!!(i!==exports.MessageListOrder.NEWEST_CHILD_MESSAGE||r&&0!==e.parentMessageId&&e.parentMessageId===r)&&s.match(this._deserialize(e))};e&&(l.channelUrl=e),n&&(l.sendingStatus=n);const d={where:l,index:o,backward:a},u=yield this.collection.query(d),c=yield u.fetch({});return Promise.all(c.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._deserializeWithMessageCreateParams(e)})))))}return[]}))}getAllChildMessages(e,s=new Mi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){(e instanceof Y||e instanceof G)&&(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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__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 t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e}}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}saveBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y){if(e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}if(e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams){const t=e.scheduledInfo.scheduledMessageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}}else if(e instanceof G){const s=e.messageParams;s&&s.fileInfoList&&Array.isArray(s.fileInfoList)&&(yield Promise.all(s.fileInfoList.map(((s,i)=>t.__awaiter(this,void 0,void 0,(function*(){if(s.file&&we(s.file)){const t=yield this.collection.saveBlob(s.file,this._getFileInfoBlobKey(e.reqId,i));s._uploadedMetaData||(s._uploadedMetaData={}),s._uploadedMetaData.fileKey=t,s._uploadedMetaData.fileType=Ce.BLOB}}))))))}}))}}const Ui={};class Ri extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _unsentMessageCache(){return Pi.of(this._iid)}constructor(e){super(e),Ui[e]=this}static of(e,t=!1){return Ui[e]&&!t||(Ui[e]=new Ri(e)),Ui[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(ds)}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 $i.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new Mi,order:a=exports.MessageListOrder.CHANNEL_LATEST,backward:r=!1,parentMessageId:o,isPollOnly:l=!1,exactMatch:d=!1,inclusive:u=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const c=Si(a),h={where:{channelUrl:e,"/where":e=>{if(null!=s&&""!==s)switch(a){case exports.MessageListOrder.CHANNEL_LATEST:if(d&&e.createdAt!==s)return!1;if(r){if(u&&e.createdAts||!u&&e.createdAt>=s)return!1;break;case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:if(!o||0===e.parentMessageId||e.parentMessageId!==o)return!1}return!(l&&!e._poll)&&n.match(this._deserialize(e))}},index:c,backward:r},p=yield this.collection.query(h),m=yield p.fetch({limit:null!=i?i:void 0});return Promise.all(m.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return this._deserialize(e)})))))}return[]}))}getAllChildMessages(e,s=new Mi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})}))}upsert(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.saveBlobs(e);for(const t of e)if(null===(s=t.threadInfo)||void 0===s?void 0:s._isUpdateRequired){const e=yield this.get(t.messageId);(null==e?void 0:e.threadInfo)&&t.threadInfo._updateFrom(e.threadInfo)}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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t;let s=[];(null===(t=e.threadInfo)||void 0===t?void 0:t.replyCount)&&e.threadInfo.replyCount>0&&(s=yield this.getAllChildMessages(e)),s.length>0&&(s.forEach((t=>t.applyParentMessage(e))),yield this.upsert(s))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(`${t}`)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:Si(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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Si(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=Si(exports.MessageListOrder.CHANNEL_LATEST),n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}saveBlobs(e){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y&&e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s}}})))))}))}_getGroupChannelPreferenceSize(e){return t.__awaiter(this,void 0,void 0,(function*(){let t=0;const{preference:s}=this._cacheContext,i=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),n=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),a=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),r=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`);return i&&(t+=JSON.stringify(i).length),n&&(t+=JSON.stringify(n).length),a&&(t+=JSON.stringify(a).length),r&&(t+=JSON.stringify(r).length),t}))}}const xi={};class ki extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),xi[e]=this}static of(e,t=!1){return xi[e]&&!t||(xi[e]=new ki(e)),xi[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(us)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){return Object.assign({},e.serialize())}_deserialize(e){return $i.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new Mi,backward:a=!1,exactMatch:r=!1,inclusive:o=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t={where:{channelUrl:e,"/where":e=>{if(s){if(r&&e.createdAt!==s)return!1;if(a){if(o&&e.createdAts||!o&&e.createdAt>=s)return!1}return n.match(this._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:a},l=yield this.collection.query(t);return(yield l.fetch({limit:null!=i?i:void 0})).map((e=>this._deserialize(e)))}return[]}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=e.map((e=>this._serialize(e)));yield this.collection.upsertMany(t)}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}markAsReadByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.updateIf({where:{channelUrl:e,messageStatus:exports.NotificationMessageStatus.SENT,createdAt:{"<":s}}},{set:{messageStatus:exports.NotificationMessageStatus.READ}}))}))}markAsReadByMessageIds(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){return(yield this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":s},messageStatus:exports.NotificationMessageStatus.SENT}},{set:{messageStatus:exports.NotificationMessageStatus.READ}})).length}return 0}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]});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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Si(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=["channelUrl","-createdAt","-notificationId"],n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}}const Li={};class Di extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _dispatcher(){return t.Vault.of(this._iid).dispatcher}get _messageCache(){return Ri.of(this._iid)}get _unsentMessageCache(){return Pi.of(this._iid)}get _notificationCache(){return ki.of(this._iid)}constructor(e){super(e),this._observers=new Map,this._dispatcherContext=this._dispatcher.on((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof t.MessageUpdateEventCommand){const{messages:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&e.messageId>0)),r=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&0===e.messageId)),o=s.filter((e=>e instanceof H));a.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.upsert(a),yield this._unsentMessageCache.remove(a.map((e=>e instanceof F?e.reqId:null)).filter((e=>null!==e)))})))),n||this._broadcastUpdateEvent(a,i)),r.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.upsert(r)})))),n||this._broadcastUpdateEvent(r,i)),o.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._notificationCache.upsert(o)})))),n||this._broadcastUpdateEvent(o,i))}else if(e instanceof t.MessageRemoveEventCommand){const{messageIds:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>"number"==typeof e)),r=s.filter((e=>"string"==typeof e));yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){a.length>0&&(yield this._messageCache.remove(a)),r.length>0&&(yield this._notificationCache.remove(r))})))),n||this._broadcastRemoveEvent(s,i)}else if(e instanceof t.UnsentMessageRemoveEventCommand){const{reqId:s,source:i}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([s])})))),this._broadcastRemoveUnsentEvent(s,i)}else if(e instanceof t.PollChangeLogEventCommand){const{polls:s,source:i}=e;if(this._cacheContext.localCacheEnabled){const e=s.map((e=>e.messageId)),i=(yield Promise.all(e.map((e=>this._messageCache.get(e))))).filter((e=>e));i.length>0&&s.forEach((e=>{const t=i.find((t=>t.messageId===e.messageId));t&&t.applyPoll(e)})),yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert(i)}))))}this._broadcastPollChangeLogEvent(s,i)}else if(e instanceof t.PollUpdateInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollUpdateEvent(s,i)}else if(e instanceof t.PollVoteInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollVoteEvent(s,i)}else if(e instanceof t.ReactionUpdateEventCommand){const{event:t,source:s}=e;t.messageId>0&&this._broadcastReactionUpdateEvent(t,s)}else if(e instanceof t.ThreadUpdateEventCommand){const{event:t,source:s}=e;this._broadcastThreadUpdateEvent(t,s)}}))))}static of(e,t=!1){var s;return Li[e]&&!t||(Li[e]&&(null===(s=Li[e]._dispatcherContext)||void 0===s||s.close()),Li[e]=new Di(e)),Li[e]}_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)}_broadcastReactionUpdateEvent(e,t){for(const s of this._observers.values())s.onReactionUpdate&&s.onReactionUpdate(e,t)}_broadcastThreadUpdateEvent(e,t){for(const s of this._observers.values())s.onThreadInfoUpdate&&s.onThreadInfoUpdate(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const qi=20;class Fi extends t.APIRequestCommand{constructor(e){const{reverse:s=!1,limit:i=qi,keys:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}`,this.params=t.deundefined({token:a,limit:i,reverse:s,order:t.MessageTemplateListOrder.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:n})}}class Bi extends t.APIResponseCommand{constructor(e,t){super(e,t);const{next:s,has_more:i=!1,templates:n}=t;this.nextToken=s,this.hasMore=i,this.templates=n.map((e=>({template:JSON.stringify(e)})))}}class ji extends t.APIRequestCommand{constructor(e){const{key:s}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}/${s}`}}class Vi extends t.APIResponseCommand{constructor(e,t){super(e,t),this.template=JSON.stringify(t)}}const zi={};class $i{constructor(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}){this._iid=e,this._sdkState=t,this._requestQueue=i,this._dispatcher=s,this._cacheContext=a,Ri.of(e),Pi.of(e),Di.of(e),this.fileMessageQueue=new ne(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}),zi[e]=this}static of(e){return zi[e]}buildMessageFromSerializedData(e){const s=t.deserialize(e);if(s.notificationId)return new H(this._iid,H.payloadify(s));switch(s.messageType){case t.MessageType.USER:return new Q(this._iid,Q.payloadify(s));case t.MessageType.FILE:return G._isMultipleFilesMessageSerializedData(s)?new G(this._iid,G.payloadify(s)):new Y(this._iid,Y.payloadify(s));case t.MessageType.ADMIN:return new V(this._iid,V.payloadify(s))}throw t.SendbirdError.invalidParameters}buildUserMessageCreateParamsFromSerializedData(e,s){return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,message:s.message,translationTargetLanguages:Object.keys(s.translations),pollId:e.pollId}))}buildFileMessageCreateParamsFromSerializedData(e,s){var i;return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,file:e.file,fileKey:e.fileKey,fileUrl:s.plainUrl,fileName:s.name,fileSize:s.size,mimeType:s.type,thumbnailSizes:null===(i=s.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),fileType:e.fileType,requireAuth:s.requireAuth}))}buildMultipleFilesMessageCreateParamsFromSerializedData(e,s){return t.deundefined({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,fileInfoList:e.fileInfoList.map((e=>new J(this._iid,e)))})}buildScheduledUserMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildScheduledFileMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildSenderFromSerializedData(e){const s=t.deserialize(e);return new p(this._iid,p.payloadify(s))}getMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new de(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ue);return i}))}getScheduledMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new _e(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ge);return i}))}getMessagesByMessageId(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,token:String(i)},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}getMessagesByTimestamp(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}_getMessagesByTimestampForCollection(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE,r,o){return t.__awaiter(this,void 0,void 0,(function*(){const l=new ce(Object.assign(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n),{checkingHasNext:r,checkingContinuousMessages:o})),d=yield this._requestQueue.send(l),{messages:u,isContinuousMessages:c,hasNext:h}=d.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:u,source:a})),{messages:u,isContinuousMessages:c,hasNext:h}}))}getThreadedMessagesByTimestamp(e,s,i,n=t.CollectionEventSource.REQUEST_THREADED_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const a=new ce(Object.assign(Object.assign(Object.assign({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:s},B),i),{replyType:t.ReplyType.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),r=yield this._requestQueue.send(a),{messages:o}=r.as(he),l=o.slice(1);return l.forEach((t=>{t.parentMessage=e})),this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:n})),{parentMessage:o[0],threadedMessages:l}}))}getMessageTemplatesByToken(e,s={}){return t.__awaiter(this,void 0,void 0,(function*(){const t=new Fi(Object.assign({token:e},s)),i=yield this._requestQueue.send(t),{hasMore:n,nextToken:a,templates:r}=i.as(Bi);return{hasMore:n,token:a,templates:r}}))}getMessageTemplate(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new ji({key:e}),s=yield this._requestQueue.send(t),{template:i}=s.as(Vi);return{template:i}}))}getMessageChangelogs(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS){return t.__awaiter(this,void 0,void 0,(function*(){const r=new pe(t.deundefined(t.undefineNullProps(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},oe),n)))),o=yield this._requestQueue.send(r),{updatedMessages:l,deletedMessagesInfo:d,hasMore:u,nextToken:c}=o.as(me),h=d.map((e=>e.messageId));return l.length>0&&this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),h.length>0&&this._dispatcher.dispatch(new t.MessageRemoveEventCommand({messageIds:h,source:a})),{updatedMessages:l,deletedMessageIds:h,hasMore:u,token:c}}))}}class Qi extends t.InstancedObject{constructor(e,s){super(e),this.targetMessageId=0;const i=s.thread_info,n=s.parent_message_id,r=s.channel_url,o=s.channel_type;i&&t.isTypeOf("object",i)&&t.isTypeOf("number",n)&&t.isTypeOf("string",r)&&t.isTypeOf("string",o)&&(this.threadInfo=new a(e,i),this.targetMessageId=n,this.channelUrl=r,this.channelType=o)}}const Gi={channelUrl:"",channelType:t.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1};class Ki extends t.APIRequestCommand{constructor({channelCustomType:e,keyword:s,limit:i,reverse:n,exactMatch:a,channelUrl:r,order:o,messageTimestampFrom:l,messageTimestampTo:d,advancedQuery:u,targetFields:c,nextToken:h}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_SEARCH}/messages`,this.params={custom_type:e,query:s,limit:i,reverse:n,exact_match:a,channel_url:r,message_ts_from:l,message_ts_to:d,sort_field:o,advanced_query:u,target_fields:c,after:h}}}class Hi extends t.APIResponseCommand{constructor(e,t){super(e,t),this.messages=t.results.map((t=>W(e,t))),this.hasNext=t.has_next,this.nextToken=t.end_cursor,this.totalCount=t.total_count}}var Wi;exports.MessageSearchOrder=void 0,(Wi=exports.MessageSearchOrder||(exports.MessageSearchOrder={})).SCORE="score",Wi.TIMESTAMP="ts";class Yi extends t.BaseListQuery{constructor(e,t){var s,i,n,a,r,o,l,d,u;super(e,t),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=t.keyword,this.reverse=null!==(s=t.reverse)&&void 0!==s&&s,this.exactMatch=null!==(i=t.exactMatch)&&void 0!==i&&i,this.channelUrl=null!==(n=t.channelUrl)&&void 0!==n?n:"",this.channelCustomType=null!==(a=t.channelCustomType)&&void 0!==a?a:"",this.messageTimestampFrom=null!==(r=t.messageTimestampFrom)&&void 0!==r?r:null,this.messageTimestampTo=null!==(o=t.messageTimestampTo)&&void 0!==o?o:null,this.order=null!==(l=t.order)&&void 0!==l?l:exports.MessageSearchOrder.SCORE,this.advancedQuery=null!==(d=t.advancedQuery)&&void 0!==d&&d,this.targetFields=null!==(u=t.targetFields)&&void 0!==u?u:null}_validate(){return super._validate()&&t.isTypeOf("string",this.keyword)&&this.keyword.length>0&&t.isTypeOf("boolean",this.reverse)&&t.isTypeOf("boolean",this.exactMatch)&&t.isTypeOf("string",this.channelUrl)&&t.isTypeOf("string",this.channelCustomType)&&(t.isTypeOf("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(t.isTypeOf("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&t.isEnumOf(exports.MessageSearchOrder,this.order)&&t.isTypeOf("boolean",this.advancedQuery)&&t.isArrayOf("string",this.targetFields,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Ki(t.undefineNullProps(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),i=yield e.send(s),{messages:n,hasNext:a,nextToken:r,totalCount:o}=i.as(Hi);return this._nextToken=r,this._hasNext=a,this._isLoading=!1,this.totalCount=o,n}return[]}throw t.SendbirdError.invalidParameters}))}}exports.AdminMessage=V,exports.AppleCriticalAlertOptions=u,exports.BanUserEventCommand=At,exports.BannedUserListQuery=Ye,exports.BaseChannel=Es,exports.BaseMessage=q,exports.BaseMessageUpdateParamsDefault=Le,exports.BaseStore=_i,exports.Config=bs,exports.CreateScheduledUserMessageResponseCommand=Ht,exports.DEFAULT_FEED_LIMIT=100,exports.DEFAULT_GROUPCHANNEL_LIMIT=100,exports.DEFAULT_MESSAGE_LIMIT=100,exports.DEFAULT_NOTIFICATION_LIMIT=100,exports.Feedback=h,exports.FileMessage=Y,exports.FileMessageEventCommand=ee,exports.FreezeEventCommand=Pt,exports.IndexedDbStore=class extends _i{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:104857600})),this._storeName=vi,this._state=Ii.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}isTransactionInactiveError(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}_putToObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.put(s);n.addEventListener("success",(e=>{t(e.target.result)})),n.addEventListener("error",(()=>{i("Failed to write.")}))}))}))}_deleteFromObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.delete(s);n.addEventListener("success",(()=>t(s))),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_openDatabase(e){return new Promise(((t,s)=>{if(this._indexedDb){this._state=Ii.OPENING;const i=this._indexedDb.open(e);i.addEventListener("upgradeneeded",(e=>{e.target.result.createObjectStore(vi,{keyPath:"key"})})),i.addEventListener("success",(s=>{this._state=Ii.OPEN,this._database=s.target.result,this._openJobQueue.forEach((e=>e())),this._openJobQueue=[],this._database.onclose=()=>{this._database=void 0,this._state=Ii.OPENING,setTimeout((()=>{this._openDatabase(e)}),5)},t(this._database)})),i.addEventListener("error",(e=>{this._state=Ii.UNINITIALIZED,s(e.target.error)}))}else s(Os.storeNotAvailable)}))}_getObjectStore(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);switch(this._state){case Ii.UNINITIALIZED:case Ii.OPEN:throw Os.storeNotInitialized;case Ii.OPENING:case Ii.CLOSED:return new Promise((t=>{this._openJobQueue.push((()=>t(this._getObjectStore(e))))}));default:return yield this._getObjectStore(e)}}))}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readonly");return yield new Promise(((t,s)=>{const i=e.getAllKeys();i.addEventListener("success",(e=>{t(e.target.result)})),i.addEventListener("error",(e=>s(e.target.error)))}))}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readonly");return yield new Promise(((s,i)=>{const n=t.get(e);n.addEventListener("success",(e=>{var t;s(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._putToObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._putToObjectStore(t,s)}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._deleteFromObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._deleteFromObjectStore(t,s)}}))}_triggerDatabaseClose(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}checkAvailability(){return t.__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 Os.storeNotAvailable;if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!ni())throw Os.storeNotAvailable;if(ni()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")){if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Os.storeNotAvailableInPrivateBrowsing}else yield new Promise(((e,t)=>{if(this._indexedDb)try{const s=this._indexedDb.open("_testMozilla");s.onerror=()=>t(Os.storeNotAvailableInPrivateBrowsing),s.onsuccess=s=>{if(s.target.result.close(),this._indexedDb){const t=this._indexedDb.deleteDatabase("_testMozilla");t.onerror=()=>e(),t.onsuccess=()=>e()}else t(Os.storeNotAvailable)}}catch(e){t(Os.storeNotAvailableInPrivateBrowsing)}else t(Os.storeNotAvailable)}))}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yield this.checkAvailability(),yield this._openDatabase(e),yield this._resetIfEncryptionChanged()}))}clear(){const e=Object.create(null,{clear:{get:()=>super.clear}});return t.__awaiter(this,void 0,void 0,(function*(){yield e.clear.call(this);const t=yield this._getObjectStore("readwrite");return yield new Promise(((e,s)=>{const i=t.clear();i.addEventListener("success",(()=>e())),i.addEventListener("error",(e=>s(e.target.error)))}))}))}},exports.Logger=class{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)}},exports.MemoryStore=fi,exports.MessageBroadcast=Di,exports.MessageCache=Ri,exports.MessageFilter=Mi,exports.MessageForm=k,exports.MessageFormItem=L,exports.MessageManager=$i,exports.MessageMetaArray=m,exports.MessageRequestHandler=Ie,exports.MessageRetrievalParamsDefault=Gi,exports.MessageReviewInfo=$,exports.MessageSearchQuery=Yi,exports.MessageThreadInfoUpdatedEventCommand=N,exports.MultipleFilesMessage=G,exports.MultipleFilesMessageRequestHandler=ps,exports.MuteUserEventCommand=bt,exports.MutedUserListQuery=Ke,exports.NESTDB_FEEDCHANNEL_COLLECTION_KEY="url",exports.NESTDB_FEEDCHANNEL_COLLECTION_NAME="FeedChannel",exports.NESTDB_GROUPCHANNEL_COLLECTION_KEY="url",exports.NESTDB_GROUPCHANNEL_COLLECTION_NAME="GroupChannel",exports.NESTDB_MESSAGE_COLLECTION_KEY="messageId",exports.NESTDB_MESSAGE_COLLECTION_NAME=ds,exports.NESTDB_NOTIFICATION_COLLECTION_KEY="notificationId",exports.NESTDB_NOTIFICATION_COLLECTION_NAME=us,exports.NESTDB_POLL_COLLECTION_KEY="pollId",exports.NESTDB_POLL_COLLECTION_NAME="Poll",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY="reqId",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME=wi,exports.NestDB=class{constructor({name:e,version:t,store:s,config:i}){this.name=e,this._version=t,this._state=exports.NestDBState.INIT,this._config=i||new bs({dbname:e}),this._store=s,this._event={success:Us,error:Us,storeReplaced:Us,upgrade:ks},this._collections=new Map,this._globalMutex=new di(`${this.name}.lock`),this._config.disableLogger&&pi.off(),new Js({dbname:e,limit:this._config.cacheLimit})}get version(){return this._version}get state(){return this._state}get store(){return this._store}estimateUsage(){return t.__awaiter(this,void 0,void 0,(function*(){return yield(e=this._store,t.__awaiter(void 0,void 0,void 0,(function*(){return yield e.usage()})));var e}))}commitSchema(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._state!==exports.NestDBState.OPENING)throw Os.databaseSchemaNotOnUpgrade;yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){const{collectionName:t,keyName:s,index:i=[]}=e;this._collections.has(t)||this._collections.set(t,new ui({dbname:this.name,collectionName:t,keyName:s,indexes:i,store:this._store}));const n=this._collections.get(t);n&&(yield n.init())})))))}))}open(){var e;return t.__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=(s=this.name,`${Bs(s)}.metadata`),n={version:0,collectionNames:[]},a=null!==(e=yield this._store.get(i))&&void 0!==e?e:n;return new Promise(((e,s)=>{const n=e=>{a.versiont.__awaiter(this,void 0,void 0,(function*(){if(s)e({continued:!1,err:s});else{a.version++,a.collectionNames=Array.from(this._collections.keys());try{yield this._store.set({key:i,value:a}),e({continued:!0})}catch(t){e({continued:!1,err:t})}}})))):e({continued:!1})},r=i=>{const{continued:o=!1,err:l=null}=i;if(o)setTimeout((()=>n(r)),10);else if(l)pi.error(l.message),this._globalMutex.unlock(),this._event.error(l),s(l);else{const i=[];a.collectionNames.forEach((e=>{const s=this._collections.get(e);s&&s.state===Ss.READY||i.push((()=>t.__awaiter(this,void 0,void 0,(function*(){const t=yield ui.metadataOf(this.name,e,this._store);if(t){const s=new ui({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:t.indexes,store:this._store});this._collections.set(e,s),yield s.init()}})))())})),Promise.all(i).then((()=>{this._state=exports.NestDBState.OPENED,this._globalMutex.unlock(),this._event.success(),e()})).catch((e=>{pi.error(e.message),this._globalMutex.unlock(),this._event.error(e),s(e)}))}};n(r)}))}catch(e){switch(e.code){case Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:pi.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new fi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;case Ms.STORE_NOT_AVAILABLE:pi.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 fi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;default:throw pi.error(e.message),this._globalMutex.unlock(),this._event.error(e),e}}}var s}))}close(){this._collections.forEach((e=>e.close())),this._state=exports.NestDBState.CLOSED}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this._collections.values()).map((e=>e.clear())))}))}reset(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.name);e&&e.clearForDatabase(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]=ks;else this._event[e]=Us}collection(e){const t=this._collections.get(e);if(t)return t;throw Os.collectionNotReady}},exports.NestDBError=Os,exports.NotificationMessage=H,exports.NotificationMessageCache=ki,exports.OGImage=l,exports.OGMetaData=d,exports.OperatorListQuery=ze,exports.PENDING_MESSAGE_DELAY=2,exports.PinnedMessage=ms,exports.PinnedMessageListQuery=ys,exports.Plugin=z,exports.PollVoteEventCommand=ls,exports.PreviousMessageListQuery=$e,exports.Reaction=o,exports.ReactionEvent=r,exports.ReadAPIRequestCommand=v,exports.ReadAPIResponseCommand=E,exports.ReadEventCommand=I,exports.ReadRequestCommand=f,exports.ReadStatus=y,exports.RestrictedUser=ve,exports.RestrictionInfo=fe,exports.ScheduledFileMessageCreateParamsDefault=Ci,exports.ScheduledUserMessageCreateParamsDefault=Ai,exports.SendableMessage=F,exports.Sender=p,exports.ThreadInfo=a,exports.ThreadInfoUpdateEvent=Qi,exports.Thumbnail=s,exports.UnbanUserEventCommand=wt,exports.UnmuteUserEventCommand=St,exports.UnsentMessageCache=Pi,exports.UpdateFileMessageEventCommand=Bt,exports.UpdateMetaCounterEventCommand=vt,exports.UpdateMetaDataEventCommand=lt,exports.UpdateUserMessageEventCommand=qt,exports.UploadFileRequestCommand=i,exports.UploadFileResponseCommand=n,exports.UploadedFileInfo=w,exports.UserMessage=Q,exports.UserMessageEventCommand=Lt,exports.UserMessageUpdateParamsDefault=qe,exports.createFileMessageCreateParams=Re,exports.createFileMessageCreateParamsFromFailedFileMessage=xe,exports.createMultipleFilesMessageCreateParams=function(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((e=>{var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((e=>({maxWidth:e.width,maxHeight:e.height}))),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))},exports.createUserMessageCreateParams=Se,exports.createUserMessageCreateParamsFromFailedUserMessage=Oe,exports.getMessageIndexBy=Si,exports.getNotificationMessageIndexBy=Oi,exports.parseMessagePayload=W,exports.payloadifyMessage=e=>{if(e.notificationId)return H.payloadify(e);switch(e.messageType){case t.MessageType.USER:return Q.payloadify(e);case t.MessageType.FILE:return e.fileInfoList?G.payloadify(e):Y.payloadify(e);case t.MessageType.ADMIN:return V.payloadify(e);default:throw t.SendbirdError.unknown}},exports.validateBaseMessageUpdateParams=De,exports.validateMessageRetrievalParams=e=>t.isTypeOf("string",e.channelUrl)&&t.isEnumOf(t.ChannelType,e.channelType)&&t.isTypeOf("number",e.messageId)&&t.isTypeOf("boolean",e.includeReactions,!0)&&t.isTypeOf("boolean",e.includeMetaArray,!0)&&t.isTypeOf("boolean",e.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",e.includeThreadInfo,!0),exports.validateScheduledFileMessageCreateParams=e=>Te(e)&&t.isTypeOf("number",e.scheduledAt)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),exports.validateScheduledUserMessageCreateParams=e=>Ae(e)&&t.isTypeOf("number",e.scheduledAt,!0),exports.validateUserMessageUpdateParams=Fe; diff --git a/cjs/lib/__bundle-1a495950.cjs b/cjs/lib/__bundle-1a495950.cjs deleted file mode 100644 index e2b3c16..0000000 --- a/cjs/lib/__bundle-1a495950.cjs +++ /dev/null @@ -1,2 +0,0 @@ -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.14.4";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.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.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",t[t.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",t[t.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",t[t.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",t[t.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",t[t.SESSION_REVOKED=400310]="SESSION_REVOKED",t[t.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",t[t.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",t[t.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",t[t.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",t[t.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",t[t.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",t[t.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",t[t.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",t[t.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",t[t.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",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.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",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.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_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",t[t.USER_DEACTIVATED=900021]="USER_DEACTIVATED",t[t.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";const n=e=>!(e instanceof o&&!e.shouldThrowOutside);class o extends Error{constructor({code:e=0,message:t=""}){super(t),this.shouldThrowOutside=!1,this._detail="",this.name="SendbirdError",this.code=e,Object.setPrototypeOf(this,o.prototype)}get detail(){return this._detail}setDetail(e){this._detail=e}get isInvalidTokenError(){return this.code===exports.SendbirdErrorCode.INVALID_TOKEN}get isSessionExpiredError(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}get isSessionTokenExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}get isSessionKeyExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}get isSessionInvalidatedError(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}get isSessionRevokedError(){return this.code===exports.SendbirdErrorCode.SESSION_REVOKED}get isUserAuthDeactivedError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED}get isUserAuthDeletedOrNotFoundError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}get isNetworkError(){return this.code===exports.SendbirdErrorCode.NETWORK_ERROR||this.code===exports.SendbirdErrorCode.NETWORK_ROUTING_ERROR}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 xmlHttpRequestNotSupported(){return new o({code:exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}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 channelTypeNotSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}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 tooManyRequests(){return new o({code:exports.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}static get alreadyConnectedAsAnotherUser(){return new o({code:exports.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}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."})}static get statLogUploadLimitExceededError(){return new o({code:exports.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}static get malformedDataError(){return new o({code:exports.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}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,exports.SendbirdErrorCode.USER_DEACTIVATED,exports.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],a=[exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.CONNECTION_REQUIRED],l=(e,t,s=!1)=>!(!s||!_(t))||("string"!=typeof e?"object"==typeof e?d(e,t):c(e,t):typeof t===e),d=(e,t,s=!1)=>!(!s||!_(t))||Object.values(e).includes(t),c=(e,t)=>t instanceof e,h=(e,t,s=!1)=>!(!s||!_(t))||Array.isArray(t)&&t.every((t=>l(e,t))),u=(e,t=!1)=>{if(t&&_(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},_=e=>null==e;class p{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 E={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=exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=i}get maxSize(){return this._maxSize}get clearOrder(){return this._clearOrder}get clearOrderComparator(){var e;return this._clearOrder===exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}get enableAutoResend(){return this._enableAutoResend}}var A;exports.SessionService=void 0,(A=exports.SessionService||(exports.SessionService={})).FEED="feed",A.CHAT="chat",A.CHAT_API="chat_api";class N{constructor(){this.isRefreshing=!1}get hasSession(){return!!this.sessionKey}get hasChatServicePermission(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(exports.SessionService.CHAT))}clear(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}const w=()=>{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 b{constructor({container:e}){this._container={},this._container=e,this.key=w()}_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(){Object.keys(this._container).forEach((e=>{var t;null===(t=this._container[e])||void 0===t||t.delete(this.key)}))}}class I{constructor(){this._container={}}on(e,t){return new b({container:this._container}).on(e,t)}once(e,t){return new b({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 I}on(e){return this._dispatcher.on("event",e)}once(e){return this._dispatcher.once("event",e)}dispatch(e){this._dispatcher.dispatch("event",e)}}class R{}const k=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},O=e=>{if(null!=e){if("object"==typeof e){if(Array.isArray(e)){const t=[...e];for(let e=0;e{null===e[t]&&delete e[t]})),e}return e}};var D,L,U,P,M,q,F,H,V,z,G,K,B;exports.ChannelType=void 0,(D=exports.ChannelType||(exports.ChannelType={})).BASE="base",D.GROUP="group",D.OPEN="open",D.FEED="feed",exports.Role=void 0,(L=exports.Role||(exports.Role={})).OPERATOR="operator",L.NONE="none",exports.MutedState=void 0,(U=exports.MutedState||(exports.MutedState={})).MUTED="muted",U.UNMUTED="unmuted",exports.MessageType=void 0,(P=exports.MessageType||(exports.MessageType={})).BASE="base",P.USER="user",P.FILE="file",P.ADMIN="admin",exports.MessageTypeFilter=void 0,(M=exports.MessageTypeFilter||(exports.MessageTypeFilter={})).ALL="",M.USER="MESG",M.FILE="FILE",M.ADMIN="ADMM",exports.ServerSideMessageType=void 0,(q=exports.ServerSideMessageType||(exports.ServerSideMessageType={})).USER="MESG",q.FILE="FILE",q.ADMIN="ADMM",exports.MentionType=void 0,(F=exports.MentionType||(exports.MentionType={})).USERS="users",F.CHANNEL="channel",exports.ReplyType=void 0,(H=exports.ReplyType||(exports.ReplyType={})).ALL="all",H.NONE="none",H.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",exports.PushNotificationDeliveryOption=void 0,(V=exports.PushNotificationDeliveryOption||(exports.PushNotificationDeliveryOption={})).DEFAULT="default",V.SUPPRESS="suppress",exports.SendingStatus=void 0,(z=exports.SendingStatus||(exports.SendingStatus={})).PENDING="pending",z.SCHEDULED="scheduled",z.SUCCEEDED="succeeded",z.FAILED="failed",z.CANCELED="canceled",exports.MessageReviewStatus=void 0,(G=exports.MessageReviewStatus||(exports.MessageReviewStatus={})).INREVIEW="InReview",G.APPROVED="Approved",exports.NotificationPriority=void 0,(K=exports.NotificationPriority||(exports.NotificationPriority={})).HIGH="high",K.NORMAL="normal",K.LOW="low",exports.MessageTemplateListOrder=void 0,(B=exports.MessageTemplateListOrder||(exports.MessageTemplateListOrder={})).CREATED_AT="created_at",B.UPDATED_AT="updated_at";const Q="v3",j=`/${Q}/users`,$=`/${Q}/sdk/users`,W=`/${Q}/storage/file`,Z=`/${Q}/group_channels`,Y=`/${Q}/sdk/group_channels`,X=`/${Q}/open_channels`,J=`/${Q}/sdk/open_channels`,ee=`/${Q}/search`,te=`/${Q}/report`,se=`/${Q}/emojis`,ie=`/${Q}/emoji_categories`,ne=`/${Q}/polls`,oe=`/${Q}/scheduled_messages`,re=`/${Q}/sdk/ui_kit/configuration`,ae=`/${Q}/sdk/statistics`,le=`/${Q}/notifications`,de=`/${Q}/notifications/users`,ce=`/${Q}/message_templates`,he=`/${Q}/sdk/push_delivery`,ue=`/${Q}/forms`,_e=e=>{switch(e){case exports.ChannelType.FEED:case exports.ChannelType.GROUP:return Z;case exports.ChannelType.OPEN:return X;default:return null}},pe=(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},Ee=(e,t,s)=>{var i;let n=t||new FormData;for(const t in e){if(!e.hasOwnProperty(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=Ee(o,n,r)}return n};var ge;exports.APIRequestMethod=void 0,(ge=exports.APIRequestMethod||(exports.APIRequestMethod={})).GET="GET",ge.POST="POST",ge.PUT="PUT",ge.DELETE="DELETE";class fe extends R{constructor(){super(...arguments),this.params={},this.requireAuth=!0,this.headers={},this.requestId=w()}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=k(this.params);return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${this.encodeParams(e[t])}`)).join("&")}`}get payload(){const e=k(this.params);return Object.keys(e).some((t=>u(e[t])))?Ee(e):JSON.stringify(e)}get hasSessionKey(){return void 0!==this.headers["Session-Key"]}}class ve extends R{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 Se extends R{constructor(e){super(),this.requestId=e}}class me extends R{constructor({expires_in:e,reason:t=exports.SendbirdErrorCode.SESSION_KEY_EXPIRED,message:s=""}){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:case exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED:case exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND:this.error=new o({code:t,message:s})}}get invalidateSessionToken(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}class Ce extends R{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 Ce(e,s,i)}}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}as(e){return new e(this._iid,this.code,this.payload)}}class Te extends R{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:w(),this.ackRequired=t,this.payload.req_id=this.requestId}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}}class ye extends fe{constructor({userId:e,authToken:t,services:s,expiringSession:i=!0}){super(),this.path=`${j}/${e}/session_key`,this.method=exports.APIRequestMethod.POST,this.params=k({token:t,services:s,expiring_session:!!i}),this.requireAuth=!1}}class Ae extends Te{constructor({authToken:e,expiringSession:t=!0,requestId:s}){super({code:"LOGI",payload:k({token:e,expiring_session:t?1:0,req_id:s}),ackRequired:!0})}}class Ne extends ve{constructor(e,t){super(e,t);const{key:s,expires_at:i,services:n}=t;this.key=s,this.expiresAt=i,this.services=n}}class we extends Ce{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):null}}class be extends R{constructor(e){super(),this.statLog=e}}class Ie extends R{constructor({request:e,deferred:t,error:s=o.requestFailed}){super(),this.request=e,this.deferred=t,this.error=s}}var xe;exports.StatType=void 0,(xe=exports.StatType||(exports.StatType={})).FEATURE_LOCALCACHE="feature:local_cache",xe.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",xe.NOTIFICATION="noti:stats",xe.WEBSOCKET_CONNECT="ws:connect",xe.API_RESULT="api:result";class Re{constructor({type:e,data:t,ts:s=Date.now()}){this.type=e,this.createdAt=s,this.data=t}static payloadify(e){return k({stat_type:e.type,ts:e.createdAt,data:k(e.data)})}}const ke=()=>"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product,Oe=()=>!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent));var De,Le,Ue;exports.SendbirdProduct=void 0,(De=exports.SendbirdProduct||(exports.SendbirdProduct={})).CHAT="chat",De.CALLS="calls",De.DESK="desk",De.LIVE="live",De.UIKIT_CHAT="uikit-chat",De.UIKIT_LIVE="uikit-live",exports.SendbirdPlatform=void 0,(Le=exports.SendbirdPlatform||(exports.SendbirdPlatform={})).ANDROID="android",Le.IOS="ios",Le.JS="js",Le.UNREAL="unreal",Le.UNITY="unity",Le.REACT_NATIVE="react-native",Le.FLUTTER="flutter",exports.DeviceOsPlatform=void 0,(Ue=exports.DeviceOsPlatform||(exports.DeviceOsPlatform={})).ANDROID="android",Ue.IOS="ios",Ue.WEB="web",Ue.MOBILE_WEB="mobile_web",Ue.WINDOWS="windows";class Pe{}Pe.sendbirdSdkUserAgentWithExtension=e=>{let t={main_sdk_info:`chat/${ke()?exports.SendbirdPlatform.REACT_NATIVE:exports.SendbirdPlatform.JS}/${i.SDK_VERSION}`,device_os_platform:Oe()?"mobile-web":"web",os_version:i.OS_VERSION};if(e){const{sendbirdExtensions:s,deviceOS:i,customData:n={}}=e;i.version&&(t.os_version=i.version),i.platform&&(t.device_os_platform=i.platform),s.length>0&&(t.extension_sdk_info=s.map((({product:e,platform:t,version:s})=>`${e}/${t}/${s}`)).join(",")),Object.keys(t).forEach((e=>delete n[e])),Object.keys(n).length>0&&(t=Object.assign(Object.assign({},t),n))}return Object.entries(t).map((([e,t])=>`${e}=${t}`)).join("&")},Pe.userAgentWithExtension=e=>{const t=ke()?"reactnative":"JS",s=e.sb_syncmanager?`s${e.sb_syncmanager}`:"",n=e.sb_uikit?`u${e.sb_uikit}`:"",o=e["device-os-platform"]?`o${e["device-os-platform"]}`:Oe()?"omobile-web":"oweb";return`${t}/c${i.SDK_VERSION}/${s}/${n}/${o}`};class Me{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=e=>{t(e)}}))}}class qe extends R{constructor(e){super(),this.requestId=e.requestId}}class Fe extends fe{constructor(e){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${_e(e.channelType)}/${e.channelUrl}/messages/${e.messageId}`,e.messageToken&&(this.params=k({mesg_token:e.messageToken}))}}class He{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:o=!1}){this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=t,this._sdkState=s,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof Se&&this.cancel(e.requestId)})),this._logger=n,this._shouldImportFetchCompat=o}_createHeader(e,t){const{appId:s,appVersion:n,sendbirdRuntimeEnvironment:o}=this._sdkState,r=Object.assign(Object.assign({},e.headers),{SendBird:`JS,${i.OS_VERSION},${i.SDK_VERSION},${s}${n?`,${n}`:""}`,"SB-User-Agent":Pe.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":Pe.sendbirdSdkUserAgentWithExtension(o)});return t||(r["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(r["Session-Key"]=this._session.sessionKey),r["App-Id"]=s,this._session&&this._session.authToken&&(r["Access-Token"]=this._session.authToken),r}_statLogApiResult(e,t,s){this._dispatcher.dispatch(new be(new Re({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}})))}_isBodyRequired(e){const{method:t}=e;return t!==exports.APIRequestMethod.GET&&(t!==exports.APIRequestMethod.DELETE||e instanceof Fe)}send(t){return e(this,void 0,void 0,(function*(){const{path:e,method:s,uploadProgressHandler:i}=t,n=this._isBodyRequired(t),{api:r}=this._sdkState,a=`${r.host}${e}${n?"":t.query}`,l=n?t.payload:null,d=this._createHeader(t,l instanceof FormData?l:void 0),c=new AbortController,{signal:h}=c;this._abortControl.set(t.requestId,c);const u=Date.now();try{if(i){const{xmlHttpRequest:e}=yield Promise.resolve().then((function(){return require("./__bundle-552fe22f.cjs")}));try{const s=yield e(this._iid,{requestId:t.requestId,method:t.method,url:a,headers:d,data:null!=l?l:void 0,uploadProgressHandler:i});return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),s}catch(e){if(!(e instanceof o&&e.code===exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED))throw e;this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored.")}}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-6301b3ce.cjs")}))),"function"!=typeof fetch&&(yield Promise.resolve().then((function(){return require("./__bundle-38c66c0d.cjs")})));const e=yield fetch(a,{method:s,body:l,headers:d,signal:h}),n=yield e.json();if(e.ok||e.redirected)return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),new ve(this._iid,n);if(n){const e=new o(n);if(e.isSessionExpiredError){if(this._dispatcher.dispatch(new me({reason:e.code,message:e.message})),!(t instanceof ye)){const s=new Me;return this._dispatcher.dispatch(new Ie({request:t,deferred:s,error:e})),s.promise}throw e}throw e.isSessionInvalidatedError?(this._dispatcher.dispatch(new me({reason:e.code,message:e.message})),e):e}throw o.requestFailed}catch(e){throw this._statLogApiResult(t,u,e),e instanceof o?(this._logger.debug("fail api request",e),e):"AbortError"===(null==e?void 0:e.name)?o.requestCanceled:(this._logger.debug("fail api request",e),o.networkError)}}))}cancel(e){if(this._abortControl.has(e)){this._abortControl.get(e).abort(),this._abortControl.delete(e)}this._dispatcher.dispatch(new qe({requestId:e}))}cancelAll(){for(const e of this._abortControl.values())e.abort();this._abortControl.clear(),this._dispatcher.dispatch(new qe({}))}}const Ve=()=>{}; -/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function ze(e){let t=e.length;for(;--t>=0;)e[t]=0}const Ge=256,Ke=286,Be=30,Qe=15,je=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]),$e=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]),Ze=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ye=new Array(576);ze(Ye);const Xe=new Array(60);ze(Xe);const Je=new Array(512);ze(Je);const et=new Array(256);ze(et);const tt=new Array(29);ze(tt);const st=new Array(Be);function it(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 nt,ot,rt;function at(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ze(st);const lt=e=>e<256?Je[e]:Je[256+(e>>>7)],dt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ct=(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<{ct(e,s[2*t],s[2*t+1])},ut=(e,t)=>{let s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1},_t=(e,t,s)=>{const i=new Array(16);let n,o,r=0;for(n=1;n<=Qe;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]=ut(i[t]++,t))}},pt=e=>{let t;for(t=0;t{e.bi_valid>8?dt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},gt=(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?ht(e,n,t):(o=et[n],ht(e,o+Ge+1,t),r=je[o],0!==r&&(n-=tt[o],ct(e,n,r)),i--,o=lt(i),ht(e,o,s),r=$e[o],0!==r&&(i-=st[o],ct(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--)ft(e,s,r);l=o;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ft(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++,ft(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,E=0;for(u=0;u<=Qe;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,E++),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!==E){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]--,E-=2}while(E>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),_t(s,d,e.bl_count)},mt=(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{ct(e,0+(i?1:0),3),Et(e),dt(e,s),dt(e,~s),s&&e.pending_buf.set(e.window.subarray(t,t+s),e.pending),e.pending+=s};var At=(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(mt(e,e.dyn_ltree,e.l_desc.max_code),mt(e,e.dyn_dtree,e.d_desc.max_code),St(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),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?yt(e,t,s,i):4===e.strategy||o===n?(ct(e,2+(i?1:0),3),vt(e,Ye,Xe)):(ct(e,4+(i?1:0),3),((e,t,s,i)=>{let n;for(ct(e,t-257,5),ct(e,s-1,5),ct(e,i-4,4),n=0;n{Tt||((()=>{let e,t,s,i,n;const o=new Array(16);for(s=0,i=0;i<28;i++)for(tt[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*(et[s]+Ge+1)]++,e.dyn_dtree[2*lt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ct(e,2,3),ht(e,256,Ye),(e=>{16===e.bi_valid?(dt(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 wt=(e,t,s,i)=>{let n=65535&e,o=e>>>16&65535,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};const bt=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 It=(e,t,s,i)=>{const n=bt,o=i+s;e^=-1;for(let s=i;s>>8^n[255&(e^t[s])];return~e},xt={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"},Rt={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:kt,_tr_stored_block:Ot,_tr_flush_block:Dt,_tr_tally:Lt,_tr_align:Ut}=Nt,{Z_NO_FLUSH:Pt,Z_PARTIAL_FLUSH:Mt,Z_FULL_FLUSH:qt,Z_FINISH:Ft,Z_BLOCK:Ht,Z_OK:Vt,Z_STREAM_END:zt,Z_STREAM_ERROR:Gt,Z_DATA_ERROR:Kt,Z_BUF_ERROR:Bt,Z_DEFAULT_COMPRESSION:Qt,Z_FILTERED:jt,Z_HUFFMAN_ONLY:$t,Z_RLE:Wt,Z_FIXED:Zt,Z_DEFAULT_STRATEGY:Yt,Z_UNKNOWN:Xt,Z_DEFLATED:Jt}=Rt,es=258,ts=262,ss=42,is=113,ns=666,os=(e,t)=>(e.msg=xt[t],t),rs=e=>2*e-(e>4?9:0),as=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ls=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 ds=(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))},hs=(e,t)=>{Dt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,cs(e.strm)},us=(e,t)=>{e.pending_buf[e.pending++]=t},_s=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ps=(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=wt(e.adler,t,n,s):2===e.state.wrap&&(e.adler=It(e.adler,t,n,s)),e.next_in+=n,e.total_in+=n,n)},Es=(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-ts?e.strstart-(e.w_size-ts):0,d=e.window,c=e.w_mask,h=e.prev,u=e.strstart+es;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},gs=e=>{const t=e.w_size;let s,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ts)&&(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),ls(e),i+=t),0===e.strm.avail_in)break;if(s=ps(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=ds(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=ds(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,cs(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&&(ps(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&&(ps(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===Ft)&&t!==Pt&&0===e.strm.avail_in&&i<=n)&&(s=i>n?n:i,r=t===Ft&&0===e.strm.avail_in&&s===i?1:0,Ot(e,e.block_start,s,r),e.block_start+=s,cs(e.strm)),r?3:1)},vs=(e,t)=>{let s,i;for(;;){if(e.lookahead=3&&(e.ins_h=ds(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-ts&&(e.match_length=Es(e,s)),e.match_length>=3)if(i=Lt(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=ds(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=ds(e,e.ins_h,e.window[e.strstart+1]);else i=Lt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(hs(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(e,!1),0===e.strm.avail_out)?1:2},Ss=(e,t)=>{let s,i,n;for(;;){if(e.lookahead=3&&(e.ins_h=ds(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=Lt(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=ds(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&&(hs(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Lt(e,0,e.window[e.strstart-1]),i&&hs(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=Lt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(e,!1),0===e.strm.avail_out)?1:2};function ms(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 Cs=[new ms(0,0,0,0,fs),new ms(4,4,8,4,vs),new ms(4,5,16,8,vs),new ms(4,6,32,32,vs),new ms(4,4,16,16,Ss),new ms(8,16,32,32,Ss),new ms(8,16,128,128,Ss),new ms(8,32,128,256,Ss),new ms(32,128,258,1024,Ss),new ms(32,258,258,4096,Ss)];function Ts(){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),as(this.dyn_ltree),as(this.dyn_dtree),as(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),as(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),as(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 ys=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==ss&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==is&&t.status!==ns?1:0},As=e=>{if(ys(e))return os(e,Gt);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?ss:is,e.adler=2===t.wrap?0:1,t.last_flush=-2,kt(t),Vt},Ns=e=>{const t=As(e);var s;return t===Vt&&((s=e.state).window_size=2*s.w_size,as(s.head),s.max_lazy_match=Cs[s.level].max_lazy,s.good_match=Cs[s.level].good_length,s.nice_match=Cs[s.level].nice_length,s.max_chain_length=Cs[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},ws=(e,t,s,i,n,o)=>{if(!e)return Gt;let r=1;if(t===Qt&&(t=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||s!==Jt||i<8||i>15||t<0||t>9||o<0||o>Zt||8===i&&1!==r)return os(e,Gt);8===i&&(i=9);const a=new Ts;return e.state=a,a.strm=e,a.status=ss,a.wrap=r,a.gzhead=null,a.w_bits=i,a.w_size=1<ws(e,t,Jt,15,8,Yt),deflateInit2:ws,deflateReset:Ns,deflateResetKeep:As,deflateSetHeader:(e,t)=>ys(e)||2!==e.state.wrap?Gt:(e.state.gzhead=t,Vt),deflate:(e,t)=>{if(ys(e)||t>Ht||t<0)return e?os(e,Gt):Gt;const s=e.state;if(!e.output||0!==e.avail_in&&!e.input||s.status===ns&&t!==Ft)return os(e,0===e.avail_out?Bt:Gt);const i=s.last_flush;if(s.last_flush=t,0!==s.pending){if(cs(e),0===e.avail_out)return s.last_flush=-1,Vt}else if(0===e.avail_in&&rs(t)<=rs(i)&&t!==Ft)return os(e,Bt);if(s.status===ns&&0!==e.avail_in)return os(e,Bt);if(s.status===ss&&0===s.wrap&&(s.status=is),s.status===ss){let t=Jt+(s.w_bits-8<<4)<<8,i=-1;if(i=s.strategy>=$t||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,_s(s,t),0!==s.strstart&&(_s(s,e.adler>>>16),_s(s,65535&e.adler)),e.adler=1,s.status=is,cs(e),0!==s.pending)return s.last_flush=-1,Vt}if(57===s.status)if(e.adler=0,us(s,31),us(s,139),us(s,8),s.gzhead)us(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)),us(s,255&s.gzhead.time),us(s,s.gzhead.time>>8&255),us(s,s.gzhead.time>>16&255),us(s,s.gzhead.time>>24&255),us(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),us(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(us(s,255&s.gzhead.extra.length),us(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=It(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69;else if(us(s,0),us(s,0),us(s,0),us(s,0),us(s,0),us(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),us(s,3),s.status=is,cs(e),0!==s.pending)return s.last_flush=-1,Vt;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=It(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex+=n,cs(e),0!==s.pending)return s.last_flush=-1,Vt;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=It(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=It(e.adler,s.pending_buf,s.pending-i,i)),cs(e),0!==s.pending)return s.last_flush=-1,Vt;i=0}t=s.gzindexi&&(e.adler=It(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=It(e.adler,s.pending_buf,s.pending-i,i)),cs(e),0!==s.pending)return s.last_flush=-1,Vt;i=0}t=s.gzindexi&&(e.adler=It(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&&(cs(e),0!==s.pending))return s.last_flush=-1,Vt;us(s,255&e.adler),us(s,e.adler>>8&255),e.adler=0}if(s.status=is,cs(e),0!==s.pending)return s.last_flush=-1,Vt}if(0!==e.avail_in||0!==s.lookahead||t!==Pt&&s.status!==ns){let i=0===s.level?fs(s,t):s.strategy===$t?((e,t)=>{let s;for(;;){if(0===e.lookahead&&(gs(e),0===e.lookahead)){if(t===Pt)return 1;break}if(e.match_length=0,s=Lt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(hs(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(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<=es){if(gs(e),e.lookahead<=es&&t===Pt)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+es;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=Lt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=Lt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(hs(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hs(e,!1),0===e.strm.avail_out)?1:2})(s,t):Cs[s.level].func(s,t);if(3!==i&&4!==i||(s.status=ns),1===i||3===i)return 0===e.avail_out&&(s.last_flush=-1),Vt;if(2===i&&(t===Mt?Ut(s):t!==Ht&&(Ot(s,0,0,!1),t===qt&&(as(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),cs(e),0===e.avail_out))return s.last_flush=-1,Vt}return t!==Ft?Vt:s.wrap<=0?zt:(2===s.wrap?(us(s,255&e.adler),us(s,e.adler>>8&255),us(s,e.adler>>16&255),us(s,e.adler>>24&255),us(s,255&e.total_in),us(s,e.total_in>>8&255),us(s,e.total_in>>16&255),us(s,e.total_in>>24&255)):(_s(s,e.adler>>>16),_s(s,65535&e.adler)),cs(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?Vt:zt)},deflateEnd:e=>{if(ys(e))return Gt;const t=e.state.status;return e.state=null,t===is?os(e,Kt):Vt},deflateSetDictionary:(e,t)=>{let s=t.length;if(ys(e))return Gt;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==ss||i.lookahead)return Gt;if(1===n&&(e.adler=wt(e.adler,t,s,0)),i.wrap=0,s>=i.w_size){0===n&&(as(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,gs(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=ds(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,gs(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,Vt},deflateInfo:"pako deflate (from Nodeca project)"};const Is=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var xs={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)Is(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;ks[254]=ks[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&&Rs)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+ks[e[s]]>t?s:t}};var Ds=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 Ls=Object.prototype.toString,{Z_NO_FLUSH:Us,Z_SYNC_FLUSH:Ps,Z_FULL_FLUSH:Ms,Z_FINISH:qs,Z_OK:Fs,Z_STREAM_END:Hs,Z_DEFAULT_COMPRESSION:Vs,Z_DEFAULT_STRATEGY:zs,Z_DEFLATED:Gs}=Rt;function Ks(e){this.options=xs.assign({level:Vs,method:Gs,chunkSize:16384,windowBits:15,memLevel:8,strategy:zs},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 Ds,this.strm.avail_out=0;let s=bs.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(s!==Fs)throw new Error(xt[s]);if(t.header&&bs.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Os.string2buf(t.dictionary):"[object ArrayBuffer]"===Ls.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,s=bs.deflateSetDictionary(this.strm,e),s!==Fs)throw new Error(xt[s]);this._dict_set=!0}}function Bs(e,t){const s=new Ks(t);if(s.push(e,!0),s.err)throw s.msg||xt[s.err];return s.result}Ks.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?qs:Us,"string"==typeof e?s.input=Os.string2buf(e):"[object ArrayBuffer]"===Ls.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===Ps||o===Ms)&&s.avail_out<=6)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else{if(n=bs.deflate(s,o),n===Hs)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),n=bs.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Fs;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},Ks.prototype.onData=function(e){this.chunks.push(e)},Ks.prototype.onEnd=function(e){e===Fs&&(this.result=xs.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qs={Deflate:Ks,deflate:Bs,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Bs(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Bs(e,t)},constants:Rt};const js=16209;var $s=function(e,t){let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A,N;const w=e.state;s=e.next_in,A=e.input,i=s+(e.avail_in-5),n=e.next_out,N=e.output,o=n-(t-e.avail_out),r=n+(e.avail_out-257),a=w.dmax,l=w.wsize,d=w.whave,c=w.wnext,h=w.window,u=w.hold,_=w.bits,p=w.lencode,E=w.distcode,g=(1<>>24,u>>>=S,_-=S,S=v>>>16&255,0===S)N[n++]=65535&v;else{if(!(16&S)){if(64&S){if(32&S){w.mode=16191;break e}e.msg="invalid literal/length code",w.mode=js;break e}v=p[(65535&v)+(u&(1<>>=S,_-=S),_<15&&(u+=A[s++]<<_,_+=8,u+=A[s++]<<_,_+=8),v=E[u&f];;){if(S=v>>>24,u>>>=S,_-=S,S=v>>>16&255,16&S){if(C=65535&v,S&=15,_a){e.msg="invalid distance too far back",w.mode=js;break e}if(u>>>=S,_-=S,S=n-o,C>S){if(S=C-S,S>d&&w.sane){e.msg="invalid distance too far back",w.mode=js;break e}if(T=0,y=h,0===c){if(T+=l-S,S2;)N[n++]=y[T++],N[n++]=y[T++],N[n++]=y[T++],m-=3;m&&(N[n++]=y[T++],m>1&&(N[n++]=y[T++]))}else{T=n-C;do{N[n++]=N[T++],N[n++]=N[T++],N[n++]=N[T++],m-=3}while(m>2);m&&(N[n++]=N[T++],m>1&&(N[n++]=N[T++]))}break}if(64&S){e.msg="invalid distance code",w.mode=js;break e}v=E[(65535&v)+(u&(1<>3,s-=m,_-=m<<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,E=0,g=0,f=0,v=0,S=0,m=0,C=0,T=0,y=0,A=0,N=null;const w=new Uint16Array(16),b=new Uint16Array(16);let I,x,R,k=null;for(E=0;E<=Ws;E++)w[E]=0;for(g=0;g=1&&0===w[v];v--);if(S>v&&(S=v),0===v)return n[o++]=20971520,n[o++]=20971520,a.bits=1,0;for(f=1;f0&&(0===e||1!==v))return-1;for(b[1]=0,E=1;E852||2===e&&y>592)return 1;for(;;){I=E-C,r[g]+1=p?(x=k[r[g]-p],R=N[r[g]-p]):(x=96,R=0),d=1<>C)+c]=I<<24|x<<16|R}while(0!==c);for(d=1<>=1;if(0!==d?(A&=d-1,A+=d):A=0,g++,0==--w[E]){if(E===v)break;E=t[s+r[g]]}if(E>S&&(A&u)!==h){for(0===C&&(C=S),_+=f,m=E-C,T=1<852||2===e&&y>592)return 1;h=A&u,n[h]=S<<24|m<<16|_-o}}return 0!==A&&(n[_+A]=E-C<<24|64<<16),a.bits=S,0};const{Z_FINISH:ti,Z_BLOCK:si,Z_TREES:ii,Z_OK:ni,Z_STREAM_END:oi,Z_NEED_DICT:ri,Z_STREAM_ERROR:ai,Z_DATA_ERROR:li,Z_MEM_ERROR:di,Z_BUF_ERROR:ci,Z_DEFLATED:hi}=Rt,ui=16180,_i=16190,pi=16191,Ei=16192,gi=16194,fi=16199,vi=16200,Si=16206,mi=16209,Ci=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ti(){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 yi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Ai=e=>{if(yi(e))return ai;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=ui,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,ni},Ni=e=>{if(yi(e))return ai;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ai(e)},wi=(e,t)=>{let s;if(yi(e))return ai;const i=e.state;return t<0?(s=0,t=-t):(s=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ai:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=s,i.wbits=t,Ni(e))},bi=(e,t)=>{if(!e)return ai;const s=new Ti;e.state=s,s.strm=e,s.window=null,s.mode=ui;const i=wi(e,t);return i!==ni&&(e.state=null),i};let Ii,xi,Ri=!0;const ki=e=>{if(Ri){Ii=new Int32Array(512),xi=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(ei(1,e.lens,0,288,Ii,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ei(2,e.lens,0,32,xi,0,e.work,{bits:5}),Ri=!1}e.lencode=Ii,e.lenbits=9,e.distcode=xi,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.whavebi(e,15),inflateInit2:bi,inflate:(e,t)=>{let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A=0;const N=new Uint8Array(4);let w,b;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(yi(e)||!e.output||!e.input&&0!==e.avail_in)return ai;s=e.state,s.mode===pi&&(s.mode=Ei),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,y=ni;e:for(;;)switch(s.mode){case ui:if(0===s.wrap){s.mode=Ei;break}for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>>8&255,s.check=It(s.check,N,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=mi;break}if((15&d)!==hi){e.msg="unknown compression method",s.mode=mi;break}if(d>>>=4,c-=4,T=8+(15&d),0===s.wbits&&(s.wbits=T),T>15||T>s.wbits){e.msg="invalid window size",s.mode=mi;break}s.dmax=1<>8&1),512&s.flags&&4&s.wrap&&(N[0]=255&d,N[1]=d>>>8&255,s.check=It(s.check,N,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,N[2]=d>>>16&255,N[3]=d>>>24&255,s.check=It(s.check,N,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&&(N[0]=255&d,N[1]=d>>>8&255,s.check=It(s.check,N,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=It(s.check,N,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&&(T=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+_),T)),512&s.flags&&4&s.wrap&&(s.check=It(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{T=i[o+_++],s.head&&T&&s.length<65536&&(s.head.name+=String.fromCharCode(T))}while(T&&_>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=pi;break;case 16189:for(;c<32;){if(0===a)break e;a--,d+=i[o++]<>>=7&c,c-=7&c,s.mode=Si;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(ki(s),s.mode=fi,t===ii){d>>>=2,c-=2;break e}break;case 2:s.mode=16196;break;case 3:e.msg="invalid block type",s.mode=mi}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=mi;break}if(s.length=65535&d,d=0,c=0,s.mode=gi,t===ii)break e;case gi: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=pi;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=mi;break}s.have=0,s.mode=16197;case 16197:for(;s.have>>=3,c-=3}for(;s.have<19;)s.lens[I[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,w={bits:s.lenbits},y=ei(0,s.lens,0,19,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid code lengths set",s.mode=mi;break}s.have=0,s.mode=16198;case 16198:for(;s.have>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=g,c-=g,s.lens[s.have++]=v;else{if(16===v){for(b=g+2;c>>=g,c-=g,0===s.have){e.msg="invalid bit length repeat",s.mode=mi;break}T=s.lens[s.have-1],_=3+(3&d),d>>>=2,c-=2}else if(17===v){for(b=g+3;c>>=g,c-=g,T=0,_=3+(7&d),d>>>=3,c-=3}else{for(b=g+7;c>>=g,c-=g,T=0,_=11+(127&d),d>>>=7,c-=7}if(s.have+_>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=mi;break}for(;_--;)s.lens[s.have++]=T}}if(s.mode===mi)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=mi;break}if(s.lenbits=9,w={bits:s.lenbits},y=ei(1,s.lens,0,s.nlen,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid literal/lengths set",s.mode=mi;break}if(s.distbits=6,s.distcode=s.distdyn,w={bits:s.distbits},y=ei(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,w),s.distbits=w.bits,y){e.msg="invalid distances set",s.mode=mi;break}if(s.mode=fi,t===ii)break e;case fi:s.mode=vi;case vi: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,$s(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===pi&&(s.back=-1);break}for(s.back=0;A=s.lencode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,s.length=v,0===f){s.mode=16205;break}if(32&f){s.back=-1,s.mode=pi;break}if(64&f){e.msg="invalid literal/length code",s.mode=mi;break}s.extra=15&f,s.mode=16201;case 16201:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=16202;case 16202:for(;A=s.distcode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,64&f){e.msg="invalid distance code",s.mode=mi;break}s.offset=v,s.extra=15&f,s.mode=16203;case 16203:if(s.extra){for(b=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=mi;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=mi;break}_>s.wnext?(_-=s.wnext,p=s.wsize-_):p=s.wnext-_,_>s.length&&(_=s.length),E=s.window}else E=n,p=r-s.offset,_=s.length;_>l&&(_=l),l-=_,s.length-=_;do{n[r++]=E[p++]}while(--_);0===s.length&&(s.mode=vi);break;case 16205:if(0===l)break e;n[r++]=s.length,l--,s.mode=vi;break;case Si:if(s.wrap){for(;c<32;){if(0===a)break e;a--,d|=i[o++]<{if(yi(e))return ai;let t=e.state;return t.window&&(t.window=null),e.state=null,ni},inflateGetHeader:(e,t)=>{if(yi(e))return ai;const s=e.state;return 2&s.wrap?(s.head=t,t.done=!1,ni):ai},inflateSetDictionary:(e,t)=>{const s=t.length;let i,n,o;return yi(e)?ai:(i=e.state,0!==i.wrap&&i.mode!==_i?ai:i.mode===_i&&(n=1,n=wt(n,t,s,0),n!==i.check)?li:(o=Oi(e,t,s,s),o?(i.mode=16210,di):(i.havedict=1,ni)))},inflateInfo:"pako inflate (from Nodeca project)"};var Li=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 Ui=Object.prototype.toString,{Z_NO_FLUSH:Pi,Z_FINISH:Mi,Z_OK:qi,Z_STREAM_END:Fi,Z_NEED_DICT:Hi,Z_STREAM_ERROR:Vi,Z_DATA_ERROR:zi,Z_MEM_ERROR:Gi}=Rt;function Ki(e){this.options=xs.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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ds,this.strm.avail_out=0;let s=Di.inflateInit2(this.strm,t.windowBits);if(s!==qi)throw new Error(xt[s]);if(this.header=new Li,Di.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Os.string2buf(t.dictionary):"[object ArrayBuffer]"===Ui.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=Di.inflateSetDictionary(this.strm,t.dictionary),s!==qi)))throw new Error(xt[s])}function Bi(e,t){const s=new Ki(t);if(s.push(e),s.err)throw s.msg||xt[s.err];return s.result}Ki.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?Mi:Pi,"[object ArrayBuffer]"===Ui.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=Di.inflate(s,r),o===Hi&&n&&(o=Di.inflateSetDictionary(s,n),o===qi?o=Di.inflate(s,r):o===zi&&(o=Hi));s.avail_in>0&&o===Fi&&s.state.wrap>0&&0!==e[s.next_in];)Di.inflateReset(s),o=Di.inflate(s,r);switch(o){case Vi:case zi:case Hi:case Gi:return this.onEnd(o),this.ended=!0,!1}if(a=s.avail_out,s.next_out&&(0===s.avail_out||o===Fi))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!==qi||0!==a){if(o===Fi)return o=Di.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},Ki.prototype.onData=function(e){this.chunks.push(e)},Ki.prototype.onEnd=function(e){e===qi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=xs.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qi={Inflate:Ki,inflate:Bi,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Bi(e,t)},ungzip:Bi,constants:Rt};const{Deflate:ji,deflate:$i,deflateRaw:Wi,gzip:Zi}=Qs,{Inflate:Yi,inflate:Xi,inflateRaw:Ji,ungzip:en}=Qi;var tn={Deflate:ji,deflate:$i,deflateRaw:Wi,gzip:Zi,Inflate:Yi,inflate:Xi,inflateRaw:Ji,ungzip:en,constants:Rt};const sn=t=>e(void 0,void 0,void 0,(function*(){const e=tn.ungzip(t);return String.fromCharCode.apply(null,e)}));var nn,on;exports.ConnectionState=void 0,(nn=exports.ConnectionState||(exports.ConnectionState={})).CONNECTING="CONNECTING",nn.OPEN="OPEN",nn.CLOSED="CLOSED";class rn extends I{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}get ws(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}_handleMessage(e){e.split("\n").forEach((e=>{if(e){const t=Ce.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 me(t.payload);e.expiresIn>=0&&this._dispatcher.dispatch(e)}}else"NOOP"===t.code||this.dispatch("message",t)}}))}connect(t,s=""){return e(this,void 0,void 0,(function*(){this._ws=new WebSocket(t,encodeURIComponent(s)),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*(){try{const e=yield sn(s.result);this._handleMessage(e)}catch(e){this.error(e)}}))}else if(t.data instanceof ArrayBuffer)try{const e=yield sn(new Uint8Array(t.data));this._handleMessage(e)}catch(e){this.error(e)}else if("undefined"!=typeof Buffer&&t.data instanceof Buffer)try{const e=t.data,s=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),i=yield sn(s);this._handleMessage(i)}catch(e){this.error(e)}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._ws.onopen=Ve,this._ws.onmessage=Ve,this._ws.onerror=Ve,this.connectionState!==exports.ConnectionState.CLOSED?(this._ws.onclose=()=>{this.dispatch("close"),e()},this._ws.close(),this._ws=void 0):e()):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 an extends R{constructor({all:e,feed:t,custom_types:s,ts:i}){super(),this.all=e,this.feed=t,this.customTypes=s,this.ts=i}}class ln{constructor(e,{session: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 He(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this.websocketClient=new rn(e,{sdkState:s,dispatcher:i,logger:n}),this.websocketClient.on("message",(e=>{if(e.payload.unread_cnt&&this._dispatcher.dispatch(new an(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 Me;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",t.requestId,i),e.reject(i)):(this._logger.debug("receive websocket ack",t.requestId,t),this._logger.debug("receive websocket ack",n),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 fe)return yield this._sendApiRequest(t);if(t instanceof Te)return yield this._sendWebsocketRequest(t);throw o.invalidParameters}))}cancel(e){this.apiClient.cancel(e)}cancelAll(){this.apiClient.cancelAll()}}exports.ConnectionStateType=void 0,(on=exports.ConnectionStateType||(exports.ConnectionStateType={}))[on.NONE=0]="NONE",on[on.INITIALIZED=1]="INITIALIZED",on[on.CONNECTING=2]="CONNECTING",on[on.CONNECTED=3]="CONNECTED",on[on.RECONNECTING=4]="RECONNECTING",on[on.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",on[on.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",on[on.LOGOUT=7]="LOGOUT";class dn extends R{constructor({stateType:e}){super(),this.stateType=e}}class cn extends R{}class hn extends R{}class un extends R{}class _n{constructor(e){var t,s,i,n;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(s=e.feed_channels)&&void 0!==s?s:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(n=e.settings_updated_at)&&void 0!==n?n:0}static payloadify(e){return k(O({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}class pn{constructor(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}static payloadify(e){return k(O({last_updated_at:e.lastUpdatedAt}))}}class En{constructor(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}static payloadify(e){return k(O({template_list_token:e.token}))}}class gn{constructor(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}){this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}static payloadify(e){return k(O({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}class fn{constructor(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}){this.default=new gn(e.default),this.realTime=new gn(e.realtime)}static payloadify(e){return k(O({default:gn.payloadify(e.default),realtime:gn.payloadify(e.realTime)}))}}const vn=1048576;var Sn,mn;exports.UnreadCountThreadingPolicy=void 0,(Sn=exports.UnreadCountThreadingPolicy||(exports.UnreadCountThreadingPolicy={}))[Sn.NONE=0]="NONE",Sn[Sn.INCLUDE_REPLY=1]="INCLUDE_REPLY",Sn[Sn.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Sn[Sn.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",exports.LastMessageThreadingPolicy=void 0,(mn=exports.LastMessageThreadingPolicy||(exports.LastMessageThreadingPolicy={}))[mn.NONE=0]="NONE",mn[mn.INCLUDE_REPLY=1]="INCLUDE_REPLY",mn[mn.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",mn[mn.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";class Cn{constructor(e={}){var t,s,i,n,o,r,a;this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*vn: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.unreadCountThreadingPolicy=null!==(o=e.unread_cnt_threading_policy)&&void 0!==o?o:exports.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(r=e.last_msg_threading_policy)&&void 0!==r?r:exports.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new pn(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new _n(e.notifications):null,this.messageTemplateInfo=e.message_template?new En(e.message_template):null,this.statConfigInfo=e.log_publish_config?new fn(e.log_publish_config):new fn}static payloadify(e){return k(O({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/vn,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?pn.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?_n.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?En.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?fn.payloadify(e.statConfigInfo):null}))}}class Tn{constructor(e){this._iid="",this._iid=e}static payloadify(e){return{}}}class yn extends fe{constructor({userId:e,metadata:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${j}/${e}/metadata`,this.params={metadata:t}}}class An extends ve{constructor(e,t){super(e,t),this.metaData=t}}class Nn extends fe{constructor({userId:e,metadata:t,upsert:s}){super(),this.method=exports.APIRequestMethod.PUT,this.path=`${j}/${e}/metadata`,this.params={metadata:t,upsert:s}}}class wn extends ve{constructor(e,t){super(e,t),this.metadata=t}}class bn extends fe{constructor({userId:e,metadataKey:t}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${j}/${e}/metadata/${t}`}}class In extends fe{constructor({userId:e}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${j}/${e}/metadata`}}const xn=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return s._iid&&delete s._iid,t&&t(s),s},Rn=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return t&&t(s),s},kn=e=>({do:t=>{e||t()},throw:t=>{if(!e)throw t}});var On;exports.UserOnlineState=void 0,(On=exports.UserOnlineState||(exports.UserOnlineState={})).ONLINE="online",On.OFFLINE="offline",On.NON_AVAILABLE="nonavailable";class Dn extends Tn{constructor(e,t){var s,i,n,o,r,a,c,h,u,_,p,E;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!==(E=t.friend_name)&&void 0!==E?E:null}static payloadify(e){return k(O(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}=Io.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainProfileUrl}?auth=${e.ekey}`:this.plainProfileUrl}serialize(){return xn(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*(){kn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Io.of(this._iid),i=new yn({userId:e.userId,metadata:t}),n=yield s.send(i),{metaData:r}=n.as(An);return this._applyMetaData(r),this.metaData}))}updateMetaData(t,s=!1){return e(this,void 0,void 0,(function*(){kn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:i}=Io.of(this._iid),n=new Nn({userId:e.userId,metadata:t,upsert:s}),r=yield i.send(n),{metadata:a}=r.as(wn);return this._applyMetaData(a),this.metaData}))}deleteMetaData(t){return e(this,void 0,void 0,(function*(){kn(l("string",t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Io.of(this._iid),i=new bn({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}=Io.of(this._iid),s=new In({userId:e.userId});yield t.send(s),this.metaData={}}))}}class Ln extends R{constructor({userProfile:e}){super(),this.userProfile=e}}class Un{constructor(e,t){var s,i,n,o,r,a,l,d,c,h,u,_,p,E;this._iid=e,this.appInfo=new Cn(t),this.user=new Dn(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!==(E=t.back_off_delay)&&void 0!==E?E:100}static payloadify(e){return k(O(Object.assign(Object.assign(Object.assign({},Dn.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=Io.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 Ln({userProfile:this}))}}class Pn extends R{constructor({request:e=!0,features:t={},options:s={},statConfigInfo:i}){super(),this.request=e,this.features=Object.assign({localCache:!0,notification:!0},t),this.options=Object.assign({ingestion:!0},s),this.statConfigInfo=i}}class Mn extends Ce{constructor(e,t,s){var i,n,r,a;super(e,t,s),this.error=null,this.services=[],this.userProfile=new Un(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,this.services=null!==(a=s.services)&&void 0!==a?a:[]}static asError(e){return new Mn("","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=Io.of(t);if(!e)throw o.lostInstance;{const{sessionManager:t,dispatcher:s}=e;yield t.login(this),this.userProfile.apply(),s.dispatch(new Pn({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo}))}}}))}}class qn{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,cause:n=null}){return e(this,void 0,void 0,(function*(){}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){}))}}const Fn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){if(!(e instanceof o))throw e;e.throwOutside()}})),Hn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){}}));class Vn extends qn{constructor(e={}){var t;super(),this.type=exports.ConnectionStateType.LOGOUT,this.name="logout",this._wasPreviouslyConnected=null===(t=e.wasPreviouslyConnected)||void 0===t||t}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 Jn,s),this._wasPreviouslyConnected&&Fn((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onDisconnected&&e.onDisconnected(i)}))}))))}))}}class zn extends qn{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 Yn({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new jn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn,e)}))}}class Gn extends qn{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 jn,e))}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new Yn({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new jn,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new zn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn,e)}))}}const Kn=t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}));class Bn{calcTimeout(){return 0}}const Qn=(t,s,i=new Bn)=>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||et(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=new Me;this._callbacks.push((e=>e?i.reject(e):i.resolve())),Fn((()=>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 Qn(((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){if(e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);if(e.isSessionExpiredError||e.isSessionInvalidatedError)return void s(e)}throw e}}))),i,n),yield t.changeState(new $n,s),this._flushCallbacks(),Fn((()=>e(this,void 0,void 0,(function*(){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 Gn({autoReconnect:!1}),s)),this._flushCallbacks(i),Fn((()=>e(this,void 0,void 0,(function*(){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 Me;return this._halt(o.connectionCanceled),t.cancelConnectForRetry(),this._callbacks.push((()=>{const i=Date.now();t.changeState(new Yn({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 Me;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 Gn({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 zn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Vn,e)}))}}class $n extends qn{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 jn,e)}))}onDisconnect(t,{autoReconnect:s}){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Gn({autoReconnect:s}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new zn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn,e)}))}}var Wn;!function(e){e.ExternalSetBackground="ExternalSetBackground",e.ExternalDisconnectWebSocket="ExternalDisconnectWebSocket"}(Wn||(Wn={}));class Zn{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:o,dispatcher:r,logger:a,disableWebSocketCloseEventHandling:l=!1}){this._disableWebSocketCloseEventHandling=!1,this._webSocketClosedCause=null,this._logger=a,this._disableWebSocketCloseEventHandling=l,this._context=new io(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",(()=>{this.isConnecting||this.isConnected||(this._logger.debug("try reconnect by session key refresh"),Hn((()=>e(this,void 0,void 0,(function*(){yield this.reconnect()})))))})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(()=>{"foreground"!==this._sdkState.appState||this._webSocketClosedCause||Hn((()=>e(this,void 0,void 0,(function*(){this._sessionManager.isSessionKeyRefreshing?yield this.disconnectWebSocket():(this._logger.debug("try reconnect by websocket connection closed"),yield 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}get websocketClient(){return this._websocketClient}connect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onConnect(this._context,t),this._registerEventDispatcher()}))}reconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{})}))}resetAndReconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{resetReconnectCount:!0})}))}background(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=Wn.ExternalSetBackground,yield e.onDisconnect(this._context,{autoReconnect:!1,cause:this._webSocketClosedCause})}))}disconnect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;yield e.onDisconnect(this._context,{error:t,autoReconnect:!0,cause:this._webSocketClosedCause})}))}disconnectWebSocket(t=!1){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;t&&(this._webSocketClosedCause=Wn.ExternalDisconnectWebSocket),yield e.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause})}))}logout(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._clearEventDispatcher(),yield e.onLogout(this._context,t)}))}}class Yn extends qn{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 Me;this._callbacks.push((e=>e?i.reject(e):i.resolve()));try{yield Qn((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 $n,s),Fn((()=>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 Jn,s)),Fn((()=>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 Me;return this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:i=!1,cause:n=null}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:Xn(n)),t.hasSession?yield t.changeState(new Gn({autoReconnect:i}),e):yield t.changeState(new Vn,e)}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){this._halt(Xn((null==s?void 0:s.cause)||null));const e=Date.now();t.hasSession?yield t.changeState(new zn,e):yield t.changeState(new Vn,e)}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:o.connectionCanceled),yield t.changeState(new Vn,e)}))}}function Xn(e){const t=o.connectionCanceled;if(e){let s=null;switch(e){case Wn.ExternalSetBackground:s="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case Wn.ExternalDisconnectWebSocket:s="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}s&&t.setDetail(s)}return t}class Jn extends qn{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 Yn({authToken:s}),e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Vn({wasPreviouslyConnected:!1}),e)}))}}class eo extends Te{constructor(){super({code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}}class to{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 eo;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)}}const so=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"];class io extends I{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:r,dispatcher:a,logger:l,entryState:d=new Jn}){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 to({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(Mn))})).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 Mn&&(this._unresolvedLogi=e,this._tryResolveConnectionRequest())}))}get currentState(){return this._currentState}get hasSession(){return this._sessionManager.session.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 dn({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;this._websocketClient.isOpen&&e&&(this._unresolvedLogi=void 0,e.error?(this._sessionManager.session.authToken=void 0,e.error.isSessionExpiredError||e.error.isSessionInvalidatedError?this._dispatcher.dispatch(new me({reason:e.error.code,message:e.error.message})):this._logger.warn(`login failed: ${e.error}`),this._rejectConnectionRequest(e.error)):(yield e.applyTo(this._iid),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(){var e;const{appId:t,appVersion:s,userId:n,extensions:o,sendbirdRuntimeEnvironment:r}=this.sdkState,{localCacheEnabled:a}=this.cacheContext,{session:l}=this._sessionManager,d=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,c=!!(null!=o?o:{}).sb_uikit,h=Pe.userAgentWithExtension(o);return`${this.sdkState.websocket.host}/?p=JS&pv=${encodeURIComponent(i.OS_VERSION)}&sv=${encodeURIComponent(i.SDK_VERSION)}&ai=${t}${s?`&av=${s}`:""}${l.hasSession?"":`&user_id=${encodeURIComponent(n)}`}&pmce=${d?1:0}&active=1&device_token_types=${encodeURIComponent(["gcm","huawei","apns"].join(","))}&SB-User-Agent=${h}&SB-SDK-User-Agent=${encodeURIComponent(Pe.sendbirdSdkUserAgentWithExtension(r))}&Request-Sent-Timestamp=${Date.now().toString()}&include_extra_data=${encodeURIComponent(String(so))}${this._sessionManager.handler?"&expiring_session=1":""}&use_local_cache=${a?1:0}&include_poll_details=1${c?"&uikit_config=1":""}`}_statLogConnection(e){var t;this._dispatcher.dispatch(new be(new Re({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=new Me;if(this._connectionRequestQueue.push(e),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);const{session:e}=this._sessionManager;t&&(e.authToken=t,e.sessionKey=void 0);const i=this._url();e.sessionKey||e.authToken?this._websocketClient.connect(i,JSON.stringify(e.hasSession?{auth:e.sessionKey}:{token:e.authToken})):this._websocketClient.connect(i,JSON.stringify({}))}return e.promise}))}cancelConnectForRetry(){this._dispatcher.dispatch(Mn.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.disconnect(),yield this._sessionManager.clear()}))}clearLoginTimer(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}class no extends fe{constructor({appId:e,userId:t,includeUIKitConfig:s=!1,localCacheEnabled:i=!0,expiringSession:n=!0}){super(),this.path=`${$}/${t}/authentication`,this.method=exports.APIRequestMethod.POST,this.params=k({expiring_session:!!n,include_logi:!0,include_extra_data:String(so),uikit_config:s,use_local_cache:i,app_id:e}),this.requireAuth=!1}}class oo extends ve{constructor(e,t){super(e,t),this.logi=new Mn(e,"LOGI",t)}}var ro;!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(ro||(ro={}));const ao=[ye,no];class lo{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r=!1}){this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new ln(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this._session=t,this._logger=n,this._dispatcher=i,this._dispatcher.on((e=>{var t;if(e instanceof dn){const{stateType:s}=e;switch(this._currentConnectionStateType=s,s){case exports.ConnectionStateType.CONNECTED:this._resolveLazyCallQueue();break;case exports.ConnectionStateType.INITIALIZED:case exports.ConnectionStateType.INTERNAL_DISCONNECTED:case exports.ConnectionStateType.EXTERNAL_DISCONNECTED:case exports.ConnectionStateType.LOGOUT:this._rejectLazyCallQueue((null===(t=this._session)||void 0===t?void 0:t.hasSession)?o.connectionClosed:o.connectionRequired)}}else if(e instanceof cn)this._session.hasChatServicePermission||this._resolveLazyCallQueue(ro.API);else if(e instanceof hn||e instanceof un)this._rejectLazyCallQueue(o.connectionClosed);else if(e instanceof Ie){const{request:t,deferred:s,error:i}=e;for(const e of ao)if(t instanceof e)return void s.reject(i);this._lazyCallQueue.push({command:t,deferred:s})}}))}get isReady(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED}get isLazyCallActivated(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING||this._currentConnectionStateType===exports.ConnectionStateType.RECONNECTING||this._session.isRefreshing}_classifyLazyCallQueueByScope(e){const t=[],s=[];let i;switch(e){case ro.ALL:i=null;break;case ro.WEBSOCKET:i=Te;break;case ro.API:i=fe}let n=!1;return this._lazyCallQueue.forEach((e=>{!i||e.command instanceof i||(n=!0),n?s.push(e):t.push(e)})),[t,s]}_resolveLazyCallQueue(t=ro.ALL){const[s,i]=this._classifyLazyCallQueueByScope(t);this._lazyCallQueue=i,s.forEach((t=>e(this,void 0,void 0,(function*(){const{command:e,deferred:s,timeout:i}=t;i&&clearTimeout(i);try{const t=yield this.send(e);s.resolve(t)}catch(e){s.reject(e)}}))))}_rejectLazyCallQueue(t,s=ro.ALL){const[i,n]=this._classifyLazyCallQueueByScope(s);this._lazyCallQueue=n,i.forEach((s=>e(this,void 0,void 0,(function*(){const{deferred:e,timeout:i}=s;clearTimeout(i),e.reject(t)}))))}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof Te){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 Me;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 fe){if(this._session.hasSession)return this._logger.debug("send api request",t),yield this.commandRouter.send(t);if(t.hasSessionKey)return this._logger.debug("send api request with tmp session key",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait api request",t);const e=new Me;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*(){if(this._logger.debug("send forced request",t),t instanceof Te||t instanceof fe)return yield this.commandRouter.send(t);throw o.invalidCommand}))}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 co="sendbird@devicetokens";class ho{constructor({type:e,token:t,device_os:s,device_manufacturer:i,system_push_enabled:n}){this.type=e,this.token=t,this.deviceOS=s,this.deviceManufacturer=i,this.systemPushEnabled=n}static payloadify(e){return k(O({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}const uo=new WeakMap;class _o extends I{constructor({_iid:e,session:t,cacheContext:s,sdkState:i,dispatcher:o,requestQueue:r,logger:a,pushNotificationAckManager:l}){super(),this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._isRefreshingAuthToken=!1,this.currentUser=null,this.session=t,this._iid=e,this._cacheContext=s,this._sdkState=i,this._dispatcher=o,this._requestQueue=r,this._logger=a,this._pushNotificationAckManager=l,this._deviceTokens=[],this._dispatcher.on((e=>{var t,s,i;if(e instanceof dn){const{stateType:t}=e;this._currentConnectionStateType=t}else if(e instanceof me&&this.handler&&!this.isSessionKeyRefreshing){if(this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?this.close():((null===(s=e.error)||void 0===s?void 0:s.isSessionTokenExpiredError)&&this.refreshAuthToken().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(this._logger.debug("session expired"),this.handler.onSessionExpired&&this.handler.onSessionExpired(),this.refreshSessionKey().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e}))))}}))}get ekey(){return uo.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 Ae({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(we);if(n)throw n;this.session.sessionKey=null!=i?i:this.session.sessionKey}))}_refreshSessionKeyByApi(t){return e(this,void 0,void 0,(function*(){const s=new ye({userId:this._sdkState.userId,authToken:t,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0});yield Qn((t=>e(this,void 0,void 0,(function*(){try{const e=yield this._requestQueue.forceSend(s),{key:t,services:i}=e.as(Ne);this.session.sessionKey=t,this.session.services=i}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){try{return void(yield this._handleSessionRefreshError(e,s))}catch(e){}}try{yield this._refreshSessionKeyByApi(t),this.complete()}catch(e){yield this._handleSessionRefreshError(e,s)}}))}_receiveNewAuthToken(){var t;const s=new Me;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired){let t=null;const i=()=>{t&&(clearTimeout(t),t=null)},n=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.resolve(e))},o=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.reject(e))};t=setTimeout((()=>o()),1e3*this._sdkState.sessionTokenRefreshTimeout),Fn((()=>e(this,void 0,void 0,(function*(){var e;(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(n,o)}))))}else s.resolve(null);return s.promise}_handleSessionRefreshError(t,s=!1){return e(this,void 0,void 0,(function*(){if(!(t instanceof o&&(t.isSessionTokenExpiredError||t.code===exports.SendbirdErrorCode.APPLICATION_NOT_FOUND)&&(this.session.authToken=void 0,s)))throw t;{const e=yield this._receiveNewAuthToken();e?(this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken,!1)):yield this.clear()}}))}_isSessionRelatedError(e){return e instanceof o&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}get isSessionKeyRefreshing(){return this.session.isRefreshing}get isRefreshingAuthToken(){return this._isRefreshingAuthToken}get isSessionExpiring(){return!!this.handler}authenticate(t,s){var i;return e(this,void 0,void 0,(function*(){this.session.authToken=s;const e=new no({appId:this._sdkState.appId,userId:t,includeUIKitConfig:!!(null!==(i=this._sdkState.extensions)&&void 0!==i?i:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!s||this.isSessionExpiring}),n=yield this._requestQueue.commandRouter.send(e),{logi:o}=n.as(oo);if(o.error)throw o.error;this.session.hasChatServicePermission||(yield o.applyTo(this._iid))}))}login(t){var s;return e(this,void 0,void 0,(function*(){const{key:e,ekey:i,services:n,userProfile:o,deviceTokenLastDeletedAt:r=0}=t;this.session.sessionKey=e,this.session.services=n,uo.set(this,i),this._deviceTokenCacheEnabled=null===(s=null==o?void 0:o.appInfo)||void 0===s?void 0:s.deviceTokenCache;const{preference:a}=this._cacheContext;if(this._deviceTokenCacheEnabled){const e=yield a.get(co);!e||e.lastDeletedAtnew ho(ho.payloadify(e)))),this._deviceTokenLastDeletedAt=e.lastDeletedAt)}else yield a.remove(co)}))}complete(){this.dispatch("refresh"),this._dispatcher.dispatch(new cn),Fn((()=>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){Fn((()=>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"),this._dispatcher.dispatch(new un),Fn((()=>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()}))))}refreshAuthToken(){return e(this,void 0,void 0,(function*(){let e=null;if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{e=yield this._receiveNewAuthToken(),e?(this._logger.debug("session refreshing.."),this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken)):yield this.clear()}catch(t){const s=e?o.sessionTokenRefreshFailed:o.sessionTokenRequestFailed;throw this._dispatcher.dispatch(new hn),this.error(s),this._logger.debug("refresh auth token error = ",s),s}finally{this.session.isRefreshing=!1}}}))}refreshSessionKey(){return e(this,void 0,void 0,(function*(){if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{yield this._refreshSessionKey(this.session.authToken)}catch(e){const t=o.sessionTokenRefreshFailed;throw this._dispatcher.dispatch(new hn),this.error(t),t}finally{this.session.isRefreshing=!1}}}))}setDeviceToken(e,t,s){if(this._deviceTokenCacheEnabled){if(this.indexOfDeviceToken(e,t)<0){const i=new ho({type:e,token:t,device_os:null==s?void 0:s.deviceOS,device_manufacturer:null==s?void 0:s.deviceManufacturer,system_push_enabled:null==s?void 0:s.systemPushEnabled});return this._deviceTokens.push(i),!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(co,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})}}))}clear(){return e(this,void 0,void 0,(function*(){this.currentUser=null,this.session.clear(),this.close(),uo.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,yield this.saveDeviceToken(),this._pushNotificationAckManager.clear()}))}}const po=(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]=po(e[s],t[s]):o[s]=t[s]}return o}return t};var Eo,go;!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Eo||(Eo={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(go||(go={}));class fo extends fe{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${ae}`,this.params={device_id:e,log_entries:t.map((e=>Re.payloadify(e)))}}}class vo{constructor({deviceId:e,cacheContext:t,requestQueue:s}){this.queue=[],this.flushWaitQueue=[],this.enabledState=Eo.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=e,this.cacheContext=t,this.requestQueue=s,this.logInfo={deviceId:e,statLogs:[],generation:1,lastFlushedAt:0},this.limit=100}get isEnabled(){return this.enabledState===Eo.ENABLED}init(t){return e(this,void 0,void 0,(function*(){this.key=t;const e=yield this.cacheContext.preference.get(this.key);e&&(this.logInfo=e)}))}_mergeQueue(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}_isDuplicateStat(e){const t=this._sentLogStats.find((t=>{var s;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(s=e.data.notificationId)&&void 0!==s?s:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}_flush(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t.length>0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new fo({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=Eo.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Eo.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}_save(){return e(this,void 0,void 0,(function*(){const e=[...this.queue,...this.flushWaitQueue];yield this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((e=>Re.payloadify(e))),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})}))}clear(){return e(this,void 0,void 0,(function*(){this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save()}))}}class So extends Re{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 mo extends vo{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".daily"),this.queue=this.logInfo.statLogs.map((e=>new Re({type:e.stat_type,ts:e.ts,data:e.data})))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this.statConfig.minInterval=864e5,this._mergeQueue(),s.localCacheStat?this.enabledState=s.enabledStat?Eo.ENABLED:Eo.COLLECT_ONLY:(this.enabledState=Eo.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=yield this._getUploadStats(),t=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);for(let s=0;se instanceof So&&e.key===t.key));if(s?s.data=po(s.data,t.data):e.push(t),this.enabledState!==Eo.PENDING&&(yield this._save()),this.isEnabled&&(this._mergeQueue(),this._isSendable)){const e=yield this._getUploadStats();return yield this._flush(e)}return!0}))}_getUploadStats(){return e(this,void 0,void 0,(function*(){return this.queue.filter((e=>{if(e instanceof So){const t=new Date,[s,i]=[e.date.getFullYear(),t.getFullYear()];if(se.type!==exports.StatType.FEATURE_LOCALCACHE_EVENT)):t.filter((e=>e.type===exports.StatType.FEATURE_LOCALCACHE_EVENT))}))}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".default"),this.queue=this.logInfo.statLogs.map((e=>(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data),new Re({type:e.stat_type,ts:e.ts,data:e.data}))))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.requestStat||s.localCacheStat){let e;this.enabledState=s.enabledStat?Eo.ENABLED:Eo.COLLECT_ONLY,s.requestStat||(e=!1),s.localCacheStat||(e=!0),void 0!==e&&(this.queue=yield this._filterQueueByType(this.queue,e),this.flushWaitQueue=yield this._filterQueueByType(this.flushWaitQueue,e),this._save())}else this.enabledState=Eo.DISABLED,yield this.clear();if(this.isEnabled&&this._isSendable(!0)){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield Kn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===Eo.DISABLED)return!0;const e=this.enabledState===Eo.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return e.push(t),this.enabledState!==Eo.PENDING&&(yield this._save()),!this.isEnabled||(this._mergeQueue(),!this._isSendable())||(yield this._flush(e))}))}}class To extends vo{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".realtime"),this.queue=this.logInfo.statLogs.map((e=>{var t;return e.data=k(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Re({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((e=>{var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.notificationStat?this.enabledState=s.enabledStat?Eo.ENABLED:Eo.COLLECT_ONLY:(this.enabledState=Eo.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield Kn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===Eo.DISABLED)return!0;const e=this.enabledState===Eo.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return!!this._isDuplicateStat(t)||(e.push(t),this.enabledState!==Eo.PENDING&&(yield this._save()),!(this.isEnabled&&(this._mergeQueue(),this.isEnabled&&this._isSendable))||(yield this._flush(e)))}))}}class yo{constructor({cacheContext:e,requestQueue:t,dispatcher:s,logger:i}){this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=w(),this.cacheContext=e,this.requestQueue=t,this.dispatcher=s,this.logger=i,this._dailyStatCollector=new mo({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Co({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._realTimeStatCollector=new To({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}_migration(){return e(this,void 0,void 0,(function*(){const e=yield this.cacheContext.preference.get(this.key);if(e){const t=[];e.statLogs.forEach((e=>{e.stat_type===exports.StatType.FEATURE_LOCALCACHE&&t.push(new Re({type:e.stat_type,ts:e.ts,data:e.data}))})),yield this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((e=>Re.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const s=[];e.statLogs.forEach((e=>{e.stat_type!==exports.StatType.FEATURE_LOCALCACHE&&e.stat_type!==exports.StatType.NOTIFICATION&&(e.stat_type===exports.StatType.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),s.push(new Re({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:s.map((e=>Re.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const i=[];e.statLogs.forEach((e=>{var t;e.stat_type===exports.StatType.NOTIFICATION&&(e.data=k(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),i.push(new Re({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:i.map((e=>Re.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt}),yield this.cacheContext.preference.remove(this.key)}}))}init(t){return e(this,void 0,void 0,(function*(){this.key=t,yield this._migration(),yield this._dailyStatCollector.init(this.key),yield this._defaultStatCollector.init(this.key),yield this._realTimeStatCollector.init(this.key),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((t=>e(this,void 0,void 0,(function*(){var e;if(t instanceof be){const{statLog:e}=t;this.put(e)}else if(t instanceof Pn){const{request:s,features:i,options:n,statConfigInfo:o}=t;this._retryCount=0,this._collectRequestStat=s,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._realTimeStatCollector.setConfig(null!==(e=this._statConfig.realTime)&&void 0!==e?e:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:n.ingestion})}})))))}))}put(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t instanceof So)this._collectFeatureLocalCacheStat&&(e=yield this._dailyStatCollector.put(t));else switch(t.type){case exports.StatType.API_RESULT:case exports.StatType.WEBSOCKET_CONNECT:this._collectRequestStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.FEATURE_LOCALCACHE:case exports.StatType.FEATURE_LOCALCACHE_EVENT:this._collectFeatureLocalCacheStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.NOTIFICATION:this._collectionNotificationStat&&(e=yield this._realTimeStatCollector.put(t))}e?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Eo.COLLECT_ONLY,this._defaultStatCollector.enabledState=Eo.COLLECT_ONLY,this._realTimeStatCollector.enabledState=Eo.COLLECT_ONLY,this.logger.debug(o.statLogUploadLimitExceededError)))}))}close(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}class Ao{constructor({limit:e=5}){this.workersByKey={},this.limit=e}run(t,s){return e(this,void 0,void 0,(function*(){if(this.workersByKey[t]||(this.workersByKey[t]=[]),this.workersByKey[t].length{switch(e){case"open":return exports.PollStatus.OPEN;case"closed":return exports.PollStatus.CLOSED;default:return null}},Lo=e=>!e||!!e.text&&l("string",e.text);class Uo extends Tn{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 k(O(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})))}}class Po extends Tn{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=Do(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 Uo(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=Do(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 Uo(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 k(O(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=>Uo.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 xn(this)}}class Mo{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}}class qo extends Mo{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)}}class Fo extends fe{constructor({title:e,optionTexts:t,data:s,allowUserSuggestion:i,allowMultipleVotes:n,closeAt:o}){super(),this.method=exports.APIRequestMethod.POST,this.path=ne,this.params={title:e,options:t,data:s,allow_user_suggestion:i,allow_multiple_votes:n,close_at:o}}}class Ho extends ve{constructor(e,t){super(e,t),this.poll=new Po(e,t)}}class Vo extends fe{constructor({channelUrl:e,channelType:t,pollId:s}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}`,this.params={channel_url:e,channel_type:t}}}class zo extends ve{constructor(e,t){super(e,t),this.poll=new Po(e,t)}}class Go extends fe{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}`,this.params={channel_url:e,channel_type:t}}}class Ko extends ve{constructor(e,t){super(e,t),this.pollOption=new Uo(e,t)}}class Bo extends fe{constructor({channelType:e,channelUrl:t,timestamp:s,token:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${_e(e)}/${encodeURIComponent(t)}/polls/changelogs`,this.params=k({change_ts:s,token:i})}}class Qo extends ve{constructor(e,t){super(e,t),this.updatedPolls=t.updated.map((t=>((e,t)=>new Po(e,t))(e,t))),this.deletedPollIds=t.deleted.map((e=>e)),this.hasMore=t.has_more,this.nextToken=t.next}}const jo={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},$o=e=>{return l("string",e.title)&&(t=e.optionTexts,h("string",t)&&t.every((e=>""!==e.trim())))&&Lo(e.data)&&l("boolean",e.allowUserSuggestion,!0)&&l("boolean",e.allowMultipleVotes,!0)&&l("number",e.closeAt,!0);var t},Wo={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0,pollOptionId:0},Zo=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId)&&e.pollId>0&&l("number",e.pollOptionId)&&e.pollOptionId>0,Yo={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0},Xo=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId),Jo={};class er extends fe{constructor({channelUrl:e,channelType:t,token:s,limit:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=ne,this.params={channel_url:e,channel_type:t,token:s,limit:i}}}class tr extends ve{constructor(e,t){var s;super(e,t),this.polls=(null!==(s=t.polls)&&void 0!==s?s:[]).map((t=>new Po(e,t))),this.token=t.next}}class sr extends fe{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i,token:n,limit:o}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}/voters`,this.params={channel_url:e,channel_type:t,token:n,limit:o}}}class ir extends ve{constructor(e,t){var s;super(e,t),this.voters=(null!==(s=t.voters)&&void 0!==s?s:[]).map((t=>new Dn(e,t))),this.token=t.next}}exports.APIRequestCommand=fe,exports.APIResponseCommand=ve,exports.API_PATH_EMOJIS=se,exports.API_PATH_EMOJI_CATEGORIES=ie,exports.API_PATH_FORMS=ue,exports.API_PATH_GROUP_CHANNELS=Z,exports.API_PATH_GROUP_CHANNELS_INTERNAL=Y,exports.API_PATH_MESSAGE_TEMPLATE=ce,exports.API_PATH_NOTIFICATIONS=le,exports.API_PATH_NOTIFICATIONS_USERS=de,exports.API_PATH_OPEN_CHANNELS=X,exports.API_PATH_OPEN_CHANNELS_INTERNAL=J,exports.API_PATH_POLLS=ne,exports.API_PATH_PUSH_DELIVERY=he,exports.API_PATH_REPORT=te,exports.API_PATH_SCHEDULED_MESSAGES=oe,exports.API_PATH_SEARCH=ee,exports.API_PATH_UIKIT_CONFIGURATION=re,exports.API_PATH_UPLOAD=W,exports.API_PATH_USERS=j,exports.AppInfo=Cn,exports.BaseCommand=R,exports.BaseListQuery=Mo,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.CancelXMLHttpRequestCommand=qe,exports.ChannelDataListQuery=qo,exports.ConnectionStateChangeCommand=dn,exports.DEFAULT_ENCRYPTION=E,exports.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT=5,exports.DailyRecordStatLog=So,exports.Deferred=Me,exports.DeleteMessageEventCommand=class extends Ce{constructor(e,t,s){var i;super(e,"DELM",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.messageId=Number(s.msg_id),this.silent=s.silent,this.messageCreatedAt=s.message_created_at?Number(s.message_created_at):-1,this.senderId=null!==(i=s.sender_id)&&void 0!==i?i:void 0}},exports.DeleteMessageRequestCommand=Fe,exports.EventDispatcher=I,exports.InstancedObject=Tn,exports.LocalCacheConfig=y,exports.MessageEventSource=Ro,exports.MessageRemoveEventCommand=class extends R{constructor({messageIds:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messageIds=e,this.source=t,this.isWebSocketEventComing=s}},exports.MessageUpdateEventCommand=class extends R{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.NotificationInfo=_n,exports.POLL_REMOVED_STATUS="removed",exports.Poll=Po,exports.PollChangeLogEventCommand=ko,exports.PollCreateParamsDefault=jo,exports.PollListQuery=class extends qo{constructor(e,t){super(e,t.channelUrl,t.channelType,t)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Io.of(this._iid),t=new er(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{polls:i,token:n}=s.as(tr);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.PollManager=class{constructor(e,{sdkState:t,dispatcher:s,sessionManager:i,requestQueue:n,logger:o}){this._iid=e,this._sdkState=t,this._sessionManager=i,this._requestQueue=n,this._dispatcher=s,this._logger=o,Jo[e]=this}static of(e){return Jo[e]}buildPollFromSerializedData(e){const t=Rn(e);return new Po(this._iid,Po.payloadify(t))}get(t){return e(this,void 0,void 0,(function*(){kn(Xo(t)).throw(o.invalidParameters);const e=new Vo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(zo);return i}))}create(t){return e(this,void 0,void 0,(function*(){kn($o(t)).throw(o.invalidParameters);const e=new Fo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(Ho);return i}))}getOption(t){return e(this,void 0,void 0,(function*(){kn(Zo(t)).throw(o.invalidParameters);const e=new Go(Object.assign({},t)),s=yield this._requestQueue.send(e),{pollOption:i}=s.as(Ko);return i}))}getPollChangeLogs(t,s,i,n=exports.CollectionEventSource.SYNC_POLL_CHANGELOGS){return e(this,void 0,void 0,(function*(){const e=new Bo(O({channelType:s,channelUrl:t,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null})),o=yield this._requestQueue.send(e),{updatedPolls:r,deletedPollIds:a,hasMore:l,nextToken:d}=o.as(Qo);return r.length>0&&this._dispatcher.dispatch(new ko({polls:r,source:n})),{updatedPolls:r,deletedPollIds:a,hasMore:l,token:d}}))}},exports.PollOption=Uo,exports.PollOptionRetrievalParamsDefault=Wo,exports.PollRetrievalParamsDefault=Yo,exports.PollUpdateInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=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.PollVoteInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoterListQuery=class extends qo{constructor(e,t){super(e,t.channelUrl,t.channelType,t),this.pollId=t.pollId,this.pollOptionId=t.pollOptionId}_validate(){return super._validate()&&l("number",this.pollId)&&l("number",this.pollOptionId)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Io.of(this._iid),t=new sr(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),s=yield e.send(t),{voters:i,token:n}=s.as(ir);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.ReactionUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.RequestResendCommand=Ie,exports.SEMVER_REGEX_STRING="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",exports.SendbirdChatOptions=p,exports.SendbirdError=o,exports.SessionExpiredCommand=me,exports.SessionRefreshAPICommand=ye,exports.StatLog=Re,exports.SubscribedUnreadMessageCountUpdateCommand=an,exports.ThreadUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.UIKitConfigInfo=pn,exports.UnsentMessageRemoveEventCommand=class extends R{constructor({reqId:e,source:t}){super(),this.reqId=e,this.source=t}},exports.User=Dn,exports.UserProfile=Un,exports.UserProfileUpdateCommand=Ln,exports.Vault=Io,exports.WebSocketEventCommand=Ce,exports.WebSocketRequestCommand=Te,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=pe(null!==(i=e.mentionType)&&void 0!==i?i:null,null!==(n=e.mentionedUserIds)&&void 0!==n?n:[],s),l=pe(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=pe,exports.createChangelogIncludeChatNotificationsCacheKey=e=>`sendbird@${e}/changelog_include_chat_notifications`,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=Rn,exports.deundefined=k,exports.getChannelApiPathByType=_e,exports.getReportApiPathByType=e=>{switch(e){case exports.ChannelType.GROUP:return`${te}/group_channels`;case exports.ChannelType.OPEN:return`${te}/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.isMilliSecondOf=(e,t=!1)=>!(!t||!_(e))||"number"==typeof e&&13===e.toString().length,exports.isReactNative=ke,exports.isResendableError=e=>e>0&&r.indexOf(e)>=0,exports.isThrowingOutside=n,exports.isTypeOf=l,exports.noop=Ve,exports.parsePollStatusPayload=Do,exports.runAsCallback=Fn,exports.runOrNothing=Hn,exports.serialize=xn,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===exports.CollectionEventSource.SYNC_MESSAGE_FILL||e===exports.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||e===exports.CollectionEventSource.SYNC_POLL_CHANGELOGS,exports.sleep=Kn,exports.undefineNullProps=O,exports.unless=kn,exports.uuid=w,exports.validatePollCreateParams=$o,exports.validatePollData=Lo,exports.validatePollOptionRetrievalParams=Zo,exports.validatePollRetrievalParams=Xo,exports.version=s; diff --git a/cjs/lib/__bundle-552fe22f.cjs b/cjs/lib/__bundle-2e006691.cjs similarity index 95% rename from cjs/lib/__bundle-552fe22f.cjs rename to cjs/lib/__bundle-2e006691.cjs index 2d731d7..46d5e38 100644 --- a/cjs/lib/__bundle-552fe22f.cjs +++ b/cjs/lib/__bundle-2e006691.cjs @@ -1 +1 @@ -var e=require("./__bundle-1a495950.cjs");exports.xmlHttpRequest=(r,s)=>new Promise(((t,o)=>{if("undefined"!=typeof XMLHttpRequest){const{dispatcher:n,logger:d}=e.Vault.of(r),{requestId:a,method:i,url:u,headers:p={},data:c="",uploadProgressHandler:l}=s;let m=!1;const E=new XMLHttpRequest;E.open(i,u),Object.keys(p).forEach((e=>{E.setRequestHeader(e,p[e])})),l&&E.upload.addEventListener("progress",(e=>{e.lengthComputable?l(a,e.loaded,e.total):d.debug("Progress computing failed: `Content-Length` header is not given.")})),E.onabort=()=>{o(e.SendbirdError.requestCanceled)},E.onerror=r=>{o(e.SendbirdError.networkError)},E.onreadystatechange=()=>{if(E.readyState===XMLHttpRequest.DONE&&!m)if(0===E.status||E.status>=200&&E.status<400)try{const s=JSON.parse(E.responseText);t(new e.APIResponseCommand(r,s))}catch(r){o(e.SendbirdError.networkError)}else try{const r=JSON.parse(E.responseText);if(r){const s=new e.SendbirdError(r);if(s.isSessionExpiredError){if(n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message})),!(E instanceof e.SessionRefreshAPICommand)){const r=new e.Deferred;return n.dispatch(new e.RequestResendCommand({request:E,deferred:r,error:s})),r.promise}}else s.isSessionInvalidatedError&&n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message}));o(s)}else o(e.SendbirdError.requestFailed)}catch(r){o(e.SendbirdError.requestFailed)}},n.on((r=>{r instanceof e.CancelXMLHttpRequestCommand&&(r.requestId&&r.requestId!==a||(m=!0,E.abort()))})),E.send(c)}else o(e.SendbirdError.xmlHttpRequestNotSupported)})); +var e=require("./__bundle-0486c467.cjs");exports.xmlHttpRequest=(r,s)=>new Promise(((t,o)=>{if("undefined"!=typeof XMLHttpRequest){const{dispatcher:n,logger:d}=e.Vault.of(r),{requestId:a,method:i,url:u,headers:p={},data:c="",uploadProgressHandler:l}=s;let m=!1;const E=new XMLHttpRequest;E.open(i,u),Object.keys(p).forEach((e=>{E.setRequestHeader(e,p[e])})),l&&E.upload.addEventListener("progress",(e=>{e.lengthComputable?l(a,e.loaded,e.total):d.debug("Progress computing failed: `Content-Length` header is not given.")})),E.onabort=()=>{o(e.SendbirdError.requestCanceled)},E.onerror=r=>{o(e.SendbirdError.networkError)},E.onreadystatechange=()=>{if(E.readyState===XMLHttpRequest.DONE&&!m)if(0===E.status||E.status>=200&&E.status<400)try{const s=JSON.parse(E.responseText);t(new e.APIResponseCommand(r,s))}catch(r){o(e.SendbirdError.networkError)}else try{const r=JSON.parse(E.responseText);if(r){const s=new e.SendbirdError(r);if(s.isSessionExpiredError){if(n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message})),!(E instanceof e.SessionRefreshAPICommand)){const r=new e.Deferred;return n.dispatch(new e.RequestResendCommand({request:E,deferred:r,error:s})),r.promise}}else s.isSessionInvalidatedError&&n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message}));o(s)}else o(e.SendbirdError.requestFailed)}catch(r){o(e.SendbirdError.requestFailed)}},n.on((r=>{r instanceof e.CancelXMLHttpRequestCommand&&(r.requestId&&r.requestId!==a||(m=!0,E.abort()))})),E.send(c)}else o(e.SendbirdError.xmlHttpRequestNotSupported)})); diff --git a/cjs/lib/__bundle-4bcf4070.cjs b/cjs/lib/__bundle-4bcf4070.cjs new file mode 100644 index 0000000..fc7ad26 --- /dev/null +++ b/cjs/lib/__bundle-4bcf4070.cjs @@ -0,0 +1 @@ +var e,t=require("./__bundle-0486c467.cjs");class s{constructor(e,t,s){var i,n;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(i=t.real_width)&&void 0!==i?i:t.width,this.realHeight=null!==(n=t.real_height)&&void 0!==n?n:t.height,this._requireAuth=s}static payloadify(e){return e instanceof s?t.deundefined(t.undefineNullProps({url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight})):t.deundefined(t.undefineNullProps({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class i extends t.APIRequestCommand{constructor(e){if(super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_UPLOAD}`,this.params=t.deundefined({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(let t=0;tnew s(e,t,!1))))&&void 0!==a?a:[],this.requireAuth=null!==(r=t.require_auth)&&void 0!==r&&r}}class a extends t.InstancedObject{constructor(e,s){var i,n,a,r,o;super(e),this.replyCount=0,this.memberCount=0,this.lastRepliedAt=0,this.updatedAt=0,this.replyCount=null!==(i=s.reply_count)&&void 0!==i?i:0,this.memberCount=null!==(n=s.member_count)&&void 0!==n?n:0,this.mostRepliedUsers=s.most_replies&&t.isArrayOf("object",s.most_replies)?s.most_replies.map((e=>new t.User(this._iid,e))):[],this.unreadReplyCount=null!==(a=s.unread_message_count)&&void 0!==a?a:0,this.isPushNotificationEnabled="number"==typeof s.push_enabled?s.push_enabled>0:void 0,this.lastRepliedAt=null!==(r=s.last_replied_at)&&void 0!==r?r:0,this.updatedAt=null!==(o=s.updated_at)&&void 0!==o?o:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((e=>t.User.payloadify(e))):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}get _isUpdateRequired(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}_updateFrom(e){var t,s;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(s=e.isPushNotificationEnabled)&&void 0!==s?s:this.isPushNotificationEnabled}}exports.ReactionEventOperation=void 0,(e=exports.ReactionEventOperation||(exports.ReactionEventOperation={})).ADD="add",e.DELETE="delete";class r{constructor(e){this.messageId=0,this.operation=null,this.updatedAt=0;const s=t.isTypeOf("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,n=e.operation?e.operation.toLowerCase():null,a=e.reaction,r=e.updated_at;s&&t.isTypeOf("string",i)&&t.isTypeOf("string",n)&&t.isEnumOf(exports.ReactionEventOperation,n)&&t.isTypeOf("string",a)&&a&&t.isTypeOf("number",r)&&(this.messageId=s,this.userId=i,this.key=a,this.operation=n,this.updatedAt=r)}}class o{constructor(e){var s;const i=e.key,n=null!==(s=[...e.user_ids])&&void 0!==s?s:[],a=e.updated_at;t.isTypeOf("string",i)&&i&&t.isArrayOf("string",n)&&n.length>0&&t.isTypeOf("number",a)&&(this.key=i,this.userIds=n,this.updatedAt=a);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 t.deundefined(t.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 t=this.userIds.indexOf(e.userId);switch(e.operation){case exports.ReactionEventOperation.ADD:t<0&&this.userIds.push(e.userId);break;case exports.ReactionEventOperation.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}}}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 s,i;return t.deundefined(t.undefineNullProps({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(s=e.width)&&void 0!==s?s: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 t.deundefined(t.undefineNullProps({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?l.payloadify(e.defaultImage):null}))}}class u{constructor(e){var t,s;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(s=e.volume)&&void 0!==s?s:1}serialize(){return{name:this.name,volume:this.volume}}static payloadify(e){return t.deundefined(t.undefineNullProps({name:e.name,volume:e.volume}))}}var c;exports.FeedbackRating=void 0,(c=exports.FeedbackRating||(exports.FeedbackRating={})).GOOD="good",c.BAD="bad";class h{constructor(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}static _getStatus(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}static _isSubmitted(e){return"SUBMITTED"===h._getStatus(e)}static _getPayloadByStatus(e){return"NO_FEEDBACK"===e?{}:null}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,rating:e.rating,comment:e.comment}))}}class p extends t.User{constructor(e,s){var i;super(e,s),this.isBlockedByMe=!1,this.role=t.isEnumOf(t.Role,s.role)?s.role:t.Role.NONE,this.isBlockedByMe=null!==(i=s.is_blocked_by_me)&&void 0!==i&&i}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}class m{constructor(e){this.key=e.key,this.value=t.isArrayOf("string",e.value)?[...e.value]:[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:e.key,value:null!==(s=e.value)&&void 0!==s?s:[]}))}}const _=e=>{switch(e){case t.MessageType.BASE:return"";case t.MessageType.USER:return"MESG";case t.MessageType.FILE:return"FILE";case t.MessageType.ADMIN:return"ADMM"}};class g extends t.InstancedObject{constructor(e,s){var i,n,a,r,o,l,d,u,c;super(e),this.channelType=t.ChannelType.BASE,this.messageType=t.MessageType.BASE,this.mentionType=null,this.mentionedUsers=null,this.mentionedUserIds=null,this.mentionedMessageTemplate=void 0,this.metaArrays=[],this.extendedMessage={},this.createdAt=0,this.updatedAt=0,this.channelUrl=s.channel_url,this.channelType=t.isEnumOf(t.ChannelType,s.channel_type)?s.channel_type:t.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(this.channelUrl=s.channel.channel_url),s.channel.channel_type&&(this.channelType=s.channel.channel_type)),this.data=null!==(i=s.data)&&void 0!==i?i:"",this.customType=null!==(n=s.custom_type)&&void 0!==n?n:"",this.mentionType=t.isEnumOf(t.MentionType,s.mention_type)?s.mention_type:null,this.mentionedUsers=s.mentioned_users?s.mentioned_users.map((e=>new t.User(this._iid,e))):null,this.mentionedUserIds=null!==(a=s.mentioned_user_ids)&&void 0!==a?a:null,this.mentionedUsers&&!this.mentionedUserIds&&(this.mentionedUserIds=this.mentionedUsers.map((e=>e.userId))),this.mentionedMessageTemplate=s.mentioned_message_template;const h=null!==(r=s.metaarray)&&void 0!==r?r:{},p=null!==(o=s.metaarray_key_order)&&void 0!==o?o:Object.keys(h).sort(((e,t)=>e.localeCompare(t)));this.metaArrays=[];for(let e=0;enew m(e)))),this.extendedMessage=null!==(l=s.extended_message)&&void 0!==l?l:{},this.extendedMessagePayload=s.extended_message_payload,this.createdAt=null!==(u=null!==(d=s.created_at)&&void 0!==d?d:s.ts)&&void 0!==u?u:0,this.updatedAt=null!==(c=s.updated_at)&&void 0!==c?c:0}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.channelUrl,channel_type:e.channelType,type:_(e.messageType),data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(s=e.mentionedUsers)||void 0===s?void 0:s.map((e=>t.User.payloadify(e))),mentioned_message_template:e.mentionedMessageTemplate,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>m.payloadify(e))),extended_message:e.extendedMessage,extended_message_payload:e.extendedMessagePayload,created_at:e.createdAt,updated_at:e.updatedAt})))}isIdentical(e){return!0}isEqual(e){return t.deepEqual(this,e)}isUserMessage(){return this.messageType===t.MessageType.USER}isFileMessage(){return this.messageType===t.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isMultipleFilesMessage(){return this.messageType===t.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isAdminMessage(){return this.messageType===t.MessageType.ADMIN}serialize(){return t.serialize(this)}getMetaArraysByKeys(e){return this.metaArrays.filter((t=>e.includes(t.key)))}}class y extends t.InstancedObject{constructor(e,s){var i,n;super(e),this.channelUrl=null!==(i=s.channel_url)&&void 0!==i?i:"",this.channelType=null!==(n=s.channel_type)&&void 0!==n?n:t.ChannelType.GROUP,this.reader=new t.User(this._iid,s.user),this.readAt=s.ts}}class f extends t.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class v extends t.APIRequestCommand{constructor(e){super();const{channelUrl:s,channelType:i,userId:n,notificationIds:a}=e;this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/messages/mark_as_read`,this.params=t.deundefined(t.undefineNullProps({user_id:n,message_ids:a}))}}class I extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new y(e,s)}}class E extends t.APIResponseCommand{constructor(e,t){super(e,t),this.readAt=t.ts,this.unreadMessageCount=t.unread_message_count}}class T extends t.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"READ",ackRequired:!0,payload:{channel_url:e,parent_message_id:t}})}}class b extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,pushEnabled:n}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/thread_push`,this.params={push_enabled:n}}}class M extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,rating:n,comment:a}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks`,this.params={rating:n,comment:a}}}class S extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class O extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n,rating:a,comment:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`,this.params={rating:a,comment:r}}}class A extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class C extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`}}class w extends t.InstancedObject{constructor(e,t){var i,n,a,r,o;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!==(n=t.file_name)&&void 0!==n?n:null,this.mimeType=null!==(a=t.file_type)&&void 0!==a?a:null,this.fileSize=null!==(r=t.file_size)&&void 0!==r?r:0,this._requireAuth=null!==(o=t.require_auth)&&void 0!==o&&o,this.thumbnails=t.thumbnails?t.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this._requireAuth)})):[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>{var t;return{url:(null!==(t=e.plainUrl)&&void 0!==t?t:"").split("auth=")[0],width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class N{constructor({channelUrl:e,channelType:t,parentMessage:s}){this.channelUrl=e,this.channelType=t,this.parentMessage=s}}var P,U,R,x;!function(e){e.NUMBER="number",e.ENUM="enum",e.TEXT="text",e.REGEX="regex",e.DECIMAL_PLACE="decimal_place"}(P||(P={})),exports.MessageFormItemLayout=void 0,(U=exports.MessageFormItemLayout||(exports.MessageFormItemLayout={})).TEXT="text",U.TEXTAREA="textarea",U.NUMBER="number",U.PHONE="phone",U.EMAIL="email",U.CHIP="chip";class k{constructor(e,t){const{id:s,name:i,items:n,version:a,is_submitted:r}=t;this.messageId=e,this.id=s,this.name=i,this.items=n.map((e=>new L(e))).sort(((e,t)=>e.sortOrder-t.sortOrder)),this.version=null!=a?a:1,this._isSubmitted=r}get isSubmitted(){var e;return null!==(e=this._isSubmitted)&&void 0!==e?e:this.items.some((e=>Array.isArray(e.submittedValues)))}get isSubmittable(){return this.items.every((e=>e.required?!!(Array.isArray(e.draftValues)&&e.draftValues.length>0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,items:e.items.map((e=>L.payloadify(e))),version:e.version,is_submitted:e._isSubmitted}))}static isMessageFormPayload(e){return Boolean(null==e?void 0:e.message_form)}}class L{constructor(e){const{id:s,name:i,required:n,sort_order:a,placeholder:r,style:o,item_type:l,validators:d,value:u,values:c}=e;this.id=s,this.name=i,this.required=n,this.sortOrder=a,this.placeholder=r,0===Object.keys(o).length?this.style={layout:l}:this.style=t.deundefined({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),c?this.submittedValues=c:u&&(this.submittedValues=[u]),this._validators=d}isValid(e){return e.every((e=>{const t=function(e,t){return t.every((t=>{switch(t.key){case P.NUMBER:{const s=Number(e);return!(isNaN(s)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&st.max)}case P.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case P.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case P.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case P.DECIMAL_PLACE:{if(0===e.length)return!1;const s=Number(e);return!(isNaN(s)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){const s=e.toString(),i=s.indexOf(".");return-1===i||s.slice(i+1).length<=t}(s,t.max_decimal_place))}default:return!0}}))}(e,this._validators);return t}))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:t.deundefined({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}class D extends t.APIRequestCommand{constructor(e){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_FORMS}/${e.formId}/submit`,this.params=t.deundefined({message_id:e.messageId,items:e.items})}}exports.ScheduledStatus=void 0,(R=exports.ScheduledStatus||(exports.ScheduledStatus={})).PENDING="pending",R.SENT="sent",R.FAILED="failed",R.CANCELED="canceled",exports.InternalScheduledStatus=void 0,(x=exports.InternalScheduledStatus||(exports.InternalScheduledStatus={})).PENDING="pending",x.IN_QUEUE="in_queue",x.SENT="sent",x.FAILED="failed",x.CANCELED="canceled",x.REMOVED="removed";class q extends g{constructor(e,t){var s,i,n,r,l,c,p,m,_;super(e,t),this.parentMessage=null,this.silent=!1,this.isOperatorMessage=!1,this.threadInfo=null,this.reactions=[],this.appleCriticalAlertOptions=null,this.scheduledInfo=null,this.suggestedReplies=null,this.myFeedback=null,this.myFeedbackStatus="NOT_APPLICABLE",this.messageForm=null,this._isContinuousMessages=!1,this._scheduledStatus=null,this.messageId=null!==(i=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==i?i:0,this.parentMessageId=null!==(n="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==n?n:0,this.threadInfo=t.thread_info?new a(this._iid,t.thread_info):null,this.reactions=t.reactions?t.reactions.map((e=>new o(e))):[],this.ogMetaData=t.og_tag?new d(t.og_tag):null,this.silent=null!==(r=t.silent)&&void 0!==r&&r,this.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,this.appleCriticalAlertOptions=t.apple_critical_alert_options?new u(t.apple_critical_alert_options):null,"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._isContinuousMessages=null!==(c=t.is_continuous_messages)&&void 0!==c&&c,this.myFeedback=h._isSubmitted(t.feedback)?new h(t.feedback):null,this.myFeedbackStatus=h._getStatus(t.feedback),this.suggestedReplies=null!==(m=null===(p=t.extended_message_payload)||void 0===p?void 0:p.suggested_replies)&&void 0!==m?m:null,this.messageForm=k.isMessageFormPayload(t.extended_message_payload)?new k(this.messageId,t.extended_message_payload.message_form):null,this.message=null!==(_=t.message)&&void 0!==_?_:""}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?a.payloadify(e.threadInfo):null,reactions:e.reactions.map((e=>o.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?u.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledMessageId,scheduled_at:null===(i=e.scheduledInfo)||void 0===i?void 0:i.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?h.payloadify(e.myFeedback):h._getPayloadByStatus(e.myFeedbackStatus),message:e.message})))}static _getParentMessageInfoPayload(e){return t.deundefined(t.undefineNullProps({type:_(e.messageType),ts:e.createdAt,user:e.sender?p.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null}))}isIdentical(e){return this.messageId===e.messageId}applyThreadInfoUpdateEvent(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}applyReactionEvent(e){if(this.messageId===e.messageId){let t=!1;for(let s=0;s=t)return this.parentMessage=e,!0}return!1}_triggerThreadInfoUpdatedEvent(){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e}=t.Vault.of(this._iid);e.dispatch(new N({channelType:t.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))}))}markThreadAsRead(){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=t.Vault.of(this._iid),s=new T({channelUrl:this.channelUrl,messageId:this.messageId});yield e.send(s),this.threadInfo&&0!==this.threadInfo.unreadReplyCount&&(this.threadInfo.unreadReplyCount=0,yield this._triggerThreadInfoUpdatedEvent())}))}setPushNotificationEnabled(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),i=new b({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e});yield s.send(i),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e)}))}submitMessageForm(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid);let i=null,n=null;const a=this.messageForm;if(!e&&a){if(!a.isSubmittable)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(a.isSubmitted)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});i=a.id,n=a.items.reduce(((e,t)=>(e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e)),[])}else e&&(i=e.formId,n=Object.entries(e.answers).reduce(((e,[s,i])=>{const n=Number(s);if(Number.isNaN(n))throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:n,value:i}),e}),[]));if(!i||!n)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});const r=new D({messageId:this.messageId,formId:i,items:n});yield s.send(r)}))}submitFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new M({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(S);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}))}))}updateFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new O({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(A);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}))}))}deleteFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new C({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e});yield s.send(n),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}))}))}}class F extends q{constructor(e,s){var i,n,a,r;if(super(e,s),this.reqId="",this.replyToChannel=!1,this.errorCode=0,this.sender=s.user?new p(this._iid,s.user):s.sender_id,this.reqId=null!==(n=null!==(i=s.req_id)&&void 0!==i?i:s.request_id)&&void 0!==n?n:"",this.replyToChannel=null!==(a=s.is_reply_to_channel)&&void 0!==a&&a,s.request_state&&t.isEnumOf(t.SendingStatus,s.request_state)&&(this.sendingStatus=s.request_state),!this.sendingStatus)if(this.messageId>0)this.sendingStatus=t.SendingStatus.SUCCEEDED;else if(this.scheduledInfo)switch(s.scheduled_status&&(this._scheduledStatus=s.scheduled_status),s.scheduled_status){case exports.InternalScheduledStatus.SENT:case exports.InternalScheduledStatus.IN_QUEUE:this.sendingStatus=t.SendingStatus.SUCCEEDED;break;case exports.InternalScheduledStatus.PENDING:this.sendingStatus=t.SendingStatus.SCHEDULED;break;case exports.InternalScheduledStatus.FAILED:case exports.InternalScheduledStatus.REMOVED:this.sendingStatus=t.SendingStatus.FAILED;break;case exports.InternalScheduledStatus.CANCELED:this.sendingStatus=t.SendingStatus.CANCELED}else this.sendingStatus=t.SendingStatus.PENDING;this.errorCode=null!==(r=s.error_code)&&void 0!==r?r:0,this._messageToken=s.mesg_token}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{user:p.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}get isResendable(){return(this.sendingStatus===t.SendingStatus.FAILED||this.sendingStatus===t.SendingStatus.CANCELED)&&t.isResendableError(this.errorCode)}isIdentical(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}const B={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},j=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo);class V extends q{constructor(e,s){var i,n,a;if(super(e,s),this.translations={},this.messageType=t.MessageType.ADMIN,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(a=i.file)||void 0===a?void 0:a.require_auth}))))}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{translations:e.translations,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class z{constructor(e){var s,i;this.detail={},this.type=null!==(s=e.type)&&void 0!==s?s:"",this.vendor=null!==(i=e.vendor)&&void 0!==i?i:"",e.detail&&t.isTypeOf("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}static payloadify(e){return t.deundefined(t.undefineNullProps({type:e.type,vendor:e.vendor,detail:e.detail}))}}class ${constructor(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}static payloadify(e){return t.deundefined({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}class Q extends F{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.messageParams=null,this.translations={},this.translationTargetLanguages=[],this.messageSurvivalSeconds=-1,this.plugins=[],this._poll=null,this.messageType=t.MessageType.USER,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},this.translationTargetLanguages=null!==(n=s.target_langs)&&void 0!==n?n:[],0===Object.keys(this.translations).length&&this.translationTargetLanguages.length>0)for(const e of this.translationTargetLanguages)this.translations[e]="";if(this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,this.plugins=s.plugins?s.plugins.map((e=>new z(e))):[],this._poll=s.poll?new t.Poll(this._iid,s.poll):null,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(o=i.file)||void 0===o?void 0:o.require_auth}))))}s.review_info&&(this.messageReviewInfo=new $(s.review_info))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((e=>z.payloadify(e))),poll:e._poll?t.Poll.payloadify(e._poll):null,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null,review_info:e.messageReviewInfo?$.payloadify(e.messageReviewInfo):void 0})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.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 G extends F{constructor(e,s){var i,n,a,r,o,l,d,u;if(super(e,s),this.messageParams=null,this.fileInfoList=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE,this.data=null!==(a=null!==(n=null===(i=s.file)||void 0===i?void 0:i.data)&&void 0!==n?n:s.custom)&&void 0!==a?a:"",this.fileInfoList=null!==(o=null===(r=s.files)||void 0===r?void 0:r.map((t=>new w(e,t))))&&void 0!==o?o:[],this.messageSurvivalSeconds=null!==(l=s.message_survival_seconds)&&void 0!==l?l:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(d=i.file)||void 0===d?void 0:d.url,require_auth:null===(u=i.file)||void 0===u?void 0:u.require_auth}))))}}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}static payloadify(e){var s,i,n,a,r,o;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{file:{name:null!==(i=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.fileName)&&void 0!==i?i:"",size:null!==(a=null===(n=e.fileInfoList[0])||void 0===n?void 0:n.fileSize)&&void 0!==a?a:0,type:null!==(o=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}static _isMultipleFilesMessagePayload(e){const t=e.files;return Array.isArray(t)&&t.length>=2}static _isMultipleFilesMessageSerializedData(e){const t=e.fileInfoList;return Array.isArray(t)}}var K;exports.NotificationMessageStatus=void 0,(K=exports.NotificationMessageStatus||(exports.NotificationMessageStatus={})).SENT="SENT",K.READ="READ";class H extends g{constructor(e,s){var i,n;if(super(e,s),this.notificationData=null,this.notificationId=s.notification_message_id,this.messageType=t.MessageType.ADMIN,this.messageStatus=null!==(i=s.message_status)&&void 0!==i?i:exports.NotificationMessageStatus.SENT,this.priority=null!==(n=s.priority)&&void 0!==n?n:t.NotificationPriority.NORMAL,this.notificationEventDeadline=s.notification_event_deadline,0===this.extendedMessage.sub_type)try{const{label:e,tags:t=[],template_key:s,template_variables:i}=JSON.parse(this.extendedMessage.sub_data);this.notificationData={label:e,tags:t,templateKey:s,templateVariables:i}}catch(e){}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}isIdentical(e){return this.notificationId===e.notificationId}}const W=(e,t)=>{if(t.notification_message_id)return new H(e,t);switch(t.type){case"MESG":return new Q(e,t);case"FILE":return G._isMultipleFilesMessagePayload(t)?new G(e,t):new Y(e,t);case"ADMM":case"BRDM":return new V(e,t);default:return null}};class Y extends F{constructor(e,i){var n,a,r,o,l,d,u,c,h,p,m,_,g,y;super(e,i),this.messageParams=null,this.plainUrl="",this.requireAuth=!1,this.thumbnails=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE;const f=i.file;if(this.plainUrl=(null!==(a=null!==(n=null==f?void 0:f.url)&&void 0!==n?n:i.url)&&void 0!==a?a:"").split("?auth=")[0],this.name=null!==(o=null!==(r=null==f?void 0:f.name)&&void 0!==r?r:i.name)&&void 0!==o?o:"File",this.size=null!==(d=null!==(l=null==f?void 0:f.size)&&void 0!==l?l:i.size)&&void 0!==d?d:0,this.data=null!==(c=null!==(u=null==f?void 0:f.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",this.type=f?null!==(h=f.type)&&void 0!==h?h:"":null!==(p=i.type)&&void 0!==p?p:"",this.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,this.thumbnails=i.thumbnails?i.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this.requireAuth)})):[],this.messageSurvivalSeconds=null!==(_=i.message_survival_seconds)&&void 0!==_?_:-1,i.parent_message_info){const s=i.parent_message_info;this.parentMessage=W(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},s),{created_at:s.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:s.file,url:null===(g=s.file)||void 0===g?void 0:g.url,require_auth:null===(y=s.file)||void 0===y?void 0:y.require_auth}))))}}static payloadify(e){var s;return t.deundefined(t.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===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.plainUrl,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}=t.Vault.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class J extends t.InstancedObject{static getPlainUrl(e){return e instanceof J?e._plainUrl:e.fileUrl}constructor(e,{file:t,fileUrl:s,fileName:i,fileSize:n,mimeType:a,thumbnailSizes:r,_uploadedMetaData:o,_thumbnails:l}){super(e),this._plainUrl=s,this.file=t,this.fileName=i,this.fileSize=n,this.mimeType=a,this.thumbnailSizes=r,this._uploadedMetaData=o,this._thumbnails=l}get fileUrl(){var e;const{sessionManager:s}=t.Vault.of(this._iid);return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&s.ekey?`${this._plainUrl}?auth=${s.ekey}`:this._plainUrl}set fileUrl(e){this._plainUrl=e}toJSON(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}class X extends t.WebSocketRequestCommand{constructor(e){var i,n,a,r;let o=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((e=>e.userId)))),super({code:"FILE",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,files:e.files?se(e.files):null,url:e.url,name:null!==(i=e.fileName)&&void 0!==i?i:"",type:null!==(n=e.mimeType)&&void 0!==n?n:"",size:null!==(a=e.fileSize)&&void 0!==a?a:0,custom:e.data,custom_type:e.customType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((e=>s.payloadify(e))),require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:o,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?u.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,message:e.message}))})}}class Z extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId)))),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e.channelType)}/${encodeURIComponent(e.channelUrl)}/messages`,this.params=t.deundefined(t.undefineNullProps({message_type:t.MessageType.FILE,user_id:e.userId,files:e.files?se(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===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:e.requireAuth,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((e=>m.payloadify(e))),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}))}}class ee extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"FILE",i),this.message=i.files&&i.files.length>=2?new G(e,i):new Y(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class te extends t.APIResponseCommand{constructor(e,s){var i,n,a,r;super(e,s),this.message=s.files&&s.files.length>=2?new G(e,s):new Y(e,s);const{sdkState:o}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(a=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(n=this.message.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)))&&void 0!==a?a:[],o.userId),this.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r}}function se(e){return e.map((e=>{var i,n;return t.deundefined(t.undefineNullProps({url:J.getPlainUrl(e),file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var ie;!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"}(ie||(ie={}));class ne{constructor(e,{sdkState:s,dispatcher:i,requestQueue:n,onlineDetector:a,cacheContext:r}){this._queueMap=new Map,this._iid=e,this._sdkState=s,this._requestQueue=n,this._cacheContext=r,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof t.ConnectionStateChangeCommand&&(this._connectionState=e.stateType)})),this._onlineDetector=a}get _shouldSendThroughWebSocket(){return this._connectionState===t.ConnectionStateType.CONNECTED||this._connectionState===t.ConnectionStateType.CONNECTING||this._connectionState===t.ConnectionStateType.RECONNECTING}_sendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._createSendFileMessageRequestParams(e,s);if(this._shouldSendThroughWebSocket){const e=new X(t),s=yield this._requestQueue.send(e),{message:i}=s.as(ee);return i}{const e=new Z(Object.assign(Object.assign({},t),{userId:this._sdkState.userId})),s=yield this._requestQueue.send(e),{message:i}=s.as(te);return i}}))}_createSendFileMessageRequestParams(e,t){const s=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){const e=t.params;s.files=e.fileInfoList}else{const e=t.params;s.url=e.fileUrl,s.requireAuth=e.requireAuth}return s}_resolveMessageQueue(e){var s;return t.__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 n=[];let a=!0;for(const r of i.messageQueue)switch(r.state){case ie.PENDING:case ie.UPLOADING:a=!1,n.push(r);break;case ie.UPLOADED:if(a)try{r.state=ie.SENDING;const s=yield this._sendFileMessage(e,r);r.deferred.resolve(s),yield t.sleep(100)}catch(e){r.deferred.reject(e)}else n.push(r);break;case ie.FAILED:{const e=null!==(s=r.error)&&void 0!==s?s:t.SendbirdError.unknown;r.deferred.reject(e.code===t.SendbirdErrorCode.REQUEST_CANCELED?t.SendbirdError.fileUploadCanceled:e);break}}const r=i.isResolveRequestPending;i.messageQueue=n,i.isResolving=!1,i.isResolveRequestPending=!1,r&&(yield this._resolveMessageQueue(e))}}))}_uploadNextPendingItem(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i){const n=i.messageQueue.find((e=>e.state===ie.PENDING));if(n){if(n.multipleFileUploadInfo){const{uploadIndex:a,uploadCount:r,requestHandler:o}=n.multipleFileUploadInfo,l=n.params,d=l.fileInfoList[a];t.isFile(d.file)&&!(null===(s=d._uploadedMetaData)||void 0===s?void 0:s.isUploaded)?yield this._tryUploadNextItemAndUpdateItemState(e,i,n):n.state=ae.requestId===t.requestId));s>=0&&e.uploadQueue.splice(s,1)}_uploadNextFileForSingleFileItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const t=new i({file:a.file,channelUrl:e.url,thumbnailSizes:a.thumbnailSizes,requestId:s.requestId}),d=yield this._requestQueue.send(t),{url:u,fileSize:c=a.fileSize,thumbnails:h=[],requireAuth:p=!1}=d.as(n);a.fileName=null!==(r=a.fileName)&&void 0!==r?r:a.file.name,a.mimeType=null!==(o=a.mimeType)&&void 0!==o?o:a.file.type,a.fileSize=null!==(l=a.fileSize)&&void 0!==l?l:a.file.size,a.fileUrl=u,a.fileSize=c,a.requireAuth=p,a._thumbnails=h}))}_uploadNextFileForMultipleFilesItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const{uploadIndex:t}=s.multipleFileUploadInfo,d=a.fileInfoList[t],u=new i({file:d.file,channelUrl:e.url,thumbnailSizes:d.thumbnailSizes,requestId:s.requestId}),c=yield this._requestQueue.send(u),{url:h,fileSize:p=d.fileSize,thumbnails:m,requireAuth:_=!1}=c.as(n);d.fileName=null!==(r=d.fileName)&&void 0!==r?r:d.file.name,d.mimeType=null!==(o=d.mimeType)&&void 0!==o?o:d.file.type,d.fileSize=null!==(l=d.fileSize)&&void 0!==l?l:d.file.size,d.file=void 0,d.fileUrl=h,d.fileSize=p,d._thumbnails=m,d._uploadedMetaData=Object.assign(Object.assign({},d._uploadedMetaData),{requireAuth:_,isUploaded:!0}),d instanceof J||(a.fileInfoList[t]=new J(this._iid,d))}))}request(e,s,i,n={}){return t.__awaiter(this,void 0,void 0,(function*(){if(!this._queueMap.has(e.url)){const t={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1};this._queueMap.set(e.url,t)}const a=this._queueMap.get(e.url),r=new t.Deferred,o={requestId:s,params:i,state:ie.PENDING,deferred:r};if(function(e){return"fileInfoList"in e}(i)){const e=i,t=Object.assign({uploadIndex:0,uploadCount:e.fileInfoList.length},n);o.multipleFileUploadInfo=t}return a.messageQueue.push(o),this._uploadNextPendingItem(e),r.promise}))}cancel(e,s){const i=this._queueMap.get(e.url);if(i){const n=s?[i.messageQueue.find((e=>e.requestId===s))]:[...i.messageQueue];for(const s of n)if(s)switch(s.state){case ie.PENDING:if(s.state=ie.FAILED,s.error=t.SendbirdError.requestCanceled,s.multipleFileUploadInfo&&!s.multipleFileUploadInfo.isCopy){const{uploadIndex:e,requestHandler:i}=s.multipleFileUploadInfo,n=s.params.fileInfoList[e];null==i||i._triggerOnFileUploaded(s.requestId,e,n,t.SendbirdError.fileUploadCanceled)}this._resolveMessageQueue(e);break;case ie.UPLOADING:this._requestQueue.cancel(s.requestId),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s.requestId}))}}else s&&(this._requestQueue.cancel(s),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s})))}}const ae={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:t.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},re=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo)&&t.isTypeOf("boolean",e.showSubchannelMessagesOnly),oe={replyType:t.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},le=e=>t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo);class de extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,includeMetaArray:n,includeReactions:a,includeThreadInfo:r,includeParentMessageInfo:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}`,this.params={is_sdk:!0,with_sorted_meta_array:n,include_reactions:a,include_thread_info:r,include_parent_message_info:o,include_poll_details:!0}}}class ue extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}class ce extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,prevResultSize:a,nextResultSize:r,isInclusive:o,reverse:l,messageTypeFilter:d,customTypesFilter:u,senderUserIdsFilter:c,replyType:h,includeMetaArray:p,includeReactions:m,parentMessageId:_,includeThreadInfo:g,includeParentMessageInfo:y,showSubchannelMessagesOnly:f,checkingHasNext:v,checkingContinuousMessages:I}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages`,this.params=t.deundefined(t.undefineNullProps({is_sdk:!0,prev_limit:a,next_limit:r,include:o,reverse:l,message_ts:i,message_id:n,message_type:null!=d?d:null,custom_types:u,sender_ids:c,include_reply_type:h,with_sorted_meta_array:p,include_reactions:m,parent_message_id:_,include_thread_info:g,include_parent_message_info:y,show_subchannel_message_only:f,include_poll_details:!0,checking_has_next:v,checking_continuous_messages:I}))}}class he extends t.APIResponseCommand{constructor(e,t){super(e,t),void 0!==t.is_continuous_messages&&(this.isContinuousMessages=t.is_continuous_messages),void 0!==t.has_next&&(this.hasNext=t.has_next),this.messages=t.messages.map((t=>W(e,t)))}}class pe extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,replyType:a,includeMetaArray:r,includeReactions:o,includeThreadInfo:l,includeParentMessageInfo:d}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/changelogs`,this.params={change_ts:i,token:n,with_sorted_meta_array:r,include_reactions:o,include_thread_info:l,include_reply_type:a,include_parent_message_info:d,include_poll_details:!0}}}class me extends t.APIResponseCommand{constructor(e,t){super(e,t),this.updatedMessages=t.updated.map((t=>W(e,t))),this.deletedMessagesInfo=t.deleted.map((e=>({messageId:e.message_id,deletedAt:e.deleted_at}))),this.hasMore=t.has_more,this.nextToken=t.next}}class _e extends t.APIRequestCommand{constructor({channelUrl:e,scheduledMessageId:s}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/scheduled_messages/${encodeURIComponent(s)}`,this.params={}}}class ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}var ye;exports.RestrictionType=void 0,(ye=exports.RestrictionType||(exports.RestrictionType={})).MUTED="muted",ye.BANNED="banned";class fe{constructor(e){var s,i,n,a;this.restrictionType=null,t.isEnumOf(exports.RestrictionType,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(s=e.description)&&void 0!==s?s:null,this.endAt=null!==(n=null!==(i=e.end_at)&&void 0!==i?i:e.muted_end_at)&&void 0!==n?n:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}static payloadify(e){return t.deundefined(t.undefineNullProps({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}class ve extends t.User{constructor(e,t){super(e,t),this.restrictionInfo=new fe(t)}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),fe.payloadify(e.restrictionInfo))))}}class Ie{constructor(){this._onPending=t.noop,this._onFailed=t.noop,this._onSucceeded=t.noop}_trigger(e){switch(null==e?void 0:e.sendingStatus){case t.SendingStatus.PENDING:0===e.errorCode&&this._onPending(e);break;case t.SendingStatus.SCHEDULED:case t.SendingStatus.SUCCEEDED:this._onSucceeded(e)}}_triggerFailed(e,s){switch(null==s?void 0:s.sendingStatus){case t.SendingStatus.FAILED:case t.SendingStatus.CANCELED:this._onFailed(e,s.scheduledInfo?null:s)}}onPending(e){return this._onPending=e,this}onFailed(e){return this._onFailed=e,this}onSucceeded(e){return this._onSucceeded=e,this}}const Ee={data:void 0,customType:void 0,mentionType:t.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},Te=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isTypeOf("number",e.parentMessageId,!0)&&t.isTypeOf("boolean",e.isReplyToChannel)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0)&&t.isTypeOf("boolean",e.isPinnedMessage,!0),be=e=>({isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}),Me=Object.assign(Object.assign({},Ee),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function Se(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}const Oe=e=>{var s;return t.deundefined(t.undefineNullProps({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(s=e.poll)||void 0===s?void 0:s.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations),extendedMessagePayload:e.extendedMessagePayload}))},Ae=e=>Te(e)&&t.isTypeOf("string",e.message)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0)&&t.isTypeOf("object",e.extendedMessagePayload,!0);var Ce;!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Ce||(Ce={}));const we=e=>"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob,Ne=e=>e===Ce.BLOB||e===Ce.FILE,Pe=e=>({file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}),Ue=Object.assign(Object.assign({},Ee),{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,message:void 0});function Re(e){var s,i,n,a;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=e.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails,message:e.message}))}const xe=(e,s)=>{var i;return e.messageParams?(!e.url&&t.isFile(s)&&(e.messageParams.file=s),e.messageParams):t.deundefined(t.undefineNullProps({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:s,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),message:e.message}))},ke=e=>Te(e)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&t.isTypeOf("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),Le={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},De=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0),qe=Object.assign(Object.assign({},Le),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Fe=e=>De(e)&&t.isTypeOf("string",e.message,!0)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0),Be=Object.assign({},Le);class je extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,token:i,limit:n}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(e)}/operators`,this.params={token:i,limit:n}}}class Ve extends t.APIResponseCommand{constructor(e,s){super(e,s),this.operators=s.operators.map((s=>new t.User(e,s))),this.token=s.next}}class ze extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;{const e=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new je(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),i=yield e.send(s),{operators:n,token:a}=i.as(Ve);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return e}}throw t.SendbirdError.invalidParameters}))}}class $e extends t.ChannelDataListQuery{constructor(e,s,i,n){var a,r,o,l,d,u,c,h,p,m;super(e,s,i,n),this.reverse=!1,this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.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!==(a=n.reverse)&&void 0!==a&&a,this.messageTypeFilter=null!==(r=n.messageTypeFilter)&&void 0!==r?r:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,this.senderUserIdsFilter=null!==(l=n.senderUserIdsFilter)&&void 0!==l?l:null,this.replyType=null!==(d=n.replyType)&&void 0!==d?d:t.ReplyType.NONE,this.includeMetaArray=null!==(u=n.includeMetaArray)&&void 0!==u&&u,this.includeReactions=null!==(c=n.includeReactions)&&void 0!==c&&c,this.includeParentMessageInfo=null!==(h=n.includeParentMessageInfo)&&void 0!==h&&h,this.includeThreadInfo=null!==(p=n.includeThreadInfo)&&void 0!==p&&p,this.showSubchannelMessagesOnly=null!==(m=n.showSubchannelMessagesOnly)&&void 0!==m&&m}_validate(){return super._validate()&&t.isTypeOf("boolean",this.reverse)&&t.isEnumOf(t.MessageTypeFilter,this.messageTypeFilter)&&t.isEnumOf(t.ReplyType,this.replyType)&&t.isArrayOf("string",this.customTypesFilter,!0)&&t.isArrayOf("string",this.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",this.includeMetaArray)&&t.isTypeOf("boolean",this.includeReactions)&&t.isTypeOf("boolean",this.includeParentMessageInfo)&&t.isTypeOf("boolean",this.includeThreadInfo)&&t.isTypeOf("boolean",this.showSubchannelMessagesOnly)}load(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=zi.of(this._iid),s=yield e.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t.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,...s.map((e=>e.createdAt))),this._hasNext=s.length>=this.limit,this._isLoading=!1,s}return[]}throw t.SendbirdError.invalidParameters}))}}class Qe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={limit:n,token:a}}}class Ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.mutedUsers=[];const{next:s,muted_list:i}=t;this.token=s,i&&i.length>0&&(this.mutedUsers=i.map((t=>new ve(e,t))))}}class Ke extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Qe(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{mutedUsers:n,token:a}=i.as(Ge);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class He extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({limit:n,token:a})}}class We extends t.APIResponseCommand{constructor(e,t){super(e,t),this.bannedUsers=[];const{next:s,banned_list:i}=t;this.token=s,i&&i.length>0&&(this.bannedUsers=i.map((t=>new ve(e,t.user))))}}class Ye extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new He(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{bannedUsers:n,token:a}=i.as(We);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}var Je;exports.ReportCategory=void 0,(Je=exports.ReportCategory||(exports.ReportCategory={})).SPAM="spam",Je.HARASSING="harassing",Je.SUSPICIOUS="suspicious",Je.INAPPROPRIATE="inappropriate";class Xe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class Ze extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${n}`}}class tt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.isMuted=!1,this.startAt=0,this.endAt=0;const{is_muted:s,start_at:i,end_at:n,remaining_duration:a,description:r}=t;this.isMuted=s,this.startAt=i,this.endAt=n,this.remainingDuration=a,this.description=r}}class st extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={keys:n,include_ts:!0}}}class it extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0}}}class at extends t.APIResponseCommand{constructor(e,t){var s,i;super(e,t),this.metaData=null!==(s=t.metadata)&&void 0!==s?s:{},this.ts=null!==(i=t.ts)&&void 0!==i?i:null}}class rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n,upsert:a}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0,upsert:null!=a&&a}}}class ot extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class lt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class dt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata/${n}`,this.params={include_ts:!0}}}class ut extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={include_ts:!0}}}class ht extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class pt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={keys:n}}}class mt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class _t extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n}}}class gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class yt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n,upsert:a=!1,mode:r="set"}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n,upsert:a,mode:r}}}class ft extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class vt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class It extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter/${n}`,this.params={}}}class Et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={}}}class Tt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={user_id:n,seconds:a,description:r}}}class bt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Mt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${encodeURIComponent(n)}`}}class St extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Ot extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({user_id:n,seconds:a,description:r})}}class At extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data),s.data.member_count&&(this.memberCount=s.data.member_count),s.data.joined_member_count&&(this.joinedMemberCount=s.data.joined_member_count)}}class Ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban/${encodeURIComponent(n)}`}}class wt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,freezing:n}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/freeze`,this.params={freeze:n}}}class Pt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.freeze=s.data.freeze}}class Ut extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}`,this.params={report_category:n,reporting_user_id:a,report_description:r}}}class Rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,description:o}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_REPORT}/users/${r}`,this.params={channel_url:s,channel_type:i===t.ChannelType.OPEN?"open_channels":"group_channels",report_category:n,reporting_user_id:a,report_description:o}}}class xt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,messageId:o,description:l,messageToken:d}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}/messages/${o}`,this.params=t.deundefined({report_category:n,reporting_user_id:a,report_description:l,offending_user_id:r,mesg_token:d})}}class kt extends t.WebSocketRequestCommand{constructor(e){let s=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MESG",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage,extended_message_payload:e.extendedMessagePayload}))})}}class Lt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"MESG",i),this.message=new Q(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class Dt extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,poll_id:e.pollId}))})}}class qt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"MEDI",i),this.message=new Q(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class Ft extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"FEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,apple_critical_alert_options:e.appleCriticalAlertOptions}))})}}class Bt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"FEDI",i),this.message=new Y(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class jt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class Vt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(t)}}class zt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class $t extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(Object.assign({},t))}}class Qt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,translationTargetLanguages:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}/translation`,this.params={target_langs:n}}}class Gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Kt extends t.APIRequestCommand{constructor(e){var s;super();let i=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:a}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(n)}/${encodeURIComponent(a)}/scheduled_messages`,this.params=t.deundefined(t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class Ht extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Wt extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId))));const{channelType:r,channelUrl:o}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(r)}/${encodeURIComponent(o)}/scheduled_messages`,this.params=t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.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((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})}}class Yt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Y(e,t)}}class Jt extends t.APIRequestCommand{constructor({pollId:e,title:s,data:i,allowUserSuggestion:n,allowMultipleVotes:a,closeAt:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`,this.params={title:s,data:i,allow_user_suggestion:n,allow_multiple_votes:a,close_at:r}}}class Xt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Zt extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`}}class es extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/close`}}class ts extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ss extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,pollId:i,optionText:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(i)}/options`,this.params={channel_url:e,channel_type:s,text:n}}}class is extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ns extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s,optionText:i}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`,this.params={text:i}}}class as extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class rs extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`}}class os extends t.WebSocketRequestCommand{constructor({reqId:e,channelType:s,channelUrl:i,pollId:n,pollOptionIds:a}){super({code:"VOTE",ackRequired:!0,payload:t.deundefined({req_id:e,channel_type:s===t.ChannelType.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:n,option_ids:a})})}}class ls extends t.WebSocketEventCommand{constructor(e,s,i){super(e,"VOTE",i),this.event=new t.PollVoteEvent(i),this.channelUrl=i.channel_url,this.channelType=i.channel_type}}const ds="Message",us="NotificationMessage";const cs=Object.assign(Object.assign({},Ee),{fileInfoList:[],message:""}),hs=e=>(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>e.maxWidth>0&&e.maxHeight>0)));class ps extends Ie{constructor(){super(...arguments),this._onFileUploaded=t.noop}_triggerOnFileUploaded(e,t,s,i){this._onFileUploaded(e,t,s,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}}class ms extends t.InstancedObject{constructor(e,t){super(e),this.message=null,this.message=W(e,t.message)}}class _s extends t.APIRequestCommand{constructor(e){const{channelType:s,channelUrl:i,limit:n,token:a,includeReactions:r,includeMetaArray:o,includeParentMessageInfo:l,includeThreadInfo:d,includePollDetails:u}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(i)}/pinned_messages`,this.params=t.deundefined({limit:n,token:a,include_reactions:r,with_sorted_meta_array:o,include_thread_info:d,include_parent_message_info:l,include_poll_details:u})}}class gs extends t.APIResponseCommand{constructor(e,t){super(e,t);const{pinned_messages:s,has_more:i,next:n}=t;this.pinnedMessages=s.map((t=>new ms(e,t))),this.hasMore=i,this.token=n}}class ys extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i),this.includeMetaArray=i.includeMetaArray,this.includeReactions=i.includeReactions,this.includeParentMessageInfo=i.includeParentMessageInfo,this.includeThreadInfo=i.includeThreadInfo,this.includePollDetails=i.includePollDetails}_validate(){return super._validate()&&t.isTypeOf("boolean",this.includeMetaArray,!0)&&t.isTypeOf("boolean",this.includeReactions,!0)&&t.isTypeOf("boolean",this.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",this.includeThreadInfo,!0)&&t.isTypeOf("boolean",this.includePollDetails,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new _s(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{pinnedMessages:n,hasMore:a,token:r}=i.as(gs);return this._token=r,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class fs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}class vs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}var Is;exports.SendMessageRequestType=void 0,(Is=exports.SendMessageRequestType||(exports.SendMessageRequestType={})).SEND="send",Is.RESEND="resend",Is.COPY="copy";class Es extends t.InstancedObject{get url(){return this._url}get name(){return this._name}set name(e){this._name=e}get createdAt(){return this._createdAt}toJSON(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}constructor(e,s){var i,n,a,r,o,l,d;super(e),this._name="",this._createdAt=0,this.pinnedMessageIds=[],this.channelType=t.ChannelType.BASE,this.coverUrl="",this.customType="",this.data="",this.isFrozen=!1,this.isEphemeral=!1,this.creator=null,this._messageCollectionLastAccessedAt=0,this._url=s.channel_url,this._name=null!==(i=s.name)&&void 0!==i?i:"",this._createdAt=1e3*s.created_at,this.coverUrl=null!==(n=s.cover_url)&&void 0!==n?n:"",this.customType=null!==(a=s.custom_type)&&void 0!==a?a:"",this.data=null!==(r=s.data)&&void 0!==r?r:"",this.isFrozen=null!==(o=s.freeze)&&void 0!==o&&o,this.isEphemeral=null!==(l=s.is_ephemeral)&&void 0!==l&&l,this.creator=s.created_by?new t.User(this._iid,s.created_by):null,s.metadata&&Object.keys(s.metadata).length>0&&s.ts?(this._cachedMetaData=new Map,Object.keys(s.metadata).forEach((e=>{this._cachedMetaData.set(e,{value:s.metadata[e],isRemoved:!1,updatedAt:s.ts})}))):"string"==typeof s.metadata&&(this._cachedMetaData=new Map(Object.entries(JSON.parse(s.metadata)))),this.pinnedMessageIds=null!==(d=s.pinned_message_ids)&&void 0!==d?d:[]}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(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?t.User.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}isGroupChannel(){return this.channelType===t.ChannelType.GROUP}isOpenChannel(){return this.channelType===t.ChannelType.OPEN}isFeedChannel(){return this.channelType===t.ChannelType.FEED}get cachedMetaData(){const e={};return this._cachedMetaData?(this._cachedMetaData.forEach(((t,s)=>{t.isRemoved||(e[s]=t.value)})),e):e}get messageCollectionLastAccessedAt(){return this._messageCollectionLastAccessedAt}_serializeCachedMetaData(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}_updateMessageCollectionLastAccessedAt(){this._messageCollectionLastAccessedAt=Date.now()}_update(e){const s=t.deundefined(e);Object.assign(this,s)}_upsertCachedMetaData(e,t){Object.keys(e).forEach((s=>{this._cachedMetaData||(this._cachedMetaData=new Map);const i=this._cachedMetaData.get(s);(!i||i.updatedAt<=t)&&this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})}))}_updateCachedMetaData(e,t){let s=!1;return this._cachedMetaData?this._cachedMetaData.forEach(((i,n)=>{var a;i.updatedAt<=t&&(this._cachedMetaData.set(n,{value:null!==(a=e[n])&&void 0!==a?a:i.value,isRemoved:!e[n],updatedAt:t}),s=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((s=>{this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})})),s=!0),{isUpdated:s}}_removeFromCachedMetaData(e,t){this._cachedMetaData&&e.forEach((e=>{const s=this._cachedMetaData.get(e);s&&s.updatedAtm.payloadify(e))):null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,created_at:i,user:a.currentUser?p.payloadify(a.currentUser):null,req_id:s,request_state:t.SendingStatus.PENDING,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>t.User.payloadify(e)))}))}_createPendingUserMessage(e,s,i){const n={};if(e.translationTargetLanguages)for(const t of e.translationTargetLanguages)n[t]="";const a=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.USER,message:e.message,translations:n,extended_message_payload:e.extendedMessagePayload})),r=new Q(this._iid,a);return r.messageParams=e,r}_createPendingScheduledUserMessage(e,t,s){const i=this._createPendingUserMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_createPendingFileMessage(e,i,n){var a,r,o,l,d,u,c;const h=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,i,n)),{type:t.MessageType.FILE,url:e.fileUrl,file:{name:null!==(a=e.fileName)&&void 0!==a?a:null===(r=e.file)||void 0===r?void 0:r.name,size:null!==(o=e.fileSize)&&void 0!==o?o:null===(l=e.file)||void 0===l?void 0:l.size,type:null!==(d=e.mimeType)&&void 0!==d?d:null===(u=e.file)||void 0===u?void 0:u.type,data:e.data},thumbnails:null===(c=e._thumbnails)||void 0===c?void 0:c.map((e=>s.payloadify(e))),message:e.message})),p=new Y(this._iid,h);return p.messageParams=e,p}_createPendingMultipleFilesMessage(e,s,i){const n=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.FILE,file:e.fileInfoList.length>0?{name:e.fileInfoList[0].fileName,size:e.fileInfoList[0].fileSize,type:e.fileInfoList[0].mimeType,data:e.data}:void 0,message:e.message})),a=new G(this._iid,n);return a.messageParams=e,a}_validateFailedFileMessageHasFile(e,s){var i;return Boolean(e.url)||t.isFile(s)||t.isFile(null===(i=e.messageParams)||void 0===i?void 0:i.file)}_createPendingScheduledFileMessage(e,t,s){const i=this._createPendingFileMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_markMessageAsFailed(e,s,i=!1){e.errorCode=s.code,s.code===t.SendbirdErrorCode.REQUEST_CANCELED||s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=t.SendingStatus.CANCELED:i||(e.sendingStatus=t.SendingStatus.FAILED)}sendUserMessage(e){const s=Object.assign(Object.assign({},Me),e);return t.unless(Ae(s)).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(s)}_sendUserMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n,requestQueue:a}=t.Vault.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)}))));const d=new kt(Object.assign(Object.assign({},e),{channelUrl:this.url,channelType:this.channelType,reqId:r}));a.send(d).then((e=>{const{message:s}=e.as(Lt);n.dispatch(new t.MessageUpdateEventCommand({messages:[s],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(s)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendUserMessage(e){return t.unless(e instanceof Q&&!!e.messageParams).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId)}resendUserMessage(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=new t.Deferred,n=null!==(s=e.messageParams)&&void 0!==s?s:Oe(e);return this._sendUserMessage(n,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>i.reject(e))).onSucceeded((e=>i.resolve(e))),i.promise}))}updateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},qe),s);t.unless(t.isTypeOf("number",e)&&Fe(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Dt(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(qt);return o}))}copyUserMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Q&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters),t.unless(!s.poll).throw(t.SendbirdError.notSupportedError);const r=new t.Deferred,o=null!==(i=s.messageParams)&&void 0!==i?i:t.undefineNullProps(Object.assign(Object.assign({},s),{mentionType:s.mentionType,mentionedUserIds:null!==(n=s.mentionedUserIds)&&void 0!==n?n:null===(a=s.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)),translationTargetLanguages:Object.keys(s.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}));return e._sendUserMessage(o).onSucceeded((e=>{r.resolve(e)})).onFailed((e=>r.reject(e))),r.promise}))}translateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Qt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:s}),a=yield i.send(n),{message:r}=a.as(Gt);return r}))}_createScheduledUserMessage(e,s){const{requestQueue:i}=t.Vault.of(this._iid),n=Date.now(),a=this._generateRequestId();t.sleep(2).then((()=>{const i=this._createPendingScheduledUserMessage(e,a,n);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))}));const r=new Kt(Object.assign({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(r).then((e=>{const{message:i}=e.as(Ht);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((i=>{if(t.isThrowingOutside(i))throw i;t.sleep(2).then((()=>{const r=this._createPendingScheduledUserMessage(e,a,n);this._markMessageAsFailed(r,i),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(i,r)}))))}))}))}sendFileMessage(e){const s=Object.assign(Object.assign({},Ue),e);return t.unless(ke(s)).throw(t.SendbirdError.invalidParameters),this._sendFileMessage(s)}sendMultipleFilesMessage(e){var s;const i=Object.assign(Object.assign({},cs),e),n=t.Vault.of(this._iid);t.unless(((e,s=t.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT)=>Te(e)&&t.isTypeOf("string",e.message,!0)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=s&&e.fileInfoList.every((e=>hs(e))))(i,null===(s=n.appInfo)||void 0===s?void 0:s.multipleFilesMessageFileCountLimit)).throw(t.SendbirdError.invalidParameters);const a=!!e.fileInfoList.find((e=>{const t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return t.unless(!a).throw(t.SendbirdError.fileSizeLimitExceededError),this._sendMultipleFilesMessage(i)}_sendFileMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=zi.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?t.CollectionEventSource.LOCAL_MESSAGE_CANCELED:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendFileMessage(e){t.unless(e instanceof Y&&!!e.messageParams).throw(t.SendbirdError.invalidParameters);const{logger:s}=t.Vault.of(this._iid);return s.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId).onFailed((e=>{s.debug("autoResendFileMessage failed",e)})).onSucceeded((e=>{s.debug("autoResendFileMessage success",e)}))}_sendMultipleFilesMessage(e,s,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=zi.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new ps;return t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e,{requestHandler:l,isCopy:s===exports.SendMessageRequestType.COPY}).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);this._markMessageAsFailed(i,s),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_createScheduledFileMessage(e,s,i,n){const{requestQueue:a}=t.Vault.of(this._iid),r=new Wt(Object.assign(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(r).then((e=>{const{message:i}=e.as(Yt);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((a=>{if(t.isThrowingOutside(a))throw a;t.sleep(2).then((()=>{const r=this._createPendingScheduledFileMessage(e,i,n);this._markMessageAsFailed(r,a),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(a,r)}))))}))}))}sendFileMessages(e){t.unless(e.every((e=>ke(Object.assign(Object.assign({},Ue),e))))).throw(t.SendbirdError.invalidParameters);const s=new Ie;for(const t of e)this.sendFileMessage(t).onPending((e=>s._trigger(e))).onFailed(((e,t)=>s._triggerFailed(e,t))).onSucceeded((e=>s._trigger(e)));return s}resendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(e instanceof Y&&i&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const n=new t.Deferred,a=xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>n.reject(e))).onSucceeded((e=>n.resolve(e))),n.promise}))}resendMessage(e,s){var i,n;if(t.unless(e instanceof F&&!e.scheduledInfo&&e.isResendable).throw(t.SendbirdError.invalidParameters),e.isUserMessage()){const t=null!==(i=e.messageParams)&&void 0!==i?i:Oe(e);return this._sendUserMessage(t,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isFileMessage()){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(i).throw(t.SendbirdError.invalidParameters);const a=null!==(n=e.messageParams)&&void 0!==n?n:xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}updateFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},Be),s);t.unless(t.isTypeOf("number",e)&&(e=>De(e))(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Ft(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(Bt);return o}))}uploadFile(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),a=t.uuid(),r=new i({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a});r.uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a);const o=yield s.send(r),{url:l,thumbnails:d}=o.as(n);return{requestId:a,url:l,thumbnails:d}}))}cancelUploadingFileMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e)).throw(t.SendbirdError.invalidParameters);const{fileMessageQueue:s}=zi.of(this._iid);return s.cancel(this,e),!0}))}copyFileMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Y&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const r=new t.Deferred,o=t.undefineNullProps(Object.assign(Object.assign({},s),{fileUrl:s.url,fileName:s.name,fileSize:s.size,mimeType:s.type,mentionType:s.mentionType,mentionedUserIds:null!==(i=s.mentionedUserIds)&&void 0!==i?i:null===(n=s.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=s.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:s.requireAuth,isPinnedMessage:!1}));return e._sendFileMessage(o).onSucceeded((e=>r.resolve(e))).onFailed((e=>r.reject(e))),r.promise}))}copyMessage(e,s){t.unless(e instanceof Es&&s instanceof F&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=s,n=e;if(i.isUserMessage()){t.unless(!i.poll).throw(t.SendbirdError.notSupportedError);const e=Se(i);return n._sendUserMessage(e)}if(i.isFileMessage()){const e=Re(i);return n._sendFileMessage(e)}if(s.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}deleteMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){if(t.unless(e instanceof q).throw(t.SendbirdError.invalidParameters),e.messageId>0){const{requestQueue:s}=t.Vault.of(this._iid),i=new t.DeleteMessageRequestCommand({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof F?e._messageToken:void 0});yield s.send(i)}}))}addReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new jt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as(Vt);return r}))}deleteReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new zt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as($t);return r}))}_updateUserMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Dt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(qt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}_updateFileMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Ft({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(Bt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}createMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"add",!0):this._updateUserMessageMetaArray(e.messageId,i,"add",!0)}))}deleteMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"remove",!0):this._updateUserMessageMetaArray(e.messageId,i,"remove",!0)}))}addMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"add",!0):this._updateUserMessageMetaArray(e.messageId,s,"add",!0)}))}removeMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"remove",!0):this._updateUserMessageMetaArray(e.messageId,s,"remove",!0)}))}report(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isEnumOf(exports.ReportCategory,e)&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:n}=t.Vault.of(this._iid),a=new Ut({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:s});yield n.send(a)}))}reportUser(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof t.User&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new Rt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.userId,category:s,description:i});yield a.send(r)}))}reportMessage(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof F&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new xt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:s,description:i,messageToken:e._messageToken});yield a.send(r)}))}updatePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&(e=>t.isTypeOf("string",e.title,!0)&&t.validatePollData(e.data)&&t.isTypeOf("boolean",e.allowUserSuggestion,!0)&&t.isTypeOf("boolean",e.allowMultipleVotes,!0)&&t.isTypeOf("number",e.closeAt,!0))(s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Jt(Object.assign({pollId:e},s)),a=yield i.send(n),{poll:r}=a.as(Xt);return r}))}deletePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Zt({pollId:e});yield i.send(n)}))}closePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new es({pollId:e}),a=yield i.send(n),{poll:r}=a.as(ts);return r}))}addPollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("string",s)&&""!==s.trim();t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new ss({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:s}),r=yield n.send(a),{poll:o}=r.as(is);return o}))}updatePollOption(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const n=t.isTypeOf("number",e)&&t.isTypeOf("number",s)&&t.isTypeOf("string",i)&&""!==i.trim();t.unless(n).throw(t.SendbirdError.invalidParameters);const{requestQueue:a}=t.Vault.of(this._iid),r=new ns({pollId:e,pollOptionId:s,optionText:i}),o=yield a.send(r),{poll:l}=o.as(as);return l}))}deletePollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new rs({pollId:e,pollOptionId:s});yield n.send(a)}))}votePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isArrayOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n,dispatcher:a}=t.Vault.of(this._iid),r=new os({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:s}),o=yield n.send(r),{event:l}=o.as(ls);return a.dispatch(new t.PollVoteInternalEventCommand({event:l,source:t.CollectionEventSource.EVENT_POLL_VOTED})),l}))}getPollChangeLogsSinceTimestamp(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)).throw(t.SendbirdError.invalidParameters);const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}getPollChangeLogsSinceToken(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e,!0));const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}createPollListQuery(e=10){return new t.PollListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}createPollVoterListQuery(e,s,i=20){return new t.PollVoterListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:s,limit:i})}pinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new fs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}unpinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new vs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}}const Ts={};class bs{constructor({dbname:e,itemSizeLimit:t=1048576,cacheLimit:s=256,blockHashBase:i=2,blockHashMultiplier:n=10,blockHashConstant:a=11,transactionApplyDelay:r=200,disableLogger:o=!1}){return Ts[e]||(this.itemSizeLimit=t,this.cacheLimit=s,this.blockHashBase=i,this.blockHashMultiplier=n,this.blockHashConstant=a,this.transactionApplyDelay=r,this.disableLogger=o,Ts[e]=this),Ts[e]}static get(e){return Ts[e]}}var Ms,Ss;!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"}(Ms||(Ms={}));class Os extends Error{constructor({code:e=Ms.UNKNOWN_ERROR,message:t="Unknown error occurred."}){super(t),this.code=e,Object.setPrototypeOf(this,Os.prototype)}static get storeNotDefined(){return new Os({code:Ms.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}static get storeNotAvailable(){return new Os({code:Ms.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}static get storeNotAvailableInPrivateBrowsing(){return new Os({code:Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}static get storeIsFull(){return new Os({code:Ms.STORE_IS_FULL,message:"Store is full."})}static get storeNotInitialized(){return new Os({code:Ms.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}static get storeKeyTypeIsInvalid(){return new Os({code:Ms.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}static get storeBrokenIntegrity(){return new Os({code:Ms.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}static get storeBrokenBlob(){return new Os({code:Ms.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}static get storeEncryptionInvalid(){return new Os({code:Ms.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}static get storeItemSizeExceeded(){return new Os({code:Ms.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}static get storeReadFailed(){return new Os({code:Ms.STORE_READ_FAILED,message:"Failed to read from store."})}static get storeWriteFailed(){return new Os({code:Ms.STORE_WRITE_FAILED,message:"Failed to write to store."})}static get databaseSchemaNotOnUpgrade(){return new Os({code:Ms.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}static get collectionNotReady(){return new Os({code:Ms.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}static get collectionKeyNotMatch(){return new Os({code:Ms.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}static get collectionQueryNotValid(){return new Os({code:Ms.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}static get collectionInsertDuplicate(){return new Os({code:Ms.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}static get collectionKeyNotFound(){return new Os({code:Ms.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}static get collectionKeyNotGiven(){return new Os({code:Ms.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}static get collectionWriteFailed(){return new Os({code:Ms.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}static get collectionItemSizeExceeded(){return new Os({code:Ms.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}static get indexTableIsRequired(){return new Os({code:Ms.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}static get indexTypesNotMatch(){return new Os({code:Ms.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}static get compareTypesNotMatch(){return new Os({code:Ms.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}static get circularReferenceFound(){return new Os({code:Ms.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ss||(Ss={}));const As=(e,t=new WeakMap)=>{if("object"==typeof e&&null!==e){if(t.has(e))throw Os.circularReferenceFound;{let s;return t.set(e,!0),Array.isArray(e)?s=e.map((e=>As(e,t))):e instanceof RegExp||e instanceof Date?s=e:(s={},Object.keys(e).forEach((i=>{s[i]=As(e[i],t)}))),t.delete(e),s}}return e},Cs=(e,t)=>{if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Os.compareTypesNotMatch;let s=0;switch(typeof e){case"boolean":case"number":s=e-t;break;case"string":s=e.localeCompare(t)}return s},ws=(e,t)=>{let s=0;for(let t=0;t>>0)%t},Ns=e=>new Promise((t=>{setTimeout((()=>t()),e)})),Ps=(e,t)=>{if(!t)return!1;if("function"!=typeof e){for(const s in e)if(["/and","&&"].includes(s)){if(e[s].some((e=>!Ps(e,t))))return!1}else if(["/or","||"].includes(s)){if(e[s].every((e=>!Ps(e,t))))return!1}else if("/where"===s){if(!(0,e[s])(t))return!1}else{const i=s;if("object"==typeof e[i]){const s=e[i];for(const e in s)switch(e){case"/eq":case"=":if(t[i]!==s[e])return!1;break;case"/neq":case"!=":if(t[i]===s[e])return!1;break;case"/gt":case">":{const n=t[i],a=s[e];if(!(Cs(n,a)>0))return!1;break}case"/gte":case">=":{const n=t[i],a=s[e];if(!(Cs(n,a)>=0))return!1;break}case"/lt":case"<":{const n=t[i],a=s[e];if(!(Cs(n,a)<0))return!1;break}case"/lte":case"<=":{const n=t[i],a=s[e];if(!(Cs(n,a)<=0))return!1;break}case"/in":{const n=t[i];if(!s[e].includes(n))return!1;break}case"/nin":{const n=t[i];if(s[e].includes(n))return!1;break}case"/contain":{const n=t[i],a=s[e];if(!n.includes(a))return!1;break}case"/regex":{const n=t[i];if(!s[e].test(n))return!1;break}case"/where":{const n=t[i];if(!(0,s[e])(n))return!1;break}}}else if("function"==typeof e[i]){if(!e[i](t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}return e(t)},Us=()=>{},Rs=()=>Promise.resolve(),xs=e=>e,ks=(e,t)=>{t()};var Ls;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Ls||(Ls={}));class Ds{constructor({initialPrevValue:e=null,initialNextValue:t=null,iterator:s,map:i=xs,backward:n=Rs,forward:a=Rs,complete:r=Us}){this._prevValue=e,this._nextValue=t,this._error=null,this._map=i,this._backward=n,this._forward=a,this._iterator=s,this._complete=r}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 t.__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 t.__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 qs{constructor({condition:e={},backward:t=!1,blockManager:s,indexer:i}){this.condition=e,this.backward=t,this._blockManager=s,this._indexer=i}findOptimizedStartPosition(){const e=["=","/eq",">",">=","/gt","/gte"],t=["=","/eq","<","<=","/lt","/lte"];if(this.backward){let s=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(let i=0;i0?t:e;for(const e in this.condition[n])if(r.includes(e))for(let t=s;t>=0;t--)if(a*Cs(this._indexer.origin[t].columnValues[i],this.condition[n][e])<=0){s=t;break}}else for(let e=s;e>=0;e--)if(a*Cs(this._indexer.origin[e].columnValues[i],this.condition[n])<=0){s=e;break}}return Math.min(s+1,this._indexer.origin.length-1)}{let s=0;if("function"!=typeof this.condition)for(let i=0;i{if((a>0?e:t).includes(r))for(let e=s;e=0){s=e;break}}));else for(let e=s;e=0){s=e;break}}return Math.max(s-1,0)}}each(e){return t.__awaiter(this,void 0,void 0,(function*(){let s=this.findOptimizedStartPosition(),i=0;this.backward&&this._indexer.origin[s]&&(i=this._indexer.origin[s].keys.length-1);const n=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[++i]){if(!this._indexer.origin[++s])return!1;i=0}return!0}return!1},a=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[--i]){if(!this._indexer.origin[--s])return!1;i=this._indexer.origin[s].keys.length-1}return!0}return!1};let r=null;if(this._indexer.origin[s]){const e=this.backward?a:n;do{const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e)){r=e;break}}while(e())}return yield new Promise((o=>{const l=new Ds({initialNextValue:As(r),iterator:e,forward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?a:n;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return As(e)}return null})),backward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?n:a;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return As(e)}return null})),complete:o});e(l)}))}))}}class Fs{constructor({condition:e={},backward:t=!1,mutex:s,blockManager:i,indexer:n}){this._mutex=s,this._iterator=new qs({condition:e,backward:t,blockManager:i,indexer:n})}fetch(e={}){return t.__awaiter(this,void 0,void 0,(function*(){let s=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 Os.collectionQueryNotValid;try{const e=[];return yield this._mutex.lock(),yield this._iterator.each((n=>t.__awaiter(this,void 0,void 0,(function*(){n.error?n.stop():n.hasNext?0===s?(e.push(n.nextValue),0t.__awaiter(this,void 0,void 0,(function*(){s.error?s.stop():s.hasNext?(e++,s.next()):s.stop()})))),this._mutex.unlock(),e}catch(e){throw this._mutex.unlock(),e}}))}}const Bs=e=>`nest@${e}`,js=(e,t)=>`${Bs(e)}/${t}`,Vs=(e,t)=>`${js(e,t)}.metadata`,zs=(e,t)=>`${js(e,t)}/block.`,$s=(e,t)=>`${js(e,t)}/blob.`;class Qs{constructor({dbname:e,collectionName:t,store:s}){this.dbname=e,this.collectionName=t,this.store=s}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.store.get(e);if(t){const{data:e,type:s}=t;if("undefined"!=typeof fetch){const t=yield fetch(e);return yield t.blob()}{const t=512,i=[],n=atob(e.split(",")[1]);for(let e=0;e{const i=((e,t,s,i=0)=>`${$s(e,t)}${s}.${i}`)(this.dbname,this.collectionName,s),n=new FileReader;n.onload=()=>{t({blobId:i,data:n.result,type:e.type})},n.readAsDataURL(e)}));return yield this.store.set({key:t,value:{data:i,type:n}}),t}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this.store.remove(e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=$s(this.dbname,this.collectionName),s=yield this.store.getAllKeys();yield Promise.all(s.filter((t=>t.startsWith(e))).map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this.store.remove(e)})))))}))}}var Gs,Ks,Hs;!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Gs||(Gs={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Ks||(Ks={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Hs||(Hs={}));const Ws=[Ks.PENDING,Ks.VOLATILE],Ys={};class Js{constructor({dbname:e,limit:t=256}){return Ys[e]||(this.dbname=e,this._items=[],this._limit=t,Ys[e]=this),Ys[e]}static get(e){return Ys[e]}get items(){return this._items}find(e,s,i=Hs.DEFAULT){return t.__awaiter(this,void 0,void 0,(function*(){let t=this.get(s);if(t)i===Hs.PERSISTENT&&(t.state=Ks.PERSISTENT);else{const n=yield e.get(s);n&&(t={key:s,value:n,state:i===Hs.PERSISTENT?Ks.PERSISTENT:Ks.VOLATILE},this.put(t))}return t}))}get(e,t=Hs.DEFAULT){const s=this._items.map((e=>e.key)).indexOf(e);if(s>-1){const e=this._items[s];return t===Hs.PERSISTENT&&(e.state=Ks.PERSISTENT),t!==Hs.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)Ws.includes(this._items[t].state)&&Ws.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===Ks.VOLATILE));let s=t.length-this._limit;if(s>0){const e=[];for(const t of this._items)t.state===Ks.VOLATILE&&s>0?s--: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)))}clearForDatabase(e){this.clearByCondition((t=>t.key.startsWith(Bs(e))))}clear(e=!1){this._items=e?[]:this._items.filter((e=>e.state!==Ks.VOLATILE))}}class Xs{constructor({dbname:e,collectionName:t,store:s}){this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=e,this.collectionName=t,this.metadataKey=((e,t)=>`${js(e,t)}/trans.metadata`)(e,t),this.recordsetKey=((e,t)=>`${js(e,t)}/trans.recordset`)(e,t),this._store=s}get generation(){return this._metadata?this._metadata.generation:0}get requestCount(){return this._requests.length}_getReducedRecordset(e=[]){return t.__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=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=[];for(let e=n.requests.length-1;e>=0;e--){const t=n.requests[e],i=t.data;s[i.key]||(a.unshift(t),s[i.key]=!0)}a.length>0&&(n.requests=a,t.unshift(n))}return t}_applyRecord(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname),{generation:i,requests:n}=s;let a=null;try{const e=yield this._store.setMany(n.map((e=>Object.assign(Object.assign({},e.data),{generation:i}))));for(let s=0;s{a&&e(a)}));else{const t=e.filter((e=>e.generation!==i));yield this._store.set({key:this.recordsetKey,value:t}),this._onWrite.forEach((e=>{e(n.map((e=>e.data)))}))}}))}init(){return t.__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,s){switch(e){case Gs.COMMIT:this._onCommit.set(t,s);break;case Gs.WRITE:this._onWrite.set(t,s);break;case Gs.ERROR:this._onError.set(t,s)}}requestWrite(e,t){this._requests.push({data:e,options:t});Js.get(this.dbname).put(Object.assign({state:Ks.PENDING},e))}requestMultipleWrite(e,t){const s=Js.get(this.dbname);for(const i of e)this._requests.push({data:i,options:t}),s.put(Object.assign({state:Ks.PENDING},i))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).clearByCondition((e=>e.state===Ks.PENDING)),this._requests=[]}))}commit(){return t.__awaiter(this,void 0,void 0,(function*(){const e=this._requests;if(e.length>0){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=n.data;s[a.key]||(s[a.key]=!0,t.unshift(n))}const i={generation:this.generation,requests:t},n=yield this._getReducedRecordset([i]);yield this._store.set({key:this.recordsetKey,value:n}),this._metadata.generation++,yield this._store.set({key:this.metadataKey,value:this._metadata});const a=Js.get(this.dbname);for(let e=0;e{t(e.map((e=>e.data)))}));const r=bs.get(this.dbname);setTimeout((()=>{try{this._applyRecord(n,i)}catch(e){this._onError.forEach((t=>t(e)))}}),r.transactionApplyDelay)}}))}}class Zs{constructor({blockId:e,keyName:t,items:s=[],limit:i}){this.blockId=e,this.keyName=t,this.limit=i,this._items=[...s]}static createFromCacheItem(e){return e?new Zs(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 s=t[this.keyName];return e===s}));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 i=s.base*Math.pow(s.multiplier,t)+s.constant;return(s.hashFunction||ws)(e,i)})(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})}`,`${zs(s,i)}${n}.${a}`;var s,i,n,a}_findBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname);for(let s=this.metadata.blockLevel;s>0;s--){const i=this.createBlockId(e,s),n=yield t.find(this._store,i);if(n){const t=Zs.createFromCacheItem(n);if(null==t?void 0:t.getItemByKey(e))return t}}return null}))}getFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return t?t.getItemByKey(e):null}))}putToBlock(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=bs.get(this.dbname),i=this.createBlockId(e),n=Math.floor(this._store.itemSizeLimit/t.itemSizeLimit),a=Js.get(this.dbname),r=yield a.find(this._store,i),o=r?Zs.createFromCacheItem(r):new Zs({blockId:i,keyName:this.keyName,items:[],limit:n});return!!(null==o?void 0:o.add(s))&&(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),!0)}))}removeFromBlock(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const e=zs(this.dbname,this.collectionName),t=(yield this._store.getAllKeys()).filter((t=>t.startsWith(e)));yield this._store.removeMany(t),yield this._transaction.clear();Js.get(this.dbname).clearByCondition((t=>t.key.startsWith(e)))}))}}const ti=e=>{const t=typeof e;return null===e||"undefined"===t||"boolean"===t||"number"===t||"string"===t};class si{constructor({dbname:e,collectionName:t,keyName:s,fields:i,transaction:n,store:a}){this._origin=[],this._table=[];const r=((e,t,s)=>`${js(e,t)}/index.${s}`)(e,t,i.join(">"));this.dbname=e,this.collectionName=t,this.keyName=s,this.fields=i,this.indexerKey=r,this._store=a,this._transaction=n,this._transaction.on(Gs.COMMIT,this.indexerKey,(()=>this.commit())),this._transaction.on(Gs.ERROR,this.indexerKey,(()=>this.abort()))}static createKey(e){return e.join(">")}static parseKey(e){return e.split(">")}_addItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);return n?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:s,keys:[t]}),!0)}_removeItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);if(n){const e=this._table[i].keys.indexOf(t);if(e>-1)return this._table[i].keys.splice(e,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1}get origin(){return this._origin}get table(){return this._table}getColumnValues(e){const t=[];for(let s of this.fields){if("-"===s[0]&&(s=s.slice(1)),!ti(e[s]))throw Os.indexTypesNotMatch;t.push(e[s])}return t}diff(e,t){for(const s in this.fields){const i="-"===this.fields[s][0]?-1:1,n=Cs(e[s],t[s]);if(0!==n)return i*n}return 0}indexOf(e){if(this._table.length>0){let t=0,s=this._table.length-1;for(;t<=s;){const i=Math.floor((t+s)/2),n=this.diff(e,this._table[i].columnValues);if(n>0)t=i+1;else{if(!(n<0))return[i,!0];s=i-1}}return[t,!1]}return[0,!1]}ensure(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.dbname),t=yield e.find(this._store,this.indexerKey,Hs.PERSISTENT);if(t)this._origin=t.value,this._table=As(this._origin);else{const t=zs(this.dbname,this.collectionName),s=yield this._store.getAllKeys();for(const i of s)if(i.startsWith(t)){const t=yield e.find(this._store,i,Hs.NO_CACHE),s=Zs.createFromCacheItem(t);if(s)for(const e of s.items)this._addItem(e)}this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}}))}drop(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).remove(this.indexerKey),yield this._store.remove(this.indexerKey)}))}addItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}removeItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}clear(){return t.__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=As(this._origin)}abort(){this._table=As(this._origin)}}const ii=()=>"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product,ni=()=>{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)}))};var ai,ri;!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(ai||(ai={})),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"}(ri||(ri={}));const oi={};class li{constructor(e,t={}){return this._state=ai.PROCESSING,this._queue=[],this._activationQueue=[],oi[e]&&!t.forceCreate||(this.nodeId=ni(),this.key=e,ii()&&(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;if(!(null==t?void 0:t.isNestDbMessage))return;const{nodeId:s,requestId:i,key:n,op:a,data:r}=t;if(s!==this.nodeId&&n===this.key)switch(a){case ri.NEWNODE:this._sendSync();break;case ri.CLAIM_HOST:this._sendSync(),this._hostId=s;break;case ri.SYNC_HOST:if(!this.isInSync){this._activationTimeout&&clearTimeout(this._activationTimeout);const{currentItemRequestId:e,queue:t}=r;for(const e of t){this._queue.findIndex((t=>t.requestId===e.requestId))<0&&this._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:this.key,op:ri.REQUEST_LOCK,ts:e.ts})}this._currentItem=this._queue.find((t=>t.requestId===e)),this._completeSync()}break;case ri.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 ri.REQUEST_LOCK:this._requestLock(t);break;case ri.ACQUIRE_LOCK:{const e=this._queue.find((e=>e.requestId===i));this._acquire(e);break}case ri.RELEASE_LOCK:this._release(i)}})),window.addEventListener("beforeunload",(()=>{this._send(ri.REMOVENODE)}))),oi[e]=this),oi[e]}get locked(){return!!this._currentItem}get isHost(){return this._hostId===this.nodeId}get isInSync(){return this._state==ai.DONE}_send(e,t={}){var s;const i={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(s=null==t?void 0:t.requestId)&&void 0!==s?s:ni(),key:this.key,op:e,data:t.data,ts:Date.now()};return ii()&&window.postMessage(i,"*"),i}_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(ri.RELEASE_LOCK,{requestId:t.requestId});const s=this._queue.findIndex((t=>t.requestId===e));s>-1&&this._queue.splice(s,1),t.onReleased&&t.onReleased(e)}}_requestLock(e){return new Promise((t=>{const s={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:e=>{this.isHost&&this._send(ri.ACQUIRE_LOCK,{requestId:e}),t()},onReleased:()=>{this._acquire(this._queue[0])}};let i=!1;for(let e=0;es.ts){this._queue.splice(e,0,s),i=!0;break}i||this._queue.push(s),this._currentItem||this._acquire(this._queue[0])}))}_sendSync(){var e;this.isHost&&this._send(ri.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 t.__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=ai.DONE,this._activationQueue.forEach((e=>e())),this._activationQueue=[])}registerNode(){this._send(ri.NEWNODE),this._waitSync()}claimHost(){this._hostId=this.nodeId,this._send(ri.CLAIM_HOST),this._waitSync()}lock(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._waitUntilSyncCompleted();const e=this._send(ri.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)}}class di{constructor({dbname:e,collectionName:t,keyName:s,keyHash:i,indexes:n,store:a}){this._state=Ss.INIT,this._indexers=[],this.dbname=e,this.name=t,this.keyName=s,this.indexes=[[s],...n.filter((e=>si.createKey(e)!==this.keyName))],this._keyHash=i,this._store=a,this._mutex=new li(((e,t)=>`${js(e,t)}.lock`)(e,t)),this._blobContainer=new Qs({dbname:e,collectionName:t,store:a}),this._transaction=new Xs({dbname:e,collectionName:t,store:a})}static metadataOf(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const t=Vs(e,s);return yield i.get(t)}))}get state(){return this._state}get isReady(){return this._state===Ss.READY}init(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._mutex.lock();try{const e=bs.get(this.dbname),t=yield di.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 ei({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store});const s=[...this.indexes],i=[],n=s.map((e=>si.createKey(e))),a=t?t.indexes.map((e=>si.createKey(e))):[];for(const e of a)n.includes(e)||i.push(si.parseKey(e));const r=[];if(r.push(...s.map((e=>{const t=new si({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store});return this._indexers.push(t),t.ensure()}))),r.push(...i.map((e=>new si({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store}).drop()))),yield Promise.all(r),yield this._transaction.commit(),n.sort().join(",")!==a.sort().join(",")){const e=Vs(this.dbname,this.name);this._metadata.indexes=s,yield this._store.set({key:e,value:this._metadata})}this._state=Ss.READY,this._mutex.unlock()}catch(e){throw this._mutex.unlock(),e}}))}close(){this._state=Ss.CLOSED}_hasPropertyOfKeyName(e){const t=e[this.keyName];return"string"==typeof t&&!!t}_getIndexerBy(e=null){e||(e=[this.keyName]);const t=si.createKey(e);for(const e of this._indexers)if(t===si.createKey(e.fields))return e;throw Os.indexTableIsRequired}_upgradeBlockLevel(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Vs(this.dbname,this.name);this._metadata.blockLevel++,yield this._store.set({key:e,value:this._metadata})}))}_requestInsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName];if(yield this._blockManager.getFromBlock(t))throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}}))}_requestRemove(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){yield this._blockManager.clearAllBlocks();for(const e of this._indexers)yield e.clear()}))}getByKey(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{const t=yield this._blockManager.getFromBlock(e);return this._mutex.unlock(),As(t)}catch(e){throw this._mutex.unlock(),e}}))}query(e={}){if(this.isReady)return new Fs({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Os.collectionNotReady}insertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestInsert(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}insertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Os.collectionKeyNotGiven;for(const t of e)yield this._requestInsert(As(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestUpsert(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Os.collectionKeyNotGiven;for(const t of e)yield this._requestUpsert(As(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}update(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestUpdate(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}updateIf(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Os.collectionNotReady;yield this._mutex.lock();try{const{where:i={},index:n=null,backward:a=!1}=e,r=[],o=new qs({condition:i,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(n)});yield o.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;Ps(i,t)&&s.set&&("function"!=typeof s.set?Object.keys(s.set).forEach((e=>{var i;t[e]=null===(i=s.set)||void 0===i?void 0:i[e]})):s.set(t),r.push(t)),e.next()}else e.stop()}))));for(const e of r)yield this._requestUpdate(As(e));return yield this._transaction.commit(),this._mutex.unlock(),r}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Os.collectionNotReady;yield this._mutex.lock();try{const{where:s={},index:i=null,backward:n=!1}=e,a=[],r=new qs({condition:s,blockManager:this._blockManager,backward:n,indexer:this._getIndexerBy(i)});yield r.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(Ps(s,t)){const e=t[this.keyName];a.push(e)}e.next()}else e.stop()}))));for(const e of a)yield this._requestRemove(e);return yield this._transaction.commit(),this._mutex.unlock(),a}catch(e){throw this._mutex.unlock(),e}}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.get(e)}))}saveBlob(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.save(e,s)}))}removeBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.remove(e)}))}removeAllBlobs(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.clear()}))}}const ui="[NESTDB]";let ci=!0;class hi{static off(){ci=!1}static log(...e){ci&&console.log(`${ui}[LOG]`,...e)}static warning(...e){ci&&console.warn(`${ui}[WARNING]`,...e)}static error(...e){ci&&console.error(`${ui}[ERROR]`,...e)}}const pi=[{},{a:700400,n:"error"}];class mi{constructor(e){var s,i,n;this.encryption=null!==(s=e.encryption)&&void 0!==s?s:t.DEFAULT_ENCRYPTION,this.itemSizeLimit=null!==(i=e.itemSizeLimit)&&void 0!==i?i:4194304,this.metadataBuffer=null!==(n=e.metadataBuffer)&&void 0!==n?n:256}get _encryptionCheckKey(){return`${this.dbname}.encrypt`}get _reservedKeys(){return[this._encryptionCheckKey]}_getRawKey(e,t=""){return`${e}${t}`}_generateShardPostfixArray(e=1){return[...Array(e).keys()]}_shardify(e){const{key:t,value:s}=e,i=JSON.stringify(this.encryption.encrypt(s)),n=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(n).map((e=>{const s={key:this._getRawKey(t,`.${e}`),data:i.substring(e*this.adjustedItemSizeLimit,(e+1)*this.adjustedItemSizeLimit)};return 0===e&&(s.metadata={shards:n}),s}))}_resetIfEncryptionChanged(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.get(this._encryptionCheckKey),t={encrypted:pi.map((e=>{var t;return null===(t=this.encryption)||void 0===t?void 0:t.encrypt(e)}))};if(e)if(e.encrypted&&Array.isArray(e.encrypted))for(const s in e.encrypted){if(JSON.stringify(e.encrypted[s])!==JSON.stringify(t.encrypted[s])){hi.warning("Encryption algorithm has changed. Stored data would be cleared."),yield this.clear();break}}else yield this.clear();yield this.set({key:this._encryptionCheckKey,value:t})}))}get adjustedItemSizeLimit(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}usage(){return t.__awaiter(this,void 0,void 0,(function*(){let e=0;const t=yield this._getAllRawKeys();for(const s of t){const t=yield this._getRaw(s);t&&(e+=JSON.stringify(t).length)}return e}))}getAllKeys(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this._getAllRawKeys()).filter((e=>e.endsWith(".0"))).map((e=>e.replace(/\.0$/,""))).filter((e=>!this._reservedKeys.includes(e)))}))}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=this._getRawKey(e,".0"),i=yield this._getRaw(s);if(i)try{const{data:s,metadata:n}=i,a=(null==n?void 0:n.shards)&&n.shards>1?yield Promise.all(this._generateShardPostfixArray(null==n?void 0:n.shards).map((i=>t.__awaiter(this,void 0,void 0,(function*(){if(i>0){const t=this._getRawKey(e,`.${i}`),s=yield this._getRaw(t);if(!s)throw Os.storeBrokenIntegrity;return s.data}return s}))))):[s];return this.encryption.decrypt(JSON.parse(a.join("")))}catch(e){return null}return null}))}set(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._shardify(e);return yield this._setRaw(t),Object.assign({},e.value)}))}setMany(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const t=this._getRawKey(e,".0"),s=yield this._getRaw(t);if(s){const{metadata:t}=s,i=this._generateShardPostfixArray(null==t?void 0:t.shards).map((t=>this._getRawKey(e,`.${t}`)));yield this._removeRaw(i);const n=Js.get(this.dbname);return null==n||n.remove(e),!0}return!1}))}removeMany(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname),s=[];for(const i of e){const e=this._getRawKey(i,".0"),n=yield this._getRaw(e);if(n){const{metadata:e}=n;s.push(...this._generateShardPostfixArray(null==e?void 0:e.shards).map((e=>this._getRawKey(i,`.${e}`))))}null==t||t.remove(i)}return s.length>0&&(yield this._removeRaw(s)),e}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.dbname);null==e||e.clearForDatabase(this.dbname)}))}}const _i=1,gi={};class yi extends mi{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:4194304}));const{delay:s=_i}=e;this.delay=s,this.observer={}}get rawData(){return gi[this.dbname]}set rawData(e){gi[this.dbname]=e}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){if(gi[this.dbname])return Object.keys(gi[this.dbname]);throw Os.storeNotAvailable}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(gi[this.dbname])return yield Ns(this.delay),gi[this.dbname][e]?Object.assign({key:e},gi[this.dbname][e]):null;throw Os.storeNotAvailable}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!gi[this.dbname])throw Os.storeNotAvailable;yield Ns(this.delay);for(const t of e){const{key:e,data:s,metadata:i}=t;gi[this.dbname][e]=Object.freeze({data:s,metadata:i})}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!gi[this.dbname])throw Os.storeNotAvailable;yield Ns(this.delay);for(const t of e)gi[this.dbname][t]&&delete gi[this.dbname][t]}))}observe(e,t,s){this.observer[e]||(this.observer[e]={}),t.forEach((t=>this.observer[e][t]=s))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,gi[this.dbname]||(gi[this.dbname]={}),yield this._resetIfEncryptionChanged()}))}set(e){const s=Object.create(null,{set:{get:()=>super.set}});return t.__awaiter(this,void 0,void 0,(function*(){const t=this.observer[e.key];if(t&&"function"==typeof t.set){const e=t.set();if(e)throw e}return s.set.call(this,e)}))}setMany(e){const s=Object.create(null,{setMany:{get:()=>super.setMany}});return t.__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 s.setMany.call(this,e)}))}clear(){const e=Object.create(null,{clear:{get:()=>super.clear}});return t.__awaiter(this,void 0,void 0,(function*(){yield e.clear.call(this),yield Ns(this.delay),gi[this.dbname]={}}))}}const fi="NestDBStore";var vi;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(vi||(vi={}));var Ii,Ei,Ti;exports.NestDBState=void 0,(Ii=exports.NestDBState||(exports.NestDBState={})).INIT="INIT",Ii.OPENING="OPENING",Ii.OPENED="OPENED",Ii.CLOSED="CLOSED";exports.LogLevel=void 0,(Ei=exports.LogLevel||(exports.LogLevel={}))[Ei.VERBOSE=0]="VERBOSE",Ei[Ei.DEBUG=1]="DEBUG",Ei[Ei.INFO=2]="INFO",Ei[Ei.WARN=3]="WARN",Ei[Ei.ERROR=4]="ERROR",Ei[Ei.NONE=5]="NONE";class bi{constructor(e){var s,i,n,a;this.messageTypeFilter=null!==(s=null==e?void 0:e.messageTypeFilter)&&void 0!==s?s:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(i=null==e?void 0:e.customTypesFilter)&&void 0!==i?i:null,this.senderUserIdsFilter=null!==(n=null==e?void 0:e.senderUserIdsFilter)&&void 0!==n?n:null,this.replyType=null!==(a=null==e?void 0:e.replyType)&&void 0!==a?a:t.ReplyType.NONE}clone(){const e=new bi,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((s=>{e[s]=t[s]})),e}match(e){switch(this.messageTypeFilter){case t.MessageTypeFilter.USER:if(e.messageType!==t.MessageType.USER)return!1;break;case t.MessageTypeFilter.FILE:if(e.messageType!==t.MessageType.FILE)return!1;break;case t.MessageTypeFilter.ADMIN:if(e.messageType!==t.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof F))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof q)switch(this.replyType){case t.ReplyType.NONE:if(e.parentMessageId>0)return!1;break;case t.ReplyType.ONLY_REPLY_TO_CHANNEL:if(e instanceof F&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}}exports.MessageListOrder=void 0,(Ti=exports.MessageListOrder||(exports.MessageListOrder={})).CHANNEL_LATEST="channel_latest",Ti.NEWEST_CHILD_MESSAGE="newest_child_message";const Mi=e=>{switch(e){case exports.MessageListOrder.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Si=()=>["channelUrl","-createdAt","-notificationId"],Oi=Object.assign(Object.assign({},Me),{scheduledAt:void 0}),Ai=Object.assign(Object.assign({},Ee),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ci="UnsentMessage",wi={};class Ni extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),this._mutex=new li("unsendmessagecache.lock"),wi[e]=this}static of(e,t=!1){return wi[e]&&!t||(wi[e]=new Ni(e)),wi[e]}get collection(){const{nestdb:e}=this._cacheContext,s=null==e?void 0:e.collection(Ci);if(!s)throw t.SendbirdError.databaseError;return s}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){if(e.messageId>0)throw t.SendbirdError.invalidParameters;const s=Object.assign({},e.serialize());var i;return e instanceof Q?(e.messageParams&&(s.messageParams=be(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(i=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},be(i)),{scheduledAt:i.scheduledAt})))):e instanceof Y?(e.messageParams&&(s.messageParams=Pe(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(e=>Object.assign(Object.assign({},Pe(e)),{scheduledAt:e.scheduledAt}))(e.scheduledInfo.scheduledMessageParams))):e instanceof G&&e.messageParams&&(s.messageParams=(e=>t.deundefined({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}))(e.messageParams)),s}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return zi.of(this._iid).buildMessageFromSerializedData(e)}_deserializeWithMessageCreateParams(e){var s,i,n;return t.__awaiter(this,void 0,void 0,(function*(){const a=zi.of(this._iid),r=this._deserialize(e);if(e.messageParams)if(r instanceof Q){const t=e.messageParams;r.messageParams=a.buildUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.messageParams;t.fileKey&&"string"==typeof t.fileKey&&Ne(null!==(s=t.fileType)&&void 0!==s?s:"")&&(t.file=null!==(i=yield this.collection.getBlob(t.fileKey))&&void 0!==i?i:void 0),r.messageParams=a.buildFileMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof G){const s=e.messageParams;s&&s.fileInfoList&&(r.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(s,r),yield Promise.all(r.messageParams.fileInfoList.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t,s,i,n;"string"==typeof(null===(t=e._uploadedMetaData)||void 0===t?void 0:t.fileKey)&&Ne(null!==(i=null===(s=e._uploadedMetaData)||void 0===s?void 0:s.fileType)&&void 0!==i?i:"")&&(e.file=null!==(n=yield this.collection.getBlob(e._uploadedMetaData.fileKey))&&void 0!==n?n:void 0)}))))))}if(r.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)if(r instanceof Q){const t=e.scheduledInfo.scheduledMessageParams;r.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.scheduledInfo.scheduledMessageParams;t.fileKey&&"string"==typeof t.fileKey&&"string"==typeof t.fileType&&Ne(t.fileType)&&(t.file=null!==(n=yield this.collection.getBlob(t.fileKey))&&void 0!==n?n:void 0),r.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(t,r)}return r}))}_getFileInfoBlobKey(e,t){return`${e}.${t}`}get(e){return t.__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:s=new bi,order:i=exports.MessageListOrder.CHANNEL_LATEST,sendingStatus:n,backward:a=!1,parentMessageId:r}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const o=Mi(i),l={"/where":e=>!!(i!==exports.MessageListOrder.NEWEST_CHILD_MESSAGE||r&&0!==e.parentMessageId&&e.parentMessageId===r)&&s.match(this._deserialize(e))};e&&(l.channelUrl=e),n&&(l.sendingStatus=n);const d={where:l,index:o,backward:a},u=yield this.collection.query(d),c=yield u.fetch({});return Promise.all(c.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._deserializeWithMessageCreateParams(e)})))))}return[]}))}getAllChildMessages(e,s=new bi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){(e instanceof Y||e instanceof G)&&(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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__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 t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e}}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}saveBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y){if(e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}if(e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams){const t=e.scheduledInfo.scheduledMessageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}}else if(e instanceof G){const s=e.messageParams;s&&s.fileInfoList&&Array.isArray(s.fileInfoList)&&(yield Promise.all(s.fileInfoList.map(((s,i)=>t.__awaiter(this,void 0,void 0,(function*(){if(s.file&&we(s.file)){const t=yield this.collection.saveBlob(s.file,this._getFileInfoBlobKey(e.reqId,i));s._uploadedMetaData||(s._uploadedMetaData={}),s._uploadedMetaData.fileKey=t,s._uploadedMetaData.fileType=Ce.BLOB}}))))))}}))}}const Pi={};class Ui extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _unsentMessageCache(){return Ni.of(this._iid)}constructor(e){super(e),Pi[e]=this}static of(e,t=!1){return Pi[e]&&!t||(Pi[e]=new Ui(e)),Pi[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(ds)}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 zi.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new bi,order:a=exports.MessageListOrder.CHANNEL_LATEST,backward:r=!1,parentMessageId:o,isPollOnly:l=!1,exactMatch:d=!1,inclusive:u=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const c=Mi(a),h={where:{channelUrl:e,"/where":e=>{if(null!=s&&""!==s)switch(a){case exports.MessageListOrder.CHANNEL_LATEST:if(d&&e.createdAt!==s)return!1;if(r){if(u&&e.createdAts||!u&&e.createdAt>=s)return!1;break;case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:if(!o||0===e.parentMessageId||e.parentMessageId!==o)return!1}return!(l&&!e._poll)&&n.match(this._deserialize(e))}},index:c,backward:r},p=yield this.collection.query(h),m=yield p.fetch({limit:null!=i?i:void 0});return Promise.all(m.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return this._deserialize(e)})))))}return[]}))}getAllChildMessages(e,s=new bi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})}))}upsert(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.saveBlobs(e);for(const t of e)if(null===(s=t.threadInfo)||void 0===s?void 0:s._isUpdateRequired){const e=yield this.get(t.messageId);(null==e?void 0:e.threadInfo)&&t.threadInfo._updateFrom(e.threadInfo)}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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t;let s=[];(null===(t=e.threadInfo)||void 0===t?void 0:t.replyCount)&&e.threadInfo.replyCount>0&&(s=yield this.getAllChildMessages(e)),s.length>0&&(s.forEach((t=>t.applyParentMessage(e))),yield this.upsert(s))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(`${t}`)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:Mi(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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Mi(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=Mi(exports.MessageListOrder.CHANNEL_LATEST),n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}saveBlobs(e){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y&&e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s}}})))))}))}_getGroupChannelPreferenceSize(e){return t.__awaiter(this,void 0,void 0,(function*(){let t=0;const{preference:s}=this._cacheContext,i=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),n=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),a=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),r=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`);return i&&(t+=JSON.stringify(i).length),n&&(t+=JSON.stringify(n).length),a&&(t+=JSON.stringify(a).length),r&&(t+=JSON.stringify(r).length),t}))}}const Ri={};class xi extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),Ri[e]=this}static of(e,t=!1){return Ri[e]&&!t||(Ri[e]=new xi(e)),Ri[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(us)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){return Object.assign({},e.serialize())}_deserialize(e){return zi.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new bi,backward:a=!1,exactMatch:r=!1,inclusive:o=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t={where:{channelUrl:e,"/where":e=>{if(s){if(r&&e.createdAt!==s)return!1;if(a){if(o&&e.createdAts||!o&&e.createdAt>=s)return!1}return n.match(this._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:a},l=yield this.collection.query(t);return(yield l.fetch({limit:null!=i?i:void 0})).map((e=>this._deserialize(e)))}return[]}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=e.map((e=>this._serialize(e)));yield this.collection.upsertMany(t)}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}markAsReadByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.updateIf({where:{channelUrl:e,messageStatus:exports.NotificationMessageStatus.SENT,createdAt:{"<":s}}},{set:{messageStatus:exports.NotificationMessageStatus.READ}}))}))}markAsReadByMessageIds(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){return(yield this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":s},messageStatus:exports.NotificationMessageStatus.SENT}},{set:{messageStatus:exports.NotificationMessageStatus.READ}})).length}return 0}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]});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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Mi(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=["channelUrl","-createdAt","-notificationId"],n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}}const ki={};class Li extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _dispatcher(){return t.Vault.of(this._iid).dispatcher}get _messageCache(){return Ui.of(this._iid)}get _unsentMessageCache(){return Ni.of(this._iid)}get _notificationCache(){return xi.of(this._iid)}constructor(e){super(e),this._observers=new Map,this._dispatcherContext=this._dispatcher.on((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof t.MessageUpdateEventCommand){const{messages:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&e.messageId>0)),r=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&0===e.messageId)),o=s.filter((e=>e instanceof H));a.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.upsert(a),yield this._unsentMessageCache.remove(a.map((e=>e instanceof F?e.reqId:null)).filter((e=>null!==e)))})))),n||this._broadcastUpdateEvent(a,i)),r.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.upsert(r)})))),n||this._broadcastUpdateEvent(r,i)),o.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._notificationCache.upsert(o)})))),n||this._broadcastUpdateEvent(o,i))}else if(e instanceof t.MessageRemoveEventCommand){const{messageIds:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>"number"==typeof e)),r=s.filter((e=>"string"==typeof e));yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){a.length>0&&(yield this._messageCache.remove(a)),r.length>0&&(yield this._notificationCache.remove(r))})))),n||this._broadcastRemoveEvent(s,i)}else if(e instanceof t.UnsentMessageRemoveEventCommand){const{reqId:s,source:i}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([s])})))),this._broadcastRemoveUnsentEvent(s,i)}else if(e instanceof t.PollChangeLogEventCommand){const{polls:s,source:i}=e;if(this._cacheContext.localCacheEnabled){const e=s.map((e=>e.messageId)),i=(yield Promise.all(e.map((e=>this._messageCache.get(e))))).filter((e=>e));i.length>0&&s.forEach((e=>{const t=i.find((t=>t.messageId===e.messageId));t&&t.applyPoll(e)})),yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert(i)}))))}this._broadcastPollChangeLogEvent(s,i)}else if(e instanceof t.PollUpdateInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollUpdateEvent(s,i)}else if(e instanceof t.PollVoteInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollVoteEvent(s,i)}else if(e instanceof t.ReactionUpdateEventCommand){const{event:t,source:s}=e;t.messageId>0&&this._broadcastReactionUpdateEvent(t,s)}else if(e instanceof t.ThreadUpdateEventCommand){const{event:t,source:s}=e;this._broadcastThreadUpdateEvent(t,s)}}))))}static of(e,t=!1){var s;return ki[e]&&!t||(ki[e]&&(null===(s=ki[e]._dispatcherContext)||void 0===s||s.close()),ki[e]=new Li(e)),ki[e]}_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)}_broadcastReactionUpdateEvent(e,t){for(const s of this._observers.values())s.onReactionUpdate&&s.onReactionUpdate(e,t)}_broadcastThreadUpdateEvent(e,t){for(const s of this._observers.values())s.onThreadInfoUpdate&&s.onThreadInfoUpdate(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const Di=20;class qi extends t.APIRequestCommand{constructor(e){const{reverse:s=!1,limit:i=Di,keys:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}`,this.params=t.deundefined({token:a,limit:i,reverse:s,order:t.MessageTemplateListOrder.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:n})}}class Fi extends t.APIResponseCommand{constructor(e,t){super(e,t);const{next:s,has_more:i=!1,templates:n}=t;this.nextToken=s,this.hasMore=i,this.templates=n.map((e=>({template:JSON.stringify(e)})))}}class Bi extends t.APIRequestCommand{constructor(e){const{key:s}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}/${s}`}}class ji extends t.APIResponseCommand{constructor(e,t){super(e,t),this.template=JSON.stringify(t)}}const Vi={};class zi{constructor(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}){this._iid=e,this._sdkState=t,this._requestQueue=i,this._dispatcher=s,this._cacheContext=a,Ui.of(e),Ni.of(e),Li.of(e),this.fileMessageQueue=new ne(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}),Vi[e]=this}static of(e){return Vi[e]}buildMessageFromSerializedData(e){const s=t.deserialize(e);if(s.notificationId)return new H(this._iid,H.payloadify(s));switch(s.messageType){case t.MessageType.USER:return new Q(this._iid,Q.payloadify(s));case t.MessageType.FILE:return G._isMultipleFilesMessageSerializedData(s)?new G(this._iid,G.payloadify(s)):new Y(this._iid,Y.payloadify(s));case t.MessageType.ADMIN:return new V(this._iid,V.payloadify(s))}throw t.SendbirdError.invalidParameters}buildUserMessageCreateParamsFromSerializedData(e,s){return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,message:s.message,translationTargetLanguages:Object.keys(s.translations),pollId:e.pollId}))}buildFileMessageCreateParamsFromSerializedData(e,s){var i;return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,file:e.file,fileKey:e.fileKey,fileUrl:s.plainUrl,fileName:s.name,fileSize:s.size,mimeType:s.type,thumbnailSizes:null===(i=s.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),fileType:e.fileType,requireAuth:s.requireAuth}))}buildMultipleFilesMessageCreateParamsFromSerializedData(e,s){return t.deundefined({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,fileInfoList:e.fileInfoList.map((e=>new J(this._iid,e)))})}buildScheduledUserMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildScheduledFileMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildSenderFromSerializedData(e){const s=t.deserialize(e);return new p(this._iid,p.payloadify(s))}getMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new de(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ue);return i}))}getScheduledMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new _e(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ge);return i}))}getMessagesByMessageId(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,token:String(i)},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}getMessagesByTimestamp(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}_getMessagesByTimestampForCollection(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE,r,o){return t.__awaiter(this,void 0,void 0,(function*(){const l=new ce(Object.assign(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n),{checkingHasNext:r,checkingContinuousMessages:o})),d=yield this._requestQueue.send(l),{messages:u,isContinuousMessages:c,hasNext:h}=d.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:u,source:a})),{messages:u,isContinuousMessages:c,hasNext:h}}))}getThreadedMessagesByTimestamp(e,s,i,n=t.CollectionEventSource.REQUEST_THREADED_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const a=new ce(Object.assign(Object.assign(Object.assign({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:s},B),i),{replyType:t.ReplyType.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),r=yield this._requestQueue.send(a),{messages:o}=r.as(he),l=o.slice(1);return l.forEach((t=>{t.parentMessage=e})),this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:n})),{parentMessage:o[0],threadedMessages:l}}))}getMessageTemplatesByToken(e,s={}){return t.__awaiter(this,void 0,void 0,(function*(){const t=new qi(Object.assign({token:e},s)),i=yield this._requestQueue.send(t),{hasMore:n,nextToken:a,templates:r}=i.as(Fi);return{hasMore:n,token:a,templates:r}}))}getMessageTemplate(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new Bi({key:e}),s=yield this._requestQueue.send(t),{template:i}=s.as(ji);return{template:i}}))}getMessageChangelogs(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS){return t.__awaiter(this,void 0,void 0,(function*(){const r=new pe(t.deundefined(t.undefineNullProps(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},oe),n)))),o=yield this._requestQueue.send(r),{updatedMessages:l,deletedMessagesInfo:d,hasMore:u,nextToken:c}=o.as(me),h=d.map((e=>e.messageId));return l.length>0&&this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),h.length>0&&this._dispatcher.dispatch(new t.MessageRemoveEventCommand({messageIds:h,source:a})),{updatedMessages:l,deletedMessageIds:h,hasMore:u,token:c}}))}}class $i extends t.InstancedObject{constructor(e,s){super(e),this.targetMessageId=0;const i=s.thread_info,n=s.parent_message_id,r=s.channel_url,o=s.channel_type;i&&t.isTypeOf("object",i)&&t.isTypeOf("number",n)&&t.isTypeOf("string",r)&&t.isTypeOf("string",o)&&(this.threadInfo=new a(e,i),this.targetMessageId=n,this.channelUrl=r,this.channelType=o)}}const Qi={channelUrl:"",channelType:t.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1};class Gi extends t.APIRequestCommand{constructor({channelCustomType:e,keyword:s,limit:i,reverse:n,exactMatch:a,channelUrl:r,order:o,messageTimestampFrom:l,messageTimestampTo:d,advancedQuery:u,targetFields:c,nextToken:h}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_SEARCH}/messages`,this.params={custom_type:e,query:s,limit:i,reverse:n,exact_match:a,channel_url:r,message_ts_from:l,message_ts_to:d,sort_field:o,advanced_query:u,target_fields:c,after:h}}}class Ki extends t.APIResponseCommand{constructor(e,t){super(e,t),this.messages=t.results.map((t=>W(e,t))),this.hasNext=t.has_next,this.nextToken=t.end_cursor,this.totalCount=t.total_count}}var Hi;exports.MessageSearchOrder=void 0,(Hi=exports.MessageSearchOrder||(exports.MessageSearchOrder={})).SCORE="score",Hi.TIMESTAMP="ts";class Wi extends t.BaseListQuery{constructor(e,t){var s,i,n,a,r,o,l,d,u;super(e,t),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=t.keyword,this.reverse=null!==(s=t.reverse)&&void 0!==s&&s,this.exactMatch=null!==(i=t.exactMatch)&&void 0!==i&&i,this.channelUrl=null!==(n=t.channelUrl)&&void 0!==n?n:"",this.channelCustomType=null!==(a=t.channelCustomType)&&void 0!==a?a:"",this.messageTimestampFrom=null!==(r=t.messageTimestampFrom)&&void 0!==r?r:null,this.messageTimestampTo=null!==(o=t.messageTimestampTo)&&void 0!==o?o:null,this.order=null!==(l=t.order)&&void 0!==l?l:exports.MessageSearchOrder.SCORE,this.advancedQuery=null!==(d=t.advancedQuery)&&void 0!==d&&d,this.targetFields=null!==(u=t.targetFields)&&void 0!==u?u:null}_validate(){return super._validate()&&t.isTypeOf("string",this.keyword)&&this.keyword.length>0&&t.isTypeOf("boolean",this.reverse)&&t.isTypeOf("boolean",this.exactMatch)&&t.isTypeOf("string",this.channelUrl)&&t.isTypeOf("string",this.channelCustomType)&&(t.isTypeOf("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(t.isTypeOf("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&t.isEnumOf(exports.MessageSearchOrder,this.order)&&t.isTypeOf("boolean",this.advancedQuery)&&t.isArrayOf("string",this.targetFields,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Gi(t.undefineNullProps(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),i=yield e.send(s),{messages:n,hasNext:a,nextToken:r,totalCount:o}=i.as(Ki);return this._nextToken=r,this._hasNext=a,this._isLoading=!1,this.totalCount=o,n}return[]}throw t.SendbirdError.invalidParameters}))}}exports.AdminMessage=V,exports.AppleCriticalAlertOptions=u,exports.BanUserEventCommand=At,exports.BannedUserListQuery=Ye,exports.BaseChannel=Es,exports.BaseMessage=q,exports.BaseMessageUpdateParamsDefault=Le,exports.BaseStore=mi,exports.Config=bs,exports.CreateScheduledUserMessageResponseCommand=Ht,exports.DEFAULT_FEED_LIMIT=100,exports.DEFAULT_GROUPCHANNEL_LIMIT=100,exports.DEFAULT_MESSAGE_LIMIT=100,exports.DEFAULT_NOTIFICATION_LIMIT=100,exports.Feedback=h,exports.FileMessage=Y,exports.FileMessageEventCommand=ee,exports.FreezeEventCommand=Pt,exports.IndexedDbStore=class extends mi{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:104857600})),this._storeName=fi,this._state=vi.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}isTransactionInactiveError(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}_putToObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.put(s);n.addEventListener("success",(e=>{t(e.target.result)})),n.addEventListener("error",(()=>{i("Failed to write.")}))}))}))}_deleteFromObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.delete(s);n.addEventListener("success",(()=>t(s))),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_openDatabase(e){return new Promise(((t,s)=>{if(this._indexedDb){this._state=vi.OPENING;const i=this._indexedDb.open(e);i.addEventListener("upgradeneeded",(e=>{e.target.result.createObjectStore(fi,{keyPath:"key"})})),i.addEventListener("success",(s=>{this._state=vi.OPEN,this._database=s.target.result,this._openJobQueue.forEach((e=>e())),this._openJobQueue=[],this._database.onclose=()=>{this._database=void 0,this._state=vi.OPENING,setTimeout((()=>{this._openDatabase(e)}),5)},t(this._database)})),i.addEventListener("error",(e=>{this._state=vi.UNINITIALIZED,s(e.target.error)}))}else s(Os.storeNotAvailable)}))}_getObjectStore(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);switch(this._state){case vi.UNINITIALIZED:case vi.OPEN:throw Os.storeNotInitialized;case vi.OPENING:case vi.CLOSED:return new Promise((t=>{this._openJobQueue.push((()=>t(this._getObjectStore(e))))}));default:return yield this._getObjectStore(e)}}))}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readonly");return yield new Promise(((t,s)=>{const i=e.getAllKeys();i.addEventListener("success",(e=>{t(e.target.result)})),i.addEventListener("error",(e=>s(e.target.error)))}))}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readonly");return yield new Promise(((s,i)=>{const n=t.get(e);n.addEventListener("success",(e=>{var t;s(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._putToObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._putToObjectStore(t,s)}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._deleteFromObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._deleteFromObjectStore(t,s)}}))}_triggerDatabaseClose(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}checkAvailability(){return t.__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 Os.storeNotAvailable;if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!ii())throw Os.storeNotAvailable;if(ii()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")){if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Os.storeNotAvailableInPrivateBrowsing}else yield new Promise(((e,t)=>{if(this._indexedDb)try{const s=this._indexedDb.open("_testMozilla");s.onerror=()=>t(Os.storeNotAvailableInPrivateBrowsing),s.onsuccess=s=>{if(s.target.result.close(),this._indexedDb){const t=this._indexedDb.deleteDatabase("_testMozilla");t.onerror=()=>e(),t.onsuccess=()=>e()}else t(Os.storeNotAvailable)}}catch(e){t(Os.storeNotAvailableInPrivateBrowsing)}else t(Os.storeNotAvailable)}))}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yield this.checkAvailability(),yield this._openDatabase(e),yield this._resetIfEncryptionChanged()}))}clear(){const e=Object.create(null,{clear:{get:()=>super.clear}});return t.__awaiter(this,void 0,void 0,(function*(){yield e.clear.call(this);const t=yield this._getObjectStore("readwrite");return yield new Promise(((e,s)=>{const i=t.clear();i.addEventListener("success",(()=>e())),i.addEventListener("error",(e=>s(e.target.error)))}))}))}},exports.Logger=class{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)}},exports.MemoryStore=yi,exports.MessageBroadcast=Li,exports.MessageCache=Ui,exports.MessageFilter=bi,exports.MessageForm=k,exports.MessageFormItem=L,exports.MessageManager=zi,exports.MessageMetaArray=m,exports.MessageRequestHandler=Ie,exports.MessageRetrievalParamsDefault=Qi,exports.MessageReviewInfo=$,exports.MessageSearchQuery=Wi,exports.MessageThreadInfoUpdatedEventCommand=N,exports.MultipleFilesMessage=G,exports.MultipleFilesMessageRequestHandler=ps,exports.MuteUserEventCommand=bt,exports.MutedUserListQuery=Ke,exports.NESTDB_FEEDCHANNEL_COLLECTION_KEY="url",exports.NESTDB_FEEDCHANNEL_COLLECTION_NAME="FeedChannel",exports.NESTDB_GROUPCHANNEL_COLLECTION_KEY="url",exports.NESTDB_GROUPCHANNEL_COLLECTION_NAME="GroupChannel",exports.NESTDB_MESSAGE_COLLECTION_KEY="messageId",exports.NESTDB_MESSAGE_COLLECTION_NAME=ds,exports.NESTDB_NOTIFICATION_COLLECTION_KEY="notificationId",exports.NESTDB_NOTIFICATION_COLLECTION_NAME=us,exports.NESTDB_POLL_COLLECTION_KEY="pollId",exports.NESTDB_POLL_COLLECTION_NAME="Poll",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY="reqId",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME=Ci,exports.NestDB=class{constructor({name:e,version:t,store:s,config:i}){this.name=e,this._version=t,this._state=exports.NestDBState.INIT,this._config=i||new bs({dbname:e}),this._store=s,this._event={success:Us,error:Us,storeReplaced:Us,upgrade:ks},this._collections=new Map,this._globalMutex=new li(`${this.name}.lock`),this._config.disableLogger&&hi.off(),new Js({dbname:e,limit:this._config.cacheLimit})}get version(){return this._version}get state(){return this._state}get store(){return this._store}estimateUsage(){return t.__awaiter(this,void 0,void 0,(function*(){return yield(e=this._store,t.__awaiter(void 0,void 0,void 0,(function*(){return yield e.usage()})));var e}))}commitSchema(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._state!==exports.NestDBState.OPENING)throw Os.databaseSchemaNotOnUpgrade;yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){const{collectionName:t,keyName:s,index:i=[]}=e;this._collections.has(t)||this._collections.set(t,new di({dbname:this.name,collectionName:t,keyName:s,indexes:i,store:this._store}));const n=this._collections.get(t);n&&(yield n.init())})))))}))}open(){var e;return t.__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=(s=this.name,`${Bs(s)}.metadata`),n={version:0,collectionNames:[]},a=null!==(e=yield this._store.get(i))&&void 0!==e?e:n;return new Promise(((e,s)=>{const n=e=>{a.versiont.__awaiter(this,void 0,void 0,(function*(){if(s)e({continued:!1,err:s});else{a.version++,a.collectionNames=Array.from(this._collections.keys());try{yield this._store.set({key:i,value:a}),e({continued:!0})}catch(t){e({continued:!1,err:t})}}})))):e({continued:!1})},r=i=>{const{continued:o=!1,err:l=null}=i;if(o)setTimeout((()=>n(r)),10);else if(l)hi.error(l.message),this._globalMutex.unlock(),this._event.error(l),s(l);else{const i=[];a.collectionNames.forEach((e=>{const s=this._collections.get(e);s&&s.state===Ss.READY||i.push((()=>t.__awaiter(this,void 0,void 0,(function*(){const t=yield di.metadataOf(this.name,e,this._store);if(t){const s=new di({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:t.indexes,store:this._store});this._collections.set(e,s),yield s.init()}})))())})),Promise.all(i).then((()=>{this._state=exports.NestDBState.OPENED,this._globalMutex.unlock(),this._event.success(),e()})).catch((e=>{hi.error(e.message),this._globalMutex.unlock(),this._event.error(e),s(e)}))}};n(r)}))}catch(e){switch(e.code){case Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:hi.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new yi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;case Ms.STORE_NOT_AVAILABLE:hi.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 yi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;default:throw hi.error(e.message),this._globalMutex.unlock(),this._event.error(e),e}}}var s}))}close(){this._collections.forEach((e=>e.close())),this._state=exports.NestDBState.CLOSED}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this._collections.values()).map((e=>e.clear())))}))}reset(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.name);e&&e.clearForDatabase(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]=ks;else this._event[e]=Us}collection(e){const t=this._collections.get(e);if(t)return t;throw Os.collectionNotReady}},exports.NestDBError=Os,exports.NotificationMessage=H,exports.NotificationMessageCache=xi,exports.OGImage=l,exports.OGMetaData=d,exports.OperatorListQuery=ze,exports.PENDING_MESSAGE_DELAY=2,exports.PinnedMessage=ms,exports.PinnedMessageListQuery=ys,exports.Plugin=z,exports.PollVoteEventCommand=ls,exports.PreviousMessageListQuery=$e,exports.Reaction=o,exports.ReactionEvent=r,exports.ReadAPIRequestCommand=v,exports.ReadAPIResponseCommand=E,exports.ReadEventCommand=I,exports.ReadRequestCommand=f,exports.ReadStatus=y,exports.RestrictedUser=ve,exports.RestrictionInfo=fe,exports.ScheduledFileMessageCreateParamsDefault=Ai,exports.ScheduledUserMessageCreateParamsDefault=Oi,exports.SendableMessage=F,exports.Sender=p,exports.ThreadInfo=a,exports.ThreadInfoUpdateEvent=$i,exports.Thumbnail=s,exports.UnbanUserEventCommand=wt,exports.UnmuteUserEventCommand=St,exports.UnsentMessageCache=Ni,exports.UpdateFileMessageEventCommand=Bt,exports.UpdateMetaCounterEventCommand=vt,exports.UpdateMetaDataEventCommand=lt,exports.UpdateUserMessageEventCommand=qt,exports.UploadFileRequestCommand=i,exports.UploadFileResponseCommand=n,exports.UploadedFileInfo=w,exports.UserMessage=Q,exports.UserMessageEventCommand=Lt,exports.UserMessageUpdateParamsDefault=qe,exports.createFileMessageCreateParams=Re,exports.createFileMessageCreateParamsFromFailedFileMessage=xe,exports.createMultipleFilesMessageCreateParams=function(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((e=>{var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((e=>({maxWidth:e.width,maxHeight:e.height}))),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))},exports.createUserMessageCreateParams=Se,exports.createUserMessageCreateParamsFromFailedUserMessage=Oe,exports.getMessageIndexBy=Mi,exports.getNotificationMessageIndexBy=Si,exports.parseMessagePayload=W,exports.payloadifyMessage=e=>{if(e.notificationId)return H.payloadify(e);switch(e.messageType){case t.MessageType.USER:return Q.payloadify(e);case t.MessageType.FILE:return e.fileInfoList?G.payloadify(e):Y.payloadify(e);case t.MessageType.ADMIN:return V.payloadify(e);default:throw t.SendbirdError.unknown}},exports.validateBaseMessageUpdateParams=De,exports.validateMessageRetrievalParams=e=>t.isTypeOf("string",e.channelUrl)&&t.isEnumOf(t.ChannelType,e.channelType)&&t.isTypeOf("number",e.messageId)&&t.isTypeOf("boolean",e.includeReactions,!0)&&t.isTypeOf("boolean",e.includeMetaArray,!0)&&t.isTypeOf("boolean",e.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",e.includeThreadInfo,!0),exports.validateScheduledFileMessageCreateParams=e=>Te(e)&&t.isTypeOf("number",e.scheduledAt)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),exports.validateScheduledUserMessageCreateParams=e=>Ae(e)&&t.isTypeOf("number",e.scheduledAt,!0),exports.validateUserMessageUpdateParams=Fe; diff --git a/cjs/lib/__bundle-611abb88.cjs b/cjs/lib/__bundle-947cb619.cjs similarity index 91% rename from cjs/lib/__bundle-611abb88.cjs rename to cjs/lib/__bundle-947cb619.cjs index 794f4d0..a7962f3 100644 --- a/cjs/lib/__bundle-611abb88.cjs +++ b/cjs/lib/__bundle-947cb619.cjs @@ -1 +1 @@ -var o=require("./__bundle-1a495950.cjs");exports.BaseChannelHandlerParams=class{constructor(){this.onUserMuted=o.noop,this.onUserUnmuted=o.noop,this.onUserBanned=o.noop,this.onUserUnbanned=o.noop,this.onChannelChanged=o.noop,this.onChannelDeleted=o.noop,this.onChannelFrozen=o.noop,this.onChannelUnfrozen=o.noop,this.onOperatorUpdated=o.noop,this.onChannelMemberCountChanged=o.noop,this.onMetaDataCreated=o.noop,this.onMetaDataUpdated=o.noop,this.onMetaDataDeleted=o.noop,this.onMetaCounterCreated=o.noop,this.onMetaCounterUpdated=o.noop,this.onMetaCounterDeleted=o.noop,this.onMessageReceived=o.noop,this.onMessageUpdated=o.noop,this.onMessageDeleted=o.noop,this.onMentionReceived=o.noop,this.onReactionUpdated=o.noop,this.onThreadInfoUpdated=o.noop}}; +var o=require("./__bundle-0486c467.cjs");exports.BaseChannelHandlerParams=class{constructor(){this.onUserMuted=o.noop,this.onUserUnmuted=o.noop,this.onUserBanned=o.noop,this.onUserUnbanned=o.noop,this.onChannelChanged=o.noop,this.onChannelDeleted=o.noop,this.onChannelFrozen=o.noop,this.onChannelUnfrozen=o.noop,this.onOperatorUpdated=o.noop,this.onChannelMemberCountChanged=o.noop,this.onMetaDataCreated=o.noop,this.onMetaDataUpdated=o.noop,this.onMetaDataDeleted=o.noop,this.onMetaCounterCreated=o.noop,this.onMetaCounterUpdated=o.noop,this.onMetaCounterDeleted=o.noop,this.onMessageReceived=o.noop,this.onMessageUpdated=o.noop,this.onMessageDeleted=o.noop,this.onMentionReceived=o.noop,this.onReactionUpdated=o.noop,this.onThreadInfoUpdated=o.noop}}; diff --git a/cjs/lib/__bundle-ca16c7ed.cjs b/cjs/lib/__bundle-ca16c7ed.cjs deleted file mode 100644 index 93aa9cf..0000000 --- a/cjs/lib/__bundle-ca16c7ed.cjs +++ /dev/null @@ -1 +0,0 @@ -var e=require("./__bundle-1a495950.cjs");class a extends e.BaseCommand{}exports.NotificationCollectionRefreshCommand=a,exports.getFeedChannelIndexBy=e=>["-lastMessageUpdatedAt","-createdAt","syncIndex"]; diff --git a/cjs/lib/__bundle-d1419fd1.cjs b/cjs/lib/__bundle-d1419fd1.cjs new file mode 100644 index 0000000..9e4e842 --- /dev/null +++ b/cjs/lib/__bundle-d1419fd1.cjs @@ -0,0 +1 @@ +var e=require("./__bundle-0486c467.cjs");class s extends e.BaseCommand{}exports.NotificationCollectionRefreshCommand=s,exports.getFeedChannelIndexBy=e=>["-lastMessageUpdatedAt","-createdAt","syncIndex"]; diff --git a/cjs/lib/__bundle-bfe2e997.cjs b/cjs/lib/__bundle-d349e14c.cjs similarity index 89% rename from cjs/lib/__bundle-bfe2e997.cjs rename to cjs/lib/__bundle-d349e14c.cjs index 3605e54..9d13de7 100644 --- a/cjs/lib/__bundle-bfe2e997.cjs +++ b/cjs/lib/__bundle-d349e14c.cjs @@ -1 +1 @@ -var e=require("./__bundle-1a495950.cjs"),s=require("./__bundle-165fd6e1.cjs");class t extends e.APIRequestCommand{constructor({channelType:s,channelUrl:t,limit:n,token:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(s)}/${encodeURIComponent(t)}/messages/parent_thread_message`,this.params=e.deundefined(e.undefineNullProps({limit:n,token:i}))}}class n extends e.APIResponseCommand{constructor(e,t){super(e,t),this.token=t.next,this.messages=t.messages.map((t=>s.parseMessagePayload(e,t)))}}class i extends e.ChannelDataListQuery{constructor(e,s,t,n){super(e,s,t,n),this._edge=""}_validate(){return super._validate()}load(){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),i=new t({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),a=yield s.send(i),{messages:r,token:d}=a.as(n);return this._edge=d,this._hasNext=!!d,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}exports.ThreadedParentMessageListQuery=i; +var e=require("./__bundle-0486c467.cjs"),s=require("./__bundle-4bcf4070.cjs");class t extends e.APIRequestCommand{constructor({channelType:s,channelUrl:t,limit:n,token:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(s)}/${encodeURIComponent(t)}/messages/parent_thread_message`,this.params=e.deundefined(e.undefineNullProps({limit:n,token:i}))}}class n extends e.APIResponseCommand{constructor(e,t){super(e,t),this.token=t.next,this.messages=t.messages.map((t=>s.parseMessagePayload(e,t)))}}class i extends e.ChannelDataListQuery{constructor(e,s,t,n){super(e,s,t,n),this._edge=""}_validate(){return super._validate()}load(){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),i=new t({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),a=yield s.send(i),{messages:r,token:d}=a.as(n);return this._edge=d,this._hasNext=!!d,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}exports.ThreadedParentMessageListQuery=i; diff --git a/cjs/lib/__bundle-dcf4d0c3.cjs b/cjs/lib/__bundle-dcf4d0c3.cjs deleted file mode 100644 index 435594b..0000000 --- a/cjs/lib/__bundle-dcf4d0c3.cjs +++ /dev/null @@ -1 +0,0 @@ -var e,t,s,n,i,a,r,o,l,d=require("./__bundle-1a495950.cjs"),h=require("./__bundle-165fd6e1.cjs"),c=require("./__bundle-2ad218ff.cjs"),u=require("./__bundle-d3673ecc.cjs"),_=require("./__bundle-bfe2e997.cjs");exports.MemberState=void 0,(e=exports.MemberState||(exports.MemberState={})).NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left";class p 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 m 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.member=new d.User(this._iid,t.user),this.deliveryAt=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 g{constructor(e){var t,s,n,i,a,r,o,l,d,h,c,u,_,p,m;this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(t=null==e?void 0:e.includeEmpty)&&void 0!==t&&t,this.nicknameContainsFilter=null!==(s=null==e?void 0:e.nicknameContainsFilter)&&void 0!==s?s:null,this.nicknameStartsWithFilter=null!==(n=null==e?void 0:e.nicknameStartsWithFilter)&&void 0!==n?n:null,this.nicknameExactMatchFilter=null!==(i=null==e?void 0:e.nicknameExactMatchFilter)&&void 0!==i?i:null,this.channelNameContainsFilter=null!==(a=null==e?void 0:e.channelNameContainsFilter)&&void 0!==a?a:"",this.myMemberStateFilter=null!==(r=null==e?void 0:e.myMemberStateFilter)&&void 0!==r?r:exports.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(o=null==e?void 0:e.customTypesFilter)&&void 0!==o?o:null,this.channelUrlsFilter=null!==(l=null==e?void 0:e.channelUrlsFilter)&&void 0!==l?l:null,this.superChannelFilter=null!==(d=null==e?void 0:e.superChannelFilter)&&void 0!==d?d:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(h=null==e?void 0:e.publicChannelFilter)&&void 0!==h?h:exports.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(c=null==e?void 0:e.customTypeStartsWithFilter)&&void 0!==c?c:null,this.unreadChannelFilter=null!==(u=null==e?void 0:e.unreadChannelFilter)&&void 0!==u?u:exports.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==e?void 0:e.hiddenChannelFilter)&&void 0!==_?_:exports.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(p=null==e?void 0:e.includeFrozen)||void 0===p||p,(null==e?void 0:e.createdAfter)&&(this.createdAfter=e.createdAfter),(null==e?void 0:e.createdBefore)&&(this.createdBefore=e.createdBefore),this.includeMetaData=null===(m=null==e?void 0:e.includeMetaData)||void 0===m||m}_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 g;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("*")&&!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.ALL:if("none"===e.myMemberState)return!1;break;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!(this.createdAfter&&e.createdAtthis.createdBefore)}}class C 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 be.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 c.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!s&&t.name.localeCompare(e)<0||s&&t.name.localeCompare(e)>0)return!1;break;case c.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>e||s&&t.createdAte||s&&t.lastMessageUpdatedAtthis._deserialize(e)));return d.forEach((e=>{!n.includeMetaData&&e.cachedMetaData&&e._clearCachedMetaData(),this._channels.has(e.url)||this._channels.set(e.url,e)})),d}return[]}))}upsert(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];if(e.forEach((e=>{if(this._channels.has(e.url)){const n=this._channels.get(e.url);if(n._pinnedMessagesUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t){const{isUpdated:s}=n._updateCachedMetaData(e.cachedMetaData,t);s||Object.assign(e,{_cachedMetaData:void 0})}n._update(e),s.push(n)}else this._channels.set(e.url,e),s.push(e)})),this.localCacheEnabled){const e=[];for(let t=0;t0&&(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},v=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),f={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},M=e=>d.isArrayOf("string",e.customTypes,!0)&&d.isTypeOf("boolean",e.includeEmpty,!0)&&d.isTypeOf("boolean",e.includeFrozen,!0)&&d.isTypeOf("boolean",e.includeMetaData,!0)&&d.isTypeOf("boolean",e.includeChatNotification,!0),y={myMemberStateFilter:exports.MyMemberStateFilter.ALL},S=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 b={keys:[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,exports.UnreadItemKey.NONSUPER_INVITATION_COUNT,exports.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},N={channelCustomTypesFilter:void 0,superChannelFilter:exports.SuperChannelFilter.ALL},T=e=>d.isArrayOf("string",e.channelCustomTypesFilter,!0)&&d.isEnumOf(exports.SuperChannelFilter,e.superChannelFilter),U={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:d.MessageTypeFilter.ALL},I=Object.assign({},d.CollectionEventSource),x=e=>e.startsWith("EVENT_")||e===d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||e===d.CollectionEventSource.REFRESH_CHANNEL;class P extends d.BaseCommand{constructor({channels:e,context:t,isWebSocketEventComing:s=!1,ts:n}){super(),this.channels=e,this.context=t,this.isWebSocketEventComing=s,this.ts=n}}class R extends d.BaseCommand{constructor({channelUrls:e,context:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.context=t,this.isWebSocketEventComing=s}}class O{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 P){const{channels:s,context:i,isWebSocketEventComing:a}=n,r=s.filter((e=>e instanceof vt));if(i.source===d.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY||i.source===d.CollectionEventSource.EVENT_CHANNEL_HIDDEN)for(const e of r)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp);else{const s=e.filterOffsetChanged(r);for(const e of s)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp)}const o=yield e.upsert(r,n.ts);a||this._broadcastUpdateEvent(o,i)}else if(n instanceof R){const{channelUrls:i,context: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 c.DatabaseOpenCommand&&(yield e.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,t)}_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 w extends d.APIRequestCommand{constructor({userId:e,ts:t,token:s,filter:n,includeChatNotification:i=!1}){super();const{customTypes:a,includeEmpty:r,includeFrozen:o}=Object.assign(Object.assign({},f),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:a,show_empty:r,show_frozen:o,include_chat_notification:i}))}}class L extends d.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((s=>new vt(e,Object.assign(s,{ts:t.ts})))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next,this.ts=t.ts}}class F extends d.APIRequestCommand{constructor({channelUrl:e,isInternalCall:t,showLatestMessage:s}){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,show_latest_message:null!=s&&s}}}class D extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}const k={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0};class H 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:c,nicknameStartsWithFilter:u,nicknameExactMatchFilter:_,channelNameContainsFilter:p,channelUrlsFilter:m,customTypesFilter:g,customTypeStartsWithFilter:C,hiddenChannelFilter:E,metadataOrderKeyFilter:v,metadataKey:f,metadataValues:M,metadataValueStartsWith:y,includeFrozen:S,includeMetaData:A,searchFilter:b,userIdsFilter:N,includeChatNotification:T=!1,includeLeftChannel:U=!1,createdAfter:I,createdBefore:x}=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:k.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=a?a:k.includeEmpty,member_state_filter:null!=r?r:k.myMemberStateFilter,super_mode:null!=o?o:k.superChannelFilter,public_mode:null!=l?l:k.publicChannelFilter,unread_filter:null!=h?h:k.unreadChannelFilter,members_nickname_contains:c,members_nickname_startswith:u,members_nickname:_,name_contains:p,channel_urls:m,custom_types:g,custom_type_startswith:C,hidden_mode:E,metadata_order_key:v,metadata_key:f,metadata_values:M,metadata_value_startswith:y,show_frozen:S,show_metadata:A,include_chat_notification:T,include_left_channel:U,created_after:I,created_before:x}),b&&b.query&&b.fields&&(this.params.search_query=b.query,this.params.search_fields=b.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(this.params.members_include_in=N.userIds,this.params.query_type=N.queryType.toUpperCase()):this.params.members_exactly_in=N.userIds)}}class V 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 vt(e,t))))),this.ts=null!=i?i:0}}class G 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 q extends d.APIResponseCommand{constructor(e,t){super(e,t),this.groupChannelCount=t.group_channel_count}}class B extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{keys:s,customTypeFilters:n,customTypesFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_item_count`,this.params=d.deundefined({item_keys:s,custom_types:null!=i?i:n})}}class j 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 z extends d.APIRequestCommand{constructor({userId:e}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_channel_count`}}class W extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class $ extends d.APIRequestCommand{constructor({userId:e,filter:t,includeFeedChannel:s=!1}){super();const{channelCustomTypesFilter:n,superChannelFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_message_count`,this.params={super_mode:null!=i?i:exports.SuperChannelFilter.ALL,custom_types:n,include_feed_channel:s}}}class K extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count,this.unreadFeedCount=t.unread_feed_count}}class Q 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:J(t)},s&&(this.params.message_type=s)}}class Y extends d.APIResponseCommand{constructor(e,t){super(e,t),this.count=t.count}}const J=e=>{if(!e)return[];const t=[];return e.forEach((e=>{switch(e){case h.ScheduledStatus.PENDING:t.push(h.InternalScheduledStatus.PENDING);break;case h.ScheduledStatus.SENT:t.push(h.InternalScheduledStatus.IN_QUEUE),t.push(h.InternalScheduledStatus.SENT);break;case h.ScheduledStatus.CANCELED:t.push(h.InternalScheduledStatus.CANCELED);break;case h.ScheduledStatus.FAILED:t.push(h.InternalScheduledStatus.FAILED)}})),t};class X 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:c,isStrict:u,isEphemeral:_,accessCode:p,name:m,data:g,customType:C,messageSurvivalSeconds:E,invitedUserIds:v,operatorUserIds:f}=e;super(),this.method=d.APIRequestMethod.POST,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined({user_ids:[t,...null!=v?v:[]].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:c,strict:u,is_ephemeral:_,access_code:p,name:m,data:g,custom_type:C,operator_ids:f,message_survival_seconds:E})}}class Z extends d.APIResponseCommand{constructor(e,t){var s;super(e,t),this.channel=new vt(e,t),this.isCreated=null===(s=t.is_created)||void 0===s||s}}class ee 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 te 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 se extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class ne extends u.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 p(e,t))):[new p(e,s.data)]}}class ie 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 ae extends u.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 p(this._iid,s.data)}}class re 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 oe extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class le extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s),this.inviter=null;const{member_count:n=0,joined_member_count:i=0,inviter:a,invitees:r=[]}=s.data;this.memberCount=n,this.joinedMemberCount=i,a&&Object.keys(a).length>0&&(this.inviter=new d.User(e,a)),this.invitees=r.map((t=>new p(e,t)))}}class de 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 he extends u.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 p(e,r)}}const ce={hidePreviousMessages:!1,allowAutoUnhide:!0};class ue 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 _e extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}class pe 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 me extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPST",ackRequired:!1,payload:{channel_url:e,time:t}})}}class ge extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class Ce 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 ve extends d.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"MACK",ackRequired:!1,payload:{channel_url:e,msg_id:t}})}}class fe extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,u,_,p,m,g,C,E,v,f,M,y,S,A,b;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.includeChatNotification=!1,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=c.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.includeChatNotification=null!==(a=t.includeChatNotification)&&void 0!==a&&a,this.channelUrlsFilter=null!==(r=t.channelUrlsFilter)&&void 0!==r?r:null,this.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,this.customTypeStartsWithFilter=null!==(l=t.customTypeStartsWithFilter)&&void 0!==l?l:"",this.nicknameContainsFilter=null!==(d=t.nicknameContainsFilter)&&void 0!==d?d:null,this.nicknameStartsWithFilter=null!==(h=t.nicknameStartsWithFilter)&&void 0!==h?h:null,this.nicknameExactMatchFilter=null!==(u=t.nicknameExactMatchFilter)&&void 0!==u?u:null,this.channelNameContainsFilter=null!==(_=t.channelNameContainsFilter)&&void 0!==_?_:"",this.myMemberStateFilter=null!==(p=t.myMemberStateFilter)&&void 0!==p?p:exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=null!==(m=t.unreadChannelFilter)&&void 0!==m?m:exports.UnreadChannelFilter.ALL,this.superChannelFilter=null!==(g=t.superChannelFilter)&&void 0!==g?g:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(C=t.publicChannelFilter)&&void 0!==C?C:exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=null!==(E=t.hiddenChannelFilter)&&void 0!==E?E:exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter=null!==(v=t.searchFilter)&&void 0!==v?v:{fields:[],query:null},this.userIdsFilter=null!==(f=t.userIdsFilter)&&void 0!==f?f:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null!==(M=t.metadataKey)&&void 0!==M?M:null,this.metadataValues=null!==(y=t.metadataValues)&&void 0!==y?y:null,this.metadataOrderKeyFilter=null!==(S=t.metadataOrderKeyFilter)&&void 0!==S?S:null,this.metadataValueStartsWith=null!==(A=t.metadataValueStartsWith)&&void 0!==A?A:null,this.order=null!==(b=t.order)&&void 0!==b?b:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,t.createdAfter&&(this.createdAfter=t.createdAfter),t.createdBefore&&(this.createdBefore=t.createdBefore)}_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(c.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)&&d.isMilliSecondOf(this.createdAfter,!0)&&d.isMilliSecondOf(this.createdBefore,!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=be.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign({},this)),this.limit,d.CollectionEventSource.REQUEST_CHANNEL,!0);return this._token=s,this._hasNext=!!s,this._isLoading=!1,t}return[]}throw d.SendbirdError.invalidParameters}))}}class Me extends d.APIRequestCommand{constructor({channelUrl:e,userId:t}){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 ye extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"DLVR",s),this.channelUrl=s.channel_url,this.deliveredStateUpdate=s.updated}}class Se{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)}}const Ae={};class be extends u.BaseChannelManager{get _messageCache(){return h.MessageCache.of(this._iid)}get _unsentMessageCache(){return h.UnsentMessageCache.of(this._iid)}constructor(e,t){var s;super(e,Object.assign(Object.assign({},t),{channelType:d.ChannelType.GROUP})),this._leftChannels=new Map,this._disableMack=!1,this._markAsReadAllLastSentAt=0,this._disableMack=null!==(s=t.disableMack)&&void 0!==s&&s,this._groupChannelHandlers=new Map,this._groupChannelCache=new C(this._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),this._groupChannelBroadcast=new O({dispatcher:t.dispatcher,groupChannelCache:this._groupChannelCache,messageCache:h.MessageCache.of(this._iid),unsentMessageCache:h.UnsentMessageCache.of(this._iid)}),setInterval((()=>{for(const e of this._groupChannelCache.channels)e.invalidateTypingStatus()&&(this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.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).catch((e=>{if(d.isThrowingOutside(e)&&"foreground"===this._sdkState.appState)throw e})):e instanceof c.AutoResendRequestCommand?(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{message:t}=e,s=yield this.getChannel(t.channelUrl,!0);t instanceof h.UserMessage?s._autoResendUserMessage(t):t instanceof h.FileMessage&&s._autoResendFileMessage(t)}))})():e instanceof c.ReduceDBSizeEventCommand?this.reduceDBSize():e instanceof h.MessageThreadInfoUpdatedEventCommand&&(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{channelUrl:t,channelType:s,parentMessage:n}=e,i=new h.ThreadInfoUpdateEvent(this._iid,{channel_type:d.ChannelType.GROUP,channel_url:t,parent_message_id:n.messageId,thread_info:h.ThreadInfo.payloadify(n.threadInfo)});if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onThreadInfoUpdated&&t.onThreadInfoUpdated(e,i)}))))}}))})()})),Ae[e]||(Ae[e]=this)}static of(e){return Ae[e]||(Ae[e]=new be(e,d.Vault.of(e))),Ae[e]}static clear(e){Ae[e]&&delete Ae[e]}get handlers(){return[...this._groupChannelHandlers.values()]}buildGroupChannelFromSerializedData(e){const t=d.deserialize(e);return new vt(this._iid,vt.payloadify(t))}buildGroupChannelListQueryFromSerializedData(e){const t=d.deserialize(e);return new fe(this._iid,t)}buildMemberFromSerializedData(e){const t=d.deserialize(e);return new p(this._iid,p.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 e=h.MessageCache.of(this._iid),{cacheContext:t}=d.Vault.of(this._iid),{localCacheConfig:s,nestdb:n}=t;if(!t.localCacheEnabled||!n||n.state!=h.NestDBState.OPENED)return;const i=1024*s.maxSize*1024;let a=yield n.estimateUsage();if(ad.__awaiter(this,void 0,void 0,(function*(){const t=new ve(e);this._requestQueue.send(t)}))));const s=this._groupChannelCache.isCachedInMemory(e.channelUrl),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId,r=yield this.getChannel(e.channelUrl,!0),{useMemberInfoInMessage:o}=d.Vault.of(this._iid);if(e instanceof h.SendableMessage){for(const t of r.members)if(t.userId===e.sender.userId){o||(e.sender.nickname=t.nickname,e.sender.plainProfileUrl=t.plainProfileUrl,e.sender.metaData=t.metaData,e.sender.isBlockedByMe=t.isBlockedByMe);break}if(!o&&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._updateLastMessage(e),a||r._shouldUpdateUnreadCountWith(e)&&r._updateUnreadCount(r.unreadMessageCount+1,r.unreadMentionCount+(n?1:0))),i&&r._updateLastMessage(e),this._dispatcher.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),e.silent&&!a||d.runAsCallback((()=>d.__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.CollectionEventSource.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(u.UpdateAdminMessageEventCommand)),t){const{message:e,mentionCountChange:n}=t;if(e.threadInfo&&(e.threadInfo.unreadReplyCount=void 0),e.channelType===d.ChannelType.GROUP){const t=this._groupChannelCache.isCachedInMemory(e.channelUrl),i=yield this.getChannel(e.channelUrl,!0),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId;let r=!1;if(a){const t=e.sender,{currentUser:s}=this._sessionManager;s&&(s.nickname=t.nickname,s.plainProfileUrl=t.plainProfileUrl,s.metaData=t.metaData)}else i.isReadMessage(e)||0!==n&&!e.silent&&t&&(i._updateUnreadCount(i.unreadMessageCount,i.unreadMentionCount+n),r=!0);i._updateLastMessage(e)?r=!0:(null===(s=i.lastMessage)||void 0===s?void 0:s.isIdentical(e))&&(t?i._updateLastMessage(e)&&(r=!0):r=!0);let o=!1;i.lastPinnedMessage&&i.lastPinnedMessage.messageId===e.messageId&&(i.lastPinnedMessage=e,r=!0,o=!0),r&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:o?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}})),e.silent&&!a||d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)})))),o&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)}))))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageUpdated&&t.onMessageUpdated(i,e),n>0&&t.onMentionReceived&&t.onMentionReceived(i,e)}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:n,silent:i,messageCreatedAt:a,senderId:r}=e.as(d.DeleteMessageEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=r===this._sdkState.userId;i||s||a>0&&e.myLastRead0&&e._updateUnreadCount(e.unreadMessageCount-1,0),this._dispatcher.dispatch(new d.MessageRemoveEventCommand({messageIds:[n],source:d.CollectionEventSource.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(h.ReadEventCommand);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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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(ye),n=this._groupChannelCache.isCachedInMemory(t),i=yield this.getChannel(t,!0);n&&Object.keys(s).forEach((e=>{i._updateUndeliveredMemberState(e,s[e])})),Object.keys(s).some((e=>e!==this._sdkState.userId))&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:d.CollectionEventSource.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(u.ReactionEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=yield this.getMessageFromCache(n.messageId);s?s instanceof h.BaseMessage&&(s.applyReactionEvent(n),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new d.ReactionUpdateEventCommand({event:n,source:d.CollectionEventSource.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(u.ThreadInfoUpdateEventCommand);if(t.channelType===d.ChannelType.GROUP){const e=yield this.getChannel(t.channelUrl,!0),s=yield this.getMessageFromCache(t.targetMessageId);s?s instanceof h.BaseMessage&&(s.applyThreadInfoUpdateEvent(t),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new d.ThreadUpdateEventCommand({event:t,source:d.CollectionEventSource.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(u.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 P({channels:s,context:{source:d.CollectionEventSource.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(u.PollUpdateEventCommand);if(n&&i===d.ChannelType.GROUP){const e=yield this.getChannel(n,!0);this._dispatcher.dispatch(new d.PollUpdateInternalEventCommand({event:t,source:d.CollectionEventSource.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.CollectionEventSource.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(u.ChannelEventCommand);if(t.isGroupChannelEvent)switch(t.category){case u.ChannelEventCategory.CHANNEL_JOIN:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,members:a}=e.as(ne);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:a}})),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 u.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(ae);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((e=>e.userId===r.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 P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})):(this._markAsLeave(n),this._dispatcher.dispatch(new R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})))):this._dispatcher.dispatch(new P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})),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 u.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const s=yield this.getChannel(t.channelUrl,!0),{operators:n}=e.as(u.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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitees:r}=e.as(le);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:a,invitees:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserReceivedInvitation&&e.onUserReceivedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitee:r}=e.as(he);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})):this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}}))):this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.TYPING_START:case u.ChannelEventCategory.TYPING_END:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.TYPING_START,{user:i}=e.as(n?ge:Ee);s._updateTypingStatus(i,n?t.ts:0),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.USER_CHANNEL_MUTE:case u.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.USER_CHANNEL_MUTE,{user:i}=e.as(n?h.MuteUserEventCommand:h.UnmuteUserEventCommand);i.userId===this._sdkState.userId&&(s.myMutedState=n?d.MutedState.MUTED:d.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 P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_MUTED:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i}})),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 u.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 R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_BANNED,user:i}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserBanned&&e.onUserBanned(n,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_UNBAN:{const s=yield this.getChannel(t.channelUrl,!0),{user:n}=e.as(h.UnbanUserEventCommand);n.userId===this._sdkState.userId&&this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserUnbanned&&e.onUserUnbanned(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_FREEZE:case u.ChannelEventCategory.CHANNEL_UNFREEZE:{const s=yield this.getChannel(t.channelUrl,!0),{freeze:n}=e.as(h.FreezeEventCommand);s.isFrozen=n,this._dispatcher.dispatch(new P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_FROZEN:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_HIDE:{const s=yield this.getChannel(t.channelUrl,!0),{allowAutoUnhide:n,hidePreviousMessages:i,messageOffsetTimestamp:a}=e.as(pe);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onChannelHidden&&e.onChannelHidden(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_UNHIDE:{const e=yield this.getChannel(t.channelUrl,!0);e.hiddenState=exports.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_DELETED:{const e=yield this.getChannel(t.channelUrl,!0);this._dispatcher.dispatch(new R({channelUrls:[t.channelUrl],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const e=yield this.getChannelWithoutCache(t.channelUrl,!0);this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.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),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:n},ts:t.ts}))),i&&(s._upsertCachedMetaData(i,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:i},ts:t.ts}))),a&&(s._removeFromCachedMetaData(a,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:a},ts: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 u.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaCounterEventCommand);n&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:n}})),i&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:i}})),a&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:a}})),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 u.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:n,latestPinnedMessage:i,ts:a}=e.as(u.UpdatePinnedMessageEventCommand);a>s._pinnedMessagesUpdatedAt&&(s.pinnedMessageIds=null!=n?n:[],s.lastPinnedMessage=i,s._pinnedMessagesUpdatedAt=a,this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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(c.UserEventCommand);switch(t.category){case c.UserEventCategory.USER_BLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.block(e.userId,s.userId);break}case c.UserEventCategory.USER_UNBLOCK:{const{blocker:e,blockee:s}=c.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()}subscribeChannelEvent(e,t){this._groupChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._groupChannelBroadcast.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 F({channelUrl:e,isInternalCall:t}),n=yield this._requestQueue.send(s),{channel:i}=n.as(D);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=d.CollectionEventSource.REFRESH_CHANNEL,n=!1){return d.__awaiter(this,void 0,void 0,(function*(){try{const i=new F({channelUrl:e,isInternalCall:t,showLatestMessage:n}),a=yield this._requestQueue.send(i),{channel:r}=a.as(D);if(r.myMemberState===exports.MemberState.NONE)this._dispatcher.dispatch(new R({channelUrls:[r.url],context:{source:s}}));else{const e=yield this.upsertChannelsToCache([r]);this._dispatcher.dispatch(new P({channels:e,context:{source:s}}))}}catch(t){t.code!==d.SendbirdErrorCode.NON_AUTHORIZED&&t.code!==d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new R({channelUrls:[e],context:{source:s}}))}}))}getMyGroupChannels(e,t,s,n=d.CollectionEventSource.REQUEST_CHANNEL,i=!1){return d.__awaiter(this,void 0,void 0,(function*(){t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3));let a=!1;if(i){const{appInfo:e,cacheContext:t}=d.Vault.of(this._iid);t&&!t.localCacheEnabled&&(null==e?void 0:e.enabledChannelMemberShipHistory)&&(null==e?void 0:e.applicationAttributes.includes("left_user_view_support"))&&(a=!0)}const r=new H(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:e,limit:s,includeLeftChannel:i&&a})),o=yield this._requestQueue.send(r),{channels:l,token:h}=o.as(V);return this._dispatcher.dispatch(new P({channels:l,context:{source:n}})),{channels:l,token:h}}))}getMyGroupChannelChangeLogs(e,t,s=d.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return d.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},f),t);d.unless((d.isTypeOf("string",e)||d.isTypeOf("number",e))&&M(n)).throw(d.SendbirdError.invalidParameters);const i=new w(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(L),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,ts:h}=a;return r.length>0&&this._dispatcher.dispatch(new P({channels:r,context:{source:s},ts:h})),o.length>0&&this._dispatcher.dispatch(new R({channelUrls:o,context:{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({},y),e);d.unless(S(t)).throw(d.SendbirdError.invalidParameters);const s=new G({userId:this._sdkState.userId,filter:t}),n=yield this._requestQueue.send(s),{groupChannelCount:i}=n.as(q);return i}))}getUnreadItemCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},b),e);d.unless((e=>d.isArrayOf(exports.UnreadItemKey,e.keys)&&d.isArrayOf("string",e.customTypeFilters,!0)&&d.isArrayOf("string",e.customTypesFilter,!0))(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),{groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m}=a.as(j);return d.deundefined({groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,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 z({userId:e.userId}),n=yield t.send(s),{unreadCount:i}=n.as(W);return i}))}getTotalUnreadMessageCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},N),e);d.unless(T(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new $({userId:s.userId,filter:t}),a=yield n.send(i),{unreadCount:r}=a.as(K);return r}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},U),e);d.unless((e=>d.isTypeOf("string",e.channelUrl,!0)&&d.isArrayOf(h.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 Q(t),i=yield s.send(n),{count:a}=i.as(Y);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);return Object.keys(t.customTypes).forEach((s=>{e+=t.customTypes[s]})),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(v(t)).throw(d.SendbirdError.invalidParameters),t.isPublic||(t.accessCode=void 0);const s=new X(Object.assign({userId:this._sdkState.userId},t)),n=yield this._requestQueue.send(s),{channel:i}=n.as(Z);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 ee({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 ee({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()}))}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){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})}))}getCachedMessageCountBetween(e,t,s,n){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.countBetween(e,t,new Se({top:s,bottom:n}))}))}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])}))}}const Ne=(e,t)=>t instanceof h.SendableMessage?e.findIndex((e=>e instanceof h.SendableMessage&&t.isIdentical(e))):e.findIndex((e=>e.isIdentical(t))),Te=(e,t)=>e.findIndex((e=>e instanceof h.BaseMessage?e.messageId===t:e instanceof h.NotificationMessage?e.notificationId===t:void 0)),Ue=(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};var Ie;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Ie||(Ie={}));class xe extends d.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=Ie.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===Ie.IDLE}get isRunning(){return this._state===Ie.RUNNING}get isDone(){return this._state===Ie.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 xe(_,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u,_;const p={hasNext:!0,nextToken:0};if(this._prevSyncLoopCount++,yield this.loadMetadata(),r.debug("message background prev sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.top),null===(n=this._metadata)||void 0===n?void 0:n.previousComplete)p.hasNext=!1;else try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(l=null===(a=this._metadata)||void 0===a?void 0:a.range)||void 0===l?void 0:l.top)?this._metadata.range.top:e,{prevResultSize:this._limit,nextResultSize:0,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(c=this._metadata)||void 0===c?void 0:c.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}p.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(p.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.lengthd.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u;const _={hasNext:!0,nextToken:0};yield this.loadMetadata(),r.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom);try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(a=null===(n=this._metadata)||void 0===n?void 0:n.range)||void 0===a?void 0:a.bottom)?this._metadata.range.bottom:e,{prevResultSize:0,nextResultSize:this._limit,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(l=this._metadata)||void 0===l?void 0:l.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}_.hasNext=s.length>=this._limit,this._metadata&&(_.nextToken=this._metadata.range.bottom),r.debug("message background next sync progress",_),yield this.saveMetadata()}catch(e){throw r.debug("message background next sync error",e),e}finally{o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:t.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(u=null===(c=i.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==u?u:0,use_local_cache:i.localCacheEnabled,starting_point:0,message_init_policy:""}}))}return _}))))})))),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){return Pe[e]||(Pe[e]={}),Pe[e][t.url]||(Pe[e][t.url]=new Re({_iid:e,channel:t})),Pe[e][t.url].ref++,Pe[e][t.url]}static clear(e,t){Pe[e]&&Pe[e][t]&&(Pe[e][t].close(),delete Pe[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 Se({})}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(){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?{range:new Se(t.range),previousComplete:t.previousComplete}:{range:new Se({}),previousComplete:!1}}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(e=Date.now()){var t,s,n,i;const{logger:a,sessionManager:r,cacheContext:o}=d.Vault.of(this._iid);o.localCacheEnabled&&r.session.hasSession&&(a.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(s=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==s?s:e),this._nextSync.start(null!==(i=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==i?i:e))}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid][this._channel.url])}}const Oe={};class we{constructor({_iid:e,channel:t,includeParams:s}){this.ref=0,this._iid=e,this._channel=t,this._includeParams=s;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}/message/changelogs.meta`);const l=((e,t)=>`sendbird:${e}@groupchannel/${t}/message/changelogs`)(i.userId,this._channel.url);this._sync=new xe(l,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};yield this.loadMetadata(),n.debug("message changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=h.MessageManager.of(this._iid),{updatedMessages:s,deletedMessageIds:i,hasMore:a,token:r}=yield e.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:d.ReplyType.ALL},this._includeParams),d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);t.hasNext=a,t.nextToken=r,(s.length>0||i.length>0)&&this._metadata&&(this._metadata.token=r),n.debug("message changelog sync progress",t),yield this.saveMetadata()}catch(e){throw n.debug("message 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 Oe[e]||(Oe[e]={}),Oe[e][t.url]||(Oe[e][t.url]=new we({_iid:e,channel:t,includeParams:s})),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])}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,sessionManager:t}=d.Vault.of(this._iid);t.session.hasSession&&(e.debug("message changelog sync resume()"),this._sync.start(0))}pause(){const{logger:e}=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 Oe[this._iid][this._channel.url])}}const Le={};class Fe{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 xe(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=d.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 Le[e]||(Le[e]={}),Le[e][t.url]||(Le[e][t.url]=new Fe({_iid:e,channel:t,hasPollMessage:s})),Le[e][t.url].ref++,Le[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 Le[this._iid][this._channel.url])}}class De extends d.APIRequestCommand{constructor(e){var t,s,n,i,a,r,o,l,h,c;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_reply_type:null!==(i=e.replyType)&&void 0!==i?i:d.ReplyType.NONE,include_reactions:null===(a=e.includeReactions)||void 0===a||a,include_meta_array:null===(r=e.includeMetaArray)||void 0===r||r,include_thread_info:null===(o=e.includeThreadInfo)||void 0===o||o,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(c=e.showSubchannelMessagesOnly)&&void 0!==c&&c,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=>h.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=>h.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 He={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};exports.MessageCollectionInitPolicy=void 0,(exports.MessageCollectionInitPolicy||(exports.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";class Ve{constructor(){this._onCacheResult=d.noop,this._onApiResult=d.noop}_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 Ge{keyOf(e){return 0}get changelogIncludeParams(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}_postprocessChannelUpdateEvent(e,t){}_postprocessChannelRemoveEvent(e){}_postprocessMessageUpdateEvent(e,t){}_postprocessMessageRemoveEvent(e){}constructor(e,{filter:t,startingPoint:s,limit:n,prevResultLimit:i,nextResultLimit:a,channel:r,channelManager:o,disableBackgroundSync:l=!1}){this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key=`mc-${d.uuid()}`,this._isDisposed=!1,this.filter=null!=t?t:new h.MessageFilter,this._channel=r,this._syncRange=new Se({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=n||h.DEFAULT_MESSAGE_LIMIT,this._prevResultLimit=null!=i?i:Math.floor(this._limit/2),this._nextResultLimit=null!=a?a:Math.floor(this._limit/2),this._channelManager=o;const{statManager:c}=d.Vault.of(this._iid);this._channelManager.subscribeChannelEvent(this._key,{onUpdate:(e,t)=>{const{source:s}=t,n=e.findIndex((e=>e.isIdentical(this.channel)));n>=0&&(this._replaceChannelOfCollection(e[n]),this.channel._runIfHandleableWithGroupChannel((e=>{switch(s){case d.CollectionEventSource.EVENT_CHANNEL_UPDATED:{let t=!1;for(let s=0;s=e.messageOffsetTimestamp){t=!0;const e=s;if(e>0){const t=this._messages.splice(0,e);this._removeMessagesFromView(t.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!t&&this._messages.length>0&&this._removeMessagesFromView(this._messages.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break}case d.CollectionEventSource.EVENT_CHANNEL_UNMUTED:{const{sdkState:e}=d.Vault.of(this._iid),{user:s}=t;e.userId===s.userId&&this._clearCheckMyMutedTimer();break}case d.CollectionEventSource.EVENT_CHANNEL_MUTED:{const{sdkState:s}=d.Vault.of(this._iid),{user:n}=t;s.userId===n.userId&&-1!==e._myMutedRemainingTime&&this._startCheckMyMutedTimer(e._myMutedRemainingTime);break}case d.CollectionEventSource.EVENT_CHANNEL_LEFT:e.isPublic&&this._clearCheckMyMutedTimer()}d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;x(s)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel)}))))})),this._postprocessChannelUpdateEvent(e[n],s))},onRemove:(e,t)=>{const s=e.indexOf(this.channel.url);s>=0&&(this._clearCheckMyMutedTimer(),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url)})))),this._postprocessChannelRemoveEvent(e[s]))}}),this._channelManager.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(this.keyOf(t)));if(d.shouldGiveEvent(t)){if(s.length>0)switch(t){case d.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case d.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case d.CollectionEventSource.EVENT_MESSAGE_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:this._updateMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:this._addMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_RECEIVED:this.hasNext||this._addMessagesToView(s,t);break;case d.CollectionEventSource.SYNC_MESSAGE_FILL:this._addMessagesToView(s,t)}n.length>0&&this._removeMessagesFromView(n,t)}this._postprocessMessageUpdateEvent(e,t)},onRemove:(e,t)=>{this._removeMessagesFromView(e,t),this._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:(e,t)=>{this._applyReactionEventToView(e,t)},onThreadInfoUpdate:(e,t)=>{this._applyThreadInfoEventToView(e,t)}});const{cacheContext:u,dispatcher:_,messageBackgroundSyncThrottleController:p}=d.Vault.of(this._iid);this._channel._updateMessageCollectionLastAccessedAt(),_.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Re.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=we.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Fe.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new xe(this._key,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.min(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:i.length>=this._prevResultLimit&&this.viewTopd.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.max(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:!(i.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>e,nextToken:this._syncRange.bottom}}return u.localCacheEnabled&&c.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(s=u.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==n?n:0,use_local_cache:u.localCacheEnabled,starting_point:0,message_init_policy:""}})),{hasNext:!1,nextToken:0}}))))})))),this._connectionEventContext=_.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)switch(e.stateType){case d.ConnectionStateType.CONNECTED:d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){this._activate()}))));break;case d.ConnectionStateType.LOGOUT:this.dispose();break;default:this._clearCheckMyMutedTimer(),this._prevFill.stop(),this._nextFill.stop()}}))}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)}_activate(){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:e}=d.Vault.of(this._iid);e.debug("check huge gap"),this._checkHugeGap(),yield this._refreshChannel(d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS)}))}_replaceChannelOfCollection(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}_shouldStartBackgroundSync(){const{cacheContext:e}=d.Vault.of(this._iid);return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}_setBaseMessageCollectionHandler(e){this._handler=e}_filterUnderOffsetMessage(e){return e}_updateChildMessagesInView(e){const t=[];return this._messages.forEach((s=>{s instanceof h.BaseMessage&&s.parentMessageId===e.messageId&&s.applyParentMessage(e)&&t.push(s)})),t}_updatePollsToView(e,t){const s=[];for(const t of e){const e=Te(this._messages,t.messageId);if(e>=0){const n=this._messages[e];n.isUserMessage()&&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,n;const i={source:t};s.length>0&&(null===(n=(e=this._handler).onMessagesUpdated)||void 0===n||n.call(e,i,this.channel,s))})))),s}_applyPollUpdateEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyPollVoteEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyReactionEventToView(e,t){const s=Te(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyReactionEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_applyThreadInfoEventToView(e,t){const s=Te(this._messages,e.targetMessageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyThreadInfoUpdateEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_removeMessagesFromView(e,t){const s=[],n=[];for(const t of e){const e=this._messages.findIndex((e=>this.keyOf(e)===t));if(e>=0){const t=this._messages[e];s.push(this.keyOf(t)),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,i;const a={source:t};null===(i=null===(e=this._handler)||void 0===e?void 0:e.onMessagesDeleted)||void 0===i||i.call(e,a,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*(){let i=[];n&&(i=yield this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter));const a=t>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,t,!1):[],r=s>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1):[];return{messages:[...i,...a,...r].sort(((e,t)=>t.createdAt-e.createdAt)),prevMessagesCount:a.length,nextMessagesCount:r.length}}))}_getRemoteMessages(e,{prevLimit:t=0,nextLimit:s=0,source:n=d.CollectionEventSource.REQUEST_MESSAGE,reverse:i=!1,checkingHasNext:a=!1,checkingContinuousMessages:r=!1}){return d.__awaiter(this,void 0,void 0,(function*(){const o=h.MessageManager.of(this._iid);return t>0||s>0?yield o._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,d.undefineNullProps(Object.assign(Object.assign(Object.assign({},this.filter),He),{isInclusive:!0,reverse:i,prevResultSize:t,nextResultSize:s})),n,a,r):{messages:[],isContinuousMessages:!1}}))}_checkHugeGap(){var e,t,s,n,i;return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r,cacheContext:o,statManager:l,logger:h}=d.Vault.of(this._iid);if(this._messages.length>0){const s=this._syncRange.top,n=this.viewTop,i=this._syncRange.bottom,c=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,n,s),_=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,i,c);try{yield d.asyncRetry((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t=new De(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:s,prevCount:u,nextStart:i,nextEnd:c,nextCount:_,checkingContinuousMessages:o.localCacheEnabled},this.filter),He)),l=yield r.send(t),{isHugeGap:h,prevMessages:p=[],prevHasMore:m,isContinuousPrevMessages:g,nextMessages:C=[],nextHasmore:E,isContinuousNextMessages:v}=l.as(ke);if(h)d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected()}))));else{const t=this.viewTop,s=this.viewBottom,n=Math.min(Number.MAX_SAFE_INTEGER,t,...p.map((e=>e.createdAt))),i=Math.max(0,s,...C.map((e=>e.createdAt)));a.dispatch(new d.MessageUpdateEventCommand({messages:p,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),a.dispatch(new d.MessageUpdateEventCommand({messages:C,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(n,i),(g||v)&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(n,i)),m&&this._prevFill.start(n),E&&this._nextFill.start(i)}}))),1)}catch(e){h.debug("Failed HugeGap Check ",e)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}else{const e=Date.now();try{const{messages:t,isContinuousMessages:n,hasNext:i}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:o.localCacheEnabled});if(t.length>0){const a=t.map((e=>e.createdAt));let r=0,o=0;for(let t=0;t=e&&o++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=i?i:o>=this._nextResultLimit,this._syncRange.extends(...a),n&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(t,d.CollectionEventSource.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)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(n=o.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==i?i:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}}))}_loadUnsentMessages(){return d.__awaiter(this,void 0,void 0,(function*(){this._unsentMessages=yield this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)}))}_hasPollMessage(){return d.__awaiter(this,void 0,void 0,(function*(){return(yield this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)).length>0}))}_refreshChannel(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:s}=d.Vault.of(this._iid);try{yield this._channelManager.refreshChannel(this.channel.url,!0,e,t)}catch(e){s.warn("Failed to refresh channel",e)}}))}_startCheckMyMutedTimer(e){this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((()=>d.__awaiter(this,void 0,void 0,(function*(){this._checkMyMutedStateTimer=void 0;let e=!0;try{e=!(yield this._channel.getMyMutedInfo()).isMuted}catch(t){e=!0}finally{if(e){const{sessionManager:e}=d.Vault.of(this._iid);this.channel._runIfHandleableWithGroupChannel((t=>{var s,n;t.myMutedState=d.MutedState.UNMUTED;const i={source:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:e.currentUser};null===(n=null===(s=this._handler)||void 0===s?void 0:s.onChannelUpdated)||void 0===n||n.call(s,i,this.channel)}))}}}))),e+1e3)}_clearCheckMyMutedTimer(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}_setHasNextAndHasPrevious(e,t){const s=e.map((e=>e.createdAt));let n=0,i=0;for(let e=0;ethis._startingPoint&&i++}this._hasPrevious=n>=this._prevResultLimit,this._hasNext=null!=t?t:i>=this._nextResultLimit}initialize(e){const t=new Ve;this._messages=[],this._unsentMessages=[],this._syncRange=new Se({}),this._hasNext=!0,this._hasPrevious=!0;let s=[],n={messages:[],prevMessagesCount:0,nextMessagesCount:0};return d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var i;const a=yield null===(i=this._backgroundSync)||void 0===i?void 0:i.loadMetadata(),{cacheContext:r,statManager:o}=d.Vault.of(this._iid);if(e===exports.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((e=>d.__awaiter(this,void 0,void 0,(function*(){n=e,s=this._filterUnderOffsetMessage(n.messages),this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE),yield this._loadUnsentMessages(),t._invokeResponse("local",null,s)})))).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("local",e,null)})).finally((()=>d.__awaiter(this,void 0,void 0,(function*(){var i,r;const{cacheContext:l}=d.Vault.of(this._iid);let h=!0,c=!0,u=!1;l.localCacheEnabled&&s.length>0&&a.range.includes(...s.map((e=>e.createdAt)))&&(!a.previousComplete&&n.prevMessagesCounta.range.bottom||n.nextMessagesCount{const t=Math.max(...s.map((e=>e.createdAt)));e._latestMessageInfo&&t>=e._latestMessageInfo.createdAt&&(c=!1)})),c?(h=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled}).then((({messages:e,isContinuousMessages:s,hasNext:n})=>{var i,a;const r=this._filterUnderOffsetMessage(e);this._messages=[],r.length>0?(this._setHasNextAndHasPrevious(r,n),this._syncRange.extends(...r.map((e=>e.createdAt))),s&&(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(r,d.CollectionEventSource.REQUEST_MESSAGE)):(this._hasPrevious=!1,this._hasNext=!1),t._invokeResponse("remote",null,r)})).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(s),t._invokeResponse("remote",null,s)),l.localCacheEnabled&&o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:h?"cache_hit":"cache_miss",max_db_size:null!==(r=null===(i=l.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==r?r:0,message_init_policy:e,use_local_cache:l.localCacheEnabled,collection_id:this._key}}))}))));o.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}}))})))),t}loadPrevious(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasPrevious)return[];if(this._isLoadingPrevious)return a.warn("Messages are already fetching."),[];this._isLoadingPrevious=!0;const r=this.viewTop;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{prevLimit:this._prevResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._prevResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasPrevious=o.length>=this._prevResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a;const{cacheContext:l}=d.Vault.of(this._iid),h=yield this._getRemoteMessages(r,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:l.localCacheEnabled});o=this._filterUnderOffsetMessage(h.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasPrevious=o.length>=this._prevResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(n=l.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==a?a:0,use_local_cache:l.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingPrevious=!1,o}))}loadNext(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasNext)return[];if(this._isLoadingNext)return a.warn("Messages are already fetching."),[];this._isLoadingNext=!0;const r=this.viewBottom;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{nextLimit:this._nextResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._nextResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasNext=o.length>=this._nextResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a,l;const{cacheContext:h}=d.Vault.of(this._iid),c=yield this._getRemoteMessages(r,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled});o=this._filterUnderOffsetMessage(c.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&c.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.bottom))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasNext=null!==(n=c.hasNext)&&void 0!==n?n:o.length>=this._nextResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(l=null===(a=h.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==l?l:0,use_local_cache:h.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingNext=!1,o}))}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."});yield this._channelManager.removeFailedMessageFromCache(e);const t=this._unsentMessages.findIndex((t=>t.reqId===e));t>-1&&this._unsentMessages.splice(t,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._runIfHandleableWithGroupChannel((e=>{e.myMemberState!==exports.MemberState.NONE&&(this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}class qe extends Ge{keyOf(e){return e.messageId}constructor(e,t){super(e,Object.assign(Object.assign({},t),{channelManager:be.of(e)}))}initialize(e){return 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)})))),super.initialize(e)}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_activate(){const e=Object.create(null,{_activate:{get:()=>super._activate}});return d.__awaiter(this,void 0,void 0,(function*(){yield e._activate.call(this),yield 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)}))))}))}_addMessagesToView(e,t){const s=this._filterUnderOffsetMessage(e),n=[],i=[];for(const e of s)if(t===d.CollectionEventSource.SYNC_MESSAGE_FILL){if(e.messageId>0){if(Ne(this._messages,e)<0){Ne(this._unsentMessages,e)<0&&n.push(e);const t=Ue(this._messages,e);this._messages.splice(t,0,e)}}else if(e instanceof h.SendableMessage){Ne(this._unsentMessages,e)<0&&Ne(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e))}}else if(e.messageId>0){const t=Ne(this._messages,e);if(t<0){const t=Ne(this._unsentMessages,e);t<0?n.push(e):(this._unsentMessages.splice(t,1),i.push(e));const s=Ue(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 h.SendableMessage){const t=Ne(this._unsentMessages,e);t<0?Ne(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,a,r;const o={source:t};n.length>0&&(null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===s||s.call(e,o,this.channel,n)),i.length>0&&(null===(r=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===r||r.call(a,o,this.channel,i))}))))}_updateMessagesToView(e,t){const s=[],n=[],i=[];for(const t of e)if(t.messageId>0){const e=Ne(this._messages,t);if(e>=0)n.push(t),this._messages[e]=t;else{const e=Ne(this._unsentMessages,t);if(e>=0){const[s]=this._unsentMessages.splice(e,1);if(this.hasNext&&s)i.push(s);else{n.push(t);const e=Ue(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 h.SendableMessage){const e=Ne(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,r,o;const l={source:t};n.length>0?null===(a=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===a||a.call(e,l,this.channel,n):i.length>0?null===(o=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===o||o.call(r,l,this.channel,[],i):s.length>0&&this._addMessagesToView(s,t)})))),n}}const Be={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 je 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 ze 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 p(e,t))))}}var We,$e,Ke;exports.MutedMemberFilter=void 0,(We=exports.MutedMemberFilter||(exports.MutedMemberFilter={})).ALL="all",We.MUTED="muted",We.UNMUTED="unmuted",exports.MemberListOrder=void 0,($e=exports.MemberListOrder||(exports.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",$e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",exports.MemberStateFilter=void 0,(Ke=exports.MemberStateFilter||(exports.MemberStateFilter={})).ALL="all",Ke.JOINED="joined_only",Ke.INVITED="invited_only",Ke.INVITED_BY_FRIEND="invited_by_friend",Ke.INVITED_BY_NON_FRIEND="invited_by_non_friend";class Qe 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 je(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{members:n,token:i}=s.as(ze);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class Ye 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 Je extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t),this.channel.myMemberState=exports.MemberState.JOINED}}class Xe 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:c,operatorUserIds:u,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:c,cover_url:a,cover_file:r,access_code:o,operator_ids:u,message_survival_seconds:_})}}class Ze extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class et 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 tt 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 st 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 nt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.countPreference=t.count_preference}}class it extends d.APIRequestCommand{constructor(e){const{channelUrl:t,locale:s}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/reset_user_history`,this.params=d.deundefined({locale:s})}}class at extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}const rt=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}),ot=Object.assign(Object.assign({},h.UserMessageUpdateParamsDefault),{scheduledAt:void 0});class lt extends d.APIRequestCommand{constructor(e){var t,s;super();let n=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((e=>e.userId))));const{channelType:i,channelUrl:a,scheduledMessageId:r}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(i)}/${encodeURIComponent(a)}/scheduled_messages/${encodeURIComponent(r)}`,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:null===(t=e._thumbnails)||void 0===t?void 0:t.map((e=>h.Thumbnail.payloadify(e))),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:n,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}))}}class dt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.message=new h.FileMessage(e,t)}}class ht 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=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class ct 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 ut 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 _t 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 pt 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({userId:e,channelUrl:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`}}class gt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}var Ct,Et;exports.CountPreference=void 0,(Ct=exports.CountPreference||(exports.CountPreference={})).ALL="all",Ct.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Ct.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Ct.OFF="off",exports.HiddenState=void 0,(Et=exports.HiddenState||(exports.HiddenState={})).UNHIDDEN="unhidden",Et.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Et.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";class vt extends h.BaseChannel{constructor(e,t){var s,n,i,a,r,o,l,c,u,_,m,g,C,E,v,f,M,y,S;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._hasBotInfo={general:!1,ai:!1},this.isDistinct=!1,this.isSuper=!1,this.isBroadcast=!1,this.isExclusive=!1,this.isPublic=!1,this.isDiscoverable=!0,this.isChatNotification=!1,this.isAccessCodeRequired=!1,this.isPushEnabled=!1,this.unreadMessageCount=0,this.unreadMentionCount=0,this.totalUnreadReplyCount=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=d.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.lastPinnedMessage=null,this._latestMessageInfo=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.isChatNotification=null!==(l=t.is_chat_notification)&&void 0!==l&&l,this.isAccessCodeRequired=null!==(c=t.is_access_code_required)&&void 0!==c&&c,this.isPushEnabled=null!==(u=t.is_push_enabled)&&void 0!==u&&u,Array.isArray(t.members)&&this.members.push(...t.members.map((e=>new p(this._iid,e)))),this.memberCount=null!==(_=t.member_count)&&void 0!==_?_:0,this.joinedMemberCount=null!==(m=t.joined_member_count)&&void 0!==m?m:0,this.hiddenState=d.isEnumOf(exports.HiddenState,t.hidden_state)?t.hidden_state:exports.HiddenState.UNHIDDEN,this.messageOffsetTimestamp=null!==(g=t.ts_message_offset)&&void 0!==g?g:0,this.messageSurvivalSeconds=null!==(C=t.message_survival_seconds)&&void 0!==C?C:-1,this.lastMessage=t.last_message?h.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(d.MutedState,t.is_muted)?this.myMutedState=t.is_muted:d.isTypeOf("boolean",t.is_muted)?this.myMutedState=t.is_muted?d.MutedState.MUTED:d.MutedState.UNMUTED:this.myMutedState=d.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!==(E=t.user_last_read)&&void 0!==E?E: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!==(f=t.joined_ts)&&void 0!==f?f:0,this._updateUnreadCount(null!==(M=t.unread_message_count)&&void 0!==M?M:0,null!==(y=t.unread_mention_count)&&void 0!==y?y:0),this.totalUnreadReplyCount=null!==(S=t.total_unread_thread_message_count)&&void 0!==S?S:0,this.lastPinnedMessage=t.latest_pinned_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.latest_pinned_message)):null,t.latest_message&&(this._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),this._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot}}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}get hasBot(){return this._hasBotInfo.general}get hasAiBot(){return this._hasBotInfo.ai}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,total_unread_thread_message_count:e.totalUnreadReplyCount,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=>p.payloadify(e))),last_message:e.lastMessage?h.payloadifyMessage(e.lastMessage):null,inviter:e.inviter?d.User.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?h.payloadifyMessage(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))}_shouldUpdateLastMessageWith(e){if(e.silent)return!1;const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.lastMessageThreadingPolicy){case d.LastMessageThreadingPolicy.NONE:case d.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case d.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt{t.onChannelChanged&&t.onChannelChanged(e)})),s.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}}))}_shouldUpdateUnreadCountWith(e){const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.unreadCountThreadingPolicy){case d.UnreadCountThreadingPolicy.NONE:case d.UnreadCountThreadingPolicy.INCLUDE_REPLY:break;case d.UnreadCountThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}_updateLastMessage(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}_updateUnreadCount(e,t){if("number"==typeof e&&e>=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,Object.assign(e,this._serializeCachedMetaData())}))}createMessageCollection(e={}){return new qe(this._iid,Object.assign(Object.assign({},e),{channel:this}))}createMemberListQuery(e={}){return new Qe(this._iid,this.url,e)}createThreadedParentMessageListQuery(e={}){return new _.ThreadedParentMessageListQuery(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 p?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 h.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 h.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 h.ReadStatus(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.payloadify(n),ts:null!=e?e:0})}})),s}getDeliveryStatus(e=!0){const{sdkState:t}=d.Vault.of(this._iid);if(!t.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;const s={};return this.members.forEach((n=>{if(e||n.userId!==t.userId){const e=this._undeliveredMemberStateMap.get(n.userId);s[n.userId]=new m(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.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*(){return this._refresh()}))}_refresh(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t,dispatcher:s}=d.Vault.of(this._iid),n=new F({channelUrl:this.url}),i=yield t.send(n),{channel:a}=i.as(D);return this._update(a),e||s.dispatch(new P({channels:[a],context:{source:d.CollectionEventSource.REFRESH_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 P({channels:[this],context:{source:d.CollectionEventSource.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 P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}))}))}updateChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},Be),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 Xe(Object.assign({channelUrl:this.url},t)),a=yield n.send(i),{channel:r}=a.as(Ze);return this._update(r),s.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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,sessionManager:n}=d.Vault.of(this._iid),i=new re({channelUrl:this.url,userIds:e}),a=yield s.send(i),{channel:r}=a.as(oe);return this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:n.currentUser,invitees:[]},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 te({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(se);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},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 ie({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 Ye({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(Je);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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 de({channelUrl:this.url,userId:e.userId});return yield t.send(s),this.myMemberState=exports.MemberState.NONE,this}))}sendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=>{n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendMultipleFilesMessage(e){const t=new h.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=be.of(this._iid);this._updateLastMessage(e),n.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 h.SendableMessage){const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new d.UnsentMessageRemoveEventCommand({reqId:e.reqId,source:d.CollectionEventSource.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 ue(Object.assign({channelUrl:this.url,userId:n.userId},t)),r=yield i.send(a),{messageOffsetTimestamp:o}=r.as(_e);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 P({channels:[this],context:{source:d.CollectionEventSource.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 tt({channelUrl:this.url});return yield t.send(s),this.hiddenState=exports.HiddenState.UNHIDDEN,e.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 et({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 h.ReadRequestCommand({channelUrl:this.url}),i=yield s.send(n),{readStatus:a}=i.as(h.ReadEventCommand);if(this._updateUnreadMemberState(e.userId,a.readAt),this.unreadMessageCount>0||this.unreadMentionCount>0){this._updateUnreadCount(0,0);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 Me({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 me({channelUrl:this.url,time:this._typingStarted});yield 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 Ce({channelUrl:this.url,time:this._typingStarted});yield e.send(t)}}))}createScheduledUserMessage(e){e=Object.assign(Object.assign({},h.ScheduledUserMessageCreateParamsDefault),e),d.unless(h.validateScheduledUserMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=new h.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({},ot),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 ht(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({},h.ScheduledFileMessageCreateParamsDefault),e),d.unless(h.validateScheduledFileMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=Date.now(),s=this._generateRequestId(),n=new h.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({},rt),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 lt(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(dt);return r}))}cancelScheduledMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new ct({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 ut({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 mt({userId:e.userId,channelUrl:this.url}),n=yield t.send(s),{pushTriggerOption:i}=n.as(gt);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 _t({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),a=yield n.send(i),{pushTriggerOption:r}=a.as(pt);return this.myPushTriggerOption=r,t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 st({channelUrl:this.url,userId:s.userId,countPreference:e}),a=yield n.send(i),{countPreference:r}=a.as(nt);return this.myCountPreference=r,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),r}))}resetMyHistory(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t,sdkState:s}=d.Vault.of(this._iid),n=new it({channelUrl:this.url,locale:s.localeForChatbot}),i=yield t.send(n),{messageOffsetTimestamp:a}=i.as(at);return this.messageOffsetTimestamp=a,this.lastMessage&&this.lastMessage.createdAt{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),n._trigger(e)})),n}if(e.isFileMessage()){const s=this._validateFailedFileMessageHasFile(e,t);d.unless(s).throw(d.SendbirdError.invalidParameters);const n=h.createFileMessageCreateParamsFromFailedFileMessage(e,t),i=new h.MessageRequestHandler;return this._sendFileMessage(n,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{i._trigger(e)})).onFailed(((e,t)=>{i._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),i._trigger(e)})),i}if(e.isMultipleFilesMessage()){const t=e.messageParams,s=new h.MultipleFilesMessageRequestHandler;return this._sendMultipleFilesMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{s._trigger(e)})).onFailed(((e,t)=>{s._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),s._trigger(e)})).onFileUploaded(((e,t,n,i)=>{s._triggerOnFileUploaded(e,t,n,i)})),s}}copyMessage(e,t){if(d.unless(e instanceof h.BaseChannel&&t instanceof h.SendableMessage&&t.sendingStatus===d.SendingStatus.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(d.SendbirdError.invalidParameters),t.isUserMessage()){d.unless(!t.poll).throw(d.SendbirdError.notSupportedError);const s=h.createUserMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendUserMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isFileMessage()){const s=h.createFileMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendFileMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isMultipleFilesMessage()){if(e.isGroupChannel()){const s=h.createMultipleFilesMessageCreateParams(t),n=new h.MultipleFilesMessageRequestHandler;return e._sendMultipleFilesMessage(s,h.SendMessageRequestType.COPY).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})).onFileUploaded(((e,t,s,i)=>{n._triggerOnFileUploaded(e,t,s,i)})),n}throw d.SendbirdError.channelTypeNotSupportedError}}}exports.BaseMessageCollection=Ge,exports.DeliveryStatus=m,exports.GetTotalUnreadMessageCountRequestCommand=$,exports.GetTotalUnreadMessageCountResponseCommand=K,exports.GroupChannel=vt,exports.GroupChannelChangeLogsParamsDefault=f,exports.GroupChannelCountParamsDefault=y,exports.GroupChannelCreateParamsDefault=E,exports.GroupChannelEventSource=I,exports.GroupChannelFilter=g,exports.GroupChannelListQuery=fe,exports.GroupChannelManager=be,exports.Member=p,exports.MemberListQuery=Qe,exports.MessageCollection=qe,exports.MessageCollectionInitHandler=Ve,exports.Sync=xe,exports.TimeRange=Se,exports.TotalUnreadMessageCountParamsDefault=N,exports.indexOfMessage=Ne,exports.placeOfMessage=Ue,exports.shouldGiveEvent=x,exports.validateGroupChannelChangeLogsParams=M,exports.validateGroupChannelCountParams=S,exports.validateGroupChannelCreateParams=v,exports.validateTotalUnreadMessageCountParams=T; diff --git a/cjs/lib/__definition.d.cts b/cjs/lib/__definition.d.cts index d31cb4e..812edef 100644 --- a/cjs/lib/__definition.d.cts +++ b/cjs/lib/__definition.d.cts @@ -6,8 +6,6 @@ import type { MMKV } from 'react-native-mmkv'; * @description Object representing an admin message. */ export declare class AdminMessage extends BaseMessage { - /** The message text of the message. */ - message: string; /** The translated messages (key-value map) for the language codes in key. */ translations: object; /** @@ -839,6 +837,8 @@ export declare class BaseMessage extends MessagePrototype { myFeedbackStatus: FeedbackStatus; /** The form of the message. */ messageForm: MessageForm | null; + /** The message text of the message. */ + message: string; isIdentical(message: BaseMessage): boolean; /** * @param threadInfoUpdateEvent @@ -1558,6 +1558,8 @@ export declare interface FileMessageCreateParams extends BaseMessageCreateParams mimeType?: string; /** The file's thumbnail sizes of the message. */ thumbnailSizes?: ThumbnailSize[]; + /** The message text of the message. */ + message?: string; } /** @@ -2816,6 +2818,7 @@ export declare class MultipleFilesMessage extends SendableMessage { export declare interface MultipleFilesMessageCreateParams extends BaseMessageCreateParams { /** The list of uploadable file information. */ fileInfoList: UploadableFileInfo[]; + message?: string; } /** @@ -4523,6 +4526,7 @@ export declare enum SendbirdErrorCode { COLLECTION_DISPOSED = 800600, DATABASE_ERROR = 800700, USER_DEACTIVATED = 900021, + CHANNEL_IS_FROZEN = 900050, RECEIVER_USER_DEACTIVATED = 900081, } @@ -4885,8 +4889,6 @@ declare abstract class UserEventHandlerParams { * @description Object representing a user message. */ export declare class UserMessage extends SendableMessage { - /** The message text of the message. */ - message: string; /** The messageParams object that used for sending this message For more details. */ messageParams: UserMessageCreateParams | null; /** The translated messages (key-value map) for the language codes in key. */ diff --git a/cjs/message.cjs b/cjs/message.cjs index 8288f26..335eea3 100644 --- a/cjs/message.cjs +++ b/cjs/message.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),s=require("./lib/__bundle-165fd6e1.cjs"),t=require("./lib/__bundle-bfe2e997.cjs");const r={channelUrl:"",scheduledMessageId:0},a={reverse:!1,limit:20};class n extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}){super.init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}),this._manager=new s.MessageManager(e,{sdkState:t,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:u})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s.MessageRetrievalParamsDefault),t);e.unless(s.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters);const a=yield this._manager.getMessage(r);if(a instanceof s.BaseMessage||a instanceof s.NotificationMessage||null===a)return a;throw"Unknown message type is given."}))}getScheduledMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),s);return e.unless((s=>e.isTypeOf("string",s.channelUrl)&&""!==s.channelUrl&&e.isTypeOf("number",s.scheduledMessageId)&&s.scheduledMessageId>0)(t)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(t)}))}getMessageTemplatesByToken(s,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},a),t);return e.unless(e.isTypeOf("string",s,!0)&&(s=>e.isTypeOf("boolean",s.reverse,!0)&&e.isTypeOf("number",s.limit,!0)&&e.isArrayOf("string",s.keys,!0))(r)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplatesByToken(s,r)}))}getMessageTemplate(s){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",s)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplate(s)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageReviewStatus",{enumerable:!0,get:function(){return e.MessageReviewStatus}}),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=s.AdminMessage,exports.AppleCriticalAlertOptions=s.AppleCriticalAlertOptions,exports.BaseMessage=s.BaseMessage,exports.Feedback=s.Feedback,Object.defineProperty(exports,"FeedbackRating",{enumerable:!0,get:function(){return s.FeedbackRating}}),exports.FileMessage=s.FileMessage,exports.MessageForm=s.MessageForm,exports.MessageFormItem=s.MessageFormItem,Object.defineProperty(exports,"MessageFormItemLayout",{enumerable:!0,get:function(){return s.MessageFormItemLayout}}),exports.MessageMetaArray=s.MessageMetaArray,exports.MessageRequestHandler=s.MessageRequestHandler,exports.MessageReviewInfo=s.MessageReviewInfo,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return s.MessageSearchOrder}}),exports.MessageSearchQuery=s.MessageSearchQuery,exports.MultipleFilesMessage=s.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=s.MultipleFilesMessageRequestHandler,exports.OGImage=s.OGImage,exports.OGMetaData=s.OGMetaData,exports.PreviousMessageListQuery=s.PreviousMessageListQuery,exports.Reaction=s.Reaction,exports.ReactionEvent=s.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return s.ReactionEventOperation}}),exports.Sender=s.Sender,exports.ThreadInfo=s.ThreadInfo,exports.ThreadInfoUpdateEvent=s.ThreadInfoUpdateEvent,exports.Thumbnail=s.Thumbnail,exports.UploadedFileInfo=s.UploadedFileInfo,exports.UserMessage=s.UserMessage,exports.ThreadedParentMessageListQuery=t.ThreadedParentMessageListQuery,exports.MessageModule=n; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),s=require("./lib/__bundle-4bcf4070.cjs"),t=require("./lib/__bundle-d349e14c.cjs");const r={channelUrl:"",scheduledMessageId:0},a={reverse:!1,limit:20};class n extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}){super.init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}),this._manager=new s.MessageManager(e,{sdkState:t,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:u})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s.MessageRetrievalParamsDefault),t);e.unless(s.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters);const a=yield this._manager.getMessage(r);if(a instanceof s.BaseMessage||a instanceof s.NotificationMessage||null===a)return a;throw"Unknown message type is given."}))}getScheduledMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),s);return e.unless((s=>e.isTypeOf("string",s.channelUrl)&&""!==s.channelUrl&&e.isTypeOf("number",s.scheduledMessageId)&&s.scheduledMessageId>0)(t)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(t)}))}getMessageTemplatesByToken(s,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},a),t);return e.unless(e.isTypeOf("string",s,!0)&&(s=>e.isTypeOf("boolean",s.reverse,!0)&&e.isTypeOf("number",s.limit,!0)&&e.isArrayOf("string",s.keys,!0))(r)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplatesByToken(s,r)}))}getMessageTemplate(s){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",s)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplate(s)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageReviewStatus",{enumerable:!0,get:function(){return e.MessageReviewStatus}}),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=s.AdminMessage,exports.AppleCriticalAlertOptions=s.AppleCriticalAlertOptions,exports.BaseMessage=s.BaseMessage,exports.Feedback=s.Feedback,Object.defineProperty(exports,"FeedbackRating",{enumerable:!0,get:function(){return s.FeedbackRating}}),exports.FileMessage=s.FileMessage,exports.MessageForm=s.MessageForm,exports.MessageFormItem=s.MessageFormItem,Object.defineProperty(exports,"MessageFormItemLayout",{enumerable:!0,get:function(){return s.MessageFormItemLayout}}),exports.MessageMetaArray=s.MessageMetaArray,exports.MessageRequestHandler=s.MessageRequestHandler,exports.MessageReviewInfo=s.MessageReviewInfo,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return s.MessageSearchOrder}}),exports.MessageSearchQuery=s.MessageSearchQuery,exports.MultipleFilesMessage=s.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=s.MultipleFilesMessageRequestHandler,exports.OGImage=s.OGImage,exports.OGMetaData=s.OGMetaData,exports.PreviousMessageListQuery=s.PreviousMessageListQuery,exports.Reaction=s.Reaction,exports.ReactionEvent=s.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return s.ReactionEventOperation}}),exports.Sender=s.Sender,exports.ThreadInfo=s.ThreadInfo,exports.ThreadInfoUpdateEvent=s.ThreadInfoUpdateEvent,exports.Thumbnail=s.Thumbnail,exports.UploadedFileInfo=s.UploadedFileInfo,exports.UserMessage=s.UserMessage,exports.ThreadedParentMessageListQuery=t.ThreadedParentMessageListQuery,exports.MessageModule=n; diff --git a/cjs/node.cjs b/cjs/node.cjs index 43f9f02..8b0b97f 100644 --- a/cjs/node.cjs +++ b/cjs/node.cjs @@ -1 +1 @@ -var e=require("./lib/__bundle-a03c4073.cjs");require("./lib/__bundle-38c66c0d.cjs");var t=require("events"),s=require("https"),r=require("http"),i=require("net"),o=require("tls"),n=require("crypto"),a=require("stream"),c=require("url"),h=require("zlib"),l=require("fs"),d=require("path"),f=require("os"),u=require("buffer");function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=_(t),m=_(s),v=_(r),y=_(i),b=_(o),g=_(n),S=_(a),E=_(c),w=_(h),k=_(l),x=_(d),C=_(f),T=_(u),O={exports:{}};const N=["nodebuffer","arraybuffer","fragments"],L="undefined"!=typeof Blob;L&&N.push("blob");var P={BINARY_TYPES:N,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:L,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}};e.getDefaultExportFromCjs(P);var B={exports:{}};function R(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var U,I,D,W,F,M,j={exports:{}};function A(){if(D)return j.exports;D=1;const e="function"==typeof __webpack_require__?__non_webpack_require__:R;return"function"==typeof e.addon?j.exports=e.addon.bind(e):j.exports=function(){if(I)return U;I=1;var e=k.default,t=x.default,s=C.default,r="function"==typeof __webpack_require__?__non_webpack_require__:R,i=process.config&&process.config.variables||{},o=!!process.env.PREBUILDS_ONLY,n=process.versions.modules,a=process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":process.versions&&process.versions.nw?"node-webkit":"node",c=process.env.npm_config_arch||s.arch(),h=process.env.npm_config_platform||s.platform(),l=process.env.LIBC||(function(t){return"linux"===t&&e.existsSync("/etc/alpine-release")}(h)?"musl":"glibc"),d=process.env.ARM_VERSION||("arm64"===c?"8":i.arm_version)||"",f=(process.versions.uv||"").split(".")[0];function u(e){return r(u.resolve(e))}function _(t){try{return e.readdirSync(t)}catch(e){return[]}}function p(e,s){var r=_(e).filter(s);return r[0]&&t.join(e,r[0])}function m(e){return/\.node$/.test(e)}function v(e){var t=e.split("-");if(2===t.length){var s=t[0],r=t[1].split("+");if(s&&r.length&&r.every(Boolean))return{name:e,platform:s,architectures:r}}}function y(e,t){return function(s){return null!=s&&s.platform===e&&s.architectures.includes(t)}}function b(e,t){return e.architectures.length-t.architectures.length}function g(e){var t=e.split("."),s={file:e,specificity:0};if("node"===t.pop()){for(var r=0;rs.specificity?-1:1:0}}return U=u,u.resolve=u.path=function(e){e=t.resolve(e||".");try{var s=r(t.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[s+"_PREBUILD"]&&(e=process.env[s+"_PREBUILD"])}catch(e){}if(!o){var i=p(t.join(e,"build/Release"),m);if(i)return i;var u=p(t.join(e,"build/Debug"),m);if(u)return u}var w=C(e);if(w)return w;var k=C(t.dirname(process.execPath));if(k)return k;var x=["platform="+h,"arch="+c,"runtime="+a,"abi="+n,"uv="+f,d?"armv="+d:"","libc="+l,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"","function"==typeof __webpack_require__?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+x+"\n loaded from: "+e+"\n");function C(e){var s=_(t.join(e,"prebuilds")).map(v).filter(y(h,c)).sort(b)[0];if(s){var r=t.join(e,"prebuilds",s.name),i=_(r).map(g).filter(S(a,n)).sort(E(a))[0];return i?t.join(r,i.file):void 0}}},u.parseTags=g,u.matchTags=S,u.compareTags=E,u.parseTuple=v,u.matchTuple=y,u.compareTuples=b,U}(),j.exports}const{EMPTY_BUFFER:q}=P,$=Buffer[Symbol.species];function G(e,t,s,r,i){for(let o=0;o{for(var o=0;o{const s=e.length;for(var r=0;r{this.pending--,this[Y]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Y]()}[Y](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[H])}}};e.getDefaultExportFromCjs(X);const K=w.default,Z=z,J=X,{kStatusCode:Q}=P,ee=Buffer[Symbol.species],te=Buffer.from([0,0,255,255]),se=Symbol("permessage-deflate"),re=Symbol("total-length"),ie=Symbol("callback"),oe=Symbol("buffers"),ne=Symbol("error");let ae;var ce=class{constructor(e,t,s){if(this._maxPayload=0|s,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!ae){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;ae=new J(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[ie];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,s=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(s.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?s.client_max_window_bits=t.clientMaxWindowBits:!0!==s.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete s.client_max_window_bits,s}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let s=e[t];if(s.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(s=s[0],"client_max_window_bits"===t){if(!0!==s){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}else if("server_max_window_bits"===t){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==s)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}e[t]=s}))})),e}decompress(e,t,s){ae.add((r=>{this._decompress(e,t,((e,t)=>{r(),s(e,t)}))}))}compress(e,t,s){ae.add((r=>{this._compress(e,t,((e,t)=>{r(),s(e,t)}))}))}_decompress(e,t,s){const r=this._isServer?"client":"server";if(!this._inflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?K.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=K.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[se]=this,this._inflate[re]=0,this._inflate[oe]=[],this._inflate.on("error",de),this._inflate.on("data",le)}this._inflate[ie]=s,this._inflate.write(e),t&&this._inflate.write(te),this._inflate.flush((()=>{const e=this._inflate[ne];if(e)return this._inflate.close(),this._inflate=null,void s(e);const i=Z.concat(this._inflate[oe],this._inflate[re]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[re]=0,this._inflate[oe]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),s(null,i)}))}_compress(e,t,s){const r=this._isServer?"server":"client";if(!this._deflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?K.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=K.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[re]=0,this._deflate[oe]=[],this._deflate.on("data",he)}this._deflate[ie]=s,this._deflate.write(e),this._deflate.flush(K.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=Z.concat(this._deflate[oe],this._deflate[re]);t&&(e=new ee(e.buffer,e.byteOffset,e.length-4)),this._deflate[ie]=null,this._deflate[re]=0,this._deflate[oe]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),s(null,e)}))}};function he(e){this[oe].push(e),this[re]+=e.length}function le(e){this[re]+=e.length,this[se]._maxPayload<1||this[re]<=this[se]._maxPayload?this[oe].push(e):(this[ne]=new RangeError("Max payload size exceeded"),this[ne].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ne][Q]=1009,this.removeListener("data",le),this.reset())}function de(e){this[se]._inflate=null,e[Q]=1007,this[ie](e)}e.getDefaultExportFromCjs(ce);var fe={exports:{}};const{isUtf8:ue}=T.default,{hasBlob:_e}=P;function pe(e){const t=e.length;let s=0;for(;s=t||128!=(192&e[s+1])||128!=(192&e[s+2])||224===e[s]&&128==(224&e[s+1])||237===e[s]&&160==(224&e[s+1]))return!1;s+=3}else{if(240!=(248&e[s]))return!1;if(s+3>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||128!=(192&e[s+3])||240===e[s]&&128==(240&e[s+1])||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}else s++;return!0}if(fe.exports={isBlob:function(e){return _e&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&("Blob"===e[Symbol.toStringTag]||"File"===e[Symbol.toStringTag])},isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:pe,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},ue)fe.exports.isValidUTF8=function(e){return e.length<24?pe(e):ue(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const e=require("utf-8-validate");fe.exports.isValidUTF8=function(t){return t.length<32?pe(t):e(t)}}catch(e){}var me=fe.exports;e.getDefaultExportFromCjs(me);const{Writable:ve}=S.default,ye=ce,{BINARY_TYPES:be,EMPTY_BUFFER:ge,kStatusCode:Se,kWebSocket:Ee}=P,{concat:we,toArrayBuffer:ke,unmask:xe}=z,{isValidStatusCode:Ce,isValidUTF8:Te}=me,Oe=Buffer[Symbol.species];var Ne=class extends ve{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||be[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Ee]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,s){if(8===this._opcode&&0==this._state)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=new Oe(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(48&t[0]){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const s=!(64&~t[0]);if(!s||this._extensions[ye.extensionName]){if(this._fin=!(128&~t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=s}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~t[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}else{e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),s=t.readUInt32BE(0);if(s>Math.pow(2,21)-1){e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}else this._payloadLength=s*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}else this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=ge;if(this._payloadLength){if(this._bufferedBytes7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[ye.extensionName].decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(s)}this.dataMessage(t),0===this._state&&this.startLoop(t)}))}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let r;r="nodebuffer"===this._binaryType?we(s,t):"arraybuffer"===this._binaryType?ke(we(s,t)):"blob"===this._binaryType?new Blob(s):s,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!0),this._state=0,this.startLoop(e)})))}else{const r=we(s,t);if(!this._skipUTF8Validation&&!Te(r)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!1),this._state=0,this.startLoop(e)})))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate((()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)})));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,ge),this.end();else{const s=e.readUInt16BE(0);if(!Ce(s)){const e=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const r=new Oe(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Te(r)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",s,r),this.end()}this._state=0}}createError(e,t,s,r,i){this._loop=!1,this._errored=!0;const o=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=i,o[Se]=r,o}};e.getDefaultExportFromCjs(Ne);const{randomFillSync:Le}=g.default,Pe=ce,{EMPTY_BUFFER:Be,kWebSocket:Re,NOOP:Ue}=P,{isBlob:Ie,isValidStatusCode:De}=me,{mask:We,toBuffer:Fe}=z,Me=Symbol("kByteLength"),je=Buffer.alloc(4),Ae=8192;let qe,$e=Ae;class Ge{constructor(e,t,s){this._extensions=t||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=Ue,this[Re]=void 0}static frame(e,t){let s,r,i=!1,o=2,n=!1;t.mask&&(s=t.maskBuffer||je,t.generateMask?t.generateMask(s):($e===Ae&&(void 0===qe&&(qe=Buffer.alloc(Ae)),Le(qe,0,Ae),$e=0),s[0]=qe[$e++],s[1]=qe[$e++],s[2]=qe[$e++],s[3]=qe[$e++]),n=!(s[0]|s[1]|s[2]|s[3]),o=6),"string"==typeof e?r=t.mask&&!n||void 0===t[Me]?(e=Buffer.from(e)).length:t[Me]:(r=e.length,i=t.mask&&t.readOnly&&!n);let a=r;r>=65536?(o+=8,a=127):r>125&&(o+=2,a=126);const c=Buffer.allocUnsafe(i?r+o:o);return c[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(c[0]|=64),c[1]=a,126===a?c.writeUInt16BE(r,2):127===a&&(c[2]=c[3]=0,c.writeUIntBE(r,4,6)),t.mask?(c[1]|=128,c[o-4]=s[0],c[o-3]=s[1],c[o-2]=s[2],c[o-1]=s[3],n?[c,e]:i?(We(e,s,c,o,r),[c]):(We(e,s,e,0,r),[c,e])):[c,e]}close(e,t,s,r){let i;if(void 0===e)i=Be;else{if("number"!=typeof e||!De(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const s=Buffer.byteLength(t);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+s),i.writeUInt16BE(e,0),"string"==typeof t?i.write(t,2):i.set(t,2)}else i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0)}const o={[Me]:i.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,i,!1,o,r]):this.sendFrame(Ge.frame(i,o),r)}ping(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):Ie(e)?(r=e.size,i=!1):(r=(e=Fe(e)).length,i=Fe.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[Me]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};Ie(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(Ge.frame(e,o),s)}pong(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):Ie(e)?(r=e.size,i=!1):(r=(e=Fe(e)).length,i=Fe.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[Me]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};Ie(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(Ge.frame(e,o),s)}send(e,t,s){const r=this._extensions[Pe.extensionName];let i,o,n=t.binary?2:1,a=t.compress;"string"==typeof e?(i=Buffer.byteLength(e),o=!1):Ie(e)?(i=e.size,o=!1):(i=(e=Fe(e)).length,o=Fe.readOnly),this._firstFragment?(this._firstFragment=!1,a&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=i>=r._threshold),this._compress=a):(a=!1,n=0),t.fin&&(this._firstFragment=!0);const c={[Me]:i,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:o,rsv1:a};Ie(e)?0!==this._state?this.enqueue([this.getBlobData,e,this._compress,c,s]):this.getBlobData(e,this._compress,c,s):0!==this._state?this.enqueue([this.dispatch,e,this._compress,c,s]):this.dispatch(e,this._compress,c,s)}getBlobData(e,t,s,r){this._bufferedBytes+=s[Me],this._state=2,e.arrayBuffer().then((e=>{if(this._socket.destroyed){const e=new Error("The socket was closed while the blob was being read");return void process.nextTick(ze,this,e,r)}this._bufferedBytes-=s[Me];const i=Fe(e);t?this.dispatch(i,t,s,r):(this._state=0,this.sendFrame(Ge.frame(i,s),r),this.dequeue())})).catch((e=>{process.nextTick(He,this,e,r)}))}dispatch(e,t,s,r){if(!t)return void this.sendFrame(Ge.frame(e,s),r);const i=this._extensions[Pe.extensionName];this._bufferedBytes+=s[Me],this._state=1,i.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){ze(this,new Error("The socket was closed while data was being compressed"),r)}else this._bufferedBytes-=s[Me],this._state=0,s.readOnly=!1,this.sendFrame(Ge.frame(t,s),r),this.dequeue()}))}dequeue(){for(;0===this._state&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][Me],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Me],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}var Ve=Ge;function ze(e,t,s){"function"==typeof s&&s(t);for(let s=0;s{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let s,r,i=Object.create(null),o=!1,n=!1,a=!1,c=-1,h=-1,l=-1,d=0;for(;d0&&e.unshift(t),e.on("close",cs),e.on("data",hs),e.on("end",ls),e.on("error",ds),this._readyState=Gt.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=Gt.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[Et.extensionName]&&this._extensions[Et.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=Gt.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==Gt.CLOSED)if(this.readyState!==Gt.CONNECTING)this.readyState!==Gt.CLOSING?(this._readyState=Gt.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),as(this)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";Kt(this,this._req,e)}}pause(){this.readyState!==Gt.CONNECTING&&this.readyState!==Gt.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,s){if(this.readyState===Gt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===Gt.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||Tt,t,s)):Zt(this,e,s)}pong(e,t,s){if(this.readyState===Gt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===Gt.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||Tt,t,s)):Zt(this,e,s)}resume(){this.readyState!==Gt.CONNECTING&&this.readyState!==Gt.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,s){if(this.readyState===Gt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(s=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==Gt.OPEN)return void Zt(this,e,s);const r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[Et.extensionName]||(r.compress=!1),this._sender.send(e||Tt,r,s)}terminate(){if(this.readyState!==Gt.CLOSED)if(this.readyState!==Gt.CONNECTING)this._socket&&(this._readyState=Gt.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";Kt(this,this._req,e)}}}Object.defineProperty(Gt,"CONNECTING",{enumerable:!0,value:qt.indexOf("CONNECTING")}),Object.defineProperty(Gt.prototype,"CONNECTING",{enumerable:!0,value:qt.indexOf("CONNECTING")}),Object.defineProperty(Gt,"OPEN",{enumerable:!0,value:qt.indexOf("OPEN")}),Object.defineProperty(Gt.prototype,"OPEN",{enumerable:!0,value:qt.indexOf("OPEN")}),Object.defineProperty(Gt,"CLOSING",{enumerable:!0,value:qt.indexOf("CLOSING")}),Object.defineProperty(Gt.prototype,"CLOSING",{enumerable:!0,value:qt.indexOf("CLOSING")}),Object.defineProperty(Gt,"CLOSED",{enumerable:!0,value:qt.indexOf("CLOSED")}),Object.defineProperty(Gt.prototype,"CLOSED",{enumerable:!0,value:qt.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(Gt.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(Gt.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[Nt])return t[Lt];return null},set(t){for(const t of this.listeners(e))if(t[Nt]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[Nt]:!0})}})})),Gt.prototype.addEventListener=Ut,Gt.prototype.removeEventListener=It;var Vt=Gt;function zt(e,t,s,r){const i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:At[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,!At.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${At.join(", ")})`);let o;if(t instanceof St)o=t;else try{o=new St(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===o.protocol?o.protocol="ws:":"https:"===o.protocol&&(o.protocol="wss:"),e._url=o.href;const n="wss:"===o.protocol,a="ws+unix:"===o.protocol;let c;if("ws:"===o.protocol||n||a?a&&!o.pathname?c="The URL's pathname is empty":o.hash&&(c="The URL contains a fragment identifier"):c='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"',c){const t=new SyntaxError(c);if(0===e._redirects)throw t;return void Ht(e,t)}const h=n?443:80,l=bt(16).toString("base64"),d=n?pt.request:mt.request,f=new Set;let u,_;if(i.createConnection=i.createConnection||(n?Xt:Yt),i.defaultPort=i.defaultPort||h,i.port=o.port||h,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(u=new Et(!0!==i.perMessageDeflate?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=Dt({[Et.extensionName]:u.offer()})),s.length){for(const e of s){if("string"!=typeof e||!$t.test(e)||f.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");f.add(e)}i.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(o.username||o.password)&&(i.auth=`${o.username}:${o.password}`),a){const e=i.path.split(":");i.socketPath=e[0],i.path=e[1]}if(i.followRedirects){if(0===e._redirects){e._originalIpc=a,e._originalSecure=n,e._originalHostOrSocketPath=a?i.socketPath:o.host;const t=r&&r.headers;if(r={...r,headers:{}},t)for(const[e,s]of Object.entries(t))r.headers[e.toLowerCase()]=s}else if(0===e.listenerCount("redirect")){const t=a?!!e._originalIpc&&i.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&o.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!n)&&(delete i.headers.authorization,delete i.headers.cookie,t||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),_=e._req=d(i),e._redirects&&e.emit("redirect",e.url,_)}else _=e._req=d(i);i.timeout&&_.on("timeout",(()=>{Kt(e,_,"Opening handshake has timed out")})),_.on("error",(t=>{null===_||_[jt]||(_=e._req=null,Ht(e,t))})),_.on("response",(o=>{const n=o.headers.location,a=o.statusCode;if(n&&i.followRedirects&&a>=300&&a<400){if(++e._redirects>i.maxRedirects)return void Kt(e,_,"Maximum redirects exceeded");let o;_.abort();try{o=new St(n,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${n}`);return void Ht(e,s)}zt(e,o,s,r)}else e.emit("unexpected-response",_,o)||Kt(e,_,`Unexpected server response: ${o.statusCode}`)})),_.on("upgrade",((t,s,r)=>{if(e.emit("upgrade",t),e.readyState!==Gt.CONNECTING)return;_=e._req=null;const o=t.headers.upgrade;if(void 0===o||"websocket"!==o.toLowerCase())return void Kt(e,s,"Invalid Upgrade header");const n=gt("sha1").update(l+Ot).digest("base64");if(t.headers["sec-websocket-accept"]!==n)return void Kt(e,s,"Invalid Sec-WebSocket-Accept header");const a=t.headers["sec-websocket-protocol"];let c;if(void 0!==a?f.size?f.has(a)||(c="Server sent an invalid subprotocol"):c="Server sent a subprotocol but none was requested":f.size&&(c="Server sent no subprotocol"),c)return void Kt(e,s,c);a&&(e._protocol=a);const h=t.headers["sec-websocket-extensions"];if(void 0!==h){if(!u){return void Kt(e,s,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=Wt(h)}catch(t){return void Kt(e,s,"Invalid Sec-WebSocket-Extensions header")}const r=Object.keys(t);if(1!==r.length||r[0]!==Et.extensionName){return void Kt(e,s,"Server indicated an extension that was not requested")}try{u.accept(t[Et.extensionName])}catch(t){return void Kt(e,s,"Invalid Sec-WebSocket-Extensions header")}e._extensions[Et.extensionName]=u}e.setSocket(s,r,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})})),i.finishRequest?i.finishRequest(_,e):_.end()}function Ht(e,t){e._readyState=Gt.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function Yt(e){return e.path=e.socketPath,vt.connect(e)}function Xt(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=vt.isIP(e.host)?"":e.host),yt.connect(e)}function Kt(e,t,s){e._readyState=Gt.CLOSING;const r=new Error(s);Error.captureStackTrace(r,Kt),t.setHeader?(t[jt]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(Ht,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Zt(e,t,s){if(t){const s=xt(t)?t.size:Ft(t).length;e._socket?e._sender._bufferedBytes+=s:e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${qt[e.readyState]})`);process.nextTick(s,t)}}function Jt(e,t){const s=this[Bt];s._closeFrameReceived=!0,s._closeMessage=t,s._closeCode=e,void 0!==s._socket[Bt]&&(s._socket.removeListener("data",hs),process.nextTick(os,s._socket),1005===e?s.close():s.close(e,t))}function Qt(){const e=this[Bt];e.isPaused||e._socket.resume()}function es(e){const t=this[Bt];void 0!==t._socket[Bt]&&(t._socket.removeListener("data",hs),process.nextTick(os,t._socket),t.close(e[Pt])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function ts(){this[Bt].emitClose()}function ss(e,t){this[Bt].emit("message",e,t)}function rs(e){const t=this[Bt];t._autoPong&&t.pong(e,!this._isServer,Rt),t.emit("ping",e)}function is(e){this[Bt].emit("pong",e)}function os(e){e.resume()}function ns(e){const t=this[Bt];t.readyState!==Gt.CLOSED&&(t.readyState===Gt.OPEN&&(t._readyState=Gt.CLOSING,as(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function as(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),Mt)}function cs(){const e=this[Bt];let t;this.removeListener("close",cs),this.removeListener("data",hs),this.removeListener("end",ls),e._readyState=Gt.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[Bt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",ts),e._receiver.on("finish",ts))}function hs(e){this[Bt]._receiver.write(e)||this.pause()}function ls(){const e=this[Bt];e._readyState=Gt.CLOSING,e._receiver.end(),this.end()}function ds(){const e=this[Bt];this.removeListener("error",ds),this.on("error",Rt),e&&(e._readyState=Gt.CLOSING,this.destroy())}e.getDefaultExportFromCjs(Vt);const{Duplex:fs}=S.default;function us(e){e.emit("close")}function _s(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ps(e){this.removeListener("error",ps),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}var ms=function(e,t){let s=!0;const r=new fs({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,s){const i=!s&&r._readableState.objectMode?t.toString():t;r.push(i)||e.pause()})),e.once("error",(function(e){r.destroyed||(s=!1,r.destroy(e))})),e.once("close",(function(){r.destroyed||r.push(null)})),r._destroy=function(t,i){if(e.readyState===e.CLOSED)return i(t),void process.nextTick(us,r);let o=!1;e.once("error",(function(e){o=!0,i(e)})),e.once("close",(function(){o||i(t),process.nextTick(us,r)})),s&&e.terminate()},r._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){r._final(t)}))},r._read=function(){e.isPaused&&e.resume()},r._write=function(t,s,i){e.readyState!==e.CONNECTING?e.send(t,i):e.once("open",(function(){r._write(t,s,i)}))},r.on("end",_s),r.on("error",ps),r};e.getDefaultExportFromCjs(ms);const{tokenChars:vs}=me;var ys={parse:function(e){const t=new Set;let s=-1,r=-1,i=0;for(;i{const s=gs.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),t.end(s)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function(){for(const s of Object.keys(t))e.removeListener(s,t[s])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(Ls,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(Ls,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{Ls(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,r){t.on("error",Ps);const i=e.headers["sec-websocket-key"],o=e.headers.upgrade,n=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void Rs(this,e,t,405,"Invalid HTTP method")}if(void 0===o||"websocket"!==o.toLowerCase()){return void Rs(this,e,t,400,"Invalid Upgrade header")}if(void 0===i||!Os.test(i)){return void Rs(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==n&&13!==n){return void Rs(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void Bs(t,400);const a=e.headers["sec-websocket-protocol"];let c=new Set;if(void 0!==a)try{c=ks.parse(a)}catch(s){return void Rs(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const h=e.headers["sec-websocket-extensions"],l={};if(this.options.perMessageDeflate&&void 0!==h){const s=new ws(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=Es.parse(h);e[ws.extensionName]&&(s.accept(e[ws.extensionName]),l[ws.extensionName]=s)}catch(s){return void Rs(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const o={origin:e.headers[""+(8===n?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(o,((o,n,a,h)=>{if(!o)return Bs(t,n||401,a,h);this.completeUpgrade(l,i,c,e,t,s,r)}));if(!this.options.verifyClient(o))return Bs(t,401)}this.completeUpgrade(l,i,c,e,t,s,r)}completeUpgrade(e,t,s,r,i,o,n){if(!i.readable||!i.writable)return i.destroy();if(i[Ts])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return Bs(i,503);const a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Ss("sha1").update(t+Cs).digest("base64")}`],c=new this.options.WebSocket(null,void 0,this.options);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;e&&(a.push(`Sec-WebSocket-Protocol: ${e}`),c._protocol=e)}if(e[ws.extensionName]){const t=e[ws.extensionName].params,s=Es.format({[ws.extensionName]:[t]});a.push(`Sec-WebSocket-Extensions: ${s}`),c._extensions=e}this.emit("headers",a,r),i.write(a.concat("\r\n").join("\r\n")),i.removeListener("error",Ps),c.setSocket(i,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(c),c.on("close",(()=>{this.clients.delete(c),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ls,this)}))),n(c,r)}};function Ls(e){e._state=2,e.emit("close")}function Ps(){this.destroy()}function Bs(e,t,s,r){s=s||gs.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${gs.STATUS_CODES[t]}\r\n`+Object.keys(r).map((e=>`${e}: ${r[e]}`)).join("\r\n")+"\r\n\r\n"+s)}function Rs(e,t,s,r,i){if(e.listenerCount("wsClientError")){const r=new Error(i);Error.captureStackTrace(r,Rs),e.emit("wsClientError",r,s,t)}else Bs(s,r,i)}e.getDefaultExportFromCjs(Ns);const Us=Vt;Us.createWebSocketStream=ms,Us.Server=Ns,Us.Receiver=Ne,Us.Sender=Ve,Us.WebSocket=Us,Us.WebSocketServer=Us.Server;var Is=Us;e.getDefaultExportFromCjs(Is);const Ds="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{WebSocket:null};Ds.WebSocket||(Ds.WebSocket=Is.WebSocket); +var e=require("./lib/__bundle-a03c4073.cjs");require("./lib/__bundle-38c66c0d.cjs");var t=require("events"),s=require("https"),r=require("http"),i=require("net"),o=require("tls"),n=require("crypto"),a=require("stream"),c=require("url"),h=require("zlib"),l=require("fs"),d=require("path"),f=require("os"),u=require("buffer");function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=_(t),m=_(s),v=_(r),y=_(i),b=_(o),g=_(n),S=_(a),E=_(c),w=_(h),k=_(l),x=_(d),C=_(f),T=_(u),O={exports:{}};const N=["nodebuffer","arraybuffer","fragments"],L="undefined"!=typeof Blob;L&&N.push("blob");var P={BINARY_TYPES:N,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:L,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}};e.getDefaultExportFromCjs(P);var B={exports:{}};function R(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var U,I,D,W,F,M,j={exports:{}};function A(){if(D)return j.exports;D=1;const e="function"==typeof __webpack_require__?__non_webpack_require__:R;return"function"==typeof e.addon?j.exports=e.addon.bind(e):j.exports=function(){if(I)return U;I=1;var e=k.default,t=x.default,s=C.default,r="function"==typeof __webpack_require__?__non_webpack_require__:R,i=process.config&&process.config.variables||{},o=!!process.env.PREBUILDS_ONLY,n=process.versions.modules,a=process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":process.versions&&process.versions.nw?"node-webkit":"node",c=process.env.npm_config_arch||s.arch(),h=process.env.npm_config_platform||s.platform(),l=process.env.LIBC||(function(t){return"linux"===t&&e.existsSync("/etc/alpine-release")}(h)?"musl":"glibc"),d=process.env.ARM_VERSION||("arm64"===c?"8":i.arm_version)||"",f=(process.versions.uv||"").split(".")[0];function u(e){return r(u.resolve(e))}function _(t){try{return e.readdirSync(t)}catch(e){return[]}}function p(e,s){var r=_(e).filter(s);return r[0]&&t.join(e,r[0])}function m(e){return/\.node$/.test(e)}function v(e){var t=e.split("-");if(2===t.length){var s=t[0],r=t[1].split("+");if(s&&r.length&&r.every(Boolean))return{name:e,platform:s,architectures:r}}}function y(e,t){return function(s){return null!=s&&s.platform===e&&s.architectures.includes(t)}}function b(e,t){return e.architectures.length-t.architectures.length}function g(e){var t=e.split("."),s={file:e,specificity:0};if("node"===t.pop()){for(var r=0;rs.specificity?-1:1:0}}return U=u,u.resolve=u.path=function(e){e=t.resolve(e||".");try{var s=r(t.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[s+"_PREBUILD"]&&(e=process.env[s+"_PREBUILD"])}catch(e){}if(!o){var i=p(t.join(e,"build/Release"),m);if(i)return i;var u=p(t.join(e,"build/Debug"),m);if(u)return u}var w=C(e);if(w)return w;var k=C(t.dirname(process.execPath));if(k)return k;var x=["platform="+h,"arch="+c,"runtime="+a,"abi="+n,"uv="+f,d?"armv="+d:"","libc="+l,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"","function"==typeof __webpack_require__?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+x+"\n loaded from: "+e+"\n");function C(e){var s=_(t.join(e,"prebuilds")).map(v).filter(y(h,c)).sort(b)[0];if(s){var r=t.join(e,"prebuilds",s.name),i=_(r).map(g).filter(S(a,n)).sort(E(a))[0];return i?t.join(r,i.file):void 0}}},u.parseTags=g,u.matchTags=S,u.compareTags=E,u.parseTuple=v,u.matchTuple=y,u.compareTuples=b,U}(),j.exports}const{EMPTY_BUFFER:q}=P,$=Buffer[Symbol.species];function G(e,t,s,r,i){for(let o=0;o{for(var o=0;o{const s=e.length;for(var r=0;r{this.pending--,this[Y]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Y]()}[Y](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[H])}}};e.getDefaultExportFromCjs(X);const K=w.default,Z=z,J=X,{kStatusCode:Q}=P,ee=Buffer[Symbol.species],te=Buffer.from([0,0,255,255]),se=Symbol("permessage-deflate"),re=Symbol("total-length"),ie=Symbol("callback"),oe=Symbol("buffers"),ne=Symbol("error");let ae;var ce=class{constructor(e,t,s){if(this._maxPayload=0|s,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!ae){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;ae=new J(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[ie];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,s=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(s.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?s.client_max_window_bits=t.clientMaxWindowBits:!0!==s.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete s.client_max_window_bits,s}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let s=e[t];if(s.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(s=s[0],"client_max_window_bits"===t){if(!0!==s){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}else if("server_max_window_bits"===t){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==s)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}e[t]=s}))})),e}decompress(e,t,s){ae.add((r=>{this._decompress(e,t,((e,t)=>{r(),s(e,t)}))}))}compress(e,t,s){ae.add((r=>{this._compress(e,t,((e,t)=>{r(),s(e,t)}))}))}_decompress(e,t,s){const r=this._isServer?"client":"server";if(!this._inflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?K.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=K.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[se]=this,this._inflate[re]=0,this._inflate[oe]=[],this._inflate.on("error",de),this._inflate.on("data",le)}this._inflate[ie]=s,this._inflate.write(e),t&&this._inflate.write(te),this._inflate.flush((()=>{const e=this._inflate[ne];if(e)return this._inflate.close(),this._inflate=null,void s(e);const i=Z.concat(this._inflate[oe],this._inflate[re]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[re]=0,this._inflate[oe]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),s(null,i)}))}_compress(e,t,s){const r=this._isServer?"server":"client";if(!this._deflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?K.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=K.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[re]=0,this._deflate[oe]=[],this._deflate.on("data",he)}this._deflate[ie]=s,this._deflate.write(e),this._deflate.flush(K.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=Z.concat(this._deflate[oe],this._deflate[re]);t&&(e=new ee(e.buffer,e.byteOffset,e.length-4)),this._deflate[ie]=null,this._deflate[re]=0,this._deflate[oe]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),s(null,e)}))}};function he(e){this[oe].push(e),this[re]+=e.length}function le(e){this[re]+=e.length,this[se]._maxPayload<1||this[re]<=this[se]._maxPayload?this[oe].push(e):(this[ne]=new RangeError("Max payload size exceeded"),this[ne].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ne][Q]=1009,this.removeListener("data",le),this.reset())}function de(e){this[se]._inflate=null,e[Q]=1007,this[ie](e)}e.getDefaultExportFromCjs(ce);var fe={exports:{}};const{isUtf8:ue}=T.default,{hasBlob:_e}=P;function pe(e){const t=e.length;let s=0;for(;s=t||128!=(192&e[s+1])||128!=(192&e[s+2])||224===e[s]&&128==(224&e[s+1])||237===e[s]&&160==(224&e[s+1]))return!1;s+=3}else{if(240!=(248&e[s]))return!1;if(s+3>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||128!=(192&e[s+3])||240===e[s]&&128==(240&e[s+1])||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}else s++;return!0}if(fe.exports={isBlob:function(e){return _e&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&("Blob"===e[Symbol.toStringTag]||"File"===e[Symbol.toStringTag])},isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:pe,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},ue)fe.exports.isValidUTF8=function(e){return e.length<24?pe(e):ue(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const e=require("utf-8-validate");fe.exports.isValidUTF8=function(t){return t.length<32?pe(t):e(t)}}catch(e){}var me=fe.exports;e.getDefaultExportFromCjs(me);const{Writable:ve}=S.default,ye=ce,{BINARY_TYPES:be,EMPTY_BUFFER:ge,kStatusCode:Se,kWebSocket:Ee}=P,{concat:we,toArrayBuffer:ke,unmask:xe}=z,{isValidStatusCode:Ce,isValidUTF8:Te}=me,Oe=Buffer[Symbol.species];var Ne=class extends ve{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||be[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Ee]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,s){if(8===this._opcode&&0==this._state)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=new Oe(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(48&t[0]){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const s=!(64&~t[0]);if(!s||this._extensions[ye.extensionName]){if(this._fin=!(128&~t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=s}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~t[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}else{e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),s=t.readUInt32BE(0);if(s>Math.pow(2,21)-1){e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}else this._payloadLength=s*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}else this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=ge;if(this._payloadLength){if(this._bufferedBytes7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[ye.extensionName].decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(s)}this.dataMessage(t),0===this._state&&this.startLoop(t)}))}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let r;r="nodebuffer"===this._binaryType?we(s,t):"arraybuffer"===this._binaryType?ke(we(s,t)):"blob"===this._binaryType?new Blob(s):s,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!0),this._state=0,this.startLoop(e)})))}else{const r=we(s,t);if(!this._skipUTF8Validation&&!Te(r)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!1),this._state=0,this.startLoop(e)})))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate((()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)})));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,ge),this.end();else{const s=e.readUInt16BE(0);if(!Ce(s)){const e=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const r=new Oe(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Te(r)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",s,r),this.end()}this._state=0}}createError(e,t,s,r,i){this._loop=!1,this._errored=!0;const o=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=i,o[Se]=r,o}};e.getDefaultExportFromCjs(Ne);const{randomFillSync:Le}=g.default,Pe=ce,{EMPTY_BUFFER:Be,kWebSocket:Re,NOOP:Ue}=P,{isBlob:Ie,isValidStatusCode:De}=me,{mask:We,toBuffer:Fe}=z,Me=Symbol("kByteLength"),je=Buffer.alloc(4),Ae=8192;let qe,$e=Ae;class Ge{constructor(e,t,s){this._extensions=t||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=Ue,this[Re]=void 0}static frame(e,t){let s,r,i=!1,o=2,n=!1;t.mask&&(s=t.maskBuffer||je,t.generateMask?t.generateMask(s):($e===Ae&&(void 0===qe&&(qe=Buffer.alloc(Ae)),Le(qe,0,Ae),$e=0),s[0]=qe[$e++],s[1]=qe[$e++],s[2]=qe[$e++],s[3]=qe[$e++]),n=!(s[0]|s[1]|s[2]|s[3]),o=6),"string"==typeof e?r=t.mask&&!n||void 0===t[Me]?(e=Buffer.from(e)).length:t[Me]:(r=e.length,i=t.mask&&t.readOnly&&!n);let a=r;r>=65536?(o+=8,a=127):r>125&&(o+=2,a=126);const c=Buffer.allocUnsafe(i?r+o:o);return c[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(c[0]|=64),c[1]=a,126===a?c.writeUInt16BE(r,2):127===a&&(c[2]=c[3]=0,c.writeUIntBE(r,4,6)),t.mask?(c[1]|=128,c[o-4]=s[0],c[o-3]=s[1],c[o-2]=s[2],c[o-1]=s[3],n?[c,e]:i?(We(e,s,c,o,r),[c]):(We(e,s,e,0,r),[c,e])):[c,e]}close(e,t,s,r){let i;if(void 0===e)i=Be;else{if("number"!=typeof e||!De(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const s=Buffer.byteLength(t);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+s),i.writeUInt16BE(e,0),"string"==typeof t?i.write(t,2):i.set(t,2)}else i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0)}const o={[Me]:i.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,i,!1,o,r]):this.sendFrame(Ge.frame(i,o),r)}ping(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):Ie(e)?(r=e.size,i=!1):(r=(e=Fe(e)).length,i=Fe.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[Me]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};Ie(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(Ge.frame(e,o),s)}pong(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):Ie(e)?(r=e.size,i=!1):(r=(e=Fe(e)).length,i=Fe.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[Me]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};Ie(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(Ge.frame(e,o),s)}send(e,t,s){const r=this._extensions[Pe.extensionName];let i,o,n=t.binary?2:1,a=t.compress;"string"==typeof e?(i=Buffer.byteLength(e),o=!1):Ie(e)?(i=e.size,o=!1):(i=(e=Fe(e)).length,o=Fe.readOnly),this._firstFragment?(this._firstFragment=!1,a&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=i>=r._threshold),this._compress=a):(a=!1,n=0),t.fin&&(this._firstFragment=!0);const c={[Me]:i,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:o,rsv1:a};Ie(e)?0!==this._state?this.enqueue([this.getBlobData,e,this._compress,c,s]):this.getBlobData(e,this._compress,c,s):0!==this._state?this.enqueue([this.dispatch,e,this._compress,c,s]):this.dispatch(e,this._compress,c,s)}getBlobData(e,t,s,r){this._bufferedBytes+=s[Me],this._state=2,e.arrayBuffer().then((e=>{if(this._socket.destroyed){const e=new Error("The socket was closed while the blob was being read");return void process.nextTick(ze,this,e,r)}this._bufferedBytes-=s[Me];const i=Fe(e);t?this.dispatch(i,t,s,r):(this._state=0,this.sendFrame(Ge.frame(i,s),r),this.dequeue())})).catch((e=>{process.nextTick(He,this,e,r)}))}dispatch(e,t,s,r){if(!t)return void this.sendFrame(Ge.frame(e,s),r);const i=this._extensions[Pe.extensionName];this._bufferedBytes+=s[Me],this._state=1,i.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){ze(this,new Error("The socket was closed while data was being compressed"),r)}else this._bufferedBytes-=s[Me],this._state=0,s.readOnly=!1,this.sendFrame(Ge.frame(t,s),r),this.dequeue()}))}dequeue(){for(;0===this._state&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][Me],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Me],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}var Ve=Ge;function ze(e,t,s){"function"==typeof s&&s(t);for(let s=0;s{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let s,r,i=Object.create(null),o=!1,n=!1,a=!1,c=-1,h=-1,l=-1,d=0;for(;d0&&e.unshift(t),e.on("close",as),e.on("data",cs),e.on("end",hs),e.on("error",ls),this._readyState=$t.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=$t.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[Et.extensionName]&&this._extensions[Et.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=$t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==$t.CLOSED)if(this.readyState!==$t.CONNECTING)this.readyState!==$t.CLOSING?(this._readyState=$t.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),ns(this)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";Xt(this,this._req,e)}}pause(){this.readyState!==$t.CONNECTING&&this.readyState!==$t.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,s){if(this.readyState===$t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===$t.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||Tt,t,s)):Kt(this,e,s)}pong(e,t,s){if(this.readyState===$t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===$t.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||Tt,t,s)):Kt(this,e,s)}resume(){this.readyState!==$t.CONNECTING&&this.readyState!==$t.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,s){if(this.readyState===$t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(s=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==$t.OPEN)return void Kt(this,e,s);const r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[Et.extensionName]||(r.compress=!1),this._sender.send(e||Tt,r,s)}terminate(){if(this.readyState!==$t.CLOSED)if(this.readyState!==$t.CONNECTING)this._socket&&(this._readyState=$t.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";Xt(this,this._req,e)}}}Object.defineProperty($t,"CONNECTING",{enumerable:!0,value:At.indexOf("CONNECTING")}),Object.defineProperty($t.prototype,"CONNECTING",{enumerable:!0,value:At.indexOf("CONNECTING")}),Object.defineProperty($t,"OPEN",{enumerable:!0,value:At.indexOf("OPEN")}),Object.defineProperty($t.prototype,"OPEN",{enumerable:!0,value:At.indexOf("OPEN")}),Object.defineProperty($t,"CLOSING",{enumerable:!0,value:At.indexOf("CLOSING")}),Object.defineProperty($t.prototype,"CLOSING",{enumerable:!0,value:At.indexOf("CLOSING")}),Object.defineProperty($t,"CLOSED",{enumerable:!0,value:At.indexOf("CLOSED")}),Object.defineProperty($t.prototype,"CLOSED",{enumerable:!0,value:At.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty($t.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty($t.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[Nt])return t[Lt];return null},set(t){for(const t of this.listeners(e))if(t[Nt]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[Nt]:!0})}})})),$t.prototype.addEventListener=Ut,$t.prototype.removeEventListener=It;var Gt=$t;function Vt(e,t,s,r){const i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:jt[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,!jt.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${jt.join(", ")})`);let o;if(t instanceof St)o=t;else try{o=new St(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===o.protocol?o.protocol="ws:":"https:"===o.protocol&&(o.protocol="wss:"),e._url=o.href;const n="wss:"===o.protocol,a="ws+unix:"===o.protocol;let c;if("ws:"===o.protocol||n||a?a&&!o.pathname?c="The URL's pathname is empty":o.hash&&(c="The URL contains a fragment identifier"):c='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"',c){const t=new SyntaxError(c);if(0===e._redirects)throw t;return void zt(e,t)}const h=n?443:80,l=bt(16).toString("base64"),d=n?pt.request:mt.request,f=new Set;let u,_;if(i.createConnection=i.createConnection||(n?Yt:Ht),i.defaultPort=i.defaultPort||h,i.port=o.port||h,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(u=new Et(!0!==i.perMessageDeflate?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=Dt({[Et.extensionName]:u.offer()})),s.length){for(const e of s){if("string"!=typeof e||!qt.test(e)||f.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");f.add(e)}i.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(o.username||o.password)&&(i.auth=`${o.username}:${o.password}`),a){const e=i.path.split(":");i.socketPath=e[0],i.path=e[1]}if(i.followRedirects){if(0===e._redirects){e._originalIpc=a,e._originalSecure=n,e._originalHostOrSocketPath=a?i.socketPath:o.host;const t=r&&r.headers;if(r={...r,headers:{}},t)for(const[e,s]of Object.entries(t))r.headers[e.toLowerCase()]=s}else if(0===e.listenerCount("redirect")){const t=a?!!e._originalIpc&&i.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&o.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!n)&&(delete i.headers.authorization,delete i.headers.cookie,t||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),_=e._req=d(i),e._redirects&&e.emit("redirect",e.url,_)}else _=e._req=d(i);i.timeout&&_.on("timeout",(()=>{Xt(e,_,"Opening handshake has timed out")})),_.on("error",(t=>{null===_||_[Mt]||(_=e._req=null,zt(e,t))})),_.on("response",(o=>{const n=o.headers.location,a=o.statusCode;if(n&&i.followRedirects&&a>=300&&a<400){if(++e._redirects>i.maxRedirects)return void Xt(e,_,"Maximum redirects exceeded");let o;_.abort();try{o=new St(n,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${n}`);return void zt(e,s)}Vt(e,o,s,r)}else e.emit("unexpected-response",_,o)||Xt(e,_,`Unexpected server response: ${o.statusCode}`)})),_.on("upgrade",((t,s,r)=>{if(e.emit("upgrade",t),e.readyState!==$t.CONNECTING)return;_=e._req=null;const o=t.headers.upgrade;if(void 0===o||"websocket"!==o.toLowerCase())return void Xt(e,s,"Invalid Upgrade header");const n=gt("sha1").update(l+Ot).digest("base64");if(t.headers["sec-websocket-accept"]!==n)return void Xt(e,s,"Invalid Sec-WebSocket-Accept header");const a=t.headers["sec-websocket-protocol"];let c;if(void 0!==a?f.size?f.has(a)||(c="Server sent an invalid subprotocol"):c="Server sent a subprotocol but none was requested":f.size&&(c="Server sent no subprotocol"),c)return void Xt(e,s,c);a&&(e._protocol=a);const h=t.headers["sec-websocket-extensions"];if(void 0!==h){if(!u){return void Xt(e,s,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=Wt(h)}catch(t){return void Xt(e,s,"Invalid Sec-WebSocket-Extensions header")}const r=Object.keys(t);if(1!==r.length||r[0]!==Et.extensionName){return void Xt(e,s,"Server indicated an extension that was not requested")}try{u.accept(t[Et.extensionName])}catch(t){return void Xt(e,s,"Invalid Sec-WebSocket-Extensions header")}e._extensions[Et.extensionName]=u}e.setSocket(s,r,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})})),i.finishRequest?i.finishRequest(_,e):_.end()}function zt(e,t){e._readyState=$t.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function Ht(e){return e.path=e.socketPath,vt.connect(e)}function Yt(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=vt.isIP(e.host)?"":e.host),yt.connect(e)}function Xt(e,t,s){e._readyState=$t.CLOSING;const r=new Error(s);Error.captureStackTrace(r,Xt),t.setHeader?(t[Mt]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(zt,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Kt(e,t,s){if(t){const s=xt(t)?t.size:Ft(t).length;e._socket?e._sender._bufferedBytes+=s:e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${At[e.readyState]})`);process.nextTick(s,t)}}function Zt(e,t){const s=this[Bt];s._closeFrameReceived=!0,s._closeMessage=t,s._closeCode=e,void 0!==s._socket[Bt]&&(s._socket.removeListener("data",cs),process.nextTick(is,s._socket),1005===e?s.close():s.close(e,t))}function Jt(){const e=this[Bt];e.isPaused||e._socket.resume()}function Qt(e){const t=this[Bt];void 0!==t._socket[Bt]&&(t._socket.removeListener("data",cs),process.nextTick(is,t._socket),t.close(e[Pt])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function es(){this[Bt].emitClose()}function ts(e,t){this[Bt].emit("message",e,t)}function ss(e){const t=this[Bt];t._autoPong&&t.pong(e,!this._isServer,Rt),t.emit("ping",e)}function rs(e){this[Bt].emit("pong",e)}function is(e){e.resume()}function os(e){const t=this[Bt];t.readyState!==$t.CLOSED&&(t.readyState===$t.OPEN&&(t._readyState=$t.CLOSING,ns(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function ns(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),3e4)}function as(){const e=this[Bt];let t;this.removeListener("close",as),this.removeListener("data",cs),this.removeListener("end",hs),e._readyState=$t.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[Bt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",es),e._receiver.on("finish",es))}function cs(e){this[Bt]._receiver.write(e)||this.pause()}function hs(){const e=this[Bt];e._readyState=$t.CLOSING,e._receiver.end(),this.end()}function ls(){const e=this[Bt];this.removeListener("error",ls),this.on("error",Rt),e&&(e._readyState=$t.CLOSING,this.destroy())}e.getDefaultExportFromCjs(Gt);const{Duplex:ds}=S.default;function fs(e){e.emit("close")}function us(){!this.destroyed&&this._writableState.finished&&this.destroy()}function _s(e){this.removeListener("error",_s),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}var ps=function(e,t){let s=!0;const r=new ds({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,s){const i=!s&&r._readableState.objectMode?t.toString():t;r.push(i)||e.pause()})),e.once("error",(function(e){r.destroyed||(s=!1,r.destroy(e))})),e.once("close",(function(){r.destroyed||r.push(null)})),r._destroy=function(t,i){if(e.readyState===e.CLOSED)return i(t),void process.nextTick(fs,r);let o=!1;e.once("error",(function(e){o=!0,i(e)})),e.once("close",(function(){o||i(t),process.nextTick(fs,r)})),s&&e.terminate()},r._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){r._final(t)}))},r._read=function(){e.isPaused&&e.resume()},r._write=function(t,s,i){e.readyState!==e.CONNECTING?e.send(t,i):e.once("open",(function(){r._write(t,s,i)}))},r.on("end",us),r.on("error",_s),r};e.getDefaultExportFromCjs(ps);const{tokenChars:ms}=me;var vs={parse:function(e){const t=new Set;let s=-1,r=-1,i=0;for(;i{const s=bs.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),t.end(s)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function(){for(const s of Object.keys(t))e.removeListener(s,t[s])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(Ns,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(Ns,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{Ns(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,r){t.on("error",Ls);const i=e.headers["sec-websocket-key"],o=e.headers.upgrade,n=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void Bs(this,e,t,405,"Invalid HTTP method")}if(void 0===o||"websocket"!==o.toLowerCase()){return void Bs(this,e,t,400,"Invalid Upgrade header")}if(void 0===i||!Ts.test(i)){return void Bs(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==n&&13!==n){return void Bs(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void Ps(t,400);const a=e.headers["sec-websocket-protocol"];let c=new Set;if(void 0!==a)try{c=ws.parse(a)}catch(s){return void Bs(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const h=e.headers["sec-websocket-extensions"],l={};if(this.options.perMessageDeflate&&void 0!==h){const s=new Es(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=Ss.parse(h);e[Es.extensionName]&&(s.accept(e[Es.extensionName]),l[Es.extensionName]=s)}catch(s){return void Bs(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const o={origin:e.headers[""+(8===n?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(o,((o,n,a,h)=>{if(!o)return Ps(t,n||401,a,h);this.completeUpgrade(l,i,c,e,t,s,r)}));if(!this.options.verifyClient(o))return Ps(t,401)}this.completeUpgrade(l,i,c,e,t,s,r)}completeUpgrade(e,t,s,r,i,o,n){if(!i.readable||!i.writable)return i.destroy();if(i[Cs])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return Ps(i,503);const a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${gs("sha1").update(t+xs).digest("base64")}`],c=new this.options.WebSocket(null,void 0,this.options);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;e&&(a.push(`Sec-WebSocket-Protocol: ${e}`),c._protocol=e)}if(e[Es.extensionName]){const t=e[Es.extensionName].params,s=Ss.format({[Es.extensionName]:[t]});a.push(`Sec-WebSocket-Extensions: ${s}`),c._extensions=e}this.emit("headers",a,r),i.write(a.concat("\r\n").join("\r\n")),i.removeListener("error",Ls),c.setSocket(i,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(c),c.on("close",(()=>{this.clients.delete(c),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ns,this)}))),n(c,r)}};function Ns(e){e._state=2,e.emit("close")}function Ls(){this.destroy()}function Ps(e,t,s,r){s=s||bs.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${bs.STATUS_CODES[t]}\r\n`+Object.keys(r).map((e=>`${e}: ${r[e]}`)).join("\r\n")+"\r\n\r\n"+s)}function Bs(e,t,s,r,i){if(e.listenerCount("wsClientError")){const r=new Error(i);Error.captureStackTrace(r,Bs),e.emit("wsClientError",r,s,t)}else Ps(s,r,i)}e.getDefaultExportFromCjs(Os);const Rs=Gt;Rs.createWebSocketStream=ps,Rs.Server=Os,Rs.Receiver=Ne,Rs.Sender=Ve,Rs.WebSocket=Rs,Rs.WebSocketServer=Rs.Server;var Us=Rs;e.getDefaultExportFromCjs(Us);const Is="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{WebSocket:null};Is.WebSocket||(Is.WebSocket=Us.WebSocket); diff --git a/cjs/openChannel.cjs b/cjs/openChannel.cjs index 6f7cbef..05214cc 100644 --- a/cjs/openChannel.cjs +++ b/cjs/openChannel.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),n=require("./lib/__bundle-165fd6e1.cjs"),t=require("./lib/__bundle-d3673ecc.cjs"),a=require("./lib/__bundle-c127c886.cjs"),s=require("./lib/__bundle-611abb88.cjs");require("./lib/__bundle-dae7bdf2.cjs");class i 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 r={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)}`,this.params={show_pinned_messages:!0}}}class l extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class d extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o,is_ephemeral:l}))}}class h extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class c extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}class u extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class C extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}const p={};class _ extends t.BaseChannelManager{constructor(n,t){super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.OPEN})),this.subscribeChannelEvent=e.noop,this.unsubscribeChannelEvent=e.noop,this.refreshChannel=()=>e.__awaiter(this,void 0,void 0,(function*(){return e.noop()})),this._openChannelCache=new i(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n).catch((n=>{if(e.isThrowingOutside(n)&&"foreground"===this._sdkState.appState)throw 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]||(p[n]=this)}static of(e){return p[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new P(this._iid,P.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)}get handlers(){return[...this._openChannelHandlers.values()]}_handleEvent(a){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(a.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let s=null;if("MESG"===a.code?s=a.as(n.UserMessageEventCommand):"FILE"===a.code?s=a.as(n.FileMessageEventCommand):"ADMM"!==a.code&&"BRDM"!=a.code||(s=a.as(t.AdminMessageEventCommand)),s){const{message:n,isMentioned:t}=s;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 s=null;if("MEDI"===a.code?s=a.as(n.UpdateUserMessageEventCommand):"FEDI"===a.code?s=a.as(n.UpdateFileMessageEventCommand):"AEDI"===a.code&&(s=a.as(t.UpdateAdminMessageEventCommand)),s){const{message:n,mentionCountChange:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);let s=!1;a.lastPinnedMessage&&a.lastPinnedMessage.messageId===n.messageId&&a.lastPinnedMessage.updatedAte.__awaiter(this,void 0,void 0,(function*(){var e,i;for(const r of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(s&&(null===(e=r.onPinnedMessageUpdated)||void 0===e||e.call(r,a),null===(i=r.onChannelChanged)||void 0===i||i.call(r,a)),r.onMessageUpdated&&r.onMessageUpdated(a,n),t>0&&r.onMentionReceived&&r.onMentionReceived(a,n))}))))}}break}case"DELM":{const{channelUrl:n,channelType:t,messageId:s}=a.as(e.DeleteMessageEventCommand);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.onMessageDeleted&&e.onMessageDeleted(t,s)}))))}break}case"MRCT":{const{channelUrl:n,channelType:s,event:i}=a.as(t.ReactionEventCommand);if(s===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,i)}))))}break}case"MTHD":{const{event:n}=a.as(t.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}=a.as(t.MemberCountUpdateEventCommand),s=[];for(const e of n){const{channelUrl:n,participantCount:t,updatedAt:a}=e,i=yield this.getChannelFromCache(n);i&&i._updateParticipantCount(t,a)&&s.push(i)}if(s.length>0){const n=yield this.upsertChannelsToCache(s);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:s,channelUrl:i,channelType:r}=a.as(t.PollUpdateEventCommand);if(i&&r===e.ChannelType.OPEN){const t=yield this.getChannel(i,!0);this._dispatcher.dispatch(new e.PollUpdateInternalEventCommand({event:n,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),s===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(t,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(t,n)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:i}=a.as(n.PollVoteEventCommand);if(s&&i===e.ChannelType.OPEN){const n=yield this.getChannel(s,!0);this._dispatcher.dispatch(new e.PollVoteInternalEventCommand({event:t,source:e.CollectionEventSource.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:s}=a.as(t.ChannelEventCommand);if(s.isOpenChannelEvent)switch(s.category){case t.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(c),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(C),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(s.channelUrl,!0),{operators:i}=a.as(t.OperatorUpdateEventCommand);n.operators=i,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,i)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_MUTE:case t.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=a.as(r?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserMuted&&e.onUserMuted(i,o):e.onUserUnmuted&&e.onUserUnmuted(i,o)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_BAN:case t.ChannelEventCategory.USER_CHANNEL_UNBAN:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=a.as(r?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserBanned&&e.onUserBanned(i,o):e.onUserUnbanned&&e.onUserUnbanned(i,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_FREEZE:case t.ChannelEventCategory.CHANNEL_UNFREEZE:{const t=yield this.getChannel(s.channelUrl,!0),{freeze:i}=a.as(n.FreezeEventCommand);t.isFrozen=i,this.upsertChannelsToCache([t]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onChannelFrozen&&e.onChannelFrozen(t):e.onChannelUnfrozen&&e.onChannelUnfrozen(t)}))}))));break}case t.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(s.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 t.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(s.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaDataEventCommand);i&&t._upsertCachedMetaData(i,s.ts),r&&t._upsertCachedMetaData(r,s.ts),o&&t._removeFromCachedMetaData(o,s.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaDataCreated&&e.onMetaDataCreated(t,i),r&&e.onMetaDataUpdated&&e.onMetaDataUpdated(t,r),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(t,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaCounterCreated&&e.onMetaCounterCreated(t,i),r&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(t,r),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(t,o)}))}))));break}case t.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const n=yield this.getChannel(s.channelUrl,!0),{pinnedMessageIds:i,latestPinnedMessage:r,ts:o}=a.as(t.UpdatePinnedMessageEventCommand);o>n._pinnedMessagesUpdatedAt&&(n.pinnedMessageIds=i,n.lastPinnedMessage=r,n._pinnedMessagesUpdatedAt=o,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))})))));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,t)}))}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:i}=s.as(l);return(yield this.upsertChannelsToCache([i]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),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 d(t),s=yield this._requestQueue.send(a),{channel:i}=s.as(l);return this.upsertChannelsToCache([i]),i}))}}const v={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class g 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 m extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:s}=n;this.token=t,this.participants=s.map((n=>new a.Participant(e,n)))}}class E 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 g(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:i}=a.as(m);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class f extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o}))}}class U extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class y 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 P extends n.BaseChannel{constructor(t,a){var s;super(t,a),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(s=a.participant_count)&&void 0!==s?s:0,this.operators=Array.isArray(a.operators)?a.operators.map((n=>new e.User(t,n))):[],this.lastPinnedMessage=a.latest_pinned_message?n.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},a.latest_pinned_message)):null}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))),latest_pinned_message:t.lastPinnedMessage?n.payloadifyMessage(t.lastPinnedMessage):null})))}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 E(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 h({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:i}=a.as(c);this._updateParticipantCount(s,i);_.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),a=new u({channelUrl:this.url}),s=yield t.send(a),{participantCount:i,ts:r}=s.as(C);this._updateParticipantCount(i,r);_.of(this._iid).setExitedToCache(this);n.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,!0)||e.isFile(n.coverUrlOrImage,!0))&&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 f(Object.assign({channelUrl:this.url},t)),i=yield a.send(s),{channel:r}=i.as(U);this._update(r);const o=_.of(this._iid);return yield o.upsertChannelsToCache([r]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,i){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:i});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new y({channelUrl:this.url});yield n.send(t);const a=_.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}updateUserMessage(n,t){const a=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateUserMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}updateFileMessage(n,t){const a=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateFileMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}}class M extends s.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,this.onPinnedMessageUpdated=e.noop}}class T extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:i,customTypes:r,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:i,custom_types:r,show_frozen:o,show_metadata:l,show_pinned_messages:!0})}}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 P(e,n)))),this.ts="number"==typeof s?s:null}}class b extends e.BaseListQuery{constructor(e,n){var t,a,s,i,r;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!==(i=n.urlKeyword)&&void 0!==i?i:null,this.customTypes=null!==(r=n.customTypes)&&void 0!==r?r: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 T(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:i}=a.as(A);this._token=i,this._hasNext=!!i;const r=_.of(this._iid);return yield r.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class O extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}),this._manager=new _(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:i,cacheContext:o,sessionManager:a})}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,i){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},r);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=i,this._manager.createChannel(e)}))}}exports.OpenChannel=P,exports.OpenChannelHandler=class extends M{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=b,exports.OpenChannelModule=O,exports.ParticipantListQuery=E; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),n=require("./lib/__bundle-4bcf4070.cjs"),t=require("./lib/__bundle-12c1cdf9.cjs"),a=require("./lib/__bundle-05f697db.cjs"),s=require("./lib/__bundle-947cb619.cjs");require("./lib/__bundle-dae7bdf2.cjs");class i 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 r={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)}`,this.params={show_pinned_messages:!0}}}class l extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class d extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o,is_ephemeral:l}))}}class h extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class c extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}class u extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class C extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}const p={};class _ extends t.BaseChannelManager{constructor(n,t){super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.OPEN})),this.subscribeChannelEvent=e.noop,this.unsubscribeChannelEvent=e.noop,this.refreshChannel=()=>e.__awaiter(this,void 0,void 0,(function*(){return e.noop()})),this._openChannelCache=new i(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n).catch((n=>{if(e.isThrowingOutside(n)&&"foreground"===this._sdkState.appState)throw 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]||(p[n]=this)}static of(e){return p[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new P(this._iid,P.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)}get handlers(){return[...this._openChannelHandlers.values()]}_handleEvent(a){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(a.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let s=null;if("MESG"===a.code?s=a.as(n.UserMessageEventCommand):"FILE"===a.code?s=a.as(n.FileMessageEventCommand):"ADMM"!==a.code&&"BRDM"!=a.code||(s=a.as(t.AdminMessageEventCommand)),s){const{message:n,isMentioned:t}=s;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 s=null;if("MEDI"===a.code?s=a.as(n.UpdateUserMessageEventCommand):"FEDI"===a.code?s=a.as(n.UpdateFileMessageEventCommand):"AEDI"===a.code&&(s=a.as(t.UpdateAdminMessageEventCommand)),s){const{message:n,mentionCountChange:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);let s=!1;a.lastPinnedMessage&&a.lastPinnedMessage.messageId===n.messageId&&a.lastPinnedMessage.updatedAte.__awaiter(this,void 0,void 0,(function*(){var e,i;for(const r of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(s&&(null===(e=r.onPinnedMessageUpdated)||void 0===e||e.call(r,a),null===(i=r.onChannelChanged)||void 0===i||i.call(r,a)),r.onMessageUpdated&&r.onMessageUpdated(a,n),t>0&&r.onMentionReceived&&r.onMentionReceived(a,n))}))))}}break}case"DELM":{const{channelUrl:n,channelType:t,messageId:s}=a.as(e.DeleteMessageEventCommand);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.onMessageDeleted&&e.onMessageDeleted(t,s)}))))}break}case"MRCT":{const{channelUrl:n,channelType:s,event:i}=a.as(t.ReactionEventCommand);if(s===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,i)}))))}break}case"MTHD":{const{event:n}=a.as(t.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}=a.as(t.MemberCountUpdateEventCommand),s=[];for(const e of n){const{channelUrl:n,participantCount:t,updatedAt:a}=e,i=yield this.getChannelFromCache(n);i&&i._updateParticipantCount(t,a)&&s.push(i)}if(s.length>0){const n=yield this.upsertChannelsToCache(s);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:s,channelUrl:i,channelType:r}=a.as(t.PollUpdateEventCommand);if(i&&r===e.ChannelType.OPEN){const t=yield this.getChannel(i,!0);this._dispatcher.dispatch(new e.PollUpdateInternalEventCommand({event:n,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),s===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(t,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(t,n)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:i}=a.as(n.PollVoteEventCommand);if(s&&i===e.ChannelType.OPEN){const n=yield this.getChannel(s,!0);this._dispatcher.dispatch(new e.PollVoteInternalEventCommand({event:t,source:e.CollectionEventSource.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:s}=a.as(t.ChannelEventCommand);if(s.isOpenChannelEvent)switch(s.category){case t.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(c),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(C),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(s.channelUrl,!0),{operators:i}=a.as(t.OperatorUpdateEventCommand);n.operators=i,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,i)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_MUTE:case t.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=a.as(r?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserMuted&&e.onUserMuted(i,o):e.onUserUnmuted&&e.onUserUnmuted(i,o)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_BAN:case t.ChannelEventCategory.USER_CHANNEL_UNBAN:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=a.as(r?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserBanned&&e.onUserBanned(i,o):e.onUserUnbanned&&e.onUserUnbanned(i,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_FREEZE:case t.ChannelEventCategory.CHANNEL_UNFREEZE:{const t=yield this.getChannel(s.channelUrl,!0),{freeze:i}=a.as(n.FreezeEventCommand);t.isFrozen=i,this.upsertChannelsToCache([t]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onChannelFrozen&&e.onChannelFrozen(t):e.onChannelUnfrozen&&e.onChannelUnfrozen(t)}))}))));break}case t.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(s.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 t.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(s.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaDataEventCommand);i&&t._upsertCachedMetaData(i,s.ts),r&&t._upsertCachedMetaData(r,s.ts),o&&t._removeFromCachedMetaData(o,s.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaDataCreated&&e.onMetaDataCreated(t,i),r&&e.onMetaDataUpdated&&e.onMetaDataUpdated(t,r),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(t,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaCounterCreated&&e.onMetaCounterCreated(t,i),r&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(t,r),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(t,o)}))}))));break}case t.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const n=yield this.getChannel(s.channelUrl,!0),{pinnedMessageIds:i,latestPinnedMessage:r,ts:o}=a.as(t.UpdatePinnedMessageEventCommand);o>n._pinnedMessagesUpdatedAt&&(n.pinnedMessageIds=i,n.lastPinnedMessage=r,n._pinnedMessagesUpdatedAt=o,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))})))));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,t)}))}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:i}=s.as(l);return(yield this.upsertChannelsToCache([i]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),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 d(t),s=yield this._requestQueue.send(a),{channel:i}=s.as(l);return this.upsertChannelsToCache([i]),i}))}}const v={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class g 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 m extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:s}=n;this.token=t,this.participants=s.map((n=>new a.Participant(e,n)))}}class E 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 g(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:i}=a.as(m);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class f extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o}))}}class U extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class y 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 P extends n.BaseChannel{constructor(t,a){var s;super(t,a),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(s=a.participant_count)&&void 0!==s?s:0,this.operators=Array.isArray(a.operators)?a.operators.map((n=>new e.User(t,n))):[],this.lastPinnedMessage=a.latest_pinned_message?n.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},a.latest_pinned_message)):null}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))),latest_pinned_message:t.lastPinnedMessage?n.payloadifyMessage(t.lastPinnedMessage):null})))}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 E(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 h({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:i}=a.as(c);this._updateParticipantCount(s,i);_.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),a=new u({channelUrl:this.url}),s=yield t.send(a),{participantCount:i,ts:r}=s.as(C);this._updateParticipantCount(i,r);_.of(this._iid).setExitedToCache(this);n.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,!0)||e.isFile(n.coverUrlOrImage,!0))&&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 f(Object.assign({channelUrl:this.url},t)),i=yield a.send(s),{channel:r}=i.as(U);this._update(r);const o=_.of(this._iid);return yield o.upsertChannelsToCache([r]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,i){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:i});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new y({channelUrl:this.url});yield n.send(t);const a=_.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}updateUserMessage(n,t){const a=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateUserMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}updateFileMessage(n,t){const a=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateFileMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}}class M extends s.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,this.onPinnedMessageUpdated=e.noop}}class T extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:i,customTypes:r,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:i,custom_types:r,show_frozen:o,show_metadata:l,show_pinned_messages:!0})}}class b 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 P(e,n)))),this.ts="number"==typeof s?s:null}}class A extends e.BaseListQuery{constructor(e,n){var t,a,s,i,r;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!==(i=n.urlKeyword)&&void 0!==i?i:null,this.customTypes=null!==(r=n.customTypes)&&void 0!==r?r: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 T(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:i}=a.as(b);this._token=i,this._hasNext=!!i;const r=_.of(this._iid);return yield r.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class O extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}),this._manager=new _(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:i,cacheContext:o,sessionManager:a})}createOpenChannelListQuery(e={}){return new A(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,i){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},r);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=i,this._manager.createChannel(e)}))}}exports.OpenChannel=P,exports.OpenChannelHandler=class extends M{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=A,exports.OpenChannelModule=O,exports.ParticipantListQuery=E; diff --git a/cjs/poll.cjs b/cjs/poll.cjs index e2e95d4..e0bd740 100644 --- a/cjs/poll.cjs +++ b/cjs/poll.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-1a495950.cjs"),t=require("./lib/__bundle-dae7bdf2.cjs");class r extends e.Module{constructor(){super(...arguments),this.name="poll"}init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}){super.init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new e.PollManager(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n})}create(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollCreateParamsDefault),t);return e.unless(e.validatePollCreateParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.create(r)}))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollRetrievalParamsDefault),t);return e.unless(e.validatePollRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.get(r)}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollOptionRetrievalParamsDefault),t);return e.unless(e.validatePollOptionRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(r)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=e.Poll,exports.PollListQuery=e.PollListQuery,exports.PollOption=e.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return e.PollStatus}}),exports.PollVoteEvent=e.PollVoteEvent,exports.PollVoterListQuery=e.PollVoterListQuery,exports.PollUpdateEvent=t.PollUpdateEvent,exports.PollModule=r; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),t=require("./lib/__bundle-dae7bdf2.cjs");class r extends e.Module{constructor(){super(...arguments),this.name="poll"}init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}){super.init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new e.PollManager(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n})}create(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollCreateParamsDefault),t);return e.unless(e.validatePollCreateParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.create(r)}))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollRetrievalParamsDefault),t);return e.unless(e.validatePollRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.get(r)}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollOptionRetrievalParamsDefault),t);return e.unless(e.validatePollOptionRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(r)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=e.Poll,exports.PollListQuery=e.PollListQuery,exports.PollOption=e.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return e.PollStatus}}),exports.PollVoteEvent=e.PollVoteEvent,exports.PollVoterListQuery=e.PollVoterListQuery,exports.PollUpdateEvent=t.PollUpdateEvent,exports.PollModule=r; diff --git a/feedChannel.js b/feedChannel.js index 5fcf4b2..2336b4b 100644 --- a/feedChannel.js +++ b/feedChannel.js @@ -1 +1 @@ -import{e,u as t,c as n,w as r,s as a,g as i,p as o,q as s,_ as c,b as u,af as l,t as h,b8 as d,B as f,A as p,d as v,f as _,h as g,bg as y,az as m,a as C,bp as b,aQ as w,Q as E,V as M,au as T,W as N,bq as k,z as x,a2 as I,C as S,O as A,a8 as U,G as D,an as F,bk as R,aw as O,ai as P,b9 as H,ba as L,aA as j,aO as G,a_ as V}from"./lib/__bundle-1db3fd0b.js";import{i as z,aO as B,aj as Q,aP as q,ac as W,aQ as K,aR as J,T as Y,z as X,aS as Z,aT as $}from"./lib/__bundle-e1a5e3f1.js";export{aj as NotificationMessage,aR as NotificationMessageStatus}from"./lib/__bundle-e1a5e3f1.js";import{y as ee,z as te,A as ne,B as re,o as ae,E as ie,F as oe,I as se,b as ce}from"./lib/__bundle-cc71b396.js";import{g as ue,N as le}from"./lib/__bundle-31d4ecef.js";import{D as he}from"./lib/__bundle-24f017be.js";import{B as de,C as fe,a as pe}from"./lib/__bundle-e53b9010.js";import"./lib/__bundle-acd77193.js";var ve=function(){function n(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}return n.payloadify=function(n){return e(t({id:n.id,name:n.name,is_default:n.isDefault}))},Object.defineProperty(n.prototype,"customType",{get:function(){return this.isDefault?"*":String(this.id)},enumerable:!1,configurable:!0}),n}(),_e=function(t){function l(e,n){var r=n.sdkState,a=n.cacheContext,i=n.channelManager,o=t.call(this,e)||this;return o._channels=new Map,o._sdkState=r,o._cacheContext=a,o._channelManager=i,o}return n(l,t),Object.defineProperty(l.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return r(!!e).throw(a.databaseError),e.collection(z)},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),l.prototype._serialize=function(e,t){return void 0===t&&(t=0),i(i({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},l.prototype._deserialize=function(e){return this._channelManager.buildFeedChannelFromSerializedData(e)},Object.defineProperty(l.prototype,"channels",{get:function(){return o([],s(this._channels.values()),!1)},enumerable:!1,configurable:!0}),l.prototype.isCachedInMemory=function(e){return this._channels.has(e)},l.prototype.get=function(e){return c(this,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=n.sent())return this._channels.set(e,this._deserialize(t)),[2,this._channels.get(e)];n.label=2;case 2:return[2,void 0];case 3:return[2,this._channels.get(e)]}}))}))},l.prototype.fetch=function(e){var t=e.token,n=e.limit,r=void 0===n?B:n,a=e.backward,i=void 0!==a&&a,o=e.order,s=void 0===o?"latest_last_message":o,l=e.borderlineChannelUrl;return c(this,void 0,void 0,(function(){var e,n,a,o,c=this;return u(this,(function(u){switch(u.label){case 0:return this.localCacheEnabled?(e=ue(s),n={where:function(e){if(t&&"latest_last_message"===s)if(!i&&e.lastMessageUpdatedAt>t||i&&e.lastMessageUpdatedAt0&&this._dispatcher.dispatch(new ge({channels:d,context:{source:o}})),f.length>0&&this._dispatcher.dispatch(new ye({channelUrls:f,context:{source:o}})),[2,{updatedChannels:d,deletedChannelUrls:f,hasMore:p,token:v}]}}))}))},l.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){var t,n,o,s,c,l,h;return u(this,(function(u){switch(u.label){case 0:return t=i(i({},te),e),r(ne(t)).throw(a.invalidParameters),n=M.of(this._iid),o=n.sdkState,s=n.requestQueue,c=new re({userId:o.userId,filter:t,includeFeedChannel:!0}),[4,s.send(c)];case 1:return l=u.sent(),h=l.as(ee).unreadFeedCount,[2,void 0===h?0:h]}}))}))},l.prototype.getTotalUnreadNotificationCount=function(){return c(this,void 0,void 0,(function(){var e,t,n,r,a,i;return u(this,(function(o){switch(o.label){case 0:return e=M.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pe({userId:t.userId}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(ee).unreadFeedCount,[2,void 0===i?0:i]}}))}))},l.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){var e,t;return u(this,(function(n){switch(n.label){case 0:return e=new Ie,[4,this._requestQueue.send(e)];case 1:return t=n.sent(),[2,{jsonString:t.as(Se).jsonString}]}}))}))},l.prototype.getNotificationTemplateListByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n,o,s,c,l,h,d;return u(this,(function(u){switch(u.label){case 0:return n=i(i({},De),t),r(C("string",e)&&function(e){return C("boolean",e.reverse,!0)&&E("string",e.keys,!0)&&C("number",e.limit,!0)}(n)).throw(a.invalidParameters),o=new Ae({token:e,keys:n.keys,reverse:n.reverse,limit:n.limit}),[4,this._requestQueue.send(o)];case 1:return s=u.sent(),c=s.as(Ue),l=c.hasMore,h=c.nextToken,d=c.notificationTemplateList,[2,{hasMore:l,token:h,notificationTemplateList:d}]}}))}))},l.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){var t,n;return u(this,(function(i){switch(i.label){case 0:return r(C("string",e)).throw(a.invalidParameters),t=new Fe({key:e}),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,{jsonString:n.as(Re).jsonString}]}}))}))},l.prototype.upsertChannelsToCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.removeChannelsFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return t.sent(),[2]}}))}))},l.prototype.getNotificationMessageFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=I.REFRESH_CHANNEL),c(this,void 0,void 0,(function(){var r,a,i,o,s;return u(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Ee({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Me).channel).myMemberState!==ae.NONE?[3,2]:(this._dispatcher.dispatch(new ye({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new ge({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(s=c.sent()).code!==U.NON_AUTHORIZED&&s.code!==U.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new ye({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},l.prototype.refreshNotificationCollections=function(){this._dispatcher.dispatch(new le)},l.prototype.subscribeChannelEvent=function(e,t){this._feedChannelBroadcast.subscribe(e,t)},l.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},l.prototype._handleEvent=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,l,d,f,p=this;return u(this,(function(v){switch(v.label){case 0:switch(e.code){case"ADMM":case"BRDM":return[3,1];case"READ":return[3,4];case"SYEV":return[3,7]}return[3,13];case 1:return(s="ADMM"===e.code||"BRDM"===e.code?e.as(Oe):null)&&s.message.channelType===this._channelType?(t=s.message,n=s.isMentioned,[4,this.getChannel(t.channelUrl,!0)]):[3,3];case 2:(r=v.sent())._runIfHandleableWithGroupChannel((function(e){var a;t instanceof Q&&n&&(null===(a=t.mentionedUsers)||void 0===a||a.forEach((function(t){var n,r;try{for(var a=h(e.members),i=a.next();!i.done;i=a.next()){var o=i.value;if(t.userId===o.userId){t.nickname=o.nickname,t.plainProfileUrl=o.plainProfileUrl,t.metaData=o.metaData;break}}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}))),p._dispatcher.dispatch(new ge({channels:[r],context:{source:I.EVENT_MESSAGE_RECEIVED}})),p._dispatcher.dispatch(new F({messages:[t],source:I.EVENT_MESSAGE_RECEIVED})),D((function(){return c(p,void 0,void 0,(function(){var e,a,i,o,s;return u(this,(function(c){try{for(e=h(this._feedChannelHandlers.values()),a=e.next();!a.done;a=e.next())(i=a.value).onMessageReceived&&i.onMessageReceived(r,t),n&&i.onMentionReceived&&i.onMentionReceived(r,t)}catch(e){o={error:e}}finally{try{a&&!a.done&&(s=e.return)&&s.call(e)}finally{if(o)throw o.error}}return[2]}))}))}))})),v.label=3;case 3:return[3,13];case 4:return(s="READ"===e.code?e.as(W):null)&&s.readStatus.channelType===this._channelType?(a=s.readStatus,i=this._feedChannelCache.isCachedInMemory(a.channelUrl),[4,this.getChannel(a.channelUrl,!0)]):[3,6];case 5:(o=v.sent())._runIfHandleableWithGroupChannel((function(e){i&&e._updateUnreadMemberState(a.reader.userId,a.readAt),a.reader.userId===p._sdkState.userId&&(i?(e.unreadMessageCount>0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))))})),v.label=6;case 6:return[3,13];case 7:if(!(s="SYEV"===e.code?e.as(fe):null)||s.event.channelType!==this._channelType)return[3,12];switch(l=s.event,l.category){case pe.CHANNEL_DELETED:return[3,8];case pe.CHANNEL_PROP_CHANGED:return[3,10]}return[3,12];case 8:return[4,this.getChannel(l.channelUrl,!0)];case 9:return d=v.sent(),this._dispatcher.dispatch(new ye({channelUrls:[l.channelUrl],context:{source:I.EVENT_CHANNEL_DELETED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(d.url,d.channelType)})),[2]}))}))})),[3,12];case 10:return[4,this.getChannelWithoutCache(l.channelUrl,!0)];case 11:return f=v.sent(),this._dispatcher.dispatch(new ge({channels:[f],context:{source:I.EVENT_CHANNEL_UPDATED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(f)})),[2]}))}))})),[3,12];case 12:return[3,13];case 13:return[2]}}))}))},l.prototype.getMessageFromCache=function(e){var t;return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},l.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return c(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,r.sent()]}}))}))},l.prototype.getMessagesFromCache=function(e,t,n,r,a,i){return void 0===a&&(a=K),void 0===i&&(i=!0),c(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i})];case 1:return[2,o.sent()]}}))}))},l}(de),je=function(e){function t(t,n){var r=e.call(this,t,i(i({},n),{channelManager:Le.of(t)}))||this,a=M.of(r._iid),o=a.connectionManager,s=a.dispatcher;return r._notificationCollectionEventContext=s.on((function(e){e instanceof le&&O(10).then((function(){o.isConnected||o.isConnecting||r.refresh()}))})),r}return n(t,e),t.prototype.keyOf=function(e){return e.notificationId},Object.defineProperty(t.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._notificationCollectionEventContext.close()},t.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},t.prototype._postprocessChannelUpdateEvent=function(e,t){var n,r,a=this._messages.filter((function(t){return t.messageStatus===J.SENT&&t.createdAt<=e.myLastRead}));if(a.length>0){try{for(var i=h(a),o=i.next();!o.done;o=i.next()){o.value.messageStatus=J.READ}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}this._updateMessagesToView(a,t)}},t.prototype._postprocessMessageUpdateEvent=function(e,t){var n,r;if(t===I.EVENT_CHANNEL_READ){var a=[],i=this._messages.map((function(e){return e.notificationId}));try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var c=s.value.notificationId,u=i.indexOf(c);u>=0&&(this._messages[u].messageStatus=J.READ,a.push(this._messages[u]))}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a.length>0&&this._updateMessagesToView(a,t)}},t.prototype._addMessagesToView=function(e,t){var n,r,a=this,i=this._filterUnderOffsetMessage(e),o=[],s=[];try{for(var l=h(i),d=l.next();!d.done;d=l.next()){var f,p=d.value;if(t===I.SYNC_MESSAGE_FILL){if((f=ie(this._messages,p))<0){var v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}}else if((f=ie(this._messages,p))<0){v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}else this._messages[f]=p,s.push(p)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r,a,i;return u(this,(function(c){return e={source:t},o.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===r||r.call(n,e,this.channel,o)),s.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,e,this.channel,s)),[2]}))}))}))},t.prototype._updateMessagesToView=function(e,t){var n,r,a=this,i=[];try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var l=s.value,d=ie(this._messages,l);d>=0&&(i.push(l),this._messages[d]=l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r;return u(this,(function(a){return e={source:t},i.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,i)),[2]}))}))})),i},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._activate()];case 1:return e.sent(),[2]}}))}))},t}(se),Ge=function(e){function t(t,n){var r,a,o=this;return(o=e.call(this,t,n)||this).channelType=S.FEED,o._groupChannel=new ce(t,n),o.isCategoryFilterEnabled=null!==(r=n.is_category_filter_enabled)&&void 0!==r&&r,o.isTemplateLabelEnabled=null===(a=n.is_template_label_enabled)||void 0===a||a,o.notificationCategories=n.categories?n.categories.map((function(e){return new ve(e)})):[],o.lastMessage=n.last_message?Y(o._iid,i({channel_type:o.channelType},n.last_message)):null,o}return n(t,e),t.payloadify=function(e){var t;return i(i({},ce.payloadify(null!==(t=e._groupChannel)&&void 0!==t?t:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((function(e){return ve.payloadify(e)})),last_message:e.lastMessage?Q.payloadify(e.lastMessage):null})},Object.defineProperty(t.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var e,t;return i(i({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((function(e){return P(e)})),lastMessage:null!==(t=null===(e=this.lastMessage)||void 0===e?void 0:e.serialize())&&void 0!==t?t:null})},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},t.prototype.markAsRead=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,c,l,h,d=this;return u(this,(function(u){switch(u.label){case 0:return t=M.of(this._iid),n=t.sdkState,r=t.dispatcher,a=t.requestQueue,!(i=null==e?void 0:e.filter((function(e){return!e||e.messageStatus===J.SENT})).map((function(e){return e.notificationId})))||i.length>0?(o=new $({userId:n.userId,channelUrl:this.url,channelType:S.FEED,notificationIds:i}),[4,a.send(o)]):[3,2];case 1:s=u.sent(),c=s.as(Z),l=c.unreadMessageCount,h=c.readAt,e?("number"==typeof l&&(this._groupChannel._updateUnreadCount(l,this._groupChannel.unreadMentionCount),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)}))),e.forEach((function(e){e.messageStatus=J.READ})),r.dispatch(new F({messages:e,source:I.EVENT_CHANNEL_READ}))):(this._groupChannel._updateUnreadMemberState(n.userId,h),this._groupChannel.unreadMessageCount!==l&&(this._groupChannel._updateUnreadCount(l,0),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})))),r.dispatch(new ge({channels:[this],context:{source:I.EVENT_CHANNEL_READ}})),u.label=2;case 2:return[2]}}))}))},t.prototype.markAsClicked=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.logClicked(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.logClicked=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30)try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.logImpression=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return[2,this.logViewed(e)]}))}))},t.prototype.logViewed=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30){try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2,!0]}return[2,!1]}))}))},t.prototype.logCustom=function(e,t){return c(this,void 0,void 0,(function(){var n,r,a,i,o,s;return u(this,(function(c){if(n=M.of(this._iid).statManager,0t||i&&e.lastMessageUpdatedAt0&&this._dispatcher.dispatch(new ge({channels:d,context:{source:o}})),f.length>0&&this._dispatcher.dispatch(new ye({channelUrls:f,context:{source:o}})),[2,{updatedChannels:d,deletedChannelUrls:f,hasMore:p,token:v}]}}))}))},l.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){var t,n,o,s,c,l,h;return u(this,(function(u){switch(u.label){case 0:return t=i(i({},te),e),r(ne(t)).throw(a.invalidParameters),n=M.of(this._iid),o=n.sdkState,s=n.requestQueue,c=new re({userId:o.userId,filter:t,includeFeedChannel:!0}),[4,s.send(c)];case 1:return l=u.sent(),h=l.as(ee).unreadFeedCount,[2,void 0===h?0:h]}}))}))},l.prototype.getTotalUnreadNotificationCount=function(){return c(this,void 0,void 0,(function(){var e,t,n,r,a,i;return u(this,(function(o){switch(o.label){case 0:return e=M.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pe({userId:t.userId}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(ee).unreadFeedCount,[2,void 0===i?0:i]}}))}))},l.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){var e,t;return u(this,(function(n){switch(n.label){case 0:return e=new Ie,[4,this._requestQueue.send(e)];case 1:return t=n.sent(),[2,{jsonString:t.as(Se).jsonString}]}}))}))},l.prototype.getNotificationTemplateListByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n,o,s,c,l,h,d;return u(this,(function(u){switch(u.label){case 0:return n=i(i({},De),t),r(C("string",e)&&function(e){return C("boolean",e.reverse,!0)&&E("string",e.keys,!0)&&C("number",e.limit,!0)}(n)).throw(a.invalidParameters),o=new Ae({token:e,keys:n.keys,reverse:n.reverse,limit:n.limit}),[4,this._requestQueue.send(o)];case 1:return s=u.sent(),c=s.as(Ue),l=c.hasMore,h=c.nextToken,d=c.notificationTemplateList,[2,{hasMore:l,token:h,notificationTemplateList:d}]}}))}))},l.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){var t,n;return u(this,(function(i){switch(i.label){case 0:return r(C("string",e)).throw(a.invalidParameters),t=new Fe({key:e}),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,{jsonString:n.as(Re).jsonString}]}}))}))},l.prototype.upsertChannelsToCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.removeChannelsFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return t.sent(),[2]}}))}))},l.prototype.getNotificationMessageFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=I.REFRESH_CHANNEL),c(this,void 0,void 0,(function(){var r,a,i,o,s;return u(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Ee({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Me).channel).myMemberState!==ae.NONE?[3,2]:(this._dispatcher.dispatch(new ye({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new ge({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(s=c.sent()).code!==U.NON_AUTHORIZED&&s.code!==U.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new ye({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},l.prototype.refreshNotificationCollections=function(){this._dispatcher.dispatch(new le)},l.prototype.subscribeChannelEvent=function(e,t){this._feedChannelBroadcast.subscribe(e,t)},l.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},l.prototype._handleEvent=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,l,d,f,p=this;return u(this,(function(v){switch(v.label){case 0:switch(e.code){case"ADMM":case"BRDM":return[3,1];case"READ":return[3,4];case"SYEV":return[3,7]}return[3,13];case 1:return(s="ADMM"===e.code||"BRDM"===e.code?e.as(Oe):null)&&s.message.channelType===this._channelType?(t=s.message,n=s.isMentioned,[4,this.getChannel(t.channelUrl,!0)]):[3,3];case 2:(r=v.sent())._runIfHandleableWithGroupChannel((function(e){var a;t instanceof Q&&n&&(null===(a=t.mentionedUsers)||void 0===a||a.forEach((function(t){var n,r;try{for(var a=h(e.members),i=a.next();!i.done;i=a.next()){var o=i.value;if(t.userId===o.userId){t.nickname=o.nickname,t.plainProfileUrl=o.plainProfileUrl,t.metaData=o.metaData;break}}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}))),p._dispatcher.dispatch(new ge({channels:[r],context:{source:I.EVENT_MESSAGE_RECEIVED}})),p._dispatcher.dispatch(new F({messages:[t],source:I.EVENT_MESSAGE_RECEIVED})),D((function(){return c(p,void 0,void 0,(function(){var e,a,i,o,s;return u(this,(function(c){try{for(e=h(this._feedChannelHandlers.values()),a=e.next();!a.done;a=e.next())(i=a.value).onMessageReceived&&i.onMessageReceived(r,t),n&&i.onMentionReceived&&i.onMentionReceived(r,t)}catch(e){o={error:e}}finally{try{a&&!a.done&&(s=e.return)&&s.call(e)}finally{if(o)throw o.error}}return[2]}))}))}))})),v.label=3;case 3:return[3,13];case 4:return(s="READ"===e.code?e.as(W):null)&&s.readStatus.channelType===this._channelType?(a=s.readStatus,i=this._feedChannelCache.isCachedInMemory(a.channelUrl),[4,this.getChannel(a.channelUrl,!0)]):[3,6];case 5:(o=v.sent())._runIfHandleableWithGroupChannel((function(e){i&&e._updateUnreadMemberState(a.reader.userId,a.readAt),a.reader.userId===p._sdkState.userId&&(i?(e.unreadMessageCount>0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))))})),v.label=6;case 6:return[3,13];case 7:if(!(s="SYEV"===e.code?e.as(fe):null)||s.event.channelType!==this._channelType)return[3,12];switch(l=s.event,l.category){case pe.CHANNEL_DELETED:return[3,8];case pe.CHANNEL_PROP_CHANGED:return[3,10]}return[3,12];case 8:return[4,this.getChannel(l.channelUrl,!0)];case 9:return d=v.sent(),this._dispatcher.dispatch(new ye({channelUrls:[l.channelUrl],context:{source:I.EVENT_CHANNEL_DELETED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(d.url,d.channelType)})),[2]}))}))})),[3,12];case 10:return[4,this.getChannelWithoutCache(l.channelUrl,!0)];case 11:return f=v.sent(),this._dispatcher.dispatch(new ge({channels:[f],context:{source:I.EVENT_CHANNEL_UPDATED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(f)})),[2]}))}))})),[3,12];case 12:return[3,13];case 13:return[2]}}))}))},l.prototype.getMessageFromCache=function(e){var t;return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},l.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return c(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,r.sent()]}}))}))},l.prototype.getMessagesFromCache=function(e,t,n,r,a,i){return void 0===a&&(a=K),void 0===i&&(i=!0),c(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i})];case 1:return[2,o.sent()]}}))}))},l}(de),je=function(e){function t(t,n){var r=e.call(this,t,i(i({},n),{channelManager:Le.of(t)}))||this,a=M.of(r._iid),o=a.connectionManager,s=a.dispatcher;return r._notificationCollectionEventContext=s.on((function(e){e instanceof le&&O(10).then((function(){o.isConnected||o.isConnecting||r.refresh()}))})),r}return n(t,e),t.prototype.keyOf=function(e){return e.notificationId},Object.defineProperty(t.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._notificationCollectionEventContext.close()},t.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},t.prototype._postprocessChannelUpdateEvent=function(e,t){var n,r,a=this._messages.filter((function(t){return t.messageStatus===J.SENT&&t.createdAt<=e.myLastRead}));if(a.length>0){try{for(var i=h(a),o=i.next();!o.done;o=i.next()){o.value.messageStatus=J.READ}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}this._updateMessagesToView(a,t)}},t.prototype._postprocessMessageUpdateEvent=function(e,t){var n,r;if(t===I.EVENT_CHANNEL_READ){var a=[],i=this._messages.map((function(e){return e.notificationId}));try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var c=s.value.notificationId,u=i.indexOf(c);u>=0&&(this._messages[u].messageStatus=J.READ,a.push(this._messages[u]))}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a.length>0&&this._updateMessagesToView(a,t)}},t.prototype._addMessagesToView=function(e,t){var n,r,a=this,i=this._filterUnderOffsetMessage(e),o=[],s=[];try{for(var l=h(i),d=l.next();!d.done;d=l.next()){var f,p=d.value;if(t===I.SYNC_MESSAGE_FILL){if((f=ie(this._messages,p))<0){var v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}}else if((f=ie(this._messages,p))<0){v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}else this._messages[f]=p,s.push(p)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r,a,i;return u(this,(function(c){return e={source:t},o.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===r||r.call(n,e,this.channel,o)),s.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,e,this.channel,s)),[2]}))}))}))},t.prototype._updateMessagesToView=function(e,t){var n,r,a=this,i=[];try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var l=s.value,d=ie(this._messages,l);d>=0&&(i.push(l),this._messages[d]=l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r;return u(this,(function(a){return e={source:t},i.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,i)),[2]}))}))})),i},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._activate()];case 1:return e.sent(),[2]}}))}))},t}(se),Ge=function(e){function t(t,n){var r,a,o=this;return(o=e.call(this,t,n)||this).channelType=S.FEED,o._groupChannel=new ce(t,n),o.isCategoryFilterEnabled=null!==(r=n.is_category_filter_enabled)&&void 0!==r&&r,o.isTemplateLabelEnabled=null===(a=n.is_template_label_enabled)||void 0===a||a,o.notificationCategories=n.categories?n.categories.map((function(e){return new ve(e)})):[],o.lastMessage=n.last_message?Y(o._iid,i({channel_type:o.channelType},n.last_message)):null,o}return n(t,e),t.payloadify=function(e){var t;return i(i({},ce.payloadify(null!==(t=e._groupChannel)&&void 0!==t?t:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((function(e){return ve.payloadify(e)})),last_message:e.lastMessage?Q.payloadify(e.lastMessage):null})},Object.defineProperty(t.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var e,t;return i(i({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((function(e){return P(e)})),lastMessage:null!==(t=null===(e=this.lastMessage)||void 0===e?void 0:e.serialize())&&void 0!==t?t:null})},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},t.prototype.markAsRead=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,c,l,h,d=this;return u(this,(function(u){switch(u.label){case 0:return t=M.of(this._iid),n=t.sdkState,r=t.dispatcher,a=t.requestQueue,!(i=null==e?void 0:e.filter((function(e){return!e||e.messageStatus===J.SENT})).map((function(e){return e.notificationId})))||i.length>0?(o=new $({userId:n.userId,channelUrl:this.url,channelType:S.FEED,notificationIds:i}),[4,a.send(o)]):[3,2];case 1:s=u.sent(),c=s.as(Z),l=c.unreadMessageCount,h=c.readAt,e?("number"==typeof l&&(this._groupChannel._updateUnreadCount(l,this._groupChannel.unreadMentionCount),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)}))),e.forEach((function(e){e.messageStatus=J.READ})),r.dispatch(new F({messages:e,source:I.EVENT_CHANNEL_READ}))):(this._groupChannel._updateUnreadMemberState(n.userId,h),this._groupChannel.unreadMessageCount!==l&&(this._groupChannel._updateUnreadCount(l,0),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})))),r.dispatch(new ge({channels:[this],context:{source:I.EVENT_CHANNEL_READ}})),u.label=2;case 2:return[2]}}))}))},t.prototype.markAsClicked=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.logClicked(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.logClicked=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30)try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.logImpression=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return[2,this.logViewed(e)]}))}))},t.prototype.logViewed=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30){try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2,!0]}return[2,!1]}))}))},t.prototype.logCustom=function(e,t){return c(this,void 0,void 0,(function(){var n,r,a,i,o,s;return u(this,(function(c){if(n=M.of(this._iid).statManager,0=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(l=this._metadata.range).extends.apply(l,y([],E(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),p.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),[3,13];case 9:return o=s.sent(),p.debug("channel background sync error",o),o instanceof g&&o.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw o;case 12:return C.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(S=null===(b=m.localCacheConfig)||void 0===b?void 0:b.maxSize)&&void 0!==S?S:0,use_local_cache:m.localCacheEnabled,starting_point:0,message_init_policy:null!==(w=null===(M=t.order)||void 0===M?void 0:M.toString())&&void 0!==w?w:"",collection_id:c.userId}})),[7];case 13:return[3,15];case 14:e.hasNext=!1,e.nextToken="",s.label=15;case 15:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)o.resume();else o.pause()}))}return t.of=function(e){return Pe[e]||(Pe[e]=new t({_iid:e})),Pe[e].ref++,Pe[e]},t.clear=function(e){Pe[e]&&(Pe[e].close(),delete Pe[e])},Object.defineProperty(t.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 _e({})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,i.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new _e(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.resume=function(){var e,t,n=i.of(this._iid),a=n.logger;n.sessionManager.session.hasSession&&(a.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:""))},t.prototype.pause=function(){i.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid])},t}(),Re={},Ve=function(){function t(t){var n=t._iid,a=this;this.ref=0,this._iid=n;var r,o=i.of(this._iid),l=o.logger,u=o.sdkState,c=o.dispatcher,d=o.cacheContext,p=o.statManager;this._metadataKey=(r=u.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta")),this._subscribers=new T;var m=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new fe(m,(function(){return e(a,void 0,void 0,(function(){var e,t,n,a,r,i,o,c,h,f,m,y;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),l.debug("channel changelog sync from",null===(f=this._metadata)||void 0===f?void 0:f.token),s.label=2;case 2:s.trys.push([2,9,,12]),t={includeEmpty:!0,includeMetaData:!0},s.label=3;case 3:return s.trys.push([3,5,,6]),[4,d.preference.get(L(u.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannelChangeLogs(null!==(y=null===(m=this._metadata)||void 0===m?void 0:m.token)&&void 0!==y?y:"",t,A.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=s.sent(),r=a.updatedChannels,i=a.deletedChannelUrls,o=a.hasMore,c=a.token,this._subscribers.dispatch("progress",{updatedChannels:r,deletedChannelUrls:i,hasMore:o,token:c}),e.hasNext=o,e.nextToken=c,this._metadata&&(this._metadata.token=c),l.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),d.localCacheEnabled&&p.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:r.length>0||i.length>0?"cache_miss":"cache_hit",max_db_size:r.length,use_local_cache:d.localCacheEnabled,starting_point:0,message_init_policy:i.length.toString(),collection_id:u.userId}})),[3,12];case 9:return h=s.sent(),l.debug("channel changelog sync error",h),h instanceof g&&h.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw h;case 12:return[2,e]}}))}))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=c.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)a.resume();else a.pause()}))}return t.of=function(e){return Re[e]||(Re[e]=new t({_iid:e})),Re[e].ref++,Re[e]},t.clear=function(e){Re[e]&&(Re[e].close(),delete Re[e])},Object.defineProperty(t.prototype,"isRunning",{get:function(){return this._sync.isRunning},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e,t,n,a;return s(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=i.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.on=function(e,t){return this._subscribers.on(e,t)},t.prototype.resume=function(){i.of(this._iid).sessionManager.session.hasSession&&this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid])},t}(),Ke=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},ze=function(e,t,n){if(e.length>0){for(var a=Ke(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(o<0))return{place:s,oldPosition:a};r=s+1,s=Math.floor((r+i)/2)}}return{place:Qe(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Qe=function(e,t,n){switch(n){case Ge.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?0===(a=t.lastMessage.createdAt-e.lastMessage.createdAt)?t.createdAt-e.createdAt:a:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var a;return 0===(a=e.name.localeCompare(t.name))?e.createdAt-t.createdAt:a;default:return 0}},je=function(){function t(t,n){var a=n.filter,r=void 0===a?new ge:a,o=n.order,l=void 0===o?Ge.LATEST_LAST_MESSAGE:o,u=n.limit,c=void 0===u?ke:u,d=n.includeChangesOnInitialLoad,p=void 0!==d&&d,_=this;this.channels=[],this._isInitialized=!1,this._iid=t,this._key="gcc-".concat(I()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=r,this.order=l,this._hasMore=!0,this._token="",this._limit=c;var v=i.of(this._iid),m=v.sdkState,g=v.cacheContext,y=v.dispatcher;g.localCacheEnabled&&(this._backgroundSync=He.of(t),this._backgroundSync.resume()),this._changelogSync=Ve.of(t),this._changelogSync.resume(),ve.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(me(n)){var a=e.filter((function(e){return _.filter.match(e,m.userId)})),r=e.filter((function(e){return!_.filter.match(e,m.userId)})).map((function(e){return e.url}));a.length>0&&_._addChannelsToView(a,t),r.length>0&&_._removeChannelsFromView(r,t)}},onRemove:function(e,t){_._removeChannelsFromView(e,t)}}),y.on((function(t){t instanceof h&&(t.stateType===f.CONNECTED?_._isGetRemoteChannelsSucceeded||e(_,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):t.stateType===f.LOGOUT&&_.dispose())}))}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,n,a){var r,i,o,l,u=this;void 0===a&&(a=!1);var c=[],h=[],d=[];try{for(var p=F(t),f=p.next();!f.done;f=p.next()){var _=f.value,v=Ke(this.channels,_);v>=0&&this.channels.splice(v,1);var m=ze(this.channels,_,this.order).place;if(v<0)m===this.channels.length?!a&&this._hasMore||(c.push(_),this.channels.push(_)):(c.push(_),this.channels.splice(m,0,_));else switch(n.source){case A.EVENT_CHANNEL_UPDATED:case A.EVENT_MESSAGE_RECEIVED:case A.SYNC_CHANNEL_CHANGELOGS:case A.EVENT_MESSAGE_SENT:this.order===Ge.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&m===this.channels.length?d.push(_):(this.channels.splice(m,0,_),h.push(_));break;default:this.channels.splice(m,0,_),h.push(_)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}if(d.length>0)try{for(var g=F(d),y=g.next();!y.done;y=g.next()){_=y.value;var C=Ke(this.channels,_);-1!==C&&this.channels.splice(C,1)}}catch(e){o={error:e}}finally{try{y&&!y.done&&(l=g.return)&&l.call(g)}finally{if(o)throw o.error}}me(n.source)&&N((function(){return e(u,void 0,void 0,(function(){var e,t,a;return s(this,(function(r){return c.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(n,c),h.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,h),d.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,d.map((function(e){return e.url}))),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,n){var a,r,i=this,o=[],l=function(e){var t=u.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(u.channels[t].url),u.channels.splice(t,1))},u=this;try{for(var c=F(t),h=c.next();!h.done;h=c.next()){l(h.value)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(a)throw a.error}}return me(n.source)&&o.length>0&&N((function(){return e(i,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=ve.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.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()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(a){switch(a.label){case 0:return[4,ve.of(this._iid).getMyGroupChannels(this._token,R(z(z({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},t.prototype._revokeLoadMore=function(){return e(this,void 0,void 0,(function(){var e;return s(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,{source:A.REQUEST_CHANNEL},!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},t.prototype.loadMore=function(){var t;return e(this,void 0,void 0,(function(){var n,a,r,o,l,u,c,h,d,p,f,_,m,y,C,b,S,M,E,w=this;return s(this,(function(L){switch(L.label){case 0:if(this._isDisposed)throw new g({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return n=null,this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning?[4,new Promise((function(e){w._changelogSyncSubscriberContext=w._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}))]:[3,2];case 1:n=L.sent(),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close(),L.label=2;case 2:return a=i.of(this._iid),r=a.cacheContext,o=a.connectionManager,l=a.statManager,this._isInitialized?[3,5]:(this._isInitialized=!0,r.localCacheEnabled?[4,this._backgroundSync.loadMetadata()]:[3,4]);case 3:L.sent(),L.label=4;case 4:l.put(new B({type:v.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{group_channel:!0}}})),L.label=5;case 5:return u=[],this._hasMore?!r.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed?[3,7]:[4,Z((function(){return e(w,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return u=e.sent(),[2]}}))}))}))]:[3,11];case 6:return L.sent(),this._hasMore=u.length>=this._limit,[3,10];case 7:return L.trys.push([7,9,,10]),[4,this._getRemoteChannels()];case 8:return u=L.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,10];case 9:return L.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,10];case 10:this._addChannelsToView(u,{source:A.REQUEST_CHANNEL},!0),L.label=11;case 11:if(n){try{for(c=F(n.updatedChannels),h=c.next();!h.done;h=c.next())d=h.value,(C=Ke(u,d))>=0?u[C]=d:(p=ze(u,d,this.order).place,u.splice(p,0,d))}catch(e){b={error:e}}finally{try{h&&!h.done&&(S=c.return)&&S.call(c)}finally{if(b)throw b.error}}f=u.map((function(e){return e.url}));try{for(_=F(n.deletedChannelUrls),m=_.next();!m.done;m=_.next())y=m.value,(C=f.indexOf(y))>=0&&(u.splice(C,1),f.splice(C,1))}catch(e){M={error:e}}finally{try{m&&!m.done&&(E=_.return)&&E.call(_)}finally{if(M)throw M.error}}}return[2,u]}}))}))},t.prototype.dispose=function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),ve.of(this._iid).unsubscribeChannelEvent(this._key))},t}(),We=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,_=t.metadataValues,v=t.metadataValueStartsWith,m=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=ee.GET,n.path=te,n.params=ne(R({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:ye.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:_,metadata_value_startswith:v,show_frozen:m,show_metadata:g})),n}return $(t,e),t}(ae),Be=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new Ce(t,e)}))),a.ts="number"==typeof s?s:0,a}return $(t,e),t}(re);!function(e){e.ALL="all",e.JOINED="joined"}(De||(De={}));var qe=function(t){function n(e,n){var a,r,i,s,o,l,u,c,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=De.ALL,m.superChannelFilter=Se.ALL,m.metadataKey=null,m.metadataValues=null,m.metadataOrderKeyFilter=null,m.metadataValueStartsWith=null,m.order=Ue.CHRONOLOGICAL,m.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,m.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,m.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,m.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,m.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,m.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,m.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,m.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:De.ALL,m.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Se.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:Ue.CHRONOLOGICAL,m}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("boolean",this.includeEmpty)&&ie("boolean",this.includeFrozen)&&ie("boolean",this.includeMetaData)&&ie("string",this.channelNameContainsFilter,!0)&&se("string",this.channelUrlsFilter,!0)&&se("string",this.customTypesFilter,!0)&&ie("string",this.customTypeStartsWithFilter,!0)&&oe(De,this.membershipFilter)&&oe(Se,this.superChannelFilter)&&oe(Ue,this.order)&&ie("string",this.metadataOrderKeyFilter,!0)&&ie("string",this.metadataKey,!0)&&se("string",this.metadataValues,!0)&&ie("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o,l;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=i.of(this._iid).requestQueue,n=new We(R(z(z({},this),{token:this._token}))),[4,t.send(n)]):[3,2]):[3,5];case 1:return a=s.sent(),r=a.as(Be),o=r.channels,l=r.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),Ye=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 $(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=ue,t.onUserLeft=ue,t.onUserReceivedInvitation=ue,t.onUserDeclinedInvitation=ue,t.onChannelHidden=ue,t.onUnreadMemberStatusUpdated=ue,t.onUndeliveredMemberStatusUpdated=ue,t.onTypingStatusUpdated=ue,t.onPollUpdated=ue,t.onPollVoted=ue,t.onPollDeleted=ue,t.onPinnedMessageUpdated=ue,t}return $(t,e),t}(Ie)),Xe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=ee.GET,n.path="".concat(ce),n.params=ne(R({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return $(t,e),t}(ae),Je=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return Ne(t,e)})),a}return $(t,e),t}(re),Ze=function(t){function n(e,n){var a,r,i,s,o,l=this;return(l=t.call(this,e,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=he.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:he.ALL,l}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("string",this.channelUrl,!0)&&(oe(Oe,this.order)||null===this.order)&&ie("boolean",this.reverse)&&(se(xe,this.scheduledStatus)||null===this.scheduledStatus)&&oe(he,this.messageTypeFilter)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=i.of(this._iid).requestQueue,t=new Xe(R(z(z({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),a=n.as(Je),r=a.scheduledMessages,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),$e=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return $(n,t),n.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new ve(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new je(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Me(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ze(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){de(ie("string",e)&&t instanceof Ye).throw(g.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){de(ie("string",e)).throw(g.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(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannel(t)]}))}))},n.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("string",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("number",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},we),t),de(Le(e)).throw(g.invalidParameters),[2,this._manager.getGroupChannelCount(e)]}))}))},n.prototype.getUnreadItemCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getUnreadItemCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(t)];case 1:return[2,e.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(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),[2,this._manager.createChannel(e)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),e&&(e.isDistinct=!0),[2,this.createChannel(e)]}))}))},n.prototype.createChannelWithUserIds=function(t,n,a,r,i,o){return void 0===n&&(n=!1),void 0===i&&(i=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return s(this,(function(s){return e=z(z({},Te),{invitedUserIds:t,isDistinct:n,name:a,data:i,customType:o}),"string"==typeof r?e.coverUrl=r:e.coverImage=r,[2,this.createChannel(e)]}))}))},n.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(se("string",t)).throw(g.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},n.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return de(ie("string",t)).throw(g.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},n}(pe);export{je as GroupChannelCollection,Ye as GroupChannelHandler,$e as GroupChannelModule,De as MembershipFilter,qe as PublicGroupChannelListQuery,Ze as ScheduledMessageListQuery}; +import{_ as e,V as i,b as s,D as h,F as f,b9 as _,ba as v,s as g,p as y,q as E,a2 as A,K as L,E as T,t as F,G as N,n as I,u as R,g as z,bb as B,a8 as J,B as Z,c as $,A as ee,az as te,e as ne,f as ae,h as re,a as ie,Q as se,X as oe,aO as le,aA as ue,bc as ce,aq as he,w as de,a_ as pe}from"./lib/__bundle-c03282ec.js";export{bd as MessageEventSource,be as MutedState}from"./lib/__bundle-c03282ec.js";import{S as fe,T as _e,G as ve,s as me,a as ge,P as ye,b as Ce,c as Se,d as Me,e as Ee,v as Ae,f as we,g as Le,h as Te,i as Fe}from"./lib/__bundle-03052043.js";export{C as CountPreference,D as DeliveryStatus,b as GroupChannel,j as GroupChannelEventSource,a as GroupChannelFilter,d as GroupChannelListQuery,k as GroupChannelSearchField,H as HiddenChannelFilter,l as HiddenState,M as Member,m as MemberListOrder,n as MemberListQuery,o as MemberState,p as MemberStateFilter,r as MessageCollection,t as MessageCollectionInitHandler,u as MessageCollectionInitPolicy,w as MutedMemberFilter,q as MyMemberStateFilter,O as OperatorFilter,P as PublicChannelFilter,Q as QueryType,c as SuperChannelFilter,U as UnreadChannelFilter,x as UnreadItemKey}from"./lib/__bundle-03052043.js";import{Q as ke,T as Ne,V as xe}from"./lib/__bundle-45809bc9.js";export{K as MessageFilter,W as PinnedMessage,X as PinnedMessageListQuery,Y as ReadStatus,V as ScheduledStatus}from"./lib/__bundle-45809bc9.js";import{G as Ge,P as Ue,S as Oe}from"./lib/__bundle-1a7e946b.js";export{G as GroupChannelListOrder,P as PublicGroupChannelListOrder,S as ScheduledMessageListOrder}from"./lib/__bundle-1a7e946b.js";import{B as Ie}from"./lib/__bundle-75f48c2c.js";import"./lib/__bundle-5dbd9d35.js";import"./lib/__bundle-acd77193.js";var De,Pe={},He=function(){function t(t){var n=t._iid,a=t.limit,r=void 0===a?100:a,o=this;this.ref=0,this._iid=n,this._limit=r;var l,u=i.of(this._iid),c=u.sdkState,d=u.dispatcher,p=u.logger,m=u.cacheContext,C=u.statManager;this._metadataKey=(l=c.userId,"sendbird:".concat(l,"@groupchannel/sync.meta"));var b=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(c.userId);this._sync=new fe(b,(function(){return e(o,void 0,void 0,(function(){var e,t,n,a,r,i,o,l,u,h,d,f,b,S,M,w;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(s.sent(),p.debug("channel background sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),null===(h=this._metadata)||void 0===h?void 0:h.completed)return[3,14];t={includeEmpty:!0,includeMetaData:!0,order:Ge.CHRONOLOGICAL},s.label=2;case 2:if(s.trys.push([2,9,12,13]),t.order!==Ge.LATEST_LAST_MESSAGE)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,m.preference.get(L(c.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannels(null!==(f=null===(d=this._metadata)||void 0===d?void 0:d.token)&&void 0!==f?f:"",t,this._limit,A.SYNC_CHANNEL_BACKGROUND)];case 7:return a=s.sent(),r=a.channels,i=a.token,e.hasNext=r.length>=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(l=this._metadata.range).extends.apply(l,y([],E(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),p.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),[3,13];case 9:return o=s.sent(),p.debug("channel background sync error",o),o instanceof g&&o.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw o;case 12:return C.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(S=null===(b=m.localCacheConfig)||void 0===b?void 0:b.maxSize)&&void 0!==S?S:0,use_local_cache:m.localCacheEnabled,starting_point:0,message_init_policy:null!==(w=null===(M=t.order)||void 0===M?void 0:M.toString())&&void 0!==w?w:"",collection_id:c.userId}})),[7];case 13:return[3,15];case 14:e.hasNext=!1,e.nextToken="",s.label=15;case 15:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)o.resume();else o.pause()}))}return t.of=function(e){return Pe[e]||(Pe[e]=new t({_iid:e})),Pe[e].ref++,Pe[e]},t.clear=function(e){Pe[e]&&(Pe[e].close(),delete Pe[e])},Object.defineProperty(t.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 _e({})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,i.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new _e(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.resume=function(){var e,t,n=i.of(this._iid),a=n.logger;n.sessionManager.session.hasSession&&(a.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:""))},t.prototype.pause=function(){i.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid])},t}(),Re={},Ve=function(){function t(t){var n=t._iid,a=this;this.ref=0,this._iid=n;var r,o=i.of(this._iid),l=o.logger,u=o.sdkState,c=o.dispatcher,d=o.cacheContext,p=o.statManager;this._metadataKey=(r=u.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta")),this._subscribers=new T;var m=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new fe(m,(function(){return e(a,void 0,void 0,(function(){var e,t,n,a,r,i,o,c,h,f,m,y;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),l.debug("channel changelog sync from",null===(f=this._metadata)||void 0===f?void 0:f.token),s.label=2;case 2:s.trys.push([2,9,,12]),t={includeEmpty:!0,includeMetaData:!0},s.label=3;case 3:return s.trys.push([3,5,,6]),[4,d.preference.get(L(u.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannelChangeLogs(null!==(y=null===(m=this._metadata)||void 0===m?void 0:m.token)&&void 0!==y?y:"",t,A.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=s.sent(),r=a.updatedChannels,i=a.deletedChannelUrls,o=a.hasMore,c=a.token,this._subscribers.dispatch("progress",{updatedChannels:r,deletedChannelUrls:i,hasMore:o,token:c}),e.hasNext=o,e.nextToken=c,this._metadata&&(this._metadata.token=c),l.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),d.localCacheEnabled&&p.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:r.length>0||i.length>0?"cache_miss":"cache_hit",max_db_size:r.length,use_local_cache:d.localCacheEnabled,starting_point:0,message_init_policy:i.length.toString(),collection_id:u.userId}})),[3,12];case 9:return h=s.sent(),l.debug("channel changelog sync error",h),h instanceof g&&h.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw h;case 12:return[2,e]}}))}))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=c.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)a.resume();else a.pause()}))}return t.of=function(e){return Re[e]||(Re[e]=new t({_iid:e})),Re[e].ref++,Re[e]},t.clear=function(e){Re[e]&&(Re[e].close(),delete Re[e])},Object.defineProperty(t.prototype,"isRunning",{get:function(){return this._sync.isRunning},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e,t,n,a;return s(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=i.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.on=function(e,t){return this._subscribers.on(e,t)},t.prototype.resume=function(){i.of(this._iid).sessionManager.session.hasSession&&this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid])},t}(),Ke=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},ze=function(e,t,n){if(e.length>0){for(var a=Ke(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(o<0))return{place:s,oldPosition:a};r=s+1,s=Math.floor((r+i)/2)}}return{place:Qe(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Qe=function(e,t,n){switch(n){case Ge.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?0===(a=t.lastMessage.createdAt-e.lastMessage.createdAt)?t.createdAt-e.createdAt:a:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var a;return 0===(a=e.name.localeCompare(t.name))?e.createdAt-t.createdAt:a;default:return 0}},je=function(){function t(t,n){var a=n.filter,r=void 0===a?new ge:a,o=n.order,l=void 0===o?Ge.LATEST_LAST_MESSAGE:o,u=n.limit,c=void 0===u?ke:u,d=n.includeChangesOnInitialLoad,p=void 0!==d&&d,_=this;this.channels=[],this._isInitialized=!1,this._iid=t,this._key="gcc-".concat(I()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=r,this.order=l,this._hasMore=!0,this._token="",this._limit=c;var v=i.of(this._iid),m=v.sdkState,g=v.cacheContext,y=v.dispatcher;g.localCacheEnabled&&(this._backgroundSync=He.of(t),this._backgroundSync.resume()),this._changelogSync=Ve.of(t),this._changelogSync.resume(),ve.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(me(n)){var a=e.filter((function(e){return _.filter.match(e,m.userId)})),r=e.filter((function(e){return!_.filter.match(e,m.userId)})).map((function(e){return e.url}));a.length>0&&_._addChannelsToView(a,t),r.length>0&&_._removeChannelsFromView(r,t)}},onRemove:function(e,t){_._removeChannelsFromView(e,t)}}),y.on((function(t){t instanceof h&&(t.stateType===f.CONNECTED?_._isGetRemoteChannelsSucceeded||e(_,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):t.stateType===f.LOGOUT&&_.dispose())}))}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,n,a){var r,i,o,l,u=this;void 0===a&&(a=!1);var c=[],h=[],d=[];try{for(var p=F(t),f=p.next();!f.done;f=p.next()){var _=f.value,v=Ke(this.channels,_);v>=0&&this.channels.splice(v,1);var m=ze(this.channels,_,this.order).place;if(v<0)m===this.channels.length?!a&&this._hasMore||(c.push(_),this.channels.push(_)):(c.push(_),this.channels.splice(m,0,_));else switch(n.source){case A.EVENT_CHANNEL_UPDATED:case A.EVENT_MESSAGE_RECEIVED:case A.SYNC_CHANNEL_CHANGELOGS:case A.EVENT_MESSAGE_SENT:this.order===Ge.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&m===this.channels.length?d.push(_):(this.channels.splice(m,0,_),h.push(_));break;default:this.channels.splice(m,0,_),h.push(_)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}if(d.length>0)try{for(var g=F(d),y=g.next();!y.done;y=g.next()){_=y.value;var C=Ke(this.channels,_);-1!==C&&this.channels.splice(C,1)}}catch(e){o={error:e}}finally{try{y&&!y.done&&(l=g.return)&&l.call(g)}finally{if(o)throw o.error}}me(n.source)&&N((function(){return e(u,void 0,void 0,(function(){var e,t,a;return s(this,(function(r){return c.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(n,c),h.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,h),d.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,d.map((function(e){return e.url}))),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,n){var a,r,i=this,o=[],l=function(e){var t=u.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(u.channels[t].url),u.channels.splice(t,1))},u=this;try{for(var c=F(t),h=c.next();!h.done;h=c.next()){l(h.value)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(a)throw a.error}}return me(n.source)&&o.length>0&&N((function(){return e(i,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=ve.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.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()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(a){switch(a.label){case 0:return[4,ve.of(this._iid).getMyGroupChannels(this._token,R(z(z({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},t.prototype._revokeLoadMore=function(){return e(this,void 0,void 0,(function(){var e;return s(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,{source:A.REQUEST_CHANNEL},!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},t.prototype.loadMore=function(){var t;return e(this,void 0,void 0,(function(){var n,a,r,o,l,u,c,h,d,p,f,_,m,y,C,b,S,M,E,w=this;return s(this,(function(L){switch(L.label){case 0:if(this._isDisposed)throw new g({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return n=null,this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning?[4,new Promise((function(e){w._changelogSyncSubscriberContext=w._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}))]:[3,2];case 1:n=L.sent(),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close(),L.label=2;case 2:return a=i.of(this._iid),r=a.cacheContext,o=a.connectionManager,l=a.statManager,this._isInitialized?[3,5]:(this._isInitialized=!0,r.localCacheEnabled?[4,this._backgroundSync.loadMetadata()]:[3,4]);case 3:L.sent(),L.label=4;case 4:l.put(new B({type:v.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{group_channel:!0}}})),L.label=5;case 5:return u=[],this._hasMore?!r.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed?[3,7]:[4,Z((function(){return e(w,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return u=e.sent(),[2]}}))}))}))]:[3,11];case 6:return L.sent(),this._hasMore=u.length>=this._limit,[3,10];case 7:return L.trys.push([7,9,,10]),[4,this._getRemoteChannels()];case 8:return u=L.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,10];case 9:return L.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,10];case 10:this._addChannelsToView(u,{source:A.REQUEST_CHANNEL},!0),L.label=11;case 11:if(n){try{for(c=F(n.updatedChannels),h=c.next();!h.done;h=c.next())d=h.value,(C=Ke(u,d))>=0?u[C]=d:(p=ze(u,d,this.order).place,u.splice(p,0,d))}catch(e){b={error:e}}finally{try{h&&!h.done&&(S=c.return)&&S.call(c)}finally{if(b)throw b.error}}f=u.map((function(e){return e.url}));try{for(_=F(n.deletedChannelUrls),m=_.next();!m.done;m=_.next())y=m.value,(C=f.indexOf(y))>=0&&(u.splice(C,1),f.splice(C,1))}catch(e){M={error:e}}finally{try{m&&!m.done&&(E=_.return)&&E.call(_)}finally{if(M)throw M.error}}}return[2,u]}}))}))},t.prototype.dispose=function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),ve.of(this._iid).unsubscribeChannelEvent(this._key))},t}(),We=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,_=t.metadataValues,v=t.metadataValueStartsWith,m=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=ee.GET,n.path=te,n.params=ne(R({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:ye.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:_,metadata_value_startswith:v,show_frozen:m,show_metadata:g})),n}return $(t,e),t}(ae),Be=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new Ce(t,e)}))),a.ts="number"==typeof s?s:0,a}return $(t,e),t}(re);!function(e){e.ALL="all",e.JOINED="joined"}(De||(De={}));var qe=function(t){function n(e,n){var a,r,i,s,o,l,u,c,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=De.ALL,m.superChannelFilter=Se.ALL,m.metadataKey=null,m.metadataValues=null,m.metadataOrderKeyFilter=null,m.metadataValueStartsWith=null,m.order=Ue.CHRONOLOGICAL,m.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,m.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,m.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,m.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,m.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,m.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,m.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,m.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:De.ALL,m.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Se.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:Ue.CHRONOLOGICAL,m}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("boolean",this.includeEmpty)&&ie("boolean",this.includeFrozen)&&ie("boolean",this.includeMetaData)&&ie("string",this.channelNameContainsFilter,!0)&&se("string",this.channelUrlsFilter,!0)&&se("string",this.customTypesFilter,!0)&&ie("string",this.customTypeStartsWithFilter,!0)&&oe(De,this.membershipFilter)&&oe(Se,this.superChannelFilter)&&oe(Ue,this.order)&&ie("string",this.metadataOrderKeyFilter,!0)&&ie("string",this.metadataKey,!0)&&se("string",this.metadataValues,!0)&&ie("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o,l;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=i.of(this._iid).requestQueue,n=new We(R(z(z({},this),{token:this._token}))),[4,t.send(n)]):[3,2]):[3,5];case 1:return a=s.sent(),r=a.as(Be),o=r.channels,l=r.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),Ye=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 $(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=ue,t.onUserLeft=ue,t.onUserReceivedInvitation=ue,t.onUserDeclinedInvitation=ue,t.onChannelHidden=ue,t.onUnreadMemberStatusUpdated=ue,t.onUndeliveredMemberStatusUpdated=ue,t.onTypingStatusUpdated=ue,t.onPollUpdated=ue,t.onPollVoted=ue,t.onPollDeleted=ue,t.onPinnedMessageUpdated=ue,t}return $(t,e),t}(Ie)),Xe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=ee.GET,n.path="".concat(ce),n.params=ne(R({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return $(t,e),t}(ae),Je=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return Ne(t,e)})),a}return $(t,e),t}(re),Ze=function(t){function n(e,n){var a,r,i,s,o,l=this;return(l=t.call(this,e,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=he.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:he.ALL,l}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("string",this.channelUrl,!0)&&(oe(Oe,this.order)||null===this.order)&&ie("boolean",this.reverse)&&(se(xe,this.scheduledStatus)||null===this.scheduledStatus)&&oe(he,this.messageTypeFilter)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=i.of(this._iid).requestQueue,t=new Xe(R(z(z({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),a=n.as(Je),r=a.scheduledMessages,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),$e=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return $(n,t),n.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new ve(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new je(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Me(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ze(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){de(ie("string",e)&&t instanceof Ye).throw(g.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){de(ie("string",e)).throw(g.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(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannel(t)]}))}))},n.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("string",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("number",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},we),t),de(Le(e)).throw(g.invalidParameters),[2,this._manager.getGroupChannelCount(e)]}))}))},n.prototype.getUnreadItemCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getUnreadItemCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(t)];case 1:return[2,e.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(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),[2,this._manager.createChannel(e)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),e&&(e.isDistinct=!0),[2,this.createChannel(e)]}))}))},n.prototype.createChannelWithUserIds=function(t,n,a,r,i,o){return void 0===n&&(n=!1),void 0===i&&(i=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return s(this,(function(s){return e=z(z({},Te),{invitedUserIds:t,isDistinct:n,name:a,data:i,customType:o}),"string"==typeof r?e.coverUrl=r:e.coverImage=r,[2,this.createChannel(e)]}))}))},n.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(se("string",t)).throw(g.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},n.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return de(ie("string",t)).throw(g.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},n}(pe);export{je as GroupChannelCollection,Ye as GroupChannelHandler,$e as GroupChannelModule,De as MembershipFilter,qe as PublicGroupChannelListQuery,Ze as ScheduledMessageListQuery}; diff --git a/index.js b/index.js index 537fa15..e4d8443 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -import{i as e,a as t,_ as i,b as a,C as u,c,E as d,A as l,d as h,e as f,u as p,f as v,U as g,g as m,h as b,P as _,j as w,k,l as I,m as A,S as N,L as M,n as Q,o as j,V as q,p as x,q as K,v as W,r as V,s as Z,t as X,w as ee,x as te,y as ne,z as re,B as ie,D as se,F as oe,W as ae,G as ue,H as ce,I as de,J as le,K as he,M as fe,N as pe,O as ve,Q as ge,R as me,T as be,X as _e,Y as ye,Z as we,$ as ke,a0 as Se}from"./lib/__bundle-1db3fd0b.js";export{a1 as AppInfo,a3 as CachedChannelInfo,a4 as CachedDataClearOrder,C as ChannelType,a2 as CollectionEventSource,r as ConnectionState,Y as DeviceOsPlatform,a5 as LastMessageThreadingPolicy,L as LocalCacheConfig,a6 as NotificationInfo,a0 as PushTemplate,T as PushTokenRegistrationState,P as PushTokenType,$ as PushTriggerOption,a7 as Role,S as SendbirdChatOptions,s as SendbirdError,a8 as SendbirdErrorCode,ad as SendbirdPlatform,ac as SendbirdProduct,a9 as UIKitConfigInfo,aa as UnreadCountThreadingPolicy,U as User,ab as UserOnlineState}from"./lib/__bundle-1db3fd0b.js";import{N as Ie,a as Ce,b as Ee,c as Te,g as Pe,M as De,d as Ue,e as Oe,f as Ae,h as Ne,i as Me,j as Le,k as Re,l as ze,m as Qe,L as je,n as Fe,o as qe,p as He,A as xe,I as Ke,q as Ge,U as We,C as Ve,r as Be,B as Je,F as Ye,s as Ze,S as $e,t as Xe,u as et,v as tt,w as nt,x as rt}from"./lib/__bundle-e1a5e3f1.js";export{r as ApplicationUserListQuery,y as BannedUserListQuery,z as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,n as LogLevel,o as MemoryStore,D as MutedUserListQuery,O as OperatorListQuery,P as Participant,E as Plugin,R as ReportCategory,G as RestrictedUser,H as RestrictionInfo,J as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-e1a5e3f1.js";import{PollModule as it}from"./poll.js";import{g as st,G as ot,A as at,U as ut,a as ct,b as dt,D as lt,R as ht}from"./lib/__bundle-24f017be.js";import{g as ft,N as pt}from"./lib/__bundle-31d4ecef.js";import"./lib/__bundle-acd77193.js";var vt=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 vt(e)})):[]},mt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new gt(e)})):[]},bt={profileImage:void 0,profileUrl:void 0,nickname:void 0},_t=function(e){return function(t,n){return i(void 0,void 0,void 0,(function(){var r,s,o,c;return a(this,(function(d){switch(d.label){case 0:switch(t){case 1:case 2:case 3:case 4:return[3,1];case 5:return[3,2];case 6:return[3,4]}return[3,11];case 1:return n(),[3,12];case 2:return[4,e.reset()];case 3:return d.sent(),n(),[3,12];case 4:return d.trys.push([4,9,,10]),r=function(e){return{v2:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Ce,keyName:Ee,index:[st(ot.LATEST_LAST_MESSAGE),st(ot.CHRONOLOGICAL),st(ot.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Ie,keyName:Te,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ue,keyName:Oe,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ae,keyName:Ne}])];case 1:return[2,t.sent()]}}))}))},v3:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Me,keyName:Le,index:[ft("latest_last_message")]}])];case 1:return[2,t.sent()]}}))}))},v4:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Re,keyName:ze,index:[Qe()]}])];case 1:return[2,t.sent()]}}))}))}}}(e),s=r.v2,o=r.v3,c=r.v4,[4,s()];case 5:return d.sent(),[4,o()];case 6:return d.sent(),[4,c()];case 7:return d.sent(),[4,e.collection(Ie).removeIf({where:{channelType:u.OPEN}})];case 8:case 9:return d.sent(),[3,10];case 10:return n(),[3,12];case 11:n(),d.label=12;case 12:return[2]}}))}))}},yt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},wt=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?yt: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 c(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}(d),kt=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 i(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:l.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),St=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=l.PUT,a.path="".concat(h,"/").concat(encodeURIComponent(n)),a.params=f(p({nickname:r,profile_url:i,profile_file:s,preferred_languages:o})),a}return c(t,e),t}(v),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,m({},n)),r}return c(t,e),t}(b),Ct=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),a.params=f({apns_device_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Et=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),a.params=f({gcm_reg_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Pt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Dt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ut=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ot=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=l.GET,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return c(t,e),t}(v),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?_[n.type.toLowerCase()]:_.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return c(t,e),t}(b),Nt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return c(t,e),t}(v),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(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=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return c(t,e),t}(v),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(t,e),t}(b),zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Qt=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 c(t,e),t}(b),jt=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=l.PUT,c.path="".concat(h,"/").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 c(t,e),t}(v),Ft=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 c(t,e),t}(b),qt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Ht=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 c(t,e),t}(b),xt=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=l.PUT,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return c(t,e),t}(v),Kt=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 c(t,e),t}(b),Gt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,n),r}c(t,e)}(b);var Wt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var Vt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Jt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return c(t,e),t}(v),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),r}return c(t,e),t}(v),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),Xt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return c(t,e),t}(v),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),tn=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.GET,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return c(t,e),t}(v),nn=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 g(t,e)})),updatedUsers:n.updated.map((function(e){return new g(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return c(t,e),t}(b),rn=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").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 c(t,e),t}(v),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return c(t,e),t}(b),on=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var an=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new g(t,e)})),r}return c(t,e),t}(b),cn=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var dn=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return c(t,e),t}(v),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return c(t,e),t}(b),hn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var fn,pn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path=w,t}return c(t,e),t}(v),vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new mt(n),r}return c(t,e),t}(b),gn=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(w,"/").concat(n),r}return c(t,e),t}(v),mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new gt(n),r}return c(t,e),t}(b),bn=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(k,"/").concat(n),r}return c(t,e),t}(v),_n=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new vt(n),r}return c(t,e),t}(b),yn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path="".concat(I),t}return c(t,e),t}(v),wn=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 c(t,e),t}(b);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(fn||(fn={}));var kn,Sn=function(e){function t(t){var n=t.deviceToken,r=t.pushTrackingId,i=t.messageId,s=t.allowedPushNotification,o=t.channelKey,a=t.templateKey,u=t.eventType,c=t.notificationEventDeadline,d=e.call(this)||this;return d.method=l.POST,d.path=A,d.params=f({device_token:n,push_tracking_id:r,message_id:i,allowed_push_notification:s,channel_key:o,template_key:a,event_type:u,notification_event_deadline:c}),d}return c(t,e),t}(v);var In=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var s=q.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,d=s.sessionManager,l=s.requestQueue,h=s.logger,f=s.userEventHandlers,p=s.appStateToggleEnabled;this._onlineDetector=new kt({logger:h,connectionDelegate:{reconnect:function(){return i(r,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:if(t=q.of(e),n=t.sdkState,r=t.connectionManager,(i=t.sessionManager).session.hasSession)return[3,5];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.connect(i.session.authToken)];case 2:return a.sent(),[3,4];case 3:if(s=a.sent(),ve(s))throw s;return h.debug("connect failed by reconnect event = ",s),[3,4];case 4:return[3,9];case 5:if("foreground"!==n.appState)return[3,9];a.label=6;case 6:return a.trys.push([6,8,,9]),[4,r.resetAndReconnect()];case 7:return a.sent(),[3,9];case 8:if(o=a.sent(),ve(o))throw o;return h.debug("resetAndReconnect failed by reconnect event = ",o),[3,9];case 9:return c.dispatch(new pt),[2]}}))}))},disconnect:function(){ie((function(){return i(r,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,q.of(e).connectionManager.disconnect()];case 1:return t.sent(),[2]}}))}))}))}}});var v=new at(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,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 wt({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){var n;if(t instanceof se){if(t.stateType===oe.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof ae){if("USEV"===t.code){var s=t.as(ut).event;if(s.category===ct.FRIEND_DISCOVERED){var c=dt.getDataAsFriendDiscoveredEvent(e,s).friendDiscoveries;ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ce){var d=q.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;"number"==typeof p&&p>d.ts&&(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){d.customTypes[e]!==t.customTypes[e]&&(l=!0),d.customTypes[e]=t.customTypes[e]})),l=l&&d.ts>0,d.ts=p),l&&ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof de?(u.preference.set(r._getUserProfileCacheKey(o.userId),le.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(he(r.appId),{value:!0})):t instanceof fe&&t.error&&t.error.isSessionInvalidatedError&&(h.debug("session revoked."),r._internalDisconnect(t.error))}))}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 N: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,g=void 0!==v&&v,m=e.localCacheConfig,b=void 0===m?new M:m,_=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,k=e.useMMKVStorageStore,S=void 0===k?null:k,I=e.appStateToggleEnabled,C=void 0===I||I;if(!kn||f){var E="su-".concat(Q()),T=null!=_?_:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new je;P.level=null!=p?p:Fe.WARN;var D=new qe({encryption:T});c||(j()?S?D=new He({MMKV:S,encryption:T}):w&&(D=new xe({AsyncStorage:w,encryption:T}),P.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):D=new Ke({encryption:T})),new q(E,{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:D,encryption:T,logger:P,localCacheEnabled:g,localCacheConfig:b,debugMode:c,appStateToggleEnabled:C});var U=[new Ge,new it],O=new n(E,a,x(x([],K(s),!1),K(U),!1));return kn||(kn=O),O}return kn},Object.defineProperty(n,"instance",{get:function(){return kn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return W},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?V.OPEN:e.isConnecting?V.CONNECTING:V.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._getNestDBVersion=function(){return 7},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._internalDisconnect=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return t=q.of(this._iid),n=t.connectionManager,r=t.sdkState,i=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),[4,n.logout(e)];case 1:return s.sent(),[4,this.clearCachedData()];case 2:return s.sent(),r.appState="foreground",[2]}}))}))},n.prototype.getMemoryStoreForDebugging=function(){var e=q.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof qe?n.store:null;throw Z.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.addSendbirdExtensions=function(e,t,n){var r,i,s=q.of(this._iid),o=s.logger,a=s.sdkState,u=new RegExp(pe);if(0===e.length)return o.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return o.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=X(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=K(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return o.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return i(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 qe),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.setLocaleForChatbot=function(e){var t=q.of(this._iid).sdkState,n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(e.trim());n&&(t.localeForChatbot=n)},n.prototype.initializeCache=function(e){return i(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:if(t=q.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.dispatcher,s=t.logger,n.userId&&n.userId===e)return[3,13];o="sendbird@".concat(n.appId,"/").concat(e,".db"),a.label=1;case 1:return a.trys.push([1,9,11,13]),r.localCacheEnabled?r.nestdb&&r.nestdb.state!==tt.CLOSED&&r.nestdb.name===o?[3,3]:(u="sendbird@".concat(n.appId,"/").concat(e,".db"),(c=r.nestdb=new nt({name:u,version:this._getNestDBVersion(),store:r.store,config:new rt({dbname:u,itemSizeLimit:61440})})).on("upgrade",_t(c)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",_t(c))})),[4,c.open()]):[3,6];case 2:return a.sent(),this._storeInitialized=!0,i.dispatch(new lt(this._iid,{userId:e})),[3,5];case 3:return[4,this._safeInitializeStore(o)];case 4:a.sent(),a.label=5;case 5:return n.userId=e,[3,8];case 6:return[4,this._safeInitializeStore(o)];case 7:a.sent(),n.userId=e,a.label=8;case 8:return[3,13];case 9:return d=a.sent(),s.warn("Nest DB Open Failed. ",d),r.store instanceof qe||(r.replaceStore(new qe),r.localCacheEnabled=!1),[4,this._safeInitializeStore(o)];case 10:throw a.sent(),n.userId=e,Z.databaseError;case 11:return[4,this._setupPreference(e)];case 12:return a.sent(),[7];case 13:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return i(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 i(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 i(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=Xe.of(this._iid),n=et.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return i(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:s.sent(),s.label=2;case 2:return[2]}}))}))},n.prototype._setupPreference=function(e){return i(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.cacheContext,i=t.statManager,[4,r.preference.init(this._getPreferenceCacheKey(e),this._getNestDBVersion())];case 1:return o.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 2:return(s=o.sent())&&new le(this._iid,s).apply(),[4,i.init("sendbird@".concat(n.appId,"/").concat(e,".statlog"))];case 3:return o.sent(),[2]}}))}))},n.prototype._ready=function(e,n,r){return void 0===r&&(r={}),i(this,void 0,void 0,(function(){var i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)&&t("string",n,!0)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.cacheContext,u=i.connectionManager,c=r.errorForOtherUser,s.userId&&s.userId!==e?c?[3,2]:[4,u.logout()]:[3,3];case 1:return a.sent(),[3,3];case 2:throw c;case 3:return a.trys.push([3,5,,6]),[4,this.initializeCache(e)];case 4:return a.sent(),q.of(this._iid).dispatcher.dispatch(new ht),[3,6];case 5:return a.sent(),d=q.of(this._iid).logger,o.localCacheEnabled=!1,d.warn("Cache initialization failed - cache is not available."),[3,6];case 6:return[2]}}))}))},n.prototype.authenticateFeed=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.authenticate(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.authenticate=function(e,t){var n;return i(this,void 0,void 0,(function(){var r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return r=q.of(this._iid),i=r.sessionManager,s=r.connectionManager,[4,this._ready(e,t,{errorForOtherUser:s.isConnected?Z.alreadyConnectedAsAnotherUser:void 0})];case 1:return a.sent(),(null===(n=i.session.services)||void 0===n?void 0:n.includes(me.CHAT))?[3,3]:(t||i.handler||(o=new $e,this.setSessionHandler(o)),[4,i.authenticate(e,t)]);case 2:a.sent(),a.label=3;case 3:return[2,this.currentUser]}}))}))},n.prototype.connect=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this._ready(e,t)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,,4,5]),[4,q.of(this._iid).connectionManager.connect(t)];case 3:return n.sent(),[3,5];case 4:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 5:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._internalDisconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return i(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(!0)];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().catch((function(e){r.debug("setBackgroundState error = ",e)})))},n.prototype.setForegroundState=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,i=e.logger;"background"===n.appState&&(n.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((function(e){i.debug("setForgroundState error = ",e)})),r.dispatch(new pt))},n.prototype.setSessionHandler=function(e){ee(e instanceof $e).throw(Z.invalidParameters),q.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){ee(t("string",e)&&n instanceof We).throw(Z.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){ee(t("string",e)&&n instanceof Ve).throw(Z.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 Be(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Je(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Ye(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new Ze(this._iid,e)},n.prototype.createPollListQuery=function(e){return new te(this._iid,m({},e))},n.prototype.createPollVoterListQuery=function(e){return new ne(this._iid,m({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=re(e);return new g(this._iid,g.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=m(m({},bt),n),ee(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(Z.invalidParameters),this.currentUser?(i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new St(m({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(It).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw Z.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),this.currentUser?(t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(It).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw Z.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.ANDROID,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.FCM,e)?[2,be.SUCCESS]:(h=new Et({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.FCM,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Pt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Ut({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.IOS,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.APNS,e)?[2,be.SUCCESS]:(h=new Ct({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.APNS,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Tt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Dt({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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.markPushNotificationAsDelivered=function(e,t){var n;return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_,y,w,k;return a(this,(function(a){switch(a.label){case 0:if(r=q.of(this._iid),i=r.logger,s=r.sessionManager,o=r.requestQueue,u=r.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=fn.DELIVERED,d=u.parseData(e),l=d.pushTrackingId,h=d.sessionTopics,f=d.sessionKey,p=d.messageId,v=d.channelKey,g=d.templateKey,m=d.notificationEventDeadline,!f)throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!h.includes(we.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(u.isAcked(l,c))return i.info("already delivered push notification:",l),[2];b=Boolean(v),_=t&&b,y=null===(n=s.deviceTokens[0])||void 0===n?void 0:n.token,w=new Sn({deviceToken:null!=y?y:"",pushTrackingId:l,eventType:c,messageId:p,channelKey:v,templateKey:g,notificationEventDeadline:m,allowedPushNotification:_}),f&&(w.headers["Session-Key"]=f),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,o.send(w)];case 2:return a.sent(),u.markAsAcked(l,c),[3,4];case 3:throw k=a.sent(),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(l,". error: ").concat(k)),k;case 4:return[2]}}))}))},n.prototype.markPushNotificationAsClicked=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_;return a(this,(function(a){switch(a.label){case 0:if(n=q.of(this._iid),r=n.logger,i=n.sessionManager,s=n.requestQueue,o=n.pushNotificationAckManager,r.debug("markPushNotificationAsClicked:",e),u=fn.CLICKED,c=o.parseData(e),d=c.pushTrackingId,l=c.sessionTopics,h=c.sessionKey,f=c.messageId,p=c.channelKey,v=c.templateKey,g=c.notificationEventDeadline,!h)throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!l.includes(we.PUSH_ACKNOWLEDGEMENT))throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(o.isAcked(d,u))return r.info("already clicked push notification:",d),[2];m=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,b=new Sn({deviceToken:null!=m?m:"",pushTrackingId:d,eventType:u,messageId:f,channelKey:p,templateKey:v,notificationEventDeadline:g}),h&&(b.headers["Session-Key"]=h),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,s.send(b)];case 2:return a.sent(),o.markAsAcked(d,u),[3,4];case 3:throw _=a.sent(),r.debug("failed to mark push notification as clicked. push tracking id: ".concat(d,". error: ").concat(_)),_;case 4:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return i(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 Nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Mt).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)).throw(Z.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(Rt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return i(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 zt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Qt).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,s,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===u&&(u=""),i(this,void 0,void 0,(function(){var i,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",s)&&t("number",o)&&t("string",u)).throw(Z.invalidParameters),i=q.of(this._iid),c=i.sdkState,d=i.requestQueue,l=new jt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:s,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(Ft).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return i(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(Ht).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),i(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new xt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(Kt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return i(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 ee(t("string",e)&&_e(_,n)).throw(Z.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new Ot({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(At).pushTokens;try{for(l=X(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 i(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 Vt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Bt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(ke,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Jt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Yt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return i(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 Zt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as($t).name]}}))}))},n.prototype.setPushTemplate=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(Se,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(en).name]}}))}))},n.prototype.blockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Gt({userId:r.userId,blockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Wt({userId:r.userId,unblockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new tn({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(nn).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return i(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 dn({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ln).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(t("boolean",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new hn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return i(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 rn({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(sn).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new on({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new an({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(un).users]}}))}))},n.prototype.deleteFriend=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new cn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return i(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 pn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(vn).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return i(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 gn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(mn).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return i(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 bn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(_n).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return i(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),ee(e.hasExtension("sb_uikit")).throw(Z.notSupportedError),t=e.requestQueue,n=new yn,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(wn).uikitConfiguration]}}))}))},n}();export{vt as Emoji,gt as EmojiCategory,mt as EmojiContainer,In as default}; +import{i as e,a as t,_ as i,b as a,C as u,c,E as d,A as l,d as h,e as f,u as p,f as v,U as g,g as m,h as b,P as _,j as w,k,l as I,m as A,S as N,L as M,n as Q,o as j,V as q,p as x,q as K,v as W,r as V,s as Z,t as X,w as ee,x as te,y as ne,z as re,B as ie,D as se,F as oe,W as ae,G as ue,H as ce,I as de,J as le,K as he,M as fe,N as pe,O as ve,Q as ge,R as me,T as be,X as _e,Y as ye,Z as we,$ as ke,a0 as Se}from"./lib/__bundle-c03282ec.js";export{a1 as AppInfo,a3 as CachedChannelInfo,a4 as CachedDataClearOrder,C as ChannelType,a2 as CollectionEventSource,r as ConnectionState,Y as DeviceOsPlatform,a5 as LastMessageThreadingPolicy,L as LocalCacheConfig,a6 as NotificationInfo,a0 as PushTemplate,T as PushTokenRegistrationState,P as PushTokenType,$ as PushTriggerOption,a7 as Role,S as SendbirdChatOptions,s as SendbirdError,a8 as SendbirdErrorCode,ad as SendbirdPlatform,ac as SendbirdProduct,a9 as UIKitConfigInfo,aa as UnreadCountThreadingPolicy,U as User,ab as UserOnlineState}from"./lib/__bundle-c03282ec.js";import{N as Ie,a as Ce,b as Ee,c as Te,g as Pe,M as De,d as Ue,e as Oe,f as Ae,h as Ne,i as Me,j as Le,k as Re,l as ze,m as Qe,L as je,n as Fe,o as qe,p as He,A as xe,I as Ke,q as Ge,U as We,C as Ve,r as Be,B as Je,F as Ye,s as Ze,S as $e,t as Xe,u as et,v as tt,w as nt,x as rt}from"./lib/__bundle-45809bc9.js";export{r as ApplicationUserListQuery,y as BannedUserListQuery,z as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,n as LogLevel,o as MemoryStore,D as MutedUserListQuery,O as OperatorListQuery,P as Participant,E as Plugin,R as ReportCategory,G as RestrictedUser,H as RestrictionInfo,J as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-45809bc9.js";import{PollModule as it}from"./poll.js";import{g as st,G as ot,A as at,U as ut,a as ct,b as dt,D as lt,R as ht}from"./lib/__bundle-1a7e946b.js";import{g as ft,N as pt}from"./lib/__bundle-5f5bca4c.js";import"./lib/__bundle-acd77193.js";var vt=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 vt(e)})):[]},mt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new gt(e)})):[]},bt={profileImage:void 0,profileUrl:void 0,nickname:void 0},_t=function(e){return function(t,n){return i(void 0,void 0,void 0,(function(){var r,s,o,c;return a(this,(function(d){switch(d.label){case 0:switch(t){case 1:case 2:case 3:case 4:return[3,1];case 5:return[3,2];case 6:return[3,4]}return[3,11];case 1:return n(),[3,12];case 2:return[4,e.reset()];case 3:return d.sent(),n(),[3,12];case 4:return d.trys.push([4,9,,10]),r=function(e){return{v2:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Ce,keyName:Ee,index:[st(ot.LATEST_LAST_MESSAGE),st(ot.CHRONOLOGICAL),st(ot.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Ie,keyName:Te,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ue,keyName:Oe,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ae,keyName:Ne}])];case 1:return[2,t.sent()]}}))}))},v3:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Me,keyName:Le,index:[ft("latest_last_message")]}])];case 1:return[2,t.sent()]}}))}))},v4:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Re,keyName:ze,index:[Qe()]}])];case 1:return[2,t.sent()]}}))}))}}}(e),s=r.v2,o=r.v3,c=r.v4,[4,s()];case 5:return d.sent(),[4,o()];case 6:return d.sent(),[4,c()];case 7:return d.sent(),[4,e.collection(Ie).removeIf({where:{channelType:u.OPEN}})];case 8:case 9:return d.sent(),[3,10];case 10:return n(),[3,12];case 11:n(),d.label=12;case 12:return[2]}}))}))}},yt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},wt=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?yt: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 c(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}(d),kt=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 i(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:l.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),St=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=l.PUT,a.path="".concat(h,"/").concat(encodeURIComponent(n)),a.params=f(p({nickname:r,profile_url:i,profile_file:s,preferred_languages:o})),a}return c(t,e),t}(v),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,m({},n)),r}return c(t,e),t}(b),Ct=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),a.params=f({apns_device_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Et=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),a.params=f({gcm_reg_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Pt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Dt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ut=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ot=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=l.GET,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return c(t,e),t}(v),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?_[n.type.toLowerCase()]:_.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return c(t,e),t}(b),Nt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return c(t,e),t}(v),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(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=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return c(t,e),t}(v),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(t,e),t}(b),zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Qt=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 c(t,e),t}(b),jt=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=l.PUT,c.path="".concat(h,"/").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 c(t,e),t}(v),Ft=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 c(t,e),t}(b),qt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Ht=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 c(t,e),t}(b),xt=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=l.PUT,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return c(t,e),t}(v),Kt=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 c(t,e),t}(b),Gt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,n),r}c(t,e)}(b);var Wt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var Vt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Jt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return c(t,e),t}(v),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),r}return c(t,e),t}(v),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),Xt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return c(t,e),t}(v),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),tn=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.GET,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return c(t,e),t}(v),nn=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 g(t,e)})),updatedUsers:n.updated.map((function(e){return new g(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return c(t,e),t}(b),rn=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").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 c(t,e),t}(v),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return c(t,e),t}(b),on=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var an=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new g(t,e)})),r}return c(t,e),t}(b),cn=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var dn=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return c(t,e),t}(v),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return c(t,e),t}(b),hn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var fn,pn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path=w,t}return c(t,e),t}(v),vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new mt(n),r}return c(t,e),t}(b),gn=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(w,"/").concat(n),r}return c(t,e),t}(v),mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new gt(n),r}return c(t,e),t}(b),bn=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(k,"/").concat(n),r}return c(t,e),t}(v),_n=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new vt(n),r}return c(t,e),t}(b),yn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path="".concat(I),t}return c(t,e),t}(v),wn=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 c(t,e),t}(b);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(fn||(fn={}));var kn,Sn=function(e){function t(t){var n=t.deviceToken,r=t.pushTrackingId,i=t.messageId,s=t.allowedPushNotification,o=t.channelKey,a=t.templateKey,u=t.eventType,c=t.notificationEventDeadline,d=e.call(this)||this;return d.method=l.POST,d.path=A,d.params=f({device_token:n,push_tracking_id:r,message_id:i,allowed_push_notification:s,channel_key:o,template_key:a,event_type:u,notification_event_deadline:c}),d}return c(t,e),t}(v);var In=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var s=q.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,d=s.sessionManager,l=s.requestQueue,h=s.logger,f=s.userEventHandlers,p=s.appStateToggleEnabled;this._onlineDetector=new kt({logger:h,connectionDelegate:{reconnect:function(){return i(r,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:if(t=q.of(e),n=t.sdkState,r=t.connectionManager,(i=t.sessionManager).session.hasSession)return[3,5];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.connect(i.session.authToken)];case 2:return a.sent(),[3,4];case 3:if(s=a.sent(),ve(s))throw s;return h.debug("connect failed by reconnect event = ",s),[3,4];case 4:return[3,9];case 5:if("foreground"!==n.appState)return[3,9];a.label=6;case 6:return a.trys.push([6,8,,9]),[4,r.resetAndReconnect()];case 7:return a.sent(),[3,9];case 8:if(o=a.sent(),ve(o))throw o;return h.debug("resetAndReconnect failed by reconnect event = ",o),[3,9];case 9:return c.dispatch(new pt),[2]}}))}))},disconnect:function(){ie((function(){return i(r,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,q.of(e).connectionManager.disconnect()];case 1:return t.sent(),[2]}}))}))}))}}});var v=new at(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,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 wt({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){var n;if(t instanceof se){if(t.stateType===oe.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof ae){if("USEV"===t.code){var s=t.as(ut).event;if(s.category===ct.FRIEND_DISCOVERED){var c=dt.getDataAsFriendDiscoveredEvent(e,s).friendDiscoveries;ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ce){var d=q.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;"number"==typeof p&&p>d.ts&&(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){d.customTypes[e]!==t.customTypes[e]&&(l=!0),d.customTypes[e]=t.customTypes[e]})),l=l&&d.ts>0,d.ts=p),l&&ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof de?(u.preference.set(r._getUserProfileCacheKey(o.userId),le.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(he(r.appId),{value:!0})):t instanceof fe&&t.error&&t.error.isSessionInvalidatedError&&(h.debug("session revoked."),r._internalDisconnect(t.error))}))}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 N: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,g=void 0!==v&&v,m=e.localCacheConfig,b=void 0===m?new M:m,_=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,k=e.useMMKVStorageStore,S=void 0===k?null:k,I=e.appStateToggleEnabled,C=void 0===I||I;if(!kn||f){var E="su-".concat(Q()),T=null!=_?_:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new je;P.level=null!=p?p:Fe.WARN;var D=new qe({encryption:T});c||(j()?S?D=new He({MMKV:S,encryption:T}):w&&(D=new xe({AsyncStorage:w,encryption:T}),P.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):D=new Ke({encryption:T})),new q(E,{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:D,encryption:T,logger:P,localCacheEnabled:g,localCacheConfig:b,debugMode:c,appStateToggleEnabled:C});var U=[new Ge,new it],O=new n(E,a,x(x([],K(s),!1),K(U),!1));return kn||(kn=O),O}return kn},Object.defineProperty(n,"instance",{get:function(){return kn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return W},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?V.OPEN:e.isConnecting?V.CONNECTING:V.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._getNestDBVersion=function(){return 7},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._internalDisconnect=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return t=q.of(this._iid),n=t.connectionManager,r=t.sdkState,i=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),[4,n.logout(e)];case 1:return s.sent(),[4,this.clearCachedData()];case 2:return s.sent(),r.appState="foreground",[2]}}))}))},n.prototype.getMemoryStoreForDebugging=function(){var e=q.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof qe?n.store:null;throw Z.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.addSendbirdExtensions=function(e,t,n){var r,i,s=q.of(this._iid),o=s.logger,a=s.sdkState,u=new RegExp(pe);if(0===e.length)return o.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return o.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=X(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=K(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return o.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return i(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 qe),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.setLocaleForChatbot=function(e){var t=q.of(this._iid).sdkState,n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(e.trim());n&&(t.localeForChatbot=n)},n.prototype.initializeCache=function(e){return i(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:if(t=q.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.dispatcher,s=t.logger,n.userId&&n.userId===e)return[3,13];o="sendbird@".concat(n.appId,"/").concat(e,".db"),a.label=1;case 1:return a.trys.push([1,9,11,13]),r.localCacheEnabled?r.nestdb&&r.nestdb.state!==tt.CLOSED&&r.nestdb.name===o?[3,3]:(u="sendbird@".concat(n.appId,"/").concat(e,".db"),(c=r.nestdb=new nt({name:u,version:this._getNestDBVersion(),store:r.store,config:new rt({dbname:u,itemSizeLimit:61440})})).on("upgrade",_t(c)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",_t(c))})),[4,c.open()]):[3,6];case 2:return a.sent(),this._storeInitialized=!0,i.dispatch(new lt(this._iid,{userId:e})),[3,5];case 3:return[4,this._safeInitializeStore(o)];case 4:a.sent(),a.label=5;case 5:return n.userId=e,[3,8];case 6:return[4,this._safeInitializeStore(o)];case 7:a.sent(),n.userId=e,a.label=8;case 8:return[3,13];case 9:return d=a.sent(),s.warn("Nest DB Open Failed. ",d),r.store instanceof qe||(r.replaceStore(new qe),r.localCacheEnabled=!1),[4,this._safeInitializeStore(o)];case 10:throw a.sent(),n.userId=e,Z.databaseError;case 11:return[4,this._setupPreference(e)];case 12:return a.sent(),[7];case 13:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return i(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 i(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 i(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=Xe.of(this._iid),n=et.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return i(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:s.sent(),s.label=2;case 2:return[2]}}))}))},n.prototype._setupPreference=function(e){return i(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.cacheContext,i=t.statManager,[4,r.preference.init(this._getPreferenceCacheKey(e),this._getNestDBVersion())];case 1:return o.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 2:return(s=o.sent())&&new le(this._iid,s).apply(),[4,i.init("sendbird@".concat(n.appId,"/").concat(e,".statlog"))];case 3:return o.sent(),[2]}}))}))},n.prototype._ready=function(e,n,r){return void 0===r&&(r={}),i(this,void 0,void 0,(function(){var i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)&&t("string",n,!0)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.cacheContext,u=i.connectionManager,c=r.errorForOtherUser,s.userId&&s.userId!==e?c?[3,2]:[4,u.logout()]:[3,3];case 1:return a.sent(),[3,3];case 2:throw c;case 3:return a.trys.push([3,5,,6]),[4,this.initializeCache(e)];case 4:return a.sent(),q.of(this._iid).dispatcher.dispatch(new ht),[3,6];case 5:return a.sent(),d=q.of(this._iid).logger,o.localCacheEnabled=!1,d.warn("Cache initialization failed - cache is not available."),[3,6];case 6:return[2]}}))}))},n.prototype.authenticateFeed=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.authenticate(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.authenticate=function(e,t){var n;return i(this,void 0,void 0,(function(){var r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return r=q.of(this._iid),i=r.sessionManager,s=r.connectionManager,[4,this._ready(e,t,{errorForOtherUser:s.isConnected?Z.alreadyConnectedAsAnotherUser:void 0})];case 1:return a.sent(),(null===(n=i.session.services)||void 0===n?void 0:n.includes(me.CHAT))?[3,3]:(t||i.handler||(o=new $e,this.setSessionHandler(o)),[4,i.authenticate(e,t)]);case 2:a.sent(),a.label=3;case 3:return[2,this.currentUser]}}))}))},n.prototype.connect=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this._ready(e,t)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,,4,5]),[4,q.of(this._iid).connectionManager.connect(t)];case 3:return n.sent(),[3,5];case 4:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 5:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._internalDisconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return i(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(!0)];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().catch((function(e){r.debug("setBackgroundState error = ",e)})))},n.prototype.setForegroundState=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,i=e.logger;"background"===n.appState&&(n.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((function(e){i.debug("setForgroundState error = ",e)})),r.dispatch(new pt))},n.prototype.setSessionHandler=function(e){ee(e instanceof $e).throw(Z.invalidParameters),q.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){ee(t("string",e)&&n instanceof We).throw(Z.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){ee(t("string",e)&&n instanceof Ve).throw(Z.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 Be(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Je(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Ye(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new Ze(this._iid,e)},n.prototype.createPollListQuery=function(e){return new te(this._iid,m({},e))},n.prototype.createPollVoterListQuery=function(e){return new ne(this._iid,m({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=re(e);return new g(this._iid,g.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=m(m({},bt),n),ee(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(Z.invalidParameters),this.currentUser?(i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new St(m({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(It).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw Z.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),this.currentUser?(t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(It).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw Z.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.ANDROID,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.FCM,e)?[2,be.SUCCESS]:(h=new Et({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.FCM,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Pt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Ut({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.IOS,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.APNS,e)?[2,be.SUCCESS]:(h=new Ct({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.APNS,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Tt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Dt({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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.markPushNotificationAsDelivered=function(e,t){var n;return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_,y,w,k;return a(this,(function(a){switch(a.label){case 0:if(r=q.of(this._iid),i=r.logger,s=r.sessionManager,o=r.requestQueue,u=r.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=fn.DELIVERED,d=u.parseData(e),l=d.pushTrackingId,h=d.sessionTopics,f=d.sessionKey,p=d.messageId,v=d.channelKey,g=d.templateKey,m=d.notificationEventDeadline,!f)throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!h.includes(we.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(u.isAcked(l,c))return i.info("already delivered push notification:",l),[2];b=Boolean(v),_=t&&b,y=null===(n=s.deviceTokens[0])||void 0===n?void 0:n.token,w=new Sn({deviceToken:null!=y?y:"",pushTrackingId:l,eventType:c,messageId:p,channelKey:v,templateKey:g,notificationEventDeadline:m,allowedPushNotification:_}),f&&(w.headers["Session-Key"]=f),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,o.send(w)];case 2:return a.sent(),u.markAsAcked(l,c),[3,4];case 3:throw k=a.sent(),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(l,". error: ").concat(k)),k;case 4:return[2]}}))}))},n.prototype.markPushNotificationAsClicked=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_;return a(this,(function(a){switch(a.label){case 0:if(n=q.of(this._iid),r=n.logger,i=n.sessionManager,s=n.requestQueue,o=n.pushNotificationAckManager,r.debug("markPushNotificationAsClicked:",e),u=fn.CLICKED,c=o.parseData(e),d=c.pushTrackingId,l=c.sessionTopics,h=c.sessionKey,f=c.messageId,p=c.channelKey,v=c.templateKey,g=c.notificationEventDeadline,!h)throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!l.includes(we.PUSH_ACKNOWLEDGEMENT))throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(o.isAcked(d,u))return r.info("already clicked push notification:",d),[2];m=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,b=new Sn({deviceToken:null!=m?m:"",pushTrackingId:d,eventType:u,messageId:f,channelKey:p,templateKey:v,notificationEventDeadline:g}),h&&(b.headers["Session-Key"]=h),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,s.send(b)];case 2:return a.sent(),o.markAsAcked(d,u),[3,4];case 3:throw _=a.sent(),r.debug("failed to mark push notification as clicked. push tracking id: ".concat(d,". error: ").concat(_)),_;case 4:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return i(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 Nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Mt).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)).throw(Z.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(Rt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return i(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 zt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Qt).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,s,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===u&&(u=""),i(this,void 0,void 0,(function(){var i,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",s)&&t("number",o)&&t("string",u)).throw(Z.invalidParameters),i=q.of(this._iid),c=i.sdkState,d=i.requestQueue,l=new jt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:s,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(Ft).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return i(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(Ht).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),i(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new xt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(Kt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return i(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 ee(t("string",e)&&_e(_,n)).throw(Z.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new Ot({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(At).pushTokens;try{for(l=X(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 i(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 Vt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Bt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(ke,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Jt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Yt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return i(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 Zt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as($t).name]}}))}))},n.prototype.setPushTemplate=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(Se,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(en).name]}}))}))},n.prototype.blockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Gt({userId:r.userId,blockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Wt({userId:r.userId,unblockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new tn({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(nn).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return i(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 dn({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ln).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(t("boolean",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new hn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return i(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 rn({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(sn).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new on({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new an({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(un).users]}}))}))},n.prototype.deleteFriend=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new cn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return i(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 pn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(vn).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return i(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 gn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(mn).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return i(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 bn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(_n).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return i(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),ee(e.hasExtension("sb_uikit")).throw(Z.notSupportedError),t=e.requestQueue,n=new yn,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(wn).uikitConfiguration]}}))}))},n}();export{vt as Emoji,gt as EmojiCategory,mt as EmojiContainer,In as default}; diff --git a/lib/__bundle-03052043.js b/lib/__bundle-03052043.js new file mode 100644 index 0000000..5bd2d82 --- /dev/null +++ b/lib/__bundle-03052043.js @@ -0,0 +1 @@ +import{c as e,e as t,u as n,g as s,X as r,a7 as a,C as i,U as o,af as u,bf as c,w as l,s as h,p as d,q as _,_ as p,b as f,t as v,Q as m,a as g,i as E,aq as C,a2 as y,b8 as M,B as b,A as N,d as U,f as S,h as T,bg as A,az as I,bc as w,W as L,ak as D,bh as x,ai as R,aO as F,V as P,z as k,O,G as H,a3 as V,be as G,aM as B,aT as q,aS as z,an as j,aR as W,aW as Q,bi as Y,a8 as K,bj as J,E as X,D as Z,F as $,b9 as ee,ba as te,ay as ne,aN as se,al as re,ao as ae,bk as ie,n as oe,aA as ue,bl as ce,bb as le,aB as he,aj as de,aF as _e,a5 as pe,aa as fe,aw as ve,$ as me,aV as ge}from"./__bundle-c03282ec.js";import{G as Ee,a as Ce,Q as ye,V as Me,Z as be,t as Ne,u as Ue,_ as Se,$ as Te,a0 as Ae,a1 as Ie,a2 as we,K as Le,v as De,a3 as xe,a4 as Re,a5 as Fe,a6 as Pe,a7 as ke,a8 as Oe,a9 as He,aa as Ve,ab as Ge,ac as Be,ad as qe,ae as ze,af as je,ag as We,ah as Qe,ai as Ye,aj as Ke,ak as Je,T as Xe,al as Ze,am as $e,an as et,ao as tt,ap as nt,aq as st,ar as rt,as as at,at as it,Y as ot,au as ut,av as ct,aw as lt,ax as ht,ay as dt,az as _t,aA as pt,aB as ft,z as vt,aC as mt,aD as gt,aE as Et,aF as Ct,aG as yt,aH as Mt,aI as bt,aJ as Nt,aK as Ut}from"./__bundle-45809bc9.js";import{G as St,g as Tt,D as At,c as It,R as wt,U as Lt,a as Dt,b as xt,A as Rt}from"./__bundle-1a7e946b.js";import{C as Ft,B as Pt,U as kt,a as Ot,O as Ht,P as Vt,M as Gt,T as Bt,R as qt,b as zt,A as jt}from"./__bundle-5dbd9d35.js";var Wt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Wt||(Wt={}));var Qt,Yt,Kt,Jt,Xt,Zt,$t,en,tn=function(i){function o(e,t){var n=i.call(this,e,t)||this;return n.state=null,n.role=null,n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,n.state=r(Wt,t.state)?t.state:null,n.role=r(a,t.role)?t.role:null,"boolean"==typeof t.is_muted&&(n.isMuted=t.is_muted),"boolean"==typeof t.is_blocked_by_me&&(n.isBlockedByMe=t.is_blocked_by_me),"boolean"==typeof t.is_blocking_me&&(n.isBlockingMe=t.is_blocking_me),n}return e(o,i),o.payloadify=function(e){return t(n(s(s({},i.payloadify.call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))},o}(Ee),nn=function(t){function n(e,n){var s,r,a=this;return(a=t.call(this,e)||this).channelUrl=null!==(s=n.channel_url)&&void 0!==s?s:"",a.channelType=null!==(r=n.channel_type)&&void 0!==r?r:i.GROUP,a.member=new o(a._iid,n.user),a.deliveryAt=n.ts,a}return e(n,t),n}(u);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Qt||(Qt={})),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"}(Yt||(Yt={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Kt||(Kt={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Jt||(Jt={})),function(e){e.ALL="all",e.UNHIDDEN="unhidden_only",e.HIDDEN="hidden_only",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Xt||(Xt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Zt||(Zt={})),function(e){e.AND="AND",e.OR="OR"}($t||($t={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(en||(en={}));var sn,rn=function(){function e(e){var t,n,s,r,a,i,o,u,c,l,h,d,_,p,f;this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(t=null==e?void 0:e.includeEmpty)&&void 0!==t&&t,this.nicknameContainsFilter=null!==(n=null==e?void 0:e.nicknameContainsFilter)&&void 0!==n?n:null,this.nicknameStartsWithFilter=null!==(s=null==e?void 0:e.nicknameStartsWithFilter)&&void 0!==s?s:null,this.nicknameExactMatchFilter=null!==(r=null==e?void 0:e.nicknameExactMatchFilter)&&void 0!==r?r:null,this.channelNameContainsFilter=null!==(a=null==e?void 0:e.channelNameContainsFilter)&&void 0!==a?a:"",this.myMemberStateFilter=null!==(i=null==e?void 0:e.myMemberStateFilter)&&void 0!==i?i:Yt.ALL,this.customTypesFilter=null!==(o=null==e?void 0:e.customTypesFilter)&&void 0!==o?o:null,this.channelUrlsFilter=null!==(u=null==e?void 0:e.channelUrlsFilter)&&void 0!==u?u:null,this.superChannelFilter=null!==(c=null==e?void 0:e.superChannelFilter)&&void 0!==c?c:Kt.ALL,this.publicChannelFilter=null!==(l=null==e?void 0:e.publicChannelFilter)&&void 0!==l?l:Qt.ALL,this.customTypeStartsWithFilter=null!==(h=null==e?void 0:e.customTypeStartsWithFilter)&&void 0!==h?h:null,this.unreadChannelFilter=null!==(d=null==e?void 0:e.unreadChannelFilter)&&void 0!==d?d:Jt.ALL,this.hiddenChannelFilter=null!==(_=null==e?void 0:e.hiddenChannelFilter)&&void 0!==_?_:Xt.UNHIDDEN,this.includeFrozen=null===(p=null==e?void 0:e.includeFrozen)||void 0===p||p,(null==e?void 0:e.createdAfter)&&(this.createdAfter=e.createdAfter),(null==e?void 0:e.createdBefore)&&(this.createdBefore=e.createdBefore),this.includeMetaData=null===(f=null==e?void 0:e.includeMetaData)||void 0===f||f}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=$t.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 s=JSON.parse(JSON.stringify(this));return Object.keys(s).forEach((function(e){n[e]=s[e]})),n},e.prototype.match=function(e,t){if(this._searchFilter){var n=this._searchFilter,s=n.query,r=n.fields;if(s&&r&&r.length>0&&!r.some((function(t){switch(t){case en.CHANNEL_NAME:return e.name.toLowerCase().includes(s.toLowerCase());case en.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(s.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var a=this._userIdsFilter,i=a.userIds,o=a.includeMode,u=a.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(i.length>0)switch(u){case $t.AND:if(i.some((function(e){return!l.includes(e)})))return!1;break;case $t.OR:if(i.every((function(e){return!l.includes(e)})))return!1}}else{if(i.includes(t)||i.push(t),e.members.length>i.length)return!1;if(!c(i,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var _=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=_})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Yt.ALL:if("none"===e.myMemberState)return!1;break;case Yt.JOINED:if("joined"!==e.myMemberState)return!1;break;case Yt.INVITED:if("invited"!==e.myMemberState)return!1;break;case Yt.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Yt.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Xt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Xt.HIDDEN:if(!e.isHidden)return!1;break;case Xt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Xt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Jt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Qt.PUBLIC:if(!e.isPublic)return!1;break;case Qt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Kt.SUPER:if(!e.isSuper)return!1;break;case Kt.NON_SUPER:if(e.isSuper)return!1}return!(this.createdAfter&&e.createdAtthis.createdBefore)},e}(),an=function(t){function n(e,n){var s=n.sdkState,r=n.cacheContext,a=t.call(this,e)||this;return a._channels=new Map,a._sdkState=s,a._cacheContext=r,a}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return l(!!e).throw(h.databaseError),e.collection(Ce)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return ps.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],_(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case St.CHRONOLOGICAL:if(!a&&n.createdAt>t||a&&n.createdAtt||a&&n.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)s._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});s._update(e),n.push(s)}else a._channels.set(e.url,e),n.push(e)})),!this.localCacheEnabled)return[3,2];for(s=[],r=0;r0?[4,this.upsert(s)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},n.prototype.unblock=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],_(this._channels.keys()),!1)),p(this,void 0,void 0,(function(){var n,s,r,a,i,o,u,c;return f(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),s=v(t),r=s.next(),l.label=2;case 2:return r.done?[3,5]:(a=r.value,[4,this.get(a)]);case 3:(null==(i=l.sent())?void 0:i._updateUnreadMemberState(this._sdkState.userId,e))&&(i._updateUnreadCount(0,0),n.push(i)),l.label=4;case 4:return r=s.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{r&&!r.done&&(c=s.return)&&c.call(s)}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}(u),on={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},un=function(e){return m("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},cn={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},ln=function(e){return m("string",e.customTypes,!0)&&g("boolean",e.includeEmpty,!0)&&g("boolean",e.includeFrozen,!0)&&g("boolean",e.includeMetaData,!0)&&g("boolean",e.includeChatNotification,!0)},hn={myMemberStateFilter:Yt.ALL},dn=function(e){return r(Yt,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"}(sn||(sn={}));var _n={keys:[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT,sn.NONSUPER_UNREAD_MENTION_COUNT,sn.SUPER_UNREAD_MENTION_COUNT,sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,sn.NONSUPER_UNREAD_MESSAGE_COUNT,sn.SUPER_UNREAD_MESSAGE_COUNT,sn.GROUP_CHANNEL_INVITATION_COUNT,sn.NONSUPER_INVITATION_COUNT,sn.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},pn={channelCustomTypesFilter:void 0,superChannelFilter:Kt.ALL},fn=function(e){return m("string",e.channelCustomTypesFilter,!0)&&r(Kt,e.superChannelFilter)},vn={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:C.ALL},mn=s({},y),gn=function(e){return e.startsWith("EVENT_")||e===y.SYNC_CHANNEL_CHANGELOGS||e===y.REFRESH_CHANNEL},En=function(t){function n(e){var n=e.channels,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=e.ts,o=t.call(this)||this;return o.channels=n,o.context=s,o.isWebSocketEventComing=a,o.ts=i,o}return e(n,t),n}(M),Cn=function(t){function n(e){var n=e.channelUrls,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=t.call(this)||this;return i.channelUrls=n,i.context=s,i.isWebSocketEventComing=a,i}return e(n,t),n}(M),yn=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,s=e.unsentMessageCache,r=e.dispatcher,a=this;this._observers=new Map,r.on((function(e){return p(a,void 0,void 0,(function(){var r,a,i,o,u,c,l,h,d,_,m,g,E,C,M,N,U,S,T=this;return f(this,(function(A){switch(A.label){case 0:if(!(e instanceof En))return[3,19];if(r=e.channels,E=e.context,C=e.isWebSocketEventComing,a=r.filter((function(e){return e instanceof ur})),E.source!==y.EVENT_CHANNEL_RESET_HISTORY&&E.source!==y.EVENT_CHANNEL_HIDDEN)return[3,9];A.label=1;case 1:A.trys.push([1,6,7,8]),i=v(a),o=i.next(),A.label=2;case 2:return o.done?[3,5]:(d=o.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 3:A.sent(),A.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return u=A.sent(),M={error:u},[3,8];case 7:try{o&&!o.done&&(N=i.return)&&N.call(i)}finally{if(M)throw M.error}return[7];case 8:return[3,17];case 9:c=t.filterOffsetChanged(a),A.label=10;case 10:A.trys.push([10,15,16,17]),l=v(c),h=l.next(),A.label=11;case 11:return h.done?[3,14]:(d=h.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 12:A.sent(),A.label=13;case 13:return h=l.next(),[3,11];case 14:return[3,17];case 15:return _=A.sent(),U={error:_},[3,17];case 16:try{h&&!h.done&&(S=l.return)&&S.call(l)}finally{if(U)throw U.error}return[7];case 17:return[4,t.upsert(a,e.ts)];case 18:return m=A.sent(),C||this._broadcastUpdateEvent(m,E),[3,24];case 19:return e instanceof Cn?(g=e.channelUrls,E=e.context,C=e.isWebSocketEventComing,[4,t.remove(g)]):[3,22];case 20:return A.sent(),[4,b((function(){return p(T,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=v(g),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(r=t.value,[4,n.removeMessagesOfChannel(r)]);case 2:return u.sent(),[4,s.removeMessagesOfChannel(r)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return a=u.sent(),i={error:a},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(i)throw i.error}return[7];case 8:return[2]}}))}))}))];case 21:return A.sent(),C||this._broadcastRemoveEvent(g,E),[3,24];case 22:return e instanceof At?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,24];case 23:A.sent(),A.label=24;case 24:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onUpdate&&i.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onRemove&&i.onRemove(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}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}(),Mn=function(r){function a(e){var a=e.userId,i=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c,h=r.call(this)||this,d=s(s({},cn),u),_=d.customTypes,p=d.includeEmpty,f=d.includeFrozen;return h.method=N.GET,h.path="".concat(U,"/").concat(encodeURIComponent(a),"/my_group_channels/changelogs"),h.params=t(n({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:_,show_empty:p,show_frozen:f,include_chat_notification:l})),h}return e(a,r),a}(S),bn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedChannels=n.updated.map((function(t){return new ur(e,Object.assign(t,{ts:n.ts}))})),s.deletedChannelUrls=n.deleted,s.hasMore=n.has_more,s.token=n.next,s.ts=n.ts,s}return e(n,t),n}(T),Nn=function(t){function n(e){var n=e.channelUrl,s=e.isInternalCall,r=e.showLatestMessage,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(s?A:I,"/").concat(encodeURIComponent(n)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=r&&r},a}return e(n,t),n}(S),Un=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Sn={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:Yt.ALL,unreadChannelFilter:Jt.ALL,superChannelFilter:Kt.ALL,publicChannelFilter:Qt.ALL,hiddenChannelFilter:Xt.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:$t.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:St.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0},Tn=function(n){function s(e){var s=this,r=e.userId,a=e.token,i=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,_=e.nicknameContainsFilter,p=e.nicknameStartsWithFilter,f=e.nicknameExactMatchFilter,v=e.channelNameContainsFilter,m=e.channelUrlsFilter,g=e.customTypesFilter,E=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,y=e.metadataOrderKeyFilter,M=e.metadataKey,b=e.metadataValues,S=e.metadataValueStartsWith,T=e.includeFrozen,A=e.includeMetaData,I=e.searchFilter,w=e.userIdsFilter,L=e.includeChatNotification,D=void 0!==L&&L,x=e.includeLeftChannel,R=void 0!==x&&x,F=e.createdAfter,P=e.createdBefore;return(s=n.call(this)||this).method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(r),"/my_group_channels"),s.params=t({token:a,limit:i,order:null!=o?o:Sn.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=u?u:Sn.includeEmpty,member_state_filter:null!=c?c:Sn.myMemberStateFilter,super_mode:null!=l?l:Sn.superChannelFilter,public_mode:null!=h?h:Sn.publicChannelFilter,unread_filter:null!=d?d:Sn.unreadChannelFilter,members_nickname_contains:_,members_nickname_startswith:p,members_nickname:f,name_contains:v,channel_urls:m,custom_types:g,custom_type_startswith:E,hidden_mode:C,metadata_order_key:y,metadata_key:M,metadata_values:b,metadata_value_startswith:S,show_frozen:T,show_metadata:A,include_chat_notification:D,include_left_channel:R,created_after:F,created_before:P}),I&&I.query&&I.fields&&(s.params.search_query=I.query,s.params.search_fields=I.fields),w&&w.userIds&&w.userIds.length>0&&(w.includeMode?(s.params.members_include_in=w.userIds,s.params.query_type=w.queryType.toUpperCase()):s.params.members_exactly_in=w.userIds),s}return e(s,n),s}(S),An=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.channels=[];var r=n.next,a=n.channels,i=n.ts;return s.token=r,a&&a.length>0&&(s.channels=a.map((function(t){return t.ts=i,new ur(e,t)}))),s.ts=null!=i?i:0,s}return e(n,t),n}(T),In=function(t){function n(e){var n=e.userId,s=e.filter,r=t.call(this)||this,a=s.myMemberStateFilter;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/group_channel_count"),r.params={state:null!=a?a:Yt.ALL},r}return e(n,t),n}(S),wn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.groupChannelCount=n.group_channel_count,s}return e(n,t),n}(T),Ln=function(n){function s(e){var s=e.userId,r=e.filter,a=n.call(this)||this,i=r.keys,o=r.customTypeFilters,u=r.customTypesFilter;return a.method=N.GET,a.path="".concat(U,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=t({item_keys:i,custom_types:null!=u?u:o}),a}return e(s,n),s}(S),Dn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=n[sn.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=n[sn.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=n[sn.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=n[sn.SUPER_INVITATION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=n[sn.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=n[sn.NONSUPER_INVITATION_COUNT]),s}return e(n,t),n}(T),xn=function(t){function n(e){var n=e.userId,s=t.call(this)||this;return s.method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_channel_count"),s}return e(n,t),n}(S),Rn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s}return e(n,t),n}(T),Fn=function(t){function n(e){var n=e.userId,s=e.filter,r=e.includeFeedChannel,a=void 0!==r&&r,i=t.call(this)||this,o=s.channelCustomTypesFilter,u=s.superChannelFilter;return i.method=N.GET,i.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_message_count"),i.params={super_mode:null!=u?u:Kt.ALL,custom_types:o,include_feed_channel:a},i}return e(n,t),n}(S),Pn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s.unreadFeedCount=n.unread_feed_count,s}return e(n,t),n}(T),kn=function(t){function n(e){var n=e.channelUrl,s=e.scheduledStatus,r=e.messageTypeFilter,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(w,"/count"),a.params={channel_url:n,status:Hn(s)},r&&(a.params.message_type=r),a}return e(n,t),n}(S),On=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.count=n.count,s}return e(n,t),n}(T),Hn=function(e){if(!e)return[];var t=[];return e.forEach((function(e){switch(e){case Me.PENDING:t.push(be.PENDING);break;case Me.SENT:t.push(be.IN_QUEUE),t.push(be.SENT);break;case Me.CANCELED:t.push(be.CANCELED);break;case Me.FAILED:t.push(be.FAILED)}})),t},Vn=function(n){function s(e){var s=this,r=e.userId,a=e.channelUrl,i=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,h=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,E=e.name,C=e.data,y=e.customType,M=e.messageSurvivalSeconds,b=e.invitedUserIds,U=e.operatorUserIds;return(s=n.call(this)||this).method=N.POST,s.path=I,s.params=t({user_ids:d([r],_(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:a,cover_url:i,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:p,is_public:h,is_discoverable:f,strict:v,is_ephemeral:m,access_code:g,name:E,data:C,custom_type:y,operator_ids:U,message_survival_seconds:M}),s}return e(s,n),s}(S),Gn=function(t){function n(e,n){var s,r=this;return(r=t.call(this,e,n)||this).channel=new ur(e,n),r.isCreated=null===(s=n.is_created)||void 0===s||s,r}return e(n,t),n}(T),Bn=function(t){function n(e){var n=e.userId,s=e.channelUrls,r=t.call(this)||this;return r.method=N.PUT,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),r.params={channel_urls:s},r}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var qn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/join"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),zn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u,l=a.users,h=void 0===l?null:l;return r.memberCount=o,r.joinedMemberCount=c,r.members=Array.isArray(h)?h.map((function(t){return new tn(e,t)})):[new tn(e,s.data)],r}return e(n,t),n}(Ft),Wn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/leave"),n.params={user_id:r,should_remove_operator_status:a},n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Qn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u;return r.memberCount=o,r.joinedMemberCount=c,r.member=new tn(r._iid,s.data),r}return e(n,t),n}(Ft),Yn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userIds;return(n=t.call(this)||this).method=N.POST,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/invite"),n.params={user_ids:r},n}return e(n,t),n}(S),Kn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this;r.inviter=null;var a=s.data,i=a.member_count,u=void 0===i?0:i,c=a.joined_member_count,l=void 0===c?0:c,h=a.inviter,d=a.invitees,_=void 0===d?[]:d;return r.memberCount=u,r.joinedMemberCount=l,h&&Object.keys(h).length>0&&(r.inviter=new o(e,h)),r.invitees=_.map((function(t){return new tn(e,t)})),r}return e(n,t),n}(Ft),Xn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/decline"),n.params={user_id:r},n}return e(n,t),n}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.NONE,s}e(n,t)}(T);var Zn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,u=a.joined_member_count,c=a.inviter,l=a.invitee;return r.memberCount=null!=i?i:0,r.joinedMemberCount=null!=u?u:0,r.inviter=new o(e,c),r.invitee=new tn(e,l),r}return e(n,t),n}(Ft),$n={hidePreviousMessages:!1,allowAutoUnhide:!0},es=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.hidePreviousMessages,i=e.allowAutoUnhide;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n.params={user_id:r,hide_previous_messages:null!=a?a:$n.hidePreviousMessages,allow_auto_unhide:null!=i?i:$n.allowAutoUnhide},n}return e(n,t),n}(S),ts=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),ns=function(t){function n(e,n,s){var r,a,i,o=this;return(o=t.call(this,e,"SYEV",s)||this).allowAutoUnhide=null,o.hidePreviousMessages=null,o.messageOffsetTimestamp=null,s.data&&(o.allowAutoUnhide=null!==(r=s.data.allow_auto_unhide)&&void 0!==r?r:null,o.hidePreviousMessages=null!==(a=s.data.hide_previous_messages)&&void 0!==a?a:null),o.messageOffsetTimestamp=null!==(i=s.ts_message_offset)&&void 0!==i?i:null,o}return e(n,t),n}(L),ss=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),rs=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),as=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),is=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),os=function(t){function n(e){var n=e.channelUrl,s=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:s}})||this}return e(n,t),n}(D),us=function(t){function a(e,n){var s,r,a,i,o,u,c,l,h,d,_,p,f,v,m,g,E,C,y,M,b,N,U,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.includeChatNotification=!1,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Yt.ALL,S.unreadChannelFilter=Jt.ALL,S.superChannelFilter=Kt.ALL,S.publicChannelFilter=Qt.ALL,S.hiddenChannelFilter=Xt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=St.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,S.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,S.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,S.includeChatNotification=null!==(i=n.includeChatNotification)&&void 0!==i&&i,S.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,S.customTypesFilter=null!==(u=n.customTypesFilter)&&void 0!==u?u:null,S.customTypeStartsWithFilter=null!==(c=n.customTypeStartsWithFilter)&&void 0!==c?c:"",S.nicknameContainsFilter=null!==(l=n.nicknameContainsFilter)&&void 0!==l?l:null,S.nicknameStartsWithFilter=null!==(h=n.nicknameStartsWithFilter)&&void 0!==h?h:null,S.nicknameExactMatchFilter=null!==(d=n.nicknameExactMatchFilter)&&void 0!==d?d:null,S.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Yt.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Jt.ALL,S.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:Kt.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Qt.ALL,S.hiddenChannelFilter=null!==(g=n.hiddenChannelFilter)&&void 0!==g?g:Xt.UNHIDDEN,S.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},S.userIdsFilter=null!==(C=n.userIdsFilter)&&void 0!==C?C:{userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null!==(y=n.metadataKey)&&void 0!==y?y:null,S.metadataValues=null!==(M=n.metadataValues)&&void 0!==M?M:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(N=n.metadataValueStartsWith)&&void 0!==N?N:null,S.order=null!==(U=n.order)&&void 0!==U?U:St.LATEST_LAST_MESSAGE,n.createdAfter&&(S.createdAfter=n.createdAfter),n.createdBefore&&(S.createdBefore=n.createdBefore),S}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&m("string",this.channelUrlsFilter,!0)&&m("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&r(Yt,this.myMemberStateFilter)&&r(Kt,this.superChannelFilter)&&r(Qt,this.publicChannelFilter)&&r(Jt,this.unreadChannelFilter)&&r(Xt,this.hiddenChannelFilter)&&m(en,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&m("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&r($t,this.userIdsFilter.queryType)&&r(St,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&m("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)&&x(this.createdAfter,!0)&&x(this.createdBefore,!0)},a.prototype.serialize=function(){return R(this)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,ps.of(this._iid).getMyGroupChannels(this._token,n(s({},this)),this.limit,y.REQUEST_CHANNEL,!0)]):[3,2]:[3,5];case 1:return e=a.sent(),t=e.channels,r=e.token,this._token=r,this._hasNext=!!r,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(F),cs=function(n){function s(e){var s=e.channelUrl,r=e.userId,a=n.call(this)||this;return a.method=N.PUT,a.path="".concat(I,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=t({userId:r}),a}return e(s,n),s}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var ls,hs=function(t){function n(e,n,s){var r=t.call(this,e,"DLVR",s)||this;return r.channelUrl=s.channel_url,r.deliveredStateUpdate=s.updated,r}return e(n,t),n}(L),ds=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,s=e.bottom,r=void 0===s?0:s;this.top=n,this.bottom=r}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0&&n.onMentionReceived&&n.onMentionReceived(g,_)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=6;case 6:return[3,79];case 7:return U=e.as(Y),me=U.channelUrl,ge=U.channelType,S=U.messageId,T=U.silent,A=U.messageCreatedAt,I=U.senderId,ge!==i.GROUP?[3,9]:[4,this.getChannel(me,!0)];case 8:w=xn.sent(),L=I===this._sdkState.userId,T||L||A>0&&w.myLastRead0&&w._updateUnreadCount(w.unreadMessageCount-1,0),this._dispatcher.dispatch(new Q({messageIds:[S],source:y.EVENT_MESSAGE_DELETED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onMessageDeleted&&n.onMessageDeleted(w,S)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=9;case 9:return[3,79];case 10:return(D=e.as(Be).readStatus).channelType!==i.GROUP?[3,12]:(V=this._groupChannelCache.isCachedInMemory(D.channelUrl),[4,this.getChannel(D.channelUrl,!0)]);case 11:x=xn.sent(),V&&x._updateUnreadMemberState(D.reader.userId,D.readAt),D.reader.userId===this._sdkState.userId?V?(x.unreadMessageCount>0||x.unreadMentionCount>0)&&(x._updateUnreadCount(0,0),this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):0!==x.unreadMessageCount&&0!==x.unreadMentionCount||(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUnreadMemberStatusUpdated&&n.onUnreadMemberStatusUpdated(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),xn.label=12;case 12:return[3,79];case 13:return R=e.as(hs),me=R.channelUrl,F=R.deliveredStateUpdate,k=void 0===F?{}:F,V=this._groupChannelCache.isCachedInMemory(me),[4,this.getChannel(me,!0)];case 14:return K=xn.sent(),V&&Object.keys(k).forEach((function(e){K._updateUndeliveredMemberState(e,k[e])})),Object.keys(k).some((function(e){return e!==Dn._sdkState.userId}))&&(this._dispatcher.dispatch(new En({channels:[K],context:{source:y.EVENT_CHANNEL_DELIVERED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUndeliveredMemberStatusUpdated&&n.onUndeliveredMemberStatusUpdated(K)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 15:return X=e.as(qt),me=X.channelUrl,ge=X.channelType,Z=X.event,ge!==i.GROUP?[3,18]:[4,this.getChannel(me,!0)];case 16:return $=xn.sent(),[4,this.getMessageFromCache(Z.messageId)];case 17:(ne=xn.sent())?ne instanceof Ge&&(ne.applyReactionEvent(Z),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new W({event:Z,source:y.EVENT_MESSAGE_REACTION_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onReactionUpdated&&n.onReactionUpdated($,Z)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=18;case 18:return[3,79];case 19:return(ee=e.as(Bt).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(ee.channelUrl,!0)];case 20:return te=xn.sent(),[4,this.getMessageFromCache(ee.targetMessageId)];case 21:(ne=xn.sent())?ne instanceof Ge&&(ne.applyThreadInfoUpdateEvent(ee),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new z({event:ee,source:y.EVENT_MESSAGE_THREADINFO_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onThreadInfoUpdated&&n.onThreadInfoUpdated(te,ee)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=22;case 22:return[3,79];case 23:se=e.as(Gt).groupChannelMemberCounts,re=[],xn.label=24;case 24:xn.trys.push([24,29,30,31]),ae=v(se),ie=ae.next(),xn.label=25;case 25:return ie.done?[3,28]:(oe=ie.value,me=oe.channelUrl,ct=oe.memberCount,lt=oe.joinedMemberCount,ue=oe.updatedAt,[4,this.getChannelFromCache(me)]);case 26:(ce=xn.sent())&&ce._setLatestMemberCount(ct,lt,ue)&&re.push(ce),xn.label=27;case 27:return ie=ae.next(),[3,25];case 28:return[3,31];case 29:return le=xn.sent(),Nn={error:le},[3,31];case 30:try{ie&&!ie.done&&(Un=ae.return)&&Un.call(ae)}finally{if(Nn)throw Nn.error}return[7];case 31:return re.length>0&&(this._dispatcher.dispatch(new En({channels:re,context:{source:y.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelMemberCountChanged&&n.onChannelMemberCountChanged(re)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 32:return he=e.as(Vt),de=he.event,_e=he.status,me=he.channelUrl,ge=he.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,34];case 33:pe=xn.sent(),this._dispatcher.dispatch(new q({event:de,source:y.EVENT_POLL_UPDATED})),H(_e===J?function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollDeleted&&n.onPollDeleted(pe,de.pollId)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}:function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollUpdated&&n.onPollUpdated(pe,de)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}),xn.label=34;case 34:return[3,79];case 35:return fe=e.as(Ve),ve=fe.event,me=fe.channelUrl,ge=fe.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,37];case 36:Ee=xn.sent(),this._dispatcher.dispatch(new B({event:ve,source:y.EVENT_POLL_VOTED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollVoted&&n.onPollVoted(Ee,ve)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=37;case 37:return[3,79];case 38:if(!(Ce=e.as(Ft).event).isGroupChannelEvent)return[3,77];switch(Ce.category){case Ot.CHANNEL_JOIN:return[3,39];case Ot.CHANNEL_LEAVE:return[3,41];case Ot.CHANNEL_OPERATOR_UPDATE:return[3,45];case Ot.CHANNEL_INVITE:return[3,47];case Ot.CHANNEL_DECLINE_INVITE:return[3,49];case Ot.TYPING_START:case Ot.TYPING_END:return[3,51];case Ot.USER_CHANNEL_MUTE:case Ot.USER_CHANNEL_UNMUTE:return[3,53];case Ot.USER_CHANNEL_BAN:return[3,55];case Ot.USER_CHANNEL_UNBAN:return[3,59];case Ot.CHANNEL_FREEZE:case Ot.CHANNEL_UNFREEZE:return[3,61];case Ot.CHANNEL_HIDE:return[3,63];case Ot.CHANNEL_UNHIDE:return[3,65];case Ot.CHANNEL_DELETED:return[3,67];case Ot.CHANNEL_PROP_CHANGED:return[3,69];case Ot.CHANNEL_META_DATA_CHANGED:return[3,71];case Ot.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case Ot.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(Ce.channelUrl,!0)];case 40:return ye=xn.sent(),Me=e.as(jn),be=Me.memberCount,Ne=Me.joinedMemberCount,Ue=Me.members,Se=!1,Ue.forEach((function(e){ye.isExclusive||ye.isSuper||ye.isBroadcast?Se=Se||ye._setLatestMemberCount(be,Ne,Ce.ts):(e.state=Wt.JOINED,ye.addMember(e,Ce.ts),Dn._updateJoinedMemberCount(ye)),e.userId===Dn._sdkState.userId&&(ye.myMemberState=Wt.JOINED)})),this._dispatcher.dispatch(new En({channels:[ye],context:{source:y.EVENT_CHANNEL_JOINED,users:Ue}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var s=v(Ue),r=s.next();!r.done;r=s.next()){var a=r.value;e.onUserJoined&&e.onUserJoined(ye,a)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}ye.isBroadcast&&Se&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,77];case 41:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Ae=Mt.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(Ce.channelUrl,!0)];case 43:Ae=xn.sent(),xn.label=44;case 44:return Te=Ae,Ie=e.as(Qn),ct=Ie.memberCount,lt=Ie.joinedMemberCount,we=Ie.member,Le=!1,De=P.of(this._iid).appInfo,Te.isExclusive||Te.isSuper||Te.isBroadcast?Le=Te._setLatestMemberCount(ct,lt,Ce.ts):((null==De?void 0:De.enabledChannelMemberShipHistory)?((Ye=Te.members.find((function(e){return e.userId===we.userId})))&&(Ye.state=Wt.LEFT),Te.memberCount=ct):Te.removeMember(we),this._updateJoinedMemberCount(Te)),we.userId===this._sdkState.userId?(Te.myMemberState=Wt.NONE,Te.invitedAt=0,Te.joinedAt=0,Te._updateUnreadCount(0,0),Te.isPublic?this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})):(this._markAsLeave(Te),this._dispatcher.dispatch(new Cn({channelUrls:[Te.url],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})))):this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(Te,we),Te.isBroadcast&&Le&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Te])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(Ce.channelUrl,!0)];case 46:Ke=xn.sent(),Je=e.as(Ht).operators,Xe=Je.map((function(e){return e.userId}));try{for(Ze=v(Ke.members),$e=Ze.next();!$e.done;$e=Ze.next())(yt=$e.value).role=Xe.includes(yt.userId)?a.OPERATOR:a.NONE}catch(e){Sn={error:e}}finally{try{$e&&!$e.done&&(Tn=Ze.return)&&Tn.call(Ze)}finally{if(Sn)throw Sn.error}}return Ke.myRole=Xe.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new En({channels:[Ke],context:{source:y.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Je}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ke,Je)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(Ce.channelUrl,!0)];case 48:et=xn.sent(),tt=e.as(Jn),ct=tt.memberCount,lt=tt.joinedMemberCount,nt=tt.inviter,(st=tt.invitees).forEach((function(e){return e.state=Wt.INVITED}));try{for(rt=v(st),at=rt.next();!at.done;at=rt.next())it=at.value,et.isExclusive||et.isSuper||et.isBroadcast?et._setLatestMemberCount(ct,lt,Ce.ts):et.addMember(it,Ce.ts),this._sdkState.userId===it.userId&&(et.hiddenState=tr.UNHIDDEN,et.myMemberState!==Wt.JOINED&&(et.myMemberState=Wt.INVITED),et.invitedAt=Ce.ts)}catch(e){An={error:e}}finally{try{at&&!at.done&&(In=rt.return)&&In.call(rt)}finally{if(An)throw An.error}}return this._dispatcher.dispatch(new En({channels:[et],context:{source:y.EVENT_CHANNEL_INVITED,inviter:nt,invitees:st}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(et,nt,st)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(Ce.channelUrl,!0)];case 50:return ot=xn.sent(),ut=e.as(Zn),ct=ut.memberCount,lt=ut.joinedMemberCount,ht=ut.inviter,dt=ut.invitee,ot.isExclusive||ot.isSuper||ot.isBroadcast?ot._setLatestMemberCount(ct,lt,Ce.ts):ot.removeMember(dt),this._sdkState.userId===dt.userId?(ot.invitedAt=0,ot.myMemberState=Wt.NONE,ot.isPublic?this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})):this._dispatcher.dispatch(new Cn({channelUrls:[ot.url],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}}))):this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ot,ht,dt)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(Ce.channelUrl,!0)];case 52:return _t=xn.sent(),pt=Ce.category===Ot.TYPING_START,ft=e.as(pt?rs:is).user,_t._updateTypingStatus(ft,pt?Ce.ts:0),this._dispatcher.dispatch(new En({channels:[_t],context:{source:y.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(_t)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(Ce.channelUrl,!0)];case 54:vt=xn.sent(),mt=Ce.category===Ot.USER_CHANNEL_MUTE,(gt=e.as(mt?Oe:He).user).userId===this._sdkState.userId&&(vt.myMutedState=mt?G.MUTED:G.UNMUTED,vt._myMutedRemainingTime=gt.restrictionInfo.remainingDuration);try{for(Et=v(vt.members),Ct=Et.next();!Ct.done;Ct=Et.next())if((yt=Ct.value).userId===gt.userId){yt.isMuted=mt;break}}catch(e){wn={error:e}}finally{try{Ct&&!Ct.done&&(Ln=Et.return)&&Ln.call(Et)}finally{if(wn)throw wn.error}}return this._dispatcher.dispatch(new En({channels:[vt],context:{source:mt?y.EVENT_CHANNEL_MUTED:y.EVENT_CHANNEL_UNMUTED,user:gt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){mt?e.onUserMuted&&e.onUserMuted(vt,gt):e.onUserUnmuted&&e.onUserUnmuted(vt,gt)})),[2]}))}))})),[3,77];case 55:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Nt=Mt.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(Ce.channelUrl,!0)];case 57:Nt=xn.sent(),xn.label=58;case 58:return bt=Nt,this._markAsLeave(bt),Ut=e.as(ke).user,Ut.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[bt.url],context:{source:y.EVENT_CHANNEL_BANNED,user:Ut}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(bt,Ut)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(Ce.channelUrl,!0)];case 60:return St=xn.sent(),Tt=e.as(Pe).user,Tt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[St.url],context:{source:y.EVENT_CHANNEL_UNBANNED,user:Tt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(St,Tt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(Ce.channelUrl,!0)];case 62:return At=xn.sent(),It=e.as(Fe).freeze,At.isFrozen=It,this._dispatcher.dispatch(new En({channels:[At],context:{source:It?y.EVENT_CHANNEL_FROZEN:y.EVENT_CHANNEL_UNFROZEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){It?e.onChannelFrozen&&e.onChannelFrozen(At):e.onChannelUnfrozen&&e.onChannelUnfrozen(At)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(Ce.channelUrl,!0)];case 64:return wt=xn.sent(),Rt=e.as(ns),Pt=Rt.allowAutoUnhide,Qt=Rt.hidePreviousMessages,Yt=Rt.messageOffsetTimestamp,null!==Pt&&(wt.hiddenState=Pt?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Qt&&Qt&&wt._updateUnreadCount(0,0),null!==Yt&&(wt.messageOffsetTimestamp=Yt),this._dispatcher.dispatch(new En({channels:[wt],context:{source:y.EVENT_CHANNEL_HIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(wt)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(Ce.channelUrl,!0)];case 66:return(Kt=xn.sent()).hiddenState=tr.UNHIDDEN,this._dispatcher.dispatch(new En({channels:[Kt],context:{source:y.EVENT_CHANNEL_UNHIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Kt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(Ce.channelUrl,!0)];case 68:return Jt=xn.sent(),this._dispatcher.dispatch(new Cn({channelUrls:[Ce.channelUrl],context:{source:y.EVENT_CHANNEL_DELETED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Jt.url,Jt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(Ce.channelUrl,!0)];case 70:return Xt=xn.sent(),this._dispatcher.dispatch(new En({channels:[Xt],context:{source:y.EVENT_CHANNEL_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Xt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(Ce.channelUrl,!0)];case 72:return Zt=xn.sent(),$t=e.as(Re),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&(Zt._upsertCachedMetaData(en,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_CREATED,metaData:en},ts:Ce.ts}))),tn&&(Zt._upsertCachedMetaData(tn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_UPDATED,metaData:tn},ts:Ce.ts}))),nn&&(Zt._removeFromCachedMetaData(nn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:nn},ts:Ce.ts}))),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){en&&e.onMetaDataCreated&&e.onMetaDataCreated(Zt,en),tn&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Zt,tn),nn&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Zt,nn)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(Ce.channelUrl,!0)];case 74:return sn=xn.sent(),rn=e.as(xe),an=rn.created,on=rn.updated,un=rn.deleted,an&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:an}})),on&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:on}})),un&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:un}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){an&&e.onMetaCounterCreated&&e.onMetaCounterCreated(sn,an),on&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(sn,on),un&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(sn,un)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(Ce.channelUrl,!0)];case 76:return cn=xn.sent(),ln=e.as(kt),hn=ln.pinnedMessageIds,dn=ln.latestPinnedMessage,(_n=ln.ts)>cn._pinnedMessagesUpdatedAt&&(cn.pinnedMessageIds=null!=hn?hn:[],cn.lastPinnedMessage=dn,cn._pinnedMessagesUpdatedAt=_n,this._dispatcher.dispatch(new En({channels:[cn],context:{source:y.EVENT_PINNED_MESSAGE_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(cn)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(cn)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((pn=e.as(Lt).event).category){case Dt.USER_BLOCK:fn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=fn.blocker,gn=fn.blockee,this._groupChannelCache.block(mn.userId,gn.userId);break;case Dt.USER_UNBLOCK:vn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=vn.blocker,gn=vn.blockee,this._groupChannelCache.unblock(mn.userId,gn.userId)}return[3,79];case 79:return[3,81];case 80:if(yn=xn.sent(),O(yn))throw yn;return[3,81];case 81:return[2]}}))}))},u.prototype._markAsLeave=function(e){var t,n=this,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((function(){s.ref--,0===s.ref&&n._leftChannels.delete(e.url)}),1e4)},u.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},u.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},u.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},u.prototype.subscribeChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},u.prototype.unsubscribeChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},u.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===Wt.JOINED})).length},u.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n;return f(this,(function(s){switch(s.label){case 0:l(g("string",e)).throw(h.invalidParameters),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=s.sent())?[2,n]:[3,4];case 3:return s.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,s.sent()]}}))}))},u.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return l(g("string",e)).throw(h.invalidParameters),n=new Nn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(s=o.sent(),r=s.as(Un).channel,a=r.unreadMessageCount,i=r.unreadMentionCount,r.myCountPreference){case er.UNREAD_MESSAGE_COUNT_ONLY:i=0;break;case er.UNREAD_MENTION_COUNT_ONLY:a=0;break;case er.OFF:a=0,i=0}return r._updateUnreadCount(a,i),[4,this.upsertChannelsToCache([r])];case 2:return[2,o.sent()[0]]}}))}))},u.prototype.refreshChannel=function(e,t,n,s){return void 0===t&&(t=!0),void 0===n&&(n=y.REFRESH_CHANNEL),void 0===s&&(s=!1),p(this,void 0,void 0,(function(){var r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Nn({channelUrl:e,isInternalCall:t,showLatestMessage:s}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Un).channel).myMemberState!==Wt.NONE?[3,2]:(this._dispatcher.dispatch(new Cn({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new En({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(u=c.sent()).code!==K.NON_AUTHORIZED&&u.code!==K.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Cn({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},u.prototype.getMyGroupChannels=function(e,t,n,r,a){return void 0===r&&(r=y.REQUEST_CHANNEL),void 0===a&&(a=!1),p(this,void 0,void 0,(function(){var i,o,u,c,l,h,d,_,p;return f(this,(function(f){switch(f.label){case 0:return t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3)),i=!1,a&&(o=P.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(i=!0)),l=new Tn(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n,includeLeftChannel:a&&i})),[4,this._requestQueue.send(l)];case 1:return h=f.sent(),d=h.as(An),_=d.channels,p=d.token,this._dispatcher.dispatch(new En({channels:_,context:{source:r}})),[2,{channels:_,token:p}]}}))}))},u.prototype.getMyGroupChannelChangeLogs=function(e,t,r){return void 0===r&&(r=y.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var a,i,o,u,c,d,_,p;return f(this,(function(f){switch(f.label){case 0:return a=s(s({},cn),t),l((g("string",e)||g("number",e))&&ln(a)).throw(h.invalidParameters),i=new Mn(n({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:a})),[4,this._requestQueue.send(i)];case 1:return o=f.sent(),u=o.as(bn),c=u.updatedChannels,d=u.deletedChannelUrls,_=u.hasMore,p=u.ts,c.length>0&&this._dispatcher.dispatch(new En({channels:c,context:{source:r},ts:p})),d.length>0&&this._dispatcher.dispatch(new Cn({channelUrls:d,context:{source:r}})),[2,{updatedChannels:c,deletedChannelUrls:d,hasMore:_,token:u.token}]}}))}))},u.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(a){switch(a.label){case 0:return t=s(s({},hn),e),l(dn(t)).throw(h.invalidParameters),n=new In({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),[2,r.as(wn).groupChannelCount]}}))}))},u.prototype.getUnreadItemCount=function(e){return p(this,void 0,void 0,(function(){var n,r,a,i,o,u,c,d,_,p,v,g,E,C,y,M;return f(this,(function(f){switch(f.label){case 0:return n=s(s({},_n),e),l(function(e){return m(sn,e.keys)&&m("string",e.customTypeFilters,!0)&&m("string",e.customTypesFilter,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid),a=r.sdkState,i=r.requestQueue,o=new Ln({userId:a.userId,filter:n}),[4,i.send(o)];case 1:return u=f.sent(),c=u.as(Dn),d=c.groupChannelUnreadMentionCount,_=c.groupChannelUnreadMessageCount,p=c.groupChannelInvitationCount,v=c.superGroupChannelUnreadMentionCount,g=c.superGroupChannelUnreadMessageCount,E=c.superGroupChannelInvitationCount,C=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,M=c.nonSuperGroupChannelInvitationCount,[2,t({groupChannelUnreadMentionCount:d,groupChannelUnreadMessageCount:_,groupChannelInvitationCount:p,superGroupChannelUnreadMentionCount:v,superGroupChannelUnreadMessageCount:g,superGroupChannelInvitationCount:E,nonSuperGroupChannelUnreadMentionCount:C,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:M})]}}))}))},u.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new xn({userId:t.userId}),[4,n.send(s)];case 1:return r=a.sent(),[2,r.as(Rn).unreadCount]}}))}))},u.prototype.getTotalUnreadMessageCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return t=s(s({},pn),e),l(fn(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Fn({userId:r.userId,filter:t}),[4,a.send(i)];case 1:return o=u.sent(),[2,o.as(Pn).unreadCount]}}))}))},u.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,a,i;return f(this,(function(o){switch(o.label){case 0:return t=s(s({},vn),e),l(function(e){return g("string",e.channelUrl,!0)&&m(Me,e.scheduledStatus,!0)&&r(C,e.messageTypeFilter)}(t)).throw(h.invalidParameters),n=P.of(this._iid).requestQueue,a=new kn(t),[4,n.send(a)];case 1:return i=o.sent(),[2,i.as(On).count]}}))}))},u.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=P.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},u.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=P.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e},u.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=P.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},u.prototype.createChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a;return f(this,(function(i){switch(i.label){case 0:return t=s(s({},on),e),l(un(t)).throw(h.invalidParameters),t.isPublic||(t.accessCode=void 0),n=new Vn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),a=r.as(Gn).channel,[4,this.upsertChannelsToCache([a])];case 2:return i.sent(),[2,a]}}))}))},u.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return e=Date.now(),l(e-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Bn({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(s=v(n),r=s.next();!r.done;r=s.next())(a=r.value)._updateUnreadMemberState(this._sdkState.userId,e),a._updateUnreadCount(0,0)}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},u.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=Date.now(),l(m("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Bn({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:d.sent(),s=this._groupChannelCache.channels,r=[];try{for(a=v(s),i=a.next();!i.done;i=a.next())o=i.value,e.includes(o.url)&&(o._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0),r.push(o))}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=a.return)&&c.call(a)}finally{if(u)throw u.error}}return r.length>0?[4,this.upsertChannelsToCache(r)]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2]}}))}))},u.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},u.prototype.getMessageFromCache=function(e){var t;return p(this,void 0,void 0,(function(){return f(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]}}))}))},u.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return p(this,void 0,void 0,(function(){return f(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,s.sent()]}}))}))},u.prototype.getMessagesFromCache=function(e,t,n,s,r,a){return void 0===r&&(r=Ye),void 0===a&&(a=!0),p(this,void 0,void 0,(function(){return f(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:s,backward:"next"===n,inclusive:a})];case 1:return[2,i.sent()]}}))}))},u.prototype.getPollMessagesFromCache=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,r.sent()]}}))}))},u.prototype.getCachedMessageCountBetween=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.countBetween(e,t,new ds({top:n,bottom:s}))];case 1:return[2,r.sent()]}}))}))},u.prototype.getUnsentMessagesFromCache=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},u.prototype.removeFailedMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},u}(Pt),fs=function(e,t){return t instanceof qe?e.findIndex((function(e){return e instanceof qe&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vs=function(e,t){return e.findIndex((function(e){return e instanceof Ge?e.messageId===t:e instanceof Ke?e.notificationId===t:void 0}))},ms=function(e,t){if(e.length>0){for(var n=0,s=e.length-1,r=Math.floor((n+s)/2);n0)s=r,r=Math.floor((n+s)/2);else{if(!(a<0))return r;n=r+1,r=Math.floor((n+s)/2)}}return e[r].createdAt>t.createdAt?r:r+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(ls||(ls={}));var gs,Es=function(t){function n(e,n,s,r){var a=t.call(this)||this;return a._state=ls.IDLE,a._retryCount=0,a._retryLimit=3,a.priority=0,a._worker=n,a}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===ls.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===ls.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===ls.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(s){switch(s.label){case 0:if(!this.isRunning)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=s.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=s.sent(),this.dispatch("error",n),this._retryCount0&&(r=s.map((function(e){return e.createdAt})),(null===(v=this._metadata)||void 0===v?void 0:(i=v.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.length0&&(r=s.map((function(e){return e.createdAt})),(null===(h=this._metadata)||void 0===h?void 0:(i=h.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit,this._metadata&&(t.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return f.sent(),[3,7];case 5:throw a=f.sent(),m.debug("message background next sync error",a),a;case 6:return g.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:n.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(v=null===(p=l.localCacheConfig)||void 0===p?void 0:p.maxSize)&&void 0!==v?v:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[2,t]}}))}))}))];case 1:return[2,s.sent()]}}))}))})),this._connectionEventContext=v.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n){return Cs[t]||(Cs[t]={}),Cs[t][n.url]||(Cs[t][n.url]=new e({_iid:t,channel:n})),Cs[t][n.url].ref++,Cs[t][n.url]},e.clear=function(e,t){Cs[e]&&Cs[e][t]&&(Cs[e][t].close(),delete Cs[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 ds({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{range:new ds(e.range),previousComplete:e.previousComplete}:{range:new ds({}),previousComplete:!1},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(e){var t,n,s,r;void 0===e&&(e=Date.now());var a=P.of(this._iid),i=a.logger,o=a.sessionManager;a.cacheContext.localCacheEnabled&&o.session.hasSession&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==n?n:e),this._nextSync.start(null!==(r=null===(s=this._metadata)||void 0===s?void 0:s.range.bottom)&&void 0!==r?r:e))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Cs[this._iid][this._channel.url])},e}(),Ms={},bs=function(){function e(e){var t=e._iid,n=e.channel,r=e.includeParams,a=this;this.ref=0,this._iid=t,this._channel=n,this._includeParams=r;var i,o,u=P.of(this._iid),c=u.logger,l=u.sdkState,d=u.dispatcher;this._metadataKey=(i=l.userId,o=n.url,"sendbird:".concat(i,"@groupchannel/").concat(o,"/message/changelogs.meta"));var _=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(l.userId,this._channel.url);this._sync=new Es(_,(function(){return p(a,void 0,void 0,(function(){var e,t,n,r,a,i,o,u;return f(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:l.sent(),c.debug("message changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),l.label=2;case 2:return l.trys.push([2,5,,8]),[4,Je.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,s({replyType:ne.ALL},this._includeParams),y.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=l.sent(),n=t.updatedMessages,r=t.deletedMessageIds,a=t.hasMore,i=t.token,e.hasNext=a,e.nextToken=i,(n.length>0||r.length>0)&&this._metadata&&(this._metadata.token=i),c.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return l.sent(),[3,8];case 5:return o=l.sent(),c.debug("message changelog sync error",o),o instanceof h&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:l.sent(),l.label=7;case 7:throw o;case 8:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n,s){return Ms[t]||(Ms[t]={}),Ms[t][n.url]||(Ms[t][n.url]=new e({_iid:t,channel:n,includeParams:s})),Ms[t][n.url].ref++,Ms[t][n.url]},e.clear=function(e,t){Ms[e]&&Ms[e][t]&&(Ms[e][t].close(),delete Ms[e])},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=P.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:s=r.sent(),this._metadata={token:s?s.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e=P.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Ms[this._iid][this._channel.url])},e}(),Ns={},Us=function(){function e(e){var t=e._iid,n=e.channel,s=e.hasPollMessage,r=this;this.ref=0,this._iid=t,this._channel=n;var a,i,o=P.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(a=c.userId,i=n.url,"sendbird:".concat(a,"@groupchannel/").concat(i,"/poll/changelogs.meta"));var d=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new Es(d,(function(){return p(r,void 0,void 0,(function(){var e,t,n,r,a,i,o,c;return f(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,s()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=P.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,se.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return r=l.sent(),a=r.hasMore,i=r.token,e.hasNext=a,e.nextToken=i,this._metadata.token=i,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 h&&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 Z)if(e.stateType===$.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n,s){return Ns[t]||(Ns[t]={}),Ns[t][n.url]||(Ns[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:s})),Ns[t][n.url].ref++,Ns[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.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 p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){P.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){P.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 Ns[this._iid][this._channel.url])},e}(),Ss=function(n){function s(e){var s,r,a,i,o,u,c,l,h,d,_=this;return(_=n.call(this)||this).method=N.GET,_.path="".concat(re(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),_.params=t({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!==(r=e.customTypes)&&void 0!==r?r:["*"],message_type:null!==(a=e.messageType)&&void 0!==a?a:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:ne.NONE,include_reactions:null===(o=e.includeReactions)||void 0===o||o,include_meta_array:null===(u=e.includeMetaArray)||void 0===u||u,include_thread_info:null===(c=e.includeThreadInfo)||void 0===c||c,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(d=e.showSubchannelMessagesOnly)&&void 0!==d&&d,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),_}return e(s,n),s}(S),Ts=function(t){function n(e,n){var s,r,a,i,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(s=n.prev_messages)&&void 0!==s?s:[]).map((function(t){return Xe(e,t)})),c.prevHasMore=null!==(r=n.prev_hasmore)&&void 0!==r&&r,c.isContinuousPrevMessages=null!==(a=n.is_continuous_prev_messages)&&void 0!==a&&a,c.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return Xe(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}(T),As={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(gs||(gs={}));var Is,ws,Ls,Ds=function(){function e(){this._onCacheResult=ue,this._onApiResult=ue}return e.prototype._invokeResponse=function(e,t,n){var s=this;H((function(){return p(s,void 0,void 0,(function(){return f(this,(function(s){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}(),xs=function(){function e(e,t){var n=t.filter,s=t.startingPoint,r=t.limit,a=t.prevResultLimit,i=t.nextResultLimit,o=t.channel,u=t.channelManager,c=t.disableBackgroundSync,l=void 0!==c&&c,h=this;this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key="mc-".concat(oe()),this._isDisposed=!1,this.filter=null!=n?n:new Le,this._channel=o,this._syncRange=new ds({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=r||Ye,this._prevResultLimit=null!=a?a:Math.floor(this._limit/2),this._nextResultLimit=null!=i?i:Math.floor(this._limit/2),this._channelManager=u;var m=P.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source,s=e.findIndex((function(e){return e.isIdentical(h.channel)}));s>=0&&(h._replaceChannelOfCollection(e[s]),h.channel._runIfHandleableWithGroupChannel((function(e){switch(n){case y.EVENT_CHANNEL_UPDATED:for(var s=!1,r=0;r=e.messageOffsetTimestamp){s=!0;var a=r;if(a>0){var i=h._messages.splice(0,a);h._removeMessagesFromView(i.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&h._messages.length>0&&h._removeMessagesFromView(h._messages.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED);break;case y.EVENT_CHANNEL_UNMUTED:var o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&h._clearCheckMyMutedTimer();break;case y.EVENT_CHANNEL_MUTED:o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&-1!==e._myMutedRemainingTime&&h._startCheckMyMutedTimer(e._myMutedRemainingTime);break;case y.EVENT_CHANNEL_LEFT:e.isPublic&&h._clearCheckMyMutedTimer()}H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(s){return gn(n)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel),[2]}))}))}))})),h._postprocessChannelUpdateEvent(e[s],n))},onRemove:function(e,t){var n=e.indexOf(h.channel.url);n>=0&&(h._clearCheckMyMutedTimer(),H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(n){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url),[2]}))}))})),h._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,s,r=[],a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value;u.channelUrl===h._channel.url&&(h.filter.match(u)?r.push(u):a.push(h.keyOf(u)))}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}if(ie(t)){if(r.length>0)switch(t){case y.LOCAL_MESSAGE_CANCELED:case y.LOCAL_MESSAGE_RESEND_STARTED:case y.EVENT_MESSAGE_SENT_FAILED:case y.EVENT_MESSAGE_SENT_SUCCESS:case y.EVENT_MESSAGE_UPDATED:case y.EVENT_MESSAGE_THREADINFO_UPDATED:case y.EVENT_MESSAGE_REACTION_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_ADDED:case y.EVENT_MESSAGE_FEEDBACK_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_DELETED:case y.SYNC_MESSAGE_CHANGELOGS:h._updateMessagesToView(r,t);break;case y.EVENT_MESSAGE_SENT_PENDING:h._addMessagesToView(r,t);break;case y.EVENT_MESSAGE_RECEIVED:h.hasNext||h._addMessagesToView(r,t);break;case y.SYNC_MESSAGE_FILL:h._addMessagesToView(r,t)}a.length>0&&h._removeMessagesFromView(a,t)}h._postprocessMessageUpdateEvent(e,t)},onRemove:function(e,t){h._removeMessagesFromView(e,t),h._postprocessMessageRemoveEvent(e)},onRemoveUnsent:function(e,t){h._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){h._updatePollsToView(e,t)},onPollUpdate:function(e,t){h._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){h._applyPollVoteEventToView(e,t)},onReactionUpdate:function(e,t){h._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){h._applyThreadInfoEventToView(e,t)}});var g=P.of(this._iid),E=g.cacheContext,C=g.dispatcher,M=g.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),C.dispatch(new En({channels:[this._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=ys.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=bs.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Us.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Es(this._key,(function(e){return p(h,void 0,void 0,(function(){var t=this;return f(this,(function(n){switch(n.label){case 0:return[4,M.run("message-fill-sync-".concat(o.url,"-prev"),(function(){return p(t,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:y.SYNC_MESSAGE_FILL,checkingContinuousMessages:E.localCacheEnabled})];case 1:return t=u.sent(),n=t.messages,s=t.isContinuousMessages,n.length>0?(r=Math.min.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:n.length>=this._prevResultLimit&&this.viewTop0?(r=Math.max.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:!(n.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>r,nextToken:this._syncRange.bottom}]):(E.localCacheEnabled&&m.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(o=null===(i=E.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==o?o:0,use_local_cache:E.localCacheEnabled,starting_point:0,message_init_policy:""}})),[2,{hasNext:!1,nextToken:0}])}}))}))}))];case 1:return[2,n.sent()]}}))}))})),this._connectionEventContext=C.on((function(e){if(e instanceof Z)switch(e.stateType){case $.CONNECTED:b((function(){return p(h,void 0,void 0,(function(){return f(this,(function(e){return this._activate(),[2]}))}))}));break;case $.LOGOUT:h.dispose();break;default:h._clearCheckMyMutedTimer(),h._prevFill.stop(),h._nextFill.stop()}}))}return e.prototype.keyOf=function(e){return 0},Object.defineProperty(e.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),e.prototype._postprocessChannelUpdateEvent=function(e,t){},e.prototype._postprocessChannelRemoveEvent=function(e){},e.prototype._postprocessMessageUpdateEvent=function(e,t){},e.prototype._postprocessMessageRemoveEvent=function(e){},Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],_(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype._activate=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return P.of(this._iid).logger.debug("check huge gap"),this._checkHugeGap(),[4,this._refreshChannel(y.SYNC_CHANNEL_CHANGELOGS)];case 1:return e.sent(),[2]}}))}))},e.prototype._replaceChannelOfCollection=function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)},e.prototype._shouldStartBackgroundSync=function(){var e=P.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled},e.prototype._setBaseMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n instanceof Ge&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,s,r=this,a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value,c=vs(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l.isUserMessage()&&l.applyPoll(u),a.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}return a.length>0&&ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},a.length>0&&(null===(s=(n=this._handler).onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,a)),[2]}))}))})),a},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollUpdateEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollVoteEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyReactionEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyReactionEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._applyThreadInfoEventToView=function(e,t){var n=this,s=vs(this._messages,e.targetMessageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyThreadInfoUpdateEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._removeMessagesFromView=function(e,t){var n,s,r=this,a=[],i=[],o=function(e){var t=u._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var n=u._messages[t];a.push(u.keyOf(n)),i.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=v(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(n)throw n.error}}return ie(t)&&i.length>0&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===s||s.call(n,e,this.channel,a,i),[2]}))}))})),a},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,s=void 0===n?0:n,r=t.nextLimit,a=void 0===r?0:r,i=t.inclusive,o=void 0===i||i;return p(this,void 0,void 0,(function(){var t,n,r,i,u;return f(this,(function(c){switch(c.label){case 0:return t=[],o?[4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter)]:[3,2];case 1:t=c.sent(),c.label=2;case 2:return s>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,s,!1)]:[3,4];case 3:return r=c.sent(),[3,5];case 4:r=[],c.label=5;case 5:return n=r,a>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,a,!1)]:[3,7];case 6:return u=c.sent(),[3,8];case 7:u=[],c.label=8;case 8:return i=u,[2,{messages:d(d(d([],_(t),!1),_(n),!1),_(i),!1).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:n.length,nextMessagesCount:i.length}]}}))}))},e.prototype._getRemoteMessages=function(e,t){var r=t.prevLimit,a=void 0===r?0:r,i=t.nextLimit,o=void 0===i?0:i,u=t.source,c=void 0===u?y.REQUEST_MESSAGE:u,l=t.reverse,h=void 0!==l&&l,d=t.checkingHasNext,_=void 0!==d&&d,v=t.checkingContinuousMessages,m=void 0!==v&&v;return p(this,void 0,void 0,(function(){var t,r;return f(this,(function(i){switch(i.label){case 0:return t=Je.of(this._iid),a>0||o>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,n(s(s(s({},this.filter),As),{isInclusive:!0,reverse:h,prevResultSize:a,nextResultSize:o})),c,_,m)]:[3,2];case 1:return r=i.sent(),[3,3];case 2:r={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,r]}}))}))},e.prototype._checkHugeGap=function(){var e,t,n,r,a;return p(this,void 0,void 0,(function(){var i,o,u,c,l,v,m,g,E,C,M,b,N,U,S,T,A,I,w,L,D,x,R,F,k,O=this;return f(this,(function(V){switch(V.label){case 0:return i=P.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=i.cacheContext,l=i.statManager,v=i.logger,this._messages.length>0?(m=this._syncRange.top,g=this.viewTop,E=this._syncRange.bottom,C=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,g,m)]):[3,8];case 1:return M=V.sent(),[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,E,C)];case 2:b=V.sent(),V.label=3;case 3:return V.trys.push([3,5,6,7]),[4,ce((function(){return p(O,void 0,void 0,(function(){var e,t,n,r,a,i,l,h,v,N,U,S,T,A,I,w,L,D=this;return f(this,(function(x){switch(x.label){case 0:return e=new Ss(s(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:g,prevEnd:m,prevCount:M,nextStart:E,nextEnd:C,nextCount:b,checkingContinuousMessages:c.localCacheEnabled},this.filter),As)),[4,u.send(e)];case 1:return t=x.sent(),n=t.as(Ts),r=n.isHugeGap,a=n.prevMessages,i=void 0===a?[]:a,l=n.prevHasMore,h=n.isContinuousPrevMessages,v=n.nextMessages,N=void 0===v?[]:v,U=n.nextHasmore,S=n.isContinuousNextMessages,r?H((function(){return p(D,void 0,void 0,(function(){var e;return f(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected(),[2]}))}))})):(T=this.viewTop,A=this.viewBottom,I=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,T],_(i.map((function(e){return e.createdAt}))),!1)),w=Math.max.apply(Math,d([0,A],_(N.map((function(e){return e.createdAt}))),!1)),o.dispatch(new j({messages:i,source:y.SYNC_MESSAGE_FILL})),o.dispatch(new j({messages:N,source:y.SYNC_MESSAGE_FILL})),this._syncRange.extends(I,w),(h||S)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(I,w)),l&&this._prevFill.start(I),U&&this._nextFill.start(w)),[2]}}))}))}),1)];case 4:return V.sent(),[3,7];case 5:return N=V.sent(),v.debug("Failed HugeGap Check ",N),[3,7];case 6:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=c.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[3,13];case 8:U=Date.now(),V.label=9;case 9:return V.trys.push([9,11,12,13]),[4,this._getRemoteMessages(U,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:y.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:c.localCacheEnabled})];case 10:if(S=V.sent(),T=S.messages,A=S.isContinuousMessages,I=S.hasNext,T.length>0){for(w=T.map((function(e){return e.createdAt})),L=0,D=0,x=0;x=U&&D++;this._hasPrevious=L>=this._prevResultLimit,this._hasNext=null!=I?I:D>=this._nextResultLimit,(k=this._syncRange).extends.apply(k,d([],_(w),!1)),A&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(T,y.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,13];case 11:return(F=V.sent())instanceof h&&F.code===K.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,13];case 12:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(a=null===(r=c.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 13:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return e=this,[4,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return e._unsentMessages=t.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s;return f(this,(function(r){switch(r.label){case 0:n=P.of(this._iid).logger,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._channelManager.refreshChannel(this.channel.url,!0,e,t)];case 2:return r.sent(),[3,4];case 3:return s=r.sent(),n.warn("Failed to refresh channel",s),[3,4];case 4:return[2]}}))}))},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return p(t,void 0,void 0,(function(){var e,t,n,s=this;return f(this,(function(r){switch(r.label){case 0:this._checkMyMutedStateTimer=void 0,e=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=r.sent(),e=!t.isMuted,[3,5];case 3:return r.sent(),e=!0,[3,5];case 4:return e&&(n=P.of(this._iid).sessionManager,this.channel._runIfHandleableWithGroupChannel((function(e){var t,r;e.myMutedState=G.UNMUTED;var a={source:y.EVENT_CHANNEL_UNMUTED,user:n.currentUser};null===(r=null===(t=s._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===r||r.call(t,a,s.channel)}))),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)},e.prototype._setHasNextAndHasPrevious=function(e,t){for(var n=e.map((function(e){return e.createdAt})),s=0,r=0,a=0;athis._startingPoint&&r++}this._hasPrevious=s>=this._prevResultLimit,this._hasNext=null!=t?t:r>=this._nextResultLimit},e.prototype.initialize=function(e){var t=this,n=new Ds;this._messages=[],this._unsentMessages=[],this._syncRange=new ds({}),this._hasNext=!0,this._hasPrevious=!0;var s=[],r={messages:[],prevMessagesCount:0,nextMessagesCount:0};return H((function(){return p(t,void 0,void 0,(function(){var t,a,i,o,u,c=this;return f(this,(function(l){switch(l.label){case 0:return[4,null===(u=this._backgroundSync)||void 0===u?void 0:u.loadMetadata()];case 1:if(t=l.sent(),a=P.of(this._iid),i=a.cacheContext,o=a.statManager,e===gs.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(e){return p(c,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return r=e,s=this._filterUnderOffsetMessage(r.messages),this._addMessagesToView(s,y.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return t.sent(),n._invokeResponse("local",null,s),[2]}}))}))})).catch((function(e){if(O(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){return p(c,void 0,void 0,(function(){var a,i,u,c,l,h,p,v=this;return f(this,(function(f){switch(f.label){case 0:return a=P.of(this._iid).cacheContext,i=!0,u=!0,c=!1,a.localCacheEnabled&&s.length>0&&(l=t.range).includes.apply(l,d([],_(s.map((function(e){return e.createdAt}))),!1))&&(!t.previousComplete&&r.prevMessagesCountt.range.bottom||r.nextMessagesCount=e._latestMessageInfo.createdAt&&(u=!1)})),u?(i=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:a.localCacheEnabled}).then((function(e){var t,s,r,a=e.messages,i=e.isContinuousMessages,o=e.hasNext,u=v._filterUnderOffsetMessage(a);v._messages=[],u.length>0?(v._setHasNextAndHasPrevious(u,o),(t=v._syncRange).extends.apply(t,d([],_(u.map((function(e){return e.createdAt}))),!1)),i&&(null===(s=v._backgroundSync)||void 0===s?void 0:s.range.overlap(v._syncRange))&&(null===(r=v._backgroundSync)||void 0===r||r.range.extends(v._syncRange.top,v._syncRange.bottom)),v._addMessagesToView(u,y.REQUEST_MESSAGE)):(v._hasPrevious=!1,v._hasNext=!1),n._invokeResponse("remote",null,u)})).catch((function(e){if(O(e))throw e;n._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(s),n._invokeResponse("remote",null,s)),a.localCacheEnabled&&o.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:i?"cache_hit":"cache_miss",max_db_size:null!==(p=null===(h=a.localCacheConfig)||void 0===h?void 0:h.maxSize)&&void 0!==p?p:0,message_init_policy:e,use_local_cache:a.localCacheEnabled,collection_id:this._key}})),[2]}}))}))}));return o.put(new le({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}})),[2]}}))}))})),n},e.prototype.loadPrevious=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasPrevious?this._isLoadingPrevious?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingPrevious=!0,o=this.viewTop,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{prevLimit:this._prevResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._prevResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h=this;return f(this,(function(p){switch(p.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=p.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top))),u=u.filter((function(e){return fs(h._messages,e)<0})),this._hasPrevious=u.length>=this._prevResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(c=null===(i=e.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==c?c:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=u.length>=this._prevResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingPrevious=!1,[2,u]}}))}))},e.prototype.loadNext=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasNext?this._isLoadingNext?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingNext=!0,o=this.viewBottom,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{nextLimit:this._nextResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._nextResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h,p=this;return f(this,(function(f){switch(f.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=f.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom))),u=u.filter((function(e){return fs(p._messages,e)<0})),this._hasNext=null!==(i=t.hasNext)&&void 0!==i?i:u.length>=this._nextResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(h=null===(c=e.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==h?h:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=u.length>=this._nextResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingNext=!1,[2,u]}}))}))},e.prototype.removeFailedMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return[4,this._channelManager.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,s=this;if(!this._isDisposed){this._isDisposed=!0;var r=P.of(this._iid),a=r.cacheContext,i=r.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(e){e.myMemberState!==Wt.NONE&&(s._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new En({channels:[s._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})))})),a.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}},e}(),Rs=function(t){function n(e,n){return t.call(this,e,s(s({},n),{channelManager:ps.of(e)}))||this}return e(n,t),n.prototype.keyOf=function(e){return e.messageId},n.prototype.initialize=function(e){var n=this;return b((function(){return p(n,void 0,void 0,(function(){var e;return f(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]}}))}))})),t.prototype.initialize.call(this,e)},n.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},n.prototype._activate=function(){return p(this,void 0,void 0,(function(){var e=this;return f(this,(function(n){switch(n.label){case 0:return[4,t.prototype._activate.call(this)];case 1:return n.sent(),[4,b((function(){return p(e,void 0,void 0,(function(){var e;return f(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]}}))}))}))];case 2:return n.sent(),[2]}}))}))},n.prototype._addMessagesToView=function(e,t){var n,s,r=this,a=this._filterUnderOffsetMessage(e),i=[],o=[];try{for(var u=v(a),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===y.SYNC_MESSAGE_FILL){if(l.messageId>0){if((E=fs(this._messages,l))<0){fs(this._unsentMessages,l)<0&&i.push(l);var h=ms(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof qe){(E=fs(this._unsentMessages,l))<0&&fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l))}}else if(l.messageId>0){if((E=fs(this._messages,l))<0){var m=fs(this._unsentMessages,l);m<0?i.push(l):(this._unsentMessages.splice(m,1),o.push(l));h=ms(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[E]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,d([],_(g),!1))}}else if(l instanceof qe){var E;(E=fs(this._unsentMessages,l))<0?fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l)):(o.push(l),this._unsentMessages[E]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,a;return f(this,(function(u){return e={source:t},i.length>0&&(null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===s||s.call(n,e,this.channel,i)),o.length>0&&(null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,e,this.channel,o)),[2]}))}))}))},n.prototype._updateMessagesToView=function(e,t){var n,s,r=this,a=[],i=[],o=[];try{for(var u=v(e),c=u.next();!c.done;c=u.next()){var l,h=c.value;if(h.messageId>0)if((l=fs(this._messages,h))>=0)i.push(h),this._messages[l]=h;else{var m=fs(this._unsentMessages,h);if(m>=0){var g=_(this._unsentMessages.splice(m,1),1)[0];if(this.hasNext&&g)o.push(g);else{i.push(h);var E=ms(this._messages,h);this._messages.splice(E,0,h)}}else{var C=this._messages.map((function(e){return e.createdAt}));(h.createdAtMath.max.apply(Math,d([],_(C),!1))&&!this._hasNext)&&a.push(h)}}else if(h instanceof qe)(l=fs(this._unsentMessages,h))>=0&&(i.push(h),this._unsentMessages[l]=h)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}return ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,u;return f(this,(function(c){return e={source:t},i.length>0?null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,i):o.length>0?null===(u=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===u||u.call(r,e,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t),[2]}))}))})),i},n}(xs),Fs={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},Ps=function(t){function n(e){var n=this,s=e.channelUrl,r=e.token,a=e.limit,i=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=N.GET,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/members"),n.params={token:r,limit:a,order:i,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}(S),ks=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.members=[];var r=n.next,a=n.members;return s.token=r,a&&a.length>0&&(s.members=a.map((function(t){return new tn(e,t)}))),s}return e(n,t),n}(T);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Is||(Is={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(ws||(ws={})),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"}(Ls||(Ls={}));var Os=function(t){function a(e,n,s){var r,a,o,u,c=this;return(c=t.call(this,e,n,i.GROUP,s)||this).mutedMemberFilter=Is.ALL,c.memberStateFilter=Ls.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Zt.ALL,c.order=ws.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(r=s.mutedMemberFilter)&&void 0!==r?r:Is.ALL,c.memberStateFilter=null!==(a=s.memberStateFilter)&&void 0!==a?a:Ls.ALL,c.nicknameStartsWithFilter=null!==(o=s.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=s.order)&&void 0!==u?u:ws.MEMBER_NICKNAME_ALPHABETICAL,c}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&r(Is,this.mutedMemberFilter)&&r(Ls,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&r(Zt,this.operatorFilter)&&r(ws,this.order)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=P.of(this._iid).requestQueue,t=new Ps(n(s(s({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=u.sent(),a=r.as(ks),i=a.members,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(he),Hs=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/accept"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),Vs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.JOINED,s}return e(n,t),n}(T),Gs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.isDistinct,i=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,_=e.customType,p=e.operatorUserIds,f=e.messageSurvivalSeconds;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r)),s.params=t({is_distinct:a,is_public:i,is_discoverable:o,name:h,data:d,custom_type:_,cover_url:u,cover_file:c,access_code:l,operator_ids:p,message_survival_seconds:f}),s}return e(s,n),s}(S),Bs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),qs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s)),n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var zs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var js=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.countPreference,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:r},a}return e(n,t),n}(S),Ws=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.countPreference=n.count_preference,s}return e(n,t),n}(T),Qs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.locale;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r),"/reset_user_history"),s.params=t({locale:a}),s}return e(s,n),s}(S),Ys=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),Ks=s(s({},Ze),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Js=s(s({},et),{scheduledAt:void 0}),Xs=function(s){function r(e){var r,a,i=this;i=s.call(this)||this;var o=[];e.mentionType===de.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((function(e){return e.userId}))));var u=e.channelType,c=e.channelUrl,l=e.scheduledMessageId;return i.method=N.PUT,i.path="".concat(re(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((function(e){return nt.payloadify(e)})),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(a=e.metaArrays)||void 0===a?void 0:a.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})),i}return e(r,s),r}(S),Zs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Ae(e,n),s}return e(n,t),n}(T),$s=function(s){function r(e){var r,a=this;a=s.call(this)||this;var i=[];e.mentionType===de.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return a.method=N.PUT,a.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),a.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(r=e.metaArrays)||void 0===r?void 0:r.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),a}return e(r,s),r}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Te(e,n),s}e(n,t)}(T);var er,tr,nr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.DELETE,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a)),n}return e(n,t),n}(S),sr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.POST,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a),"/send_now"),n}return e(n,t),n}(S),rr=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.pushTriggerOption,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:r},a}return e(n,t),n}(S),ar=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T),ir=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=t.call(this)||this;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),r}return e(n,t),n}(S),or=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T);!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"}(er||(er={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(tr||(tr={}));var ur=function(u){function c(e,t){var n,c,l,h,p,f,v,m,E,C,y,M,b,N,U,S,T,A,I,w,L=this;return(L=u.call(this,e,t)||this)._unreadMemberStateMap=new Map,L._undeliveredMemberStateMap=new Map,L._typingStatus=new Map,L._lastMemberCountUpdated=0,L._typingStarted=0,L._typingEnded=0,L._hasBotInfo={general:!1,ai:!1},L.isDistinct=!1,L.isSuper=!1,L.isBroadcast=!1,L.isExclusive=!1,L.isPublic=!1,L.isDiscoverable=!0,L.isChatNotification=!1,L.isAccessCodeRequired=!1,L.isPushEnabled=!1,L.unreadMessageCount=0,L.unreadMentionCount=0,L.totalUnreadReplyCount=0,L.members=[],L.memberCount=0,L.joinedMemberCount=0,L.hiddenState=tr.UNHIDDEN,L.lastMessage=null,L.messageOffsetTimestamp=0,L.messageSurvivalSeconds=-1,L.myMemberState=Wt.NONE,L.myRole=a.NONE,L.myMutedState=G.UNMUTED,L.myLastRead=0,L.myCountPreference=er.ALL,L.myPushTriggerOption=me.DEFAULT,L.inviter=null,L.invitedAt=0,L.joinedAt=0,L.lastPinnedMessage=null,L._latestMessageInfo=null,L._pinnedMessagesUpdatedAt=0,L._myMutedRemainingTime=-1,L.channelType=i.GROUP,L.isDistinct=null!==(c=t.is_distinct)&&void 0!==c&&c,L.isSuper=null!==(l=t.is_super)&&void 0!==l&&l,L.isBroadcast=null!==(h=t.is_broadcast)&&void 0!==h&&h,L.isExclusive=null!==(p=t.is_exclusive)&&void 0!==p&&p,L.isPublic=null!==(f=t.is_public)&&void 0!==f&&f,L.isDiscoverable=null!==(v=t.is_discoverable)&&void 0!==v?v:L.isPublic,L.isChatNotification=null!==(m=t.is_chat_notification)&&void 0!==m&&m,L.isAccessCodeRequired=null!==(E=t.is_access_code_required)&&void 0!==E&&E,L.isPushEnabled=null!==(C=t.is_push_enabled)&&void 0!==C&&C,Array.isArray(t.members)&&(n=L.members).push.apply(n,d([],_(t.members.map((function(e){return new tn(L._iid,e)}))),!1)),L.memberCount=null!==(y=t.member_count)&&void 0!==y?y:0,L.joinedMemberCount=null!==(M=t.joined_member_count)&&void 0!==M?M:0,L.hiddenState=r(tr,t.hidden_state)?t.hidden_state:tr.UNHIDDEN,L.messageOffsetTimestamp=null!==(b=t.ts_message_offset)&&void 0!==b?b:0,L.messageSurvivalSeconds=null!==(N=t.message_survival_seconds)&&void 0!==N?N:-1,L.lastMessage=t.last_message?Xe(L._iid,s({channel_type:L.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((function(e){g("number",t.read_receipt[e])&&L._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((function(e){g("number",t.delivery_receipt[e])&&L._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),L.myMemberState=r(Wt,t.member_state)?t.member_state:Wt.NONE,L.myRole=r(a,t.my_role)?t.my_role:a.NONE,r(G,t.is_muted)?L.myMutedState=t.is_muted:g("boolean",t.is_muted)?L.myMutedState=t.is_muted?G.MUTED:G.UNMUTED:L.myMutedState=G.UNMUTED,L.myCountPreference=r(er,t.count_preference)?t.count_preference:er.ALL,L.myPushTriggerOption=r(me,t.push_trigger_option)?t.push_trigger_option:me.ALL,L.myLastRead=null!==(U=t.user_last_read)&&void 0!==U?U:0,L.inviter=t.inviter?new o(L._iid,t.inviter):null,L.invitedAt=null!==(S=t.invited_at)&&void 0!==S?S:0,L.joinedAt=null!==(T=t.joined_ts)&&void 0!==T?T:0,L._updateUnreadCount(null!==(A=t.unread_message_count)&&void 0!==A?A:0,null!==(I=t.unread_mention_count)&&void 0!==I?I:0),L.totalUnreadReplyCount=null!==(w=t.total_unread_thread_message_count)&&void 0!==w?w:0,L.lastPinnedMessage=t.latest_pinned_message?Xe(L._iid,s({channel_type:L.channelType},t.latest_pinned_message)):null,t.latest_message&&(L._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),L._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot},L}return e(c,u),Object.defineProperty(c.prototype,"isHidden",{get:function(){return this.hiddenState!==tr.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._unreadMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._undeliveredMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasBot",{get:function(){return this._hasBotInfo.general},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasAiBot",{get:function(){return this._hasBotInfo.ai},enumerable:!1,configurable:!0}),c.payloadify=function(e){return t(n(s(s({},u.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,total_unread_thread_message_count:e.totalUnreadReplyCount,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 tn.payloadify(e)})),last_message:e.lastMessage?at(e.lastMessage):null,inviter:e.inviter?o.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?at(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))},c.prototype._shouldUpdateLastMessageWith=function(e){if(e.silent)return!1;var t=P.of(this._iid).appInfo;switch(null==t?void 0:t.lastMessageThreadingPolicy){case pe.NONE:case pe.INCLUDE_REPLY:break;case pe.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case pe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case fe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},c.prototype._updateLastMessage=function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)},c.prototype._updateUnreadCount=function(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===er.ALL||this.myCountPreference===er.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=P.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===er.ALL||this.myCountPreference===er.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},c.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)},c.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},c.prototype._setLatestMemberCount=function(e,t,n){var s=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,s=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),s},c.prototype.isReadMessage=function(e){var t=P.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt},c.prototype.serialize=function(){var e=this;return R(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))},c.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Rs(this._iid,s(s({},e),{channel:this}))},c.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Os(this._iid,this.url,e)},c.prototype.createThreadedParentMessageListQuery=function(e){return void 0===e&&(e={}),new it(this._iid,this.url,this.channelType,e)},c.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 s=this.members[n];s.state===Wt.JOINED&&(e.state=s.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},c.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof tn?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},c.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof qe&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var s=P.of(this._iid).sdkState,r=e.createdAt,a=0;try{for(var i=v(this.members),o=i.next();!o.done;o=i.next()){var u=o.value;if(s.userId!==u.userId&&u.state===Wt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&a.push(i)}})),a},c.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var s=P.of(this._iid).sdkState;if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var r=e instanceof qe?e.sender:null,a=[];return this.members.forEach((function(i){if(t||i.userId!==s.userId&&i.userId!==(null==r?void 0:r.userId)){var o=n._unreadMemberStateMap.get(i.userId);o&&o=t&&(e._typingStatus.delete(a),s=!0)})),s},c.prototype.refresh=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){return[2,this._refresh()]}))}))},c.prototype._refresh=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return t=P.of(this._iid),n=t.requestQueue,s=t.dispatcher,r=new Nn({channelUrl:this.url}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Un).channel,this._update(i),e||s.dispatch(new En({channels:[i],context:{source:y.REFRESH_CHANNEL}})),[2,this]}}))}))},c.prototype.freeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.freeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.unfreeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.unfreeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.updateChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return t=s(s({},Fs),e),l(function(e){return g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new Gs(s({channelUrl:this.url},t)),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Bs).channel,this._update(u),r.dispatch(new En({channels:[u],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.invite=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return l(e.every((function(e){return e instanceof o}))).throw(h.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},c.prototype.inviteWithUserIds=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(m("string",e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.requestQueue,r=t.sessionManager,a=new Yn({channelUrl:this.url,userIds:e}),[4,s.send(a)];case 1:return i=u.sent(),o=i.as(Kn).channel,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_INVITED,inviter:r.currentUser,invitees:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.join=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new qn({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(zn).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.leave=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return t=P.of(this._iid),n=t.sdkState,s=t.requestQueue,r=new Wn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,s.send(r)];case 1:return a.sent(),this.myMemberState=Wt.NONE,[2]}}))}))},c.prototype.acceptInvitation=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new Hs({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(Vs).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.declineInvitation=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new Xn({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),this.myMemberState=Wt.NONE,[2,this]}}))}))},c.prototype.sendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),ps.of(t._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.updateUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateUserMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendMultipleFilesMessage=function(e){var t=this,n=new ut,s=P.of(this._iid).dispatcher;return u.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){n._trigger(e)})).onFailed((function(e,t){n._triggerFailed(e,t)})).onSucceeded((function(e){var r=ps.of(t._iid);t._updateLastMessage(e),r.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})).onFileUploaded((function(e,t,s,r){n._triggerOnFileUploaded(e,t,s,r)})),n},c.prototype.updateFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateFileMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.deleteMessage=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,u.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&e instanceof qe&&P.of(this._iid).dispatcher.dispatch(new ge({reqId:e.reqId,source:y.EVENT_MESSAGE_DELETED})),[2]}}))}))},c.prototype.hide=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=s(s({},$n),e),l(function(e){return g("boolean",e.hidePreviousMessages,!0)&&g("boolean",e.allowAutoUnhide,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.sdkState,i=n.requestQueue,o=new es(s({channelUrl:this.url,userId:a.userId},t)),[4,i.send(o)];case 1:return u=d.sent(),c=u.as(ts).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.unhide=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=new zs({channelUrl:this.url}),[4,n.send(s)];case 1:return r.sent(),this.hiddenState=tr.UNHIDDEN,t.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.delete=function(){return p(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=P.of(this._iid).requestQueue,t=new qs({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o=this;return f(this,(function(u){switch(u.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.dispatcher,s=e.requestQueue,r=new yt({channelUrl:this.url}),[4,s.send(r)];case 1:return a=u.sent(),i=a.as(Be).readStatus,this._updateUnreadMemberState(t.userId,i.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_READ}})),[2]}}))}))},c.prototype.markAsDelivered=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new cs({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),[2]}}))}))},c.prototype.startTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=n?(this._typingStarted=s,this._typingEnded=0,r=new ss({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.endTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=n?(this._typingStarted=0,this._typingEnded=s,r=new as({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.createScheduledUserMessage=function(e){e=s(s({},ct),e),l(lt(e)).throw(h.invalidParameters);var t=new Ct;return this._createScheduledUserMessage(e,t),t},c.prototype.updateScheduledUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a,i;return f(this,(function(o){switch(o.label){case 0:return n=s(s({},Js),t),l(function(e){return tt(e)&&g("number",e.scheduledAt,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid).requestQueue,a=new $s(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(a)];case 1:return i=o.sent(),[2,i.as(Mt).message]}}))}))},c.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},ht),e),l(dt(e)).throw(h.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new Ct;return ve(bt).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);H((function(){return p(t,void 0,void 0,(function(){return f(this,(function(e){return[2,a._trigger(s)]}))}))}))})),E(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a},c.prototype.updateScheduledFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a;return f(this,(function(i){switch(i.label){case 0:return n=s(s({},Ks),t),l(function(e){return $e(e)&&g("number",e.scheduledAt,!0)&&(E(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(h.invalidParameters),E(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return r=new Xs(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,P.of(this._iid).requestQueue.send(r)];case 3:return a=i.sent(),[2,a.as(Zs).message]}}))}))},c.prototype.cancelScheduledMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new nr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.sendScheduledMessageNow=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new sr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.getMyPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a;return f(this,(function(i){switch(i.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new ir({userId:t.userId,channelUrl:this.url}),[4,n.send(s)];case 1:return r=i.sent(),a=r.as(or).pushTriggerOption,this.myPushTriggerOption=a,[2,a]}}))}))},c.prototype.setMyPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(me,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new rr({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(ar).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.setMyCountPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(er,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new js({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Ws).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.resetMyHistory=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=e.sdkState,r=new Qs({channelUrl:this.url,locale:s.localeForChatbot}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Ys).messageOffsetTimestamp,this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t;return n(this,(function(s){switch(s.label){case 0:return e=g.of(this._iid),(t=new f).replyType=l.ALL,[4,e.fetch({sendingStatus:r.PENDING,backward:!0,filter:t})];case 1:return[2,s.sent()]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return s(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(this._localCacheEnabled&&this._enableAutoResend&&"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 b({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"}(C||(C={}));var N=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var s=t.data,n=s.blocker,r=s.blockee;return{blocker:new _(e,n),blockee:new _(e,r)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var s=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(s)?s.map((function(t){return new _(e,t)})):[]}},e}(),v=function(t){function s(e,s){var n=s.userId,r=t.call(this)||this;return r._iid=e,r.userId=n,r}return e(s,t),s}(t),D=function(t){function s(){return t.call(this)||this}return e(s,t),s}(t),T=function(t){function s(e,s,n){var r=t.call(this,e,"USEV",n)||this;return r.event=new N(n),r}return e(s,t),s}(A);export{S as A,v as D,E as G,p as P,D as R,R as S,T as U,C as a,N as b,b as c,L as g}; +import{c as e,b8 as t,_ as s,b as n,ao as r,aK as a,D as i,F as o,t as u,a8 as c,an as d,a2 as h,ay as l,U as _,W as A}from"./__bundle-c03282ec.js";import{u as g,K as f}from"./__bundle-45809bc9.js";var E,p,R;!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"}(E||(E={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(p||(p={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(R||(R={}));var C,L=function(e){switch(e){case E.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case E.CHRONOLOGICAL:return["-createdAt","syncIndex"];case E.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},b=function(t){function s(e){var s=e.message,n=t.call(this)||this;return n.message=s,n}return e(s,t),s}(t),I={},S=function(){function e(e,t){var s=t.localCacheEnabled,n=t.enableAutoResend,r=t.dispatcher,a=t.sdkState,u=t.logger,c=this;this._iid=e,I[e]=this,this._localCacheEnabled=s,this._enableAutoResend=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=u,this._sdkState=a,this._localCacheEnabled&&r.on((function(e){if(e instanceof i)switch(e.stateType){case o.CONNECTED:c._isProcessingAutoResend||c.processAutoResendRegisteredPendingMessages().then((function(){return c._processNextAutoResend()}));break;case o.INTERNAL_DISCONNECTED:case o.EXTERNAL_DISCONNECTED:c._isProcessingAutoResend=!1}}))}return e.of=function(e){return I[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,a,i,o;return n(this,(function(n){switch(n.label){case 0:return this._enableAutoResend?[4,this._fetchAllCachedPendingMessages()]:[2];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())0===(a=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",a.reqId),a.sendingStatus=r.FAILED,a.errorCode=c.ACK_TIMEOUT,this._dispatcher.dispatch(new d({messages:[a],source:h.LOCAL_MESSAGE_FAILED})))}catch(e){i={error:e}}finally{try{s&&!s.done&&(o=t.return)&&o.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,i,o,c,l,_;return n(this,(function(n){switch(n.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())i=s.value,this._enableAutoResend&&i.errorCode&&a(i.errorCode)&&(o=(new Date).getTime(),c=i.createdAt+2592e5,this._enableAutoResend&&o<=c?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(c).toLocaleString()),i.sendingStatus=r.FAILED,this._dispatcher.dispatch(new d({messages:[i],source:h.LOCAL_MESSAGE_FAILED}))))}catch(e){l={error:e}}finally{try{s&&!s.done&&(_=t.return)&&_.call(t)}finally{if(l)throw l.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===r.SUCCEEDED||e.sendingStatus===r.FAILED&&!a(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t;return n(this,(function(s){switch(s.label){case 0:return e=g.of(this._iid),(t=new f).replyType=l.ALL,[4,e.fetch({sendingStatus:r.PENDING,backward:!0,filter:t})];case 1:return[2,s.sent()]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return s(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(this._localCacheEnabled&&this._enableAutoResend&&"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 b({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"}(C||(C={}));var N=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var s=t.data,n=s.blocker,r=s.blockee;return{blocker:new _(e,n),blockee:new _(e,r)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var s=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(s)?s.map((function(t){return new _(e,t)})):[]}},e}(),v=function(t){function s(e,s){var n=s.userId,r=t.call(this)||this;return r._iid=e,r.userId=n,r}return e(s,t),s}(t),D=function(t){function s(){return t.call(this)||this}return e(s,t),s}(t),T=function(t){function s(e,s,n){var r=t.call(this,e,"USEV",n)||this;return r.event=new N(n),r}return e(s,t),s}(A);export{S as A,v as D,E as G,p as P,D as R,R as S,T as U,C as a,N as b,b as c,L as g}; diff --git a/lib/__bundle-1db3fd0b.js b/lib/__bundle-1db3fd0b.js deleted file mode 100644 index 11a2cfc..0000000 --- a/lib/__bundle-1db3fd0b.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 i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[i++],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 i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function c(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r0&&b.indexOf(e)>=0},I=function(e){return e>0&&m.indexOf(e)>=0},k=function(e,t){if(void 0===t&&(t=!1),t&&D(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},O=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(),i=c([],a(t),!1).sort(),r=0;r=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}(),L={encrypt:function(e){return e},decrypt:function(e){return e}},x=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return r(this,void 0,void 0,(function(){return s(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),r(this,void 0,void 0,(function(){var i,r,a,c,u,l,h,d,_,f;return s(this,(function(s){switch(s.label){case 0:return this._version=t,this._keysAddress=e,i="".concat(e,".metadata.version"),[4,this._store.get(i)];case 1:return r=s.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=s.sent())&&void 0!==n?n:[],!r||r.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(i,64),o?(this._clearOrder=s,this._customClearOrderComparator=o):this._clearOrder=E.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=c}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===E.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableAutoResend",{get:function(){return this._enableAutoResend},enumerable:!1,configurable:!0}),e}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(P||(P={}));var q,V,H,z,G,j,K,B,Q,W,Z,Y,X,J=function(){function e(){this.isRefreshing=!1}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasChatServicePermission",{get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(P.CHAT))},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]},e}(),$=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)}))},ee=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=$()}return e.prototype._register=function(e,t,n){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: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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))},e}(),te=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new ee({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new ee({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,i,r=this._container[e];if(r){var s=[];try{for(var a=o(r.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=r.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&s.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}s.forEach((function(e){return r.delete(e)}))}},e}(),ne=function(){function e(){this._dispatcher=new te}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}(),ie=function(){},re=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},se=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){for(var t=c([],a(e),!1),n=0;n0&&(i.extension_sdk_info=r.map((function(e){var t=e.product,n=e.platform,i=e.version;return"".concat(t,"/").concat(n,"/").concat(i)})).join(",")),Object.keys(i).forEach((function(e){return delete c[e]})),Object.keys(c).length>0&&(i=n(n({},i),c))}return Object.entries(i).map((function(e){var t=a(e,2),n=t[0],i=t[1];return"".concat(n,"=").concat(i)})).join("&")},e.userAgentWithExtension=function(e){var t=Ye()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",i=e.sb_uikit?"u".concat(e.sb_uikit):"",r=e["device-os-platform"]?"o".concat(e["device-os-platform"]):Xe()?"omobile-web":"oweb";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(i,"/").concat(r)},e}(),et=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=function(e){n(e)}}))},tt=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t.requestId,n}return t(n,e),n}(ie),nt=function(e){function n(t){var n=e.call(this)||this;return n.method=oe.DELETE,n.path="".concat(Ie(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),t.messageToken&&(n.params=re({mesg_token:t.messageToken})),n}return t(n,e),n}(xe);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Ue);var it=function(e){function n(t,n,i){var r,s=this;return(s=e.call(this,t,"DELM",i)||this).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(r=i.sender_id)&&void 0!==r?r:void 0,s}return t(n,e),n}(Fe),rt=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=n,this._sdkState=i,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof Pe&&c.cancel(e.requestId)})),this._logger=s,this._shouldImportFetchCompat=a}return e.prototype._createHeader=function(e,t){var i=this._sdkState,r=i.appId,s=i.appVersion,o=i.sendbirdRuntimeEnvironment,a=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(r).concat(s?",".concat(s):""),"SB-User-Agent":$e.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":$e.sendbirdSdkUserAgentWithExtension(o)});return t||(a["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(a["Session-Key"]=this._session.sessionKey),a["App-Id"]=r,this._session&&this._session.authToken&&(a["Access-Token"]=this._session.authToken),a},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new je(new Ze({type:Le.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._isBodyRequired=function(e){var t=e.method;return t!==oe.GET&&(t!==oe.DELETE||e instanceof nt)},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a,c,l,h,d,_,f,p,E,g,b,m,y,w;return s(this,(function(s){switch(s.label){case 0:t=e.path,n=e.method,i=e.uploadProgressHandler,r=this._isBodyRequired(e),o=this._sdkState.api,a="".concat(o.host).concat(t).concat(r?"":e.query),c=r?e.payload:null,l=this._createHeader(e,c instanceof FormData?c:void 0),h=new AbortController,d=h.signal,this._abortControl.set(e.requestId,h),_=Date.now(),s.label=1;case 1:return s.trys.push([1,13,,14]),i?[4,import("./__bundle-4b40b3a8.js")]:[3,6];case 2:f=s.sent().xmlHttpRequest,s.label=3;case 3:return s.trys.push([3,5,,6]),[4,f(this._iid,{requestId:e.requestId,method:e.method,url:a,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i})];case 4:return p=s.sent(),this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,p];case 5:if(!((E=s.sent())instanceof v&&E.code===u.XMLHTTPREQUEST_NOT_SUPPORTED))throw E;return this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),[3,6];case 6:return 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,8]:[4,import("./__bundle-7c3d40f4.js")];case 7:s.sent(),s.label=8;case 8:return"function"==typeof fetch?[3,10]:[4,import("./__bundle-46d64517.js")];case 9:s.sent(),s.label=10;case 10:return[4,fetch(a,{method:n,body:c,headers:l,signal:d})];case 11:return[4,(g=s.sent()).json()];case 12:if(b=s.sent(),g.ok||g.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,new Ue(this._iid,b)];if(b){if((m=new v(b)).isSessionExpiredError){if(this._dispatcher.dispatch(new Me({reason:m.code,message:m.message})),!(e instanceof Ve))return y=new et,this._dispatcher.dispatch(new Ke({request:e,deferred:y,error:m})),[2,y.promise];throw m}throw m.isSessionInvalidatedError?(this._dispatcher.dispatch(new Me({reason:m.code,message:m.message})),m):m}throw v.requestFailed;case 13:throw w=s.sent(),this._statLogApiResult(e,_,w),w instanceof v?(this._logger.debug("fail api request",w),w):"AbortError"===(null==w?void 0:w.name)?v.requestCanceled:(this._logger.debug("fail api request",w),v.networkError);case 14:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new tt({requestId:e}))},e.prototype.cancelAll=function(){var e,t;try{for(var n=o(this._abortControl.values()),i=n.next();!i.done;i=n.next()){i.value.abort()}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear(),this._dispatcher.dispatch(new tt({}))},e}(),st=function(){};function ot(e){let t=e.length;for(;--t>=0;)e[t]=0}const at=256,ct=286,ut=30,lt=15,ht=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]),dt=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]),_t=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ft=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pt=new Array(576);ot(pt);const Et=new Array(60);ot(Et);const gt=new Array(512);ot(gt);const vt=new Array(256);ot(vt);const bt=new Array(29);ot(bt);const mt=new Array(ut);function yt(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}let wt,St,Tt;function Nt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ot(mt);const Ct=e=>e<256?gt[e]:gt[256+(e>>>7)],At=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},It=(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<{It(e,n[2*t],n[2*t+1])},Ot=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},Dt=(e,t,n)=>{const i=new Array(16);let r,s,o=0;for(r=1;r<=lt;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=Ot(i[t]++,t))}},Rt=e=>{let t;for(t=0;t{e.bi_valid>8?At(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},xt=(e,t,n,i)=>{const r=2*t,s=2*n;return e[r]{const i=e.heap[n];let r=n<<1;for(;r<=e.heap_len&&(r{let i,r,s,o,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,r=e.pending_buf[e.sym_buf+a++],0===i?kt(e,r,t):(s=vt[r],kt(e,s+at+1,t),o=ht[s],0!==o&&(r-=bt[s],It(e,r,o)),i--,s=Ct(i),kt(e,s,n),o=dt[s],0!==o&&(i-=mt[s],It(e,i,o)))}while(a{const n=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)Ut(e,n,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ut(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,n[2*c]=n[2*o]+n[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,n[2*o+1]=n[2*a+1]=c,e.heap[1]=c++,Ut(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,i=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=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<=lt;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>i||(e.bl_count[d]++,_=0,l>=a&&(_=o[l-a]),f=n[2*l],e.opt_len+=f*(d+_),s&&(e.static_len+=f*(r[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>i||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),Dt(n,u,e.bl_count)},Ft=(e,t,n)=>{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=t[2*(i+1)+1],++a{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),i=0;i<=n;i++)if(r=o,o=t[2*(i+1)+1],!(++a{It(e,0+(i?1:0),3),Lt(e),At(e,n),At(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var zt=(e,t,n,i)=>{let r,s,o=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(Ft(e,e.dyn_ltree,e.l_desc.max_code),Ft(e,e.dyn_dtree,e.d_desc.max_code),Mt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ft[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&-1!==t?Ht(e,t,n,i):4===e.strategy||s===r?(It(e,2+(i?1:0),3),Pt(e,pt,Et)):(It(e,4+(i?1:0),3),((e,t,n,i)=>{let r;for(It(e,t-257,5),It(e,n-1,5),It(e,i-4,4),r=0;r{Vt||((()=>{let e,t,n,i,r;const s=new Array(16);for(n=0,i=0;i<28;i++)for(bt[i]=n,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++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(vt[n]+at+1)]++,e.dyn_dtree[2*Ct(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{It(e,2,3),kt(e,256,pt),(e=>{16===e.bi_valid?(At(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 jt=(e,t,n,i)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+t[i++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Kt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Bt=(e,t,n,i)=>{const r=Kt,s=i+n;e^=-1;for(let n=i;n>>8^r[255&(e^t[n])];return~e},Qt={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"},Wt={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:Zt,_tr_stored_block:Yt,_tr_flush_block:Xt,_tr_tally:Jt,_tr_align:$t}=Gt,{Z_NO_FLUSH:en,Z_PARTIAL_FLUSH:tn,Z_FULL_FLUSH:nn,Z_FINISH:rn,Z_BLOCK:sn,Z_OK:on,Z_STREAM_END:an,Z_STREAM_ERROR:cn,Z_DATA_ERROR:un,Z_BUF_ERROR:ln,Z_DEFAULT_COMPRESSION:hn,Z_FILTERED:dn,Z_HUFFMAN_ONLY:_n,Z_RLE:fn,Z_FIXED:pn,Z_DEFAULT_STRATEGY:En,Z_UNKNOWN:gn,Z_DEFLATED:vn}=Wt,bn=258,mn=262,yn=42,wn=113,Sn=666,Tn=(e,t)=>(e.msg=Qt[t],t),Nn=e=>2*e-(e>4?9:0),Cn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},An=e=>{let t,n,i,r=e.w_size;t=e.hash_size,i=t;do{n=e.head[--i],e.head[i]=n>=r?n-r:0}while(--t);t=r,i=t;do{n=e.prev[--i],e.prev[i]=n>=r?n-r:0}while(--t)};let In=(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))},On=(e,t)=>{Xt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,kn(e.strm)},Dn=(e,t)=>{e.pending_buf[e.pending++]=t},Rn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Ln=(e,t,n,i)=>{let r=e.avail_in;return r>i&&(r=i),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),n),1===e.state.wrap?e.adler=jt(e.adler,t,r,n):2===e.state.wrap&&(e.adler=Bt(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)},xn=(e,t)=>{let n,i,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-mn?e.strstart-(e.w_size-mn):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+bn;let _=u[s+o-1],f=u[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+o]===f&&u[n+o-1]===_&&u[n]===u[s]&&u[++n]===u[s+1]){s+=2,n++;do{}while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&so){if(e.match_start=t,o=i,i>=a)break;_=u[s+o-1],f=u[s+o]}}}while((t=h[t&l])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead},Un=e=>{const t=e.w_size;let n,i,r;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-mn)&&(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),An(e),i+=t),0===e.strm.avail_in)break;if(n=Ln(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=n,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=In(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=In(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,i,r,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(n=65535,r=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(n=i+e.strm.avail_in),n>r&&(n=r),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,kn(e.strm),i&&(i>n&&(i=n),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,n-=i),n&&(Ln(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===o);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_waterr&&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++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(Ln(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,s=r>e.w_size?e.w_size:r,i=e.strstart-e.block_start,(i>=s||(i||t===rn)&&t!==en&&0===e.strm.avail_in&&i<=r)&&(n=i>r?r:i,o=t===rn&&0===e.strm.avail_in&&n===i?1:0,Yt(e,e.block_start,n,o),e.block_start+=n,kn(e.strm)),o?3:1)},Mn=(e,t)=>{let n,i;for(;;){if(e.lookahead=3&&(e.ins_h=In(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-mn&&(e.match_length=xn(e,n)),e.match_length>=3)if(i=Jt(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=In(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=In(e,e.ins_h,e.window[e.strstart+1]);else i=Jt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(On(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2},Fn=(e,t)=>{let n,i,r;for(;;){if(e.lookahead=3&&(e.ins_h=In(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){r=e.strstart+e.lookahead-3,i=Jt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=In(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++,i&&(On(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Jt(e,0,e.window[e.strstart-1]),i&&On(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=Jt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2};function qn(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}const Vn=[new qn(0,0,0,0,Pn),new qn(4,4,8,4,Mn),new qn(4,5,16,8,Mn),new qn(4,6,32,32,Mn),new qn(4,4,16,16,Fn),new qn(8,16,32,32,Fn),new qn(8,16,128,128,Fn),new qn(8,32,128,256,Fn),new qn(32,128,258,1024,Fn),new qn(32,258,258,4096,Fn)];function Hn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=vn,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),Cn(this.dyn_ltree),Cn(this.dyn_dtree),Cn(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),Cn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Cn(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 zn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==yn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==wn&&t.status!==Sn?1:0},Gn=e=>{if(zn(e))return Tn(e,cn);e.total_in=e.total_out=0,e.data_type=gn;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?yn:wn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Zt(t),on},jn=e=>{const t=Gn(e);var n;return t===on&&((n=e.state).window_size=2*n.w_size,Cn(n.head),n.max_lazy_match=Vn[n.level].max_lazy,n.good_match=Vn[n.level].good_length,n.nice_match=Vn[n.level].nice_length,n.max_chain_length=Vn[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},Kn=(e,t,n,i,r,s)=>{if(!e)return cn;let o=1;if(t===hn&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>9||n!==vn||i<8||i>15||t<0||t>9||s<0||s>pn||8===i&&1!==o)return Tn(e,cn);8===i&&(i=9);const a=new Hn;return e.state=a,a.strm=e,a.status=yn,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<Kn(e,t,vn,15,8,En),deflateInit2:Kn,deflateReset:jn,deflateResetKeep:Gn,deflateSetHeader:(e,t)=>zn(e)||2!==e.state.wrap?cn:(e.state.gzhead=t,on),deflate:(e,t)=>{if(zn(e)||t>sn||t<0)return e?Tn(e,cn):cn;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Sn&&t!==rn)return Tn(e,0===e.avail_out?ln:cn);const i=n.last_flush;if(n.last_flush=t,0!==n.pending){if(kn(e),0===e.avail_out)return n.last_flush=-1,on}else if(0===e.avail_in&&Nn(t)<=Nn(i)&&t!==rn)return Tn(e,ln);if(n.status===Sn&&0!==e.avail_in)return Tn(e,ln);if(n.status===yn&&0===n.wrap&&(n.status=wn),n.status===yn){let t=vn+(n.w_bits-8<<4)<<8,i=-1;if(i=n.strategy>=_n||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=i<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Rn(n,t),0!==n.strstart&&(Rn(n,e.adler>>>16),Rn(n,65535&e.adler)),e.adler=1,n.status=wn,kn(e),0!==n.pending)return n.last_flush=-1,on}if(57===n.status)if(e.adler=0,Dn(n,31),Dn(n,139),Dn(n,8),n.gzhead)Dn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Dn(n,255&n.gzhead.time),Dn(n,n.gzhead.time>>8&255),Dn(n,n.gzhead.time>>16&255),Dn(n,n.gzhead.time>>24&255),Dn(n,9===n.level?2:n.strategy>=_n||n.level<2?4:0),Dn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Dn(n,255&n.gzhead.extra.length),Dn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Bt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Dn(n,0),Dn(n,0),Dn(n,0),Dn(n,0),Dn(n,0),Dn(n,9===n.level?2:n.strategy>=_n||n.level<2?4:0),Dn(n,3),n.status=wn,kn(e),0!==n.pending)return n.last_flush=-1,on;if(69===n.status){if(n.gzhead.extra){let t=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=r,kn(e),0!==n.pending)return n.last_flush=-1,on;t=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>t&&(e.adler=Bt(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,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,on;i=0}t=n.gzindexi&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,on;i=0}t=n.gzindexi&&(e.adler=Bt(e.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(kn(e),0!==n.pending))return n.last_flush=-1,on;Dn(n,255&e.adler),Dn(n,e.adler>>8&255),e.adler=0}if(n.status=wn,kn(e),0!==n.pending)return n.last_flush=-1,on}if(0!==e.avail_in||0!==n.lookahead||t!==en&&n.status!==Sn){let i=0===n.level?Pn(n,t):n.strategy===_n?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Un(e),0===e.lookahead)){if(t===en)return 1;break}if(e.match_length=0,n=Jt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(On(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===fn?((e,t)=>{let n,i,r,s;const o=e.window;for(;;){if(e.lookahead<=bn){if(Un(e),e.lookahead<=bn&&t===en)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=e.strstart+bn;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=Jt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Jt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(On(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===rn?(On(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(On(e,!1),0===e.strm.avail_out)?1:2})(n,t):Vn[n.level].func(n,t);if(3!==i&&4!==i||(n.status=Sn),1===i||3===i)return 0===e.avail_out&&(n.last_flush=-1),on;if(2===i&&(t===tn?$t(n):t!==sn&&(Yt(n,0,0,!1),t===nn&&(Cn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),kn(e),0===e.avail_out))return n.last_flush=-1,on}return t!==rn?on:n.wrap<=0?an:(2===n.wrap?(Dn(n,255&e.adler),Dn(n,e.adler>>8&255),Dn(n,e.adler>>16&255),Dn(n,e.adler>>24&255),Dn(n,255&e.total_in),Dn(n,e.total_in>>8&255),Dn(n,e.total_in>>16&255),Dn(n,e.total_in>>24&255)):(Rn(n,e.adler>>>16),Rn(n,65535&e.adler)),kn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?on:an)},deflateEnd:e=>{if(zn(e))return cn;const t=e.state.status;return e.state=null,t===wn?Tn(e,un):on},deflateSetDictionary:(e,t)=>{let n=t.length;if(zn(e))return cn;const i=e.state,r=i.wrap;if(2===r||1===r&&i.status!==yn||i.lookahead)return cn;if(1===r&&(e.adler=jt(e.adler,t,n,0)),i.wrap=0,n>=i.w_size){0===r&&(Cn(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(n-i.w_size,n),0),t=e,n=i.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Un(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=In(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,Un(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=o,e.input=a,e.avail_in=s,i.wrap=r,on},deflateInfo:"pako deflate (from Nodeca project)"};const Qn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Wn={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)Qn(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,i=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Yn[254]=Yn[254]=1;var Xn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,i,r,s,o=e.length,a=0;for(r=0;r>>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 i,r;const s=new Array(2*n);for(r=0,i=0;i4)s[r++]=65533,i+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&i1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Zn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let i=0;i{(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 Jn=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 $n=Object.prototype.toString,{Z_NO_FLUSH:ei,Z_SYNC_FLUSH:ti,Z_FULL_FLUSH:ni,Z_FINISH:ii,Z_OK:ri,Z_STREAM_END:si,Z_DEFAULT_COMPRESSION:oi,Z_DEFAULT_STRATEGY:ai,Z_DEFLATED:ci}=Wt;function ui(e){this.options=Wn.assign({level:oi,method:ci,chunkSize:16384,windowBits:15,memLevel:8,strategy:ai},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 Jn,this.strm.avail_out=0;let n=Bn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ri)throw new Error(Qt[n]);if(t.header&&Bn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Xn.string2buf(t.dictionary):"[object ArrayBuffer]"===$n.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Bn.deflateSetDictionary(this.strm,e),n!==ri)throw new Error(Qt[n]);this._dict_set=!0}}function li(e,t){const n=new ui(t);if(n.push(e,!0),n.err)throw n.msg||Qt[n.err];return n.result}ui.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?ii:ei,"string"==typeof e?n.input=Xn.string2buf(e):"[object ArrayBuffer]"===$n.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(i),n.next_out=0,n.avail_out=i),(s===ti||s===ni)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(r=Bn.deflate(n,s),r===si)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),r=Bn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===ri;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},ui.prototype.onData=function(e){this.chunks.push(e)},ui.prototype.onEnd=function(e){e===ri&&(this.result=Wn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var hi={Deflate:ui,deflate:li,deflateRaw:function(e,t){return(t=t||{}).raw=!0,li(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,li(e,t)},constants:Wt};const di=16209;var _i=function(e,t){let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T,N;const C=e.state;n=e.next_in,T=e.input,i=n+(e.avail_in-5),r=e.next_out,N=e.output,s=r-(t-e.avail_out),o=r+(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,E=(1<>>24,d>>>=b,_-=b,b=v>>>16&255,0===b)N[r++]=65535&v;else{if(!(16&b)){if(64&b){if(32&b){C.mode=16191;break e}e.msg="invalid literal/length code",C.mode=di;break e}v=f[(65535&v)+(d&(1<>>=b,_-=b),_<15&&(d+=T[n++]<<_,_+=8,d+=T[n++]<<_,_+=8),v=p[d&g];;){if(b=v>>>24,d>>>=b,_-=b,b=v>>>16&255,16&b){if(y=65535&v,b&=15,_a){e.msg="invalid distance too far back",C.mode=di;break e}if(d>>>=b,_-=b,b=r-s,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=di;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)N[r++]=S[w++],N[r++]=S[w++],N[r++]=S[w++],m-=3;m&&(N[r++]=S[w++],m>1&&(N[r++]=S[w++]))}else{w=r-y;do{N[r++]=N[w++],N[r++]=N[w++],N[r++]=N[w++],m-=3}while(m>2);m&&(N[r++]=N[w++],m>1&&(N[r++]=N[w++]))}break}if(64&b){e.msg="invalid distance code",C.mode=di;break e}v=p[(65535&v)+(d&(1<>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=r,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,E=0,g=0,v=0,b=0,m=0,y=0,w=0,S=0,T=0,N=null;const C=new Uint16Array(16),A=new Uint16Array(16);let I,k,O,D=null;for(p=0;p<=fi;p++)C[p]=0;for(E=0;E=1&&0===C[v];v--);if(b>v&&(b=v),0===v)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(A[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){I=p-y,o[E]+1=f?(k=D[o[E]-f],O=N[o[E]-f]):(k=96,O=0),u=1<>y)+l]=I<<24|k<<16|O}while(0!==l);for(u=1<>=1;if(0!==u?(T&=u-1,T+=u):T=0,E++,0==--C[p]){if(p===v)break;p=t[n+o[E]]}if(p>b&&(T&d)!==h){for(0===y&&(y=b),_+=g,m=p-y,w=1<852||2===e&&S>592)return 1;h=T&d,r[h]=b<<24|m<<16|_-s}}return 0!==T&&(r[_+T]=p-y<<24|64<<16),a.bits=b,0};const{Z_FINISH:mi,Z_BLOCK:yi,Z_TREES:wi,Z_OK:Si,Z_STREAM_END:Ti,Z_NEED_DICT:Ni,Z_STREAM_ERROR:Ci,Z_DATA_ERROR:Ai,Z_MEM_ERROR:Ii,Z_BUF_ERROR:ki,Z_DEFLATED:Oi}=Wt,Di=16180,Ri=16190,Li=16191,xi=16192,Ui=16194,Pi=16199,Mi=16200,Fi=16206,qi=16209,Vi=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Hi(){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 zi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Gi=e=>{if(zi(e))return Ci;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=Di,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,Si},ji=e=>{if(zi(e))return Ci;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Gi(e)},Ki=(e,t)=>{let n;if(zi(e))return Ci;const i=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Ci:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,ji(e))},Bi=(e,t)=>{if(!e)return Ci;const n=new Hi;e.state=n,n.strm=e,n.window=null,n.mode=Di;const i=Ki(e,t);return i!==Si&&(e.state=null),i};let Qi,Wi,Zi=!0;const Yi=e=>{if(Zi){Qi=new Int32Array(512),Wi=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(bi(1,e.lens,0,288,Qi,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;bi(2,e.lens,0,32,Wi,0,e.work,{bits:5}),Zi=!1}e.lencode=Qi,e.lenbits=9,e.distcode=Wi,e.distbits=5},Xi=(e,t,n,i)=>{let r;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):(r=s.wsize-s.wnext,r>i&&(r=i),s.window.set(t.subarray(n-i,n-i+r),s.wnext),(i-=r)?(s.window.set(t.subarray(n-i,n),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whaveBi(e,15),inflateInit2:Bi,inflate:(e,t)=>{let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T=0;const N=new Uint8Array(4);let C,A;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(zi(e)||!e.output||!e.input&&0!==e.avail_in)return Ci;n=e.state,n.mode===Li&&(n.mode=xi),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=Si;e:for(;;)switch(n.mode){case Di:if(0===n.wrap){n.mode=xi;break}for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>>8&255,n.check=Bt(n.check,N,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=qi;break}if((15&u)!==Oi){e.msg="unknown compression method",n.mode=qi;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=qi;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Bt(n.check,N,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>8&255,N[2]=u>>>16&255,N[3]=u>>>24&255,n.check=Bt(n.check,N,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>8),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Bt(n.check,N,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+=i[s++]<>>8&255,n.check=Bt(n.check,N,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(i.subarray(s,s+_),w)),512&n.flags&&4&n.wrap&&(n.check=Bt(n.check,i,_,s)),a-=_,s+=_,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=i[s+_++],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=Li;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>=7&l,l-=7&l,n.mode=Fi;break}for(;l<3;){if(0===a)break e;a--,u+=i[s++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(Yi(n),n.mode=Pi,t===wi){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=qi}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=i[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=qi;break}if(n.length=65535&u,u=0,l=0,n.mode=Ui,t===wi)break e;case Ui:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;r.set(i.subarray(s,s+_),o),a-=_,s+=_,c-=_,o+=_,n.length-=_;break}n.mode=Li;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=i[s++]<>>=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=qi;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,C={bits:n.lenbits},S=bi(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=qi;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=E,l-=E,n.lens[n.have++]=v;else{if(16===v){for(A=E+2;l>>=E,l-=E,0===n.have){e.msg="invalid bit length repeat",n.mode=qi;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===v){for(A=E+3;l>>=E,l-=E,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(A=E+7;l>>=E,l-=E,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=qi;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===qi)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=qi;break}if(n.lenbits=9,C={bits:n.lenbits},S=bi(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=qi;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=bi(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=qi;break}if(n.mode=Pi,t===wi)break e;case Pi:n.mode=Mi;case Mi:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,n.hold=u,n.bits=l,_i(e,d),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===Li&&(n.back=-1);break}for(n.back=0;T=n.lencode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,n.length=v,0===g){n.mode=16205;break}if(32&g){n.back=-1,n.mode=Li;break}if(64&g){e.msg="invalid literal/length code",n.mode=qi;break}n.extra=15&g,n.mode=16201;case 16201:if(n.extra){for(A=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;T=n.distcode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,64&g){e.msg="invalid distance code",n.mode=qi;break}n.offset=v,n.extra=15&g,n.mode=16203;case 16203:if(n.extra){for(A=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=qi;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=qi;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=r,f=o-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{r[o++]=p[f++]}while(--_);0===n.length&&(n.mode=Mi);break;case 16205:if(0===c)break e;r[o++]=n.length,c--,n.mode=Mi;break;case Fi:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=i[s++]<{if(zi(e))return Ci;let t=e.state;return t.window&&(t.window=null),e.state=null,Si},inflateGetHeader:(e,t)=>{if(zi(e))return Ci;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Si):Ci},inflateSetDictionary:(e,t)=>{const n=t.length;let i,r,s;return zi(e)?Ci:(i=e.state,0!==i.wrap&&i.mode!==Ri?Ci:i.mode===Ri&&(r=1,r=jt(r,t,n,0),r!==i.check)?Ai:(s=Xi(e,t,n,n),s?(i.mode=16210,Ii):(i.havedict=1,Si)))},inflateInfo:"pako inflate (from Nodeca project)"};var $i=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 er=Object.prototype.toString,{Z_NO_FLUSH:tr,Z_FINISH:nr,Z_OK:ir,Z_STREAM_END:rr,Z_NEED_DICT:sr,Z_STREAM_ERROR:or,Z_DATA_ERROR:ar,Z_MEM_ERROR:cr}=Wt;function ur(e){this.options=Wn.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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Jn,this.strm.avail_out=0;let n=Ji.inflateInit2(this.strm,t.windowBits);if(n!==ir)throw new Error(Qt[n]);if(this.header=new $i,Ji.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Xn.string2buf(t.dictionary):"[object ArrayBuffer]"===er.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Ji.inflateSetDictionary(this.strm,t.dictionary),n!==ir)))throw new Error(Qt[n])}function lr(e,t){const n=new ur(t);if(n.push(e),n.err)throw n.msg||Qt[n.err];return n.result}ur.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?nr:tr,"[object ArrayBuffer]"===er.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(i),n.next_out=0,n.avail_out=i),s=Ji.inflate(n,o),s===sr&&r&&(s=Ji.inflateSetDictionary(n,r),s===ir?s=Ji.inflate(n,o):s===ar&&(s=sr));n.avail_in>0&&s===rr&&n.state.wrap>0&&0!==e[n.next_in];)Ji.inflateReset(n),s=Ji.inflate(n,o);switch(s){case or:case ar:case sr:case cr:return this.onEnd(s),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||s===rr))if("string"===this.options.to){let e=Xn.utf8border(n.output,n.next_out),t=n.next_out-e,r=Xn.buf2string(n.output,e);n.next_out=t,n.avail_out=i-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==ir||0!==a){if(s===rr)return s=Ji.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},ur.prototype.onData=function(e){this.chunks.push(e)},ur.prototype.onEnd=function(e){e===ir&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Wn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var hr={Inflate:ur,inflate:lr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,lr(e,t)},ungzip:lr,constants:Wt};const{Deflate:dr,deflate:_r,deflateRaw:fr,gzip:pr}=hi,{Inflate:Er,inflate:gr,inflateRaw:vr,ungzip:br}=hr;var mr,yr={Deflate:dr,deflate:_r,deflateRaw:fr,gzip:pr,Inflate:Er,inflate:gr,inflateRaw:vr,ungzip:br,constants:Wt},wr=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){return t=yr.ungzip(e),[2,String.fromCharCode.apply(null,t)]}))}))};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(mr||(mr={}));var Sr,Tr=function(e){function n(t,n){var i=n.sdkState,r=n.dispatcher,s=n.logger,o=e.call(this)||this;return o.lastActive=0,o._iid=t,o._sdkState=i,o._dispatcher=r,o._logger=s,o}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===mr.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return mr.CONNECTING;case 1:return mr.OPEN}return mr.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ws",{get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Fe.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 i=new Me(n.payload);i.expiresIn>=0&&t._dispatcher.dispatch(i)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e,t){return void 0===t&&(t=""),r(this,void 0,void 0,(function(){var n=this;return s(this,(function(i){return this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return r(n,void 0,void 0,(function(){var t,n,i,o,a,c,u,l=this;return s(this,(function(h){switch(h.label){case 0:return(null===(u=this._sdkState.websocket)||void 0===u?void 0:u.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return r(l,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,wr(t.result)];case 1:return e=i.sent(),this._handleMessage(e),[3,3];case 2:return n=i.sent(),this.error(n),[3,3];case 3:return[2]}}))}))},[3,12]):[3,1]:[3,13];case 1:if(!(e.data instanceof ArrayBuffer))return[3,6];h.label=2;case 2:return h.trys.push([2,4,,5]),[4,wr(new Uint8Array(e.data))];case 3:return a=h.sent(),this._handleMessage(a),[3,5];case 4:return n=h.sent(),this.error(n),[3,5];case 5:return[3,12];case 6:if(!("undefined"!=typeof Buffer&&e.data instanceof Buffer))return[3,11];h.label=7;case 7:return h.trys.push([7,9,,10]),i=e.data,o=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),[4,wr(o)];case 8:return a=h.sent(),this._handleMessage(a),[3,10];case 9:return c=h.sent(),this.error(c),[3,10];case 10:return[3,12];case 11:"string"==typeof e.data&&this._handleMessage(e.data),h.label=12;case 12:return[3,14];case 13:this._handleMessage(e.data),h.label=14;case 14:return[2]}}))}))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",v.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now(),[2]}))}))},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws?(e._ws.onopen=st,e._ws.onmessage=st,e._ws.onerror=st,e.connectionState!==mr.CLOSED?(e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=void 0):t()):t()}))},n.prototype.send=function(e){if(!this._ws)throw v.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}(te),Nr=function(e){function n(t){var n=t.all,i=t.feed,r=t.custom_types,s=t.ts,o=e.call(this)||this;return o.all=n,o.feed=i,o.customTypes=r,o.ts=s,o}return t(n,e),n}(ie),Cr=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=r,this._logger=s,this.apiClient=new rt(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:a}),this.websocketClient=new Tr(e,{sdkState:i,dispatcher:r,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new Nr(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 v({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(v.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r=this;return s(this,(function(s){if(!this._sdkState.websocket)throw v.connectionRequired;if(t=new et,e.ackRequired){i=function(i,s){r._ackStateMap.has(e.requestId)&&(r._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),i?(r._logger.debug("fail websocket request",e.requestId,i),t.reject(i)):(r._logger.debug("receive websocket ack",e.requestId,e),r._logger.debug("receive websocket ack",s),t.resolve(s)))};try{n=setTimeout((function(){return i(v.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return i(void 0,e)},reject:function(e){return i(e)}}),this.websocketClient.send(e)}catch(e){i(e)}}else try{this.websocketClient.send(e),t.resolve()}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return e instanceof xe?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof qe?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw v.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"}(Sr||(Sr={}));var Ar,Ir,kr=function(e){function n(t){var n=t.stateType,i=e.call(this)||this;return i.stateType=n,i}return t(n,e),n}(ie),Or=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Dr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Rr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Lr=function(){function e(e){var t,n,i,r;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(n=e.feed_channels)&&void 0!==n?n:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(r=e.settings_updated_at)&&void 0!==r?r:0}return e.payloadify=function(e){return re(se({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))},e}(),xr=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},Ur=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 re(se({last_updated_at:e.lastUpdatedAt}))},e}(),Pr=function(){function e(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}return e.payloadify=function(e){return re(se({template_list_token:e.token}))},e}(),Mr=function(){function e(e){void 0===e&&(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}),this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}return e.payloadify=function(e){return re(se({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))},e}(),Fr=function(){function e(e){void 0===e&&(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}),this.default=new Mr(e.default),this.realTime=new Mr(e.realtime)}return e.payloadify=function(e){return re(se({default:Mr.payloadify(e.default),realtime:Mr.payloadify(e.realTime)}))},e}(),qr=1048576,Vr=5;!function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Ar||(Ar={})),function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Ir||(Ir={}));var Hr=function(){function e(e){var t,n,i,r,s,o,a;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*qr: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!==(i=e.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(r=e.allow_sdk_log_ingestion)||void 0===r||r,this.unreadCountThreadingPolicy=null!==(s=e.unread_cnt_threading_policy)&&void 0!==s?s:Ar.NONE,this.lastMessageThreadingPolicy=null!==(o=e.last_msg_threading_policy)&&void 0!==o?o:Ir.NONE,this.uikitConfigInfo=new Ur(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new Lr(e.notifications):null,this.messageTemplateInfo=e.message_template?new Pr(e.message_template):null,this.statConfigInfo=e.log_publish_config?new Fr(e.log_publish_config):new Fr}return e.payloadify=function(e){return re(se({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/qr,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?Ur.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Lr.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Pr.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Fr.payloadify(e.statConfigInfo):null}))},e}(),zr=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return{}},e}(),Gr=function(e){function n(t){var n=t.userId,i=t.metadata,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(ce,"/").concat(n,"/metadata"),r.params={metadata:i},r}return t(n,e),n}(xe),jr=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metaData=n,i}return t(n,e),n}(Ue),Kr=function(e){function n(t){var n=t.userId,i=t.metadata,r=t.upsert,s=e.call(this)||this;return s.method=oe.PUT,s.path="".concat(ce,"/").concat(n,"/metadata"),s.params={metadata:i,upsert:r},s}return t(n,e),n}(xe),Br=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metadata=n,i}return t(n,e),n}(Ue),Qr=function(e){function n(t){var n=t.userId,i=t.metadataKey,r=e.call(this)||this;return r.method=oe.DELETE,r.path="".concat(ce,"/").concat(n,"/metadata/").concat(i),r}return t(n,e),n}(xe);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Ue);var Wr=function(e){function n(t){var n=t.userId,i=e.call(this)||this;return i.method=oe.DELETE,i.path="".concat(ce,"/").concat(n,"/metadata"),i}return t(n,e),n}(xe);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Ue);var Zr,Yr=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Xr=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Jr=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"}(Zr||(Zr={}));var $r,es=function(e){function i(t,n){var i,r,s,o,u,l,h,d,_,f,p,E,g=this;return(g=e.call(this,t)||this).userId=null!==(r=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==r?r:"",g.nickname=null!==(o=null!==(s=n.nickname)&&void 0!==s?s:n.name)&&void 0!==o?o:"",g.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",g.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,g.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},g.connectionStatus=Zr.NON_AVAILABLE,S(Zr,n.is_online)?g.connectionStatus=n.is_online:w("boolean",n.is_online)&&(g.connectionStatus=n.is_online?Zr.ONLINE:Zr.OFFLINE),g.isActive=null===(_=n.is_active)||void 0===_||_,g.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,g.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,g.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,g.friendName=null!==(E=n.friend_name)&&void 0!==E?E:null,g}return t(i,e),i.payloadify=function(t){return re(se(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(i.prototype,"profileUrl",{get:function(){var e=Ws.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),i.prototype.serialize=function(){return Yr(this)},i.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)}))},i.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(i){t?delete n.metaData[i]:n.metaData[i]=e[i]}))},i.prototype.createMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return Jr(this._isValidMetaData(e)).throw(v.invalidParameters),t=Ws.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Gr({userId:n.userId,metadata:e}),[4,i.send(r)];case 1:return o=s.sent(),a=o.as(jr).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},i.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n,i,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:return Jr(this._isValidMetaData(e)).throw(v.invalidParameters),n=Ws.of(this._iid),i=n.sdkState,r=n.requestQueue,o=new Kr({userId:i.userId,metadata:e,upsert:t}),[4,r.send(o)];case 1:return a=s.sent(),c=a.as(Br).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},i.prototype.deleteMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return Jr(w("string",e)).throw(v.invalidParameters),t=Ws.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Qr({userId:n.userId,metadataKey:e}),[4,i.send(r)];case 1:return s.sent(),this._applyMetaData(((o={})[e]=!0,o),!0),[2,this.metaData]}}))}))},i.prototype.deleteAllMetaData=function(){return r(this,void 0,void 0,(function(){var e,t,n,i;return s(this,(function(r){switch(r.label){case 0:return e=Ws.of(this._iid),t=e.sdkState,n=e.requestQueue,i=new Wr({userId:t.userId}),[4,n.send(i)];case 1:return r.sent(),this.metaData={},[2]}}))}))},i}(zr),ts=function(e){function n(t){var n=t.userProfile,i=e.call(this)||this;return i.userProfile=n,i}return t(n,e),n}(ie),ns=function(){function e(e,t){var n,i,r,s,o,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new Hr(t),this.user=new es(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=t.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(r=t.pong_timeout)&&void 0!==r?r:5e3,this.reconnectInterval=null!==(o=null===(s=t.reconnect)||void 0===s?void 0:s.interval)&&void 0!==o?o: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 re(se(n(n(n({},es.payloadify(e.user)),Hr.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,i=Ws.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:function(i){return i>0?1e3*Math.min(e*Math.pow(n,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 ts({userProfile:this}))},e}(),is=function(e){function i(t){var i=t.request,r=void 0===i||i,s=t.features,o=void 0===s?{}:s,a=t.options,c=void 0===a?{}:a,u=t.statConfigInfo,l=e.call(this)||this;return l.request=r,l.features=n({localCache:!0,notification:!0},o),l.options=n({ingestion:!0},c),l.statConfigInfo=u,l}return t(i,e),i}(ie),rs=function(e){function i(t,n,i){var r,s,o,a,c=this;return(c=e.call(this,t,n,i)||this).error=null,c.services=[],c.userProfile=new ns(t,i),c.deviceTokenLastDeletedAt=null!==(r=i.device_token_last_deleted_at)&&void 0!==r?r:0,c.key=null!==(s=i.key)&&void 0!==s?s:"",c.ekey=null!==(o=i.ekey)&&void 0!==o?o:"",c.error=i.error?new v(i):null,c.services=null!==(a=i.services)&&void 0!==a?a:[],c}return t(i,e),i.asError=function(e){return new i("","LOGI",n({user_id:"",error:!0},e))},i.prototype.applyTo=function(e){return r(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(r){switch(r.label){case 0:return this.error?[3,4]:(t=Ws.of(e))?(n=t.sessionManager,i=t.dispatcher,[4,n.login(this)]):[3,2];case 1:return r.sent(),this.userProfile.apply(),i.dispatch(new is({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),[3,3];case 2:throw v.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},i}(Fe),ss=function(){function e(){this.type=Sr.NONE,this.name="none"}return e.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,t.cause,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e}(),os=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e()];case 1:return n.sent(),[3,3];case 2:if(!((t=n.sent())instanceof v))throw t;return t.throwOutside(),[3,3];case 3:return[2]}}))}))},as=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e()];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},cs=function(e){function n(t){void 0===t&&(t={});var n,i=this;return(i=e.call(this)||this).type=Sr.LOGOUT,i.name="logout",i._wasPreviouslyConnected=null===(n=t.wasPreviouslyConnected)||void 0===n||n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(o){switch(o.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return o.sent(),[4,e.changeState(new ms,t)];case 2:return o.sent(),this._wasPreviouslyConnected&&os((function(){return r(i,void 0,void 0,(function(){return s(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(ss),us=function(e){function n(){var t=e.call(this)||this;return t.type=Sr.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new gs({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new fs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new cs,t)];case 1:return n.sent(),[2]}}))}))},n}(ss),ls=function(e){function n(t){var n=t.autoReconnect,i=e.call(this)||this;return i.type=Sr.INTERNAL_DISCONNECTED,i.name="internaldisconnected",i._autoReconnect=!1,i._autoReconnect=n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new fs,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new gs({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new fs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new us,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new cs,t)];case 1:return n.sent(),[2]}}))}))},n}(ss),hs=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},ds=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),_s=function(e,t,n){return void 0===n&&(n=new ds),r(void 0,void 0,void 0,(function(){var i,r,o,a,c,u;return s(this,(function(s){switch(s.label){case 0:i=0,r=null,o=function(e){return r=null!=e?e:new Error("Halted")},a=function(){i=0},s.label=1;case 1:if(!(-1===t||i=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new kr({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 r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.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 n.sent(),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.session.authToken=void 0,t.error.isSessionExpiredError||t.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Me({reason:t.error.code,message:t.error.message})):this._logger.warn("login failed: ".concat(t.error)),this._rejectConnectionRequest(t.error),n.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(){var e,t=this.sdkState,n=t.appId,i=t.appVersion,r=t.userId,s=t.extensions,o=t.sendbirdRuntimeEnvironment,a=this.cacheContext.localCacheEnabled,c=this._sessionManager.session,u=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=s?s:{}).sb_uikit,d=$e.userAgentWithExtension(s);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(n).concat(i?"&av=".concat(i):"").concat(c.hasSession?"":"&user_id=".concat(encodeURIComponent(r)),"&pmce=").concat(u?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent($e.sendbirdSdkUserAgentWithExtension(o)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(Ss))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(a?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")},n.prototype._statLogConnection=function(e){var t;this._dispatcher.dispatch(new je(new Ze({type:Le.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=""),r(this,void 0,void 0,(function(){var n,i,r,o=this;return s(this,(function(s){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(v.connectionCanceled)),n=new et,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){o._loginTimer=void 0,o._rejectConnectionRequest(v.loginTimeout)}),null===(t=this.sdkState.websocket)||void 0===t?void 0:t.responseTimeout),i=this._sessionManager.session,e&&(i.authToken=e,i.sessionKey=void 0),r=this._url(),i.sessionKey||i.authToken?this._websocketClient.connect(r,JSON.stringify(i.hasSession?{auth:i.sessionKey}:{token:i.authToken})):this._websocketClient.connect(r,JSON.stringify({}))),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(rs.asError(v.connectionRenew))},n.prototype.disconnect=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,[4,this.disconnect()];case 1:return e.sent(),[4,this._sessionManager.clear()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)},n}(te),Ns=function(e){function n(t){var n=t.appId,i=t.userId,r=t.includeUIKitConfig,s=void 0!==r&&r,o=t.localCacheEnabled,a=void 0===o||o,c=t.expiringSession,u=void 0===c||c,l=e.call(this)||this;return l.path="".concat(ue,"/").concat(i,"/authentication"),l.method=oe.POST,l.params=re({expiring_session:!!u,include_logi:!0,include_extra_data:String(Ss),uikit_config:s,use_local_cache:a,app_id:n}),l.requireAuth=!1,l}return t(n,e),n}(xe),Cs=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.logi=new rs(t,"LOGI",n),i}return t(n,e),n}(Ue);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(bs||(bs={}));var As,Is,ks=[Ve,Ns],Os=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,a=t.useFetchCompat,c=void 0!==a&&a,u=this;this._currentConnectionStateType=Sr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Cr(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:c}),this._session=n,this._logger=s,this._dispatcher=r,this._dispatcher.on((function(e){var t,n,i;if(e instanceof kr){var r=e.stateType;switch(u._currentConnectionStateType=r,r){case Sr.CONNECTED:u._resolveLazyCallQueue();break;case Sr.INITIALIZED:case Sr.INTERNAL_DISCONNECTED:case Sr.EXTERNAL_DISCONNECTED:case Sr.LOGOUT:u._rejectLazyCallQueue((null===(i=u._session)||void 0===i?void 0:i.hasSession)?v.connectionClosed:v.connectionRequired)}}else if(e instanceof Or)u._session.hasChatServicePermission||u._resolveLazyCallQueue(bs.API);else if(e instanceof Dr||e instanceof Rr)u._rejectLazyCallQueue(v.connectionClosed);else if(e instanceof Ke){var s=e.request,a=e.deferred,c=e.error;try{for(var l=o(ks),h=l.next();!h.done;h=l.next()){if(s instanceof h.value)return void a.reject(c)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}u._lazyCallQueue.push({command:s,deferred:a})}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===Sr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Sr.CONNECTING||this._currentConnectionStateType===Sr.RECONNECTING||this._session.isRefreshing},enumerable:!1,configurable:!0}),e.prototype._classifyLazyCallQueueByScope=function(e){var t,n=[],i=[];switch(e){case bs.ALL:t=null;break;case bs.WEBSOCKET:t=qe;break;case bs.API:t=xe}var r=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(r=!0),r?i.push(e):n.push(e)})),[n,i]},e.prototype._resolveLazyCallQueue=function(e){var t=this;void 0===e&&(e=bs.ALL);var n=a(this._classifyLazyCallQueueByScope(e),2),i=n[0],o=n[1];this._lazyCallQueue=o,i.forEach((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:t=e.command,n=e.deferred,(i=e.timeout)&&clearTimeout(i),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.send(t)];case 2:return r=s.sent(),n.resolve(r),[3,4];case 3:return o=s.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}))},e.prototype._rejectLazyCallQueue=function(e,t){var n=this;void 0===t&&(t=bs.ALL);var i=a(this._classifyLazyCallQueueByScope(t),2),o=i[0],c=i[1];this._lazyCallQueue=c,o.forEach((function(t){return r(n,void 0,void 0,(function(){var n,i;return s(this,(function(r){return n=t.deferred,i=t.timeout,clearTimeout(i),n.reject(e),[2]}))}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(r){switch(r.label){case 0:return e instanceof qe?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:case 7:return[2,r.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new et,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),v.connectionRequired;case 3:case 9:return[3,11];case 4:return e instanceof xe?this._session.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,10];case 6:return e.hasSessionKey?(this._logger.debug("send api request with tmp session key",e),[4,this.commandRouter.send(e)]):[3,8];case 8:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new et,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=v.connectionRequired,this._logger.debug("fail api request",n),n;case 10:throw v.invalidCommand;case 11:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),e instanceof qe||e instanceof xe?[4,this.commandRouter.send(e)]:[3,2];case 1:return[2,t.sent()];case 2:throw v.invalidCommand}}))}))},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(v.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}(),Ds="sendbird@devicetokens",Rs=function(){function e(e){var t=e.type,n=e.token,i=e.device_os,r=e.device_manufacturer,s=e.system_push_enabled;this.type=t,this.token=n,this.deviceOS=i,this.deviceManufacturer=r,this.systemPushEnabled=s}return e.payloadify=function(e){return re(se({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))},e}(),Ls=new WeakMap,xs=function(e){function n(t){var n=t._iid,i=t.session,r=t.cacheContext,s=t.sdkState,o=t.dispatcher,a=t.requestQueue,c=t.logger,u=t.pushNotificationAckManager,l=e.call(this)||this;return l._currentConnectionStateType=Sr.INITIALIZED,l._isRefreshingAuthToken=!1,l.currentUser=null,l.session=i,l._iid=n,l._cacheContext=r,l._sdkState=s,l._dispatcher=o,l._requestQueue=a,l._logger=c,l._pushNotificationAckManager=u,l._deviceTokens=[],l._dispatcher.on((function(e){var t,n,i;if(e instanceof kr){var r=e.stateType;l._currentConnectionStateType=r}else if(e instanceof Me&&l.handler&&!l.isSessionKeyRefreshing){if(l._currentConnectionStateType===Sr.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?l.close():((null===(n=e.error)||void 0===n?void 0:n.isSessionTokenExpiredError)&&l.refreshAuthToken().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(l._logger.debug("session expired"),l.handler.onSessionExpired&&l.handler.onSessionExpired(),l.refreshSessionKey().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e}))))}})),l}return t(n,e),Object.defineProperty(n.prototype,"ekey",{get:function(){return Ls.get(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokens",{get:function(){return this._deviceTokens},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokenLastDeletedAt",{get:function(){return this._deviceTokenLastDeletedAt},enumerable:!1,configurable:!0}),n.prototype.indexOfDeviceToken=function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))},n.prototype.hasDeviceToken=function(e,t){return this.indexOfDeviceToken(e,t)>=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return new He({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=s.sent(),i=n.as(Ge),r=i.newKey,o=i.error)throw o;return this.session.sessionKey=null!=r?r:this.session.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(i){switch(i.label){case 0:return t=new Ve({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),[4,_s((function(e){return r(n,void 0,void 0,(function(){var n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=s.sent(),i=n.as(ze),r=i.key,o=i.services,this.session.sessionKey=r,this.session.services=o,[3,3];case 2:if(a=s.sent(),!this._isSessionRelatedError(a))throw a;return e(a),[3,3];case 3:return[2]}}))}))}),3)];case 1:return i.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:if(this._currentConnectionStateType!==Sr.CONNECTED)return[3,8];r.label=1;case 1:return r.trys.push([1,3,,8]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return r.sent(),this.complete(),[2];case 3:n=r.sent(),r.label=4;case 4:return r.trys.push([4,6,,7]),[4,this._handleSessionRefreshError(n,t)];case 5:return r.sent(),[2];case 6:return r.sent(),[3,7];case 7:return[3,8];case 8:return r.trys.push([8,10,,12]),[4,this._refreshSessionKeyByApi(e)];case 9:return r.sent(),this.complete(),[3,12];case 10:return i=r.sent(),[4,this._handleSessionRefreshError(i,t)];case 11:return r.sent(),[3,12];case 12:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e,t=this,n=new et;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var i=null,o=function(){i&&(clearTimeout(i),i=null)},a=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},c=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};i=setTimeout((function(){return c()}),1e3*this._sdkState.sessionTokenRefreshTimeout),os((function(){return r(t,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(a,c),[2]}))}))}))}else n.resolve(null);return n.promise},n.prototype._handleSessionRefreshError=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return e instanceof v&&(e.isSessionTokenExpiredError||e.code===u.APPLICATION_NOT_FOUND)?(this.session.authToken=void 0,t?[4,this._receiveNewAuthToken()]:[3,6]):[3,6];case 1:return(n=i.sent())?(this.session.authToken=n,[4,this._refreshSessionKey(this.session.authToken,!1)]):[3,3];case 2:return i.sent(),[3,5];case 3:return[4,this.clear()];case 4:i.sent(),i.label=5;case 5:return[2];case 6:throw e}}))}))},n.prototype._isSessionRelatedError=function(e){return e instanceof v&&(e.isSessionExpiredError||e.isSessionInvalidatedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this.session.isRefreshing},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isSessionExpiring",{get:function(){return!!this.handler},enumerable:!1,configurable:!0}),n.prototype.authenticate=function(e,t){var n;return r(this,void 0,void 0,(function(){var i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.session.authToken=t,i=new Ns({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!t||this.isSessionExpiring}),[4,this._requestQueue.commandRouter.send(i)];case 1:return r=s.sent(),(o=r.as(Cs).logi).error?[3,4]:this.session.hasChatServicePermission?[3,3]:[4,o.applyTo(this._iid)];case 2:s.sent(),s.label=3;case 3:return[3,5];case 4:throw o.error;case 5:return[2]}}))}))},n.prototype.login=function(e){var t;return r(this,void 0,void 0,(function(){var n,i,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return n=e.key,i=e.ekey,r=e.services,o=e.userProfile,a=e.deviceTokenLastDeletedAt,c=void 0===a?0:a,this.session.sessionKey=n,this.session.services=r,Ls.set(this,i),this._deviceTokenCacheEnabled=null===(t=null==o?void 0:o.appInfo)||void 0===t?void 0:t.deviceTokenCache,u=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,u.get(Ds)]:[3,5];case 1:return!(l=s.sent())||l.lastDeletedAt0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])},e.prototype._isDuplicateStat=function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t},e.prototype._flush=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r;return s(this,(function(s){switch(s.label){case 0:if(t=!0,!(e.length>0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Ms({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=As.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=As.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},e.prototype._save=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=c(c([],a(this.queue),!1),a(this.flushWaitQueue),!1),[4,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((function(e){return Ze.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})];case 1:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save(),[2]}))}))},e}(),qs=function(e){function n(t){var n,i,r,s,o=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:o,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,i=n.getFullYear(),r=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0"),"".concat(i).concat(r).concat(s)),"_").concat(o),l}return t(n,e),n}(Ze),Vs=function(e){function n(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(n,e),Object.defineProperty(n.prototype,"_isSendable",{get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),n.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,e.prototype.init.call(this,t+".daily")];case 1:return n.sent(),this.queue=this.logInfo.statLogs.map((function(e){return new Ze({type:e.stat_type,ts:e.ts,data:e.data})})),[2]}}))}))},n.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),t.localCacheStat?(this.enabledState=t.enabledStat?As.ENABLED:As.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=As.DISABLED,[4,this.clear()];case 2:s.sent(),s.label=3;case 3:return this.isEnabled&&this._isSendable?[4,this._getUploadStats()]:[3,9];case 4:n=s.sent(),i=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),r=0,s.label=5;case 5:return r=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),i.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,e.prototype.init.call(this,t+".realtime")];case 1:return i.sent(),this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Ze({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}})),[2]}}))}))},i.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.statConfig=e,this._mergeQueue(),t.notificationStat?(this.enabledState=t.enabledStat?As.ENABLED:As.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=As.DISABLED,[4,this.clear()];case 2:i.sent(),i.label=3;case 3:return this.isEnabled&&this._isSendable?(n=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),[4,hs(n)]):[3,6];case 4:return i.sent(),[4,this._flush(this.queue)];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},i.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.enabledState===As.DISABLED?[2,!0]:(t=this.enabledState===As.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,this._isDuplicateStat(e)?[2,!0]:(t.push(e),this.enabledState===As.PENDING?[3,2]:[4,this._save()]));case 1:n.sent(),n.label=2;case 2:return this.isEnabled?(this._mergeQueue(),this.isEnabled&&this._isSendable?[4,this._flush(t)]:[3,4]):[3,4];case 3:return[2,n.sent()];case 4:return[2,!0]}}))}))},i}(Fs),Gs=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,i=e.dispatcher,r=e.logger;this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=$(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=i,this.logger=r,this._dailyStatCollector=new Vs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Hs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._realTimeStatCollector=new zs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}return e.prototype._migration=function(){return r(this,void 0,void 0,(function(){var e,t,i,r;return s(this,(function(s){switch(s.label){case 0:return[4,this.cacheContext.preference.get(this.key)];case 1:return(e=s.sent())?(t=[],e.statLogs.forEach((function(e){e.stat_type===Le.FEATURE_LOCALCACHE&&t.push(new Ze({type:e.stat_type,ts:e.ts,data:e.data}))})),[4,this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((function(e){return Ze.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})]):[3,6];case 2:return s.sent(),i=[],e.statLogs.forEach((function(e){e.stat_type!==Le.FEATURE_LOCALCACHE&&e.stat_type!==Le.NOTIFICATION&&(e.stat_type===Le.FEATURE_LOCALCACHE_EVENT&&(e.data=n({message_init_policy:"",starting_point:0},e.data)),i.push(new Ze({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:i.map((function(e){return Ze.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 3:return s.sent(),r=[],e.statLogs.forEach((function(e){var t;e.stat_type===Le.NOTIFICATION&&(e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),r.push(new Ze({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:r.map((function(e){return Ze.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 4:return s.sent(),[4,this.cacheContext.preference.remove(this.key)];case 5:s.sent(),s.label=6;case 6:return[2]}}))}))},e.prototype.init=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.key=e,[4,this._migration()];case 1:return n.sent(),[4,this._dailyStatCollector.init(this.key)];case 2:return n.sent(),[4,this._defaultStatCollector.init(this.key)];case 3:return n.sent(),[4,this._realTimeStatCollector.init(this.key)];case 4:return n.sent(),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){return e instanceof je?(t=e.statLog,this.put(t)):e instanceof is&&(n=e.request,i=e.features,r=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=n,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._realTimeStatCollector.setConfig(null!==(a=this._statConfig.realTime)&&void 0!==a?a:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:r.ingestion})),[2]}))}))}))),[2]}}))}))},e.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=!0,e instanceof qs?this._collectFeatureLocalCacheStat?[4,this._dailyStatCollector.put(e)]:[3,2]:[3,3];case 1:t=n.sent(),n.label=2;case 2:return[3,13];case 3:switch(e.type){case Le.API_RESULT:case Le.WEBSOCKET_CONNECT:return[3,4];case Le.FEATURE_LOCALCACHE:case Le.FEATURE_LOCALCACHE_EVENT:return[3,7];case Le.NOTIFICATION:return[3,10]}return[3,13];case 4:return this._collectRequestStat?[4,this._defaultStatCollector.put(e)]:[3,6];case 5:t=n.sent(),n.label=6;case 6:return[3,13];case 7:return this._collectFeatureLocalCacheStat?[4,this._defaultStatCollector.put(e)]:[3,9];case 8:t=n.sent(),n.label=9;case 9:return[3,13];case 10:return this._collectionNotificationStat?[4,this._realTimeStatCollector.put(e)]:[3,12];case 11:t=n.sent(),n.label=12;case 12:return[3,13];case 13:return t?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=As.COLLECT_ONLY,this._defaultStatCollector.enabledState=As.COLLECT_ONLY,this._realTimeStatCollector.enabledState=As.COLLECT_ONLY,this.logger.debug(v.statLogUploadLimitExceededError))),[2]}}))}))},e.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)},e}(),js=function(){function e(e){var t=e.limit,n=void 0===t?5:t;this.workersByKey={},this.limit=n}return e.prototype.run=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.workersByKey[e]||(this.workersByKey[e]=[]),this.workersByKey[e].length0})).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},i.payloadify=function(t){return re(se(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 lo.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})))},i.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[i];r>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=r)}})),i.req_id&&i.voted_option_ids&&(this.votedPollOptionIds=i.voted_option_ids),"number"==typeof i.voter_count&&(this.voterCount=i.voter_count),!0},i.prototype.serialize=function(){return Yr(this)},i}(zr),_o=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}(),fo=function(e){function n(t,n,i,r){var s=e.call(this,t,r)||this;return s.channelUrl=n,s.channelType=i,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(q,this.channelType)},n}(_o),po=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},Eo=function(e){function n(t){var n=t.title,i=t.optionTexts,r=t.data,s=t.allowUserSuggestion,o=t.allowMultipleVotes,a=t.closeAt,c=e.call(this)||this;return c.method=oe.POST,c.path=be,c.params={title:n,options:i,data:r,allow_user_suggestion:s,allow_multiple_votes:o,close_at:a},c}return t(n,e),n}(xe),go=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new ho(t,n),i}return t(n,e),n}(Ue),vo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=e.call(this)||this;return s.method=oe.GET,s.path="".concat(be,"/").concat(encodeURIComponent(r)),s.params={channel_url:n,channel_type:i},s}return t(n,e),n}(xe),bo=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new ho(t,n),i}return t(n,e),n}(Ue),mo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s)),o.params={channel_url:n,channel_type:i},o}return t(n,e),n}(xe),yo=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.pollOption=new lo(t,n),i}return t(n,e),n}(Ue),wo=function(e){function n(t){var n=t.channelType,i=t.channelUrl,r=t.timestamp,s=t.token,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(Ie(n),"/").concat(encodeURIComponent(i),"/polls/changelogs"),o.params=re({change_ts:r,token:s}),o}return t(n,e),n}(xe),So=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.updatedPolls=n.updated.map((function(e){return function(e,t){return new ho(e,t)}(t,e)})),i.deletedPollIds=n.deleted.map((function(e){return e})),i.hasMore=n.has_more,i.nextToken=n.next,i}return t(n,e),n}(Ue),To={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},No=function(e){return w("string",e.title)&&(t=e.optionTexts,N("string",t)&&t.every((function(e){return""!==e.trim()})))&&uo(e.data)&&w("boolean",e.allowUserSuggestion,!0)&&w("boolean",e.allowMultipleVotes,!0)&&w("number",e.closeAt,!0);var t},Co={channelUrl:"",channelType:q.BASE,pollId:0,pollOptionId:0},Ao=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)&&e.pollId>0&&w("number",e.pollOptionId)&&e.pollOptionId>0},Io={channelUrl:"",channelType:q.BASE,pollId:0},ko=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)},Oo={},Do=function(){function e(e,t){var n=t.sdkState,i=t.dispatcher,r=t.sessionManager,s=t.requestQueue,o=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=r,this._requestQueue=s,this._dispatcher=i,this._logger=o,Oo[e]=this}return e.of=function(e){return Oo[e]},e.prototype.buildPollFromSerializedData=function(e){var t=Xr(e);return new ho(this._iid,ho.payloadify(t))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return Jr(ko(e)).throw(v.invalidParameters),t=new vo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(bo).poll]}}))}))},e.prototype.create=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return Jr(No(e)).throw(v.invalidParameters),t=new Eo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(go).poll]}}))}))},e.prototype.getOption=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return Jr(Ao(e)).throw(v.invalidParameters),t=new mo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(yo).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,i){return void 0===i&&(i=Ks.SYNC_POLL_CHANGELOGS),r(this,void 0,void 0,(function(){var r,o,a,c,u,l,h;return s(this,(function(s){switch(s.label){case 0:return r=new wo(se({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(r)];case 1:return o=s.sent(),a=o.as(So),c=a.updatedPolls,u=a.deletedPollIds,l=a.hasMore,h=a.nextToken,c.length>0&&this._dispatcher.dispatch(new ro({polls:c,source:i})),[2,{updatedPolls:c,deletedPollIds:u,hasMore:l,token:h}]}}))}))},e}(),Ro=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.token,s=t.limit,o=e.call(this)||this;return o.method=oe.GET,o.path=be,o.params={channel_url:n,channel_type:i,token:r,limit:s},o}return t(n,e),n}(xe),Lo=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).polls=(null!==(i=n.polls)&&void 0!==i?i:[]).map((function(e){return new ho(t,e)})),r.token=n.next,r}return t(n,e),n}(Ue),xo=function(e){function i(t,n){return e.call(this,t,n.channelUrl,n.channelType,n)||this}return t(i,e),i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Ws.of(this._iid).requestQueue,t=new Ro(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(Lo),o=r.polls,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(fo),Uo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=t.token,a=t.limit,c=e.call(this)||this;return c.method=oe.GET,c.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s),"/voters"),c.params={channel_url:n,channel_type:i,token:o,limit:a},c}return t(n,e),n}(xe),Po=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).voters=(null!==(i=n.voters)&&void 0!==i?i:[]).map((function(e){return new es(t,e)})),r.token=n.next,r}return t(n,e),n}(Ue),Mo=function(e){function i(t,n){var i=e.call(this,t,n.channelUrl,n.channelType,n)||this;return i.pollId=n.pollId,i.pollOptionId=n.pollOptionId,i}return t(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&w("number",this.pollId)&&w("number",this.pollOptionId)},i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Ws.of(this._iid).requestQueue,t=new Uo(n(n({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(Po),o=r.voters,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(fo);export{_ as $,oe as A,as as B,q as C,kr as D,te as E,Sr as F,os as G,Nr as H,ts as I,ns as J,xr as K,F as L,Me as M,Je as N,g as O,f as P,N as Q,P as R,R as S,d as T,es as U,Ws as V,Fe as W,S as X,We as Y,Ps as Z,r as _,w as a,Z as a$,p as a0,Hr as a1,Ks as a2,M as a3,E as a4,Ir as a5,Lr as a6,V as a7,u as a8,Ur as a9,st as aA,fo as aB,ke as aC,Ee as aD,De as aE,j as aF,uo as aG,be as aH,po as aI,Vr as aJ,I as aK,nt as aL,oo as aM,Do as aN,_o as aO,L as aP,i as aQ,to as aR,no as aS,so as aT,ro as aU,io as aV,eo as aW,Ne as aX,X as aY,pe as aZ,Zs as a_,Ar as aa,Zr as ab,Be as ac,Qe as ad,le as ae,zr as af,y as ag,z as ah,Yr as ai,K as aj,qe as ak,Ie as al,Ae as am,$s as an,W as ao,A as ap,G as aq,ho as ar,Y as as,Q as at,Oe as au,tt as av,hs as aw,et as ax,B as ay,he as az,s as b,To as b0,No as b1,Io as b2,ko as b3,Co as b4,Ao as b5,lo as b6,Ys as b7,ie as b8,Ze as b9,Le as ba,qs as bb,me as bc,Xs as bd,H as be,O as bf,de as bg,C as bh,it as bi,ao as bj,Js as bk,_s as bl,co as bm,fe as bn,_e as bo,Se as bp,Te as bq,Ve as br,Ke as bs,t as c,ce as d,re as e,xe as f,n as g,Ue as h,k as i,ve as j,ge as k,ye as l,Ce as m,$ as n,Ye as o,c as p,a as q,mr as r,v as s,o as t,se as u,l as v,Jr as w,xo as x,Mo as y,Xr as z}; diff --git a/lib/__bundle-45809bc9.js b/lib/__bundle-45809bc9.js new file mode 100644 index 0000000..ac13a64 --- /dev/null +++ b/lib/__bundle-45809bc9.js @@ -0,0 +1 @@ +import{e,u as t,V as n,c as r,A as i,ae as s,f as a,h as o,g as u,U as c,af as l,Q as d,a as h,X as f,p,q as m,t as v,a7 as y,ag as _,ah as g,ai as b,C as I,aj as E,ak as T,al as w,W as M,am as S,_ as A,b as U,an as N,a2 as C,s as O,a8 as P,ao as k,ap as R,aq as x,w as D,ar as L,as as F,at as q,au as z,av as B,D as j,F as K,aw as Q,i as G,ax as V,ay as H,az as W,aA as Y,aB as J,aC as X,aD as Z,aE as $,aF as ee,aG as te,aH as ne,aI as re,aJ as ie,n as se,G as ae,O as oe,aK as ue,x as ce,y as le,aL as de,aM as he,aN as fe,d as pe,aO as me,aP as ve,aQ as ye,aR as _e,aS as ge,B as be,aT as Ie,aU as Ee,aV as Te,aW as we,aX as Me,aY as Se,z as Ae,aZ as Ue,a_ as Ne}from"./__bundle-c03282ec.js";var Ce,Oe=function(){function r(e,t,n){var r,i;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(r=t.real_width)&&void 0!==r?r:t.width,this.realHeight=null!==(i=t.real_height)&&void 0!==i?i:t.height,this._requireAuth=n}return r.payloadify=function(n){return e(t(n instanceof r?{url:n.plainUrl,width:n.width,height:n.height,real_width:n.realWidth,real_height:n.realHeight}:{url:"",width:n.maxWidth,height:n.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(r.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),r}(),Pe=function(t){function n(n){var r=t.call(this)||this;if(r.method=i.POST,r.path="".concat(s),r.params=e({file:n.file,channel_url:n.channelUrl}),n.thumbnailSizes)for(var a=0;a0:void 0,u.lastRepliedAt=null!==(a=t.last_replied_at)&&void 0!==a?a:0,u.updatedAt=null!==(o=t.updated_at)&&void 0!==o?o:0,u}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{reply_count:r.replyCount,unread_message_count:r.unreadReplyCount,member_count:r.memberCount,most_replies:Array.isArray(r.mostRepliedUsers)?r.mostRepliedUsers.map((function(e){return c.payloadify(e)})):[],push_enabled:"boolean"==typeof r.isPushNotificationEnabled?r.isPushNotificationEnabled?1:0:void 0,last_replied_at:r.lastRepliedAt,updated_at:r.updatedAt})))},Object.defineProperty(i.prototype,"_isUpdateRequired",{get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled},enumerable:!1,configurable:!0}),i.prototype._updateFrom=function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled},i}(l);!function(e){e.ADD="add",e.DELETE="delete"}(Ce||(Ce={}));var xe,De=function(e){this.messageId=0,this.operation=null,this.updatedAt=0;var t=h("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,n=e.user_id,r=e.operation?e.operation.toLowerCase():null,i=e.reaction,s=e.updated_at;t&&h("string",n)&&h("string",r)&&f(Ce,r)&&h("string",i)&&i&&h("number",s)&&(this.messageId=t,this.userId=n,this.key=i,this.operation=r,this.updatedAt=s)},Le=function(){function n(e){var t,n,r,i=e.key,s=null!==(r=p([],m(e.user_ids),!1))&&void 0!==r?r:[],a=e.updated_at;h("string",i)&&i&&d("string",s)&&s.length>0&&h("number",a)&&(this.key=i,this.userIds=s,this.updatedAt=a);var o={};try{for(var u=v(this.userIds),c=u.next();!c.done;c=u.next()){o[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._version=o}return Object.defineProperty(n.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({key:n.key,user_ids:n.userIds,updated_at:n.updatedAt}))},n.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 Ce.ADD:t<0&&this.userIds.push(e.userId);break;case Ce.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},n}(),Fe=function(){function n(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 n.payloadify=function(n){var r,i;return e(t({url:n.url,secure_url:n.secureUrl,type:n.type,width:null!==(r=n.width)&&void 0!==r?r:0,height:null!==(i=n.height)&&void 0!==i?i:0,alt:n.alt}))},n}(),qe=function(){function n(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 Fe(e["og:image"]))}return n.payloadify=function(n){return e(t({"og:title":n.title,"og:url":n.url,"og:description":n.description,"og:image":n.defaultImage?Fe.payloadify(n.defaultImage):null}))},n}(),ze=function(){function n(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 n.prototype.serialize=function(){return{name:this.name,volume:this.volume}},n.payloadify=function(n){return e(t({name:n.name,volume:n.volume}))},n}();!function(e){e.GOOD="good",e.BAD="bad"}(xe||(xe={}));var Be=function(){function n(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}return n._getStatus=function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"},n._isSubmitted=function(e){return"SUBMITTED"===n._getStatus(e)},n._getPayloadByStatus=function(e){return"NO_FEEDBACK"===e?{}:null},n.payloadify=function(n){return e(t({id:n.id,rating:n.rating,comment:n.comment}))},n}(),je=function(n){function i(e,t){var r,i=this;return(i=n.call(this,e,t)||this).isBlockedByMe=!1,i.role=f(y,t.role)?t.role:y.NONE,i.isBlockedByMe=null!==(r=t.is_blocked_by_me)&&void 0!==r&&r,i}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{role:r.role,is_blocked_by_me:r.isBlockedByMe})))},i}(c),Ke=function(){function n(e){this.key=e.key,this.value=d("string",e.value)?p([],m(e.value),!1):[]}return n.payloadify=function(n){var r;return e(t({key:n.key,value:null!==(r=n.value)&&void 0!==r?r:[]}))},n}(),Qe=function(e){switch(e){case g.BASE:return"";case g.USER:return"MESG";case g.FILE:return"FILE";case g.ADMIN:return"ADMM"}},Ge=function(n){function i(e,t){var r,i,s,a,o,u,l,d,h,p=this;(p=n.call(this,e)||this).channelType=I.BASE,p.messageType=g.BASE,p.mentionType=null,p.mentionedUsers=null,p.mentionedUserIds=null,p.mentionedMessageTemplate=void 0,p.metaArrays=[],p.extendedMessage={},p.createdAt=0,p.updatedAt=0,p.channelUrl=t.channel_url,p.channelType=f(I,t.channel_type)?t.channel_type:I.GROUP,t.channel&&(t.channel.channel_url&&(p.channelUrl=t.channel.channel_url),t.channel.channel_type&&(p.channelType=t.channel.channel_type)),p.data=null!==(r=t.data)&&void 0!==r?r:"",p.customType=null!==(i=t.custom_type)&&void 0!==i?i:"",p.mentionType=f(E,t.mention_type)?t.mention_type:null,p.mentionedUsers=t.mentioned_users?t.mentioned_users.map((function(e){return new c(p._iid,e)})):null,p.mentionedUserIds=null!==(s=t.mentioned_user_ids)&&void 0!==s?s:null,p.mentionedUsers&&!p.mentionedUserIds&&(p.mentionedUserIds=p.mentionedUsers.map((function(e){return e.userId}))),p.mentionedMessageTemplate=t.mentioned_message_template;var m=null!==(a=t.metaarray)&&void 0!==a?a:{},v=null!==(o=t.metaarray_key_order)&&void 0!==o?o:Object.keys(m).sort((function(e,t){return e.localeCompare(t)}));p.metaArrays=[];for(var y=0;y0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({id:n.id,name:n.name,items:n.items.map((function(e){return dt.payloadify(e)})),version:n.version,is_submitted:n._isSubmitted}))},n.isMessageFormPayload=function(e){return Boolean(null==e?void 0:e.message_form)},n}(),dt=function(){function n(t){var n=t.id,r=t.name,i=t.required,s=t.sort_order,a=t.placeholder,o=t.style,u=t.item_type,c=t.validators,l=t.value,d=t.values;this.id=n,this.name=r,this.required=i,this.sortOrder=s,this.placeholder=a,0===Object.keys(o).length?this.style={layout:u}:this.style=e({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),d?this.submittedValues=d:l&&(this.submittedValues=[l]),this._validators=c}return n.prototype.isValid=function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case it.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case it.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case it.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case it.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case it.DECIMAL_PLACE:return 0!==e.length&&(n=Number(e),!(isNaN(n)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(n,t.max_decimal_place)));default:return!0}}))}(e,t._validators);return n}))},n.payloadify=function(n){return e(t({id:n.id,name:n.name,required:n.required,sort_order:n.sortOrder,placeholder:n.placeholder,style:e({layout:n.style.layout,options:n.style.options,default_options:n.style.defaultOptions,result_count:n.style.resultCount}),item_type:n.style.layout,validators:n._validators,values:n.submittedValues}))},n}(),ht=function(t){function n(n){var r=t.call(this)||this;return r.method=i.POST,r.path="".concat(S,"/").concat(n.formId,"/submit"),r.params=e({message_id:n.messageId,items:n.items}),r}return r(n,t),n}(a);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ut||(ut={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ct||(ct={}));var ft,pt=function(i){function s(e,t){var n,r,s,a,o,u,c,l,d,h=this;return(h=i.call(this,e,t)||this).parentMessage=null,h.silent=!1,h.isOperatorMessage=!1,h.threadInfo=null,h.reactions=[],h.appleCriticalAlertOptions=null,h.scheduledInfo=null,h.suggestedReplies=null,h.myFeedback=null,h.myFeedbackStatus="NOT_APPLICABLE",h.messageForm=null,h._isContinuousMessages=!1,h._scheduledStatus=null,h.messageId=null!==(r=null!==(n=t.msg_id)&&void 0!==n?n:t.message_id)&&void 0!==r?r:0,h.parentMessageId=null!==(s="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==s?s:0,h.threadInfo=t.thread_info?new Re(h._iid,t.thread_info):null,h.reactions=t.reactions?t.reactions.map((function(e){return new Le(e)})):[],h.ogMetaData=t.og_tag?new qe(t.og_tag):null,h.silent=null!==(a=t.silent)&&void 0!==a&&a,h.isOperatorMessage=null!==(o=t.is_op_msg)&&void 0!==o&&o,h.appleCriticalAlertOptions=t.apple_critical_alert_options?new ze(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(h.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},h._scheduledStatus=t.scheduled_status),h._isContinuousMessages=null!==(u=t.is_continuous_messages)&&void 0!==u&&u,h.myFeedback=Be._isSubmitted(t.feedback)?new Be(t.feedback):null,h.myFeedbackStatus=Be._getStatus(t.feedback),h.suggestedReplies=null!==(l=null===(c=t.extended_message_payload)||void 0===c?void 0:c.suggested_replies)&&void 0!==l?l:null,h.messageForm=lt.isMessageFormPayload(t.extended_message_payload)?new lt(h.messageId,t.extended_message_payload.message_form):null,h.message=null!==(d=t.message)&&void 0!==d?d:"",h}return r(s,i),s.payloadify=function(n){var r,s;return e(t(u(u({},i.payloadify.call(this,n)),{message_id:n.messageId,parent_message_id:n.parentMessageId,thread_info:n.threadInfo?Re.payloadify(n.threadInfo):null,reactions:n.reactions.map((function(e){return Le.payloadify(e)})),og_tag:n.ogMetaData?qe.payloadify(n.ogMetaData):null,silent:n.silent,is_op_msg:n.isOperatorMessage,apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,scheduled_message_id:null===(r=n.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=n.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:n._scheduledStatus,feedback:n.myFeedback?Be.payloadify(n.myFeedback):Be._getPayloadByStatus(n.myFeedbackStatus),message:n.message})))},s._getParentMessageInfoPayload=function(n){return e(t({type:Qe(n.messageType),ts:n.createdAt,user:n.sender?je.payloadify(n.sender):null,message:n.message,file:{url:n.plainUrl,name:n.name,type:n.type,require_auth:n.requireAuth},files:Array.isArray(n.fileInfoList)?n.fileInfoList.map((function(e){return at.payloadify(e)})):null}))},s.prototype.isIdentical=function(e){return this.messageId===e.messageId},s.prototype.applyThreadInfoUpdateEvent=function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)},s.prototype.applyReactionEvent=function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1},s.prototype._triggerThreadInfoUpdatedEvent=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){return(e=n.of(this._iid).dispatcher).dispatch(new ot({channelType:I.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_THREADINFO_UPDATED})),[2]}))}))},s.prototype.markThreadAsRead=function(){return A(this,void 0,void 0,(function(){var e,t;return U(this,(function(r){switch(r.label){case 0:return e=n.of(this._iid).requestQueue,t=new Xe({channelUrl:this.channelUrl,messageId:this.messageId}),[4,e.send(t)];case 1:return r.sent(),this.threadInfo&&0!==this.threadInfo.unreadReplyCount?(this.threadInfo.unreadReplyCount=0,[4,this._triggerThreadInfoUpdatedEvent()]):[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},s.prototype.setPushNotificationEnabled=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return t=n.of(this._iid).requestQueue,r=new Ze({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),[4,t.send(r)];case 1:return i.sent(),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e),[2]}}))}))},s.prototype.submitMessageForm=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(t=n.of(this._iid).requestQueue,r=null,i=null,s=this.messageForm,!e&&s){if(!s.isSubmittable)throw new O({code:P.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(s.isSubmitted)throw new O({code:P.INVALID_PARAMETER,message:"The form has already been submitted."});r=s.id,i=s.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[])}else e&&(r=e.formId,i=Object.entries(e.answers).reduce((function(e,t){var n=m(t,2),r=n[0],i=n[1],s=Number(r);if(Number.isNaN(s))throw new O({code:P.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:s,value:i}),e}),[]));if(!r||!i)throw new O({code:P.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});return a=new ht({messageId:this.messageId,formId:r,items:i}),[4,t.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.submitFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new $e({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(et),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_ADDED})),[2]}}))}))},s.prototype.updateFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new tt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(nt),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_UPDATED})),[2]}}))}))},s.prototype.deleteFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new rt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e}),[4,r.send(s)];case 1:return a.sent(),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_DELETED})),[2]}}))}))},s}(Ge),mt=function(n){function i(e,t){var r,i,s,a,o=this;if((o=n.call(this,e,t)||this).reqId="",o.replyToChannel=!1,o.errorCode=0,o.sender=t.user?new je(o._iid,t.user):t.sender_id,o.reqId=null!==(i=null!==(r=t.req_id)&&void 0!==r?r:t.request_id)&&void 0!==i?i:"",o.replyToChannel=null!==(s=t.is_reply_to_channel)&&void 0!==s&&s,t.request_state&&f(k,t.request_state)&&(o.sendingStatus=t.request_state),!o.sendingStatus)if(o.messageId>0)o.sendingStatus=k.SUCCEEDED;else if(o.scheduledInfo)switch(t.scheduled_status&&(o._scheduledStatus=t.scheduled_status),t.scheduled_status){case ct.SENT:case ct.IN_QUEUE:o.sendingStatus=k.SUCCEEDED;break;case ct.PENDING:o.sendingStatus=k.SCHEDULED;break;case ct.FAILED:case ct.REMOVED:o.sendingStatus=k.FAILED;break;case ct.CANCELED:o.sendingStatus=k.CANCELED}else o.sendingStatus=k.PENDING;return o.errorCode=null!==(a=t.error_code)&&void 0!==a?a:0,o._messageToken=t.mesg_token,o}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{user:je.payloadify(r.sender),req_id:r.reqId,is_reply_to_channel:r.replyToChannel,request_state:r.sendingStatus,error_code:r.errorCode,mesg_token:r._messageToken})))},Object.defineProperty(i.prototype,"isResendable",{get:function(){return(this.sendingStatus===k.FAILED||this.sendingStatus===k.CANCELED)&&R(this.errorCode)},enumerable:!1,configurable:!0}),i.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},i}(pt),vt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},yt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)},_t=function(n){function i(r,i){var s,a,o,c=this;if((c=n.call(this,r,i)||this).translations={},c.messageType=g.ADMIN,c.translations=null!==(s=i.translations)&&void 0!==s?s:{},i.parent_message_info){var l=i.parent_message_info;c.parentMessage=Mt(r,e(t(u(u({},l),{message_id:c.parentMessageId,channel_url:c.channelUrl,channel_type:c.channelType,file:l.file,url:null===(a=l.file)||void 0===a?void 0:a.url,require_auth:null===(o=l.file)||void 0===o?void 0:o.require_auth}))))}return c}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{translations:r.translations,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i}(pt),gt=function(){function n(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&&h("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return n.payloadify=function(n){return e(t({type:n.type,vendor:n.vendor,detail:n.detail}))},n}(),bt=function(){function t(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}return t.payloadify=function(t){return e({status:t.status,original_message_info:t.originalMessageInfo?{id:t.originalMessageInfo.messageId,ts:t.originalMessageInfo.createdAt}:void 0})},t}(),It=function(n){function i(r,i){var s,a,o,c,l,d,h,f=this;if((f=n.call(this,r,i)||this).messageParams=null,f.translations={},f.translationTargetLanguages=[],f.messageSurvivalSeconds=-1,f.plugins=[],f._poll=null,f.messageType=g.USER,f.translations=null!==(o=i.translations)&&void 0!==o?o:{},f.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(f.translations).length&&f.translationTargetLanguages.length>0)try{for(var p=v(f.translationTargetLanguages),m=p.next();!m.done;m=p.next()){var y=m.value;f.translations[y]=""}}catch(e){s={error:e}}finally{try{m&&!m.done&&(a=p.return)&&a.call(p)}finally{if(s)throw s.error}}if(f.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,f.plugins=i.plugins?i.plugins.map((function(e){return new gt(e)})):[],f._poll=i.poll?new L(f._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;f.parentMessage=Mt(r,e(t(u(u({},_),{created_at:_.ts,message_id:f.parentMessageId,channel_url:f.channelUrl,channel_type:f.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(f.messageReviewInfo=new bt(i.review_info)),f}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{translations:r.translations,message_survival_seconds:r.messageSurvivalSeconds,plugins:r.plugins.map((function(e){return gt.payloadify(e)})),poll:r._poll?L.payloadify(r._poll):null,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null,review_info:r.messageReviewInfo?bt.payloadify(r.messageReviewInfo):void 0})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(i.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),i}(mt),Et=function(n){function i(r,i){var s,a,o,c,l,d,h,f,p=this;if((p=n.call(this,r,i)||this).messageParams=null,p.fileInfoList=[],p.messageSurvivalSeconds=-1,p.messageType=g.FILE,p.data=null!==(o=null!==(a=null===(s=i.file)||void 0===s?void 0:s.data)&&void 0!==a?a:i.custom)&&void 0!==o?o:"",p.fileInfoList=null!==(l=null===(c=i.files)||void 0===c?void 0:c.map((function(e){return new at(r,e)})))&&void 0!==l?l:[],p.messageSurvivalSeconds=null!==(d=i.message_survival_seconds)&&void 0!==d?d:-1,i.parent_message_info){var m=i.parent_message_info;p.parentMessage=Mt(r,e(t(u(u({},m),{created_at:m.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:m.file,url:null===(h=m.file)||void 0===h?void 0:h.url,require_auth:null===(f=m.file)||void 0===f?void 0:f.require_auth}))))}return p}return r(i,n),i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.payloadify=function(r){var i,s,a,o,c,l;return e(t(u(u({},n.payloadify.call(this,r)),{file:{name:null!==(s=null===(i=r.fileInfoList[0])||void 0===i?void 0:i.fileName)&&void 0!==s?s:"",size:null!==(o=null===(a=r.fileInfoList[0])||void 0===a?void 0:a.fileSize)&&void 0!==o?o:0,type:null!==(l=null===(c=r.fileInfoList[0])||void 0===c?void 0:c.mimeType)&&void 0!==l?l:"",data:r.data},files:Array.isArray(r.fileInfoList)?r.fileInfoList.map((function(e){return at.payloadify(e)})):null,message_survival_seconds:r.messageSurvivalSeconds,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},i._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},i}(mt);!function(e){e.SENT="SENT",e.READ="READ"}(ft||(ft={}));var Tt=function(n){function i(e,t){var r,i,s=this;if((s=n.call(this,e,t)||this).notificationData=null,s.notificationId=t.notification_message_id,s.messageType=g.ADMIN,s.messageStatus=null!==(r=t.message_status)&&void 0!==r?r:ft.SENT,s.priority=null!==(i=t.priority)&&void 0!==i?i:F.NORMAL,s.notificationEventDeadline=t.notification_event_deadline,0===s.extendedMessage.sub_type)try{var a=JSON.parse(s.extendedMessage.sub_data),o=a.label,u=a.tags,c=void 0===u?[]:u,l=a.template_key,d=a.template_variables;s.notificationData={label:o,tags:c,templateKey:l,templateVariables:d}}catch(e){}return s}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{notification_message_id:r.notificationId,message_status:r.messageStatus,priority:r.priority,notification_event_deadline:r.notificationEventDeadline})))},i.prototype.isIdentical=function(e){return this.notificationId===e.notificationId},i}(Ge),wt=function(e){if(e.notificationId)return Tt.payloadify(e);switch(e.messageType){case g.USER:return It.payloadify(e);case g.FILE:return e.fileInfoList?Et.payloadify(e):St.payloadify(e);case g.ADMIN:return _t.payloadify(e);default:throw O.unknown}},Mt=function(e,t){if(t.notification_message_id)return new Tt(e,t);switch(t.type){case"MESG":return new It(e,t);case"FILE":return Et._isMultipleFilesMessagePayload(t)?new Et(e,t):new St(e,t);case"ADMM":case"BRDM":return new _t(e,t);default:return null}},St=function(i){function s(n,r){var s,a,o,c,l,d,h,f,p,m,v,y,_,b,I=this;(I=i.call(this,n,r)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=g.FILE;var E=r.file;if(I.plainUrl=(null!==(a=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==a?a:"").split("?auth=")[0],I.name=null!==(c=null!==(o=null==E?void 0:E.name)&&void 0!==o?o:r.name)&&void 0!==c?c:"File",I.size=null!==(d=null!==(l=null==E?void 0:E.size)&&void 0!==l?l:r.size)&&void 0!==d?d:0,I.data=null!==(f=null!==(h=null==E?void 0:E.data)&&void 0!==h?h:r.custom)&&void 0!==f?f:"",I.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(m=r.type)&&void 0!==m?m:"",I.requireAuth=null!==(v=r.require_auth)&&void 0!==v&&v,I.thumbnails=r.thumbnails?r.thumbnails.map((function(e){var t;return new Oe(I._iid,"string"==typeof e?{url:e,width:0,height:0}:u(u({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),I.requireAuth)})):[],I.messageSurvivalSeconds=null!==(y=r.message_survival_seconds)&&void 0!==y?y:-1,r.parent_message_info){var T=r.parent_message_info;I.parentMessage=Mt(n,e(t(u(u({},T),{created_at:T.ts,message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:T.file,url:null===(_=T.file)||void 0===_?void 0:_.url,require_auth:null===(b=T.file)||void 0===b?void 0:b.require_auth}))))}return I}return r(s,i),s.payloadify=function(n){var r;return e(t(u(u({},i.payloadify.call(this,n)),{url:n.plainUrl,require_auth:n.requireAuth,file:{name:n.name,size:n.size,type:n.type,data:n.data},thumbnails:null===(r=n.thumbnails)||void 0===r?void 0:r.map((function(e){return{url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:n.messageSurvivalSeconds,parent_message_info:n.parentMessage?i._getParentMessageInfoPayload.call(this,n.parentMessage):null})))},Object.defineProperty(s.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},s}(mt),At=function(e){function t(t,n){var r=n.file,i=n.fileUrl,s=n.fileName,a=n.fileSize,o=n.mimeType,u=n.thumbnailSizes,c=n._uploadedMetaData,l=n._thumbnails,d=e.call(this,t)||this;return d._plainUrl=i,d.file=r,d.fileName=s,d.fileSize=a,d.mimeType=o,d.thumbnailSizes=u,d._uploadedMetaData=c,d._thumbnails=l,d}return r(t,e),t.getPlainUrl=function(e){return e instanceof t?e._plainUrl:e.fileUrl},Object.defineProperty(t.prototype,"fileUrl",{get:function(){var e,t=n.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}},t}(l),Ut=function(n){function i(r){var i,s,a,o,u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,files:r.files?Pt(r.files):null,url:r.url,name:null!==(i=r.fileName)&&void 0!==i?i:"",type:null!==(s=r.mimeType)&&void 0!==s?s:"",size:null!==(a=r.fileSize)&&void 0!==a?a:0,custom:r.data,custom_type:r.customType,thumbnails:null===(o=r._thumbnails)||void 0===o?void 0:o.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:u,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,pin_message:r.isPinnedMessage,message:r.message}))})||this}return r(i,n),i}(T),Nt=function(n){function s(r){var s,a,o=this;o=n.call(this)||this;var u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),o.method=i.POST,o.path="".concat(w(r.channelType),"/").concat(encodeURIComponent(r.channelUrl),"/messages"),o.params=e(t({message_type:g.FILE,user_id:r.userId,files:r.files?Pt(r.files):null,url:r.fileUrl,mention_type:r.mentionType,mentioned_user_ids:u,file_name:r.fileName,file_size:r.fileSize,file_type:r.mimeType,data:r.data,custom_type:r.customType,thumbnails:null===(s=r._thumbnails)||void 0===s?void 0:s.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,sorted_metaarray:null===(a=r.metaArrays)||void 0===a?void 0:a.map((function(e){return Ke.payloadify(e)})),push_option:r.pushNotificationDeliveryOption,parent_message_id:r.parentMessageId?r.parentMessageId:null,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,reply_to_channel:r.isReplyToChannel,req_id:r.reqId,pin_message:r.isPinnedMessage})),o}return r(s,n),s}(a),Ct=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"FILE",i)||this).message=i.files&&i.files.length>=2?new Et(t,i):new St(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),Ot=function(e){function t(t,r){var i,s,a,o,u=this;(u=e.call(this,t,r)||this).message=r.files&&r.files.length>=2?new Et(t,r):new St(t,r);var c=n.of(t).sdkState;return u.isMentioned=z(u.message.mentionType,null!==(a=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(s=u.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return r(t,e),t}(o);function Pt(n){return n.map((function(n){var r,i;return e(t({url:At.getPlainUrl(n),file_name:n.fileName,file_type:n.mimeType,file_size:n.fileSize,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),require_auth:null===(i=n._uploadedMetaData)||void 0===i?void 0:i.requireAuth}))}))}var kt;!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"}(kt||(kt={}));var Rt=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext,o=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=a,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof j&&(o._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===K.CONNECTED||this._connectionState===K.CONNECTING||this._connectionState===K.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){switch(s.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(r=new Ut(n),[4,this._requestQueue.send(r)]):[3,2];case 1:return i=s.sent(),[2,i.as(Ct).message];case 2:return r=new Nt(u(u({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),[2,i.as(Ot).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=u(u({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{r=t.params;n.url=r.fileUrl,n.requireAuth=r.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p;return U(this,(function(m){switch(m.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,r=[],i=!0,m.label=1;case 1:m.trys.push([1,15,16,17]),s=v(n.messageQueue),a=s.next(),m.label=2;case 2:if(a.done)return[3,14];switch(o=a.value,o.state){case kt.PENDING:case kt.UPLOADING:return[3,3];case kt.UPLOADED:return[3,4];case kt.FAILED:return[3,12]}return[3,13];case 3:return i=!1,r.push(o),[3,13];case 4:if(!i)return[3,10];m.label=5;case 5:return m.trys.push([5,8,,9]),o.state=kt.SENDING,[4,this._sendFileMessage(e,o)];case 6:return u=m.sent(),o.deferred.resolve(u),[4,Q(100)];case 7:return m.sent(),[3,9];case 8:return c=m.sent(),o.deferred.reject(c),[3,9];case 9:return[3,11];case 10:r.push(o),m.label=11;case 11:return[3,13];case 12:return l=null!==(t=o.error)&&void 0!==t?t:O.unknown,o.deferred.reject(l.code===P.REQUEST_CANCELED?O.fileUploadCanceled:l),[3,13];case 13:return a=s.next(),[3,2];case 14:return[3,17];case 15:return d=m.sent(),f={error:d},[3,17];case 16:try{a&&!a.done&&(p=s.return)&&p.call(s)}finally{if(f)throw f.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:m.sent(),m.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,m.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d;return U(this,(function(h){switch(h.label){case 0:return(n=this._queueMap.get(e.url))&&(r=n.messageQueue.find((function(e){return e.state===kt.PENDING})))?r.multipleFileUploadInfo?(i=r.multipleFileUploadInfo,s=i.uploadIndex,a=i.uploadCount,o=i.requestHandler,d=r.params,u=d.fileInfoList[s],!G(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]):[3,4]:[3,9];case 1:return h.sent(),[3,3];case 2:r.state=s=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,u,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return a=new Pe({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(a)];case 1:return o=v.sent(),u=o.as(ke),c=u.url,l=u.fileSize,d=void 0===l?n.fileSize:l,h=u.thumbnails,f=void 0===h?[]:h,p=u.requireAuth,m=void 0!==p&&p,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(i=n.mimeType)&&void 0!==i?i:n.file.type,n.fileSize=null!==(s=n.fileSize)&&void 0!==s?s:n.file.size,n.fileUrl=c,n.fileSize=d,n.requireAuth=m,n._thumbnails=f,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,c,l,d,h,f,p,m,v,y;return U(this,(function(_){switch(_.label){case 0:return a=t.multipleFileUploadInfo.uploadIndex,o=n.fileInfoList[a],c=new Pe({file:o.file,channelUrl:e.url,thumbnailSizes:o.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(c)];case 1:return l=_.sent(),d=l.as(ke),h=d.url,f=d.fileSize,p=void 0===f?o.fileSize:f,m=d.thumbnails,v=d.requireAuth,y=void 0!==v&&v,o.fileName=null!==(r=o.fileName)&&void 0!==r?r:o.file.name,o.mimeType=null!==(i=o.mimeType)&&void 0!==i?i:o.file.type,o.fileSize=null!==(s=o.fileSize)&&void 0!==s?s:o.file.size,o.file=void 0,o.fileUrl=h,o.fileSize=p,o._thumbnails=m,o._uploadedMetaData=u(u({},o._uploadedMetaData),{requireAuth:y,isUploaded:!0}),o instanceof At||(n.fileInfoList[a]=new At(this._iid,o)),[2]}}))}))},e.prototype.request=function(e,t,n,r){return void 0===r&&(r={}),A(this,void 0,void 0,(function(){var i,s,a,o,c;return U(this,(function(l){return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),a=new V,o={requestId:t,params:n,state:kt.PENDING,deferred:a},function(e){return"fileInfoList"in e}(n)&&(c=u({uploadIndex:0,uploadCount:n.fileInfoList.length},r),o.multipleFileUploadInfo=c),s.messageQueue.push(o),this._uploadNextPendingItem(e),[2,a.promise]}))}))},e.prototype.cancel=function(e,t){var n,r,i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:p([],m(i.messageQueue),!1);try{for(var a=v(s),o=a.next();!o.done;o=a.next()){var u=o.value;if(u)switch(u.state){case kt.PENDING:if(u.state=kt.FAILED,u.error=O.requestCanceled,u.multipleFileUploadInfo&&!u.multipleFileUploadInfo.isCopy){var c=u.multipleFileUploadInfo,l=c.uploadIndex,d=c.requestHandler,h=u.params.fileInfoList[l];null==d||d._triggerOnFileUploaded(u.requestId,l,h,O.fileUploadCanceled)}this._resolveMessageQueue(e);break;case kt.UPLOADING:this._requestQueue.cancel(u.requestId),this._dispatcher.dispatch(new B({requestId:u.requestId}))}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new B({requestId:t})))},e}();var xt,Dt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:H.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Lt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&f(H,e.replyType)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)&&h("boolean",e.showSubchannelMessagesOnly)},Ft={replyType:H.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},qt=function(e){return f(H,e.replyType)&&h("boolean",e.includeReactions)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)},zt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.includeMetaArray,o=t.includeReactions,u=t.includeThreadInfo,c=t.includeParentMessageInfo,l=e.call(this)||this;return l.method=i.GET,l.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s)),l.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions:o,include_thread_info:u,include_parent_message_info:c,include_poll_details:!0},l}return r(t,e),t}(a),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o),jt=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.timestamp,u=r.token,c=r.prevResultSize,l=r.nextResultSize,d=r.isInclusive,h=r.reverse,f=r.messageTypeFilter,p=r.customTypesFilter,m=r.senderUserIdsFilter,v=r.replyType,y=r.includeMetaArray,_=r.includeReactions,g=r.parentMessageId,b=r.includeThreadInfo,I=r.includeParentMessageInfo,E=r.showSubchannelMessagesOnly,T=r.checkingHasNext,M=r.checkingContinuousMessages,S=n.call(this)||this;return S.method=i.GET,S.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages"),S.params=e(t({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:m,include_reply_type:v,with_sorted_meta_array:y,include_reactions:_,parent_message_id:g,include_thread_info:b,include_parent_message_info:I,show_subchannel_message_only:E,include_poll_details:!0,checking_has_next:T,checking_continuous_messages:M})),S}return r(s,n),s}(a),Kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return void 0!==n.is_continuous_messages&&(r.isContinuousMessages=n.is_continuous_messages),void 0!==n.has_next&&(r.hasNext=n.has_next),r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),Qt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.timestamp,a=t.token,o=t.replyType,u=t.includeMetaArray,c=t.includeReactions,l=t.includeThreadInfo,d=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=i.GET,h.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:s,token:a,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_reply_type:o,include_parent_message_info:d,include_poll_details:!0},h}return r(t,e),t}(a),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return Mt(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return r(t,e),t}(o),Vt=function(e){function t(t){var n=t.channelUrl,r=t.scheduledMessageId,s=e.call(this)||this;return s.method=i.GET,s.path="".concat(W,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),s.params={},s}return r(t,e),t}(a),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o);!function(e){e.MUTED="muted",e.BANNED="banned"}(xt||(xt={}));var Wt=function(){function n(e){var t,n,r,i;this.restrictionType=null,f(xt,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(r=null!==(n=e.end_at)&&void 0!==n?n:e.muted_end_at)&&void 0!==r?r:-1,this.remainingDuration=null!==(i=e.remaining_duration)&&void 0!==i?i:-1}return n.payloadify=function(n){return e(t({restriction_type:n.restrictionType,description:n.description,end_at:n.endAt,remaining_duration:n.remainingDuration}))},n}(),Yt=function(n){function i(e,t){var r=n.call(this,e,t)||this;return r.restrictionInfo=new Wt(t),r}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),Wt.payloadify(r.restrictionInfo))))},i}(c),Jt=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return r(t,e),t}(c),Xt=function(){function e(){this._onPending=Y,this._onFailed=Y,this._onSucceeded=Y}return e.prototype._trigger=function(e){switch(null==e?void 0:e.sendingStatus){case k.PENDING:0===e.errorCode&&this._onPending(e);break;case k.SCHEDULED:case k.SUCCEEDED:this._onSucceeded(e)}},e.prototype._triggerFailed=function(e,t){switch(null==t?void 0:t.sendingStatus){case k.FAILED:case k.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}(),Zt={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},$t=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(Ke,e.metaArrays,!0)&&h("number",e.parentMessageId,!0)&&h("boolean",e.isReplyToChannel)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)&&h("boolean",e.isPinnedMessage,!0)},en=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},tn=u(u({},Zt),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function nn(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var rn,sn=function(n){var r;return e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,pollId:null===(r=n.poll)||void 0===r?void 0:r.id,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,message:n.message,translationTargetLanguages:Object.keys(n.translations),extendedMessagePayload:n.extendedMessagePayload}))},an=function(e){return $t(e)&&h("string",e.message)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)&&h("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(rn||(rn={}));var on=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},un=function(e){return e===rn.BLOB||e===rn.FILE},cn=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},ln=u(u({},Zt),{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,message:void 0});function dn(e){var n,r,i,s;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=e.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails,message:e.message}))}var hn,fn=function(n,r){var i;return n.messageParams?(!n.url&&G(r)&&(n.messageParams.file=r),n.messageParams):e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,file:r,fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,thumbnailSizes:null===(i=n.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),message:n.message}))},pn=function(e){return $t(e)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&h("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},mn={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},vn=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(Ke,e.metaArrays,!0)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)},yn=u(u({},mn),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),_n=function(e){return vn(e)&&h("string",e.message,!0)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)},gn=u({},mn),bn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.token,a=t.limit,o=e.call(this)||this;return o.method=i.GET,o.path="".concat(w(r),"/").concat(encodeURIComponent(n),"/operators"),o.params={token:s,limit:a},o}return r(t,e),t}(a),In=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new c(t,e)})),r.token=n.next,r}return r(t,e),t}(o),En=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=n.of(this._iid).requestQueue,r=new bn(u(u({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(r)]):[3,2]):[3,5];case 1:return i=c.sent(),s=i.as(In),a=s.operators,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),Tn=function(e){function n(t,n,r,i){var s,a,o,u,c,l,d,h,f,p,m=this;return(m=e.call(this,t,n,r,i)||this).reverse=!1,m.messageTypeFilter=x.ALL,m.customTypesFilter=null,m.senderUserIdsFilter=null,m.replyType=H.NONE,m.includeMetaArray=!1,m.includeReactions=!1,m.includeParentMessageInfo=!1,m.includeThreadInfo=!1,m.showSubchannelMessagesOnly=!1,m._edge=Number.MAX_SAFE_INTEGER,m.reverse=null!==(s=i.reverse)&&void 0!==s&&s,m.messageTypeFilter=null!==(a=i.messageTypeFilter)&&void 0!==a?a:x.ALL,m.customTypesFilter=null!==(o=i.customTypesFilter)&&void 0!==o?o:null,m.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,m.replyType=null!==(c=i.replyType)&&void 0!==c?c:H.NONE,m.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,m.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,m.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,m.includeThreadInfo=null!==(f=i.includeThreadInfo)&&void 0!==f&&f,m.showSubchannelMessagesOnly=null!==(p=i.showSubchannelMessagesOnly)&&void 0!==p&&p,m}return r(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.reverse)&&f(x,this.messageTypeFilter)&&f(H,this.replyType)&&d("string",this.customTypesFilter,!0)&&d("string",this.senderUserIdsFilter,!0)&&h("boolean",this.includeMetaArray)&&h("boolean",this.includeReactions)&&h("boolean",this.includeParentMessageInfo)&&h("boolean",this.includeThreadInfo)&&h("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,$s.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t({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=n.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 O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},n}(J),wn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.limit,o=t.token;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:o},n}return r(t,e),t}(a),Mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.mutedUsers=[];var i=n.next,s=n.muted_list;return r.token=i,s&&s.length>0&&(r.mutedUsers=s.map((function(e){return new Yt(t,e)}))),r}return r(t,e),t}(o),Sn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new wn(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Mn),s=i.mutedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),An=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.limit,u=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({limit:o,token:u}),r}return r(n,t),n}(a),Un=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map((function(e){return new Yt(t,e.user)}))),r}return r(t,e),t}(o),Nn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new An(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Un),s=i.bannedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(hn||(hn={}));var Cn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var On=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var Pn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return r(t,e),t}(a),kn=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,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return r(t,e),t}(o),Rn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return r(t,e),t}(a),xn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),Dn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return r(t,e),t}(a),Ln=function(e){function t(t,n){var r,i,s=this;return(s=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},s.ts=null!==(i=n.ts)&&void 0!==i?i:null,s}return r(t,e),t}(o),Fn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata,o=t.upsert;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=o&&o},n}return r(t,e),t}(a),qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),zn=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 r(t,e),t}(M),Bn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return r(t,e),t}(a),jn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),Kn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return r(t,e),t}(a),Qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),Gn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return r(t,e),t}(a),Vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Hn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return r(t,e),t}(a),Wn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Yn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter,o=t.upsert,u=void 0!==o&&o,c=t.mode,l=void 0===c?"set":c;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:u,mode:l},n}return r(t,e),t}(a),Jn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Xn=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 r(t,e),t}(M),Zn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params={},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var $n=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var er=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId,o=t.seconds,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:o,description:u},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var tr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),nr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var rr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ir=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.userId,u=n.seconds,c=n.description;return(r=t.call(this)||this).method=i.POST,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({user_id:o,seconds:u,description:c}),r}return r(n,t),n}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var sr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(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 r(t,e),t}(M),ar=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var or=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ur=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var cr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return r(t,e),t}(M),lr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(X(s),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:o,report_description:u},n}return r(t,e),t}(a),dr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.offendingUserId,c=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(Z,"/users/").concat(u),n.params={channel_url:r,channel_type:s===I.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:o,report_description:c},n}return r(t,e),t}(a),hr=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.category,u=n.userId,c=n.offendingUserId,l=n.messageId,d=n.description,h=n.messageToken;return(r=t.call(this)||this).method=i.POST,r.path="".concat(X(a),"/").concat(encodeURIComponent(s),"/messages/").concat(l),r.params=e({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),r}return r(n,t),n}(a),fr=function(n){function i(r){var i=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,poll_id:r.pollId,pin_message:r.isPinnedMessage,extended_message_payload:r.extendedMessagePayload}))})||this}return r(i,n),i}(T),pr=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"MESG",i)||this).message=new It(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),mr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,poll_id:r.pollId}))})||this}return r(i,n),i}(T),vr=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"MEDI",s)||this).message=new It(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),yr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,apple_critical_alert_options:r.appleCriticalAlertOptions}))})||this}return r(i,n),i}(T),_r=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"FEDI",s)||this).message=new St(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),gr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),br=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(n),r}return r(t,e),t}(o),Ir=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.DELETE,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),Er=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(u({},n)),r}return r(t,e),t}(o),Tr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.translationTargetLanguages,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s),"/translation"),o.params={target_langs:a},o}return r(t,e),t}(a),wr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Mr=function(n){function s(r){var s,a=this;a=n.call(this)||this;var o=[];r.mentionType===E.USERS&&(r.mentionedUserIds?o=r.mentionedUserIds:r.mentionedUsers&&(o=r.mentionedUsers.map((function(e){return e.userId}))));var u=r.channelType,c=r.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=e(t({req_id:r.reqId,scheduled_at:r.scheduledAt,message_type:ee.USER,message:r.message,custom_type:r.customType,data:r.data,mention_type:r.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=r.metaArrays)||void 0===s?void 0:s.map((function(e){return Ke.payloadify(e)})),apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption})),a}return r(s,n),s}(a),Sr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Ar=function(e){function n(n){var r,s,a=this;a=e.call(this)||this;var o=[];n.mentionType===E.USERS&&(n.mentionedUserIds?o=n.mentionedUserIds:n.mentionedUsers&&(o=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=t({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ee.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=n.metaArrays)||void 0===s?void 0:s.map((function(e){return Ke.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,push_option:n.pushNotificationDeliveryOption}),a}return r(n,e),n}(a),Ur=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new St(t,n),r}return r(t,e),t}(o),Nr=function(e){function t(t){var n=t.pollId,r=t.title,s=t.data,a=t.allowUserSuggestion,o=t.allowMultipleVotes,u=t.closeAt,c=e.call(this)||this;return c.method=i.PUT,c.path="".concat(ne,"/").concat(encodeURIComponent(n)),c.params={title:r,data:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return r(t,e),t}(a),Cr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Or=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.DELETE,r.path="".concat(ne,"/").concat(encodeURIComponent(n)),r}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var Pr=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.PUT,r.path="".concat(ne,"/").concat(encodeURIComponent(n),"/close"),r}return r(t,e),t}(a),kr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Rr=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.pollId,a=t.optionText,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(ne,"/").concat(encodeURIComponent(s),"/options"),o.params={channel_url:n,channel_type:r,text:a},o}return r(t,e),t}(a),xr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Dr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=t.optionText,a=e.call(this)||this;return a.method=i.PUT,a.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:s},a}return r(t,e),t}(a),Lr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Fr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=e.call(this)||this;return s.method=i.DELETE,s.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var qr=function(t){function n(n){var r=n.reqId,i=n.channelType,s=n.channelUrl,a=n.pollId,o=n.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:e({req_id:r,channel_type:i===I.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:a,option_ids:o})})||this}return r(n,t),n}(T),zr=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=new re(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return r(t,e),t}(M),Br=100,jr="GroupChannel",Kr="url",Qr=100,Gr="Message",Vr="messageId",Hr=100,Wr="NotificationMessage",Yr="notificationId",Jr="Poll",Xr="pollId",Zr=100,$r="FeedChannel",ei="url";function ti(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((function(e){var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))}var ni=u(u({},Zt),{fileInfoList:[],message:""}),ri=function(e){return(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},ii=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._onFileUploaded=Y,t}return r(t,e),t.prototype._triggerOnFileUploaded=function(e,t,n,r){this._onFileUploaded(e,t,n,r)},t.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},t.prototype.onPending=function(t){return e.prototype.onPending.call(this,t),this},t.prototype.onFailed=function(t){return e.prototype.onFailed.call(this,t),this},t.prototype.onSucceeded=function(t){return e.prototype.onSucceeded.call(this,t),this},t}(Xt),si=function(e){function t(t,n){var r=e.call(this,t)||this;return r.message=null,r.message=Mt(t,n.message),r}return r(t,e),t}(l),ai=function(t){function n(n){var r=this,s=n.channelType,a=n.channelUrl,o=n.limit,u=n.token,c=n.includeReactions,l=n.includeMetaArray,d=n.includeParentMessageInfo,h=n.includeThreadInfo,f=n.includePollDetails;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/pinned_messages"),r.params=e({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),r}return r(n,t),n}(a),oi=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.pinned_messages,s=n.has_more,a=n.next;return r.pinnedMessages=i.map((function(e){return new si(t,e)})),r.hasMore=s,r.token=a,r}return r(t,e),t}(o),ui=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s.includeMetaArray=i.includeMetaArray,s.includeReactions=i.includeReactions,s.includeParentMessageInfo=i.includeParentMessageInfo,s.includeThreadInfo=i.includeThreadInfo,s.includePollDetails=i.includePollDetails,s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.includeMetaArray,!0)&&h("boolean",this.includeReactions,!0)&&h("boolean",this.includeParentMessageInfo,!0)&&h("boolean",this.includeThreadInfo,!0)&&h("boolean",this.includePollDetails,!0)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new ai(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=c.sent(),i=r.as(oi),s=i.pinnedMessages,a=i.hasMore,o=i.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ci=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.POST,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var li=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.DELETE,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var di,hi=2;!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(di||(di={}));var fi,pi=function(i){function s(e,t){var n,r,s,a,o,u,l,d=this;return(d=i.call(this,e)||this)._name="",d._createdAt=0,d.pinnedMessageIds=[],d.channelType=I.BASE,d.coverUrl="",d.customType="",d.data="",d.isFrozen=!1,d.isEphemeral=!1,d.creator=null,d._messageCollectionLastAccessedAt=0,d._url=t.channel_url,d._name=null!==(n=t.name)&&void 0!==n?n:"",d._createdAt=1e3*t.created_at,d.coverUrl=null!==(r=t.cover_url)&&void 0!==r?r:"",d.customType=null!==(s=t.custom_type)&&void 0!==s?s:"",d.data=null!==(a=t.data)&&void 0!==a?a:"",d.isFrozen=null!==(o=t.freeze)&&void 0!==o&&o,d.isEphemeral=null!==(u=t.is_ephemeral)&&void 0!==u&&u,d.creator=t.created_by?new c(d._iid,t.created_by):null,t.metadata&&Object.keys(t.metadata).length>0&&t.ts?(d._cachedMetaData=new Map,Object.keys(t.metadata).forEach((function(e){d._cachedMetaData.set(e,{value:t.metadata[e],isRemoved:!1,updatedAt:t.ts})}))):"string"==typeof t.metadata&&(d._cachedMetaData=new Map(Object.entries(JSON.parse(t.metadata)))),d.pinnedMessageIds=null!==(l=t.pinned_message_ids)&&void 0!==l?l:[],d}return r(s,i),Object.defineProperty(s.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),s.prototype.toJSON=function(){return u(u({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},s.payloadify=function(n){return e(t(u(u({},i.payloadify.call(this,n)),{channel_url:n.url,name:n.name,cover_url:n.coverUrl,custom_type:n.customType,data:n.data,freeze:n.isFrozen,is_ephemeral:n.isEphemeral,created_by:n.creator?c.payloadify(n.creator):null,created_at:n.createdAt/1e3,metadata:n.cachedMetaData,pinned_message_ids:n.pinnedMessageIds})))},s.prototype.isGroupChannel=function(){return this.channelType===I.GROUP},s.prototype.isOpenChannel=function(){return this.channelType===I.OPEN},s.prototype.isFeedChannel=function(){return this.channelType===I.FEED},Object.defineProperty(s.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(s.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),s.prototype._serializeCachedMetaData=function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}},s.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},s.prototype._update=function(t){var n=e(t);Object.assign(this,n)},s.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})}))},s.prototype._updateCachedMetaData=function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(i,s){var a;i.updatedAt<=t&&(n._cachedMetaData.set(s,{value:null!==(a=e[s])&&void 0!==a?a:i.value,isRemoved:!e[s],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}},s.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0,message:t.message})),s=new Et(this._iid,i);return s.messageParams=t,s},s.prototype._validateFailedFileMessageHasFile=function(e,t){var n;return Boolean(e.url)||G(t)||G(null===(n=e.messageParams)||void 0===n?void 0:n.file)},s.prototype._createPendingScheduledFileMessage=function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r},s.prototype._markMessageAsFailed=function(e,t,n){void 0===n&&(n=!1),e.errorCode=t.code,t.code===P.REQUEST_CANCELED||t.code===P.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=k.CANCELED:n||(e.sendingStatus=k.FAILED)},s.prototype.sendUserMessage=function(e){var t=u(u({},tn),e);return D(an(t)).throw(O.invalidParameters),this._sendUserMessage(t)},s.prototype._sendUserMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,c=null!=r?r:this._generateRequestId(),l=Date.now(),d=new Xt;return Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l);a.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(r)]}))}))}));var s=new fr(u(u({},e),{channelUrl:i.url,channelType:i.channelType,reqId:c}));o.send(s).then((function(e){var t=e.as(pr).message;a.dispatch(new N({messages:[t],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(t)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l),s=n.of(i._iid).cacheContext,o=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,o),a.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._triggerFailed(t,r)]}))}))}))}))}))})),d},s.prototype._autoResendUserMessage=function(e){return D(e instanceof It&&!!e.messageParams).throw(O.invalidParameters),this._sendUserMessage(e.messageParams,di.SEND,e.reqId)},s.prototype.resendUserMessage=function(e){var t;return A(this,void 0,void 0,(function(){var n,r;return U(this,(function(i){return D(e instanceof It&&!e.scheduledInfo).throw(O.invalidParameters),n=new V,r=null!==(t=e.messageParams)&&void 0!==t?t:sn(e),this._sendUserMessage(r,di.RESEND,e.reqId).onFailed((function(e){return n.reject(e)})).onSucceeded((function(e){return n.resolve(e)})),[2,n.promise]}))}))},s.prototype.updateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},yn),t),D(h("number",e)&&_n(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new mr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(vr).message]}}))}))},s.prototype.copyUserMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof It&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),D(!n.poll).throw(O.notSupportedError),o=new V,c=null!==(r=n.messageParams)&&void 0!==r?r:t(u(u({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(a=n.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),e._sendUserMessage(c).onSucceeded((function(e){o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.translateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof It&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Tr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(wr).message]}}))}))},s.prototype._createScheduledUserMessage=function(e,t){var r=this,i=n.of(this._iid).requestQueue,s=Date.now(),a=this._generateRequestId();Q(2).then((function(){var n=r._createPendingScheduledUserMessage(e,a,s);ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))}));var o=new Mr(u({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(o).then((function(e){var n=e.as(Sr).message;ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var i=r._createPendingScheduledUserMessage(e,a,s);r._markMessageAsFailed(i,n),ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,i)]}))}))}))}))}))},s.prototype.sendFileMessage=function(e){var t=u(u({},ln),e);return D(pn(t)).throw(O.invalidParameters),this._sendFileMessage(t)},s.prototype.sendMultipleFilesMessage=function(e){var t,r=u(u({},ni),e),i=n.of(this._iid);D(function(e,t){return void 0===t&&(t=ie),$t(e)&&h("string",e.message,!0)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return ri(e)}))}(r,null===(t=i.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(O.invalidParameters);var s=!!e.fileInfoList.find((function(e){var t=i.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return D(!s).throw(O.fileSizeLimitExceededError),this._sendMultipleFilesMessage(r)},s.prototype._sendFileMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid).dispatcher,a=$s.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new Xt;return Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u);s.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(r)]}))}))})),a.request(i,o,e).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u),a=n.of(i._iid).cacheContext,l=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,l),s.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:t.code===P.FILE_UPLOAD_CANCEL_FAILED?C.LOCAL_MESSAGE_CANCELED:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,r)]}))}))}))}))}))})),c},s.prototype._autoResendFileMessage=function(e){D(e instanceof St&&!!e.messageParams).throw(O.invalidParameters);var t=n.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,di.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},s.prototype._sendMultipleFilesMessage=function(e,t,r){var i=this,s=n.of(this._iid).dispatcher,a=$s.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new ii;return Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);s.dispatch(new N({messages:[n],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(n)]}))}))})),a.request(i,o,e,{requestHandler:c,isCopy:t===di.COPY}).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);i._markMessageAsFailed(n,t),s.dispatch(new N({messages:[n],source:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,n)]}))}))}))}))}))})),c},s.prototype._createScheduledFileMessage=function(e,t,r,i){var s=this,a=n.of(this._iid).requestQueue,o=new Ar(u(u({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(Ur).message;ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var a=s._createPendingScheduledFileMessage(e,r,i);s._markMessageAsFailed(a,n),ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,a)]}))}))}))}))}))},s.prototype.sendFileMessages=function(e){var t,n;D(e.every((function(e){return pn(u(u({},ln),e))}))).throw(O.invalidParameters);var r=new Xt;try{for(var i=v(e),s=i.next();!s.done;s=i.next()){var a=s.value;this.sendFileMessage(a).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{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},s.prototype.resendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){return n=this._validateFailedFileMessageHasFile(e,t),D(e instanceof St&&n&&!e.scheduledInfo).throw(O.invalidParameters),r=new V,i=fn(e,t),this._sendFileMessage(i,di.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),[2,r.promise]}))}))},s.prototype.resendMessage=function(e,t){var n,r;if(D(e instanceof mt&&!e.scheduledInfo&&e.isResendable).throw(O.invalidParameters),e.isUserMessage()){var i=null!==(n=e.messageParams)&&void 0!==n?n:sn(e);return this._sendUserMessage(i,di.RESEND,e.reqId)}if(e.isFileMessage()){var s=this._validateFailedFileMessageHasFile(e,t);D(s).throw(O.invalidParameters);i=null!==(r=e.messageParams)&&void 0!==r?r:fn(e,t);return this._sendFileMessage(i,di.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.updateFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},gn),t),D(h("number",e)&&function(e){return vn(e)}(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new yr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(_r).message]}}))}))},s.prototype.uploadFile=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=n.of(this._iid).requestQueue,r=se(),(i=new Pe({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:r})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(r),[4,t.send(i)];case 1:return s=c.sent(),a=s.as(ke),o=a.url,u=a.thumbnails,[2,{requestId:r,url:o,thumbnails:u}]}}))}))},s.prototype.cancelUploadingFileMessage=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),$s.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},s.prototype.copyFileMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof St&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),o=new V,c=t(u(u({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=n.thumbnails)||void 0===a?void 0:a.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(c).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.copyMessage=function(e,t){D(e instanceof s&&t instanceof mt&&t.sendingStatus===k.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(O.invalidParameters);var n=t,r=e;if(n.isUserMessage()){D(!n.poll).throw(O.notSupportedError);var i=nn(n);return r._sendUserMessage(i)}if(n.isFileMessage()){i=dn(n);return r._sendFileMessage(i)}if(t.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.deleteMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(e instanceof pt).throw(O.invalidParameters),e.messageId>0?(t=n.of(this._iid).requestQueue,r=new de({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof mt?e._messageToken:void 0}),[4,t.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},s.prototype.addReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new gr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(br).reactionEvent]}}))}))},s.prototype.deleteReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Ir({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Er).reactionEvent]}}))}))},s.prototype._updateUserMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new mr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(vr).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype._updateFileMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new yr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(_r).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype.createMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new Ke({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},s.prototype.deleteMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new Ke({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},s.prototype.addMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof Ke}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},s.prototype.removeMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof Ke}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},s.prototype.report=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return D(f(hn,e)&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new lr({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:t}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.reportUser=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof c&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new dr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.userId,category:t,description:r}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.reportMessage=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof mt&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new hr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:t,description:r,messageToken:e._messageToken}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.updatePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(h("number",e)&&function(e){return h("string",e.title,!0)&&te(e.data)&&h("boolean",e.allowUserSuggestion,!0)&&h("boolean",e.allowMultipleVotes,!0)&&h("number",e.closeAt,!0)}(t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Nr(u({pollId:e},t)),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Cr).poll]}}))}))},s.prototype.deletePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i;return U(this,(function(s){switch(s.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Or({pollId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},s.prototype.closePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Pr({pollId:e}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(kr).poll]}}))}))},s.prototype.addPollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=h("number",e)&&h("string",t)&&""!==t.trim(),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Rr({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(xr).poll]}}))}))},s.prototype.updatePollOption=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return i=h("number",e)&&h("number",t)&&h("string",r)&&""!==r.trim(),D(i).throw(O.invalidParameters),s=n.of(this._iid).requestQueue,a=new Dr({pollId:e,pollOptionId:t,optionText:r}),[4,s.send(a)];case 1:return o=u.sent(),[2,o.as(Lr).poll]}}))}))},s.prototype.deletePollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return r=h("number",e)&&h("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Fr({pollId:e,pollOptionId:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},s.prototype.votePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a,o,u,c;return U(this,(function(l){switch(l.label){case 0:return r=h("number",e)&&d("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid),s=i.requestQueue,a=i.dispatcher,o=new qr({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(zr).event,a.dispatch(new he({event:c,source:C.EVENT_POLL_VOTED})),[2,c]}}))}))},s.prototype.getPollChangeLogsSinceTimestamp=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("number",e)).throw(O.invalidParameters),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.getPollChangeLogsSinceToken=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("string",e,!0)),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new ce(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},s.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new le(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},s.prototype.pinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new ci({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s.prototype.unpinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new li({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s}(l),mi=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 r(t,e),t}((function(){this.onConnected=Y,this.onReconnectStarted=Y,this.onReconnectSucceeded=Y,this.onReconnectFailed=Y,this.onDisconnected=Y})),vi=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 r(t,e),t}((function(){this.onSessionExpired=Y,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=Y,this.onSessionRefreshed=Y,this.onSessionClosed=Y})),yi=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 r(t,e),t}((function(){this.onFriendsDiscovered=Y,this.onTotalUnreadMessageCountChanged=Y,this.onTotalUnreadMessageCountUpdated=Y})),_i=function(t){function n(n){var r=n.limit,s=n.token,a=n.userIdsFilter,o=n.metaDataKeyFilter,u=n.metaDataValuesFilter,c=n.nicknameStartsWithFilter,l=t.call(this)||this;return l.method=i.GET,l.path=pe,l.params=e({limit:r,token:s,user_ids:a,metadatakey:o,metadatavalues_in:u,nickname_startswith:c}),l}return r(n,t),n}(a),gi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),bi=function(e){function i(t,n){var r,i,s,a=this;return(a=e.call(this,t,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)&&h("string",this.metaDataKeyFilter,!0)&&d("string",this.metaDataValuesFilter,!0)&&h("string",this.nicknameStartsWithFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new _i(t(u(u({},this),{token:this._token}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(gi),a=s.users,o=s.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),Ii=function(t){function n(n){var r=n.userId,s=n.limit,a=n.token,o=n.userIdsFilter,u=t.call(this)||this;return u.method=i.GET,u.path="".concat(pe,"/").concat(r,"/block"),u.params=e({limit:s,token:a,user_ids:o}),u}return r(n,t),n}(a),Ei=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Ti=function(e){function i(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Ii(t(u(u({},this),{userId:r.userId,token:this._token}))),[4,i.send(s)]):[3,2]:[3,5];case 1:return a=d.sent(),o=a.as(Ei),c=o.users,l=o.next,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,c];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),wi=function(e){function t(t){var n=t.userId,r=t.limit,s=t.token,a=e.call(this)||this;return a.method=i.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(n),"/friends"),a.params={limit:r,token:s},a}return r(t,e),t}(a),Mi=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 c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Si=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),t=e.sdkState,r=e.requestQueue,i=new wi(u(u({},this),{userId:t.userId,token:this._token})),[4,r.send(i)]):[3,2]:[3,5];case 1:return s=d.sent(),a=s.as(Mi),o=a.users,c=a.hasMore,l=a.next,this._token=l,this._hasNext=c,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(me),Ai={},Ui=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,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,d=void 0===l?11:l,h=e.transactionApplyDelay,f=void 0===h?200:h,p=e.disableLogger,m=void 0!==p&&p;return Ai[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=c,this.blockHashConstant=d,this.transactionApplyDelay=f,this.disableLogger=m,Ai[t]=this),Ai[t]}return e.get=function(e){return Ai[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_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"}(fi||(fi={}));var Ni,Ci=function(e){function t(n){var r=n.code,i=void 0===r?fi.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 r(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:fi.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.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:fi.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:fi.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:fi.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:fi.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:fi.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:fi.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:fi.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:fi.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:fi.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:fi.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"}(Ni||(Ni={}));var Oi,Pi=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Ci.circularReferenceFound;var n;return t.set(e,!0),Array.isArray(e)?n=e.map((function(e){return Pi(e,t)})):e instanceof RegExp||e instanceof Date?n=e:(n={},Object.keys(e).forEach((function(r){n[r]=Pi(e[r],t)}))),t.delete(e),n}return e},ki=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Ci.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Ri=function(e,t){for(var n=0,r=0;r>>0)%t},xi=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Di=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!Di(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Di(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(!(ki(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(ki(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(ki(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(ki(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)},Li=function(){},Fi=function(){return Promise.resolve()},qi=function(e){return e},zi=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Oi||(Oi={}));var Bi,ji,Ki,Qi=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?qi:a,u=e.backward,c=void 0===u?Fi:u,l=e.forward,d=void 0===l?Fi:l,h=e.complete,f=void 0===h?Li:h;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=c,this._forward=d,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 A(this,void 0,void 0,(function(){var e,t,n;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(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}(),Gi=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(h=0;h0?n:t;for(var o in this.condition[i])if(a.includes(o))for(var u=r;u>=0;u--)if(s*ki(this._indexer.origin[u].columnValues[h],this.condition[i][o])<=0){r=u;break}}else for(u=r;u>=0;u--)if(s*ki(this._indexer.origin[u].columnValues[h],this.condition[i])<=0){r=u;break}}return Math.min(r+1,this._indexer.origin.length-1)}var c=0;if("function"!=typeof this.condition)for(var l=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=c;o=0){c=o;break}}));else for(var a=c;a=0){c=a;break}},d=this,h=0;h-1){var r=this._items[n];return t===Ki.PERSISTENT&&(r.state=ji.PERSISTENT),t!==Ki.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)ts.includes(this._items[r].state)&&ts.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 i=this._items.filter((function(e){return e.state===ji.VOLATILE})),s=i.length-this._limit;if(s>0){var a=[];try{for(var o=v(this._items),u=o.next();!u.done;u=o.next()){var c=u.value;c.state===ji.VOLATILE&&s>0?s--:a.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this._items=a}}}},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.clearForDatabase=function(e){this.clearByCondition((function(t){return t.key.startsWith(Hi(e))}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==ji.VOLATILE}))},e}(),is=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(Wi(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(Wi(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=[]),A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,p([],m(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],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,c,l,d;return U(this,(function(h){switch(h.label){case 0:n=rs.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return u(u({},e.data),{generation:r})})))];case 2:for(a=h.sent(),o=0;o0))return[3,4];for(t=[],n={},o=e.length-1;o>=0;o--)r=e[o],l=r.data,n[l.key]||(n[l.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=p.sent(),[4,this._store.set({key:this.recordsetKey,value:s})];case 2:return p.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(p.sent(),a=rs.get(this.dbname),o=0;o0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=a.sent())&&(s=ss.createFromCacheItem(i),null==s?void 0:s.getItemByKey(e)))return[2,s];a.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return n=Ui.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,rs.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(null==(a=s?ss.createFromCacheItem(s):new ss({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:a.add(t))?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(this,(function(r){switch(r.label){case 0:return e=Ji(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(),rs.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),os=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 u=function(e,t,n){return"".concat(Wi(e,t),"/index.").concat(n)}(t,n,i.join(">"));this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=u,this._store=a,this._transaction=s,this._transaction.on(Bi.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Bi.ERROR,this.indexerKey,(function(){return o.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=m(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=m(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var a=v(this.fields),o=a.next();!o.done;o=a.next()){var u=o.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw Ci.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=ki(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 A(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,y;return U(this,(function(_){switch(_.label){case 0:return[4,(e=rs.get(this.dbname)).find(this._store,this.indexerKey,Ki.PERSISTENT)];case 1:return(t=_.sent())?[3,11]:(n=Ji(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=_.sent(),_.label=3;case 3:_.trys.push([3,8,9,10]),i=v(r),s=i.next(),_.label=4;case 4:return s.done?[3,7]:(a=s.value).startsWith(n)?[4,e.find(this._store,a,Ki.NO_CACHE)]:[3,6];case 5:if(o=_.sent(),u=ss.createFromCacheItem(o))try{for(m=void 0,c=v(u.items),l=c.next();!l.done;l=c.next())d=l.value,this._addItem(d)}catch(e){m={error:e}}finally{try{l&&!l.done&&(y=c.return)&&y.call(c)}finally{if(m)throw m.error}}_.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return h=_.sent(),f={error:h},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=Pi(this._origin),_.label=12;case 12:return[2]}}))}))},e.prototype.drop=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return rs.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.addItem=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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=Pi(this._origin)},e.prototype.abort=function(){this._table=Pi(this._origin)},e}(),us=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},cs=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"}($i||($i={})),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"}(es||(es={}));var ls,ds={},hs=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=$i.PROCESSING,this._queue=[],this._activationQueue=[],ds[e]&&!t.forceCreate||(this.nodeId=cs(),this.key=e,us()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data;if(null==i?void 0:i.isNestDbMessage){var s=i.nodeId,a=i.requestId,o=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&o===n.key)switch(u){case es.NEWNODE:n._sendSync();break;case es.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case es.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,d=l.currentItemRequestId,h=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:es.REQUEST_LOCK,ts:e.ts})};try{for(var p=v(h),m=p.next();!m.done;m=p.next()){f(m.value)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case es.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case es.REQUEST_LOCK:n._requestLock(i);break;case es.ACQUIRE_LOCK:var y=n._queue.find((function(e){return e.requestId===a}));n._acquire(y);break;case es.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(es.REMOVENODE)}))),ds[e]=this),ds[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==$i.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:cs(),key:this.key,op:e,data:t.data,ts:Date.now()};return us()&&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(es.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){for(var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(es.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},i=!1,s=0;sr.ts){t._queue.splice(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(es.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 A(this,void 0,void 0,(function(){var e=this;return U(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=$i.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(es.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(es.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(es.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}(),fs=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=Ni.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=p([[r]],m(s.filter((function(e){return os.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new hs(function(e,t){return"".concat(Wi(e,t),".lock")}(t,n)),this._blobContainer=new Zi({dbname:t,collectionName:n,store:a}),this._transaction=new is({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return r=Yi(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===Ni.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,y,_=this;return U(this,(function(g){switch(g.label){case 0:return[4,this._mutex.lock()];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,9,,10]),t=Ui.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=g.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:g.sent(),this._blockManager=new as({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=p([],m(this.indexes),!1),i=[],s=r.map((function(e){return os.createKey(e)})),a=n?n.indexes.map((function(e){return os.createKey(e)})):[];try{for(o=v(a),u=o.next();!u.done;u=o.next())c=u.value,s.includes(c)||i.push(os.parseKey(c))}catch(e){f={error:e}}finally{try{u&&!u.done&&(y=o.return)&&y.call(o)}finally{if(f)throw f.error}}return(l=[]).push.apply(l,p([],m(r.map((function(e){var t=new os({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,p([],m(i.map((function(e){return new os({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return g.sent(),[4,this._transaction.commit()];case 6:return g.sent(),s.sort().join(",")===a.sort().join(",")?[3,8]:(d=Yi(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:d,value:this._metadata})]);case 7:g.sent(),g.label=8;case 8:return this._state=Ni.READY,this._mutex.unlock(),[3,10];case 9:throw h=g.sent(),this._mutex.unlock(),h;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Ni.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=os.createKey(e);try{for(var i=v(this._indexers),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===os.createKey(a.fields))return a}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw Ci.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return e=Yi(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return o.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return o.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return o.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:o.sent(),o.label=5;case 5:o.trys.push([5,10,11,12]),n=v(this._indexers),r=n.next(),o.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:o.sent(),o.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=o.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw Ci.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=v(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),a=v(this._indexers),o=a.next(),p.label=16;case 16:return o.done?[3,20]:0===(u=o.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return o=a.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),h={error:c},[3,23];case 22:try{o&&!o.done&&(f=a.return)&&f.call(a)}finally{if(h)throw h.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=v(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return a=c.sent(),o={error:a},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=o.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:o.sent(),o.label=3;case 3:o.trys.push([3,8,9,10]),n=v(this._indexers),r=n.next(),o.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:o.sent(),o.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=o.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return U(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=v(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(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,Pi(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Ci.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new Vi({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ci.collectionNotReady},e.prototype.insertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestInsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpdate(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p,m,y=this;return U(this,(function(_){switch(_.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:_.sent(),_.label=2;case 2:return _.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,a=e.backward,o=void 0!==a&&a,u=[],[4,new Gi({condition:r,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(s)}).each((function(e){return A(y,void 0,void 0,(function(){var n;return U(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(n=e.nextValue,Di(r,n)&&t.set&&("function"!=typeof t.set?Object.keys(t.set).forEach((function(e){var r;n[e]=null===(r=t.set)||void 0===r?void 0:r[e]})):t.set(n),u.push(n)),e.next()):e.stop(),[2]}))}))}))];case 3:_.sent(),_.label=4;case 4:_.trys.push([4,9,10,11]),c=v(u),l=c.next(),_.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestUpdate(Pi(d))]);case 6:_.sent(),_.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return h=_.sent(),p={error:h},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return _.sent(),this._mutex.unlock(),[2,u];case 13:return f=_.sent(),[4,this._transaction.clear()];case 14:throw _.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),Ci.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m=this;return U(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,a=void 0!==s&&s,o=[],[4,new Gi({condition:n,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(i)}).each((function(e){return A(m,void 0,void 0,(function(){var t,r;return U(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Di(n,t)&&(r=t[this.keyName],o.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=v(o),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return d=y.sent(),f={error:d},[3,11];case 10:try{c&&!c.done&&(p=u.return)&&p.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,o];case 13:throw h=y.sent(),this._mutex.unlock(),h;case 14:return[3,16];case 15:throw this._transaction.clear(),Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),ps="[NESTDB]",ms=!0,vs=function(){function e(){}return e.off=function(){ms=!1},e.log=function(){for(var e=[],t=0;t1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return A(o,void 0,void 0,(function(){var n,i;return U(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw Ci.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}}))}))})))]:[3,4];case 3:return a=u.sent(),[3,5];case 4:a=[r],u.label=5;case 5:return s=a,[2,this.encryption.decrypt(JSON.parse(s.join("")))];case 6:return u.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,u({},e.value)]}}))}))},e.prototype.setMany=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,p([],m(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a=this;return U(this,(function(o){switch(o.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=o.sent())?(r=n.metadata,i=this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return a._getRawKey(e,".".concat(t))})),[4,this._removeRaw(i)]):[3,3];case 2:return o.sent(),null==(s=rs.get(this.dbname))||s.remove(e),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d=this;return U(this,(function(h){switch(h.label){case 0:t=rs.get(this.dbname),n=[],r=function(e){var r,s,a;return U(this,(function(o){switch(o.label){case 0:return r=i._getRawKey(e,".0"),[4,i._getRaw(r)];case 1:return(s=o.sent())&&(a=s.metadata,n.push.apply(n,p([],m(i._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return d._getRawKey(e,".".concat(t))}))),!1))),null==t||t.remove(e),[2]}}))},i=this,h.label=1;case 1:h.trys.push([1,6,7,8]),s=v(e),a=s.next(),h.label=2;case 2:return a.done?[3,5]:(o=a.value,[5,r(o)]);case 3:h.sent(),h.label=4;case 4:return a=s.next(),[3,2];case 5:return[3,8];case 6:return u=h.sent(),c={error:u},[3,8];case 7:try{a&&!a.done&&(l=s.return)&&l.call(s)}finally{if(c)throw c.error}return[7];case 8:return n.length>0?[4,this._removeRaw(n)]:[3,10];case 9:h.sent(),h.label=10;case 10:return[2,e]}}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){return null==(e=rs.get(this.dbname))||e.clearForDatabase(this.dbname),[2]}))}))},e}(),gs={},bs=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,u(u({},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 r(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return gs[this.dbname]},set:function(e){gs[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(gs[this.dbname])return[2,Object.keys(gs[this.dbname])];throw Ci.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return gs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:return t.sent(),[2,gs[this.dbname][e]?u({key:e},gs[this.dbname][e]):null];case 2:throw Ci.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return gs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:c.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,s=r.data,a=r.metadata,gs[this.dbname][i]=Object.freeze({data:s,metadata:a})}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}}return[3,3];case 2:throw Ci.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return gs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:a.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,gs[this.dbname][r]&&delete gs[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw Ci.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 A(this,void 0,void 0,(function(){return U(this,(function(e){return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,gs[this.dbname]||(gs[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.set=function(t){return A(this,void 0,void 0,(function(){var n,r;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u;return U(this,(function(c){try{for(n=v(t),r=n.next();!r.done;r=n.next())if(i=r.value,(s=this.observer[i.key])&&"function"==typeof s.set&&(a=s.set()))throw a}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return t.sent(),[4,xi(this.delay)];case 2:return t.sent(),gs[this.dbname]={},[2]}}))}))},t}(_s),Is="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(ls||(ls={}));var Es,Ts=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=Is,r._state=ls.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 r(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype.isTransactionInactiveError=function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")},t.prototype._putToObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.put(t);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))]}))}))},t.prototype._deleteFromObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.delete(t);i.addEventListener("success",(function(){return n(t)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))]}))}))},t.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=ls.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Is,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=ls.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=ls.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=ls.UNINITIALIZED,r(e.target.error)}))}else r(Ci.storeNotAvailable)}))},t.prototype._getObjectStore=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 ls.UNINITIALIZED:case ls.OPEN:return[3,2];case ls.OPENING:case ls.CLOSED:return[3,3]}return[3,4];case 2:throw Ci.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 A(this,void 0,void 0,(function(){var e;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._putToObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._putToObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._deleteFromObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._deleteFromObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){var e,t=this;return U(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||!us())return[3,4];if(!(us()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Ci.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(Ci.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),t._indexedDb){var i=t._indexedDb.deleteDatabase("_testMozilla");i.onerror=function(){return e()},i.onsuccess=function(){return e()}}else n(Ci.storeNotAvailable)}}catch(e){n(Ci.storeNotAvailableInPrivateBrowsing)}else n(Ci.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Ci.storeNotAvailable;case 5:return[3,7];case 6:throw Ci.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(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(),[4,this._resetIfEncryptionChanged()];case 3:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this._getObjectStore("readwrite")];case 2:return t=n.sent(),[4,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 3:return[2,n.sent()]}}))}))},t}(_s),ws=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?2097152:i,a=ye(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,u(u({},a),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:t=[];try{for(n=v(e),r=n.next();!r.done;r=n.next())i=r.value,s=i.key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(s),JSON.stringify(i)])}catch(e){a={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return u.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._asyncStorage)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}}))}))},t}(_s),Ms=function(e){function t(t){var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._mmkv)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}}))}))},t}(_s);!function(e){e.INIT="INIT",e.OPENING="OPENING",e.OPENED="OPENED",e.CLOSED="CLOSED"}(Es||(Es={}));var Ss,As=function(){function e(e){var t=e.name,n=e.version,r=e.store,i=e.config;this.name=t,this._version=n,this._state=Es.INIT,this._config=i||new Ui({dbname:t}),this._store=r,this._event={success:Li,error:Li,storeReplaced:Li,upgrade:zi},this._collections=new Map,this._globalMutex=new hs("".concat(this.name,".lock")),this._config.disableLogger&&vs.off(),new rs({dbname:t,limit:this._config.cacheLimit})}return Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),e.prototype.estimateUsage=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,(t=this._store,A(void 0,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,t.usage()];case 1:return[2,e.sent()]}}))})))];case 1:return[2,e.sent()]}var t}))}))},e.prototype.commitSchema=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this._state!==Es.OPENING?[3,2]:[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=e.collectionName,n=e.keyName,r=e.index,i=void 0===r?[]:r,this._collections.has(t)||this._collections.set(t,new fs({dbname:this.name,collectionName:t,keyName:n,indexes:i,store:this._store})),(s=this._collections.get(t))?[4,s.init()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[3,3];case 2:throw Ci.databaseSchemaNotOnUpgrade;case 3:return[2]}}))}))},e.prototype.open=function(){var e;return A(this,void 0,void 0,(function(){var t,n,r,i,s=this;return U(this,(function(a){switch(a.label){case 0:return[4,this._globalMutex.lock()];case 1:if(a.sent(),this._state===Es.OPENED)return[3,12];this._state=Es.OPENING,a.label=2;case 2:return a.trys.push([2,5,,12]),[4,this._store.init(this.name)];case 3:return a.sent(),o=this.name,t="".concat(Hi(o),".metadata"),n={version:0,collectionNames:[]},[4,this._store.get(t)];case 4:return r=null!==(e=a.sent())&&void 0!==e?e:n,[2,new Promise((function(e,n){var i=function(e){r.version0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof mt))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof pt)switch(this.replyType){case H.NONE:if(e.parentMessageId>0)return!1;break;case H.ONLY_REPLY_TO_CHANNEL:if(e instanceof mt&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Us||(Us={}));var Os,Ps=function(e){switch(e){case Us.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Us.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},ks=function(){return["channelUrl","-createdAt","-notificationId"]},Rs=u(u({},tn),{scheduledAt:void 0}),xs=function(e){return an(e)&&h("number",e.scheduledAt,!0)},Ds=u(u({},Zt),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ls=function(e){return $t(e)&&h("number",e.scheduledAt)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Fs="UnsentMessage",qs="reqId",zs={},Bs=function(t){function i(e){var n=t.call(this,e)||this;return n._mutex=new hs("unsendmessagecache.lock"),zs[e]=n,n}return r(i,t),Object.defineProperty(i.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),i.of=function(e,t){return void 0===t&&(t=!1),zs[e]&&!t||(zs[e]=new i(e)),zs[e]},Object.defineProperty(i.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Fs);if(!t)throw O.databaseError;return t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),i.prototype._serialize=function(t){if(t.messageId>0)throw O.invalidParameters;var n,r=u({},t.serialize());return t instanceof It?(t.messageParams&&(r.messageParams=en(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=(n=t.scheduledInfo.scheduledMessageParams,u(u({},en(n)),{scheduledAt:n.scheduledAt})))):t instanceof St?(t.messageParams&&(r.messageParams=cn(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=function(e){return u(u({},cn(e)),{scheduledAt:e.scheduledAt})}(t.scheduledInfo.scheduledMessageParams))):t instanceof Et&&t.messageParams&&(r.messageParams=function(t){return e({fileInfoList:t.fileInfoList,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption})}(t.messageParams)),r},i.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),$s.of(this._iid).buildMessageFromSerializedData(e)},i.prototype._deserializeWithMessageCreateParams=function(e){var t,n,r;return A(this,void 0,void 0,(function(){var i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return i=$s.of(this._iid),s=this._deserialize(e),e.messageParams?s instanceof It?(o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),[3,6]):[3,1]:[3,6];case 1:return s instanceof St?(o=e.messageParams).fileKey&&"string"==typeof o.fileKey&&un(null!==(t=o.fileType)&&void 0!==t?t:"")?(a=o,[4,this.collection.getBlob(o.fileKey)]):[3,3]:[3,4];case 2:a.file=null!==(n=d.sent())&&void 0!==n?n:void 0,d.label=3;case 3:return s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(o,s),[3,6];case 4:return s instanceof Et&&((o=e.messageParams)&&o.fileInfoList)?(s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(o,s),[4,Promise.all(s.messageParams.fileInfoList.map((function(e){return A(l,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&un(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!==(s=a.sent())&&void 0!==s?s:void 0,a.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:d.sent(),d.label=6;case 6:return s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?s instanceof It?(u=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(u,s),[3,10]):[3,7]:[3,10];case 7:return s instanceof St?(u=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof u.fileKey&&"string"==typeof u.fileType&&un(u.fileType)?(c=u,[4,this.collection.getBlob(u.fileKey)]):[3,9]:[3,10];case 8:c.file=null!==(r=d.sent())&&void 0!==r?r:void 0,d.label=9;case 9:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(u,s),d.label=10;case 10:return[2,s]}}))}))},i.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},i.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new Cs:n,i=e.order,s=void 0===i?Us.CHANNEL_LATEST:i,a=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return A(this,void 0,void 0,(function(){var e,n,i,o,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?(e=Ps(s),n={"/where":function(e){return!!(s!==Us.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(l._deserialize(e))}},t&&(n.channelUrl=t),a&&(n.sendingStatus=a),i={where:n,index:e,backward:u},[4,this.collection.query(i)]):[3,3];case 1:return[4,d.sent().fetch({})];case 2:return o=d.sent(),[2,Promise.all(o.map((function(e){return A(l,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},i.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Cs),A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:Us.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},i.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return e instanceof St||e instanceof Et?[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]}}))}))},i.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},i.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.saveBlob=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i=this;return U(this,(function(s){switch(s.label){case 0:return e instanceof St?e.messageParams&&(r=e.messageParams).file&&on(r.file)?[4,this.collection.saveBlob(r.file,e.reqId)]:[3,2]:[3,5];case 1:n=s.sent(),r.fileKey=n,r.fileType=rn.BLOB,s.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&on(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=s.sent(),t.fileKey=n,t.fileType=rn.BLOB,s.label=4;case 4:return[3,7];case 5:return e instanceof Et&&((r=e.messageParams)&&r.fileInfoList&&Array.isArray(r.fileInfoList))?[4,Promise.all(r.fileInfoList.map((function(t,n){return A(i,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return t.file&&on(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=rn.BLOB,i.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},i}(l),js={},Ks=function(e){function t(t){var n=e.call(this,t)||this;return js[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Bs.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),js[e]&&!n||(js[e]=new t(e)),js[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Gr)},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 u(u({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),$s.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Cs:s,o=e.order,u=void 0===o?Us.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,d=e.parentMessageId,h=e.isPollOnly,f=void 0!==h&&h,p=e.exactMatch,m=void 0!==p&&p,v=e.inclusive,y=void 0===v||v;return A(this,void 0,void 0,(function(){var e,r,s,o=this;return U(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=Ps(u),r={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Us.CHANNEL_LATEST:if(m&&e.createdAt!==n)return!1;if(l){if(y&&e.createdAtn||!y&&e.createdAt>=n)return!1;break;case Us.NEWEST_CHILD_MESSAGE:if(!d||0===e.parentMessageId||e.parentMessageId!==d)return!1}return!(f&&!e._poll)&&a.match(o._deserialize(e))}},index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({limit:null!=i?i:void 0})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return A(o,void 0,void 0,(function(){return U(this,(function(t){return[2,this._deserialize(e)]}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Cs),A(this,void 0,void 0,(function(){return U(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:Us.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,13];case 1:d.sent(),d.label=2;case 2:d.trys.push([2,7,8,9]),n=v(e),r=n.next(),d.label=3;case 3:return r.done?[3,6]:(i=r.value,(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)?[4,this.get(i.messageId)]:[3,5]);case 4:(null==(s=d.sent())?void 0:s.threadInfo)&&i.threadInfo._updateFrom(s.threadInfo),d.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return a=d.sent(),u={error:a},[3,9];case 8:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 9:return o=e.map((function(e){return l._serialize(e)})),[4,this.collection.upsertMany(o)];case 10:return d.sent(),[4,this.upsertChildMessages(e)];case 11:return d.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 12:d.sent(),d.label=13;case 13:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:Ps(Us.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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:Ps(Us.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=Ps(Us.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 A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return e instanceof St&&e.messageParams&&((t=e.messageParams).file&&on(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.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=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return s=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return a=o.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),s&&(t+=JSON.stringify(s).length),a&&(t+=JSON.stringify(a).length),[2,t]}}))}))},t}(l),Qs={},Gs=function(e){function t(t){var n=e.call(this,t)||this;return Qs[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),Qs[e]&&!n||(Qs[e]=new t(e)),Qs[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Wr)},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 u({},e.serialize())},t.prototype._deserialize=function(e){return $s.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Cs:s,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,d=e.inclusive,h=void 0===d||d;return A(this,void 0,void 0,(function(){var e,r=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(e={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(h&&e.createdAtn||!h&&e.createdAt>=n)return!1}return a.match(r._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},[4,this.collection.query(e)]):[3,3];case 1:return[4,s.sent().fetch({limit:null!=i?i:void 0})];case 2:return[2,s.sent().map((function(e){return r._deserialize(e)}))];case 3:return[2,[]]}}))}))},t.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?(t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.markAsReadByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,messageStatus:ft.SENT,createdAt:{"<":t}}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.markAsReadByMessageIds=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:ft.SENT}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:return[2,n.sent().length];case 2:return[2,0]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]})]:[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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:Ps(Us.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=["channelUrl","-createdAt","-notificationId"],[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}(l),Vs={},Hs=function(e){function t(t){var n=e.call(this,t)||this;return n._observers=new Map,n._dispatcherContext=n._dispatcher.on((function(e){return A(n,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,v,y,_,g,b=this;return U(this,(function(E){switch(E.label){case 0:return e instanceof N?(t=e.messages,g=e.source,a=e.isWebSocketEventComing,n=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&e.messageId>0})),r=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&0===e.messageId})),i=t.filter((function(e){return e instanceof Tt})),n.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(n)];case 1:return e.sent(),[4,this._unsentMessageCache.remove(n.map((function(e){return e instanceof mt?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,7];case 1:E.sent(),a||this._broadcastUpdateEvent(n,g),E.label=2;case 2:return r.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.upsert(r)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:E.sent(),a||this._broadcastUpdateEvent(r,g),E.label=4;case 4:return i.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._notificationCache.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,6];case 5:E.sent(),a||this._broadcastUpdateEvent(i,g),E.label=6;case 6:return[3,24];case 7:return e instanceof we?(s=e.messageIds,g=e.source,a=e.isWebSocketEventComing,o=s.filter((function(e){return"number"==typeof e})),u=s.filter((function(e){return"string"==typeof e})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return o.length>0?[4,this._messageCache.remove(o)]:[3,2];case 1:e.sent(),e.label=2;case 2:return u.length>0?[4,this._notificationCache.remove(u)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))}))]):[3,9];case 8:return E.sent(),a||this._broadcastRemoveEvent(s,g),[3,24];case 9:return e instanceof Te?(c=e.reqId,g=e.source,[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.remove([c])];case 1:return e.sent(),[2]}}))}))}))]):[3,11];case 10:return E.sent(),this._broadcastRemoveUnsentEvent(c,g),[3,24];case 11:return e instanceof Ee?(l=e.polls,g=e.source,this._cacheContext.localCacheEnabled?(d=l.map((function(e){return e.messageId})),[4,Promise.all(d.map((function(e){return b._messageCache.get(e)})))]):[3,14]):[3,15];case 12:return(h=E.sent().filter((function(e){return e}))).length>0&&l.forEach((function(e){var t=h.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(h)];case 1:return[2,e.sent()]}}))}))}))];case 13:E.sent(),E.label=14;case 14:return this._broadcastPollChangeLogEvent(l,g),[3,24];case 15:return e instanceof Ie?(f=e.event,g=e.source,[4,this._messageCache.get(f.messageId)]):[3,19];case 16:return(p=E.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollUpdateEvent(f)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([p])];case 1:return[2,e.sent()]}}))}))}))]:[3,18];case 17:E.sent(),E.label=18;case 18:return this._broadcastPollUpdateEvent(f,g),[3,24];case 19:return e instanceof he?(m=e.event,g=e.source,[4,this._messageCache.get(m.messageId)]):[3,23];case 20:return(v=E.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(m)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,22];case 21:E.sent(),E.label=22;case 22:return this._broadcastPollVoteEvent(m,g),[3,24];case 23:e instanceof _e?(y=e.event,g=e.source,y.messageId>0&&this._broadcastReactionUpdateEvent(y,g)):e instanceof ge&&(_=e.event,g=e.source,this._broadcastThreadUpdateEvent(_,g)),E.label=24;case 24:return[2]}}))}))})),n}return r(t,e),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dispatcher",{get:function(){return n.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_messageCache",{get:function(){return Ks.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Bs.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_notificationCache",{get:function(){return Gs.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){var r;return void 0===n&&(n=!1),Vs[e]&&!n||(Vs[e]&&(null===(r=Vs[e]._dispatcherContext)||void 0===r||r.close()),Vs[e]=new t(e)),Vs[e]},t.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemove&&a.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastReactionUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastThreadUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype.subscribe=function(e,t){this._observers.set(e,t)},t.prototype.unsubscribe=function(e){this._observers.delete(e)},t.prototype.unsubscribeAll=function(){this._observers.clear()},t}(l),Ws=function(t){function n(n){var r=this,s=n.reverse,a=void 0!==s&&s,o=n.limit,u=void 0===o?20:o,c=n.keys,l=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(Me),r.params=e({token:l,limit:u,reverse:a,order:Se.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),r}return r(n,t),n}(a),Ys=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.next,s=n.has_more,a=void 0!==s&&s,o=n.templates;return r.nextToken=i,r.hasMore=a,r.templates=o.map((function(e){return{template:JSON.stringify(e)}})),r}return r(t,e),t}(o),Js=function(e){function t(t){var n=this,r=t.key;return(n=e.call(this)||this).method=i.GET,n.path="".concat(Me,"/").concat(r),n}return r(t,e),t}(a),Xs=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.template=JSON.stringify(n),r}return r(t,e),t}(o),Zs={},$s=function(){function n(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=a,Ks.of(e),Bs.of(e),Hs.of(e),this.fileMessageQueue=new Rt(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),Zs[e]=this}return n.of=function(e){return Zs[e]},n.prototype.buildMessageFromSerializedData=function(e){var t=Ae(e);if(t.notificationId)return new Tt(this._iid,Tt.payloadify(t));switch(t.messageType){case g.USER:return new It(this._iid,It.payloadify(t));case g.FILE:return Et._isMultipleFilesMessageSerializedData(t)?new Et(this._iid,Et.payloadify(t)):new St(this._iid,St.payloadify(t));case g.ADMIN:return new _t(this._iid,_t.payloadify(t))}throw O.invalidParameters},n.prototype.buildUserMessageCreateParamsFromSerializedData=function(n,r){return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,message:r.message,translationTargetLanguages:Object.keys(r.translations),pollId:n.pollId}))},n.prototype.buildFileMessageCreateParamsFromSerializedData=function(n,r){var i;return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,file:n.file,fileKey:n.fileKey,fileUrl:r.plainUrl,fileName:r.name,fileSize:r.size,mimeType:r.type,thumbnailSizes:null===(i=r.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:n.fileType,requireAuth:r.requireAuth}))},n.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(t,n){var r=this;return e({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUserIds:n.mentionedUserIds,mentionedUsers:n.mentionedUsers,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption,appleCriticalAlertOptions:n.appleCriticalAlertOptions,reqId:n.reqId,fileInfoList:t.fileInfoList.map((function(e){return new At(r._iid,e)}))})},n.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildSenderFromSerializedData=function(e){var t=Ae(e);return new je(this._iid,je.payloadify(t))},n.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new zt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Bt).message]}}))}))},n.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Vt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Ht).message]}}))}))},n.prototype.getMessagesByMessageId=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new jt(u(u({channelType:t,channelUrl:e,token:String(n)},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(Kt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype.getMessagesByTimestamp=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new jt(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(Kt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype._getMessagesByTimestampForCollection=function(e,t,n,r,i,s,a){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var o,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return o=new jt(u(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r),{checkingHasNext:s,checkingContinuousMessages:a})),[4,this._requestQueue.send(o)];case 1:return c=p.sent(),l=c.as(Kt),d=l.messages,h=l.isContinuousMessages,f=l.hasNext,this._dispatcher.dispatch(new N({messages:d,source:i})),[2,{messages:d,isContinuousMessages:h,hasNext:f}]}}))}))},n.prototype.getThreadedMessagesByTimestamp=function(e,t,n,r){return void 0===r&&(r=C.REQUEST_THREADED_MESSAGE),A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return i=new jt(u(u(u({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},vt),n),{replyType:H.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return s=c.sent(),a=s.as(Kt).messages,(o=a.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new N({messages:o,source:r})),[2,{parentMessage:a[0],threadedMessages:o}]}}))}))},n.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return n=new Ws(u({token:e},t)),[4,this._requestQueue.send(n)];case 1:return r=c.sent(),i=r.as(Ys),s=i.hasMore,a=i.nextToken,o=i.templates,[2,{hasMore:s,token:a,templates:o}]}}))}))},n.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Js({key:e}),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,{template:n.as(Xs).template}]}}))}))},n.prototype.getMessageChangelogs=function(n,r,i,s,a){return void 0===a&&(a=C.REQUEST_MESSAGE_CHANGELOGS),A(this,void 0,void 0,(function(){var o,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return o=new Qt(e(t(u(u({channelType:r,channelUrl:n,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},Ft),s)))),[4,this._requestQueue.send(o)];case 1:return c=v.sent(),l=c.as(Gt),d=l.updatedMessages,h=l.deletedMessagesInfo,f=l.hasMore,p=l.nextToken,m=h.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new N({messages:d,source:a})),m.length>0&&this._dispatcher.dispatch(new we({messageIds:m,source:a})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:f,token:p}]}}))}))},n}(),ea=function(e){function t(t,n){var r=e.call(this,t)||this;r.targetMessageId=0;var i=n.thread_info,s=n.parent_message_id,a=n.channel_url,o=n.channel_type;return i&&h("object",i)&&h("number",s)&&h("string",a)&&h("string",o)&&(r.threadInfo=new Re(t,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return r(t,e),t}(l),ta={channelUrl:"",channelType:I.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},na=function(e){function t(t){var n=t.channelCustomType,r=t.keyword,s=t.limit,a=t.reverse,o=t.exactMatch,u=t.channelUrl,c=t.order,l=t.messageTimestampFrom,d=t.messageTimestampTo,h=t.advancedQuery,f=t.targetFields,p=t.nextToken,m=e.call(this)||this;return m.method=i.GET,m.path="".concat(Ue,"/messages"),m.params={custom_type:n,query:r,limit:s,reverse:a,exact_match:o,channel_url:u,message_ts_from:l,message_ts_to:d,sort_field:c,advanced_query:h,target_fields:f,after:p},m}return r(t,e),t}(a),ra=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return Mt(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return r(t,e),t}(o);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Os||(Os={}));var ia=function(e){function i(t,n){var r,i,s,a,o,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Os.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(a=n.channelCustomType)&&void 0!==a?a:"",h.messageTimestampFrom=null!==(o=n.messageTimestampFrom)&&void 0!==o?o:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:Os.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&h("string",this.keyword)&&this.keyword.length>0&&h("boolean",this.reverse)&&h("boolean",this.exactMatch)&&h("string",this.channelUrl)&&h("string",this.channelCustomType)&&(h("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(h("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&f(Os,this.order)&&h("boolean",this.advancedQuery)&&d("string",this.targetFields,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new na(t(u(u({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=d.sent(),s=i.as(ra),a=s.messages,o=s.hasNext,c=s.nextToken,l=s.totalCount,this._nextToken=c,this._hasNext=o,this._isLoading=!1,this.totalCount=l,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),sa=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.limit,u=r.token,c=n.call(this)||this;return c.method=i.GET,c.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages/parent_thread_message"),c.params=e(t({limit:o,token:u})),c}return r(s,n),s}(a),aa=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.next,r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),oa=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s._edge="",s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.load=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new sa({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(aa),s=i.messages,a=i.token,this._edge=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ua={channelUrl:"",scheduledMessageId:0},ca={reverse:!1,limit:20},la=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return r(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new $s(t,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},t.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},t.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},t.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=u(u({},ta),e),D(function(e){return h("string",e.channelUrl)&&f(I,e.channelType)&&h("number",e.messageId)&&h("boolean",e.includeReactions,!0)&&h("boolean",e.includeMetaArray,!0)&&h("boolean",e.includeParentMessageInfo,!0)&&h("boolean",e.includeThreadInfo,!0)}(t)).throw(O.invalidParameters),[4,this._manager.getMessage(t)];case 1:if((n=r.sent())instanceof pt||n instanceof Tt||null===n)return[2,n];throw"Unknown message type is given."}}))}))},t.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){return t=u(u({},ua),e),D(function(e){return h("string",e.channelUrl)&&""!==e.channelUrl&&h("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(O.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},t.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return n=u(u({},ca),t),D(h("string",e,!0)&&function(e){return h("boolean",e.reverse,!0)&&h("number",e.limit,!0)&&d("string",e.keys,!0)}(n)).throw(O.invalidParameters),[2,this._manager.getMessageTemplatesByToken(e,n)]}))}))},t.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),[2,this._manager.getMessageTemplate(e)]}))}))},t}(Ne);export{It as $,ws as A,Ti as B,mi as C,Sn as D,gt as E,Si as F,Yt as G,Wt as H,Ts as I,xt as J,Cs as K,Ns as L,Us as M,Gr as N,En as O,Jt as P,Br as Q,hn as R,vi as S,Mt as T,yi as U,ut as V,si as W,ui as X,Ve as Y,ct as Z,ot as _,jr as a,Ce as a$,St as a0,ea as a1,Re as a2,Xn as a3,zn as a4,cr as a5,or as a6,sr as a7,tr as a8,rr as a9,di as aA,fn as aB,nn as aC,dn as aD,ti as aE,Xt as aF,He as aG,Sr as aH,hi as aI,ke as aJ,Pe as aK,Hs as aL,_t as aM,De as aN,Zr as aO,Gs as aP,Hr as aQ,ft as aR,Je as aS,We as aT,bt as aU,Os as aV,Et as aW,Fe as aX,qe as aY,Tn as aZ,Le as a_,zr as aa,pt as ab,Ye as ac,mt as ad,vr as ae,_r as af,pr as ag,Ct as ah,Qr as ai,Tt as aj,$s as ak,mn as al,vn as am,yn as an,_n as ao,Oe as ap,Ke as aq,ze as ar,wt as as,oa as at,ii as au,Rs as av,xs as aw,Ds as ax,Ls as ay,sn as az,Kr as b,je as b0,at as b1,Be as b2,xe as b3,lt as b4,dt as b5,st as b6,Vr as c,Fs as d,qs as e,Jr as f,Ps as g,Xr as h,$r as i,ei as j,Wr as k,Yr as l,ks as m,Ss as n,bs as o,Ms as p,la as q,bi as r,ia as s,Ks as t,Bs as u,Es as v,As as w,Ui as x,Nn as y,pi as z}; diff --git a/lib/__bundle-e53b9010.js b/lib/__bundle-5dbd9d35.js similarity index 97% rename from lib/__bundle-e53b9010.js rename to lib/__bundle-5dbd9d35.js index 667d378..97f2304 100644 --- a/lib/__bundle-e53b9010.js +++ b/lib/__bundle-5dbd9d35.js @@ -1 +1 @@ -import{C as e,c as n,W as t,U as s,g as r,_ as a,b as i,af as o,V as u,au as E,aE as N,u as c,bm as _}from"./__bundle-1db3fd0b.js";import{T as l,aL as d,aM as h,aN as C,a1 as A}from"./__bundle-e1a5e3f1.js";import{P as p}from"./__bundle-acd77193.js";var f;!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"}(f||(f={}));var m=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}(),v=function(e){function t(n,t,s){var r=e.call(this,n,"SYEV",s)||this;return r.event=new m(s),r}return n(t,e),t}(t),T=function(e){function t(n,t,r){var a=e.call(this,n,t,r)||this,i=r.data.operators,o=void 0===i?[]:i;return a.operators=o.map((function(e){return new s(a._iid,e)})),a}return n(t,e),t}(v),g=function(e){function t(n,t,s){var a,i=this;return(i=e.call(this,n,"SYEV",s)||this).pinnedMessageIds=[],i.latestPinnedMessage=null,i.ts=0,s.data&&(i.pinnedMessageIds=null!==(a=s.data.pinned_message_ids)&&void 0!==a?a:[],i.latestPinnedMessage=s.data.latest_pinned_message?l(n,r({},s.data.latest_pinned_message)):null),i.ts=s.ts,i}return n(t,e),t}(t),H=function(e){function t(n,t){var s=e.call(this,n)||this;return s._logger=t.logger,s._sdkState=t.sdkState,s._sessionManager=t.sessionManager,s._requestQueue=t.requestQueue,s._dispatcher=t.dispatcher,s._cacheContext=t.cacheContext,s._channelType=t.channelType,s}return n(t,e),Object.defineProperty(t.prototype,"_messageBroadcast",{get:function(){return d.of(this._iid)},enumerable:!1,configurable:!0}),t.prototype.subscribeMessageEvent=function(e,n){this._messageBroadcast.subscribe(e,n)},t.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},t.prototype.getMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,null]}))}))},t.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,n,t){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getMessagesFromCache=function(e,n,t,s,r,o){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getPollMessagesFromCache=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getCachedMessageCountBetween=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,0]}))}))},t.prototype.getUnsentMessagesFromCache=function(e,n){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.removeFailedMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},t}(o),L=function(e){function t(n,t,s){var r,a,i,o,N=this;(N=e.call(this,n,"ADMM",s)||this).message=new h(n,s);var c=u.of(n).sdkState;return N.isMentioned=E(N.message.mentionType,null!==(i=null!==(r=N.message.mentionedUserIds)&&void 0!==r?r:null===(a=N.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==i?i:[],c.userId),N.forceUpdateLastMessage=null!==(o=s.force_update_last_message)&&void 0!==o&&o,N}return n(t,e),t}(t),I=function(e){function t(n,t,s){var r,a,i,o,E,_=this;(_=e.call(this,n,"AEDI",s)||this).message=new h(n,s);var l=u.of(n).sdkState;return _.mentionCountChange=N({mentionType:null===(r=s.old_values)||void 0===r?void 0:r.mention_type,mentionedUserIds:null!==(i=null===(a=s.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==i?i:[]},c({mentionType:_.message.mentionType,mentionedUserIds:null!==(o=_.message.mentionedUserIds)&&void 0!==o?o:null===(E=_.message.mentionedUsers)||void 0===E?void 0:E.map((function(e){return e.userId}))}),l.userId),_}return n(t,e),t}(t),U=function(e){function t(n,t,s){var r=e.call(this,n,"MRCT",s)||this;return r.channelUrl=s.channel_url,r.channelType=s.channel_type,r.event=new C(s),r}return n(t,e),t}(t),M=function(e){function t(n,t,s){var r=e.call(this,n,"MTHD",s)||this;return r.event=new A(n,s),r}return n(t,e),t}(t),y=function(e){function t(n,t,s){var r=e.call(this,n,"MCNT",s)||this;return r.groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),r.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),r}return n(t,e),t}(t),b=function(e){function t(n,t,s){var r=e.call(this,n,"PEDI",s)||this;return r.event=new p(n,s),r.status=_(s.poll.status)||s.poll.status,r.channelUrl=s.channel_url,r.channelType=s.channel_type,r}return n(t,e),t}(t);export{L as A,H as B,v as C,y as M,T as O,b as P,U as R,M as T,g as U,f as a,I as b}; +import{C as e,c as n,W as t,U as s,g as r,_ as a,b as i,af as o,V as u,au as E,aE as N,u as c,bm as _}from"./__bundle-c03282ec.js";import{T as l,aL as d,aM as h,aN as C,a1 as A}from"./__bundle-45809bc9.js";import{P as p}from"./__bundle-acd77193.js";var f;!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"}(f||(f={}));var m=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}(),v=function(e){function t(n,t,s){var r=e.call(this,n,"SYEV",s)||this;return r.event=new m(s),r}return n(t,e),t}(t),T=function(e){function t(n,t,r){var a=e.call(this,n,t,r)||this,i=r.data.operators,o=void 0===i?[]:i;return a.operators=o.map((function(e){return new s(a._iid,e)})),a}return n(t,e),t}(v),g=function(e){function t(n,t,s){var a,i=this;return(i=e.call(this,n,"SYEV",s)||this).pinnedMessageIds=[],i.latestPinnedMessage=null,i.ts=0,s.data&&(i.pinnedMessageIds=null!==(a=s.data.pinned_message_ids)&&void 0!==a?a:[],i.latestPinnedMessage=s.data.latest_pinned_message?l(n,r({},s.data.latest_pinned_message)):null),i.ts=s.ts,i}return n(t,e),t}(t),H=function(e){function t(n,t){var s=e.call(this,n)||this;return s._logger=t.logger,s._sdkState=t.sdkState,s._sessionManager=t.sessionManager,s._requestQueue=t.requestQueue,s._dispatcher=t.dispatcher,s._cacheContext=t.cacheContext,s._channelType=t.channelType,s}return n(t,e),Object.defineProperty(t.prototype,"_messageBroadcast",{get:function(){return d.of(this._iid)},enumerable:!1,configurable:!0}),t.prototype.subscribeMessageEvent=function(e,n){this._messageBroadcast.subscribe(e,n)},t.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},t.prototype.getMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,null]}))}))},t.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,n,t){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getMessagesFromCache=function(e,n,t,s,r,o){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getPollMessagesFromCache=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getCachedMessageCountBetween=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,0]}))}))},t.prototype.getUnsentMessagesFromCache=function(e,n){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.removeFailedMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},t}(o),L=function(e){function t(n,t,s){var r,a,i,o,N=this;(N=e.call(this,n,"ADMM",s)||this).message=new h(n,s);var c=u.of(n).sdkState;return N.isMentioned=E(N.message.mentionType,null!==(i=null!==(r=N.message.mentionedUserIds)&&void 0!==r?r:null===(a=N.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==i?i:[],c.userId),N.forceUpdateLastMessage=null!==(o=s.force_update_last_message)&&void 0!==o&&o,N}return n(t,e),t}(t),I=function(e){function t(n,t,s){var r,a,i,o,E,_=this;(_=e.call(this,n,"AEDI",s)||this).message=new h(n,s);var l=u.of(n).sdkState;return _.mentionCountChange=N({mentionType:null===(r=s.old_values)||void 0===r?void 0:r.mention_type,mentionedUserIds:null!==(i=null===(a=s.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==i?i:[]},c({mentionType:_.message.mentionType,mentionedUserIds:null!==(o=_.message.mentionedUserIds)&&void 0!==o?o:null===(E=_.message.mentionedUsers)||void 0===E?void 0:E.map((function(e){return e.userId}))}),l.userId),_}return n(t,e),t}(t),U=function(e){function t(n,t,s){var r=e.call(this,n,"MRCT",s)||this;return r.channelUrl=s.channel_url,r.channelType=s.channel_type,r.event=new C(s),r}return n(t,e),t}(t),M=function(e){function t(n,t,s){var r=e.call(this,n,"MTHD",s)||this;return r.event=new A(n,s),r}return n(t,e),t}(t),y=function(e){function t(n,t,s){var r=e.call(this,n,"MCNT",s)||this;return r.groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),r.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),r}return n(t,e),t}(t),b=function(e){function t(n,t,s){var r=e.call(this,n,"PEDI",s)||this;return r.event=new p(n,s),r.status=_(s.poll.status)||s.poll.status,r.channelUrl=s.channel_url,r.channelType=s.channel_type,r}return n(t,e),t}(t);export{L as A,H as B,v as C,y as M,T as O,b as P,U as R,M as T,g as U,f as a,I as b}; diff --git a/lib/__bundle-31d4ecef.js b/lib/__bundle-5f5bca4c.js similarity index 73% rename from lib/__bundle-31d4ecef.js rename to lib/__bundle-5f5bca4c.js index cd39cdd..78170cd 100644 --- a/lib/__bundle-31d4ecef.js +++ b/lib/__bundle-5f5bca4c.js @@ -1 +1 @@ -import{c as t,b8 as n}from"./__bundle-1db3fd0b.js";var e=function(t){return["-lastMessageUpdatedAt","-createdAt","syncIndex"]},r=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t(e,n),e}(n);export{r as N,e as g}; +import{c as t,b8 as n}from"./__bundle-c03282ec.js";var e=function(t){return["-lastMessageUpdatedAt","-createdAt","syncIndex"]},r=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t(e,n),e}(n);export{r as N,e as g}; diff --git a/lib/__bundle-123134d8.js b/lib/__bundle-75f48c2c.js similarity index 89% rename from lib/__bundle-123134d8.js rename to lib/__bundle-75f48c2c.js index c0e480d..1fce20b 100644 --- a/lib/__bundle-123134d8.js +++ b/lib/__bundle-75f48c2c.js @@ -1 +1 @@ -import{aA as e}from"./__bundle-1db3fd0b.js";var t=function(){this.onUserMuted=e,this.onUserUnmuted=e,this.onUserBanned=e,this.onUserUnbanned=e,this.onChannelChanged=e,this.onChannelDeleted=e,this.onChannelFrozen=e,this.onChannelUnfrozen=e,this.onOperatorUpdated=e,this.onChannelMemberCountChanged=e,this.onMetaDataCreated=e,this.onMetaDataUpdated=e,this.onMetaDataDeleted=e,this.onMetaCounterCreated=e,this.onMetaCounterUpdated=e,this.onMetaCounterDeleted=e,this.onMessageReceived=e,this.onMessageUpdated=e,this.onMessageDeleted=e,this.onMentionReceived=e,this.onReactionUpdated=e,this.onThreadInfoUpdated=e};export{t as B}; +import{aA as e}from"./__bundle-c03282ec.js";var t=function(){this.onUserMuted=e,this.onUserUnmuted=e,this.onUserBanned=e,this.onUserUnbanned=e,this.onChannelChanged=e,this.onChannelDeleted=e,this.onChannelFrozen=e,this.onChannelUnfrozen=e,this.onOperatorUpdated=e,this.onChannelMemberCountChanged=e,this.onMetaDataCreated=e,this.onMetaDataUpdated=e,this.onMetaDataDeleted=e,this.onMetaCounterCreated=e,this.onMetaCounterUpdated=e,this.onMetaCounterDeleted=e,this.onMessageReceived=e,this.onMessageUpdated=e,this.onMessageDeleted=e,this.onMentionReceived=e,this.onReactionUpdated=e,this.onThreadInfoUpdated=e};export{t as B}; diff --git a/lib/__bundle-4b40b3a8.js b/lib/__bundle-b5ef7de4.js similarity index 86% rename from lib/__bundle-4b40b3a8.js rename to lib/__bundle-b5ef7de4.js index 19b0e4a..28105b0 100644 --- a/lib/__bundle-4b40b3a8.js +++ b/lib/__bundle-b5ef7de4.js @@ -1 +1 @@ -import{V as e,s as t,h as s,M as r,br as a,ax as n,bs as o,av as d}from"./__bundle-1db3fd0b.js";var i=function(i,u){return new Promise((function(c,p){if("undefined"!=typeof XMLHttpRequest){var f=e.of(i),l=f.dispatcher,g=f.logger,h=u.requestId,m=u.method,q=u.url,v=u.headers,b=void 0===v?{}:v,w=u.data,E=void 0===w?"":w,x=u.uploadProgressHandler,y=!1,H=new XMLHttpRequest;H.open(m,q),Object.keys(b).forEach((function(e){H.setRequestHeader(e,b[e])})),x&&H.upload.addEventListener("progress",(function(e){e.lengthComputable?x(h,e.loaded,e.total):g.debug("Progress computing failed: `Content-Length` header is not given.")})),H.onabort=function(){p(t.requestCanceled)},H.onerror=function(e){p(t.networkError)},H.onreadystatechange=function(){if(H.readyState===XMLHttpRequest.DONE&&!y)if(0===H.status||H.status>=200&&H.status<400)try{var e=JSON.parse(H.responseText);c(new s(i,e))}catch(u){p(t.networkError)}else try{var d=JSON.parse(H.responseText);if(d){var u=new t(d);if(u.isSessionExpiredError){if(l.dispatch(new r({reason:u.code,message:u.message})),!(H instanceof a)){var f=new n;return l.dispatch(new o({request:H,deferred:f,error:u})),f.promise}}else u.isSessionInvalidatedError&&l.dispatch(new r({reason:u.code,message:u.message}));p(u)}else p(t.requestFailed)}catch(u){p(t.requestFailed)}},l.on((function(e){e instanceof d&&(e.requestId&&e.requestId!==h||(y=!0,H.abort()))})),H.send(E)}else p(t.xmlHttpRequestNotSupported)}))};export{i as xmlHttpRequest}; +import{V as e,s as t,h as s,M as r,br as a,ax as n,bs as o,av as d}from"./__bundle-c03282ec.js";var i=function(i,u){return new Promise((function(c,p){if("undefined"!=typeof XMLHttpRequest){var f=e.of(i),l=f.dispatcher,g=f.logger,h=u.requestId,m=u.method,q=u.url,v=u.headers,w=void 0===v?{}:v,b=u.data,E=void 0===b?"":b,x=u.uploadProgressHandler,y=!1,H=new XMLHttpRequest;H.open(m,q),Object.keys(w).forEach((function(e){H.setRequestHeader(e,w[e])})),x&&H.upload.addEventListener("progress",(function(e){e.lengthComputable?x(h,e.loaded,e.total):g.debug("Progress computing failed: `Content-Length` header is not given.")})),H.onabort=function(){p(t.requestCanceled)},H.onerror=function(e){p(t.networkError)},H.onreadystatechange=function(){if(H.readyState===XMLHttpRequest.DONE&&!y)if(0===H.status||H.status>=200&&H.status<400)try{var e=JSON.parse(H.responseText);c(new s(i,e))}catch(u){p(t.networkError)}else try{var d=JSON.parse(H.responseText);if(d){var u=new t(d);if(u.isSessionExpiredError){if(l.dispatch(new r({reason:u.code,message:u.message})),!(H instanceof a)){var f=new n;return l.dispatch(new o({request:H,deferred:f,error:u})),f.promise}}else u.isSessionInvalidatedError&&l.dispatch(new r({reason:u.code,message:u.message}));p(u)}else p(t.requestFailed)}catch(u){p(t.requestFailed)}},l.on((function(e){e instanceof d&&(e.requestId&&e.requestId!==h||(y=!0,H.abort()))})),H.send(E)}else p(t.xmlHttpRequestNotSupported)}))};export{i as xmlHttpRequest}; diff --git a/lib/__bundle-c03282ec.js b/lib/__bundle-c03282ec.js new file mode 100644 index 0000000..cf42a4a --- /dev/null +++ b/lib/__bundle-c03282ec.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 i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[i++],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 i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function c(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r0&&b.indexOf(e)>=0},I=function(e){return e>0&&m.indexOf(e)>=0},O=function(e,t){if(void 0===t&&(t=!1),t&&D(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},k=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(),i=c([],a(t),!1).sort(),r=0;r=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}(),L={encrypt:function(e){return e},decrypt:function(e){return e}},x=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return r(this,void 0,void 0,(function(){return s(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),r(this,void 0,void 0,(function(){var i,r,a,c,u,l,h,d,_,f;return s(this,(function(s){switch(s.label){case 0:return this._version=t,this._keysAddress=e,i="".concat(e,".metadata.version"),[4,this._store.get(i)];case 1:return r=s.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=s.sent())&&void 0!==n?n:[],!r||r.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(i,64),o?(this._clearOrder=s,this._customClearOrderComparator=o):this._clearOrder=E.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=c}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===E.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableAutoResend",{get:function(){return this._enableAutoResend},enumerable:!1,configurable:!0}),e}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(P||(P={}));var q,H,V,z,G,j,K,B,Q,W,Z,Y,X,J=function(){function e(){this.isRefreshing=!1}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasChatServicePermission",{get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(P.CHAT))},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]},e}(),$=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)}))},ee=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=$()}return e.prototype._register=function(e,t,n){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: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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))},e}(),te=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new ee({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new ee({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,i,r=this._container[e];if(r){var s=[];try{for(var a=o(r.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=r.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&s.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}s.forEach((function(e){return r.delete(e)}))}},e}(),ne=function(){function e(){this._dispatcher=new te}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}(),ie=function(){},re=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},se=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){for(var t=c([],a(e),!1),n=0;n0&&(i.extension_sdk_info=r.map((function(e){var t=e.product,n=e.platform,i=e.version;return"".concat(t,"/").concat(n,"/").concat(i)})).join(",")),Object.keys(i).forEach((function(e){return delete c[e]})),Object.keys(c).length>0&&(i=n(n({},i),c))}return Object.entries(i).map((function(e){var t=a(e,2),n=t[0],i=t[1];return"".concat(n,"=").concat(i)})).join("&")},e.userAgentWithExtension=function(e){var t=Xe()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",i=e.sb_uikit?"u".concat(e.sb_uikit):"",r=e["device-os-platform"]?"o".concat(e["device-os-platform"]):Je()?"omobile-web":"oweb";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(i,"/").concat(r)},e}(),tt=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=function(e){n(e)}}))},nt=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t.requestId,n}return t(n,e),n}(ie),it=function(e){function n(t){var n=e.call(this)||this;return n.method=oe.DELETE,n.path="".concat(Oe(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),t.messageToken&&(n.params=re({mesg_token:t.messageToken})),n}return t(n,e),n}(Ue);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Pe);var rt=function(e){function n(t,n,i){var r,s=this;return(s=e.call(this,t,"DELM",i)||this).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(r=i.sender_id)&&void 0!==r?r:void 0,s}return t(n,e),n}(qe),st=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=n,this._sdkState=i,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof Me&&c.cancel(e.requestId)})),this._logger=s,this._shouldImportFetchCompat=a}return e.prototype._createHeader=function(e,t){var i=this._sdkState,r=i.appId,s=i.appVersion,o=i.sendbirdRuntimeEnvironment,a=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(r).concat(s?",".concat(s):""),"SB-User-Agent":et.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":et.sendbirdSdkUserAgentWithExtension(o)});return t||(a["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(a["Session-Key"]=this._session.sessionKey),a["App-Id"]=r,this._session&&this._session.authToken&&(a["Access-Token"]=this._session.authToken),a},e.prototype._statLogApiResult=function(e,t,n){e.path.includes("/sdk/statistics")||this._dispatcher.dispatch(new Ke(new Ye({type:xe.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._isBodyRequired=function(e){var t=e.method;return t!==oe.GET&&(t!==oe.DELETE||e instanceof it)},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a,c,l,h,d,_,f,p,E,g,b,m,y,w;return s(this,(function(s){switch(s.label){case 0:t=e.path,n=e.method,i=e.uploadProgressHandler,r=this._isBodyRequired(e),o=this._sdkState.api,a="".concat(o.host).concat(t).concat(r?"":e.query),c=r?e.payload:null,l=this._createHeader(e,c instanceof FormData?c:void 0),h=new AbortController,d=h.signal,this._abortControl.set(e.requestId,h),_=Date.now(),s.label=1;case 1:return s.trys.push([1,13,,14]),i?[4,import("./__bundle-b5ef7de4.js")]:[3,6];case 2:f=s.sent().xmlHttpRequest,s.label=3;case 3:return s.trys.push([3,5,,6]),[4,f(this._iid,{requestId:e.requestId,method:e.method,url:a,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i})];case 4:return p=s.sent(),this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,p];case 5:if(!((E=s.sent())instanceof v&&E.code===u.XMLHTTPREQUEST_NOT_SUPPORTED))throw E;return this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),[3,6];case 6:return 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,8]:[4,import("./__bundle-7c3d40f4.js")];case 7:s.sent(),s.label=8;case 8:return"function"==typeof fetch?[3,10]:[4,import("./__bundle-46d64517.js")];case 9:s.sent(),s.label=10;case 10:return[4,fetch(a,{method:n,body:c,headers:l,signal:d})];case 11:return[4,(g=s.sent()).json()];case 12:if(b=s.sent(),g.ok||g.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,new Pe(this._iid,b)];if(b){if((m=new v(b)).isSessionExpiredError){if(this._dispatcher.dispatch(new Fe({reason:m.code,message:m.message})),!(e instanceof Ve))return y=new tt,this._dispatcher.dispatch(new Be({request:e,deferred:y,error:m})),[2,y.promise];throw m}throw m.isSessionInvalidatedError?(this._dispatcher.dispatch(new Fe({reason:m.code,message:m.message})),m):m}throw v.requestFailed;case 13:throw w=s.sent(),this._statLogApiResult(e,_,w),w instanceof v?(this._logger.debug("fail api request",w),w):"AbortError"===(null==w?void 0:w.name)?v.requestCanceled:(this._logger.debug("fail api request",w),v.networkError);case 14:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new nt({requestId:e}))},e.prototype.cancelAll=function(){var e,t;try{for(var n=o(this._abortControl.values()),i=n.next();!i.done;i=n.next()){i.value.abort()}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear(),this._dispatcher.dispatch(new nt({}))},e}(),ot=function(){};function at(e){let t=e.length;for(;--t>=0;)e[t]=0}const ct=256,ut=286,lt=30,ht=15,dt=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]),_t=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]),ft=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),pt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Et=new Array(576);at(Et);const gt=new Array(60);at(gt);const vt=new Array(512);at(vt);const bt=new Array(256);at(bt);const mt=new Array(29);at(mt);const yt=new Array(lt);function wt(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}let St,Tt,Nt;function Ct(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}at(yt);const At=e=>e<256?vt[e]:vt[256+(e>>>7)],It=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Ot=(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<{Ot(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},Rt=(e,t,n)=>{const i=new Array(16);let r,s,o=0;for(r=1;r<=ht;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=Dt(i[t]++,t))}},Lt=e=>{let t;for(t=0;t{e.bi_valid>8?It(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ut=(e,t,n,i)=>{const r=2*t,s=2*n;return e[r]{const i=e.heap[n];let r=n<<1;for(;r<=e.heap_len&&(r{let i,r,s,o,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,r=e.pending_buf[e.sym_buf+a++],0===i?kt(e,r,t):(s=bt[r],kt(e,s+ct+1,t),o=dt[s],0!==o&&(r-=mt[s],Ot(e,r,o)),i--,s=At(i),kt(e,s,n),o=_t[s],0!==o&&(i-=yt[s],Ot(e,i,o)))}while(a{const n=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)Pt(e,n,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Pt(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,n[2*c]=n[2*o]+n[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,n[2*o+1]=n[2*a+1]=c,e.heap[1]=c++,Pt(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,i=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=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<=ht;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>i||(e.bl_count[d]++,_=0,l>=a&&(_=o[l-a]),f=n[2*l],e.opt_len+=f*(d+_),s&&(e.static_len+=f*(r[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>i||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),Rt(n,u,e.bl_count)},qt=(e,t,n)=>{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=t[2*(i+1)+1],++a{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),i=0;i<=n;i++)if(r=o,o=t[2*(i+1)+1],!(++a{Ot(e,0+(i?1:0),3),xt(e),It(e,n),It(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Gt=(e,t,n,i)=>{let r,s,o=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(qt(e,e.dyn_ltree,e.l_desc.max_code),qt(e,e.dyn_dtree,e.d_desc.max_code),Ft(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*pt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&-1!==t?zt(e,t,n,i):4===e.strategy||s===r?(Ot(e,2+(i?1:0),3),Mt(e,Et,gt)):(Ot(e,4+(i?1:0),3),((e,t,n,i)=>{let r;for(Ot(e,t-257,5),Ot(e,n-1,5),Ot(e,i-4,4),r=0;r{Vt||((()=>{let e,t,n,i,r;const s=new Array(16);for(n=0,i=0;i<28;i++)for(mt[i]=n,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++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(bt[n]+ct+1)]++,e.dyn_dtree[2*At(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Ot(e,2,3),kt(e,256,Et),(e=>{16===e.bi_valid?(It(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 Kt=(e,t,n,i)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+t[i++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Bt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Qt=(e,t,n,i)=>{const r=Bt,s=i+n;e^=-1;for(let n=i;n>>8^r[255&(e^t[n])];return~e},Wt={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"},Zt={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:Yt,_tr_stored_block:Xt,_tr_flush_block:Jt,_tr_tally:$t,_tr_align:en}=jt,{Z_NO_FLUSH:tn,Z_PARTIAL_FLUSH:nn,Z_FULL_FLUSH:rn,Z_FINISH:sn,Z_BLOCK:on,Z_OK:an,Z_STREAM_END:cn,Z_STREAM_ERROR:un,Z_DATA_ERROR:ln,Z_BUF_ERROR:hn,Z_DEFAULT_COMPRESSION:dn,Z_FILTERED:_n,Z_HUFFMAN_ONLY:fn,Z_RLE:pn,Z_FIXED:En,Z_DEFAULT_STRATEGY:gn,Z_UNKNOWN:vn,Z_DEFLATED:bn}=Zt,mn=258,yn=262,wn=42,Sn=113,Tn=666,Nn=(e,t)=>(e.msg=Wt[t],t),Cn=e=>2*e-(e>4?9:0),An=e=>{let t=e.length;for(;--t>=0;)e[t]=0},In=e=>{let t,n,i,r=e.w_size;t=e.hash_size,i=t;do{n=e.head[--i],e.head[i]=n>=r?n-r:0}while(--t);t=r,i=t;do{n=e.prev[--i],e.prev[i]=n>=r?n-r:0}while(--t)};let On=(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)=>{Jt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,kn(e.strm)},Rn=(e,t)=>{e.pending_buf[e.pending++]=t},Ln=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},xn=(e,t,n,i)=>{let r=e.avail_in;return r>i&&(r=i),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),n),1===e.state.wrap?e.adler=Kt(e.adler,t,r,n):2===e.state.wrap&&(e.adler=Qt(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)},Un=(e,t)=>{let n,i,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-yn?e.strstart-(e.w_size-yn):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+mn;let _=u[s+o-1],f=u[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+o]===f&&u[n+o-1]===_&&u[n]===u[s]&&u[++n]===u[s+1]){s+=2,n++;do{}while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&so){if(e.match_start=t,o=i,i>=a)break;_=u[s+o-1],f=u[s+o]}}}while((t=h[t&l])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead},Pn=e=>{const t=e.w_size;let n,i,r;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-yn)&&(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),In(e),i+=t),0===e.strm.avail_in)break;if(n=xn(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=n,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=On(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=On(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,i,r,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(n=65535,r=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(n=i+e.strm.avail_in),n>r&&(n=r),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,kn(e.strm),i&&(i>n&&(i=n),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,n-=i),n&&(xn(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===o);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_waterr&&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++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(xn(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,s=r>e.w_size?e.w_size:r,i=e.strstart-e.block_start,(i>=s||(i||t===sn)&&t!==tn&&0===e.strm.avail_in&&i<=r)&&(n=i>r?r:i,o=t===sn&&0===e.strm.avail_in&&n===i?1:0,Xt(e,e.block_start,n,o),e.block_start+=n,kn(e.strm)),o?3:1)},Fn=(e,t)=>{let n,i;for(;;){if(e.lookahead=3&&(e.ins_h=On(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-yn&&(e.match_length=Un(e,n)),e.match_length>=3)if(i=$t(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=On(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=On(e,e.ins_h,e.window[e.strstart+1]);else i=$t(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(Dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===sn?(Dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Dn(e,!1),0===e.strm.avail_out)?1:2},qn=(e,t)=>{let n,i,r;for(;;){if(e.lookahead=3&&(e.ins_h=On(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){r=e.strstart+e.lookahead-3,i=$t(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=On(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++,i&&(Dn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=$t(e,0,e.window[e.strstart-1]),i&&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&&(i=$t(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===sn?(Dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Dn(e,!1),0===e.strm.avail_out)?1:2};function Hn(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}const Vn=[new Hn(0,0,0,0,Mn),new Hn(4,4,8,4,Fn),new Hn(4,5,16,8,Fn),new Hn(4,6,32,32,Fn),new Hn(4,4,16,16,qn),new Hn(8,16,32,32,qn),new Hn(8,16,128,128,qn),new Hn(8,32,128,256,qn),new Hn(32,128,258,1024,qn),new Hn(32,258,258,4096,qn)];function zn(){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=bn,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),An(this.dyn_ltree),An(this.dyn_dtree),An(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),An(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),An(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 Gn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==wn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Sn&&t.status!==Tn?1:0},jn=e=>{if(Gn(e))return Nn(e,un);e.total_in=e.total_out=0,e.data_type=vn;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?wn:Sn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Yt(t),an},Kn=e=>{const t=jn(e);var n;return t===an&&((n=e.state).window_size=2*n.w_size,An(n.head),n.max_lazy_match=Vn[n.level].max_lazy,n.good_match=Vn[n.level].good_length,n.nice_match=Vn[n.level].nice_length,n.max_chain_length=Vn[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},Bn=(e,t,n,i,r,s)=>{if(!e)return un;let o=1;if(t===dn&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>9||n!==bn||i<8||i>15||t<0||t>9||s<0||s>En||8===i&&1!==o)return Nn(e,un);8===i&&(i=9);const a=new zn;return e.state=a,a.strm=e,a.status=wn,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<Bn(e,t,bn,15,8,gn),deflateInit2:Bn,deflateReset:Kn,deflateResetKeep:jn,deflateSetHeader:(e,t)=>Gn(e)||2!==e.state.wrap?un:(e.state.gzhead=t,an),deflate:(e,t)=>{if(Gn(e)||t>on||t<0)return e?Nn(e,un):un;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Tn&&t!==sn)return Nn(e,0===e.avail_out?hn:un);const i=n.last_flush;if(n.last_flush=t,0!==n.pending){if(kn(e),0===e.avail_out)return n.last_flush=-1,an}else if(0===e.avail_in&&Cn(t)<=Cn(i)&&t!==sn)return Nn(e,hn);if(n.status===Tn&&0!==e.avail_in)return Nn(e,hn);if(n.status===wn&&0===n.wrap&&(n.status=Sn),n.status===wn){let t=bn+(n.w_bits-8<<4)<<8,i=-1;if(i=n.strategy>=fn||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=i<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Ln(n,t),0!==n.strstart&&(Ln(n,e.adler>>>16),Ln(n,65535&e.adler)),e.adler=1,n.status=Sn,kn(e),0!==n.pending)return n.last_flush=-1,an}if(57===n.status)if(e.adler=0,Rn(n,31),Rn(n,139),Rn(n,8),n.gzhead)Rn(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)),Rn(n,255&n.gzhead.time),Rn(n,n.gzhead.time>>8&255),Rn(n,n.gzhead.time>>16&255),Rn(n,n.gzhead.time>>24&255),Rn(n,9===n.level?2:n.strategy>=fn||n.level<2?4:0),Rn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Rn(n,255&n.gzhead.extra.length),Rn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Qt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Rn(n,0),Rn(n,0),Rn(n,0),Rn(n,0),Rn(n,0),Rn(n,9===n.level?2:n.strategy>=fn||n.level<2?4:0),Rn(n,3),n.status=Sn,kn(e),0!==n.pending)return n.last_flush=-1,an;if(69===n.status){if(n.gzhead.extra){let t=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=r,kn(e),0!==n.pending)return n.last_flush=-1,an;t=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>t&&(e.adler=Qt(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,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,an;i=0}t=n.gzindexi&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,an;i=0}t=n.gzindexi&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(kn(e),0!==n.pending))return n.last_flush=-1,an;Rn(n,255&e.adler),Rn(n,e.adler>>8&255),e.adler=0}if(n.status=Sn,kn(e),0!==n.pending)return n.last_flush=-1,an}if(0!==e.avail_in||0!==n.lookahead||t!==tn&&n.status!==Tn){let i=0===n.level?Mn(n,t):n.strategy===fn?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Pn(e),0===e.lookahead)){if(t===tn)return 1;break}if(e.match_length=0,n=$t(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===sn?(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===pn?((e,t)=>{let n,i,r,s;const o=e.window;for(;;){if(e.lookahead<=mn){if(Pn(e),e.lookahead<=mn&&t===tn)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=e.strstart+mn;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=$t(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=$t(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===sn?(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):Vn[n.level].func(n,t);if(3!==i&&4!==i||(n.status=Tn),1===i||3===i)return 0===e.avail_out&&(n.last_flush=-1),an;if(2===i&&(t===nn?en(n):t!==on&&(Xt(n,0,0,!1),t===rn&&(An(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),kn(e),0===e.avail_out))return n.last_flush=-1,an}return t!==sn?an:n.wrap<=0?cn:(2===n.wrap?(Rn(n,255&e.adler),Rn(n,e.adler>>8&255),Rn(n,e.adler>>16&255),Rn(n,e.adler>>24&255),Rn(n,255&e.total_in),Rn(n,e.total_in>>8&255),Rn(n,e.total_in>>16&255),Rn(n,e.total_in>>24&255)):(Ln(n,e.adler>>>16),Ln(n,65535&e.adler)),kn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?an:cn)},deflateEnd:e=>{if(Gn(e))return un;const t=e.state.status;return e.state=null,t===Sn?Nn(e,ln):an},deflateSetDictionary:(e,t)=>{let n=t.length;if(Gn(e))return un;const i=e.state,r=i.wrap;if(2===r||1===r&&i.status!==wn||i.lookahead)return un;if(1===r&&(e.adler=Kt(e.adler,t,n,0)),i.wrap=0,n>=i.w_size){0===r&&(An(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(n-i.w_size,n),0),t=e,n=i.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Pn(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=On(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,Pn(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=o,e.input=a,e.avail_in=s,i.wrap=r,an},deflateInfo:"pako deflate (from Nodeca project)"};const Wn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Zn=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)Wn(n,t)&&(e[t]=n[t])}}return e},Yn=e=>{let t=0;for(let n=0,i=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Jn[254]=Jn[254]=1;var $n=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,i,r,s,o=e.length,a=0;for(r=0;r>>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},ei=(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let i,r;const s=new Array(2*n);for(r=0,i=0;i4)s[r++]=65533,i+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&i1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Xn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let i=0;i{(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+Jn[e[n]]>t?n:t};var ni=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 ii=Object.prototype.toString,{Z_NO_FLUSH:ri,Z_SYNC_FLUSH:si,Z_FULL_FLUSH:oi,Z_FINISH:ai,Z_OK:ci,Z_STREAM_END:ui,Z_DEFAULT_COMPRESSION:li,Z_DEFAULT_STRATEGY:hi,Z_DEFLATED:di}=Zt;function _i(e){this.options=Zn({level:li,method:di,chunkSize:16384,windowBits:15,memLevel:8,strategy:hi},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 ni,this.strm.avail_out=0;let n=Qn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ci)throw new Error(Wt[n]);if(t.header&&Qn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?$n(t.dictionary):"[object ArrayBuffer]"===ii.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Qn.deflateSetDictionary(this.strm,e),n!==ci)throw new Error(Wt[n]);this._dict_set=!0}}function fi(e,t){const n=new _i(t);if(n.push(e,!0),n.err)throw n.msg||Wt[n.err];return n.result}_i.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?ai:ri,"string"==typeof e?n.input=$n(e):"[object ArrayBuffer]"===ii.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(i),n.next_out=0,n.avail_out=i),(s===si||s===oi)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(r=Qn.deflate(n,s),r===ui)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),r=Qn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===ci;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},_i.prototype.onData=function(e){this.chunks.push(e)},_i.prototype.onEnd=function(e){e===ci&&(this.result=Yn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var pi={Deflate:_i,deflate:fi,deflateRaw:function(e,t){return(t=t||{}).raw=!0,fi(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,fi(e,t)},constants:Zt};const Ei=16209;var gi=function(e,t){let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T,N;const C=e.state;n=e.next_in,T=e.input,i=n+(e.avail_in-5),r=e.next_out,N=e.output,s=r-(t-e.avail_out),o=r+(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,E=(1<>>24,d>>>=b,_-=b,b=v>>>16&255,0===b)N[r++]=65535&v;else{if(!(16&b)){if(64&b){if(32&b){C.mode=16191;break e}e.msg="invalid literal/length code",C.mode=Ei;break e}v=f[(65535&v)+(d&(1<>>=b,_-=b),_<15&&(d+=T[n++]<<_,_+=8,d+=T[n++]<<_,_+=8),v=p[d&g];;){if(b=v>>>24,d>>>=b,_-=b,b=v>>>16&255,16&b){if(y=65535&v,b&=15,_a){e.msg="invalid distance too far back",C.mode=Ei;break e}if(d>>>=b,_-=b,b=r-s,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=Ei;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)N[r++]=S[w++],N[r++]=S[w++],N[r++]=S[w++],m-=3;m&&(N[r++]=S[w++],m>1&&(N[r++]=S[w++]))}else{w=r-y;do{N[r++]=N[w++],N[r++]=N[w++],N[r++]=N[w++],m-=3}while(m>2);m&&(N[r++]=N[w++],m>1&&(N[r++]=N[w++]))}break}if(64&b){e.msg="invalid distance code",C.mode=Ei;break e}v=p[(65535&v)+(d&(1<>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=r,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,E=0,g=0,v=0,b=0,m=0,y=0,w=0,S=0,T=0,N=null;const C=new Uint16Array(16),A=new Uint16Array(16);let I,O,k,D=null;for(p=0;p<=vi;p++)C[p]=0;for(E=0;E=1&&0===C[v];v--);if(b>v&&(b=v),0===v)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(A[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){I=p-y,o[E]+1=f?(O=D[o[E]-f],k=N[o[E]-f]):(O=96,k=0),u=1<>y)+l]=I<<24|O<<16|k}while(0!==l);for(u=1<>=1;if(0!==u?(T&=u-1,T+=u):T=0,E++,0==--C[p]){if(p===v)break;p=t[n+o[E]]}if(p>b&&(T&d)!==h){for(0===y&&(y=b),_+=g,m=p-y,w=1<852||2===e&&S>592)return 1;h=T&d,r[h]=b<<24|m<<16|_-s}}return 0!==T&&(r[_+T]=p-y<<24|64<<16),a.bits=b,0};const{Z_FINISH:Ti,Z_BLOCK:Ni,Z_TREES:Ci,Z_OK:Ai,Z_STREAM_END:Ii,Z_NEED_DICT:Oi,Z_STREAM_ERROR:ki,Z_DATA_ERROR:Di,Z_MEM_ERROR:Ri,Z_BUF_ERROR:Li,Z_DEFLATED:xi}=Zt,Ui=16180,Pi=16190,Mi=16191,Fi=16192,qi=16194,Hi=16199,Vi=16200,zi=16206,Gi=16209,ji=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ki(){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 Bi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Qi=e=>{if(Bi(e))return ki;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=Ui,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,Ai},Wi=e=>{if(Bi(e))return ki;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Qi(e)},Zi=(e,t)=>{let n;if(Bi(e))return ki;const i=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ki:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,Wi(e))},Yi=(e,t)=>{if(!e)return ki;const n=new Ki;e.state=n,n.strm=e,n.window=null,n.mode=Ui;const i=Zi(e,t);return i!==Ai&&(e.state=null),i};let Xi,Ji,$i=!0;const er=e=>{if($i){Xi=new Int32Array(512),Ji=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(Si(1,e.lens,0,288,Xi,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Si(2,e.lens,0,32,Ji,0,e.work,{bits:5}),$i=!1}e.lencode=Xi,e.lenbits=9,e.distcode=Ji,e.distbits=5},tr=(e,t,n,i)=>{let r;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):(r=s.wsize-s.wnext,r>i&&(r=i),s.window.set(t.subarray(n-i,n-i+r),s.wnext),(i-=r)?(s.window.set(t.subarray(n-i,n),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whaveYi(e,15),inflateInit2:Yi,inflate:(e,t)=>{let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T=0;const N=new Uint8Array(4);let C,A;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Bi(e)||!e.output||!e.input&&0!==e.avail_in)return ki;n=e.state,n.mode===Mi&&(n.mode=Fi),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=Ai;e:for(;;)switch(n.mode){case Ui:if(0===n.wrap){n.mode=Fi;break}for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>>8&255,n.check=Qt(n.check,N,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=Gi;break}if((15&u)!==xi){e.msg="unknown compression method",n.mode=Gi;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=Gi;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Qt(n.check,N,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>8&255,N[2]=u>>>16&255,N[3]=u>>>24&255,n.check=Qt(n.check,N,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>8),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Qt(n.check,N,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+=i[s++]<>>8&255,n.check=Qt(n.check,N,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(i.subarray(s,s+_),w)),512&n.flags&&4&n.wrap&&(n.check=Qt(n.check,i,_,s)),a-=_,s+=_,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=i[s+_++],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=Mi;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>=7&l,l-=7&l,n.mode=zi;break}for(;l<3;){if(0===a)break e;a--,u+=i[s++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(er(n),n.mode=Hi,t===Ci){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Gi}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=i[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Gi;break}if(n.length=65535&u,u=0,l=0,n.mode=qi,t===Ci)break e;case qi:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;r.set(i.subarray(s,s+_),o),a-=_,s+=_,c-=_,o+=_,n.length-=_;break}n.mode=Mi;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=i[s++]<>>=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=Gi;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,C={bits:n.lenbits},S=Si(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=Gi;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=E,l-=E,n.lens[n.have++]=v;else{if(16===v){for(A=E+2;l>>=E,l-=E,0===n.have){e.msg="invalid bit length repeat",n.mode=Gi;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===v){for(A=E+3;l>>=E,l-=E,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(A=E+7;l>>=E,l-=E,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Gi;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===Gi)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Gi;break}if(n.lenbits=9,C={bits:n.lenbits},S=Si(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=Gi;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=Si(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=Gi;break}if(n.mode=Hi,t===Ci)break e;case Hi:n.mode=Vi;case Vi:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,n.hold=u,n.bits=l,gi(e,d),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===Mi&&(n.back=-1);break}for(n.back=0;T=n.lencode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,n.length=v,0===g){n.mode=16205;break}if(32&g){n.back=-1,n.mode=Mi;break}if(64&g){e.msg="invalid literal/length code",n.mode=Gi;break}n.extra=15&g,n.mode=16201;case 16201:if(n.extra){for(A=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;T=n.distcode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,64&g){e.msg="invalid distance code",n.mode=Gi;break}n.offset=v,n.extra=15&g,n.mode=16203;case 16203:if(n.extra){for(A=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=Gi;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=Gi;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=r,f=o-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{r[o++]=p[f++]}while(--_);0===n.length&&(n.mode=Vi);break;case 16205:if(0===c)break e;r[o++]=n.length,c--,n.mode=Vi;break;case zi:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=i[s++]<{if(Bi(e))return ki;let t=e.state;return t.window&&(t.window=null),e.state=null,Ai},inflateGetHeader:(e,t)=>{if(Bi(e))return ki;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Ai):ki},inflateSetDictionary:(e,t)=>{const n=t.length;let i,r,s;return Bi(e)?ki:(i=e.state,0!==i.wrap&&i.mode!==Pi?ki:i.mode===Pi&&(r=1,r=Kt(r,t,n,0),r!==i.check)?Di:(s=tr(e,t,n,n),s?(i.mode=16210,Ri):(i.havedict=1,Ai)))},inflateInfo:"pako inflate (from Nodeca project)"};var ir=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 rr=Object.prototype.toString,{Z_NO_FLUSH:sr,Z_FINISH:or,Z_OK:ar,Z_STREAM_END:cr,Z_NEED_DICT:ur,Z_STREAM_ERROR:lr,Z_DATA_ERROR:hr,Z_MEM_ERROR:dr}=Zt;function _r(e){this.options=Zn({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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ni,this.strm.avail_out=0;let n=nr.inflateInit2(this.strm,t.windowBits);if(n!==ar)throw new Error(Wt[n]);if(this.header=new ir,nr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=$n(t.dictionary):"[object ArrayBuffer]"===rr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=nr.inflateSetDictionary(this.strm,t.dictionary),n!==ar)))throw new Error(Wt[n])}function fr(e,t){const n=new _r(t);if(n.push(e),n.err)throw n.msg||Wt[n.err];return n.result}_r.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?or:sr,"[object ArrayBuffer]"===rr.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(i),n.next_out=0,n.avail_out=i),s=nr.inflate(n,o),s===ur&&r&&(s=nr.inflateSetDictionary(n,r),s===ar?s=nr.inflate(n,o):s===hr&&(s=ur));n.avail_in>0&&s===cr&&n.state.wrap>0&&0!==e[n.next_in];)nr.inflateReset(n),s=nr.inflate(n,o);switch(s){case lr:case hr:case ur:case dr:return this.onEnd(s),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||s===cr))if("string"===this.options.to){let e=ti(n.output,n.next_out),t=n.next_out-e,r=ei(n.output,e);n.next_out=t,n.avail_out=i-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==ar||0!==a){if(s===cr)return s=nr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},_r.prototype.onData=function(e){this.chunks.push(e)},_r.prototype.onEnd=function(e){e===ar&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Yn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var pr={Inflate:_r,inflate:fr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,fr(e,t)},ungzip:fr,constants:Zt};const{Deflate:Er,deflate:gr,deflateRaw:vr,gzip:br}=pi,{Inflate:mr,inflate:yr,inflateRaw:wr,ungzip:Sr}=pr;var Tr,Nr={Deflate:Er,deflate:gr,deflateRaw:vr,gzip:br,Inflate:mr,inflate:yr,inflateRaw:wr,ungzip:Sr,constants:Zt},Cr=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){return t=Nr.ungzip(e),[2,String.fromCharCode.apply(null,t)]}))}))};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(Tr||(Tr={}));var Ar,Ir=function(e){function n(t,n){var i=n.sdkState,r=n.dispatcher,s=n.logger,o=e.call(this)||this;return o.lastActive=0,o._iid=t,o._sdkState=i,o._dispatcher=r,o._logger=s,o}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===Tr.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return Tr.CONNECTING;case 1:return Tr.OPEN}return Tr.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ws",{get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._handleMessage=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 i=new Fe(n.payload);i.expiresIn>=0&&t._dispatcher.dispatch(i)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e,t){return void 0===t&&(t=""),r(this,void 0,void 0,(function(){var n=this;return s(this,(function(i){return this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return r(n,void 0,void 0,(function(){var t,n,i,o,a,c,u,l=this;return s(this,(function(h){switch(h.label){case 0:return(null===(u=this._sdkState.websocket)||void 0===u?void 0:u.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return r(l,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,Cr(t.result)];case 1:return e=i.sent(),this._handleMessage(e),[3,3];case 2:return n=i.sent(),this.error(n),[3,3];case 3:return[2]}}))}))},[3,12]):[3,1]:[3,13];case 1:if(!(e.data instanceof ArrayBuffer))return[3,6];h.label=2;case 2:return h.trys.push([2,4,,5]),[4,Cr(new Uint8Array(e.data))];case 3:return a=h.sent(),this._handleMessage(a),[3,5];case 4:return n=h.sent(),this.error(n),[3,5];case 5:return[3,12];case 6:if(!("undefined"!=typeof Buffer&&e.data instanceof Buffer))return[3,11];h.label=7;case 7:return h.trys.push([7,9,,10]),i=e.data,o=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),[4,Cr(o)];case 8:return a=h.sent(),this._handleMessage(a),[3,10];case 9:return c=h.sent(),this.error(c),[3,10];case 10:return[3,12];case 11:"string"==typeof e.data&&this._handleMessage(e.data),h.label=12;case 12:return[3,14];case 13:this._handleMessage(e.data),h.label=14;case 14:return[2]}}))}))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",v.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now(),[2]}))}))},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws?(e._ws.onopen=ot,e._ws.onmessage=ot,e._ws.onerror=ot,e.connectionState!==Tr.CLOSED?(e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=void 0):t()):t()}))},n.prototype.send=function(e){if(!this._ws)throw v.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}(te),Or=function(e){function n(t){var n=t.all,i=t.feed,r=t.custom_types,s=t.ts,o=e.call(this)||this;return o.all=n,o.feed=i,o.customTypes=r,o.ts=s,o}return t(n,e),n}(ie),kr=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=r,this._logger=s,this.apiClient=new st(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:a}),this.websocketClient=new Ir(e,{sdkState:i,dispatcher:r,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new Or(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 v({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(v.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r=this;return s(this,(function(s){if(!this._sdkState.websocket)throw v.connectionRequired;if(t=new tt,e.ackRequired){i=function(i,s){r._ackStateMap.has(e.requestId)&&(r._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),i?(r._logger.debug("fail websocket request",e.requestId,i),t.reject(i)):(r._logger.debug("receive websocket ack",e.requestId,e),r._logger.debug("receive websocket ack",s),t.resolve(s)))};try{n=setTimeout((function(){return i(v.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return i(void 0,e)},reject:function(e){return i(e)}}),this.websocketClient.send(e)}catch(e){i(e)}}else try{this.websocketClient.send(e),t.resolve()}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return e instanceof Ue?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof He?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw v.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"}(Ar||(Ar={}));var Dr,Rr,Lr=function(e){function n(t){var n=t.stateType,i=e.call(this)||this;return i.stateType=n,i}return t(n,e),n}(ie),xr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Ur=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Pr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Mr=function(){function e(e){var t,n,i,r;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(n=e.feed_channels)&&void 0!==n?n:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(r=e.settings_updated_at)&&void 0!==r?r:0}return e.payloadify=function(e){return re(se({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))},e}(),Fr=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},qr=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 re(se({last_updated_at:e.lastUpdatedAt}))},e}(),Hr=function(){function e(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}return e.payloadify=function(e){return re(se({template_list_token:e.token}))},e}(),Vr=function(){function e(e){void 0===e&&(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}),this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}return e.payloadify=function(e){return re(se({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))},e}(),zr=function(){function e(e){void 0===e&&(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}),this.default=new Vr(e.default),this.realTime=new Vr(e.realtime)}return e.payloadify=function(e){return re(se({default:Vr.payloadify(e.default),realtime:Vr.payloadify(e.realTime)}))},e}(),Gr=1048576,jr=5;!function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Dr||(Dr={})),function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Rr||(Rr={}));var Kr=function(){function e(e){var t,n,i,r,s,o,a;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Gr: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!==(i=e.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(r=e.allow_sdk_log_ingestion)||void 0===r||r,this.unreadCountThreadingPolicy=null!==(s=e.unread_cnt_threading_policy)&&void 0!==s?s:Dr.NONE,this.lastMessageThreadingPolicy=null!==(o=e.last_msg_threading_policy)&&void 0!==o?o:Rr.NONE,this.uikitConfigInfo=new qr(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new Mr(e.notifications):null,this.messageTemplateInfo=e.message_template?new Hr(e.message_template):null,this.statConfigInfo=e.log_publish_config?new zr(e.log_publish_config):new zr}return e.payloadify=function(e){return re(se({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Gr,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?qr.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Mr.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Hr.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?zr.payloadify(e.statConfigInfo):null}))},e}(),Br=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return{}},e}(),Qr=function(e){function n(t){var n=t.userId,i=t.metadata,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(ce,"/").concat(n,"/metadata"),r.params={metadata:i},r}return t(n,e),n}(Ue),Wr=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metaData=n,i}return t(n,e),n}(Pe),Zr=function(e){function n(t){var n=t.userId,i=t.metadata,r=t.upsert,s=e.call(this)||this;return s.method=oe.PUT,s.path="".concat(ce,"/").concat(n,"/metadata"),s.params={metadata:i,upsert:r},s}return t(n,e),n}(Ue),Yr=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metadata=n,i}return t(n,e),n}(Pe),Xr=function(e){function n(t){var n=t.userId,i=t.metadataKey,r=e.call(this)||this;return r.method=oe.DELETE,r.path="".concat(ce,"/").concat(n,"/metadata/").concat(i),r}return t(n,e),n}(Ue);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Pe);var Jr=function(e){function n(t){var n=t.userId,i=e.call(this)||this;return i.method=oe.DELETE,i.path="".concat(ce,"/").concat(n,"/metadata"),i}return t(n,e),n}(Ue);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Pe);var $r,es=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},ts=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ns=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"}($r||($r={}));var is,rs=function(e){function i(t,n){var i,r,s,o,u,l,h,d,_,f,p,E,g=this;return(g=e.call(this,t)||this).userId=null!==(r=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==r?r:"",g.nickname=null!==(o=null!==(s=n.nickname)&&void 0!==s?s:n.name)&&void 0!==o?o:"",g.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",g.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,g.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},g.connectionStatus=$r.NON_AVAILABLE,S($r,n.is_online)?g.connectionStatus=n.is_online:w("boolean",n.is_online)&&(g.connectionStatus=n.is_online?$r.ONLINE:$r.OFFLINE),g.isActive=null===(_=n.is_active)||void 0===_||_,g.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,g.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,g.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,g.friendName=null!==(E=n.friend_name)&&void 0!==E?E:null,g}return t(i,e),i.payloadify=function(t){return re(se(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(i.prototype,"profileUrl",{get:function(){var e=eo.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),i.prototype.serialize=function(){return es(this)},i.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)}))},i.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(i){t?delete n.metaData[i]:n.metaData[i]=e[i]}))},i.prototype.createMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return ns(this._isValidMetaData(e)).throw(v.invalidParameters),t=eo.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Qr({userId:n.userId,metadata:e}),[4,i.send(r)];case 1:return o=s.sent(),a=o.as(Wr).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},i.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n,i,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:return ns(this._isValidMetaData(e)).throw(v.invalidParameters),n=eo.of(this._iid),i=n.sdkState,r=n.requestQueue,o=new Zr({userId:i.userId,metadata:e,upsert:t}),[4,r.send(o)];case 1:return a=s.sent(),c=a.as(Yr).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},i.prototype.deleteMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return ns(w("string",e)).throw(v.invalidParameters),t=eo.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Xr({userId:n.userId,metadataKey:e}),[4,i.send(r)];case 1:return s.sent(),this._applyMetaData(((o={})[e]=!0,o),!0),[2,this.metaData]}}))}))},i.prototype.deleteAllMetaData=function(){return r(this,void 0,void 0,(function(){var e,t,n,i;return s(this,(function(r){switch(r.label){case 0:return e=eo.of(this._iid),t=e.sdkState,n=e.requestQueue,i=new Jr({userId:t.userId}),[4,n.send(i)];case 1:return r.sent(),this.metaData={},[2]}}))}))},i}(Br),ss=function(e){function n(t){var n=t.userProfile,i=e.call(this)||this;return i.userProfile=n,i}return t(n,e),n}(ie),os=function(){function e(e,t){var n,i,r,s,o,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new Kr(t),this.user=new rs(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=t.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(r=t.pong_timeout)&&void 0!==r?r:5e3,this.reconnectInterval=null!==(o=null===(s=t.reconnect)||void 0===s?void 0:s.interval)&&void 0!==o?o: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 re(se(n(n(n({},rs.payloadify(e.user)),Kr.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,i=eo.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:function(i){return i>0?1e3*Math.min(e*Math.pow(n,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 ss({userProfile:this}))},e}(),as=function(e){function i(t){var i=t.request,r=void 0===i||i,s=t.features,o=void 0===s?{}:s,a=t.options,c=void 0===a?{}:a,u=t.statConfigInfo,l=e.call(this)||this;return l.request=r,l.features=n({localCache:!0,notification:!0},o),l.options=n({ingestion:!0},c),l.statConfigInfo=u,l}return t(i,e),i}(ie),cs=function(e){function i(t,n,i){var r,s,o,a,c=this;return(c=e.call(this,t,n,i)||this).error=null,c.services=[],c.userProfile=new os(t,i),c.deviceTokenLastDeletedAt=null!==(r=i.device_token_last_deleted_at)&&void 0!==r?r:0,c.key=null!==(s=i.key)&&void 0!==s?s:"",c.ekey=null!==(o=i.ekey)&&void 0!==o?o:"",c.error=i.error?new v(i):null,c.services=null!==(a=i.services)&&void 0!==a?a:[],c}return t(i,e),i.asError=function(e){return new i("","LOGI",n({user_id:"",error:!0},e))},i.prototype.applyTo=function(e){return r(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(r){switch(r.label){case 0:return this.error?[3,4]:(t=eo.of(e))?(n=t.sessionManager,i=t.dispatcher,[4,n.login(this)]):[3,2];case 1:return r.sent(),this.userProfile.apply(),i.dispatch(new as({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),[3,3];case 2:throw v.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},i}(qe),us=function(){function e(){this.type=Ar.NONE,this.name="none"}return e.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,t.cause,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e}(),ls=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e()];case 1:return n.sent(),[3,3];case 2:if(!((t=n.sent())instanceof v))throw t;return t.throwOutside(),[3,3];case 3:return[2]}}))}))},hs=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e()];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},ds=function(e){function n(t){void 0===t&&(t={});var n,i=this;return(i=e.call(this)||this).type=Ar.LOGOUT,i.name="logout",i._wasPreviouslyConnected=null===(n=t.wasPreviouslyConnected)||void 0===n||n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(o){switch(o.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return o.sent(),[4,e.changeState(new Ts,t)];case 2:return o.sent(),this._wasPreviouslyConnected&&ls((function(){return r(i,void 0,void 0,(function(){return s(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(us),_s=function(e){function n(){var t=e.call(this)||this;return t.type=Ar.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new ys({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new vs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ds,t)];case 1:return n.sent(),[2]}}))}))},n}(us),fs=function(e){function n(t){var n=t.autoReconnect,i=e.call(this)||this;return i.type=Ar.INTERNAL_DISCONNECTED,i.name="internaldisconnected",i._autoReconnect=!1,i._autoReconnect=n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new vs,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new ys({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new vs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new _s,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ds,t)];case 1:return n.sent(),[2]}}))}))},n}(us),ps=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},Es=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),gs=function(e,t,n){return void 0===n&&(n=new Es),r(void 0,void 0,void 0,(function(){var i,r,o,a,c,u;return s(this,(function(s){switch(s.label){case 0:i=0,r=null,o=function(e){return r=null!=e?e:new Error("Halted")},a=function(){i=0},s.label=1;case 1:if(!(-1===t||i=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Lr({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 r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return n.sent(),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.session.authToken=void 0,t.error.isSessionExpiredError||t.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Fe({reason:t.error.code,message:t.error.message})):this._logger.warn("login failed: ".concat(t.error)),this._rejectConnectionRequest(t.error),n.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(){var e,t=this.sdkState,n=t.appId,i=t.appVersion,r=t.userId,s=t.extensions,o=t.sendbirdRuntimeEnvironment,a=this.cacheContext.localCacheEnabled,c=this._sessionManager.session,u=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=s?s:{}).sb_uikit,d=et.userAgentWithExtension(s);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(n).concat(i?"&av=".concat(i):"").concat(c.hasSession?"":"&user_id=".concat(encodeURIComponent(r)),"&pmce=").concat(u?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent(et.sendbirdSdkUserAgentWithExtension(o)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(As))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(a?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")},n.prototype._statLogConnection=function(e){var t;this._dispatcher.dispatch(new Ke(new Ye({type:xe.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:this._connectedAt>0?this._connectedAt-this._connectingAt:0,logi_latency:this._logiReceivedAt>0?this._logiReceivedAt-this._connectedAt:void 0,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=""),r(this,void 0,void 0,(function(){var n,i,r,o=this;return s(this,(function(s){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(v.connectionCanceled)),n=new tt,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout((function(){o._loginTimer=void 0,o._rejectConnectionRequest(v.loginTimeout)}),null===(t=this.sdkState.websocket)||void 0===t?void 0:t.responseTimeout),i=this._sessionManager.session,e&&(i.authToken=e,i.sessionKey=void 0),r=this._url(),i.sessionKey||i.authToken?this._websocketClient.connect(r,JSON.stringify(i.hasSession?{auth:i.sessionKey}:{token:i.authToken})):this._websocketClient.connect(r,JSON.stringify({}))),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(cs.asError(v.connectionRenew))},n.prototype.disconnect=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,[4,this.disconnect()];case 1:return e.sent(),[4,this._sessionManager.clear()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)},n}(te),Os=function(e){function n(t){var n=t.appId,i=t.userId,r=t.includeUIKitConfig,s=void 0!==r&&r,o=t.localCacheEnabled,a=void 0===o||o,c=t.expiringSession,u=void 0===c||c,l=e.call(this)||this;return l.path="".concat(ue,"/").concat(i,"/authentication"),l.method=oe.POST,l.params=re({expiring_session:!!u,include_logi:!0,include_extra_data:String(As),uikit_config:s,use_local_cache:a,app_id:n}),l.requireAuth=!1,l}return t(n,e),n}(Ue),ks=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.logi=new cs(t,"LOGI",n),i}return t(n,e),n}(Pe);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(Ss||(Ss={}));var Ds,Rs,Ls=[Ve,Os],xs=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,a=t.useFetchCompat,c=void 0!==a&&a,u=this;this._currentConnectionStateType=Ar.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new kr(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:c}),this._session=n,this._logger=s,this._dispatcher=r,this._dispatcher.on((function(e){var t,n,i;if(e instanceof Lr){var r=e.stateType;switch(u._currentConnectionStateType=r,r){case Ar.CONNECTED:u._resolveLazyCallQueue();break;case Ar.INITIALIZED:case Ar.INTERNAL_DISCONNECTED:case Ar.EXTERNAL_DISCONNECTED:case Ar.LOGOUT:u._rejectLazyCallQueue((null===(i=u._session)||void 0===i?void 0:i.hasSession)?v.connectionClosed:v.connectionRequired)}}else if(e instanceof xr)u._session.hasChatServicePermission||u._resolveLazyCallQueue(Ss.API);else if(e instanceof Ur||e instanceof Pr)u._rejectLazyCallQueue(v.connectionClosed);else if(e instanceof Be){var s=e.request,a=e.deferred,c=e.error;try{for(var l=o(Ls),h=l.next();!h.done;h=l.next()){if(s instanceof h.value)return void a.reject(c)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}u._lazyCallQueue.push({command:s,deferred:a})}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===Ar.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Ar.CONNECTING||this._currentConnectionStateType===Ar.RECONNECTING||this._session.isRefreshing},enumerable:!1,configurable:!0}),e.prototype._classifyLazyCallQueueByScope=function(e){var t,n=[],i=[];switch(e){case Ss.ALL:t=null;break;case Ss.WEBSOCKET:t=He;break;case Ss.API:t=Ue}var r=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(r=!0),r?i.push(e):n.push(e)})),[n,i]},e.prototype._resolveLazyCallQueue=function(e){var t=this;void 0===e&&(e=Ss.ALL);var n=a(this._classifyLazyCallQueueByScope(e),2),i=n[0],o=n[1];this._lazyCallQueue=o,i.forEach((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:t=e.command,n=e.deferred,(i=e.timeout)&&clearTimeout(i),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.send(t)];case 2:return r=s.sent(),n.resolve(r),[3,4];case 3:return o=s.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}))},e.prototype._rejectLazyCallQueue=function(e,t){var n=this;void 0===t&&(t=Ss.ALL);var i=a(this._classifyLazyCallQueueByScope(t),2),o=i[0],c=i[1];this._lazyCallQueue=c,o.forEach((function(t){return r(n,void 0,void 0,(function(){var n,i;return s(this,(function(r){return n=t.deferred,i=t.timeout,clearTimeout(i),n.reject(e),[2]}))}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(r){switch(r.label){case 0:return e instanceof He?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:case 7:return[2,r.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new tt,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),v.connectionRequired;case 3:case 9:return[3,11];case 4:return e instanceof Ue?this._session.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,10];case 6:return e.hasSessionKey?(this._logger.debug("send api request with tmp session key",e),[4,this.commandRouter.send(e)]):[3,8];case 8:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new tt,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=v.connectionRequired,this._logger.debug("fail api request",n),n;case 10:throw v.invalidCommand;case 11:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),e instanceof He||e instanceof Ue?[4,this.commandRouter.send(e)]:[3,2];case 1:return[2,t.sent()];case 2:throw v.invalidCommand}}))}))},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(v.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}(),Us="sendbird@devicetokens",Ps=function(){function e(e){var t=e.type,n=e.token,i=e.device_os,r=e.device_manufacturer,s=e.system_push_enabled;this.type=t,this.token=n,this.deviceOS=i,this.deviceManufacturer=r,this.systemPushEnabled=s}return e.payloadify=function(e){return re(se({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))},e}(),Ms=new WeakMap,Fs=function(e){function n(t){var n=t._iid,i=t.session,r=t.cacheContext,s=t.sdkState,o=t.dispatcher,a=t.requestQueue,c=t.logger,u=t.pushNotificationAckManager,l=e.call(this)||this;return l._currentConnectionStateType=Ar.INITIALIZED,l._isRefreshingAuthToken=!1,l.currentUser=null,l.session=i,l._iid=n,l._cacheContext=r,l._sdkState=s,l._dispatcher=o,l._requestQueue=a,l._logger=c,l._pushNotificationAckManager=u,l._deviceTokens=[],l._dispatcher.on((function(e){var t,n,i;if(e instanceof Lr){var r=e.stateType;l._currentConnectionStateType=r}else if(e instanceof Fe&&l.handler&&!l.isSessionKeyRefreshing){if(l._currentConnectionStateType===Ar.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?l.close():((null===(n=e.error)||void 0===n?void 0:n.isSessionTokenExpiredError)&&l.refreshAuthToken().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(l._logger.debug("session expired"),l.handler.onSessionExpired&&l.handler.onSessionExpired(),l.refreshSessionKey().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e}))))}})),l}return t(n,e),Object.defineProperty(n.prototype,"ekey",{get:function(){return Ms.get(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokens",{get:function(){return this._deviceTokens},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokenLastDeletedAt",{get:function(){return this._deviceTokenLastDeletedAt},enumerable:!1,configurable:!0}),n.prototype.indexOfDeviceToken=function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))},n.prototype.hasDeviceToken=function(e,t){return this.indexOfDeviceToken(e,t)>=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return new ze({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=s.sent(),i=n.as(je),r=i.newKey,o=i.error)throw o;return this.session.sessionKey=null!=r?r:this.session.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(i){switch(i.label){case 0:return t=new Ve({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),[4,gs((function(e){return r(n,void 0,void 0,(function(){var n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=s.sent(),i=n.as(Ge),r=i.key,o=i.services,this.session.sessionKey=r,this.session.services=o,[3,3];case 2:if(a=s.sent(),!this._isSessionRelatedError(a))throw a;return e(a),[3,3];case 3:return[2]}}))}))}),3)];case 1:return i.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:if(this._currentConnectionStateType!==Ar.CONNECTED)return[3,8];r.label=1;case 1:return r.trys.push([1,3,,8]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return r.sent(),this.complete(),[2];case 3:n=r.sent(),r.label=4;case 4:return r.trys.push([4,6,,7]),[4,this._handleSessionRefreshError(n,t)];case 5:return r.sent(),[2];case 6:return r.sent(),[3,7];case 7:return[3,8];case 8:return r.trys.push([8,10,,12]),[4,this._refreshSessionKeyByApi(e)];case 9:return r.sent(),this.complete(),[3,12];case 10:return i=r.sent(),[4,this._handleSessionRefreshError(i,t)];case 11:return r.sent(),[3,12];case 12:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e,t=this,n=new tt;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var i=null,o=function(){i&&(clearTimeout(i),i=null)},a=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},c=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};i=setTimeout((function(){return c()}),1e3*this._sdkState.sessionTokenRefreshTimeout),ls((function(){return r(t,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(a,c),[2]}))}))}))}else n.resolve(null);return n.promise},n.prototype._handleSessionRefreshError=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return e instanceof v&&(e.isSessionTokenExpiredError||e.code===u.APPLICATION_NOT_FOUND)?(this.session.authToken=void 0,t?[4,this._receiveNewAuthToken()]:[3,6]):[3,6];case 1:return(n=i.sent())?(this.session.authToken=n,[4,this._refreshSessionKey(this.session.authToken,!1)]):[3,3];case 2:return i.sent(),[3,5];case 3:return[4,this.clear()];case 4:i.sent(),i.label=5;case 5:return[2];case 6:throw e}}))}))},n.prototype._isSessionRelatedError=function(e){return e instanceof v&&(e.isSessionExpiredError||e.isSessionInvalidatedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this.session.isRefreshing},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isSessionExpiring",{get:function(){return!!this.handler},enumerable:!1,configurable:!0}),n.prototype.authenticate=function(e,t){var n;return r(this,void 0,void 0,(function(){var i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.session.authToken=t,i=new Os({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!t||this.isSessionExpiring}),[4,this._requestQueue.commandRouter.send(i)];case 1:return r=s.sent(),(o=r.as(ks).logi).error?[3,4]:this.session.hasChatServicePermission?[3,3]:[4,o.applyTo(this._iid)];case 2:s.sent(),s.label=3;case 3:return[3,5];case 4:throw o.error;case 5:return[2]}}))}))},n.prototype.login=function(e){var t;return r(this,void 0,void 0,(function(){var n,i,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return n=e.key,i=e.ekey,r=e.services,o=e.userProfile,a=e.deviceTokenLastDeletedAt,c=void 0===a?0:a,this.session.sessionKey=n,this.session.services=r,Ms.set(this,i),this._deviceTokenCacheEnabled=null===(t=null==o?void 0:o.appInfo)||void 0===t?void 0:t.deviceTokenCache,u=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,u.get(Us)]:[3,5];case 1:return!(l=s.sent())||l.lastDeletedAt0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])},e.prototype._isDuplicateStat=function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t},e.prototype._save=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=c(c([],a(this.queue),!1),a(this.flushWaitQueue),!1),[4,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((function(e){return Ye.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})];case 1:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save(),[2]}))}))},e}(),Gs=function(e){function n(t){var n,i,r,s,o=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:o,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,i=n.getFullYear(),r=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0"),"".concat(i).concat(r).concat(s)),"_").concat(o),l}return t(n,e),n}(Ye),js=function(e){function n(t){var n=t.deviceId,i=t.statLogs,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(we),r.params={device_id:n,log_entries:i.map((function(e){return Ye.payloadify(e)}))},r}return t(n,e),n}(Ue),Ks=function(e){function n(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(n,e),Object.defineProperty(n.prototype,"_isSendable",{get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),n.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,e.prototype.init.call(this,t+".daily")];case 1:return n.sent(),this.queue=this.logInfo.statLogs.map((function(e){return new Ye({type:e.stat_type,ts:e.ts,data:e.data})})),[2]}}))}))},n.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),t.localCacheStat?(this.enabledState=t.enabledStat?Ds.ENABLED:Ds.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=Ds.DISABLED,[4,this.clear()];case 2:s.sent(),s.label=3;case 3:return this.isEnabled&&this._isSendable?[4,this._getUploadStats()]:[3,9];case 4:n=s.sent(),i=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),r=0,s.label=5;case 5:return r0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new js({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Vs,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=Ds.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ds.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},n}(zs),Bs=function(e){function i(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(i,e),i.prototype._isSendable=function(e){if(void 0===e&&(e=!1),this.queue.length0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new js({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Vs,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=Ds.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ds.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},i}(zs),Qs=function(e){function n(t){var n=t.deviceId,i=t.statLogs,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(Se),r.params={device_id:n,log_entries:i.map((function(e){return Ye.payloadify(e)}))},r}return t(n,e),n}(Ue),Ws=function(e){function i(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(i,e),Object.defineProperty(i.prototype,"_isSendable",{get:function(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),i.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,e.prototype.init.call(this,t+".realtime")];case 1:return i.sent(),this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Ye({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}})),[2]}}))}))},i.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.statConfig=e,this._mergeQueue(),t.notificationStat?(this.enabledState=t.enabledStat?Ds.ENABLED:Ds.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=Ds.DISABLED,[4,this.clear()];case 2:i.sent(),i.label=3;case 3:return this.isEnabled&&this._isSendable?(n=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),[4,ps(n)]):[3,6];case 4:return i.sent(),[4,this._flush(this.queue)];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},i.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.enabledState===Ds.DISABLED?[2,!0]:(t=this.enabledState===Ds.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,this._isDuplicateStat(e)?[2,!0]:(t.push(e),this.enabledState===Ds.PENDING?[3,2]:[4,this._save()]));case 1:n.sent(),n.label=2;case 2:return this.isEnabled?(this._mergeQueue(),this.isEnabled&&this._isSendable?[4,this._flush(t)]:[3,4]):[3,4];case 3:return[2,n.sent()];case 4:return[2,!0]}}))}))},i.prototype._flush=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r;return s(this,(function(s){switch(s.label){case 0:if(t=!0,!(e.length>0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Qs({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Vs,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=Ds.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ds.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},i}(zs),Zs=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,i=e.dispatcher,r=e.logger;this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=$(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=i,this.logger=r,this._dailyStatCollector=new Ks({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Bs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new Ws({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}return e.prototype._migration=function(){return r(this,void 0,void 0,(function(){var e,t,i,r;return s(this,(function(s){switch(s.label){case 0:return[4,this.cacheContext.preference.get(this.key)];case 1:return(e=s.sent())?(t=[],e.statLogs.forEach((function(e){e.stat_type===xe.FEATURE_LOCALCACHE&&t.push(new Ye({type:e.stat_type,ts:e.ts,data:e.data}))})),[4,this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((function(e){return Ye.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})]):[3,6];case 2:return s.sent(),i=[],e.statLogs.forEach((function(e){e.stat_type!==xe.FEATURE_LOCALCACHE&&e.stat_type!==xe.NOTIFICATION&&(e.stat_type===xe.FEATURE_LOCALCACHE_EVENT&&(e.data=n({message_init_policy:"",starting_point:0},e.data)),i.push(new Ye({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:i.map((function(e){return Ye.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 3:return s.sent(),r=[],e.statLogs.forEach((function(e){var t;e.stat_type===xe.NOTIFICATION&&(e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),r.push(new Ye({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:r.map((function(e){return Ye.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 4:return s.sent(),[4,this.cacheContext.preference.remove(this.key)];case 5:s.sent(),s.label=6;case 6:return[2]}}))}))},e.prototype.init=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.key=e,[4,this._migration()];case 1:return n.sent(),[4,this._dailyStatCollector.init(this.key)];case 2:return n.sent(),[4,this._defaultStatCollector.init(this.key)];case 3:return n.sent(),[4,this._notificationStatCollector.init(this.key)];case 4:return n.sent(),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){return e instanceof Ke?(t=e.statLog,this.put(t)):e instanceof as&&(n=e.request,i=e.features,r=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=n,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._notificationStatCollector.setConfig(null!==(a=this._statConfig.realTime)&&void 0!==a?a:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:r.ingestion})),[2]}))}))}))),[2]}}))}))},e.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=!0,e instanceof Gs?this._collectFeatureLocalCacheStat?[4,this._dailyStatCollector.put(e)]:[3,2]:[3,3];case 1:t=n.sent(),n.label=2;case 2:return[3,13];case 3:switch(e.type){case xe.API_RESULT:case xe.WEBSOCKET_CONNECT:return[3,4];case xe.FEATURE_LOCALCACHE:case xe.FEATURE_LOCALCACHE_EVENT:return[3,7];case xe.NOTIFICATION:return[3,10]}return[3,13];case 4:return this._collectRequestStat?[4,this._defaultStatCollector.put(e)]:[3,6];case 5:t=n.sent(),n.label=6;case 6:return[3,13];case 7:return this._collectFeatureLocalCacheStat?[4,this._defaultStatCollector.put(e)]:[3,9];case 8:t=n.sent(),n.label=9;case 9:return[3,13];case 10:return this._collectionNotificationStat?[4,this._notificationStatCollector.put(e)]:[3,12];case 11:t=n.sent(),n.label=12;case 12:return[3,13];case 13:return t?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Ds.COLLECT_ONLY,this._defaultStatCollector.enabledState=Ds.COLLECT_ONLY,this._notificationStatCollector.enabledState=Ds.COLLECT_ONLY,this.logger.debug(v.statLogUploadLimitExceededError))),[2]}}))}))},e.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)},e}(),Ys=function(){function e(e){var t=e.limit,n=void 0===t?5:t;this.workersByKey={},this.limit=n}return e.prototype.run=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.workersByKey[e]||(this.workersByKey[e]=[]),this.workersByKey[e].length0})).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},i.payloadify=function(t){return re(se(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 go.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})))},i.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[i];r>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=r)}})),i.req_id&&i.voted_option_ids&&(this.votedPollOptionIds=i.voted_option_ids),"number"==typeof i.voter_count&&(this.voterCount=i.voter_count),!0},i.prototype.serialize=function(){return es(this)},i}(Br),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,i,r){var s=e.call(this,t,r)||this;return s.channelUrl=n,s.channelType=i,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(q,this.channelType)},n}(bo),yo=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},wo=function(e){function n(t){var n=t.title,i=t.optionTexts,r=t.data,s=t.allowUserSuggestion,o=t.allowMultipleVotes,a=t.closeAt,c=e.call(this)||this;return c.method=oe.POST,c.path=be,c.params={title:n,options:i,data:r,allow_user_suggestion:s,allow_multiple_votes:o,close_at:a},c}return t(n,e),n}(Ue),So=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new vo(t,n),i}return t(n,e),n}(Pe),To=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=e.call(this)||this;return s.method=oe.GET,s.path="".concat(be,"/").concat(encodeURIComponent(r)),s.params={channel_url:n,channel_type:i},s}return t(n,e),n}(Ue),No=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new vo(t,n),i}return t(n,e),n}(Pe),Co=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s)),o.params={channel_url:n,channel_type:i},o}return t(n,e),n}(Ue),Ao=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.pollOption=new go(t,n),i}return t(n,e),n}(Pe),Io=function(e){function n(t){var n=t.channelType,i=t.channelUrl,r=t.timestamp,s=t.token,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(Oe(n),"/").concat(encodeURIComponent(i),"/polls/changelogs"),o.params=re({change_ts:r,token:s}),o}return t(n,e),n}(Ue),Oo=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.updatedPolls=n.updated.map((function(e){return function(e,t){return new vo(e,t)}(t,e)})),i.deletedPollIds=n.deleted.map((function(e){return e})),i.hasMore=n.has_more,i.nextToken=n.next,i}return t(n,e),n}(Pe),ko={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Do=function(e){return w("string",e.title)&&(t=e.optionTexts,N("string",t)&&t.every((function(e){return""!==e.trim()})))&&Eo(e.data)&&w("boolean",e.allowUserSuggestion,!0)&&w("boolean",e.allowMultipleVotes,!0)&&w("number",e.closeAt,!0);var t},Ro={channelUrl:"",channelType:q.BASE,pollId:0,pollOptionId:0},Lo=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)&&e.pollId>0&&w("number",e.pollOptionId)&&e.pollOptionId>0},xo={channelUrl:"",channelType:q.BASE,pollId:0},Uo=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)},Po={},Mo=function(){function e(e,t){var n=t.sdkState,i=t.dispatcher,r=t.sessionManager,s=t.requestQueue,o=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=r,this._requestQueue=s,this._dispatcher=i,this._logger=o,Po[e]=this}return e.of=function(e){return Po[e]},e.prototype.buildPollFromSerializedData=function(e){var t=ts(e);return new vo(this._iid,vo.payloadify(t))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return ns(Uo(e)).throw(v.invalidParameters),t=new To(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(No).poll]}}))}))},e.prototype.create=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return ns(Do(e)).throw(v.invalidParameters),t=new wo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(So).poll]}}))}))},e.prototype.getOption=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return ns(Lo(e)).throw(v.invalidParameters),t=new Co(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(Ao).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,i){return void 0===i&&(i=Xs.SYNC_POLL_CHANGELOGS),r(this,void 0,void 0,(function(){var r,o,a,c,u,l,h;return s(this,(function(s){switch(s.label){case 0:return r=new Io(se({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(r)];case 1:return o=s.sent(),a=o.as(Oo),c=a.updatedPolls,u=a.deletedPollIds,l=a.hasMore,h=a.nextToken,c.length>0&&this._dispatcher.dispatch(new lo({polls:c,source:i})),[2,{updatedPolls:c,deletedPollIds:u,hasMore:l,token:h}]}}))}))},e}(),Fo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.token,s=t.limit,o=e.call(this)||this;return o.method=oe.GET,o.path=be,o.params={channel_url:n,channel_type:i,token:r,limit:s},o}return t(n,e),n}(Ue),qo=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).polls=(null!==(i=n.polls)&&void 0!==i?i:[]).map((function(e){return new vo(t,e)})),r.token=n.next,r}return t(n,e),n}(Pe),Ho=function(e){function i(t,n){return e.call(this,t,n.channelUrl,n.channelType,n)||this}return t(i,e),i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=eo.of(this._iid).requestQueue,t=new Fo(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(qo),o=r.polls,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(mo),Vo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=t.token,a=t.limit,c=e.call(this)||this;return c.method=oe.GET,c.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s),"/voters"),c.params={channel_url:n,channel_type:i,token:o,limit:a},c}return t(n,e),n}(Ue),zo=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).voters=(null!==(i=n.voters)&&void 0!==i?i:[]).map((function(e){return new rs(t,e)})),r.token=n.next,r}return t(n,e),n}(Pe),Go=function(e){function i(t,n){var i=e.call(this,t,n.channelUrl,n.channelType,n)||this;return i.pollId=n.pollId,i.pollOptionId=n.pollOptionId,i}return t(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&w("number",this.pollId)&&w("number",this.pollOptionId)},i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=eo.of(this._iid).requestQueue,t=new Vo(n(n({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(zo),o=r.voters,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(mo);export{_ as $,oe as A,hs as B,q as C,Lr as D,te as E,Ar as F,ls as G,Or as H,ss as I,os as J,Fr as K,F as L,Fe as M,$e as N,g as O,f as P,N as Q,P as R,R as S,d as T,rs as U,eo as V,qe as W,S as X,Ze as Y,Hs as Z,r as _,w as a,Z as a$,p as a0,Kr as a1,Xs as a2,M as a3,E as a4,Rr as a5,Mr as a6,H as a7,u as a8,qr as a9,ot as aA,mo as aB,ke as aC,Ee as aD,Re as aE,j as aF,Eo as aG,be as aH,yo as aI,jr as aJ,I as aK,it as aL,_o as aM,Mo as aN,bo as aO,L as aP,i as aQ,ao as aR,co as aS,ho as aT,lo as aU,uo as aV,oo as aW,Ce as aX,X as aY,pe as aZ,to as a_,Dr as aa,$r as ab,Qe as ac,We as ad,le as ae,Br as af,y as ag,z as ah,es as ai,K as aj,He as ak,Oe as al,Ie as am,so as an,W as ao,A as ap,G as aq,vo as ar,Y as as,Q as at,De as au,nt as av,ps as aw,tt as ax,B as ay,he as az,s as b,ko as b0,Do as b1,xo as b2,Uo as b3,Ro as b4,Lo as b5,go as b6,no as b7,ie as b8,Ye as b9,xe as ba,Gs as bb,me as bc,io as bd,V as be,k as bf,de as bg,C as bh,rt as bi,fo as bj,ro as bk,gs as bl,po as bm,fe as bn,_e as bo,Te as bp,Ne as bq,Ve as br,Be as bs,t as c,ce as d,re as e,Ue as f,n as g,Pe as h,O as i,ve as j,ge as k,ye as l,Ae as m,$ as n,Xe as o,c as p,a as q,Tr as r,v as s,o as t,se as u,l as v,ns as w,Ho as x,Go as y,ts as z}; diff --git a/lib/__bundle-cc71b396.js b/lib/__bundle-cc71b396.js deleted file mode 100644 index 98b2398..0000000 --- a/lib/__bundle-cc71b396.js +++ /dev/null @@ -1 +0,0 @@ -import{c as e,e as t,u as n,g as s,X as r,a7 as a,C as i,U as o,af as u,bf as c,w as l,s as h,p as d,q as _,_ as p,b as f,t as v,Q as m,a as g,i as E,aq as C,a2 as y,b8 as M,B as b,A as N,d as U,f as S,h as T,bg as A,az as I,bc as w,W as L,ak as D,bh as x,ai as R,aO as F,V as P,z as k,O,G as H,a3 as V,be as G,aM as B,aT as q,aS as z,an as j,aR as W,aW as Q,bi as Y,a8 as K,bj as J,E as X,D as Z,F as $,b9 as ee,ba as te,ay as ne,aN as se,al as re,ao as ae,bk as ie,n as oe,aA as ue,bl as ce,bb as le,aB as he,aj as de,aF as _e,a5 as pe,aa as fe,aw as ve,$ as me,aV as ge}from"./__bundle-1db3fd0b.js";import{G as Ee,a as Ce,Q as ye,V as Me,Z as be,t as Ne,u as Ue,_ as Se,$ as Te,a0 as Ae,a1 as Ie,a2 as we,K as Le,v as De,a3 as xe,a4 as Re,a5 as Fe,a6 as Pe,a7 as ke,a8 as Oe,a9 as He,aa as Ve,ab as Ge,ac as Be,ad as qe,ae as ze,af as je,ag as We,ah as Qe,ai as Ye,aj as Ke,ak as Je,T as Xe,al as Ze,am as $e,an as et,ao as tt,ap as nt,aq as st,ar as rt,as as at,at as it,Y as ot,au as ut,av as ct,aw as lt,ax as ht,ay as dt,az as _t,aA as pt,aB as ft,z as vt,aC as mt,aD as gt,aE as Et,aF as Ct,aG as yt,aH as Mt,aI as bt,aJ as Nt,aK as Ut}from"./__bundle-e1a5e3f1.js";import{G as St,g as Tt,D as At,c as It,R as wt,U as Lt,a as Dt,b as xt,A as Rt}from"./__bundle-24f017be.js";import{C as Ft,B as Pt,U as kt,a as Ot,O as Ht,P as Vt,M as Gt,T as Bt,R as qt,b as zt,A as jt}from"./__bundle-e53b9010.js";var Wt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Wt||(Wt={}));var Qt,Yt,Kt,Jt,Xt,Zt,$t,en,tn=function(i){function o(e,t){var n=i.call(this,e,t)||this;return n.state=null,n.role=null,n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,n.state=r(Wt,t.state)?t.state:null,n.role=r(a,t.role)?t.role:null,"boolean"==typeof t.is_muted&&(n.isMuted=t.is_muted),"boolean"==typeof t.is_blocked_by_me&&(n.isBlockedByMe=t.is_blocked_by_me),"boolean"==typeof t.is_blocking_me&&(n.isBlockingMe=t.is_blocking_me),n}return e(o,i),o.payloadify=function(e){return t(n(s(s({},i.payloadify.call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))},o}(Ee),nn=function(t){function n(e,n){var s,r,a=this;return(a=t.call(this,e)||this).channelUrl=null!==(s=n.channel_url)&&void 0!==s?s:"",a.channelType=null!==(r=n.channel_type)&&void 0!==r?r:i.GROUP,a.member=new o(a._iid,n.user),a.deliveryAt=n.ts,a}return e(n,t),n}(u);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Qt||(Qt={})),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"}(Yt||(Yt={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Kt||(Kt={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Jt||(Jt={})),function(e){e.ALL="all",e.UNHIDDEN="unhidden_only",e.HIDDEN="hidden_only",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Xt||(Xt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Zt||(Zt={})),function(e){e.AND="AND",e.OR="OR"}($t||($t={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(en||(en={}));var sn,rn=function(){function e(e){var t,n,s,r,a,i,o,u,c,l,h,d,_,p,f;this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(t=null==e?void 0:e.includeEmpty)&&void 0!==t&&t,this.nicknameContainsFilter=null!==(n=null==e?void 0:e.nicknameContainsFilter)&&void 0!==n?n:null,this.nicknameStartsWithFilter=null!==(s=null==e?void 0:e.nicknameStartsWithFilter)&&void 0!==s?s:null,this.nicknameExactMatchFilter=null!==(r=null==e?void 0:e.nicknameExactMatchFilter)&&void 0!==r?r:null,this.channelNameContainsFilter=null!==(a=null==e?void 0:e.channelNameContainsFilter)&&void 0!==a?a:"",this.myMemberStateFilter=null!==(i=null==e?void 0:e.myMemberStateFilter)&&void 0!==i?i:Yt.ALL,this.customTypesFilter=null!==(o=null==e?void 0:e.customTypesFilter)&&void 0!==o?o:null,this.channelUrlsFilter=null!==(u=null==e?void 0:e.channelUrlsFilter)&&void 0!==u?u:null,this.superChannelFilter=null!==(c=null==e?void 0:e.superChannelFilter)&&void 0!==c?c:Kt.ALL,this.publicChannelFilter=null!==(l=null==e?void 0:e.publicChannelFilter)&&void 0!==l?l:Qt.ALL,this.customTypeStartsWithFilter=null!==(h=null==e?void 0:e.customTypeStartsWithFilter)&&void 0!==h?h:null,this.unreadChannelFilter=null!==(d=null==e?void 0:e.unreadChannelFilter)&&void 0!==d?d:Jt.ALL,this.hiddenChannelFilter=null!==(_=null==e?void 0:e.hiddenChannelFilter)&&void 0!==_?_:Xt.UNHIDDEN,this.includeFrozen=null===(p=null==e?void 0:e.includeFrozen)||void 0===p||p,(null==e?void 0:e.createdAfter)&&(this.createdAfter=e.createdAfter),(null==e?void 0:e.createdBefore)&&(this.createdBefore=e.createdBefore),this.includeMetaData=null===(f=null==e?void 0:e.includeMetaData)||void 0===f||f}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=$t.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 s=JSON.parse(JSON.stringify(this));return Object.keys(s).forEach((function(e){n[e]=s[e]})),n},e.prototype.match=function(e,t){if(this._searchFilter){var n=this._searchFilter,s=n.query,r=n.fields;if(s&&r&&r.length>0&&!r.some((function(t){switch(t){case en.CHANNEL_NAME:return e.name.toLowerCase().includes(s.toLowerCase());case en.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(s.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var a=this._userIdsFilter,i=a.userIds,o=a.includeMode,u=a.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(i.length>0)switch(u){case $t.AND:if(i.some((function(e){return!l.includes(e)})))return!1;break;case $t.OR:if(i.every((function(e){return!l.includes(e)})))return!1}}else{if(i.includes(t)||i.push(t),e.members.length>i.length)return!1;if(!c(i,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var _=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=_})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Yt.ALL:if("none"===e.myMemberState)return!1;break;case Yt.JOINED:if("joined"!==e.myMemberState)return!1;break;case Yt.INVITED:if("invited"!==e.myMemberState)return!1;break;case Yt.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Yt.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Xt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Xt.HIDDEN:if(!e.isHidden)return!1;break;case Xt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Xt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Jt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Qt.PUBLIC:if(!e.isPublic)return!1;break;case Qt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Kt.SUPER:if(!e.isSuper)return!1;break;case Kt.NON_SUPER:if(e.isSuper)return!1}return!(this.createdAfter&&e.createdAtthis.createdBefore)},e}(),an=function(t){function n(e,n){var s=n.sdkState,r=n.cacheContext,a=t.call(this,e)||this;return a._channels=new Map,a._sdkState=s,a._cacheContext=r,a}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return l(!!e).throw(h.databaseError),e.collection(Ce)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return ps.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],_(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case St.CHRONOLOGICAL:if(!a&&n.createdAt>t||a&&n.createdAtt||a&&n.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)s._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});s._update(e),n.push(s)}else a._channels.set(e.url,e),n.push(e)})),!this.localCacheEnabled)return[3,2];for(s=[],r=0;r0?[4,this.upsert(s)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},n.prototype.unblock=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],_(this._channels.keys()),!1)),p(this,void 0,void 0,(function(){var n,s,r,a,i,o,u,c;return f(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),s=v(t),r=s.next(),l.label=2;case 2:return r.done?[3,5]:(a=r.value,[4,this.get(a)]);case 3:(null==(i=l.sent())?void 0:i._updateUnreadMemberState(this._sdkState.userId,e))&&(i._updateUnreadCount(0,0),n.push(i)),l.label=4;case 4:return r=s.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{r&&!r.done&&(c=s.return)&&c.call(s)}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}(u),on={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},un=function(e){return m("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},cn={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},ln=function(e){return m("string",e.customTypes,!0)&&g("boolean",e.includeEmpty,!0)&&g("boolean",e.includeFrozen,!0)&&g("boolean",e.includeMetaData,!0)&&g("boolean",e.includeChatNotification,!0)},hn={myMemberStateFilter:Yt.ALL},dn=function(e){return r(Yt,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"}(sn||(sn={}));var _n={keys:[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT,sn.NONSUPER_UNREAD_MENTION_COUNT,sn.SUPER_UNREAD_MENTION_COUNT,sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,sn.NONSUPER_UNREAD_MESSAGE_COUNT,sn.SUPER_UNREAD_MESSAGE_COUNT,sn.GROUP_CHANNEL_INVITATION_COUNT,sn.NONSUPER_INVITATION_COUNT,sn.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},pn={channelCustomTypesFilter:void 0,superChannelFilter:Kt.ALL},fn=function(e){return m("string",e.channelCustomTypesFilter,!0)&&r(Kt,e.superChannelFilter)},vn={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:C.ALL},mn=s({},y),gn=function(e){return e.startsWith("EVENT_")||e===y.SYNC_CHANNEL_CHANGELOGS||e===y.REFRESH_CHANNEL},En=function(t){function n(e){var n=e.channels,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=e.ts,o=t.call(this)||this;return o.channels=n,o.context=s,o.isWebSocketEventComing=a,o.ts=i,o}return e(n,t),n}(M),Cn=function(t){function n(e){var n=e.channelUrls,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=t.call(this)||this;return i.channelUrls=n,i.context=s,i.isWebSocketEventComing=a,i}return e(n,t),n}(M),yn=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,s=e.unsentMessageCache,r=e.dispatcher,a=this;this._observers=new Map,r.on((function(e){return p(a,void 0,void 0,(function(){var r,a,i,o,u,c,l,h,d,_,m,g,E,C,M,N,U,S,T=this;return f(this,(function(A){switch(A.label){case 0:if(!(e instanceof En))return[3,19];if(r=e.channels,E=e.context,C=e.isWebSocketEventComing,a=r.filter((function(e){return e instanceof ur})),E.source!==y.EVENT_CHANNEL_RESET_HISTORY&&E.source!==y.EVENT_CHANNEL_HIDDEN)return[3,9];A.label=1;case 1:A.trys.push([1,6,7,8]),i=v(a),o=i.next(),A.label=2;case 2:return o.done?[3,5]:(d=o.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 3:A.sent(),A.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return u=A.sent(),M={error:u},[3,8];case 7:try{o&&!o.done&&(N=i.return)&&N.call(i)}finally{if(M)throw M.error}return[7];case 8:return[3,17];case 9:c=t.filterOffsetChanged(a),A.label=10;case 10:A.trys.push([10,15,16,17]),l=v(c),h=l.next(),A.label=11;case 11:return h.done?[3,14]:(d=h.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 12:A.sent(),A.label=13;case 13:return h=l.next(),[3,11];case 14:return[3,17];case 15:return _=A.sent(),U={error:_},[3,17];case 16:try{h&&!h.done&&(S=l.return)&&S.call(l)}finally{if(U)throw U.error}return[7];case 17:return[4,t.upsert(a,e.ts)];case 18:return m=A.sent(),C||this._broadcastUpdateEvent(m,E),[3,24];case 19:return e instanceof Cn?(g=e.channelUrls,E=e.context,C=e.isWebSocketEventComing,[4,t.remove(g)]):[3,22];case 20:return A.sent(),[4,b((function(){return p(T,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=v(g),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(r=t.value,[4,n.removeMessagesOfChannel(r)]);case 2:return u.sent(),[4,s.removeMessagesOfChannel(r)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return a=u.sent(),i={error:a},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(i)throw i.error}return[7];case 8:return[2]}}))}))}))];case 21:return A.sent(),C||this._broadcastRemoveEvent(g,E),[3,24];case 22:return e instanceof At?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,24];case 23:A.sent(),A.label=24;case 24:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onUpdate&&i.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onRemove&&i.onRemove(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}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}(),Mn=function(r){function a(e){var a=e.userId,i=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c,h=r.call(this)||this,d=s(s({},cn),u),_=d.customTypes,p=d.includeEmpty,f=d.includeFrozen;return h.method=N.GET,h.path="".concat(U,"/").concat(encodeURIComponent(a),"/my_group_channels/changelogs"),h.params=t(n({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:_,show_empty:p,show_frozen:f,include_chat_notification:l})),h}return e(a,r),a}(S),bn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedChannels=n.updated.map((function(t){return new ur(e,Object.assign(t,{ts:n.ts}))})),s.deletedChannelUrls=n.deleted,s.hasMore=n.has_more,s.token=n.next,s.ts=n.ts,s}return e(n,t),n}(T),Nn=function(t){function n(e){var n=e.channelUrl,s=e.isInternalCall,r=e.showLatestMessage,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(s?A:I,"/").concat(encodeURIComponent(n)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=r&&r},a}return e(n,t),n}(S),Un=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Sn={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:Yt.ALL,unreadChannelFilter:Jt.ALL,superChannelFilter:Kt.ALL,publicChannelFilter:Qt.ALL,hiddenChannelFilter:Xt.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:$t.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:St.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0},Tn=function(n){function s(e){var s=this,r=e.userId,a=e.token,i=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,_=e.nicknameContainsFilter,p=e.nicknameStartsWithFilter,f=e.nicknameExactMatchFilter,v=e.channelNameContainsFilter,m=e.channelUrlsFilter,g=e.customTypesFilter,E=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,y=e.metadataOrderKeyFilter,M=e.metadataKey,b=e.metadataValues,S=e.metadataValueStartsWith,T=e.includeFrozen,A=e.includeMetaData,I=e.searchFilter,w=e.userIdsFilter,L=e.includeChatNotification,D=void 0!==L&&L,x=e.includeLeftChannel,R=void 0!==x&&x,F=e.createdAfter,P=e.createdBefore;return(s=n.call(this)||this).method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(r),"/my_group_channels"),s.params=t({token:a,limit:i,order:null!=o?o:Sn.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=u?u:Sn.includeEmpty,member_state_filter:null!=c?c:Sn.myMemberStateFilter,super_mode:null!=l?l:Sn.superChannelFilter,public_mode:null!=h?h:Sn.publicChannelFilter,unread_filter:null!=d?d:Sn.unreadChannelFilter,members_nickname_contains:_,members_nickname_startswith:p,members_nickname:f,name_contains:v,channel_urls:m,custom_types:g,custom_type_startswith:E,hidden_mode:C,metadata_order_key:y,metadata_key:M,metadata_values:b,metadata_value_startswith:S,show_frozen:T,show_metadata:A,include_chat_notification:D,include_left_channel:R,created_after:F,created_before:P}),I&&I.query&&I.fields&&(s.params.search_query=I.query,s.params.search_fields=I.fields),w&&w.userIds&&w.userIds.length>0&&(w.includeMode?(s.params.members_include_in=w.userIds,s.params.query_type=w.queryType.toUpperCase()):s.params.members_exactly_in=w.userIds),s}return e(s,n),s}(S),An=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.channels=[];var r=n.next,a=n.channels,i=n.ts;return s.token=r,a&&a.length>0&&(s.channels=a.map((function(t){return t.ts=i,new ur(e,t)}))),s.ts=null!=i?i:0,s}return e(n,t),n}(T),In=function(t){function n(e){var n=e.userId,s=e.filter,r=t.call(this)||this,a=s.myMemberStateFilter;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/group_channel_count"),r.params={state:null!=a?a:Yt.ALL},r}return e(n,t),n}(S),wn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.groupChannelCount=n.group_channel_count,s}return e(n,t),n}(T),Ln=function(n){function s(e){var s=e.userId,r=e.filter,a=n.call(this)||this,i=r.keys,o=r.customTypeFilters,u=r.customTypesFilter;return a.method=N.GET,a.path="".concat(U,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=t({item_keys:i,custom_types:null!=u?u:o}),a}return e(s,n),s}(S),Dn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=n[sn.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=n[sn.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=n[sn.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=n[sn.SUPER_INVITATION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=n[sn.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=n[sn.NONSUPER_INVITATION_COUNT]),s}return e(n,t),n}(T),xn=function(t){function n(e){var n=e.userId,s=t.call(this)||this;return s.method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_channel_count"),s}return e(n,t),n}(S),Rn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s}return e(n,t),n}(T),Fn=function(t){function n(e){var n=e.userId,s=e.filter,r=e.includeFeedChannel,a=void 0!==r&&r,i=t.call(this)||this,o=s.channelCustomTypesFilter,u=s.superChannelFilter;return i.method=N.GET,i.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_message_count"),i.params={super_mode:null!=u?u:Kt.ALL,custom_types:o,include_feed_channel:a},i}return e(n,t),n}(S),Pn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s.unreadFeedCount=n.unread_feed_count,s}return e(n,t),n}(T),kn=function(t){function n(e){var n=e.channelUrl,s=e.scheduledStatus,r=e.messageTypeFilter,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(w,"/count"),a.params={channel_url:n,status:Hn(s)},r&&(a.params.message_type=r),a}return e(n,t),n}(S),On=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.count=n.count,s}return e(n,t),n}(T),Hn=function(e){if(!e)return[];var t=[];return e.forEach((function(e){switch(e){case Me.PENDING:t.push(be.PENDING);break;case Me.SENT:t.push(be.IN_QUEUE),t.push(be.SENT);break;case Me.CANCELED:t.push(be.CANCELED);break;case Me.FAILED:t.push(be.FAILED)}})),t},Vn=function(n){function s(e){var s=this,r=e.userId,a=e.channelUrl,i=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,h=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,E=e.name,C=e.data,y=e.customType,M=e.messageSurvivalSeconds,b=e.invitedUserIds,U=e.operatorUserIds;return(s=n.call(this)||this).method=N.POST,s.path=I,s.params=t({user_ids:d([r],_(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:a,cover_url:i,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:p,is_public:h,is_discoverable:f,strict:v,is_ephemeral:m,access_code:g,name:E,data:C,custom_type:y,operator_ids:U,message_survival_seconds:M}),s}return e(s,n),s}(S),Gn=function(t){function n(e,n){var s,r=this;return(r=t.call(this,e,n)||this).channel=new ur(e,n),r.isCreated=null===(s=n.is_created)||void 0===s||s,r}return e(n,t),n}(T),Bn=function(t){function n(e){var n=e.userId,s=e.channelUrls,r=t.call(this)||this;return r.method=N.PUT,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),r.params={channel_urls:s},r}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var qn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/join"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),zn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u,l=a.users,h=void 0===l?null:l;return r.memberCount=o,r.joinedMemberCount=c,r.members=Array.isArray(h)?h.map((function(t){return new tn(e,t)})):[new tn(e,s.data)],r}return e(n,t),n}(Ft),Wn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/leave"),n.params={user_id:r,should_remove_operator_status:a},n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Qn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u;return r.memberCount=o,r.joinedMemberCount=c,r.member=new tn(r._iid,s.data),r}return e(n,t),n}(Ft),Yn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userIds;return(n=t.call(this)||this).method=N.POST,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/invite"),n.params={user_ids:r},n}return e(n,t),n}(S),Kn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this;r.inviter=null;var a=s.data,i=a.member_count,u=void 0===i?0:i,c=a.joined_member_count,l=void 0===c?0:c,h=a.inviter,d=a.invitees,_=void 0===d?[]:d;return r.memberCount=u,r.joinedMemberCount=l,h&&Object.keys(h).length>0&&(r.inviter=new o(e,h)),r.invitees=_.map((function(t){return new tn(e,t)})),r}return e(n,t),n}(Ft),Xn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/decline"),n.params={user_id:r},n}return e(n,t),n}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.NONE,s}e(n,t)}(T);var Zn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,u=a.joined_member_count,c=a.inviter,l=a.invitee;return r.memberCount=null!=i?i:0,r.joinedMemberCount=null!=u?u:0,r.inviter=new o(e,c),r.invitee=new tn(e,l),r}return e(n,t),n}(Ft),$n={hidePreviousMessages:!1,allowAutoUnhide:!0},es=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.hidePreviousMessages,i=e.allowAutoUnhide;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n.params={user_id:r,hide_previous_messages:null!=a?a:$n.hidePreviousMessages,allow_auto_unhide:null!=i?i:$n.allowAutoUnhide},n}return e(n,t),n}(S),ts=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),ns=function(t){function n(e,n,s){var r,a,i,o=this;return(o=t.call(this,e,"SYEV",s)||this).allowAutoUnhide=null,o.hidePreviousMessages=null,o.messageOffsetTimestamp=null,s.data&&(o.allowAutoUnhide=null!==(r=s.data.allow_auto_unhide)&&void 0!==r?r:null,o.hidePreviousMessages=null!==(a=s.data.hide_previous_messages)&&void 0!==a?a:null),o.messageOffsetTimestamp=null!==(i=s.ts_message_offset)&&void 0!==i?i:null,o}return e(n,t),n}(L),ss=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),rs=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),as=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),is=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),os=function(t){function n(e){var n=e.channelUrl,s=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:s}})||this}return e(n,t),n}(D),us=function(t){function a(e,n){var s,r,a,i,o,u,c,l,h,d,_,p,f,v,m,g,E,C,y,M,b,N,U,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.includeChatNotification=!1,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Yt.ALL,S.unreadChannelFilter=Jt.ALL,S.superChannelFilter=Kt.ALL,S.publicChannelFilter=Qt.ALL,S.hiddenChannelFilter=Xt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=St.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,S.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,S.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,S.includeChatNotification=null!==(i=n.includeChatNotification)&&void 0!==i&&i,S.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,S.customTypesFilter=null!==(u=n.customTypesFilter)&&void 0!==u?u:null,S.customTypeStartsWithFilter=null!==(c=n.customTypeStartsWithFilter)&&void 0!==c?c:"",S.nicknameContainsFilter=null!==(l=n.nicknameContainsFilter)&&void 0!==l?l:null,S.nicknameStartsWithFilter=null!==(h=n.nicknameStartsWithFilter)&&void 0!==h?h:null,S.nicknameExactMatchFilter=null!==(d=n.nicknameExactMatchFilter)&&void 0!==d?d:null,S.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Yt.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Jt.ALL,S.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:Kt.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Qt.ALL,S.hiddenChannelFilter=null!==(g=n.hiddenChannelFilter)&&void 0!==g?g:Xt.UNHIDDEN,S.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},S.userIdsFilter=null!==(C=n.userIdsFilter)&&void 0!==C?C:{userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null!==(y=n.metadataKey)&&void 0!==y?y:null,S.metadataValues=null!==(M=n.metadataValues)&&void 0!==M?M:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(N=n.metadataValueStartsWith)&&void 0!==N?N:null,S.order=null!==(U=n.order)&&void 0!==U?U:St.LATEST_LAST_MESSAGE,n.createdAfter&&(S.createdAfter=n.createdAfter),n.createdBefore&&(S.createdBefore=n.createdBefore),S}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&m("string",this.channelUrlsFilter,!0)&&m("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&r(Yt,this.myMemberStateFilter)&&r(Kt,this.superChannelFilter)&&r(Qt,this.publicChannelFilter)&&r(Jt,this.unreadChannelFilter)&&r(Xt,this.hiddenChannelFilter)&&m(en,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&m("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&r($t,this.userIdsFilter.queryType)&&r(St,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&m("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)&&x(this.createdAfter,!0)&&x(this.createdBefore,!0)},a.prototype.serialize=function(){return R(this)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,ps.of(this._iid).getMyGroupChannels(this._token,n(s({},this)),this.limit,y.REQUEST_CHANNEL,!0)]):[3,2]:[3,5];case 1:return e=a.sent(),t=e.channels,r=e.token,this._token=r,this._hasNext=!!r,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(F),cs=function(n){function s(e){var s=e.channelUrl,r=e.userId,a=n.call(this)||this;return a.method=N.PUT,a.path="".concat(I,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=t({userId:r}),a}return e(s,n),s}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var ls,hs=function(t){function n(e,n,s){var r=t.call(this,e,"DLVR",s)||this;return r.channelUrl=s.channel_url,r.deliveredStateUpdate=s.updated,r}return e(n,t),n}(L),ds=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,s=e.bottom,r=void 0===s?0:s;this.top=n,this.bottom=r}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0&&n.onMentionReceived&&n.onMentionReceived(g,_)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=6;case 6:return[3,79];case 7:return U=e.as(Y),me=U.channelUrl,ge=U.channelType,S=U.messageId,T=U.silent,A=U.messageCreatedAt,I=U.senderId,ge!==i.GROUP?[3,9]:[4,this.getChannel(me,!0)];case 8:w=xn.sent(),L=I===this._sdkState.userId,T||L||A>0&&w.myLastRead0&&w._updateUnreadCount(w.unreadMessageCount-1,0),this._dispatcher.dispatch(new Q({messageIds:[S],source:y.EVENT_MESSAGE_DELETED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onMessageDeleted&&n.onMessageDeleted(w,S)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=9;case 9:return[3,79];case 10:return(D=e.as(Be).readStatus).channelType!==i.GROUP?[3,12]:(V=this._groupChannelCache.isCachedInMemory(D.channelUrl),[4,this.getChannel(D.channelUrl,!0)]);case 11:x=xn.sent(),V&&x._updateUnreadMemberState(D.reader.userId,D.readAt),D.reader.userId===this._sdkState.userId?V?(x.unreadMessageCount>0||x.unreadMentionCount>0)&&(x._updateUnreadCount(0,0),this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):0!==x.unreadMessageCount&&0!==x.unreadMentionCount||(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUnreadMemberStatusUpdated&&n.onUnreadMemberStatusUpdated(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),xn.label=12;case 12:return[3,79];case 13:return R=e.as(hs),me=R.channelUrl,F=R.deliveredStateUpdate,k=void 0===F?{}:F,V=this._groupChannelCache.isCachedInMemory(me),[4,this.getChannel(me,!0)];case 14:return K=xn.sent(),V&&Object.keys(k).forEach((function(e){K._updateUndeliveredMemberState(e,k[e])})),Object.keys(k).some((function(e){return e!==Dn._sdkState.userId}))&&(this._dispatcher.dispatch(new En({channels:[K],context:{source:y.EVENT_CHANNEL_DELIVERED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUndeliveredMemberStatusUpdated&&n.onUndeliveredMemberStatusUpdated(K)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 15:return X=e.as(qt),me=X.channelUrl,ge=X.channelType,Z=X.event,ge!==i.GROUP?[3,18]:[4,this.getChannel(me,!0)];case 16:return $=xn.sent(),[4,this.getMessageFromCache(Z.messageId)];case 17:(ne=xn.sent())?ne instanceof Ge&&(ne.applyReactionEvent(Z),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new W({event:Z,source:y.EVENT_MESSAGE_REACTION_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onReactionUpdated&&n.onReactionUpdated($,Z)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=18;case 18:return[3,79];case 19:return(ee=e.as(Bt).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(ee.channelUrl,!0)];case 20:return te=xn.sent(),[4,this.getMessageFromCache(ee.targetMessageId)];case 21:(ne=xn.sent())?ne instanceof Ge&&(ne.applyThreadInfoUpdateEvent(ee),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new z({event:ee,source:y.EVENT_MESSAGE_THREADINFO_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onThreadInfoUpdated&&n.onThreadInfoUpdated(te,ee)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=22;case 22:return[3,79];case 23:se=e.as(Gt).groupChannelMemberCounts,re=[],xn.label=24;case 24:xn.trys.push([24,29,30,31]),ae=v(se),ie=ae.next(),xn.label=25;case 25:return ie.done?[3,28]:(oe=ie.value,me=oe.channelUrl,ct=oe.memberCount,lt=oe.joinedMemberCount,ue=oe.updatedAt,[4,this.getChannelFromCache(me)]);case 26:(ce=xn.sent())&&ce._setLatestMemberCount(ct,lt,ue)&&re.push(ce),xn.label=27;case 27:return ie=ae.next(),[3,25];case 28:return[3,31];case 29:return le=xn.sent(),Nn={error:le},[3,31];case 30:try{ie&&!ie.done&&(Un=ae.return)&&Un.call(ae)}finally{if(Nn)throw Nn.error}return[7];case 31:return re.length>0&&(this._dispatcher.dispatch(new En({channels:re,context:{source:y.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelMemberCountChanged&&n.onChannelMemberCountChanged(re)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 32:return he=e.as(Vt),de=he.event,_e=he.status,me=he.channelUrl,ge=he.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,34];case 33:pe=xn.sent(),this._dispatcher.dispatch(new q({event:de,source:y.EVENT_POLL_UPDATED})),H(_e===J?function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollDeleted&&n.onPollDeleted(pe,de.pollId)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}:function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollUpdated&&n.onPollUpdated(pe,de)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}),xn.label=34;case 34:return[3,79];case 35:return fe=e.as(Ve),ve=fe.event,me=fe.channelUrl,ge=fe.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,37];case 36:Ee=xn.sent(),this._dispatcher.dispatch(new B({event:ve,source:y.EVENT_POLL_VOTED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollVoted&&n.onPollVoted(Ee,ve)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=37;case 37:return[3,79];case 38:if(!(Ce=e.as(Ft).event).isGroupChannelEvent)return[3,77];switch(Ce.category){case Ot.CHANNEL_JOIN:return[3,39];case Ot.CHANNEL_LEAVE:return[3,41];case Ot.CHANNEL_OPERATOR_UPDATE:return[3,45];case Ot.CHANNEL_INVITE:return[3,47];case Ot.CHANNEL_DECLINE_INVITE:return[3,49];case Ot.TYPING_START:case Ot.TYPING_END:return[3,51];case Ot.USER_CHANNEL_MUTE:case Ot.USER_CHANNEL_UNMUTE:return[3,53];case Ot.USER_CHANNEL_BAN:return[3,55];case Ot.USER_CHANNEL_UNBAN:return[3,59];case Ot.CHANNEL_FREEZE:case Ot.CHANNEL_UNFREEZE:return[3,61];case Ot.CHANNEL_HIDE:return[3,63];case Ot.CHANNEL_UNHIDE:return[3,65];case Ot.CHANNEL_DELETED:return[3,67];case Ot.CHANNEL_PROP_CHANGED:return[3,69];case Ot.CHANNEL_META_DATA_CHANGED:return[3,71];case Ot.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case Ot.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(Ce.channelUrl,!0)];case 40:return ye=xn.sent(),Me=e.as(jn),be=Me.memberCount,Ne=Me.joinedMemberCount,Ue=Me.members,Se=!1,Ue.forEach((function(e){ye.isExclusive||ye.isSuper||ye.isBroadcast?Se=Se||ye._setLatestMemberCount(be,Ne,Ce.ts):(e.state=Wt.JOINED,ye.addMember(e,Ce.ts),Dn._updateJoinedMemberCount(ye)),e.userId===Dn._sdkState.userId&&(ye.myMemberState=Wt.JOINED)})),this._dispatcher.dispatch(new En({channels:[ye],context:{source:y.EVENT_CHANNEL_JOINED,users:Ue}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var s=v(Ue),r=s.next();!r.done;r=s.next()){var a=r.value;e.onUserJoined&&e.onUserJoined(ye,a)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}ye.isBroadcast&&Se&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,77];case 41:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Ae=Mt.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(Ce.channelUrl,!0)];case 43:Ae=xn.sent(),xn.label=44;case 44:return Te=Ae,Ie=e.as(Qn),ct=Ie.memberCount,lt=Ie.joinedMemberCount,we=Ie.member,Le=!1,De=P.of(this._iid).appInfo,Te.isExclusive||Te.isSuper||Te.isBroadcast?Le=Te._setLatestMemberCount(ct,lt,Ce.ts):((null==De?void 0:De.enabledChannelMemberShipHistory)?((Ye=Te.members.find((function(e){return e.userId===we.userId})))&&(Ye.state=Wt.LEFT),Te.memberCount=ct):Te.removeMember(we),this._updateJoinedMemberCount(Te)),we.userId===this._sdkState.userId?(Te.myMemberState=Wt.NONE,Te.invitedAt=0,Te.joinedAt=0,Te._updateUnreadCount(0,0),Te.isPublic?this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})):(this._markAsLeave(Te),this._dispatcher.dispatch(new Cn({channelUrls:[Te.url],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})))):this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(Te,we),Te.isBroadcast&&Le&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Te])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(Ce.channelUrl,!0)];case 46:Ke=xn.sent(),Je=e.as(Ht).operators,Xe=Je.map((function(e){return e.userId}));try{for(Ze=v(Ke.members),$e=Ze.next();!$e.done;$e=Ze.next())(yt=$e.value).role=Xe.includes(yt.userId)?a.OPERATOR:a.NONE}catch(e){Sn={error:e}}finally{try{$e&&!$e.done&&(Tn=Ze.return)&&Tn.call(Ze)}finally{if(Sn)throw Sn.error}}return Ke.myRole=Xe.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new En({channels:[Ke],context:{source:y.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Je}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ke,Je)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(Ce.channelUrl,!0)];case 48:et=xn.sent(),tt=e.as(Jn),ct=tt.memberCount,lt=tt.joinedMemberCount,nt=tt.inviter,(st=tt.invitees).forEach((function(e){return e.state=Wt.INVITED}));try{for(rt=v(st),at=rt.next();!at.done;at=rt.next())it=at.value,et.isExclusive||et.isSuper||et.isBroadcast?et._setLatestMemberCount(ct,lt,Ce.ts):et.addMember(it,Ce.ts),this._sdkState.userId===it.userId&&(et.hiddenState=tr.UNHIDDEN,et.myMemberState!==Wt.JOINED&&(et.myMemberState=Wt.INVITED),et.invitedAt=Ce.ts)}catch(e){An={error:e}}finally{try{at&&!at.done&&(In=rt.return)&&In.call(rt)}finally{if(An)throw An.error}}return this._dispatcher.dispatch(new En({channels:[et],context:{source:y.EVENT_CHANNEL_INVITED,inviter:nt,invitees:st}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(et,nt,st)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(Ce.channelUrl,!0)];case 50:return ot=xn.sent(),ut=e.as(Zn),ct=ut.memberCount,lt=ut.joinedMemberCount,ht=ut.inviter,dt=ut.invitee,ot.isExclusive||ot.isSuper||ot.isBroadcast?ot._setLatestMemberCount(ct,lt,Ce.ts):ot.removeMember(dt),this._sdkState.userId===dt.userId?(ot.invitedAt=0,ot.myMemberState=Wt.NONE,ot.isPublic?this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})):this._dispatcher.dispatch(new Cn({channelUrls:[ot.url],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}}))):this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ot,ht,dt)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(Ce.channelUrl,!0)];case 52:return _t=xn.sent(),pt=Ce.category===Ot.TYPING_START,ft=e.as(pt?rs:is).user,_t._updateTypingStatus(ft,pt?Ce.ts:0),this._dispatcher.dispatch(new En({channels:[_t],context:{source:y.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(_t)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(Ce.channelUrl,!0)];case 54:vt=xn.sent(),mt=Ce.category===Ot.USER_CHANNEL_MUTE,(gt=e.as(mt?Oe:He).user).userId===this._sdkState.userId&&(vt.myMutedState=mt?G.MUTED:G.UNMUTED,vt._myMutedRemainingTime=gt.restrictionInfo.remainingDuration);try{for(Et=v(vt.members),Ct=Et.next();!Ct.done;Ct=Et.next())if((yt=Ct.value).userId===gt.userId){yt.isMuted=mt;break}}catch(e){wn={error:e}}finally{try{Ct&&!Ct.done&&(Ln=Et.return)&&Ln.call(Et)}finally{if(wn)throw wn.error}}return this._dispatcher.dispatch(new En({channels:[vt],context:{source:mt?y.EVENT_CHANNEL_MUTED:y.EVENT_CHANNEL_UNMUTED,user:gt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){mt?e.onUserMuted&&e.onUserMuted(vt,gt):e.onUserUnmuted&&e.onUserUnmuted(vt,gt)})),[2]}))}))})),[3,77];case 55:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Nt=Mt.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(Ce.channelUrl,!0)];case 57:Nt=xn.sent(),xn.label=58;case 58:return bt=Nt,this._markAsLeave(bt),Ut=e.as(ke).user,Ut.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[bt.url],context:{source:y.EVENT_CHANNEL_BANNED,user:Ut}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(bt,Ut)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(Ce.channelUrl,!0)];case 60:return St=xn.sent(),Tt=e.as(Pe).user,Tt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[St.url],context:{source:y.EVENT_CHANNEL_UNBANNED,user:Tt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(St,Tt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(Ce.channelUrl,!0)];case 62:return At=xn.sent(),It=e.as(Fe).freeze,At.isFrozen=It,this._dispatcher.dispatch(new En({channels:[At],context:{source:It?y.EVENT_CHANNEL_FROZEN:y.EVENT_CHANNEL_UNFROZEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){It?e.onChannelFrozen&&e.onChannelFrozen(At):e.onChannelUnfrozen&&e.onChannelUnfrozen(At)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(Ce.channelUrl,!0)];case 64:return wt=xn.sent(),Rt=e.as(ns),Pt=Rt.allowAutoUnhide,Qt=Rt.hidePreviousMessages,Yt=Rt.messageOffsetTimestamp,null!==Pt&&(wt.hiddenState=Pt?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Qt&&Qt&&wt._updateUnreadCount(0,0),null!==Yt&&(wt.messageOffsetTimestamp=Yt),this._dispatcher.dispatch(new En({channels:[wt],context:{source:y.EVENT_CHANNEL_HIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(wt)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(Ce.channelUrl,!0)];case 66:return(Kt=xn.sent()).hiddenState=tr.UNHIDDEN,this._dispatcher.dispatch(new En({channels:[Kt],context:{source:y.EVENT_CHANNEL_UNHIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Kt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(Ce.channelUrl,!0)];case 68:return Jt=xn.sent(),this._dispatcher.dispatch(new Cn({channelUrls:[Ce.channelUrl],context:{source:y.EVENT_CHANNEL_DELETED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Jt.url,Jt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(Ce.channelUrl,!0)];case 70:return Xt=xn.sent(),this._dispatcher.dispatch(new En({channels:[Xt],context:{source:y.EVENT_CHANNEL_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Xt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(Ce.channelUrl,!0)];case 72:return Zt=xn.sent(),$t=e.as(Re),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&(Zt._upsertCachedMetaData(en,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_CREATED,metaData:en},ts:Ce.ts}))),tn&&(Zt._upsertCachedMetaData(tn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_UPDATED,metaData:tn},ts:Ce.ts}))),nn&&(Zt._removeFromCachedMetaData(nn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:nn},ts:Ce.ts}))),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){en&&e.onMetaDataCreated&&e.onMetaDataCreated(Zt,en),tn&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Zt,tn),nn&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Zt,nn)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(Ce.channelUrl,!0)];case 74:return sn=xn.sent(),rn=e.as(xe),an=rn.created,on=rn.updated,un=rn.deleted,an&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:an}})),on&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:on}})),un&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:un}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){an&&e.onMetaCounterCreated&&e.onMetaCounterCreated(sn,an),on&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(sn,on),un&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(sn,un)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(Ce.channelUrl,!0)];case 76:return cn=xn.sent(),ln=e.as(kt),hn=ln.pinnedMessageIds,dn=ln.latestPinnedMessage,(_n=ln.ts)>cn._pinnedMessagesUpdatedAt&&(cn.pinnedMessageIds=null!=hn?hn:[],cn.lastPinnedMessage=dn,cn._pinnedMessagesUpdatedAt=_n,this._dispatcher.dispatch(new En({channels:[cn],context:{source:y.EVENT_PINNED_MESSAGE_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(cn)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(cn)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((pn=e.as(Lt).event).category){case Dt.USER_BLOCK:fn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=fn.blocker,gn=fn.blockee,this._groupChannelCache.block(mn.userId,gn.userId);break;case Dt.USER_UNBLOCK:vn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=vn.blocker,gn=vn.blockee,this._groupChannelCache.unblock(mn.userId,gn.userId)}return[3,79];case 79:return[3,81];case 80:if(yn=xn.sent(),O(yn))throw yn;return[3,81];case 81:return[2]}}))}))},u.prototype._markAsLeave=function(e){var t,n=this,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((function(){s.ref--,0===s.ref&&n._leftChannels.delete(e.url)}),1e4)},u.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},u.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},u.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},u.prototype.subscribeChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},u.prototype.unsubscribeChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},u.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===Wt.JOINED})).length},u.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n;return f(this,(function(s){switch(s.label){case 0:l(g("string",e)).throw(h.invalidParameters),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=s.sent())?[2,n]:[3,4];case 3:return s.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,s.sent()]}}))}))},u.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return l(g("string",e)).throw(h.invalidParameters),n=new Nn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(s=o.sent(),r=s.as(Un).channel,a=r.unreadMessageCount,i=r.unreadMentionCount,r.myCountPreference){case er.UNREAD_MESSAGE_COUNT_ONLY:i=0;break;case er.UNREAD_MENTION_COUNT_ONLY:a=0;break;case er.OFF:a=0,i=0}return r._updateUnreadCount(a,i),[4,this.upsertChannelsToCache([r])];case 2:return[2,o.sent()[0]]}}))}))},u.prototype.refreshChannel=function(e,t,n,s){return void 0===t&&(t=!0),void 0===n&&(n=y.REFRESH_CHANNEL),void 0===s&&(s=!1),p(this,void 0,void 0,(function(){var r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Nn({channelUrl:e,isInternalCall:t,showLatestMessage:s}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Un).channel).myMemberState!==Wt.NONE?[3,2]:(this._dispatcher.dispatch(new Cn({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new En({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(u=c.sent()).code!==K.NON_AUTHORIZED&&u.code!==K.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Cn({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},u.prototype.getMyGroupChannels=function(e,t,n,r,a){return void 0===r&&(r=y.REQUEST_CHANNEL),void 0===a&&(a=!1),p(this,void 0,void 0,(function(){var i,o,u,c,l,h,d,_,p;return f(this,(function(f){switch(f.label){case 0:return t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3)),i=!1,a&&(o=P.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(i=!0)),l=new Tn(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n,includeLeftChannel:a&&i})),[4,this._requestQueue.send(l)];case 1:return h=f.sent(),d=h.as(An),_=d.channels,p=d.token,this._dispatcher.dispatch(new En({channels:_,context:{source:r}})),[2,{channels:_,token:p}]}}))}))},u.prototype.getMyGroupChannelChangeLogs=function(e,t,r){return void 0===r&&(r=y.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var a,i,o,u,c,d,_,p;return f(this,(function(f){switch(f.label){case 0:return a=s(s({},cn),t),l((g("string",e)||g("number",e))&&ln(a)).throw(h.invalidParameters),i=new Mn(n({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:a})),[4,this._requestQueue.send(i)];case 1:return o=f.sent(),u=o.as(bn),c=u.updatedChannels,d=u.deletedChannelUrls,_=u.hasMore,p=u.ts,c.length>0&&this._dispatcher.dispatch(new En({channels:c,context:{source:r},ts:p})),d.length>0&&this._dispatcher.dispatch(new Cn({channelUrls:d,context:{source:r}})),[2,{updatedChannels:c,deletedChannelUrls:d,hasMore:_,token:u.token}]}}))}))},u.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(a){switch(a.label){case 0:return t=s(s({},hn),e),l(dn(t)).throw(h.invalidParameters),n=new In({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),[2,r.as(wn).groupChannelCount]}}))}))},u.prototype.getUnreadItemCount=function(e){return p(this,void 0,void 0,(function(){var n,r,a,i,o,u,c,d,_,p,v,g,E,C,y,M;return f(this,(function(f){switch(f.label){case 0:return n=s(s({},_n),e),l(function(e){return m(sn,e.keys)&&m("string",e.customTypeFilters,!0)&&m("string",e.customTypesFilter,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid),a=r.sdkState,i=r.requestQueue,o=new Ln({userId:a.userId,filter:n}),[4,i.send(o)];case 1:return u=f.sent(),c=u.as(Dn),d=c.groupChannelUnreadMentionCount,_=c.groupChannelUnreadMessageCount,p=c.groupChannelInvitationCount,v=c.superGroupChannelUnreadMentionCount,g=c.superGroupChannelUnreadMessageCount,E=c.superGroupChannelInvitationCount,C=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,M=c.nonSuperGroupChannelInvitationCount,[2,t({groupChannelUnreadMentionCount:d,groupChannelUnreadMessageCount:_,groupChannelInvitationCount:p,superGroupChannelUnreadMentionCount:v,superGroupChannelUnreadMessageCount:g,superGroupChannelInvitationCount:E,nonSuperGroupChannelUnreadMentionCount:C,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:M})]}}))}))},u.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new xn({userId:t.userId}),[4,n.send(s)];case 1:return r=a.sent(),[2,r.as(Rn).unreadCount]}}))}))},u.prototype.getTotalUnreadMessageCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return t=s(s({},pn),e),l(fn(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Fn({userId:r.userId,filter:t}),[4,a.send(i)];case 1:return o=u.sent(),[2,o.as(Pn).unreadCount]}}))}))},u.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,a,i;return f(this,(function(o){switch(o.label){case 0:return t=s(s({},vn),e),l(function(e){return g("string",e.channelUrl,!0)&&m(Me,e.scheduledStatus,!0)&&r(C,e.messageTypeFilter)}(t)).throw(h.invalidParameters),n=P.of(this._iid).requestQueue,a=new kn(t),[4,n.send(a)];case 1:return i=o.sent(),[2,i.as(On).count]}}))}))},u.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=P.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},u.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=P.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e},u.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=P.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},u.prototype.createChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a;return f(this,(function(i){switch(i.label){case 0:return t=s(s({},on),e),l(un(t)).throw(h.invalidParameters),t.isPublic||(t.accessCode=void 0),n=new Vn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),a=r.as(Gn).channel,[4,this.upsertChannelsToCache([a])];case 2:return i.sent(),[2,a]}}))}))},u.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return e=Date.now(),l(e-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Bn({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(s=v(n),r=s.next();!r.done;r=s.next())(a=r.value)._updateUnreadMemberState(this._sdkState.userId,e),a._updateUnreadCount(0,0)}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},u.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=Date.now(),l(m("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Bn({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:d.sent(),s=this._groupChannelCache.channels,r=[];try{for(a=v(s),i=a.next();!i.done;i=a.next())o=i.value,e.includes(o.url)&&(o._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0),r.push(o))}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=a.return)&&c.call(a)}finally{if(u)throw u.error}}return r.length>0?[4,this.upsertChannelsToCache(r)]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2]}}))}))},u.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},u.prototype.getMessageFromCache=function(e){var t;return p(this,void 0,void 0,(function(){return f(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]}}))}))},u.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return p(this,void 0,void 0,(function(){return f(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,s.sent()]}}))}))},u.prototype.getMessagesFromCache=function(e,t,n,s,r,a){return void 0===r&&(r=Ye),void 0===a&&(a=!0),p(this,void 0,void 0,(function(){return f(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:s,backward:"next"===n,inclusive:a})];case 1:return[2,i.sent()]}}))}))},u.prototype.getPollMessagesFromCache=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,r.sent()]}}))}))},u.prototype.getCachedMessageCountBetween=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.countBetween(e,t,new ds({top:n,bottom:s}))];case 1:return[2,r.sent()]}}))}))},u.prototype.getUnsentMessagesFromCache=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},u.prototype.removeFailedMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},u}(Pt),fs=function(e,t){return t instanceof qe?e.findIndex((function(e){return e instanceof qe&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vs=function(e,t){return e.findIndex((function(e){return e instanceof Ge?e.messageId===t:e instanceof Ke?e.notificationId===t:void 0}))},ms=function(e,t){if(e.length>0){for(var n=0,s=e.length-1,r=Math.floor((n+s)/2);n0)s=r,r=Math.floor((n+s)/2);else{if(!(a<0))return r;n=r+1,r=Math.floor((n+s)/2)}}return e[r].createdAt>t.createdAt?r:r+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(ls||(ls={}));var gs,Es=function(t){function n(e,n,s,r){var a=t.call(this)||this;return a._state=ls.IDLE,a._retryCount=0,a._retryLimit=3,a.priority=0,a._worker=n,a}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===ls.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===ls.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===ls.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(s){switch(s.label){case 0:if(!this.isRunning)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=s.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=s.sent(),this.dispatch("error",n),this._retryCount0&&(r=s.map((function(e){return e.createdAt})),(null===(v=this._metadata)||void 0===v?void 0:(i=v.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.length0&&(r=s.map((function(e){return e.createdAt})),(null===(h=this._metadata)||void 0===h?void 0:(i=h.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit,this._metadata&&(t.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return f.sent(),[3,7];case 5:throw a=f.sent(),m.debug("message background next sync error",a),a;case 6:return g.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:n.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(v=null===(p=l.localCacheConfig)||void 0===p?void 0:p.maxSize)&&void 0!==v?v:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[2,t]}}))}))}))];case 1:return[2,s.sent()]}}))}))})),this._connectionEventContext=v.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n){return Cs[t]||(Cs[t]={}),Cs[t][n.url]||(Cs[t][n.url]=new e({_iid:t,channel:n})),Cs[t][n.url].ref++,Cs[t][n.url]},e.clear=function(e,t){Cs[e]&&Cs[e][t]&&(Cs[e][t].close(),delete Cs[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 ds({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{range:new ds(e.range),previousComplete:e.previousComplete}:{range:new ds({}),previousComplete:!1},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(e){var t,n,s,r;void 0===e&&(e=Date.now());var a=P.of(this._iid),i=a.logger,o=a.sessionManager;a.cacheContext.localCacheEnabled&&o.session.hasSession&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==n?n:e),this._nextSync.start(null!==(r=null===(s=this._metadata)||void 0===s?void 0:s.range.bottom)&&void 0!==r?r:e))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Cs[this._iid][this._channel.url])},e}(),Ms={},bs=function(){function e(e){var t=e._iid,n=e.channel,r=e.includeParams,a=this;this.ref=0,this._iid=t,this._channel=n,this._includeParams=r;var i,o,u=P.of(this._iid),c=u.logger,l=u.sdkState,d=u.dispatcher;this._metadataKey=(i=l.userId,o=n.url,"sendbird:".concat(i,"@groupchannel/").concat(o,"/message/changelogs.meta"));var _=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(l.userId,this._channel.url);this._sync=new Es(_,(function(){return p(a,void 0,void 0,(function(){var e,t,n,r,a,i,o,u;return f(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:l.sent(),c.debug("message changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),l.label=2;case 2:return l.trys.push([2,5,,8]),[4,Je.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,s({replyType:ne.ALL},this._includeParams),y.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=l.sent(),n=t.updatedMessages,r=t.deletedMessageIds,a=t.hasMore,i=t.token,e.hasNext=a,e.nextToken=i,(n.length>0||r.length>0)&&this._metadata&&(this._metadata.token=i),c.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return l.sent(),[3,8];case 5:return o=l.sent(),c.debug("message changelog sync error",o),o instanceof h&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:l.sent(),l.label=7;case 7:throw o;case 8:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n,s){return Ms[t]||(Ms[t]={}),Ms[t][n.url]||(Ms[t][n.url]=new e({_iid:t,channel:n,includeParams:s})),Ms[t][n.url].ref++,Ms[t][n.url]},e.clear=function(e,t){Ms[e]&&Ms[e][t]&&(Ms[e][t].close(),delete Ms[e])},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=P.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:s=r.sent(),this._metadata={token:s?s.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e=P.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Ms[this._iid][this._channel.url])},e}(),Ns={},Us=function(){function e(e){var t=e._iid,n=e.channel,s=e.hasPollMessage,r=this;this.ref=0,this._iid=t,this._channel=n;var a,i,o=P.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(a=c.userId,i=n.url,"sendbird:".concat(a,"@groupchannel/").concat(i,"/poll/changelogs.meta"));var d=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new Es(d,(function(){return p(r,void 0,void 0,(function(){var e,t,n,r,a,i,o,c;return f(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,s()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=P.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,se.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return r=l.sent(),a=r.hasMore,i=r.token,e.hasNext=a,e.nextToken=i,this._metadata.token=i,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 h&&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 Z)if(e.stateType===$.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n,s){return Ns[t]||(Ns[t]={}),Ns[t][n.url]||(Ns[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:s})),Ns[t][n.url].ref++,Ns[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.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 p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){P.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){P.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 Ns[this._iid][this._channel.url])},e}(),Ss=function(n){function s(e){var s,r,a,i,o,u,c,l,h,d,_=this;return(_=n.call(this)||this).method=N.GET,_.path="".concat(re(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),_.params=t({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!==(r=e.customTypes)&&void 0!==r?r:["*"],message_type:null!==(a=e.messageType)&&void 0!==a?a:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:ne.NONE,include_reactions:null===(o=e.includeReactions)||void 0===o||o,include_meta_array:null===(u=e.includeMetaArray)||void 0===u||u,include_thread_info:null===(c=e.includeThreadInfo)||void 0===c||c,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(d=e.showSubchannelMessagesOnly)&&void 0!==d&&d,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),_}return e(s,n),s}(S),Ts=function(t){function n(e,n){var s,r,a,i,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(s=n.prev_messages)&&void 0!==s?s:[]).map((function(t){return Xe(e,t)})),c.prevHasMore=null!==(r=n.prev_hasmore)&&void 0!==r&&r,c.isContinuousPrevMessages=null!==(a=n.is_continuous_prev_messages)&&void 0!==a&&a,c.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return Xe(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}(T),As={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(gs||(gs={}));var Is,ws,Ls,Ds=function(){function e(){this._onCacheResult=ue,this._onApiResult=ue}return e.prototype._invokeResponse=function(e,t,n){var s=this;H((function(){return p(s,void 0,void 0,(function(){return f(this,(function(s){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}(),xs=function(){function e(e,t){var n=t.filter,s=t.startingPoint,r=t.limit,a=t.prevResultLimit,i=t.nextResultLimit,o=t.channel,u=t.channelManager,c=t.disableBackgroundSync,l=void 0!==c&&c,h=this;this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key="mc-".concat(oe()),this._isDisposed=!1,this.filter=null!=n?n:new Le,this._channel=o,this._syncRange=new ds({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=r||Ye,this._prevResultLimit=null!=a?a:Math.floor(this._limit/2),this._nextResultLimit=null!=i?i:Math.floor(this._limit/2),this._channelManager=u;var m=P.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source,s=e.findIndex((function(e){return e.isIdentical(h.channel)}));s>=0&&(h._replaceChannelOfCollection(e[s]),h.channel._runIfHandleableWithGroupChannel((function(e){switch(n){case y.EVENT_CHANNEL_UPDATED:for(var s=!1,r=0;r=e.messageOffsetTimestamp){s=!0;var a=r;if(a>0){var i=h._messages.splice(0,a);h._removeMessagesFromView(i.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&h._messages.length>0&&h._removeMessagesFromView(h._messages.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED);break;case y.EVENT_CHANNEL_UNMUTED:var o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&h._clearCheckMyMutedTimer();break;case y.EVENT_CHANNEL_MUTED:o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&-1!==e._myMutedRemainingTime&&h._startCheckMyMutedTimer(e._myMutedRemainingTime);break;case y.EVENT_CHANNEL_LEFT:e.isPublic&&h._clearCheckMyMutedTimer()}H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(s){return gn(n)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel),[2]}))}))}))})),h._postprocessChannelUpdateEvent(e[s],n))},onRemove:function(e,t){var n=e.indexOf(h.channel.url);n>=0&&(h._clearCheckMyMutedTimer(),H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(n){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url),[2]}))}))})),h._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,s,r=[],a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value;u.channelUrl===h._channel.url&&(h.filter.match(u)?r.push(u):a.push(h.keyOf(u)))}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}if(ie(t)){if(r.length>0)switch(t){case y.LOCAL_MESSAGE_CANCELED:case y.LOCAL_MESSAGE_RESEND_STARTED:case y.EVENT_MESSAGE_SENT_FAILED:case y.EVENT_MESSAGE_SENT_SUCCESS:case y.EVENT_MESSAGE_UPDATED:case y.EVENT_MESSAGE_THREADINFO_UPDATED:case y.EVENT_MESSAGE_REACTION_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_ADDED:case y.EVENT_MESSAGE_FEEDBACK_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_DELETED:case y.SYNC_MESSAGE_CHANGELOGS:h._updateMessagesToView(r,t);break;case y.EVENT_MESSAGE_SENT_PENDING:h._addMessagesToView(r,t);break;case y.EVENT_MESSAGE_RECEIVED:h.hasNext||h._addMessagesToView(r,t);break;case y.SYNC_MESSAGE_FILL:h._addMessagesToView(r,t)}a.length>0&&h._removeMessagesFromView(a,t)}h._postprocessMessageUpdateEvent(e,t)},onRemove:function(e,t){h._removeMessagesFromView(e,t),h._postprocessMessageRemoveEvent(e)},onRemoveUnsent:function(e,t){h._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){h._updatePollsToView(e,t)},onPollUpdate:function(e,t){h._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){h._applyPollVoteEventToView(e,t)},onReactionUpdate:function(e,t){h._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){h._applyThreadInfoEventToView(e,t)}});var g=P.of(this._iid),E=g.cacheContext,C=g.dispatcher,M=g.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),C.dispatch(new En({channels:[this._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=ys.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=bs.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Us.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Es(this._key,(function(e){return p(h,void 0,void 0,(function(){var t=this;return f(this,(function(n){switch(n.label){case 0:return[4,M.run("message-fill-sync-".concat(o.url,"-prev"),(function(){return p(t,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:y.SYNC_MESSAGE_FILL,checkingContinuousMessages:E.localCacheEnabled})];case 1:return t=u.sent(),n=t.messages,s=t.isContinuousMessages,n.length>0?(r=Math.min.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:n.length>=this._prevResultLimit&&this.viewTop0?(r=Math.max.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:!(n.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>r,nextToken:this._syncRange.bottom}]):(E.localCacheEnabled&&m.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(o=null===(i=E.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==o?o:0,use_local_cache:E.localCacheEnabled,starting_point:0,message_init_policy:""}})),[2,{hasNext:!1,nextToken:0}])}}))}))}))];case 1:return[2,n.sent()]}}))}))})),this._connectionEventContext=C.on((function(e){if(e instanceof Z)switch(e.stateType){case $.CONNECTED:b((function(){return p(h,void 0,void 0,(function(){return f(this,(function(e){return this._activate(),[2]}))}))}));break;case $.LOGOUT:h.dispose();break;default:h._clearCheckMyMutedTimer(),h._prevFill.stop(),h._nextFill.stop()}}))}return e.prototype.keyOf=function(e){return 0},Object.defineProperty(e.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),e.prototype._postprocessChannelUpdateEvent=function(e,t){},e.prototype._postprocessChannelRemoveEvent=function(e){},e.prototype._postprocessMessageUpdateEvent=function(e,t){},e.prototype._postprocessMessageRemoveEvent=function(e){},Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],_(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype._activate=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return P.of(this._iid).logger.debug("check huge gap"),this._checkHugeGap(),[4,this._refreshChannel(y.SYNC_CHANNEL_CHANGELOGS)];case 1:return e.sent(),[2]}}))}))},e.prototype._replaceChannelOfCollection=function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)},e.prototype._shouldStartBackgroundSync=function(){var e=P.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled},e.prototype._setBaseMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n instanceof Ge&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,s,r=this,a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value,c=vs(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l.isUserMessage()&&l.applyPoll(u),a.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}return a.length>0&&ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},a.length>0&&(null===(s=(n=this._handler).onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,a)),[2]}))}))})),a},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollUpdateEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollVoteEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyReactionEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyReactionEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._applyThreadInfoEventToView=function(e,t){var n=this,s=vs(this._messages,e.targetMessageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyThreadInfoUpdateEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._removeMessagesFromView=function(e,t){var n,s,r=this,a=[],i=[],o=function(e){var t=u._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var n=u._messages[t];a.push(u.keyOf(n)),i.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=v(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(n)throw n.error}}return ie(t)&&i.length>0&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===s||s.call(n,e,this.channel,a,i),[2]}))}))})),a},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,s=void 0===n?0:n,r=t.nextLimit,a=void 0===r?0:r,i=t.inclusive,o=void 0===i||i;return p(this,void 0,void 0,(function(){var t,n,r,i,u;return f(this,(function(c){switch(c.label){case 0:return t=[],o?[4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter)]:[3,2];case 1:t=c.sent(),c.label=2;case 2:return s>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,s,!1)]:[3,4];case 3:return r=c.sent(),[3,5];case 4:r=[],c.label=5;case 5:return n=r,a>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,a,!1)]:[3,7];case 6:return u=c.sent(),[3,8];case 7:u=[],c.label=8;case 8:return i=u,[2,{messages:d(d(d([],_(t),!1),_(n),!1),_(i),!1).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:n.length,nextMessagesCount:i.length}]}}))}))},e.prototype._getRemoteMessages=function(e,t){var r=t.prevLimit,a=void 0===r?0:r,i=t.nextLimit,o=void 0===i?0:i,u=t.source,c=void 0===u?y.REQUEST_MESSAGE:u,l=t.reverse,h=void 0!==l&&l,d=t.checkingHasNext,_=void 0!==d&&d,v=t.checkingContinuousMessages,m=void 0!==v&&v;return p(this,void 0,void 0,(function(){var t,r;return f(this,(function(i){switch(i.label){case 0:return t=Je.of(this._iid),a>0||o>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,n(s(s(s({},this.filter),As),{isInclusive:!0,reverse:h,prevResultSize:a,nextResultSize:o})),c,_,m)]:[3,2];case 1:return r=i.sent(),[3,3];case 2:r={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,r]}}))}))},e.prototype._checkHugeGap=function(){var e,t,n,r,a;return p(this,void 0,void 0,(function(){var i,o,u,c,l,v,m,g,E,C,M,b,N,U,S,T,A,I,w,L,D,x,R,F,k,O=this;return f(this,(function(V){switch(V.label){case 0:return i=P.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=i.cacheContext,l=i.statManager,v=i.logger,this._messages.length>0?(m=this._syncRange.top,g=this.viewTop,E=this._syncRange.bottom,C=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,g,m)]):[3,8];case 1:return M=V.sent(),[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,E,C)];case 2:b=V.sent(),V.label=3;case 3:return V.trys.push([3,5,6,7]),[4,ce((function(){return p(O,void 0,void 0,(function(){var e,t,n,r,a,i,l,h,v,N,U,S,T,A,I,w,L,D=this;return f(this,(function(x){switch(x.label){case 0:return e=new Ss(s(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:g,prevEnd:m,prevCount:M,nextStart:E,nextEnd:C,nextCount:b,checkingContinuousMessages:c.localCacheEnabled},this.filter),As)),[4,u.send(e)];case 1:return t=x.sent(),n=t.as(Ts),r=n.isHugeGap,a=n.prevMessages,i=void 0===a?[]:a,l=n.prevHasMore,h=n.isContinuousPrevMessages,v=n.nextMessages,N=void 0===v?[]:v,U=n.nextHasmore,S=n.isContinuousNextMessages,r?H((function(){return p(D,void 0,void 0,(function(){var e;return f(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected(),[2]}))}))})):(T=this.viewTop,A=this.viewBottom,I=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,T],_(i.map((function(e){return e.createdAt}))),!1)),w=Math.max.apply(Math,d([0,A],_(N.map((function(e){return e.createdAt}))),!1)),o.dispatch(new j({messages:i,source:y.SYNC_MESSAGE_FILL})),o.dispatch(new j({messages:N,source:y.SYNC_MESSAGE_FILL})),this._syncRange.extends(I,w),(h||S)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(I,w)),l&&this._prevFill.start(I),U&&this._nextFill.start(w)),[2]}}))}))}),1)];case 4:return V.sent(),[3,7];case 5:return N=V.sent(),v.debug("Failed HugeGap Check ",N),[3,7];case 6:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=c.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[3,13];case 8:U=Date.now(),V.label=9;case 9:return V.trys.push([9,11,12,13]),[4,this._getRemoteMessages(U,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:y.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:c.localCacheEnabled})];case 10:if(S=V.sent(),T=S.messages,A=S.isContinuousMessages,I=S.hasNext,T.length>0){for(w=T.map((function(e){return e.createdAt})),L=0,D=0,x=0;x=U&&D++;this._hasPrevious=L>=this._prevResultLimit,this._hasNext=null!=I?I:D>=this._nextResultLimit,(k=this._syncRange).extends.apply(k,d([],_(w),!1)),A&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(T,y.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,13];case 11:return(F=V.sent())instanceof h&&F.code===K.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,13];case 12:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(a=null===(r=c.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 13:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return e=this,[4,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return e._unsentMessages=t.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s;return f(this,(function(r){switch(r.label){case 0:n=P.of(this._iid).logger,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._channelManager.refreshChannel(this.channel.url,!0,e,t)];case 2:return r.sent(),[3,4];case 3:return s=r.sent(),n.warn("Failed to refresh channel",s),[3,4];case 4:return[2]}}))}))},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return p(t,void 0,void 0,(function(){var e,t,n,s=this;return f(this,(function(r){switch(r.label){case 0:this._checkMyMutedStateTimer=void 0,e=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=r.sent(),e=!t.isMuted,[3,5];case 3:return r.sent(),e=!0,[3,5];case 4:return e&&(n=P.of(this._iid).sessionManager,this.channel._runIfHandleableWithGroupChannel((function(e){var t,r;e.myMutedState=G.UNMUTED;var a={source:y.EVENT_CHANNEL_UNMUTED,user:n.currentUser};null===(r=null===(t=s._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===r||r.call(t,a,s.channel)}))),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)},e.prototype._setHasNextAndHasPrevious=function(e,t){for(var n=e.map((function(e){return e.createdAt})),s=0,r=0,a=0;athis._startingPoint&&r++}this._hasPrevious=s>=this._prevResultLimit,this._hasNext=null!=t?t:r>=this._nextResultLimit},e.prototype.initialize=function(e){var t=this,n=new Ds;this._messages=[],this._unsentMessages=[],this._syncRange=new ds({}),this._hasNext=!0,this._hasPrevious=!0;var s=[],r={messages:[],prevMessagesCount:0,nextMessagesCount:0};return H((function(){return p(t,void 0,void 0,(function(){var t,a,i,o,u,c=this;return f(this,(function(l){switch(l.label){case 0:return[4,null===(u=this._backgroundSync)||void 0===u?void 0:u.loadMetadata()];case 1:if(t=l.sent(),a=P.of(this._iid),i=a.cacheContext,o=a.statManager,e===gs.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(e){return p(c,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return r=e,s=this._filterUnderOffsetMessage(r.messages),this._addMessagesToView(s,y.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return t.sent(),n._invokeResponse("local",null,s),[2]}}))}))})).catch((function(e){if(O(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){return p(c,void 0,void 0,(function(){var a,i,u,c,l,h,p,v=this;return f(this,(function(f){switch(f.label){case 0:return a=P.of(this._iid).cacheContext,i=!0,u=!0,c=!1,a.localCacheEnabled&&s.length>0&&(l=t.range).includes.apply(l,d([],_(s.map((function(e){return e.createdAt}))),!1))&&(!t.previousComplete&&r.prevMessagesCountt.range.bottom||r.nextMessagesCount=e._latestMessageInfo.createdAt&&(u=!1)})),u?(i=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:a.localCacheEnabled}).then((function(e){var t,s,r,a=e.messages,i=e.isContinuousMessages,o=e.hasNext,u=v._filterUnderOffsetMessage(a);v._messages=[],u.length>0?(v._setHasNextAndHasPrevious(u,o),(t=v._syncRange).extends.apply(t,d([],_(u.map((function(e){return e.createdAt}))),!1)),i&&(null===(s=v._backgroundSync)||void 0===s?void 0:s.range.overlap(v._syncRange))&&(null===(r=v._backgroundSync)||void 0===r||r.range.extends(v._syncRange.top,v._syncRange.bottom)),v._addMessagesToView(u,y.REQUEST_MESSAGE)):(v._hasPrevious=!1,v._hasNext=!1),n._invokeResponse("remote",null,u)})).catch((function(e){if(O(e))throw e;n._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(s),n._invokeResponse("remote",null,s)),a.localCacheEnabled&&o.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:i?"cache_hit":"cache_miss",max_db_size:null!==(p=null===(h=a.localCacheConfig)||void 0===h?void 0:h.maxSize)&&void 0!==p?p:0,message_init_policy:e,use_local_cache:a.localCacheEnabled,collection_id:this._key}})),[2]}}))}))}));return o.put(new le({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}})),[2]}}))}))})),n},e.prototype.loadPrevious=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasPrevious?this._isLoadingPrevious?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingPrevious=!0,o=this.viewTop,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{prevLimit:this._prevResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._prevResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h=this;return f(this,(function(p){switch(p.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=p.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top))),u=u.filter((function(e){return fs(h._messages,e)<0})),this._hasPrevious=u.length>=this._prevResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(c=null===(i=e.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==c?c:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=u.length>=this._prevResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingPrevious=!1,[2,u]}}))}))},e.prototype.loadNext=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasNext?this._isLoadingNext?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingNext=!0,o=this.viewBottom,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{nextLimit:this._nextResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._nextResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h,p=this;return f(this,(function(f){switch(f.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=f.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom))),u=u.filter((function(e){return fs(p._messages,e)<0})),this._hasNext=null!==(i=t.hasNext)&&void 0!==i?i:u.length>=this._nextResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(h=null===(c=e.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==h?h:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=u.length>=this._nextResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingNext=!1,[2,u]}}))}))},e.prototype.removeFailedMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return[4,this._channelManager.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,s=this;if(!this._isDisposed){this._isDisposed=!0;var r=P.of(this._iid),a=r.cacheContext,i=r.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(e){e.myMemberState!==Wt.NONE&&(s._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new En({channels:[s._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})))})),a.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}},e}(),Rs=function(t){function n(e,n){return t.call(this,e,s(s({},n),{channelManager:ps.of(e)}))||this}return e(n,t),n.prototype.keyOf=function(e){return e.messageId},n.prototype.initialize=function(e){var n=this;return b((function(){return p(n,void 0,void 0,(function(){var e;return f(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]}}))}))})),t.prototype.initialize.call(this,e)},n.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},n.prototype._activate=function(){return p(this,void 0,void 0,(function(){var e=this;return f(this,(function(n){switch(n.label){case 0:return[4,t.prototype._activate.call(this)];case 1:return n.sent(),[4,b((function(){return p(e,void 0,void 0,(function(){var e;return f(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]}}))}))}))];case 2:return n.sent(),[2]}}))}))},n.prototype._addMessagesToView=function(e,t){var n,s,r=this,a=this._filterUnderOffsetMessage(e),i=[],o=[];try{for(var u=v(a),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===y.SYNC_MESSAGE_FILL){if(l.messageId>0){if((E=fs(this._messages,l))<0){fs(this._unsentMessages,l)<0&&i.push(l);var h=ms(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof qe){(E=fs(this._unsentMessages,l))<0&&fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l))}}else if(l.messageId>0){if((E=fs(this._messages,l))<0){var m=fs(this._unsentMessages,l);m<0?i.push(l):(this._unsentMessages.splice(m,1),o.push(l));h=ms(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[E]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,d([],_(g),!1))}}else if(l instanceof qe){var E;(E=fs(this._unsentMessages,l))<0?fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l)):(o.push(l),this._unsentMessages[E]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,a;return f(this,(function(u){return e={source:t},i.length>0&&(null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===s||s.call(n,e,this.channel,i)),o.length>0&&(null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,e,this.channel,o)),[2]}))}))}))},n.prototype._updateMessagesToView=function(e,t){var n,s,r=this,a=[],i=[],o=[];try{for(var u=v(e),c=u.next();!c.done;c=u.next()){var l,h=c.value;if(h.messageId>0)if((l=fs(this._messages,h))>=0)i.push(h),this._messages[l]=h;else{var m=fs(this._unsentMessages,h);if(m>=0){var g=_(this._unsentMessages.splice(m,1),1)[0];if(this.hasNext&&g)o.push(g);else{i.push(h);var E=ms(this._messages,h);this._messages.splice(E,0,h)}}else{var C=this._messages.map((function(e){return e.createdAt}));(h.createdAtMath.max.apply(Math,d([],_(C),!1))&&!this._hasNext)&&a.push(h)}}else if(h instanceof qe)(l=fs(this._unsentMessages,h))>=0&&(i.push(h),this._unsentMessages[l]=h)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}return ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,u;return f(this,(function(c){return e={source:t},i.length>0?null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,i):o.length>0?null===(u=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===u||u.call(r,e,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t),[2]}))}))})),i},n}(xs),Fs={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},Ps=function(t){function n(e){var n=this,s=e.channelUrl,r=e.token,a=e.limit,i=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=N.GET,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/members"),n.params={token:r,limit:a,order:i,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}(S),ks=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.members=[];var r=n.next,a=n.members;return s.token=r,a&&a.length>0&&(s.members=a.map((function(t){return new tn(e,t)}))),s}return e(n,t),n}(T);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Is||(Is={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(ws||(ws={})),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"}(Ls||(Ls={}));var Os=function(t){function a(e,n,s){var r,a,o,u,c=this;return(c=t.call(this,e,n,i.GROUP,s)||this).mutedMemberFilter=Is.ALL,c.memberStateFilter=Ls.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Zt.ALL,c.order=ws.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(r=s.mutedMemberFilter)&&void 0!==r?r:Is.ALL,c.memberStateFilter=null!==(a=s.memberStateFilter)&&void 0!==a?a:Ls.ALL,c.nicknameStartsWithFilter=null!==(o=s.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=s.order)&&void 0!==u?u:ws.MEMBER_NICKNAME_ALPHABETICAL,c}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&r(Is,this.mutedMemberFilter)&&r(Ls,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&r(Zt,this.operatorFilter)&&r(ws,this.order)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=P.of(this._iid).requestQueue,t=new Ps(n(s(s({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=u.sent(),a=r.as(ks),i=a.members,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(he),Hs=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/accept"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),Vs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.JOINED,s}return e(n,t),n}(T),Gs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.isDistinct,i=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,_=e.customType,p=e.operatorUserIds,f=e.messageSurvivalSeconds;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r)),s.params=t({is_distinct:a,is_public:i,is_discoverable:o,name:h,data:d,custom_type:_,cover_url:u,cover_file:c,access_code:l,operator_ids:p,message_survival_seconds:f}),s}return e(s,n),s}(S),Bs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),qs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s)),n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var zs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var js=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.countPreference,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:r},a}return e(n,t),n}(S),Ws=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.countPreference=n.count_preference,s}return e(n,t),n}(T),Qs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.locale;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r),"/reset_user_history"),s.params=t({locale:a}),s}return e(s,n),s}(S),Ys=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),Ks=s(s({},Ze),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Js=s(s({},et),{scheduledAt:void 0}),Xs=function(s){function r(e){var r,a,i=this;i=s.call(this)||this;var o=[];e.mentionType===de.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((function(e){return e.userId}))));var u=e.channelType,c=e.channelUrl,l=e.scheduledMessageId;return i.method=N.PUT,i.path="".concat(re(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((function(e){return nt.payloadify(e)})),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(a=e.metaArrays)||void 0===a?void 0:a.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})),i}return e(r,s),r}(S),Zs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Ae(e,n),s}return e(n,t),n}(T),$s=function(s){function r(e){var r,a=this;a=s.call(this)||this;var i=[];e.mentionType===de.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return a.method=N.PUT,a.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),a.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(r=e.metaArrays)||void 0===r?void 0:r.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),a}return e(r,s),r}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Te(e,n),s}e(n,t)}(T);var er,tr,nr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.DELETE,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a)),n}return e(n,t),n}(S),sr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.POST,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a),"/send_now"),n}return e(n,t),n}(S),rr=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.pushTriggerOption,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:r},a}return e(n,t),n}(S),ar=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T),ir=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=t.call(this)||this;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),r}return e(n,t),n}(S),or=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T);!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"}(er||(er={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(tr||(tr={}));var ur=function(u){function c(e,t){var n,c,l,h,p,f,v,m,E,C,y,M,b,N,U,S,T,A,I,w,L=this;return(L=u.call(this,e,t)||this)._unreadMemberStateMap=new Map,L._undeliveredMemberStateMap=new Map,L._typingStatus=new Map,L._lastMemberCountUpdated=0,L._typingStarted=0,L._typingEnded=0,L._hasBotInfo={general:!1,ai:!1},L.isDistinct=!1,L.isSuper=!1,L.isBroadcast=!1,L.isExclusive=!1,L.isPublic=!1,L.isDiscoverable=!0,L.isChatNotification=!1,L.isAccessCodeRequired=!1,L.isPushEnabled=!1,L.unreadMessageCount=0,L.unreadMentionCount=0,L.totalUnreadReplyCount=0,L.members=[],L.memberCount=0,L.joinedMemberCount=0,L.hiddenState=tr.UNHIDDEN,L.lastMessage=null,L.messageOffsetTimestamp=0,L.messageSurvivalSeconds=-1,L.myMemberState=Wt.NONE,L.myRole=a.NONE,L.myMutedState=G.UNMUTED,L.myLastRead=0,L.myCountPreference=er.ALL,L.myPushTriggerOption=me.DEFAULT,L.inviter=null,L.invitedAt=0,L.joinedAt=0,L.lastPinnedMessage=null,L._latestMessageInfo=null,L._pinnedMessagesUpdatedAt=0,L._myMutedRemainingTime=-1,L.channelType=i.GROUP,L.isDistinct=null!==(c=t.is_distinct)&&void 0!==c&&c,L.isSuper=null!==(l=t.is_super)&&void 0!==l&&l,L.isBroadcast=null!==(h=t.is_broadcast)&&void 0!==h&&h,L.isExclusive=null!==(p=t.is_exclusive)&&void 0!==p&&p,L.isPublic=null!==(f=t.is_public)&&void 0!==f&&f,L.isDiscoverable=null!==(v=t.is_discoverable)&&void 0!==v?v:L.isPublic,L.isChatNotification=null!==(m=t.is_chat_notification)&&void 0!==m&&m,L.isAccessCodeRequired=null!==(E=t.is_access_code_required)&&void 0!==E&&E,L.isPushEnabled=null!==(C=t.is_push_enabled)&&void 0!==C&&C,Array.isArray(t.members)&&(n=L.members).push.apply(n,d([],_(t.members.map((function(e){return new tn(L._iid,e)}))),!1)),L.memberCount=null!==(y=t.member_count)&&void 0!==y?y:0,L.joinedMemberCount=null!==(M=t.joined_member_count)&&void 0!==M?M:0,L.hiddenState=r(tr,t.hidden_state)?t.hidden_state:tr.UNHIDDEN,L.messageOffsetTimestamp=null!==(b=t.ts_message_offset)&&void 0!==b?b:0,L.messageSurvivalSeconds=null!==(N=t.message_survival_seconds)&&void 0!==N?N:-1,L.lastMessage=t.last_message?Xe(L._iid,s({channel_type:L.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((function(e){g("number",t.read_receipt[e])&&L._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((function(e){g("number",t.delivery_receipt[e])&&L._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),L.myMemberState=r(Wt,t.member_state)?t.member_state:Wt.NONE,L.myRole=r(a,t.my_role)?t.my_role:a.NONE,r(G,t.is_muted)?L.myMutedState=t.is_muted:g("boolean",t.is_muted)?L.myMutedState=t.is_muted?G.MUTED:G.UNMUTED:L.myMutedState=G.UNMUTED,L.myCountPreference=r(er,t.count_preference)?t.count_preference:er.ALL,L.myPushTriggerOption=r(me,t.push_trigger_option)?t.push_trigger_option:me.ALL,L.myLastRead=null!==(U=t.user_last_read)&&void 0!==U?U:0,L.inviter=t.inviter?new o(L._iid,t.inviter):null,L.invitedAt=null!==(S=t.invited_at)&&void 0!==S?S:0,L.joinedAt=null!==(T=t.joined_ts)&&void 0!==T?T:0,L._updateUnreadCount(null!==(A=t.unread_message_count)&&void 0!==A?A:0,null!==(I=t.unread_mention_count)&&void 0!==I?I:0),L.totalUnreadReplyCount=null!==(w=t.total_unread_thread_message_count)&&void 0!==w?w:0,L.lastPinnedMessage=t.latest_pinned_message?Xe(L._iid,s({channel_type:L.channelType},t.latest_pinned_message)):null,t.latest_message&&(L._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),L._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot},L}return e(c,u),Object.defineProperty(c.prototype,"isHidden",{get:function(){return this.hiddenState!==tr.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._unreadMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._undeliveredMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasBot",{get:function(){return this._hasBotInfo.general},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasAiBot",{get:function(){return this._hasBotInfo.ai},enumerable:!1,configurable:!0}),c.payloadify=function(e){return t(n(s(s({},u.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,total_unread_thread_message_count:e.totalUnreadReplyCount,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 tn.payloadify(e)})),last_message:e.lastMessage?at(e.lastMessage):null,inviter:e.inviter?o.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?at(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))},c.prototype._shouldUpdateLastMessageWith=function(e){if(e.silent)return!1;var t=P.of(this._iid).appInfo;switch(null==t?void 0:t.lastMessageThreadingPolicy){case pe.NONE:case pe.INCLUDE_REPLY:break;case pe.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case pe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case fe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},c.prototype._updateLastMessage=function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)},c.prototype._updateUnreadCount=function(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===er.ALL||this.myCountPreference===er.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=P.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===er.ALL||this.myCountPreference===er.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},c.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)},c.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},c.prototype._setLatestMemberCount=function(e,t,n){var s=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,s=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),s},c.prototype.isReadMessage=function(e){var t=P.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt},c.prototype.serialize=function(){var e=this;return R(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))},c.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Rs(this._iid,s(s({},e),{channel:this}))},c.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Os(this._iid,this.url,e)},c.prototype.createThreadedParentMessageListQuery=function(e){return void 0===e&&(e={}),new it(this._iid,this.url,this.channelType,e)},c.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 s=this.members[n];s.state===Wt.JOINED&&(e.state=s.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},c.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof tn?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},c.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof qe&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var s=P.of(this._iid).sdkState,r=e.createdAt,a=0;try{for(var i=v(this.members),o=i.next();!o.done;o=i.next()){var u=o.value;if(s.userId!==u.userId&&u.state===Wt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&a.push(i)}})),a},c.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var s=P.of(this._iid).sdkState;if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var r=e instanceof qe?e.sender:null,a=[];return this.members.forEach((function(i){if(t||i.userId!==s.userId&&i.userId!==(null==r?void 0:r.userId)){var o=n._unreadMemberStateMap.get(i.userId);o&&o=t&&(e._typingStatus.delete(a),s=!0)})),s},c.prototype.refresh=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){return[2,this._refresh()]}))}))},c.prototype._refresh=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return t=P.of(this._iid),n=t.requestQueue,s=t.dispatcher,r=new Nn({channelUrl:this.url}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Un).channel,this._update(i),e||s.dispatch(new En({channels:[i],context:{source:y.REFRESH_CHANNEL}})),[2,this]}}))}))},c.prototype.freeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.freeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.unfreeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.unfreeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.updateChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return t=s(s({},Fs),e),l(function(e){return g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new Gs(s({channelUrl:this.url},t)),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Bs).channel,this._update(u),r.dispatch(new En({channels:[u],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.invite=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return l(e.every((function(e){return e instanceof o}))).throw(h.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},c.prototype.inviteWithUserIds=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(m("string",e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.requestQueue,r=t.sessionManager,a=new Yn({channelUrl:this.url,userIds:e}),[4,s.send(a)];case 1:return i=u.sent(),o=i.as(Kn).channel,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_INVITED,inviter:r.currentUser,invitees:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.join=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new qn({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(zn).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.leave=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return t=P.of(this._iid),n=t.sdkState,s=t.requestQueue,r=new Wn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,s.send(r)];case 1:return a.sent(),this.myMemberState=Wt.NONE,[2]}}))}))},c.prototype.acceptInvitation=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new Hs({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(Vs).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.declineInvitation=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new Xn({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),this.myMemberState=Wt.NONE,[2,this]}}))}))},c.prototype.sendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),ps.of(t._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.updateUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateUserMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendMultipleFilesMessage=function(e){var t=this,n=new ut,s=P.of(this._iid).dispatcher;return u.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){n._trigger(e)})).onFailed((function(e,t){n._triggerFailed(e,t)})).onSucceeded((function(e){var r=ps.of(t._iid);t._updateLastMessage(e),r.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})).onFileUploaded((function(e,t,s,r){n._triggerOnFileUploaded(e,t,s,r)})),n},c.prototype.updateFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateFileMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.deleteMessage=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,u.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&e instanceof qe&&P.of(this._iid).dispatcher.dispatch(new ge({reqId:e.reqId,source:y.EVENT_MESSAGE_DELETED})),[2]}}))}))},c.prototype.hide=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=s(s({},$n),e),l(function(e){return g("boolean",e.hidePreviousMessages,!0)&&g("boolean",e.allowAutoUnhide,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.sdkState,i=n.requestQueue,o=new es(s({channelUrl:this.url,userId:a.userId},t)),[4,i.send(o)];case 1:return u=d.sent(),c=u.as(ts).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.unhide=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=new zs({channelUrl:this.url}),[4,n.send(s)];case 1:return r.sent(),this.hiddenState=tr.UNHIDDEN,t.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.delete=function(){return p(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=P.of(this._iid).requestQueue,t=new qs({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o=this;return f(this,(function(u){switch(u.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.dispatcher,s=e.requestQueue,r=new yt({channelUrl:this.url}),[4,s.send(r)];case 1:return a=u.sent(),i=a.as(Be).readStatus,this._updateUnreadMemberState(t.userId,i.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_READ}})),[2]}}))}))},c.prototype.markAsDelivered=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new cs({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),[2]}}))}))},c.prototype.startTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=n?(this._typingStarted=s,this._typingEnded=0,r=new ss({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.endTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=n?(this._typingStarted=0,this._typingEnded=s,r=new as({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.createScheduledUserMessage=function(e){e=s(s({},ct),e),l(lt(e)).throw(h.invalidParameters);var t=new Ct;return this._createScheduledUserMessage(e,t),t},c.prototype.updateScheduledUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a,i;return f(this,(function(o){switch(o.label){case 0:return n=s(s({},Js),t),l(function(e){return tt(e)&&g("number",e.scheduledAt,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid).requestQueue,a=new $s(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(a)];case 1:return i=o.sent(),[2,i.as(Mt).message]}}))}))},c.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},ht),e),l(dt(e)).throw(h.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new Ct;return ve(bt).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);H((function(){return p(t,void 0,void 0,(function(){return f(this,(function(e){return[2,a._trigger(s)]}))}))}))})),E(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a},c.prototype.updateScheduledFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a;return f(this,(function(i){switch(i.label){case 0:return n=s(s({},Ks),t),l(function(e){return $e(e)&&g("number",e.scheduledAt,!0)&&(E(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(h.invalidParameters),E(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return r=new Xs(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,P.of(this._iid).requestQueue.send(r)];case 3:return a=i.sent(),[2,a.as(Zs).message]}}))}))},c.prototype.cancelScheduledMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new nr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.sendScheduledMessageNow=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new sr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.getMyPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a;return f(this,(function(i){switch(i.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new ir({userId:t.userId,channelUrl:this.url}),[4,n.send(s)];case 1:return r=i.sent(),a=r.as(or).pushTriggerOption,this.myPushTriggerOption=a,[2,a]}}))}))},c.prototype.setMyPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(me,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new rr({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(ar).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.setMyCountPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(er,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new js({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Ws).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.resetMyHistory=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=e.sdkState,r=new Qs({channelUrl:this.url,locale:s.localeForChatbot}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Ys).messageOffsetTimestamp,this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt0:void 0,u.lastRepliedAt=null!==(a=t.last_replied_at)&&void 0!==a?a:0,u.updatedAt=null!==(o=t.updated_at)&&void 0!==o?o:0,u}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{reply_count:r.replyCount,unread_message_count:r.unreadReplyCount,member_count:r.memberCount,most_replies:Array.isArray(r.mostRepliedUsers)?r.mostRepliedUsers.map((function(e){return c.payloadify(e)})):[],push_enabled:"boolean"==typeof r.isPushNotificationEnabled?r.isPushNotificationEnabled?1:0:void 0,last_replied_at:r.lastRepliedAt,updated_at:r.updatedAt})))},Object.defineProperty(i.prototype,"_isUpdateRequired",{get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled},enumerable:!1,configurable:!0}),i.prototype._updateFrom=function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled},i}(l);!function(e){e.ADD="add",e.DELETE="delete"}(Ce||(Ce={}));var xe,De=function(e){this.messageId=0,this.operation=null,this.updatedAt=0;var t=h("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,n=e.user_id,r=e.operation?e.operation.toLowerCase():null,i=e.reaction,s=e.updated_at;t&&h("string",n)&&h("string",r)&&f(Ce,r)&&h("string",i)&&i&&h("number",s)&&(this.messageId=t,this.userId=n,this.key=i,this.operation=r,this.updatedAt=s)},Le=function(){function n(e){var t,n,r,i=e.key,s=null!==(r=p([],m(e.user_ids),!1))&&void 0!==r?r:[],a=e.updated_at;h("string",i)&&i&&d("string",s)&&s.length>0&&h("number",a)&&(this.key=i,this.userIds=s,this.updatedAt=a);var o={};try{for(var u=v(this.userIds),c=u.next();!c.done;c=u.next()){o[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._version=o}return Object.defineProperty(n.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({key:n.key,user_ids:n.userIds,updated_at:n.updatedAt}))},n.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 Ce.ADD:t<0&&this.userIds.push(e.userId);break;case Ce.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},n}(),Fe=function(){function n(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 n.payloadify=function(n){var r,i;return e(t({url:n.url,secure_url:n.secureUrl,type:n.type,width:null!==(r=n.width)&&void 0!==r?r:0,height:null!==(i=n.height)&&void 0!==i?i:0,alt:n.alt}))},n}(),qe=function(){function n(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 Fe(e["og:image"]))}return n.payloadify=function(n){return e(t({"og:title":n.title,"og:url":n.url,"og:description":n.description,"og:image":n.defaultImage?Fe.payloadify(n.defaultImage):null}))},n}(),ze=function(){function n(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 n.prototype.serialize=function(){return{name:this.name,volume:this.volume}},n.payloadify=function(n){return e(t({name:n.name,volume:n.volume}))},n}();!function(e){e.GOOD="good",e.BAD="bad"}(xe||(xe={}));var Be=function(){function n(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}return n._getStatus=function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"},n._isSubmitted=function(e){return"SUBMITTED"===n._getStatus(e)},n._getPayloadByStatus=function(e){return"NO_FEEDBACK"===e?{}:null},n.payloadify=function(n){return e(t({id:n.id,rating:n.rating,comment:n.comment}))},n}(),Ke=function(n){function i(e,t){var r,i=this;return(i=n.call(this,e,t)||this).isBlockedByMe=!1,i.role=f(y,t.role)?t.role:y.NONE,i.isBlockedByMe=null!==(r=t.is_blocked_by_me)&&void 0!==r&&r,i}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{role:r.role,is_blocked_by_me:r.isBlockedByMe})))},i}(c),je=function(){function n(e){this.key=e.key,this.value=d("string",e.value)?p([],m(e.value),!1):[]}return n.payloadify=function(n){var r;return e(t({key:n.key,value:null!==(r=n.value)&&void 0!==r?r:[]}))},n}(),Qe=function(e){switch(e){case g.BASE:return"";case g.USER:return"MESG";case g.FILE:return"FILE";case g.ADMIN:return"ADMM"}},Ge=function(n){function i(e,t){var r,i,s,a,o,u,l,d,h,p=this;(p=n.call(this,e)||this).channelType=I.BASE,p.messageType=g.BASE,p.mentionType=null,p.mentionedUsers=null,p.mentionedUserIds=null,p.mentionedMessageTemplate=void 0,p.metaArrays=[],p.extendedMessage={},p.createdAt=0,p.updatedAt=0,p.channelUrl=t.channel_url,p.channelType=f(I,t.channel_type)?t.channel_type:I.GROUP,t.channel&&(t.channel.channel_url&&(p.channelUrl=t.channel.channel_url),t.channel.channel_type&&(p.channelType=t.channel.channel_type)),p.data=null!==(r=t.data)&&void 0!==r?r:"",p.customType=null!==(i=t.custom_type)&&void 0!==i?i:"",p.mentionType=f(E,t.mention_type)?t.mention_type:null,p.mentionedUsers=t.mentioned_users?t.mentioned_users.map((function(e){return new c(p._iid,e)})):null,p.mentionedUserIds=null!==(s=t.mentioned_user_ids)&&void 0!==s?s:null,p.mentionedUsers&&!p.mentionedUserIds&&(p.mentionedUserIds=p.mentionedUsers.map((function(e){return e.userId}))),p.mentionedMessageTemplate=t.mentioned_message_template;var m=null!==(a=t.metaarray)&&void 0!==a?a:{},v=null!==(o=t.metaarray_key_order)&&void 0!==o?o:Object.keys(m).sort((function(e,t){return e.localeCompare(t)}));p.metaArrays=[];for(var y=0;y0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({id:n.id,name:n.name,items:n.items.map((function(e){return dt.payloadify(e)})),version:n.version,is_submitted:n._isSubmitted}))},n.isMessageFormPayload=function(e){return Boolean(null==e?void 0:e.message_form)},n}(),dt=function(){function n(t){var n=t.id,r=t.name,i=t.required,s=t.sort_order,a=t.placeholder,o=t.style,u=t.item_type,c=t.validators,l=t.value,d=t.values;this.id=n,this.name=r,this.required=i,this.sortOrder=s,this.placeholder=a,0===Object.keys(o).length?this.style={layout:u}:this.style=e({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),d?this.submittedValues=d:l&&(this.submittedValues=[l]),this._validators=c}return n.prototype.isValid=function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case it.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case it.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case it.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case it.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case it.DECIMAL_PLACE:return 0!==e.length&&(n=Number(e),!(isNaN(n)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(n,t.max_decimal_place)));default:return!0}}))}(e,t._validators);return n}))},n.payloadify=function(n){return e(t({id:n.id,name:n.name,required:n.required,sort_order:n.sortOrder,placeholder:n.placeholder,style:e({layout:n.style.layout,options:n.style.options,default_options:n.style.defaultOptions,result_count:n.style.resultCount}),item_type:n.style.layout,validators:n._validators,values:n.submittedValues}))},n}(),ht=function(t){function n(n){var r=t.call(this)||this;return r.method=i.POST,r.path="".concat(S,"/").concat(n.formId,"/submit"),r.params=e({message_id:n.messageId,items:n.items}),r}return r(n,t),n}(a);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ut||(ut={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ct||(ct={}));var ft,pt=function(i){function s(e,t){var n,r,s,a,o,u,c,l,d=this;return(d=i.call(this,e,t)||this).parentMessage=null,d.silent=!1,d.isOperatorMessage=!1,d.threadInfo=null,d.reactions=[],d.appleCriticalAlertOptions=null,d.scheduledInfo=null,d.suggestedReplies=null,d.myFeedback=null,d.myFeedbackStatus="NOT_APPLICABLE",d.messageForm=null,d._isContinuousMessages=!1,d._scheduledStatus=null,d.messageId=null!==(r=null!==(n=t.msg_id)&&void 0!==n?n:t.message_id)&&void 0!==r?r:0,d.parentMessageId=null!==(s="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==s?s:0,d.threadInfo=t.thread_info?new Re(d._iid,t.thread_info):null,d.reactions=t.reactions?t.reactions.map((function(e){return new Le(e)})):[],d.ogMetaData=t.og_tag?new qe(t.og_tag):null,d.silent=null!==(a=t.silent)&&void 0!==a&&a,d.isOperatorMessage=null!==(o=t.is_op_msg)&&void 0!==o&&o,d.appleCriticalAlertOptions=t.apple_critical_alert_options?new ze(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(d.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},d._scheduledStatus=t.scheduled_status),d._isContinuousMessages=null!==(u=t.is_continuous_messages)&&void 0!==u&&u,d.myFeedback=Be._isSubmitted(t.feedback)?new Be(t.feedback):null,d.myFeedbackStatus=Be._getStatus(t.feedback),d.suggestedReplies=null!==(l=null===(c=t.extended_message_payload)||void 0===c?void 0:c.suggested_replies)&&void 0!==l?l:null,d.messageForm=lt.isMessageFormPayload(t.extended_message_payload)?new lt(d.messageId,t.extended_message_payload.message_form):null,d}return r(s,i),s.payloadify=function(n){var r,s;return e(t(u(u({},i.payloadify.call(this,n)),{message_id:n.messageId,parent_message_id:n.parentMessageId,thread_info:n.threadInfo?Re.payloadify(n.threadInfo):null,reactions:n.reactions.map((function(e){return Le.payloadify(e)})),og_tag:n.ogMetaData?qe.payloadify(n.ogMetaData):null,silent:n.silent,is_op_msg:n.isOperatorMessage,apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,scheduled_message_id:null===(r=n.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=n.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:n._scheduledStatus,feedback:n.myFeedback?Be.payloadify(n.myFeedback):Be._getPayloadByStatus(n.myFeedbackStatus)})))},s._getParentMessageInfoPayload=function(n){return e(t({type:Qe(n.messageType),ts:n.createdAt,user:n.sender?Ke.payloadify(n.sender):null,message:n.message,file:{url:n.plainUrl,name:n.name,type:n.type,require_auth:n.requireAuth},files:Array.isArray(n.fileInfoList)?n.fileInfoList.map((function(e){return at.payloadify(e)})):null}))},s.prototype.isIdentical=function(e){return this.messageId===e.messageId},s.prototype.applyThreadInfoUpdateEvent=function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)},s.prototype.applyReactionEvent=function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1},s.prototype._triggerThreadInfoUpdatedEvent=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){return(e=n.of(this._iid).dispatcher).dispatch(new ot({channelType:I.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_THREADINFO_UPDATED})),[2]}))}))},s.prototype.markThreadAsRead=function(){return A(this,void 0,void 0,(function(){var e,t;return U(this,(function(r){switch(r.label){case 0:return e=n.of(this._iid).requestQueue,t=new Xe({channelUrl:this.channelUrl,messageId:this.messageId}),[4,e.send(t)];case 1:return r.sent(),this.threadInfo&&0!==this.threadInfo.unreadReplyCount?(this.threadInfo.unreadReplyCount=0,[4,this._triggerThreadInfoUpdatedEvent()]):[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},s.prototype.setPushNotificationEnabled=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return t=n.of(this._iid).requestQueue,r=new Ze({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),[4,t.send(r)];case 1:return i.sent(),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e),[2]}}))}))},s.prototype.submitMessageForm=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(t=n.of(this._iid).requestQueue,r=null,i=null,s=this.messageForm,!e&&s){if(!s.isSubmittable)throw new O({code:P.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(s.isSubmitted)throw new O({code:P.INVALID_PARAMETER,message:"The form has already been submitted."});r=s.id,i=s.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[])}else e&&(r=e.formId,i=Object.entries(e.answers).reduce((function(e,t){var n=m(t,2),r=n[0],i=n[1],s=Number(r);if(Number.isNaN(s))throw new O({code:P.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:s,value:i}),e}),[]));if(!r||!i)throw new O({code:P.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});return a=new ht({messageId:this.messageId,formId:r,items:i}),[4,t.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.submitFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new $e({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(et),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_ADDED})),[2]}}))}))},s.prototype.updateFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new tt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(nt),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_UPDATED})),[2]}}))}))},s.prototype.deleteFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new rt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e}),[4,r.send(s)];case 1:return a.sent(),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_DELETED})),[2]}}))}))},s}(Ge),mt=function(n){function i(e,t){var r,i,s,a,o=this;if((o=n.call(this,e,t)||this).reqId="",o.replyToChannel=!1,o.errorCode=0,o.sender=t.user?new Ke(o._iid,t.user):t.sender_id,o.reqId=null!==(i=null!==(r=t.req_id)&&void 0!==r?r:t.request_id)&&void 0!==i?i:"",o.replyToChannel=null!==(s=t.is_reply_to_channel)&&void 0!==s&&s,t.request_state&&f(k,t.request_state)&&(o.sendingStatus=t.request_state),!o.sendingStatus)if(o.messageId>0)o.sendingStatus=k.SUCCEEDED;else if(o.scheduledInfo)switch(t.scheduled_status&&(o._scheduledStatus=t.scheduled_status),t.scheduled_status){case ct.SENT:case ct.IN_QUEUE:o.sendingStatus=k.SUCCEEDED;break;case ct.PENDING:o.sendingStatus=k.SCHEDULED;break;case ct.FAILED:case ct.REMOVED:o.sendingStatus=k.FAILED;break;case ct.CANCELED:o.sendingStatus=k.CANCELED}else o.sendingStatus=k.PENDING;return o.errorCode=null!==(a=t.error_code)&&void 0!==a?a:0,o._messageToken=t.mesg_token,o}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{user:Ke.payloadify(r.sender),req_id:r.reqId,is_reply_to_channel:r.replyToChannel,request_state:r.sendingStatus,error_code:r.errorCode,mesg_token:r._messageToken})))},Object.defineProperty(i.prototype,"isResendable",{get:function(){return(this.sendingStatus===k.FAILED||this.sendingStatus===k.CANCELED)&&R(this.errorCode)},enumerable:!1,configurable:!0}),i.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},i}(pt),vt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},yt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)},_t=function(n){function i(r,i){var s,a,o,c,l=this;if((l=n.call(this,r,i)||this).translations={},l.message=null!==(s=i.message)&&void 0!==s?s:"",l.messageType=g.ADMIN,l.translations=null!==(a=i.translations)&&void 0!==a?a:{},i.parent_message_info){var d=i.parent_message_info;l.parentMessage=Mt(r,e(t(u(u({},d),{message_id:l.parentMessageId,channel_url:l.channelUrl,channel_type:l.channelType,file:d.file,url:null===(o=d.file)||void 0===o?void 0:o.url,require_auth:null===(c=d.file)||void 0===c?void 0:c.require_auth}))))}return l}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{message:r.message,translations:r.translations,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i}(pt),gt=function(){function n(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&&h("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return n.payloadify=function(n){return e(t({type:n.type,vendor:n.vendor,detail:n.detail}))},n}(),bt=function(){function t(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}return t.payloadify=function(t){return e({status:t.status,original_message_info:t.originalMessageInfo?{id:t.originalMessageInfo.messageId,ts:t.originalMessageInfo.createdAt}:void 0})},t}(),It=function(n){function i(r,i){var s,a,o,c,l,d,h,f=this;if((f=n.call(this,r,i)||this).message="",f.messageParams=null,f.translations={},f.translationTargetLanguages=[],f.messageSurvivalSeconds=-1,f.plugins=[],f._poll=null,f.message=i.message,f.messageType=g.USER,f.translations=null!==(o=i.translations)&&void 0!==o?o:{},f.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(f.translations).length&&f.translationTargetLanguages.length>0)try{for(var p=v(f.translationTargetLanguages),m=p.next();!m.done;m=p.next()){var y=m.value;f.translations[y]=""}}catch(e){s={error:e}}finally{try{m&&!m.done&&(a=p.return)&&a.call(p)}finally{if(s)throw s.error}}if(f.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,f.plugins=i.plugins?i.plugins.map((function(e){return new gt(e)})):[],f._poll=i.poll?new L(f._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;f.parentMessage=Mt(r,e(t(u(u({},_),{created_at:_.ts,message_id:f.parentMessageId,channel_url:f.channelUrl,channel_type:f.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(f.messageReviewInfo=new bt(i.review_info)),f}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{message:r.message,translations:r.translations,message_survival_seconds:r.messageSurvivalSeconds,plugins:r.plugins.map((function(e){return gt.payloadify(e)})),poll:r._poll?L.payloadify(r._poll):null,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null,review_info:r.messageReviewInfo?bt.payloadify(r.messageReviewInfo):void 0})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(i.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),i}(mt),Et=function(n){function i(r,i){var s,a,o,c,l,d,h,f,p=this;if((p=n.call(this,r,i)||this).messageParams=null,p.fileInfoList=[],p.messageSurvivalSeconds=-1,p.messageType=g.FILE,p.data=null!==(o=null!==(a=null===(s=i.file)||void 0===s?void 0:s.data)&&void 0!==a?a:i.custom)&&void 0!==o?o:"",p.fileInfoList=null!==(l=null===(c=i.files)||void 0===c?void 0:c.map((function(e){return new at(r,e)})))&&void 0!==l?l:[],p.messageSurvivalSeconds=null!==(d=i.message_survival_seconds)&&void 0!==d?d:-1,i.parent_message_info){var m=i.parent_message_info;p.parentMessage=Mt(r,e(t(u(u({},m),{created_at:m.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:m.file,url:null===(h=m.file)||void 0===h?void 0:h.url,require_auth:null===(f=m.file)||void 0===f?void 0:f.require_auth}))))}return p}return r(i,n),i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.payloadify=function(r){var i,s,a,o,c,l;return e(t(u(u({},n.payloadify.call(this,r)),{file:{name:null!==(s=null===(i=r.fileInfoList[0])||void 0===i?void 0:i.fileName)&&void 0!==s?s:"",size:null!==(o=null===(a=r.fileInfoList[0])||void 0===a?void 0:a.fileSize)&&void 0!==o?o:0,type:null!==(l=null===(c=r.fileInfoList[0])||void 0===c?void 0:c.mimeType)&&void 0!==l?l:"",data:r.data},files:Array.isArray(r.fileInfoList)?r.fileInfoList.map((function(e){return at.payloadify(e)})):null,message_survival_seconds:r.messageSurvivalSeconds,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},i._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},i}(mt);!function(e){e.SENT="SENT",e.READ="READ"}(ft||(ft={}));var Tt=function(n){function i(e,t){var r,i,s=this;if((s=n.call(this,e,t)||this).notificationData=null,s.notificationId=t.notification_message_id,s.messageType=g.ADMIN,s.messageStatus=null!==(r=t.message_status)&&void 0!==r?r:ft.SENT,s.priority=null!==(i=t.priority)&&void 0!==i?i:F.NORMAL,s.notificationEventDeadline=t.notification_event_deadline,0===s.extendedMessage.sub_type)try{var a=JSON.parse(s.extendedMessage.sub_data),o=a.label,u=a.tags,c=void 0===u?[]:u,l=a.template_key,d=a.template_variables;s.notificationData={label:o,tags:c,templateKey:l,templateVariables:d}}catch(e){}return s}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{notification_message_id:r.notificationId,message_status:r.messageStatus,priority:r.priority,notification_event_deadline:r.notificationEventDeadline})))},i.prototype.isIdentical=function(e){return this.notificationId===e.notificationId},i}(Ge),wt=function(e){if(e.notificationId)return Tt.payloadify(e);switch(e.messageType){case g.USER:return It.payloadify(e);case g.FILE:return e.fileInfoList?Et.payloadify(e):St.payloadify(e);case g.ADMIN:return _t.payloadify(e);default:throw O.unknown}},Mt=function(e,t){if(t.notification_message_id)return new Tt(e,t);switch(t.type){case"MESG":return new It(e,t);case"FILE":return Et._isMultipleFilesMessagePayload(t)?new Et(e,t):new St(e,t);case"ADMM":case"BRDM":return new _t(e,t);default:return null}},St=function(i){function s(n,r){var s,a,o,c,l,d,h,f,p,m,v,y,_,b,I=this;(I=i.call(this,n,r)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=g.FILE;var E=r.file;if(I.plainUrl=(null!==(a=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==a?a:"").split("?auth=")[0],I.name=null!==(c=null!==(o=null==E?void 0:E.name)&&void 0!==o?o:r.name)&&void 0!==c?c:"File",I.size=null!==(d=null!==(l=null==E?void 0:E.size)&&void 0!==l?l:r.size)&&void 0!==d?d:0,I.data=null!==(f=null!==(h=null==E?void 0:E.data)&&void 0!==h?h:r.custom)&&void 0!==f?f:"",I.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(m=r.type)&&void 0!==m?m:"",I.requireAuth=null!==(v=r.require_auth)&&void 0!==v&&v,I.thumbnails=r.thumbnails?r.thumbnails.map((function(e){var t;return new Oe(I._iid,"string"==typeof e?{url:e,width:0,height:0}:u(u({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),I.requireAuth)})):[],I.messageSurvivalSeconds=null!==(y=r.message_survival_seconds)&&void 0!==y?y:-1,r.parent_message_info){var T=r.parent_message_info;I.parentMessage=Mt(n,e(t(u(u({},T),{created_at:T.ts,message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:T.file,url:null===(_=T.file)||void 0===_?void 0:_.url,require_auth:null===(b=T.file)||void 0===b?void 0:b.require_auth}))))}return I}return r(s,i),s.payloadify=function(n){var r;return e(t(u(u({},i.payloadify.call(this,n)),{url:n.plainUrl,require_auth:n.requireAuth,file:{name:n.name,size:n.size,type:n.type,data:n.data},thumbnails:null===(r=n.thumbnails)||void 0===r?void 0:r.map((function(e){return{url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:n.messageSurvivalSeconds,parent_message_info:n.parentMessage?i._getParentMessageInfoPayload.call(this,n.parentMessage):null})))},Object.defineProperty(s.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,ea.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},s}(mt),At=function(e){function t(t,n){var r=n.file,i=n.fileUrl,s=n.fileName,a=n.fileSize,o=n.mimeType,u=n.thumbnailSizes,c=n._uploadedMetaData,l=n._thumbnails,d=e.call(this,t)||this;return d._plainUrl=i,d.file=r,d.fileName=s,d.fileSize=a,d.mimeType=o,d.thumbnailSizes=u,d._uploadedMetaData=c,d._thumbnails=l,d}return r(t,e),t.getPlainUrl=function(e){return e instanceof t?e._plainUrl:e.fileUrl},Object.defineProperty(t.prototype,"fileUrl",{get:function(){var e,t=n.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}},t}(l),Ut=function(n){function i(r){var i,s,a,o,u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,files:r.files?Pt(r.files):null,url:r.url,name:null!==(i=r.fileName)&&void 0!==i?i:"",type:null!==(s=r.mimeType)&&void 0!==s?s:"",size:null!==(a=r.fileSize)&&void 0!==a?a:0,custom:r.data,custom_type:r.customType,thumbnails:null===(o=r._thumbnails)||void 0===o?void 0:o.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:u,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,pin_message:r.isPinnedMessage}))})||this}return r(i,n),i}(T),Nt=function(n){function s(r){var s,a,o=this;o=n.call(this)||this;var u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),o.method=i.POST,o.path="".concat(w(r.channelType),"/").concat(encodeURIComponent(r.channelUrl),"/messages"),o.params=e(t({message_type:g.FILE,user_id:r.userId,files:r.files?Pt(r.files):null,url:r.fileUrl,mention_type:r.mentionType,mentioned_user_ids:u,file_name:r.fileName,file_size:r.fileSize,file_type:r.mimeType,data:r.data,custom_type:r.customType,thumbnails:null===(s=r._thumbnails)||void 0===s?void 0:s.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,sorted_metaarray:null===(a=r.metaArrays)||void 0===a?void 0:a.map((function(e){return je.payloadify(e)})),push_option:r.pushNotificationDeliveryOption,parent_message_id:r.parentMessageId?r.parentMessageId:null,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,reply_to_channel:r.isReplyToChannel,req_id:r.reqId,pin_message:r.isPinnedMessage})),o}return r(s,n),s}(a),Ct=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"FILE",i)||this).message=i.files&&i.files.length>=2?new Et(t,i):new St(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),Ot=function(e){function t(t,r){var i,s,a,o,u=this;(u=e.call(this,t,r)||this).message=r.files&&r.files.length>=2?new Et(t,r):new St(t,r);var c=n.of(t).sdkState;return u.isMentioned=z(u.message.mentionType,null!==(a=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(s=u.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return r(t,e),t}(o);function Pt(n){return n.map((function(n){var r,i;return e(t({url:At.getPlainUrl(n),file_name:n.fileName,file_type:n.mimeType,file_size:n.fileSize,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),require_auth:null===(i=n._uploadedMetaData)||void 0===i?void 0:i.requireAuth}))}))}var kt;!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"}(kt||(kt={}));var Rt=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext,o=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=a,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof K&&(o._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===j.CONNECTED||this._connectionState===j.CONNECTING||this._connectionState===j.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){switch(s.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(r=new Ut(n),[4,this._requestQueue.send(r)]):[3,2];case 1:return i=s.sent(),[2,i.as(Ct).message];case 2:return r=new Nt(u(u({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),[2,i.as(Ot).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=u(u({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{r=t.params;n.url=r.fileUrl,n.requireAuth=r.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p;return U(this,(function(m){switch(m.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,r=[],i=!0,m.label=1;case 1:m.trys.push([1,15,16,17]),s=v(n.messageQueue),a=s.next(),m.label=2;case 2:if(a.done)return[3,14];switch(o=a.value,o.state){case kt.PENDING:case kt.UPLOADING:return[3,3];case kt.UPLOADED:return[3,4];case kt.FAILED:return[3,12]}return[3,13];case 3:return i=!1,r.push(o),[3,13];case 4:if(!i)return[3,10];m.label=5;case 5:return m.trys.push([5,8,,9]),o.state=kt.SENDING,[4,this._sendFileMessage(e,o)];case 6:return u=m.sent(),o.deferred.resolve(u),[4,Q(100)];case 7:return m.sent(),[3,9];case 8:return c=m.sent(),o.deferred.reject(c),[3,9];case 9:return[3,11];case 10:r.push(o),m.label=11;case 11:return[3,13];case 12:return l=null!==(t=o.error)&&void 0!==t?t:O.unknown,o.deferred.reject(l.code===P.REQUEST_CANCELED?O.fileUploadCanceled:l),[3,13];case 13:return a=s.next(),[3,2];case 14:return[3,17];case 15:return d=m.sent(),f={error:d},[3,17];case 16:try{a&&!a.done&&(p=s.return)&&p.call(s)}finally{if(f)throw f.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:m.sent(),m.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,m.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d;return U(this,(function(h){switch(h.label){case 0:return(n=this._queueMap.get(e.url))&&(r=n.messageQueue.find((function(e){return e.state===kt.PENDING})))?r.multipleFileUploadInfo?(i=r.multipleFileUploadInfo,s=i.uploadIndex,a=i.uploadCount,o=i.requestHandler,d=r.params,u=d.fileInfoList[s],!G(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]):[3,4]:[3,9];case 1:return h.sent(),[3,3];case 2:r.state=s=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,u,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return a=new Pe({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(a)];case 1:return o=v.sent(),u=o.as(ke),c=u.url,l=u.fileSize,d=void 0===l?n.fileSize:l,h=u.thumbnails,f=void 0===h?[]:h,p=u.requireAuth,m=void 0!==p&&p,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(i=n.mimeType)&&void 0!==i?i:n.file.type,n.fileSize=null!==(s=n.fileSize)&&void 0!==s?s:n.file.size,n.fileUrl=c,n.fileSize=d,n.requireAuth=m,n._thumbnails=f,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,c,l,d,h,f,p,m,v,y;return U(this,(function(_){switch(_.label){case 0:return a=t.multipleFileUploadInfo.uploadIndex,o=n.fileInfoList[a],c=new Pe({file:o.file,channelUrl:e.url,thumbnailSizes:o.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(c)];case 1:return l=_.sent(),d=l.as(ke),h=d.url,f=d.fileSize,p=void 0===f?o.fileSize:f,m=d.thumbnails,v=d.requireAuth,y=void 0!==v&&v,o.fileName=null!==(r=o.fileName)&&void 0!==r?r:o.file.name,o.mimeType=null!==(i=o.mimeType)&&void 0!==i?i:o.file.type,o.fileSize=null!==(s=o.fileSize)&&void 0!==s?s:o.file.size,o.file=void 0,o.fileUrl=h,o.fileSize=p,o._thumbnails=m,o._uploadedMetaData=u(u({},o._uploadedMetaData),{requireAuth:y,isUploaded:!0}),o instanceof At||(n.fileInfoList[a]=new At(this._iid,o)),[2]}}))}))},e.prototype.request=function(e,t,n,r){return void 0===r&&(r={}),A(this,void 0,void 0,(function(){var i,s,a,o,c;return U(this,(function(l){return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),a=new V,o={requestId:t,params:n,state:kt.PENDING,deferred:a},function(e){return"fileInfoList"in e}(n)&&(c=u({uploadIndex:0,uploadCount:n.fileInfoList.length},r),o.multipleFileUploadInfo=c),s.messageQueue.push(o),this._uploadNextPendingItem(e),[2,a.promise]}))}))},e.prototype.cancel=function(e,t){var n,r,i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:p([],m(i.messageQueue),!1);try{for(var a=v(s),o=a.next();!o.done;o=a.next()){var u=o.value;if(u)switch(u.state){case kt.PENDING:if(u.state=kt.FAILED,u.error=O.requestCanceled,u.multipleFileUploadInfo&&!u.multipleFileUploadInfo.isCopy){var c=u.multipleFileUploadInfo,l=c.uploadIndex,d=c.requestHandler,h=u.params.fileInfoList[l];null==d||d._triggerOnFileUploaded(u.requestId,l,h,O.fileUploadCanceled)}this._resolveMessageQueue(e);break;case kt.UPLOADING:this._requestQueue.cancel(u.requestId),this._dispatcher.dispatch(new B({requestId:u.requestId}))}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new B({requestId:t})))},e}();var xt,Dt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:H.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Lt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&f(H,e.replyType)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)&&h("boolean",e.showSubchannelMessagesOnly)},Ft={replyType:H.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},qt=function(e){return f(H,e.replyType)&&h("boolean",e.includeReactions)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)},zt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.includeMetaArray,o=t.includeReactions,u=t.includeThreadInfo,c=t.includeParentMessageInfo,l=e.call(this)||this;return l.method=i.GET,l.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s)),l.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions:o,include_thread_info:u,include_parent_message_info:c,include_poll_details:!0},l}return r(t,e),t}(a),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o),Kt=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.timestamp,u=r.token,c=r.prevResultSize,l=r.nextResultSize,d=r.isInclusive,h=r.reverse,f=r.messageTypeFilter,p=r.customTypesFilter,m=r.senderUserIdsFilter,v=r.replyType,y=r.includeMetaArray,_=r.includeReactions,g=r.parentMessageId,b=r.includeThreadInfo,I=r.includeParentMessageInfo,E=r.showSubchannelMessagesOnly,T=r.checkingHasNext,M=r.checkingContinuousMessages,S=n.call(this)||this;return S.method=i.GET,S.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages"),S.params=e(t({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:m,include_reply_type:v,with_sorted_meta_array:y,include_reactions:_,parent_message_id:g,include_thread_info:b,include_parent_message_info:I,show_subchannel_message_only:E,include_poll_details:!0,checking_has_next:T,checking_continuous_messages:M})),S}return r(s,n),s}(a),jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return void 0!==n.is_continuous_messages&&(r.isContinuousMessages=n.is_continuous_messages),void 0!==n.has_next&&(r.hasNext=n.has_next),r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),Qt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.timestamp,a=t.token,o=t.replyType,u=t.includeMetaArray,c=t.includeReactions,l=t.includeThreadInfo,d=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=i.GET,h.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:s,token:a,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_reply_type:o,include_parent_message_info:d,include_poll_details:!0},h}return r(t,e),t}(a),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return Mt(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return r(t,e),t}(o),Vt=function(e){function t(t){var n=t.channelUrl,r=t.scheduledMessageId,s=e.call(this)||this;return s.method=i.GET,s.path="".concat(W,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),s.params={},s}return r(t,e),t}(a),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o);!function(e){e.MUTED="muted",e.BANNED="banned"}(xt||(xt={}));var Wt=function(){function n(e){var t,n,r,i;this.restrictionType=null,f(xt,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(r=null!==(n=e.end_at)&&void 0!==n?n:e.muted_end_at)&&void 0!==r?r:-1,this.remainingDuration=null!==(i=e.remaining_duration)&&void 0!==i?i:-1}return n.payloadify=function(n){return e(t({restriction_type:n.restrictionType,description:n.description,end_at:n.endAt,remaining_duration:n.remainingDuration}))},n}(),Yt=function(n){function i(e,t){var r=n.call(this,e,t)||this;return r.restrictionInfo=new Wt(t),r}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),Wt.payloadify(r.restrictionInfo))))},i}(c),Jt=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return r(t,e),t}(c),Xt=function(){function e(){this._onPending=Y,this._onFailed=Y,this._onSucceeded=Y}return e.prototype._trigger=function(e){switch(null==e?void 0:e.sendingStatus){case k.PENDING:0===e.errorCode&&this._onPending(e);break;case k.SCHEDULED:case k.SUCCEEDED:this._onSucceeded(e)}},e.prototype._triggerFailed=function(e,t){switch(null==t?void 0:t.sendingStatus){case k.FAILED:case k.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}(),Zt={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},$t=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(je,e.metaArrays,!0)&&h("number",e.parentMessageId,!0)&&h("boolean",e.isReplyToChannel)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)&&h("boolean",e.isPinnedMessage,!0)},en=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},tn=u(u({},Zt),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function nn(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var rn,sn=function(n){var r;return e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,pollId:null===(r=n.poll)||void 0===r?void 0:r.id,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,message:n.message,translationTargetLanguages:Object.keys(n.translations),extendedMessagePayload:n.extendedMessagePayload}))},an=function(e){return $t(e)&&h("string",e.message)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)&&h("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(rn||(rn={}));var on=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},un=function(e){return e===rn.BLOB||e===rn.FILE},cn=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},ln=u(u({},Zt),{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});function dn(e){var n,r,i,s;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=e.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails}))}var hn,fn=function(n,r){var i;return n.messageParams?(!n.url&&G(r)&&(n.messageParams.file=r),n.messageParams):e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,file:r,fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,thumbnailSizes:null===(i=n.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))},pn=function(e){return $t(e)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},mn={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},vn=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(je,e.metaArrays,!0)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)},yn=u(u({},mn),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),_n=function(e){return vn(e)&&h("string",e.message,!0)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)},gn=u({},mn),bn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.token,a=t.limit,o=e.call(this)||this;return o.method=i.GET,o.path="".concat(w(r),"/").concat(encodeURIComponent(n),"/operators"),o.params={token:s,limit:a},o}return r(t,e),t}(a),In=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new c(t,e)})),r.token=n.next,r}return r(t,e),t}(o),En=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=n.of(this._iid).requestQueue,r=new bn(u(u({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(r)]):[3,2]):[3,5];case 1:return i=c.sent(),s=i.as(In),a=s.operators,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),Tn=function(e){function n(t,n,r,i){var s,a,o,u,c,l,d,h,f,p,m=this;return(m=e.call(this,t,n,r,i)||this).reverse=!1,m.messageTypeFilter=x.ALL,m.customTypesFilter=null,m.senderUserIdsFilter=null,m.replyType=H.NONE,m.includeMetaArray=!1,m.includeReactions=!1,m.includeParentMessageInfo=!1,m.includeThreadInfo=!1,m.showSubchannelMessagesOnly=!1,m._edge=Number.MAX_SAFE_INTEGER,m.reverse=null!==(s=i.reverse)&&void 0!==s&&s,m.messageTypeFilter=null!==(a=i.messageTypeFilter)&&void 0!==a?a:x.ALL,m.customTypesFilter=null!==(o=i.customTypesFilter)&&void 0!==o?o:null,m.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,m.replyType=null!==(c=i.replyType)&&void 0!==c?c:H.NONE,m.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,m.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,m.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,m.includeThreadInfo=null!==(f=i.includeThreadInfo)&&void 0!==f&&f,m.showSubchannelMessagesOnly=null!==(p=i.showSubchannelMessagesOnly)&&void 0!==p&&p,m}return r(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.reverse)&&f(x,this.messageTypeFilter)&&f(H,this.replyType)&&d("string",this.customTypesFilter,!0)&&d("string",this.senderUserIdsFilter,!0)&&h("boolean",this.includeMetaArray)&&h("boolean",this.includeReactions)&&h("boolean",this.includeParentMessageInfo)&&h("boolean",this.includeThreadInfo)&&h("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,ea.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t({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=n.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 O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},n}(J),wn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.limit,o=t.token;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:o},n}return r(t,e),t}(a),Mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.mutedUsers=[];var i=n.next,s=n.muted_list;return r.token=i,s&&s.length>0&&(r.mutedUsers=s.map((function(e){return new Yt(t,e)}))),r}return r(t,e),t}(o),Sn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new wn(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Mn),s=i.mutedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),An=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.limit,u=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({limit:o,token:u}),r}return r(n,t),n}(a),Un=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map((function(e){return new Yt(t,e.user)}))),r}return r(t,e),t}(o),Nn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new An(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Un),s=i.bannedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(hn||(hn={}));var Cn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var On=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var Pn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return r(t,e),t}(a),kn=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,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return r(t,e),t}(o),Rn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return r(t,e),t}(a),xn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),Dn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return r(t,e),t}(a),Ln=function(e){function t(t,n){var r,i,s=this;return(s=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},s.ts=null!==(i=n.ts)&&void 0!==i?i:null,s}return r(t,e),t}(o),Fn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata,o=t.upsert;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=o&&o},n}return r(t,e),t}(a),qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),zn=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 r(t,e),t}(M),Bn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return r(t,e),t}(a),Kn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),jn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return r(t,e),t}(a),Qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),Gn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return r(t,e),t}(a),Vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Hn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return r(t,e),t}(a),Wn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Yn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter,o=t.upsert,u=void 0!==o&&o,c=t.mode,l=void 0===c?"set":c;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:u,mode:l},n}return r(t,e),t}(a),Jn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Xn=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 r(t,e),t}(M),Zn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params={},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var $n=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var er=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId,o=t.seconds,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:o,description:u},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var tr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),nr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var rr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ir=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.userId,u=n.seconds,c=n.description;return(r=t.call(this)||this).method=i.POST,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({user_id:o,seconds:u,description:c}),r}return r(n,t),n}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var sr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(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 r(t,e),t}(M),ar=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var or=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ur=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var cr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return r(t,e),t}(M),lr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(X(s),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:o,report_description:u},n}return r(t,e),t}(a),dr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.offendingUserId,c=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(Z,"/users/").concat(u),n.params={channel_url:r,channel_type:s===I.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:o,report_description:c},n}return r(t,e),t}(a),hr=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.category,u=n.userId,c=n.offendingUserId,l=n.messageId,d=n.description,h=n.messageToken;return(r=t.call(this)||this).method=i.POST,r.path="".concat(X(a),"/").concat(encodeURIComponent(s),"/messages/").concat(l),r.params=e({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),r}return r(n,t),n}(a),fr=function(n){function i(r){var i=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,poll_id:r.pollId,pin_message:r.isPinnedMessage,extended_message_payload:r.extendedMessagePayload}))})||this}return r(i,n),i}(T),pr=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"MESG",i)||this).message=new It(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),mr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,poll_id:r.pollId}))})||this}return r(i,n),i}(T),vr=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"MEDI",s)||this).message=new It(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),yr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,apple_critical_alert_options:r.appleCriticalAlertOptions}))})||this}return r(i,n),i}(T),_r=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"FEDI",s)||this).message=new St(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),gr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),br=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(n),r}return r(t,e),t}(o),Ir=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.DELETE,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),Er=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(u({},n)),r}return r(t,e),t}(o),Tr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.translationTargetLanguages,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s),"/translation"),o.params={target_langs:a},o}return r(t,e),t}(a),wr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Mr=function(n){function s(r){var s,a=this;a=n.call(this)||this;var o=[];r.mentionType===E.USERS&&(r.mentionedUserIds?o=r.mentionedUserIds:r.mentionedUsers&&(o=r.mentionedUsers.map((function(e){return e.userId}))));var u=r.channelType,c=r.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=e(t({req_id:r.reqId,scheduled_at:r.scheduledAt,message_type:ee.USER,message:r.message,custom_type:r.customType,data:r.data,mention_type:r.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=r.metaArrays)||void 0===s?void 0:s.map((function(e){return je.payloadify(e)})),apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption})),a}return r(s,n),s}(a),Sr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Ar=function(e){function n(n){var r,s,a=this;a=e.call(this)||this;var o=[];n.mentionType===E.USERS&&(n.mentionedUserIds?o=n.mentionedUserIds:n.mentionedUsers&&(o=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=t({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ee.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=n.metaArrays)||void 0===s?void 0:s.map((function(e){return je.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,push_option:n.pushNotificationDeliveryOption}),a}return r(n,e),n}(a),Ur=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new St(t,n),r}return r(t,e),t}(o),Nr=function(e){function t(t){var n=t.pollId,r=t.title,s=t.data,a=t.allowUserSuggestion,o=t.allowMultipleVotes,u=t.closeAt,c=e.call(this)||this;return c.method=i.PUT,c.path="".concat(ne,"/").concat(encodeURIComponent(n)),c.params={title:r,data:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return r(t,e),t}(a),Cr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Or=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.DELETE,r.path="".concat(ne,"/").concat(encodeURIComponent(n)),r}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var Pr=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.PUT,r.path="".concat(ne,"/").concat(encodeURIComponent(n),"/close"),r}return r(t,e),t}(a),kr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Rr=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.pollId,a=t.optionText,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(ne,"/").concat(encodeURIComponent(s),"/options"),o.params={channel_url:n,channel_type:r,text:a},o}return r(t,e),t}(a),xr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Dr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=t.optionText,a=e.call(this)||this;return a.method=i.PUT,a.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:s},a}return r(t,e),t}(a),Lr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Fr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=e.call(this)||this;return s.method=i.DELETE,s.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var qr=function(t){function n(n){var r=n.reqId,i=n.channelType,s=n.channelUrl,a=n.pollId,o=n.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:e({req_id:r,channel_type:i===I.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:a,option_ids:o})})||this}return r(n,t),n}(T),zr=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=new re(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return r(t,e),t}(M),Br=100,Kr="GroupChannel",jr="url",Qr=100,Gr="Message",Vr="messageId",Hr=100,Wr="NotificationMessage",Yr="notificationId",Jr="Poll",Xr="pollId",Zr=100,$r="FeedChannel",ei="url";function ti(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((function(e){var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))}var ni=u(u({},Zt),{fileInfoList:[]}),ri=function(e){return(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},ii=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._onFileUploaded=Y,t}return r(t,e),t.prototype._triggerOnFileUploaded=function(e,t,n,r){this._onFileUploaded(e,t,n,r)},t.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},t.prototype.onPending=function(t){return e.prototype.onPending.call(this,t),this},t.prototype.onFailed=function(t){return e.prototype.onFailed.call(this,t),this},t.prototype.onSucceeded=function(t){return e.prototype.onSucceeded.call(this,t),this},t}(Xt),si=function(e){function t(t,n){var r=e.call(this,t)||this;return r.message=null,r.message=Mt(t,n.message),r}return r(t,e),t}(l),ai=function(t){function n(n){var r=this,s=n.channelType,a=n.channelUrl,o=n.limit,u=n.token,c=n.includeReactions,l=n.includeMetaArray,d=n.includeParentMessageInfo,h=n.includeThreadInfo,f=n.includePollDetails;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/pinned_messages"),r.params=e({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),r}return r(n,t),n}(a),oi=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.pinned_messages,s=n.has_more,a=n.next;return r.pinnedMessages=i.map((function(e){return new si(t,e)})),r.hasMore=s,r.token=a,r}return r(t,e),t}(o),ui=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s.includeMetaArray=i.includeMetaArray,s.includeReactions=i.includeReactions,s.includeParentMessageInfo=i.includeParentMessageInfo,s.includeThreadInfo=i.includeThreadInfo,s.includePollDetails=i.includePollDetails,s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.includeMetaArray,!0)&&h("boolean",this.includeReactions,!0)&&h("boolean",this.includeParentMessageInfo,!0)&&h("boolean",this.includeThreadInfo,!0)&&h("boolean",this.includePollDetails,!0)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new ai(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=c.sent(),i=r.as(oi),s=i.pinnedMessages,a=i.hasMore,o=i.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ci=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.POST,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var li=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.DELETE,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var di,hi=2;!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(di||(di={}));var fi,pi=function(i){function s(e,t){var n,r,s,a,o,u,l,d=this;return(d=i.call(this,e)||this)._name="",d._createdAt=0,d.pinnedMessageIds=[],d.channelType=I.BASE,d.coverUrl="",d.customType="",d.data="",d.isFrozen=!1,d.isEphemeral=!1,d.creator=null,d._messageCollectionLastAccessedAt=0,d._url=t.channel_url,d._name=null!==(n=t.name)&&void 0!==n?n:"",d._createdAt=1e3*t.created_at,d.coverUrl=null!==(r=t.cover_url)&&void 0!==r?r:"",d.customType=null!==(s=t.custom_type)&&void 0!==s?s:"",d.data=null!==(a=t.data)&&void 0!==a?a:"",d.isFrozen=null!==(o=t.freeze)&&void 0!==o&&o,d.isEphemeral=null!==(u=t.is_ephemeral)&&void 0!==u&&u,d.creator=t.created_by?new c(d._iid,t.created_by):null,t.metadata&&Object.keys(t.metadata).length>0&&t.ts?(d._cachedMetaData=new Map,Object.keys(t.metadata).forEach((function(e){d._cachedMetaData.set(e,{value:t.metadata[e],isRemoved:!1,updatedAt:t.ts})}))):"string"==typeof t.metadata&&(d._cachedMetaData=new Map(Object.entries(JSON.parse(t.metadata)))),d.pinnedMessageIds=null!==(l=t.pinned_message_ids)&&void 0!==l?l:[],d}return r(s,i),Object.defineProperty(s.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),s.prototype.toJSON=function(){return u(u({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},s.payloadify=function(n){return e(t(u(u({},i.payloadify.call(this,n)),{channel_url:n.url,name:n.name,cover_url:n.coverUrl,custom_type:n.customType,data:n.data,freeze:n.isFrozen,is_ephemeral:n.isEphemeral,created_by:n.creator?c.payloadify(n.creator):null,created_at:n.createdAt/1e3,metadata:n.cachedMetaData,pinned_message_ids:n.pinnedMessageIds})))},s.prototype.isGroupChannel=function(){return this.channelType===I.GROUP},s.prototype.isOpenChannel=function(){return this.channelType===I.OPEN},s.prototype.isFeedChannel=function(){return this.channelType===I.FEED},Object.defineProperty(s.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(s.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),s.prototype._serializeCachedMetaData=function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}},s.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},s.prototype._update=function(t){var n=e(t);Object.assign(this,n)},s.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})}))},s.prototype._updateCachedMetaData=function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(i,s){var a;i.updatedAt<=t&&(n._cachedMetaData.set(s,{value:null!==(a=e[s])&&void 0!==a?a:i.value,isRemoved:!e[s],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}},s.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0})),s=new Et(this._iid,i);return s.messageParams=t,s},s.prototype._validateFailedFileMessageHasFile=function(e,t){var n;return Boolean(e.url)||G(t)||G(null===(n=e.messageParams)||void 0===n?void 0:n.file)},s.prototype._createPendingScheduledFileMessage=function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r},s.prototype._markMessageAsFailed=function(e,t,n){void 0===n&&(n=!1),e.errorCode=t.code,t.code===P.REQUEST_CANCELED||t.code===P.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=k.CANCELED:n||(e.sendingStatus=k.FAILED)},s.prototype.sendUserMessage=function(e){var t=u(u({},tn),e);return D(an(t)).throw(O.invalidParameters),this._sendUserMessage(t)},s.prototype._sendUserMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,c=null!=r?r:this._generateRequestId(),l=Date.now(),d=new Xt;return Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l);a.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(r)]}))}))}));var s=new fr(u(u({},e),{channelUrl:i.url,channelType:i.channelType,reqId:c}));o.send(s).then((function(e){var t=e.as(pr).message;a.dispatch(new N({messages:[t],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(t)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l),s=n.of(i._iid).cacheContext,o=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,o),a.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._triggerFailed(t,r)]}))}))}))}))}))})),d},s.prototype._autoResendUserMessage=function(e){return D(e instanceof It&&!!e.messageParams).throw(O.invalidParameters),this._sendUserMessage(e.messageParams,di.SEND,e.reqId)},s.prototype.resendUserMessage=function(e){var t;return A(this,void 0,void 0,(function(){var n,r;return U(this,(function(i){return D(e instanceof It&&!e.scheduledInfo).throw(O.invalidParameters),n=new V,r=null!==(t=e.messageParams)&&void 0!==t?t:sn(e),this._sendUserMessage(r,di.RESEND,e.reqId).onFailed((function(e){return n.reject(e)})).onSucceeded((function(e){return n.resolve(e)})),[2,n.promise]}))}))},s.prototype.updateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},yn),t),D(h("number",e)&&_n(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new mr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(vr).message]}}))}))},s.prototype.copyUserMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof It&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),D(!n.poll).throw(O.notSupportedError),o=new V,c=null!==(r=n.messageParams)&&void 0!==r?r:t(u(u({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(a=n.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),e._sendUserMessage(c).onSucceeded((function(e){o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.translateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof It&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Tr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(wr).message]}}))}))},s.prototype._createScheduledUserMessage=function(e,t){var r=this,i=n.of(this._iid).requestQueue,s=Date.now(),a=this._generateRequestId();Q(2).then((function(){var n=r._createPendingScheduledUserMessage(e,a,s);ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))}));var o=new Mr(u({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(o).then((function(e){var n=e.as(Sr).message;ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var i=r._createPendingScheduledUserMessage(e,a,s);r._markMessageAsFailed(i,n),ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,i)]}))}))}))}))}))},s.prototype.sendFileMessage=function(e){var t=u(u({},ln),e);return D(pn(t)).throw(O.invalidParameters),this._sendFileMessage(t)},s.prototype.sendMultipleFilesMessage=function(e){var t,r=u(u({},ni),e),i=n.of(this._iid);D(function(e,t){return void 0===t&&(t=ie),$t(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return ri(e)}))}(r,null===(t=i.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(O.invalidParameters);var s=!!e.fileInfoList.find((function(e){var t=i.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return D(!s).throw(O.fileSizeLimitExceededError),this._sendMultipleFilesMessage(r)},s.prototype._sendFileMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid).dispatcher,a=ea.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new Xt;return Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u);s.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(r)]}))}))})),a.request(i,o,e).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u),a=n.of(i._iid).cacheContext,l=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,l),s.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:t.code===P.FILE_UPLOAD_CANCEL_FAILED?C.LOCAL_MESSAGE_CANCELED:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,r)]}))}))}))}))}))})),c},s.prototype._autoResendFileMessage=function(e){D(e instanceof St&&!!e.messageParams).throw(O.invalidParameters);var t=n.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,di.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},s.prototype._sendMultipleFilesMessage=function(e,t,r){var i=this,s=n.of(this._iid).dispatcher,a=ea.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new ii;return Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);s.dispatch(new N({messages:[n],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(n)]}))}))})),a.request(i,o,e,{requestHandler:c,isCopy:t===di.COPY}).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);i._markMessageAsFailed(n,t),s.dispatch(new N({messages:[n],source:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,n)]}))}))}))}))}))})),c},s.prototype._createScheduledFileMessage=function(e,t,r,i){var s=this,a=n.of(this._iid).requestQueue,o=new Ar(u(u({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(Ur).message;ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var a=s._createPendingScheduledFileMessage(e,r,i);s._markMessageAsFailed(a,n),ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,a)]}))}))}))}))}))},s.prototype.sendFileMessages=function(e){var t,n;D(e.every((function(e){return pn(u(u({},ln),e))}))).throw(O.invalidParameters);var r=new Xt;try{for(var i=v(e),s=i.next();!s.done;s=i.next()){var a=s.value;this.sendFileMessage(a).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{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},s.prototype.resendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){return n=this._validateFailedFileMessageHasFile(e,t),D(e instanceof St&&n&&!e.scheduledInfo).throw(O.invalidParameters),r=new V,i=fn(e,t),this._sendFileMessage(i,di.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),[2,r.promise]}))}))},s.prototype.resendMessage=function(e,t){var n,r;if(D(e instanceof mt&&!e.scheduledInfo&&e.isResendable).throw(O.invalidParameters),e.isUserMessage()){var i=null!==(n=e.messageParams)&&void 0!==n?n:sn(e);return this._sendUserMessage(i,di.RESEND,e.reqId)}if(e.isFileMessage()){var s=this._validateFailedFileMessageHasFile(e,t);D(s).throw(O.invalidParameters);i=null!==(r=e.messageParams)&&void 0!==r?r:fn(e,t);return this._sendFileMessage(i,di.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.updateFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},gn),t),D(h("number",e)&&function(e){return vn(e)}(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new yr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(_r).message]}}))}))},s.prototype.uploadFile=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=n.of(this._iid).requestQueue,r=se(),(i=new Pe({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:r})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(r),[4,t.send(i)];case 1:return s=c.sent(),a=s.as(ke),o=a.url,u=a.thumbnails,[2,{requestId:r,url:o,thumbnails:u}]}}))}))},s.prototype.cancelUploadingFileMessage=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),ea.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},s.prototype.copyFileMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof St&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),o=new V,c=t(u(u({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=n.thumbnails)||void 0===a?void 0:a.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(c).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.copyMessage=function(e,t){D(e instanceof s&&t instanceof mt&&t.sendingStatus===k.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(O.invalidParameters);var n=t,r=e;if(n.isUserMessage()){D(!n.poll).throw(O.notSupportedError);var i=nn(n);return r._sendUserMessage(i)}if(n.isFileMessage()){i=dn(n);return r._sendFileMessage(i)}if(t.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.deleteMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(e instanceof pt).throw(O.invalidParameters),e.messageId>0?(t=n.of(this._iid).requestQueue,r=new de({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof mt?e._messageToken:void 0}),[4,t.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},s.prototype.addReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new gr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(br).reactionEvent]}}))}))},s.prototype.deleteReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Ir({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Er).reactionEvent]}}))}))},s.prototype._updateUserMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new mr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(vr).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype._updateFileMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new yr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(_r).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype.createMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new je({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},s.prototype.deleteMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new je({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},s.prototype.addMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof je}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},s.prototype.removeMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof je}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},s.prototype.report=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return D(f(hn,e)&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new lr({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:t}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.reportUser=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof c&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new dr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.userId,category:t,description:r}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.reportMessage=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof mt&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new hr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:t,description:r,messageToken:e._messageToken}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.updatePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(h("number",e)&&function(e){return h("string",e.title,!0)&&te(e.data)&&h("boolean",e.allowUserSuggestion,!0)&&h("boolean",e.allowMultipleVotes,!0)&&h("number",e.closeAt,!0)}(t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Nr(u({pollId:e},t)),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Cr).poll]}}))}))},s.prototype.deletePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i;return U(this,(function(s){switch(s.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Or({pollId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},s.prototype.closePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Pr({pollId:e}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(kr).poll]}}))}))},s.prototype.addPollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=h("number",e)&&h("string",t)&&""!==t.trim(),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Rr({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(xr).poll]}}))}))},s.prototype.updatePollOption=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return i=h("number",e)&&h("number",t)&&h("string",r)&&""!==r.trim(),D(i).throw(O.invalidParameters),s=n.of(this._iid).requestQueue,a=new Dr({pollId:e,pollOptionId:t,optionText:r}),[4,s.send(a)];case 1:return o=u.sent(),[2,o.as(Lr).poll]}}))}))},s.prototype.deletePollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return r=h("number",e)&&h("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Fr({pollId:e,pollOptionId:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},s.prototype.votePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a,o,u,c;return U(this,(function(l){switch(l.label){case 0:return r=h("number",e)&&d("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid),s=i.requestQueue,a=i.dispatcher,o=new qr({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(zr).event,a.dispatch(new he({event:c,source:C.EVENT_POLL_VOTED})),[2,c]}}))}))},s.prototype.getPollChangeLogsSinceTimestamp=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("number",e)).throw(O.invalidParameters),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.getPollChangeLogsSinceToken=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("string",e,!0)),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new ce(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},s.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new le(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},s.prototype.pinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new ci({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s.prototype.unpinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new li({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s}(l),mi=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 r(t,e),t}((function(){this.onConnected=Y,this.onReconnectStarted=Y,this.onReconnectSucceeded=Y,this.onReconnectFailed=Y,this.onDisconnected=Y})),vi=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 r(t,e),t}((function(){this.onSessionExpired=Y,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=Y,this.onSessionRefreshed=Y,this.onSessionClosed=Y})),yi=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 r(t,e),t}((function(){this.onFriendsDiscovered=Y,this.onTotalUnreadMessageCountChanged=Y,this.onTotalUnreadMessageCountUpdated=Y})),_i=function(t){function n(n){var r=n.limit,s=n.token,a=n.userIdsFilter,o=n.metaDataKeyFilter,u=n.metaDataValuesFilter,c=n.nicknameStartsWithFilter,l=t.call(this)||this;return l.method=i.GET,l.path=pe,l.params=e({limit:r,token:s,user_ids:a,metadatakey:o,metadatavalues_in:u,nickname_startswith:c}),l}return r(n,t),n}(a),gi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),bi=function(e){function i(t,n){var r,i,s,a=this;return(a=e.call(this,t,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)&&h("string",this.metaDataKeyFilter,!0)&&d("string",this.metaDataValuesFilter,!0)&&h("string",this.nicknameStartsWithFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new _i(t(u(u({},this),{token:this._token}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(gi),a=s.users,o=s.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),Ii=function(t){function n(n){var r=n.userId,s=n.limit,a=n.token,o=n.userIdsFilter,u=t.call(this)||this;return u.method=i.GET,u.path="".concat(pe,"/").concat(r,"/block"),u.params=e({limit:s,token:a,user_ids:o}),u}return r(n,t),n}(a),Ei=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Ti=function(e){function i(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Ii(t(u(u({},this),{userId:r.userId,token:this._token}))),[4,i.send(s)]):[3,2]:[3,5];case 1:return a=d.sent(),o=a.as(Ei),c=o.users,l=o.next,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,c];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),wi=function(e){function t(t){var n=t.userId,r=t.limit,s=t.token,a=e.call(this)||this;return a.method=i.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(n),"/friends"),a.params={limit:r,token:s},a}return r(t,e),t}(a),Mi=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 c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Si=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),t=e.sdkState,r=e.requestQueue,i=new wi(u(u({},this),{userId:t.userId,token:this._token})),[4,r.send(i)]):[3,2]:[3,5];case 1:return s=d.sent(),a=s.as(Mi),o=a.users,c=a.hasMore,l=a.next,this._token=l,this._hasNext=c,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(me),Ai={},Ui=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,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,d=void 0===l?11:l,h=e.transactionApplyDelay,f=void 0===h?200:h,p=e.disableLogger,m=void 0!==p&&p;return Ai[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=c,this.blockHashConstant=d,this.transactionApplyDelay=f,this.disableLogger=m,Ai[t]=this),Ai[t]}return e.get=function(e){return Ai[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_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"}(fi||(fi={}));var Ni,Ci=function(e){function t(n){var r=n.code,i=void 0===r?fi.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 r(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:fi.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.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:fi.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:fi.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:fi.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:fi.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:fi.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:fi.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:fi.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:fi.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:fi.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:fi.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"}(Ni||(Ni={}));var Oi,Pi=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Ci.circularReferenceFound;t.set(e,!0);var n=void 0;if(Array.isArray(e))n=e.map((function(e){return Pi(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]=Pi(e[r],t);return t.delete(e),n}return e},ki=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Ci.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Ri=function(e,t){for(var n=0,r=0;r>>0)%t},xi=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Di=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!Di(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Di(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(!(ki(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(ki(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(ki(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(ki(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)},Li=function(){},Fi=function(){return Promise.resolve()},qi=function(e){return e},zi=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Oi||(Oi={}));var Bi,Ki,ji,Qi=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?qi:a,u=e.backward,c=void 0===u?Fi:u,l=e.forward,d=void 0===l?Fi:l,h=e.complete,f=void 0===h?Li:h;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=c,this._forward=d,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 A(this,void 0,void 0,(function(){var e,t,n;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(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}(),Gi=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 u in this.condition[s])if(o.includes(u))for(var c=r;c>=0;c--)if(a*ki(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(a*ki(this._indexer.origin[c].columnValues[i],this.condition[s])<=0){r=c;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var d=function(r){var i=h._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),h.condition[i])if("object"==typeof h.condition[i])Object.keys(h.condition[i]).forEach((function(a){if((s>0?t:n).includes(a))for(var o=l;o=0){l=o;break}}));else for(var a=l;a=0){l=a;break}},h=this,i=0;i-1){var r=this._items[n];return t===ji.PERSISTENT&&(r.state=Ki.PERSISTENT),t!==ji.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)ts.includes(this._items[r].state)&&ts.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 i=this._items.filter((function(e){return e.state===Ki.VOLATILE})),s=i.length-this._limit;if(s>0){var a=[];try{for(var o=v(this._items),u=o.next();!u.done;u=o.next()){var c=u.value;c.state===Ki.VOLATILE&&s>0?s--:a.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this._items=a}}}},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.clearForDatabase=function(e){this.clearByCondition((function(t){return t.key.startsWith(Hi(e))}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==Ki.VOLATILE}))},e}(),is=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(Wi(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(Wi(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=[]),A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,p([],m(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],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,c,l,d;return U(this,(function(h){switch(h.label){case 0:n=rs.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return u(u({},e.data),{generation:r})})))];case 2:for(a=h.sent(),o=0;o0))return[3,4];for(t=[],n={},o=e.length-1;o>=0;o--)r=e[o],l=r.data,n[l.key]||(n[l.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=p.sent(),[4,this._store.set({key:this.recordsetKey,value:s})];case 2:return p.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(p.sent(),a=rs.get(this.dbname),o=0;o0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=a.sent())&&(s=ss.createFromCacheItem(i),null==s?void 0:s.getItemByKey(e)))return[2,s];a.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return n=Ui.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,rs.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(null==(a=s?ss.createFromCacheItem(s):new ss({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:a.add(t))?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(this,(function(r){switch(r.label){case 0:return e=Ji(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(),rs.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),os={},us=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 u=function(e,t,n){return"".concat(Wi(e,t),"/index.").concat(n)}(t,n,i.join(">"));return os[u]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=u,this._transaction=s,this._store=a,this._transaction.on(Bi.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Bi.ERROR,this.indexerKey,(function(){return o.abort()}))),os[u]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in os)delete os[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=m(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=m(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var a=v(this.fields),o=a.next();!o.done;o=a.next()){var u=o.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw Ci.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=ki(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 A(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,y;return U(this,(function(_){switch(_.label){case 0:return[4,(e=rs.get(this.dbname)).find(this._store,this.indexerKey,ji.PERSISTENT)];case 1:return(t=_.sent())?[3,11]:(n=Ji(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=_.sent(),_.label=3;case 3:_.trys.push([3,8,9,10]),i=v(r),s=i.next(),_.label=4;case 4:return s.done?[3,7]:(a=s.value).startsWith(n)?[4,e.find(this._store,a,ji.NO_CACHE)]:[3,6];case 5:if(o=_.sent(),u=ss.createFromCacheItem(o))try{for(m=void 0,c=v(u.items),l=c.next();!l.done;l=c.next())d=l.value,this._addItem(d)}catch(e){m={error:e}}finally{try{l&&!l.done&&(y=c.return)&&y.call(c)}finally{if(m)throw m.error}}_.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return h=_.sent(),f={error:h},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=Pi(this._origin),_.label=12;case 12:return os[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return rs.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete os[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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=Pi(this._origin)},e.prototype.abort=function(){this._table=Pi(this._origin)},e}(),cs=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},ls=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"}($i||($i={})),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"}(es||(es={}));var ds,hs={},fs=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=$i.PROCESSING,this._queue=[],this._activationQueue=[],hs[e]&&!t.forceCreate||(this.nodeId=ls(),this.key=e,cs()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data;if(null==i?void 0:i.isNestDbMessage){var s=i.nodeId,a=i.requestId,o=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&o===n.key)switch(u){case es.NEWNODE:n._sendSync();break;case es.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case es.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,d=l.currentItemRequestId,h=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:es.REQUEST_LOCK,ts:e.ts})};try{for(var p=v(h),m=p.next();!m.done;m=p.next()){f(m.value)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case es.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case es.REQUEST_LOCK:n._requestLock(i);break;case es.ACQUIRE_LOCK:var y=n._queue.find((function(e){return e.requestId===a}));n._acquire(y);break;case es.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(es.REMOVENODE)}))),hs[e]=this),hs[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==$i.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:ls(),key:this.key,op:e,data:t.data,ts:Date.now()};return cs()&&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(es.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(es.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(es.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 A(this,void 0,void 0,(function(){var e=this;return U(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=$i.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(es.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(es.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(es.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}(),ps=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=Ni.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=p([[r]],m(s.filter((function(e){return us.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new fs(function(e,t){return"".concat(Wi(e,t),".lock")}(t,n)),this._blobContainer=new Zi({dbname:t,collectionName:n,store:a}),this._transaction=new is({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return r=Yi(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===Ni.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,y,_=this;return U(this,(function(g){switch(g.label){case 0:return[4,this._mutex.lock()];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,9,,10]),t=Ui.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=g.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:g.sent(),this._blockManager=new as({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=p([],m(this.indexes),!1),i=[],s=r.map((function(e){return us.createKey(e)})),a=n?n.indexes.map((function(e){return us.createKey(e)})):[];try{for(o=v(a),u=o.next();!u.done;u=o.next())c=u.value,s.includes(c)||i.push(us.parseKey(c))}catch(e){f={error:e}}finally{try{u&&!u.done&&(y=o.return)&&y.call(o)}finally{if(f)throw f.error}}return(l=[]).push.apply(l,p([],m(r.map((function(e){var t=new us({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,p([],m(i.map((function(e){return new us({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return g.sent(),[4,this._transaction.commit()];case 6:return g.sent(),s.sort().join(",")===a.sort().join(",")?[3,8]:(d=Yi(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:d,value:this._metadata})]);case 7:g.sent(),g.label=8;case 8:return this._state=Ni.READY,this._mutex.unlock(),[3,10];case 9:throw h=g.sent(),this._mutex.unlock(),h;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Ni.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=us.createKey(e);try{for(var i=v(this._indexers),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===us.createKey(a.fields))return a}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw Ci.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return e=Yi(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return o.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return o.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return o.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:o.sent(),o.label=5;case 5:o.trys.push([5,10,11,12]),n=v(this._indexers),r=n.next(),o.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:o.sent(),o.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=o.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw Ci.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=v(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),a=v(this._indexers),o=a.next(),p.label=16;case 16:return o.done?[3,20]:0===(u=o.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return o=a.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),h={error:c},[3,23];case 22:try{o&&!o.done&&(f=a.return)&&f.call(a)}finally{if(h)throw h.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=v(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return a=c.sent(),o={error:a},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=o.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:o.sent(),o.label=3;case 3:o.trys.push([3,8,9,10]),n=v(this._indexers),r=n.next(),o.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:o.sent(),o.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=o.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return U(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=v(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(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,Pi(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Ci.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new Vi({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ci.collectionNotReady},e.prototype.insertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestInsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpdate(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p,m,y=this;return U(this,(function(_){switch(_.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:_.sent(),_.label=2;case 2:return _.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,a=e.backward,o=void 0!==a&&a,u=[],[4,new Gi({condition:r,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(s)}).each((function(e){return A(y,void 0,void 0,(function(){var n,i;return U(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Di(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];else t.set(n);u.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:_.sent(),_.label=4;case 4:_.trys.push([4,9,10,11]),c=v(u),l=c.next(),_.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestUpdate(Pi(d))]);case 6:_.sent(),_.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return h=_.sent(),p={error:h},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return _.sent(),this._mutex.unlock(),[2,u];case 13:return f=_.sent(),[4,this._transaction.clear()];case 14:throw _.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),Ci.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m=this;return U(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,a=void 0!==s&&s,o=[],[4,new Gi({condition:n,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(i)}).each((function(e){return A(m,void 0,void 0,(function(){var t,r;return U(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Di(n,t)&&(r=t[this.keyName],o.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=v(o),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return d=y.sent(),f={error:d},[3,11];case 10:try{c&&!c.done&&(p=u.return)&&p.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,o];case 13:throw h=y.sent(),this._mutex.unlock(),h;case 14:return[3,16];case 15:throw this._transaction.clear(),Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),ms="[NESTDB]",vs=!0,ys=function(){function e(){}return e.off=function(){vs=!1},e.log=function(){for(var e=[],t=0;t1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return A(o,void 0,void 0,(function(){var n,i;return U(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw Ci.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}}))}))})))]:[3,4];case 3:return a=u.sent(),[3,5];case 4:a=[r],u.label=5;case 5:return s=a,[2,this.encryption.decrypt(JSON.parse(s.join("")))];case 6:return u.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,u({},e.value)]}}))}))},e.prototype.setMany=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,p([],m(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a=this;return U(this,(function(o){switch(o.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=o.sent())?(r=n.metadata,i=this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return a._getRawKey(e,".".concat(t))})),[4,this._removeRaw(i)]):[3,3];case 2:return o.sent(),null==(s=rs.get(this.dbname))||s.remove(e),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d=this;return U(this,(function(h){switch(h.label){case 0:t=rs.get(this.dbname),n=[],r=function(e){var r,s,a;return U(this,(function(o){switch(o.label){case 0:return r=i._getRawKey(e,".0"),[4,i._getRaw(r)];case 1:return(s=o.sent())&&(a=s.metadata,n.push.apply(n,p([],m(i._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return d._getRawKey(e,".".concat(t))}))),!1))),null==t||t.remove(e),[2]}}))},i=this,h.label=1;case 1:h.trys.push([1,6,7,8]),s=v(e),a=s.next(),h.label=2;case 2:return a.done?[3,5]:(o=a.value,[5,r(o)]);case 3:h.sent(),h.label=4;case 4:return a=s.next(),[3,2];case 5:return[3,8];case 6:return u=h.sent(),c={error:u},[3,8];case 7:try{a&&!a.done&&(l=s.return)&&l.call(s)}finally{if(c)throw c.error}return[7];case 8:return n.length>0?[4,this._removeRaw(n)]:[3,10];case 9:h.sent(),h.label=10;case 10:return[2,e]}}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){return null==(e=rs.get(this.dbname))||e.clearForDatabase(this.dbname),[2]}))}))},e}(),bs={},Is=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,u(u({},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 r(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return bs[this.dbname]},set:function(e){bs[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(bs[this.dbname])return[2,Object.keys(bs[this.dbname])];throw Ci.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return bs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:return t.sent(),[2,bs[this.dbname][e]?u({key:e},bs[this.dbname][e]):null];case 2:throw Ci.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return bs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:c.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,s=r.data,a=r.metadata,bs[this.dbname][i]=Object.freeze({data:s,metadata:a})}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}}return[3,3];case 2:throw Ci.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return bs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:a.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,bs[this.dbname][r]&&delete bs[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw Ci.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 A(this,void 0,void 0,(function(){return U(this,(function(e){return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,bs[this.dbname]||(bs[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.set=function(t){return A(this,void 0,void 0,(function(){var n,r;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u;return U(this,(function(c){try{for(n=v(t),r=n.next();!r.done;r=n.next())if(i=r.value,(s=this.observer[i.key])&&"function"==typeof s.set&&(a=s.set()))throw a}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return t.sent(),[4,xi(this.delay)];case 2:return t.sent(),bs[this.dbname]={},[2]}}))}))},t}(gs),Es="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(ds||(ds={}));var Ts,ws=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=Es,r._state=ds.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 r(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype.isTransactionInactiveError=function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")},t.prototype._putToObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.put(t);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))]}))}))},t.prototype._deleteFromObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.delete(t);i.addEventListener("success",(function(){return n(t)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))]}))}))},t.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=ds.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Es,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=ds.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=ds.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=ds.UNINITIALIZED,r(e.target.error)}))}else r(Ci.storeNotAvailable)}))},t.prototype._getObjectStore=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 ds.UNINITIALIZED:case ds.OPEN:return[3,2];case ds.OPENING:case ds.CLOSED:return[3,3]}return[3,4];case 2:throw Ci.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 A(this,void 0,void 0,(function(){var e;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._putToObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._putToObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._deleteFromObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._deleteFromObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){var e,t=this;return U(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||!cs())return[3,4];if(!(cs()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Ci.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(Ci.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),t._indexedDb){var i=t._indexedDb.deleteDatabase("_testMozilla");i.onerror=function(){return e()},i.onsuccess=function(){return e()}}else n(Ci.storeNotAvailable)}}catch(e){n(Ci.storeNotAvailableInPrivateBrowsing)}else n(Ci.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Ci.storeNotAvailable;case 5:return[3,7];case 6:throw Ci.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(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(),[4,this._resetIfEncryptionChanged()];case 3:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this._getObjectStore("readwrite")];case 2:return t=n.sent(),[4,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 3:return[2,n.sent()]}}))}))},t}(gs),Ms=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?2097152:i,a=ye(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,u(u({},a),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:t=[];try{for(n=v(e),r=n.next();!r.done;r=n.next())i=r.value,s=i.key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(s),JSON.stringify(i)])}catch(e){a={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return u.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._asyncStorage)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}}))}))},t}(gs),Ss=function(e){function t(t){var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._mmkv)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}}))}))},t}(gs);!function(e){e.INIT="INIT",e.OPENING="OPENING",e.OPENED="OPENED",e.CLOSED="CLOSED"}(Ts||(Ts={}));var As,Us=function(){function e(e){var t=e.name,n=e.version,r=e.store,i=e.config;this.name=t,this._version=n,this._state=Ts.INIT,this._config=i||new Ui({dbname:t}),this._store=r,this._event={success:Li,error:Li,storeReplaced:Li,upgrade:zi},this._collections=new Map,this._globalMutex=new fs("".concat(this.name,".lock")),this._config.disableLogger&&ys.off(),new rs({dbname:t,limit:this._config.cacheLimit})}return Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),e.prototype.estimateUsage=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,(t=this._store,A(void 0,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,t.usage()];case 1:return[2,e.sent()]}}))})))];case 1:return[2,e.sent()]}var t}))}))},e.prototype.commitSchema=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this._state!==Ts.OPENING?[3,2]:[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=e.collectionName,n=e.keyName,r=e.index,i=void 0===r?[]:r,this._collections.has(t)||this._collections.set(t,new ps({dbname:this.name,collectionName:t,keyName:n,indexes:i,store:this._store})),(s=this._collections.get(t))?[4,s.init()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[3,3];case 2:throw Ci.databaseSchemaNotOnUpgrade;case 3:return[2]}}))}))},e.prototype.open=function(){var e;return A(this,void 0,void 0,(function(){var t,n,r,i,s=this;return U(this,(function(a){switch(a.label){case 0:return[4,this._globalMutex.lock()];case 1:if(a.sent(),this._state===Ts.OPENED)return[3,12];this._state=Ts.OPENING,a.label=2;case 2:return a.trys.push([2,5,,12]),[4,this._store.init(this.name)];case 3:return a.sent(),o=this.name,t="".concat(Hi(o),".metadata"),n={version:0,collectionNames:[]},[4,this._store.get(t)];case 4:return r=null!==(e=a.sent())&&void 0!==e?e:n,[2,new Promise((function(e,n){var i=function(e){r.version0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof mt))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof pt)switch(this.replyType){case H.NONE:if(e.parentMessageId>0)return!1;break;case H.ONLY_REPLY_TO_CHANNEL:if(e instanceof mt&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Ns||(Ns={}));var Ps,ks=function(e){switch(e){case Ns.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Ns.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Rs=function(){return["channelUrl","-createdAt","-notificationId"]},xs=u(u({},tn),{scheduledAt:void 0}),Ds=function(e){return an(e)&&h("number",e.scheduledAt,!0)},Ls=u(u({},Zt),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Fs=function(e){return $t(e)&&h("number",e.scheduledAt)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},qs="UnsentMessage",zs="reqId",Bs={},Ks=function(t){function i(e){var n=t.call(this,e)||this;return n._mutex=new fs("unsendmessagecache.lock"),Bs[e]=n,n}return r(i,t),Object.defineProperty(i.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),i.of=function(e,t){return void 0===t&&(t=!1),Bs[e]&&!t||(Bs[e]=new i(e)),Bs[e]},Object.defineProperty(i.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(qs);if(!t)throw O.databaseError;return t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),i.prototype._serialize=function(t){if(t.messageId>0)throw O.invalidParameters;var n,r=u({},t.serialize());return t instanceof It?(t.messageParams&&(r.messageParams=en(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=(n=t.scheduledInfo.scheduledMessageParams,u(u({},en(n)),{scheduledAt:n.scheduledAt})))):t instanceof St?(t.messageParams&&(r.messageParams=cn(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=function(e){return u(u({},cn(e)),{scheduledAt:e.scheduledAt})}(t.scheduledInfo.scheduledMessageParams))):t instanceof Et&&t.messageParams&&(r.messageParams=function(t){return e({fileInfoList:t.fileInfoList,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption})}(t.messageParams)),r},i.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),ea.of(this._iid).buildMessageFromSerializedData(e)},i.prototype._deserializeWithMessageCreateParams=function(e){var t,n,r;return A(this,void 0,void 0,(function(){var i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return i=ea.of(this._iid),s=this._deserialize(e),e.messageParams?s instanceof It?(o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),[3,6]):[3,1]:[3,6];case 1:return s instanceof St?(o=e.messageParams).fileKey&&"string"==typeof o.fileKey&&un(null!==(t=o.fileType)&&void 0!==t?t:"")?(a=o,[4,this.collection.getBlob(o.fileKey)]):[3,3]:[3,4];case 2:a.file=null!==(n=d.sent())&&void 0!==n?n:void 0,d.label=3;case 3:return s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(o,s),[3,6];case 4:return s instanceof Et&&((o=e.messageParams)&&o.fileInfoList)?(s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(o,s),[4,Promise.all(s.messageParams.fileInfoList.map((function(e){return A(l,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&un(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!==(s=a.sent())&&void 0!==s?s:void 0,a.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:d.sent(),d.label=6;case 6:return s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?s instanceof It?(u=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(u,s),[3,10]):[3,7]:[3,10];case 7:return s instanceof St?(u=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof u.fileKey&&"string"==typeof u.fileType&&un(u.fileType)?(c=u,[4,this.collection.getBlob(u.fileKey)]):[3,9]:[3,10];case 8:c.file=null!==(r=d.sent())&&void 0!==r?r:void 0,d.label=9;case 9:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(u,s),d.label=10;case 10:return[2,s]}}))}))},i.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},i.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new Os:n,i=e.order,s=void 0===i?Ns.CHANNEL_LATEST:i,a=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return A(this,void 0,void 0,(function(){var e,n,i,o,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?(e=ks(s),n={"/where":function(e){return!!(s!==Ns.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(l._deserialize(e))}},t&&(n.channelUrl=t),a&&(n.sendingStatus=a),i={where:n,index:e,backward:u},[4,this.collection.query(i)]):[3,3];case 1:return[4,d.sent().fetch({})];case 2:return o=d.sent(),[2,Promise.all(o.map((function(e){return A(l,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},i.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Os),A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:Ns.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},i.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return e instanceof St||e instanceof Et?[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]}}))}))},i.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},i.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.saveBlob=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i=this;return U(this,(function(s){switch(s.label){case 0:return e instanceof St?e.messageParams&&(r=e.messageParams).file&&on(r.file)?[4,this.collection.saveBlob(r.file,e.reqId)]:[3,2]:[3,5];case 1:n=s.sent(),r.fileKey=n,r.fileType=rn.BLOB,s.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&on(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=s.sent(),t.fileKey=n,t.fileType=rn.BLOB,s.label=4;case 4:return[3,7];case 5:return e instanceof Et&&((r=e.messageParams)&&r.fileInfoList&&Array.isArray(r.fileInfoList))?[4,Promise.all(r.fileInfoList.map((function(t,n){return A(i,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return t.file&&on(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=rn.BLOB,i.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},i}(l),js={},Qs=function(e){function t(t){var n=e.call(this,t)||this;return js[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Ks.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),js[e]&&!n||(js[e]=new t(e)),js[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Gr)},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 u(u({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),ea.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Os:s,o=e.order,u=void 0===o?Ns.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,d=e.parentMessageId,h=e.isPollOnly,f=void 0!==h&&h,p=e.exactMatch,m=void 0!==p&&p,v=e.inclusive,y=void 0===v||v;return A(this,void 0,void 0,(function(){var e,r,s,o=this;return U(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=ks(u),r={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Ns.CHANNEL_LATEST:if(m&&e.createdAt!==n)return!1;if(l){if(y&&e.createdAtn||!y&&e.createdAt>=n)return!1;break;case Ns.NEWEST_CHILD_MESSAGE:if(!d||0===e.parentMessageId||e.parentMessageId!==d)return!1}return!(f&&!e._poll)&&a.match(o._deserialize(e))}},index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({limit:null!=i?i:void 0})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return A(o,void 0,void 0,(function(){return U(this,(function(t){return[2,this._deserialize(e)]}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Os),A(this,void 0,void 0,(function(){return U(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:Ns.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,13];case 1:d.sent(),d.label=2;case 2:d.trys.push([2,7,8,9]),n=v(e),r=n.next(),d.label=3;case 3:return r.done?[3,6]:(i=r.value,(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)?[4,this.get(i.messageId)]:[3,5]);case 4:(null==(s=d.sent())?void 0:s.threadInfo)&&i.threadInfo._updateFrom(s.threadInfo),d.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return a=d.sent(),u={error:a},[3,9];case 8:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 9:return o=e.map((function(e){return l._serialize(e)})),[4,this.collection.upsertMany(o)];case 10:return d.sent(),[4,this.upsertChildMessages(e)];case 11:return d.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 12:d.sent(),d.label=13;case 13:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:ks(Ns.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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:ks(Ns.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=ks(Ns.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 A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return e instanceof St&&e.messageParams&&((t=e.messageParams).file&&on(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.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=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return s=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return a=o.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),s&&(t+=JSON.stringify(s).length),a&&(t+=JSON.stringify(a).length),[2,t]}}))}))},t}(l),Gs={},Vs=function(e){function t(t){var n=e.call(this,t)||this;return Gs[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),Gs[e]&&!n||(Gs[e]=new t(e)),Gs[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Wr)},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 u({},e.serialize())},t.prototype._deserialize=function(e){return ea.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Os:s,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,d=e.inclusive,h=void 0===d||d;return A(this,void 0,void 0,(function(){var e,r=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(e={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(h&&e.createdAtn||!h&&e.createdAt>=n)return!1}return a.match(r._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},[4,this.collection.query(e)]):[3,3];case 1:return[4,s.sent().fetch({limit:null!=i?i:void 0})];case 2:return[2,s.sent().map((function(e){return r._deserialize(e)}))];case 3:return[2,[]]}}))}))},t.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?(t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.markAsReadByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,messageStatus:ft.SENT,createdAt:{"<":t}}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.markAsReadByMessageIds=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:ft.SENT}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:return[2,n.sent().length];case 2:return[2,0]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]})]:[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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:ks(Ns.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=["channelUrl","-createdAt","-notificationId"],[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}(l),Hs={},Ws=function(e){function t(t){var n=e.call(this,t)||this;return n._observers=new Map,n._dispatcherContext=n._dispatcher.on((function(e){return A(n,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,v,y,_,g,b=this;return U(this,(function(E){switch(E.label){case 0:return e instanceof N?(t=e.messages,g=e.source,a=e.isWebSocketEventComing,n=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&e.messageId>0})),r=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&0===e.messageId})),i=t.filter((function(e){return e instanceof Tt})),n.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(n)];case 1:return e.sent(),[4,this._unsentMessageCache.remove(n.map((function(e){return e instanceof mt?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,7];case 1:E.sent(),a||this._broadcastUpdateEvent(n,g),E.label=2;case 2:return r.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.upsert(r)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:E.sent(),a||this._broadcastUpdateEvent(r,g),E.label=4;case 4:return i.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._notificationCache.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,6];case 5:E.sent(),a||this._broadcastUpdateEvent(i,g),E.label=6;case 6:return[3,24];case 7:return e instanceof we?(s=e.messageIds,g=e.source,a=e.isWebSocketEventComing,o=s.filter((function(e){return"number"==typeof e})),u=s.filter((function(e){return"string"==typeof e})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return o.length>0?[4,this._messageCache.remove(o)]:[3,2];case 1:e.sent(),e.label=2;case 2:return u.length>0?[4,this._notificationCache.remove(u)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))}))]):[3,9];case 8:return E.sent(),a||this._broadcastRemoveEvent(s,g),[3,24];case 9:return e instanceof Te?(c=e.reqId,g=e.source,[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.remove([c])];case 1:return e.sent(),[2]}}))}))}))]):[3,11];case 10:return E.sent(),this._broadcastRemoveUnsentEvent(c,g),[3,24];case 11:return e instanceof Ee?(l=e.polls,g=e.source,this._cacheContext.localCacheEnabled?(d=l.map((function(e){return e.messageId})),[4,Promise.all(d.map((function(e){return b._messageCache.get(e)})))]):[3,14]):[3,15];case 12:return(h=E.sent().filter((function(e){return e}))).length>0&&l.forEach((function(e){var t=h.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(h)];case 1:return[2,e.sent()]}}))}))}))];case 13:E.sent(),E.label=14;case 14:return this._broadcastPollChangeLogEvent(l,g),[3,24];case 15:return e instanceof Ie?(f=e.event,g=e.source,[4,this._messageCache.get(f.messageId)]):[3,19];case 16:return(p=E.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollUpdateEvent(f)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([p])];case 1:return[2,e.sent()]}}))}))}))]:[3,18];case 17:E.sent(),E.label=18;case 18:return this._broadcastPollUpdateEvent(f,g),[3,24];case 19:return e instanceof he?(m=e.event,g=e.source,[4,this._messageCache.get(m.messageId)]):[3,23];case 20:return(v=E.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(m)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,22];case 21:E.sent(),E.label=22;case 22:return this._broadcastPollVoteEvent(m,g),[3,24];case 23:e instanceof _e?(y=e.event,g=e.source,y.messageId>0&&this._broadcastReactionUpdateEvent(y,g)):e instanceof ge&&(_=e.event,g=e.source,this._broadcastThreadUpdateEvent(_,g)),E.label=24;case 24:return[2]}}))}))})),n}return r(t,e),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dispatcher",{get:function(){return n.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_messageCache",{get:function(){return Qs.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Ks.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_notificationCache",{get:function(){return Vs.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){var r;return void 0===n&&(n=!1),Hs[e]&&!n||(Hs[e]&&(null===(r=Hs[e]._dispatcherContext)||void 0===r||r.close()),Hs[e]=new t(e)),Hs[e]},t.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemove&&a.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastReactionUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastThreadUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype.subscribe=function(e,t){this._observers.set(e,t)},t.prototype.unsubscribe=function(e){this._observers.delete(e)},t.prototype.unsubscribeAll=function(){this._observers.clear()},t}(l),Ys=function(t){function n(n){var r=this,s=n.reverse,a=void 0!==s&&s,o=n.limit,u=void 0===o?20:o,c=n.keys,l=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(Me),r.params=e({token:l,limit:u,reverse:a,order:Se.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),r}return r(n,t),n}(a),Js=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.next,s=n.has_more,a=void 0!==s&&s,o=n.templates;return r.nextToken=i,r.hasMore=a,r.templates=o.map((function(e){return{template:JSON.stringify(e)}})),r}return r(t,e),t}(o),Xs=function(e){function t(t){var n=this,r=t.key;return(n=e.call(this)||this).method=i.GET,n.path="".concat(Me,"/").concat(r),n}return r(t,e),t}(a),Zs=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.template=JSON.stringify(n),r}return r(t,e),t}(o),$s={},ea=function(){function n(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=a,Qs.of(e),Ks.of(e),Ws.of(e),this.fileMessageQueue=new Rt(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),$s[e]=this}return n.of=function(e){return $s[e]},n.prototype.buildMessageFromSerializedData=function(e){var t=Ae(e);if(t.notificationId)return new Tt(this._iid,Tt.payloadify(t));switch(t.messageType){case g.USER:return new It(this._iid,It.payloadify(t));case g.FILE:return Et._isMultipleFilesMessageSerializedData(t)?new Et(this._iid,Et.payloadify(t)):new St(this._iid,St.payloadify(t));case g.ADMIN:return new _t(this._iid,_t.payloadify(t))}throw O.invalidParameters},n.prototype.buildUserMessageCreateParamsFromSerializedData=function(n,r){return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,message:r.message,translationTargetLanguages:Object.keys(r.translations),pollId:n.pollId}))},n.prototype.buildFileMessageCreateParamsFromSerializedData=function(n,r){var i;return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,file:n.file,fileKey:n.fileKey,fileUrl:r.plainUrl,fileName:r.name,fileSize:r.size,mimeType:r.type,thumbnailSizes:null===(i=r.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:n.fileType,requireAuth:r.requireAuth}))},n.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(t,n){var r=this;return e({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUserIds:n.mentionedUserIds,mentionedUsers:n.mentionedUsers,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption,appleCriticalAlertOptions:n.appleCriticalAlertOptions,reqId:n.reqId,fileInfoList:t.fileInfoList.map((function(e){return new At(r._iid,e)}))})},n.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildSenderFromSerializedData=function(e){var t=Ae(e);return new Ke(this._iid,Ke.payloadify(t))},n.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new zt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Bt).message]}}))}))},n.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Vt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Ht).message]}}))}))},n.prototype.getMessagesByMessageId=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new Kt(u(u({channelType:t,channelUrl:e,token:String(n)},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(jt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype.getMessagesByTimestamp=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new Kt(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(jt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype._getMessagesByTimestampForCollection=function(e,t,n,r,i,s,a){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var o,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return o=new Kt(u(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r),{checkingHasNext:s,checkingContinuousMessages:a})),[4,this._requestQueue.send(o)];case 1:return c=p.sent(),l=c.as(jt),d=l.messages,h=l.isContinuousMessages,f=l.hasNext,this._dispatcher.dispatch(new N({messages:d,source:i})),[2,{messages:d,isContinuousMessages:h,hasNext:f}]}}))}))},n.prototype.getThreadedMessagesByTimestamp=function(e,t,n,r){return void 0===r&&(r=C.REQUEST_THREADED_MESSAGE),A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return i=new Kt(u(u(u({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},vt),n),{replyType:H.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return s=c.sent(),a=s.as(jt).messages,(o=a.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new N({messages:o,source:r})),[2,{parentMessage:a[0],threadedMessages:o}]}}))}))},n.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return n=new Ys(u({token:e},t)),[4,this._requestQueue.send(n)];case 1:return r=c.sent(),i=r.as(Js),s=i.hasMore,a=i.nextToken,o=i.templates,[2,{hasMore:s,token:a,templates:o}]}}))}))},n.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Xs({key:e}),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,{template:n.as(Zs).template}]}}))}))},n.prototype.getMessageChangelogs=function(n,r,i,s,a){return void 0===a&&(a=C.REQUEST_MESSAGE_CHANGELOGS),A(this,void 0,void 0,(function(){var o,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return o=new Qt(e(t(u(u({channelType:r,channelUrl:n,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},Ft),s)))),[4,this._requestQueue.send(o)];case 1:return c=v.sent(),l=c.as(Gt),d=l.updatedMessages,h=l.deletedMessagesInfo,f=l.hasMore,p=l.nextToken,m=h.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new N({messages:d,source:a})),m.length>0&&this._dispatcher.dispatch(new we({messageIds:m,source:a})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:f,token:p}]}}))}))},n}(),ta=function(e){function t(t,n){var r=e.call(this,t)||this;r.targetMessageId=0;var i=n.thread_info,s=n.parent_message_id,a=n.channel_url,o=n.channel_type;return i&&h("object",i)&&h("number",s)&&h("string",a)&&h("string",o)&&(r.threadInfo=new Re(t,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return r(t,e),t}(l),na={channelUrl:"",channelType:I.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},ra=function(e){function t(t){var n=t.channelCustomType,r=t.keyword,s=t.limit,a=t.reverse,o=t.exactMatch,u=t.channelUrl,c=t.order,l=t.messageTimestampFrom,d=t.messageTimestampTo,h=t.advancedQuery,f=t.targetFields,p=t.nextToken,m=e.call(this)||this;return m.method=i.GET,m.path="".concat(Ue,"/messages"),m.params={custom_type:n,query:r,limit:s,reverse:a,exact_match:o,channel_url:u,message_ts_from:l,message_ts_to:d,sort_field:c,advanced_query:h,target_fields:f,after:p},m}return r(t,e),t}(a),ia=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return Mt(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return r(t,e),t}(o);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Ps||(Ps={}));var sa=function(e){function i(t,n){var r,i,s,a,o,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Ps.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(a=n.channelCustomType)&&void 0!==a?a:"",h.messageTimestampFrom=null!==(o=n.messageTimestampFrom)&&void 0!==o?o:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:Ps.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&h("string",this.keyword)&&this.keyword.length>0&&h("boolean",this.reverse)&&h("boolean",this.exactMatch)&&h("string",this.channelUrl)&&h("string",this.channelCustomType)&&(h("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(h("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&f(Ps,this.order)&&h("boolean",this.advancedQuery)&&d("string",this.targetFields,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new ra(t(u(u({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=d.sent(),s=i.as(ia),a=s.messages,o=s.hasNext,c=s.nextToken,l=s.totalCount,this._nextToken=c,this._hasNext=o,this._isLoading=!1,this.totalCount=l,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),aa=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.limit,u=r.token,c=n.call(this)||this;return c.method=i.GET,c.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages/parent_thread_message"),c.params=e(t({limit:o,token:u})),c}return r(s,n),s}(a),oa=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.next,r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),ua=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s._edge="",s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.load=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new aa({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(oa),s=i.messages,a=i.token,this._edge=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ca={channelUrl:"",scheduledMessageId:0},la={reverse:!1,limit:20},da=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return r(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new ea(t,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},t.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},t.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},t.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=u(u({},na),e),D(function(e){return h("string",e.channelUrl)&&f(I,e.channelType)&&h("number",e.messageId)&&h("boolean",e.includeReactions,!0)&&h("boolean",e.includeMetaArray,!0)&&h("boolean",e.includeParentMessageInfo,!0)&&h("boolean",e.includeThreadInfo,!0)}(t)).throw(O.invalidParameters),[4,this._manager.getMessage(t)];case 1:if((n=r.sent())instanceof pt||n instanceof Tt||null===n)return[2,n];throw"Unknown message type is given."}}))}))},t.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){return t=u(u({},ca),e),D(function(e){return h("string",e.channelUrl)&&""!==e.channelUrl&&h("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(O.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},t.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return n=u(u({},la),t),D(h("string",e,!0)&&function(e){return h("boolean",e.reverse,!0)&&h("number",e.limit,!0)&&d("string",e.keys,!0)}(n)).throw(O.invalidParameters),[2,this._manager.getMessageTemplatesByToken(e,n)]}))}))},t.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),[2,this._manager.getMessageTemplate(e)]}))}))},t}(Ne);export{It as $,Ms as A,Ti as B,mi as C,Sn as D,gt as E,Si as F,Yt as G,Wt as H,ws as I,xt as J,Os as K,Cs as L,Ns as M,Gr as N,En as O,Jt as P,Br as Q,hn as R,vi as S,Mt as T,yi as U,ut as V,si as W,ui as X,Ve as Y,ct as Z,ot as _,Kr as a,Ce as a$,St as a0,ta as a1,Re as a2,Xn as a3,zn as a4,cr as a5,or as a6,sr as a7,tr as a8,rr as a9,di as aA,fn as aB,nn as aC,dn as aD,ti as aE,Xt as aF,He as aG,Sr as aH,hi as aI,ke as aJ,Pe as aK,Ws as aL,_t as aM,De as aN,Zr as aO,Vs as aP,Hr as aQ,ft as aR,Je as aS,We as aT,bt as aU,Ps as aV,Et as aW,Fe as aX,qe as aY,Tn as aZ,Le as a_,zr as aa,pt as ab,Ye as ac,mt as ad,vr as ae,_r as af,pr as ag,Ct as ah,Qr as ai,Tt as aj,ea as ak,mn as al,vn as am,yn as an,_n as ao,Oe as ap,je as aq,ze as ar,wt as as,ua as at,ii as au,xs as av,Ds as aw,Ls as ax,Fs as ay,sn as az,jr as b,Ke as b0,at as b1,Be as b2,xe as b3,lt as b4,dt as b5,st as b6,Vr as c,qs as d,zs as e,Jr as f,ks as g,Xr as h,$r as i,ei as j,Wr as k,Yr as l,Rs as m,As as n,Is as o,Ss as p,da as q,bi as r,sa as s,Qs as t,Ks as u,Ts as v,Us as w,Ui as x,Nn as y,pi as z}; diff --git a/lib/__definition.d.ts b/lib/__definition.d.ts index d31cb4e..812edef 100644 --- a/lib/__definition.d.ts +++ b/lib/__definition.d.ts @@ -6,8 +6,6 @@ import type { MMKV } from 'react-native-mmkv'; * @description Object representing an admin message. */ export declare class AdminMessage extends BaseMessage { - /** The message text of the message. */ - message: string; /** The translated messages (key-value map) for the language codes in key. */ translations: object; /** @@ -839,6 +837,8 @@ export declare class BaseMessage extends MessagePrototype { myFeedbackStatus: FeedbackStatus; /** The form of the message. */ messageForm: MessageForm | null; + /** The message text of the message. */ + message: string; isIdentical(message: BaseMessage): boolean; /** * @param threadInfoUpdateEvent @@ -1558,6 +1558,8 @@ export declare interface FileMessageCreateParams extends BaseMessageCreateParams mimeType?: string; /** The file's thumbnail sizes of the message. */ thumbnailSizes?: ThumbnailSize[]; + /** The message text of the message. */ + message?: string; } /** @@ -2816,6 +2818,7 @@ export declare class MultipleFilesMessage extends SendableMessage { export declare interface MultipleFilesMessageCreateParams extends BaseMessageCreateParams { /** The list of uploadable file information. */ fileInfoList: UploadableFileInfo[]; + message?: string; } /** @@ -4523,6 +4526,7 @@ export declare enum SendbirdErrorCode { COLLECTION_DISPOSED = 800600, DATABASE_ERROR = 800700, USER_DEACTIVATED = 900021, + CHANNEL_IS_FROZEN = 900050, RECEIVER_USER_DEACTIVATED = 900081, } @@ -4885,8 +4889,6 @@ declare abstract class UserEventHandlerParams { * @description Object representing a user message. */ export declare class UserMessage extends SendableMessage { - /** The message text of the message. */ - message: string; /** The messageParams object that used for sending this message For more details. */ messageParams: UserMessageCreateParams | null; /** The translated messages (key-value map) for the language codes in key. */ diff --git a/message.js b/message.js index 4cd6b0a..a14c9aa 100644 --- a/message.js +++ b/message.js @@ -1 +1 @@ -export{aj as MentionType,a$ as MessageReviewStatus,ah as MessageType,aq as MessageTypeFilter,at as PushNotificationDeliveryOption,ay as ReplyType,ao as SendingStatus}from"./lib/__bundle-1db3fd0b.js";export{aM as AdminMessage,ar as AppleCriticalAlertOptions,ab as BaseMessage,b2 as Feedback,b3 as FeedbackRating,a0 as FileMessage,b4 as MessageForm,b5 as MessageFormItem,b6 as MessageFormItemLayout,aq as MessageMetaArray,q as MessageModule,aF as MessageRequestHandler,aU as MessageReviewInfo,aV as MessageSearchOrder,s as MessageSearchQuery,aW as MultipleFilesMessage,au as MultipleFilesMessageRequestHandler,aX as OGImage,aY as OGMetaData,aZ as PreviousMessageListQuery,a_ as Reaction,aN as ReactionEvent,a$ as ReactionEventOperation,b0 as Sender,a2 as ThreadInfo,a1 as ThreadInfoUpdateEvent,at as ThreadedParentMessageListQuery,ap as Thumbnail,b1 as UploadedFileInfo,$ as UserMessage}from"./lib/__bundle-e1a5e3f1.js"; +export{aj as MentionType,a$ as MessageReviewStatus,ah as MessageType,aq as MessageTypeFilter,at as PushNotificationDeliveryOption,ay as ReplyType,ao as SendingStatus}from"./lib/__bundle-c03282ec.js";export{aM as AdminMessage,ar as AppleCriticalAlertOptions,ab as BaseMessage,b2 as Feedback,b3 as FeedbackRating,a0 as FileMessage,b4 as MessageForm,b5 as MessageFormItem,b6 as MessageFormItemLayout,aq as MessageMetaArray,q as MessageModule,aF as MessageRequestHandler,aU as MessageReviewInfo,aV as MessageSearchOrder,s as MessageSearchQuery,aW as MultipleFilesMessage,au as MultipleFilesMessageRequestHandler,aX as OGImage,aY as OGMetaData,aZ as PreviousMessageListQuery,a_ as Reaction,aN as ReactionEvent,a$ as ReactionEventOperation,b0 as Sender,a2 as ThreadInfo,a1 as ThreadInfoUpdateEvent,at as ThreadedParentMessageListQuery,ap as Thumbnail,b1 as UploadedFileInfo,$ as UserMessage}from"./lib/__bundle-45809bc9.js"; diff --git a/node.js b/node.js index 563a3fa..729c017 100644 --- a/node.js +++ b/node.js @@ -1 +1 @@ -import{g as e}from"./lib/__bundle-d33aa991.js";import"./lib/__bundle-46d64517.js";import t from"events";import s from"https";import r from"http";import i from"net";import o from"tls";import n from"crypto";import a from"stream";import c from"url";import h from"zlib";import l from"fs";import d from"path";import f from"os";import u from"buffer";var _={exports:{}};const p=["nodebuffer","arraybuffer","fragments"],m="undefined"!=typeof Blob;m&&p.push("blob");var v={BINARY_TYPES:p,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:m,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}};e(v);var y={exports:{}};function b(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var g,S,w,E,k,x,T={exports:{}};function O(){if(w)return T.exports;w=1;const e="function"==typeof __webpack_require__?__non_webpack_require__:b;return"function"==typeof e.addon?T.exports=e.addon.bind(e):T.exports=function(){if(S)return g;S=1;var e=l,t=d,s=f,r="function"==typeof __webpack_require__?__non_webpack_require__:b,i=process.config&&process.config.variables||{},o=!!process.env.PREBUILDS_ONLY,n=process.versions.modules,a=process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":process.versions&&process.versions.nw?"node-webkit":"node",c=process.env.npm_config_arch||s.arch(),h=process.env.npm_config_platform||s.platform(),u=process.env.LIBC||(function(t){return"linux"===t&&e.existsSync("/etc/alpine-release")}(h)?"musl":"glibc"),_=process.env.ARM_VERSION||("arm64"===c?"8":i.arm_version)||"",p=(process.versions.uv||"").split(".")[0];function m(e){return r(m.resolve(e))}function v(t){try{return e.readdirSync(t)}catch(e){return[]}}function y(e,s){var r=v(e).filter(s);return r[0]&&t.join(e,r[0])}function w(e){return/\.node$/.test(e)}function E(e){var t=e.split("-");if(2===t.length){var s=t[0],r=t[1].split("+");if(s&&r.length&&r.every(Boolean))return{name:e,platform:s,architectures:r}}}function k(e,t){return function(s){return null!=s&&s.platform===e&&s.architectures.includes(t)}}function x(e,t){return e.architectures.length-t.architectures.length}function T(e){var t=e.split("."),s={file:e,specificity:0};if("node"===t.pop()){for(var r=0;rs.specificity?-1:1:0}}return g=m,m.resolve=m.path=function(e){e=t.resolve(e||".");try{var s=r(t.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[s+"_PREBUILD"]&&(e=process.env[s+"_PREBUILD"])}catch(e){}if(!o){var i=y(t.join(e,"build/Release"),w);if(i)return i;var l=y(t.join(e,"build/Debug"),w);if(l)return l}var d=b(e);if(d)return d;var f=b(t.dirname(process.execPath));if(f)return f;var m=["platform="+h,"arch="+c,"runtime="+a,"abi="+n,"uv="+p,_?"armv="+_:"","libc="+u,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"","function"==typeof __webpack_require__?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+m+"\n loaded from: "+e+"\n");function b(e){var s=v(t.join(e,"prebuilds")).map(E).filter(k(h,c)).sort(x)[0];if(s){var r=t.join(e,"prebuilds",s.name),i=v(r).map(T).filter(O(a,n)).sort(C(a))[0];return i?t.join(r,i.file):void 0}}},m.parseTags=T,m.matchTags=O,m.compareTags=C,m.parseTuple=E,m.matchTuple=k,m.compareTuples=x,g}(),T.exports}const{EMPTY_BUFFER:C}=v,N=Buffer[Symbol.species];function L(e,t,s,r,i){for(let o=0;o{for(var o=0;o{const s=e.length;for(var r=0;r{this.pending--,this[U]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[U]()}[U](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[R])}}};e(I);const D=h,W=B,M=I,{kStatusCode:A}=v,F=Buffer[Symbol.species],j=Buffer.from([0,0,255,255]),$=Symbol("permessage-deflate"),G=Symbol("total-length"),V=Symbol("callback"),q=Symbol("buffers"),z=Symbol("error");let H;var Y=class{constructor(e,t,s){if(this._maxPayload=0|s,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!H){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;H=new M(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[V];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,s=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(s.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?s.client_max_window_bits=t.clientMaxWindowBits:!0!==s.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete s.client_max_window_bits,s}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let s=e[t];if(s.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(s=s[0],"client_max_window_bits"===t){if(!0!==s){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}else if("server_max_window_bits"===t){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==s)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}e[t]=s}))})),e}decompress(e,t,s){H.add((r=>{this._decompress(e,t,((e,t)=>{r(),s(e,t)}))}))}compress(e,t,s){H.add((r=>{this._compress(e,t,((e,t)=>{r(),s(e,t)}))}))}_decompress(e,t,s){const r=this._isServer?"client":"server";if(!this._inflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?D.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=D.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[$]=this,this._inflate[G]=0,this._inflate[q]=[],this._inflate.on("error",Z),this._inflate.on("data",K)}this._inflate[V]=s,this._inflate.write(e),t&&this._inflate.write(j),this._inflate.flush((()=>{const e=this._inflate[z];if(e)return this._inflate.close(),this._inflate=null,void s(e);const i=W.concat(this._inflate[q],this._inflate[G]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[G]=0,this._inflate[q]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),s(null,i)}))}_compress(e,t,s){const r=this._isServer?"server":"client";if(!this._deflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?D.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=D.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[G]=0,this._deflate[q]=[],this._deflate.on("data",X)}this._deflate[V]=s,this._deflate.write(e),this._deflate.flush(D.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=W.concat(this._deflate[q],this._deflate[G]);t&&(e=new F(e.buffer,e.byteOffset,e.length-4)),this._deflate[V]=null,this._deflate[G]=0,this._deflate[q]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),s(null,e)}))}};function X(e){this[q].push(e),this[G]+=e.length}function K(e){this[G]+=e.length,this[$]._maxPayload<1||this[G]<=this[$]._maxPayload?this[q].push(e):(this[z]=new RangeError("Max payload size exceeded"),this[z].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[z][A]=1009,this.removeListener("data",K),this.reset())}function Z(e){this[$]._inflate=null,e[A]=1007,this[V](e)}e(Y);var J={exports:{}};const{isUtf8:Q}=u,{hasBlob:ee}=v;function te(e){const t=e.length;let s=0;for(;s=t||128!=(192&e[s+1])||128!=(192&e[s+2])||224===e[s]&&128==(224&e[s+1])||237===e[s]&&160==(224&e[s+1]))return!1;s+=3}else{if(240!=(248&e[s]))return!1;if(s+3>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||128!=(192&e[s+3])||240===e[s]&&128==(240&e[s+1])||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}else s++;return!0}if(J.exports={isBlob:function(e){return ee&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&("Blob"===e[Symbol.toStringTag]||"File"===e[Symbol.toStringTag])},isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:te,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},Q)J.exports.isValidUTF8=function(e){return e.length<24?te(e):Q(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const e=require("utf-8-validate");J.exports.isValidUTF8=function(t){return t.length<32?te(t):e(t)}}catch(e){}var se=J.exports;e(se);const{Writable:re}=a,ie=Y,{BINARY_TYPES:oe,EMPTY_BUFFER:ne,kStatusCode:ae,kWebSocket:ce}=v,{concat:he,toArrayBuffer:le,unmask:de}=B,{isValidStatusCode:fe,isValidUTF8:ue}=se,_e=Buffer[Symbol.species];var pe=class extends re{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||oe[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[ce]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,s){if(8===this._opcode&&0==this._state)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=new _e(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(48&t[0]){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const s=!(64&~t[0]);if(!s||this._extensions[ie.extensionName]){if(this._fin=!(128&~t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=s}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~t[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}else{e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),s=t.readUInt32BE(0);if(s>Math.pow(2,21)-1){e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}else this._payloadLength=s*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}else this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=ne;if(this._payloadLength){if(this._bufferedBytes7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[ie.extensionName].decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(s)}this.dataMessage(t),0===this._state&&this.startLoop(t)}))}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let r;r="nodebuffer"===this._binaryType?he(s,t):"arraybuffer"===this._binaryType?le(he(s,t)):"blob"===this._binaryType?new Blob(s):s,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!0),this._state=0,this.startLoop(e)})))}else{const r=he(s,t);if(!this._skipUTF8Validation&&!ue(r)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!1),this._state=0,this.startLoop(e)})))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate((()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)})));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,ne),this.end();else{const s=e.readUInt16BE(0);if(!fe(s)){const e=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const r=new _e(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ue(r)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",s,r),this.end()}this._state=0}}createError(e,t,s,r,i){this._loop=!1,this._errored=!0;const o=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=i,o[ae]=r,o}};e(pe);const{randomFillSync:me}=n,ve=Y,{EMPTY_BUFFER:ye,kWebSocket:be,NOOP:ge}=v,{isBlob:Se,isValidStatusCode:we}=se,{mask:Ee,toBuffer:ke}=B,xe=Symbol("kByteLength"),Te=Buffer.alloc(4),Oe=8192;let Ce,Ne=Oe;class Le{constructor(e,t,s){this._extensions=t||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=ge,this[be]=void 0}static frame(e,t){let s,r,i=!1,o=2,n=!1;t.mask&&(s=t.maskBuffer||Te,t.generateMask?t.generateMask(s):(Ne===Oe&&(void 0===Ce&&(Ce=Buffer.alloc(Oe)),me(Ce,0,Oe),Ne=0),s[0]=Ce[Ne++],s[1]=Ce[Ne++],s[2]=Ce[Ne++],s[3]=Ce[Ne++]),n=!(s[0]|s[1]|s[2]|s[3]),o=6),"string"==typeof e?r=t.mask&&!n||void 0===t[xe]?(e=Buffer.from(e)).length:t[xe]:(r=e.length,i=t.mask&&t.readOnly&&!n);let a=r;r>=65536?(o+=8,a=127):r>125&&(o+=2,a=126);const c=Buffer.allocUnsafe(i?r+o:o);return c[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(c[0]|=64),c[1]=a,126===a?c.writeUInt16BE(r,2):127===a&&(c[2]=c[3]=0,c.writeUIntBE(r,4,6)),t.mask?(c[1]|=128,c[o-4]=s[0],c[o-3]=s[1],c[o-2]=s[2],c[o-1]=s[3],n?[c,e]:i?(Ee(e,s,c,o,r),[c]):(Ee(e,s,e,0,r),[c,e])):[c,e]}close(e,t,s,r){let i;if(void 0===e)i=ye;else{if("number"!=typeof e||!we(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const s=Buffer.byteLength(t);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+s),i.writeUInt16BE(e,0),"string"==typeof t?i.write(t,2):i.set(t,2)}else i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0)}const o={[xe]:i.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,i,!1,o,r]):this.sendFrame(Le.frame(i,o),r)}ping(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):Se(e)?(r=e.size,i=!1):(r=(e=ke(e)).length,i=ke.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[xe]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};Se(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(Le.frame(e,o),s)}pong(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):Se(e)?(r=e.size,i=!1):(r=(e=ke(e)).length,i=ke.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[xe]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};Se(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(Le.frame(e,o),s)}send(e,t,s){const r=this._extensions[ve.extensionName];let i,o,n=t.binary?2:1,a=t.compress;"string"==typeof e?(i=Buffer.byteLength(e),o=!1):Se(e)?(i=e.size,o=!1):(i=(e=ke(e)).length,o=ke.readOnly),this._firstFragment?(this._firstFragment=!1,a&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=i>=r._threshold),this._compress=a):(a=!1,n=0),t.fin&&(this._firstFragment=!0);const c={[xe]:i,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:o,rsv1:a};Se(e)?0!==this._state?this.enqueue([this.getBlobData,e,this._compress,c,s]):this.getBlobData(e,this._compress,c,s):0!==this._state?this.enqueue([this.dispatch,e,this._compress,c,s]):this.dispatch(e,this._compress,c,s)}getBlobData(e,t,s,r){this._bufferedBytes+=s[xe],this._state=2,e.arrayBuffer().then((e=>{if(this._socket.destroyed){const e=new Error("The socket was closed while the blob was being read");return void process.nextTick(Be,this,e,r)}this._bufferedBytes-=s[xe];const i=ke(e);t?this.dispatch(i,t,s,r):(this._state=0,this.sendFrame(Le.frame(i,s),r),this.dequeue())})).catch((e=>{process.nextTick(Re,this,e,r)}))}dispatch(e,t,s,r){if(!t)return void this.sendFrame(Le.frame(e,s),r);const i=this._extensions[ve.extensionName];this._bufferedBytes+=s[xe],this._state=1,i.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){Be(this,new Error("The socket was closed while data was being compressed"),r)}else this._bufferedBytes-=s[xe],this._state=0,s.readOnly=!1,this.sendFrame(Le.frame(t,s),r),this.dequeue()}))}dequeue(){for(;0===this._state&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][xe],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][xe],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}var Pe=Le;function Be(e,t,s){"function"==typeof s&&s(t);for(let s=0;s{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let s,r,i=Object.create(null),o=!1,n=!1,a=!1,c=-1,h=-1,l=-1,d=0;for(;d0&&e.unshift(t),e.on("close",Yt),e.on("data",Xt),e.on("end",Kt),e.on("error",Zt),this._readyState=Lt.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=Lt.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[ct.extensionName]&&this._extensions[ct.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=Lt.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==Lt.CLOSED)if(this.readyState!==Lt.CONNECTING)this.readyState!==Lt.CLOSING?(this._readyState=Lt.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),Ht(this)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";Dt(this,this._req,e)}}pause(){this.readyState!==Lt.CONNECTING&&this.readyState!==Lt.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,s){if(this.readyState===Lt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===Lt.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||ut,t,s)):Wt(this,e,s)}pong(e,t,s){if(this.readyState===Lt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===Lt.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||ut,t,s)):Wt(this,e,s)}resume(){this.readyState!==Lt.CONNECTING&&this.readyState!==Lt.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,s){if(this.readyState===Lt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(s=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==Lt.OPEN)return void Wt(this,e,s);const r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[ct.extensionName]||(r.compress=!1),this._sender.send(e||ut,r,s)}terminate(){if(this.readyState!==Lt.CLOSED)if(this.readyState!==Lt.CONNECTING)this._socket&&(this._readyState=Lt.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";Dt(this,this._req,e)}}}Object.defineProperty(Lt,"CONNECTING",{enumerable:!0,value:Ct.indexOf("CONNECTING")}),Object.defineProperty(Lt.prototype,"CONNECTING",{enumerable:!0,value:Ct.indexOf("CONNECTING")}),Object.defineProperty(Lt,"OPEN",{enumerable:!0,value:Ct.indexOf("OPEN")}),Object.defineProperty(Lt.prototype,"OPEN",{enumerable:!0,value:Ct.indexOf("OPEN")}),Object.defineProperty(Lt,"CLOSING",{enumerable:!0,value:Ct.indexOf("CLOSING")}),Object.defineProperty(Lt.prototype,"CLOSING",{enumerable:!0,value:Ct.indexOf("CLOSING")}),Object.defineProperty(Lt,"CLOSED",{enumerable:!0,value:Ct.indexOf("CLOSED")}),Object.defineProperty(Lt.prototype,"CLOSED",{enumerable:!0,value:Ct.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(Lt.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(Lt.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[pt])return t[mt];return null},set(t){for(const t of this.listeners(e))if(t[pt]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[pt]:!0})}})})),Lt.prototype.addEventListener=gt,Lt.prototype.removeEventListener=St;var Pt=Lt;function Bt(e,t,s,r){const i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Ot[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,!Ot.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Ot.join(", ")})`);let o;if(t instanceof at)o=t;else try{o=new at(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===o.protocol?o.protocol="ws:":"https:"===o.protocol&&(o.protocol="wss:"),e._url=o.href;const n="wss:"===o.protocol,a="ws+unix:"===o.protocol;let c;if("ws:"===o.protocol||n||a?a&&!o.pathname?c="The URL's pathname is empty":o.hash&&(c="The URL contains a fragment identifier"):c='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"',c){const t=new SyntaxError(c);if(0===e._redirects)throw t;return void Rt(e,t)}const h=n?443:80,l=ot(16).toString("base64"),d=n?tt.request:st.request,f=new Set;let u,_;if(i.createConnection=i.createConnection||(n?It:Ut),i.defaultPort=i.defaultPort||h,i.port=o.port||h,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(u=new ct(!0!==i.perMessageDeflate?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=wt({[ct.extensionName]:u.offer()})),s.length){for(const e of s){if("string"!=typeof e||!Nt.test(e)||f.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");f.add(e)}i.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(o.username||o.password)&&(i.auth=`${o.username}:${o.password}`),a){const e=i.path.split(":");i.socketPath=e[0],i.path=e[1]}if(i.followRedirects){if(0===e._redirects){e._originalIpc=a,e._originalSecure=n,e._originalHostOrSocketPath=a?i.socketPath:o.host;const t=r&&r.headers;if(r={...r,headers:{}},t)for(const[e,s]of Object.entries(t))r.headers[e.toLowerCase()]=s}else if(0===e.listenerCount("redirect")){const t=a?!!e._originalIpc&&i.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&o.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!n)&&(delete i.headers.authorization,delete i.headers.cookie,t||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),_=e._req=d(i),e._redirects&&e.emit("redirect",e.url,_)}else _=e._req=d(i);i.timeout&&_.on("timeout",(()=>{Dt(e,_,"Opening handshake has timed out")})),_.on("error",(t=>{null===_||_[Tt]||(_=e._req=null,Rt(e,t))})),_.on("response",(o=>{const n=o.headers.location,a=o.statusCode;if(n&&i.followRedirects&&a>=300&&a<400){if(++e._redirects>i.maxRedirects)return void Dt(e,_,"Maximum redirects exceeded");let o;_.abort();try{o=new at(n,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${n}`);return void Rt(e,s)}Bt(e,o,s,r)}else e.emit("unexpected-response",_,o)||Dt(e,_,`Unexpected server response: ${o.statusCode}`)})),_.on("upgrade",((t,s,r)=>{if(e.emit("upgrade",t),e.readyState!==Lt.CONNECTING)return;_=e._req=null;const o=t.headers.upgrade;if(void 0===o||"websocket"!==o.toLowerCase())return void Dt(e,s,"Invalid Upgrade header");const n=nt("sha1").update(l+_t).digest("base64");if(t.headers["sec-websocket-accept"]!==n)return void Dt(e,s,"Invalid Sec-WebSocket-Accept header");const a=t.headers["sec-websocket-protocol"];let c;if(void 0!==a?f.size?f.has(a)||(c="Server sent an invalid subprotocol"):c="Server sent a subprotocol but none was requested":f.size&&(c="Server sent no subprotocol"),c)return void Dt(e,s,c);a&&(e._protocol=a);const h=t.headers["sec-websocket-extensions"];if(void 0!==h){if(!u){return void Dt(e,s,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=Et(h)}catch(t){return void Dt(e,s,"Invalid Sec-WebSocket-Extensions header")}const r=Object.keys(t);if(1!==r.length||r[0]!==ct.extensionName){return void Dt(e,s,"Server indicated an extension that was not requested")}try{u.accept(t[ct.extensionName])}catch(t){return void Dt(e,s,"Invalid Sec-WebSocket-Extensions header")}e._extensions[ct.extensionName]=u}e.setSocket(s,r,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})})),i.finishRequest?i.finishRequest(_,e):_.end()}function Rt(e,t){e._readyState=Lt.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function Ut(e){return e.path=e.socketPath,rt.connect(e)}function It(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=rt.isIP(e.host)?"":e.host),it.connect(e)}function Dt(e,t,s){e._readyState=Lt.CLOSING;const r=new Error(s);Error.captureStackTrace(r,Dt),t.setHeader?(t[Tt]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(Rt,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Wt(e,t,s){if(t){const s=dt(t)?t.size:kt(t).length;e._socket?e._sender._bufferedBytes+=s:e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${Ct[e.readyState]})`);process.nextTick(s,t)}}function Mt(e,t){const s=this[yt];s._closeFrameReceived=!0,s._closeMessage=t,s._closeCode=e,void 0!==s._socket[yt]&&(s._socket.removeListener("data",Xt),process.nextTick(qt,s._socket),1005===e?s.close():s.close(e,t))}function At(){const e=this[yt];e.isPaused||e._socket.resume()}function Ft(e){const t=this[yt];void 0!==t._socket[yt]&&(t._socket.removeListener("data",Xt),process.nextTick(qt,t._socket),t.close(e[vt])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function jt(){this[yt].emitClose()}function $t(e,t){this[yt].emit("message",e,t)}function Gt(e){const t=this[yt];t._autoPong&&t.pong(e,!this._isServer,bt),t.emit("ping",e)}function Vt(e){this[yt].emit("pong",e)}function qt(e){e.resume()}function zt(e){const t=this[yt];t.readyState!==Lt.CLOSED&&(t.readyState===Lt.OPEN&&(t._readyState=Lt.CLOSING,Ht(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function Ht(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),xt)}function Yt(){const e=this[yt];let t;this.removeListener("close",Yt),this.removeListener("data",Xt),this.removeListener("end",Kt),e._readyState=Lt.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[yt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",jt),e._receiver.on("finish",jt))}function Xt(e){this[yt]._receiver.write(e)||this.pause()}function Kt(){const e=this[yt];e._readyState=Lt.CLOSING,e._receiver.end(),this.end()}function Zt(){const e=this[yt];this.removeListener("error",Zt),this.on("error",bt),e&&(e._readyState=Lt.CLOSING,this.destroy())}e(Pt);const{Duplex:Jt}=a;function Qt(e){e.emit("close")}function es(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ts(e){this.removeListener("error",ts),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}var ss=function(e,t){let s=!0;const r=new Jt({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,s){const i=!s&&r._readableState.objectMode?t.toString():t;r.push(i)||e.pause()})),e.once("error",(function(e){r.destroyed||(s=!1,r.destroy(e))})),e.once("close",(function(){r.destroyed||r.push(null)})),r._destroy=function(t,i){if(e.readyState===e.CLOSED)return i(t),void process.nextTick(Qt,r);let o=!1;e.once("error",(function(e){o=!0,i(e)})),e.once("close",(function(){o||i(t),process.nextTick(Qt,r)})),s&&e.terminate()},r._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){r._final(t)}))},r._read=function(){e.isPaused&&e.resume()},r._write=function(t,s,i){e.readyState!==e.CONNECTING?e.send(t,i):e.once("open",(function(){r._write(t,s,i)}))},r.on("end",es),r.on("error",ts),r};e(ss);const{tokenChars:rs}=se;var is={parse:function(e){const t=new Set;let s=-1,r=-1,i=0;for(;i{const s=ns.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),t.end(s)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function(){for(const s of Object.keys(t))e.removeListener(s,t[s])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(ms,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(ms,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{ms(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,r){t.on("error",vs);const i=e.headers["sec-websocket-key"],o=e.headers.upgrade,n=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void bs(this,e,t,405,"Invalid HTTP method")}if(void 0===o||"websocket"!==o.toLowerCase()){return void bs(this,e,t,400,"Invalid Upgrade header")}if(void 0===i||!_s.test(i)){return void bs(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==n&&13!==n){return void bs(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void ys(t,400);const a=e.headers["sec-websocket-protocol"];let c=new Set;if(void 0!==a)try{c=ls.parse(a)}catch(s){return void bs(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const h=e.headers["sec-websocket-extensions"],l={};if(this.options.perMessageDeflate&&void 0!==h){const s=new hs(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=cs.parse(h);e[hs.extensionName]&&(s.accept(e[hs.extensionName]),l[hs.extensionName]=s)}catch(s){return void bs(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const o={origin:e.headers[""+(8===n?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(o,((o,n,a,h)=>{if(!o)return ys(t,n||401,a,h);this.completeUpgrade(l,i,c,e,t,s,r)}));if(!this.options.verifyClient(o))return ys(t,401)}this.completeUpgrade(l,i,c,e,t,s,r)}completeUpgrade(e,t,s,r,i,o,n){if(!i.readable||!i.writable)return i.destroy();if(i[us])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return ys(i,503);const a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${as("sha1").update(t+fs).digest("base64")}`],c=new this.options.WebSocket(null,void 0,this.options);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;e&&(a.push(`Sec-WebSocket-Protocol: ${e}`),c._protocol=e)}if(e[hs.extensionName]){const t=e[hs.extensionName].params,s=cs.format({[hs.extensionName]:[t]});a.push(`Sec-WebSocket-Extensions: ${s}`),c._extensions=e}this.emit("headers",a,r),i.write(a.concat("\r\n").join("\r\n")),i.removeListener("error",vs),c.setSocket(i,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(c),c.on("close",(()=>{this.clients.delete(c),this._shouldEmitClose&&!this.clients.size&&process.nextTick(ms,this)}))),n(c,r)}};function ms(e){e._state=2,e.emit("close")}function vs(){this.destroy()}function ys(e,t,s,r){s=s||ns.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${ns.STATUS_CODES[t]}\r\n`+Object.keys(r).map((e=>`${e}: ${r[e]}`)).join("\r\n")+"\r\n\r\n"+s)}function bs(e,t,s,r,i){if(e.listenerCount("wsClientError")){const r=new Error(i);Error.captureStackTrace(r,bs),e.emit("wsClientError",r,s,t)}else ys(s,r,i)}e(ps);const gs=Pt;gs.createWebSocketStream=ss,gs.Server=ps,gs.Receiver=pe,gs.Sender=Pe,gs.WebSocket=gs,gs.WebSocketServer=gs.Server;var Ss=gs;e(Ss);var ws="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{WebSocket:null};ws.WebSocket||(ws.WebSocket=Ss.WebSocket); +import{g as e}from"./lib/__bundle-d33aa991.js";import"./lib/__bundle-46d64517.js";import t from"events";import s from"https";import r from"http";import i from"net";import o from"tls";import n from"crypto";import a from"stream";import c from"url";import h from"zlib";import l from"fs";import d from"path";import f from"os";import u from"buffer";var _={exports:{}};const p=["nodebuffer","arraybuffer","fragments"],m="undefined"!=typeof Blob;m&&p.push("blob");var v={BINARY_TYPES:p,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:m,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}};e(v);var y={exports:{}};function b(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var g,S,w,E,k,x,T={exports:{}};function O(){if(w)return T.exports;w=1;const e="function"==typeof __webpack_require__?__non_webpack_require__:b;return"function"==typeof e.addon?T.exports=e.addon.bind(e):T.exports=function(){if(S)return g;S=1;var e=l,t=d,s=f,r="function"==typeof __webpack_require__?__non_webpack_require__:b,i=process.config&&process.config.variables||{},o=!!process.env.PREBUILDS_ONLY,n=process.versions.modules,a=process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":process.versions&&process.versions.nw?"node-webkit":"node",c=process.env.npm_config_arch||s.arch(),h=process.env.npm_config_platform||s.platform(),u=process.env.LIBC||(function(t){return"linux"===t&&e.existsSync("/etc/alpine-release")}(h)?"musl":"glibc"),_=process.env.ARM_VERSION||("arm64"===c?"8":i.arm_version)||"",p=(process.versions.uv||"").split(".")[0];function m(e){return r(m.resolve(e))}function v(t){try{return e.readdirSync(t)}catch(e){return[]}}function y(e,s){var r=v(e).filter(s);return r[0]&&t.join(e,r[0])}function w(e){return/\.node$/.test(e)}function E(e){var t=e.split("-");if(2===t.length){var s=t[0],r=t[1].split("+");if(s&&r.length&&r.every(Boolean))return{name:e,platform:s,architectures:r}}}function k(e,t){return function(s){return null!=s&&s.platform===e&&s.architectures.includes(t)}}function x(e,t){return e.architectures.length-t.architectures.length}function T(e){var t=e.split("."),s={file:e,specificity:0};if("node"===t.pop()){for(var r=0;rs.specificity?-1:1:0}}return g=m,m.resolve=m.path=function(e){e=t.resolve(e||".");try{var s=r(t.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[s+"_PREBUILD"]&&(e=process.env[s+"_PREBUILD"])}catch(e){}if(!o){var i=y(t.join(e,"build/Release"),w);if(i)return i;var l=y(t.join(e,"build/Debug"),w);if(l)return l}var d=b(e);if(d)return d;var f=b(t.dirname(process.execPath));if(f)return f;var m=["platform="+h,"arch="+c,"runtime="+a,"abi="+n,"uv="+p,_?"armv="+_:"","libc="+u,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"","function"==typeof __webpack_require__?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+m+"\n loaded from: "+e+"\n");function b(e){var s=v(t.join(e,"prebuilds")).map(E).filter(k(h,c)).sort(x)[0];if(s){var r=t.join(e,"prebuilds",s.name),i=v(r).map(T).filter(O(a,n)).sort(C(a))[0];return i?t.join(r,i.file):void 0}}},m.parseTags=T,m.matchTags=O,m.compareTags=C,m.parseTuple=E,m.matchTuple=k,m.compareTuples=x,g}(),T.exports}const{EMPTY_BUFFER:C}=v,N=Buffer[Symbol.species];function L(e,t,s,r,i){for(let o=0;o{for(var o=0;o{const s=e.length;for(var r=0;r{this.pending--,this[U]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[U]()}[U](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[R])}}};e(I);const D=h,W=B,M=I,{kStatusCode:A}=v,F=Buffer[Symbol.species],j=Buffer.from([0,0,255,255]),$=Symbol("permessage-deflate"),G=Symbol("total-length"),V=Symbol("callback"),q=Symbol("buffers"),z=Symbol("error");let H;var Y=class{constructor(e,t,s){if(this._maxPayload=0|s,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!H){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;H=new M(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[V];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,s=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(s.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?s.client_max_window_bits=t.clientMaxWindowBits:!0!==s.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete s.client_max_window_bits,s}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let s=e[t];if(s.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(s=s[0],"client_max_window_bits"===t){if(!0!==s){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}else if("server_max_window_bits"===t){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==s)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}e[t]=s}))})),e}decompress(e,t,s){H.add((r=>{this._decompress(e,t,((e,t)=>{r(),s(e,t)}))}))}compress(e,t,s){H.add((r=>{this._compress(e,t,((e,t)=>{r(),s(e,t)}))}))}_decompress(e,t,s){const r=this._isServer?"client":"server";if(!this._inflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?D.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=D.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[$]=this,this._inflate[G]=0,this._inflate[q]=[],this._inflate.on("error",Z),this._inflate.on("data",K)}this._inflate[V]=s,this._inflate.write(e),t&&this._inflate.write(j),this._inflate.flush((()=>{const e=this._inflate[z];if(e)return this._inflate.close(),this._inflate=null,void s(e);const i=W.concat(this._inflate[q],this._inflate[G]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[G]=0,this._inflate[q]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),s(null,i)}))}_compress(e,t,s){const r=this._isServer?"server":"client";if(!this._deflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?D.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=D.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[G]=0,this._deflate[q]=[],this._deflate.on("data",X)}this._deflate[V]=s,this._deflate.write(e),this._deflate.flush(D.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=W.concat(this._deflate[q],this._deflate[G]);t&&(e=new F(e.buffer,e.byteOffset,e.length-4)),this._deflate[V]=null,this._deflate[G]=0,this._deflate[q]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),s(null,e)}))}};function X(e){this[q].push(e),this[G]+=e.length}function K(e){this[G]+=e.length,this[$]._maxPayload<1||this[G]<=this[$]._maxPayload?this[q].push(e):(this[z]=new RangeError("Max payload size exceeded"),this[z].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[z][A]=1009,this.removeListener("data",K),this.reset())}function Z(e){this[$]._inflate=null,e[A]=1007,this[V](e)}e(Y);var J={exports:{}};const{isUtf8:Q}=u,{hasBlob:ee}=v;function te(e){const t=e.length;let s=0;for(;s=t||128!=(192&e[s+1])||128!=(192&e[s+2])||224===e[s]&&128==(224&e[s+1])||237===e[s]&&160==(224&e[s+1]))return!1;s+=3}else{if(240!=(248&e[s]))return!1;if(s+3>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||128!=(192&e[s+3])||240===e[s]&&128==(240&e[s+1])||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}else s++;return!0}if(J.exports={isBlob:function(e){return ee&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&("Blob"===e[Symbol.toStringTag]||"File"===e[Symbol.toStringTag])},isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:te,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},Q)J.exports.isValidUTF8=function(e){return e.length<24?te(e):Q(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const e=require("utf-8-validate");J.exports.isValidUTF8=function(t){return t.length<32?te(t):e(t)}}catch(e){}var se=J.exports;e(se);const{Writable:re}=a,ie=Y,{BINARY_TYPES:oe,EMPTY_BUFFER:ne,kStatusCode:ae,kWebSocket:ce}=v,{concat:he,toArrayBuffer:le,unmask:de}=B,{isValidStatusCode:fe,isValidUTF8:ue}=se,_e=Buffer[Symbol.species];var pe=class extends re{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||oe[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[ce]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,s){if(8===this._opcode&&0==this._state)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=new _e(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(48&t[0]){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const s=!(64&~t[0]);if(!s||this._extensions[ie.extensionName]){if(this._fin=!(128&~t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=s}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~t[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}else{e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),s=t.readUInt32BE(0);if(s>Math.pow(2,21)-1){e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}else this._payloadLength=s*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}else this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=ne;if(this._payloadLength){if(this._bufferedBytes7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[ie.extensionName].decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(s)}this.dataMessage(t),0===this._state&&this.startLoop(t)}))}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let r;r="nodebuffer"===this._binaryType?he(s,t):"arraybuffer"===this._binaryType?le(he(s,t)):"blob"===this._binaryType?new Blob(s):s,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!0),this._state=0,this.startLoop(e)})))}else{const r=he(s,t);if(!this._skipUTF8Validation&&!ue(r)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!1),this._state=0,this.startLoop(e)})))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate((()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)})));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,ne),this.end();else{const s=e.readUInt16BE(0);if(!fe(s)){const e=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const r=new _e(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ue(r)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",s,r),this.end()}this._state=0}}createError(e,t,s,r,i){this._loop=!1,this._errored=!0;const o=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=i,o[ae]=r,o}};e(pe);const{randomFillSync:me}=n,ve=Y,{EMPTY_BUFFER:ye,kWebSocket:be,NOOP:ge}=v,{isBlob:Se,isValidStatusCode:we}=se,{mask:Ee,toBuffer:ke}=B,xe=Symbol("kByteLength"),Te=Buffer.alloc(4),Oe=8192;let Ce,Ne=Oe;class Le{constructor(e,t,s){this._extensions=t||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=ge,this[be]=void 0}static frame(e,t){let s,r,i=!1,o=2,n=!1;t.mask&&(s=t.maskBuffer||Te,t.generateMask?t.generateMask(s):(Ne===Oe&&(void 0===Ce&&(Ce=Buffer.alloc(Oe)),me(Ce,0,Oe),Ne=0),s[0]=Ce[Ne++],s[1]=Ce[Ne++],s[2]=Ce[Ne++],s[3]=Ce[Ne++]),n=!(s[0]|s[1]|s[2]|s[3]),o=6),"string"==typeof e?r=t.mask&&!n||void 0===t[xe]?(e=Buffer.from(e)).length:t[xe]:(r=e.length,i=t.mask&&t.readOnly&&!n);let a=r;r>=65536?(o+=8,a=127):r>125&&(o+=2,a=126);const c=Buffer.allocUnsafe(i?r+o:o);return c[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(c[0]|=64),c[1]=a,126===a?c.writeUInt16BE(r,2):127===a&&(c[2]=c[3]=0,c.writeUIntBE(r,4,6)),t.mask?(c[1]|=128,c[o-4]=s[0],c[o-3]=s[1],c[o-2]=s[2],c[o-1]=s[3],n?[c,e]:i?(Ee(e,s,c,o,r),[c]):(Ee(e,s,e,0,r),[c,e])):[c,e]}close(e,t,s,r){let i;if(void 0===e)i=ye;else{if("number"!=typeof e||!we(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const s=Buffer.byteLength(t);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+s),i.writeUInt16BE(e,0),"string"==typeof t?i.write(t,2):i.set(t,2)}else i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0)}const o={[xe]:i.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,i,!1,o,r]):this.sendFrame(Le.frame(i,o),r)}ping(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):Se(e)?(r=e.size,i=!1):(r=(e=ke(e)).length,i=ke.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[xe]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};Se(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(Le.frame(e,o),s)}pong(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):Se(e)?(r=e.size,i=!1):(r=(e=ke(e)).length,i=ke.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[xe]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};Se(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(Le.frame(e,o),s)}send(e,t,s){const r=this._extensions[ve.extensionName];let i,o,n=t.binary?2:1,a=t.compress;"string"==typeof e?(i=Buffer.byteLength(e),o=!1):Se(e)?(i=e.size,o=!1):(i=(e=ke(e)).length,o=ke.readOnly),this._firstFragment?(this._firstFragment=!1,a&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=i>=r._threshold),this._compress=a):(a=!1,n=0),t.fin&&(this._firstFragment=!0);const c={[xe]:i,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:o,rsv1:a};Se(e)?0!==this._state?this.enqueue([this.getBlobData,e,this._compress,c,s]):this.getBlobData(e,this._compress,c,s):0!==this._state?this.enqueue([this.dispatch,e,this._compress,c,s]):this.dispatch(e,this._compress,c,s)}getBlobData(e,t,s,r){this._bufferedBytes+=s[xe],this._state=2,e.arrayBuffer().then((e=>{if(this._socket.destroyed){const e=new Error("The socket was closed while the blob was being read");return void process.nextTick(Be,this,e,r)}this._bufferedBytes-=s[xe];const i=ke(e);t?this.dispatch(i,t,s,r):(this._state=0,this.sendFrame(Le.frame(i,s),r),this.dequeue())})).catch((e=>{process.nextTick(Re,this,e,r)}))}dispatch(e,t,s,r){if(!t)return void this.sendFrame(Le.frame(e,s),r);const i=this._extensions[ve.extensionName];this._bufferedBytes+=s[xe],this._state=1,i.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){Be(this,new Error("The socket was closed while data was being compressed"),r)}else this._bufferedBytes-=s[xe],this._state=0,s.readOnly=!1,this.sendFrame(Le.frame(t,s),r),this.dequeue()}))}dequeue(){for(;0===this._state&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][xe],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][xe],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}var Pe=Le;function Be(e,t,s){"function"==typeof s&&s(t);for(let s=0;s{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let s,r,i=Object.create(null),o=!1,n=!1,a=!1,c=-1,h=-1,l=-1,d=0;for(;d0&&e.unshift(t),e.on("close",Ht),e.on("data",Yt),e.on("end",Xt),e.on("error",Kt),this._readyState=Nt.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=Nt.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[ct.extensionName]&&this._extensions[ct.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=Nt.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==Nt.CLOSED)if(this.readyState!==Nt.CONNECTING)this.readyState!==Nt.CLOSING?(this._readyState=Nt.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),zt(this)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";It(this,this._req,e)}}pause(){this.readyState!==Nt.CONNECTING&&this.readyState!==Nt.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,s){if(this.readyState===Nt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===Nt.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||ut,t,s)):Dt(this,e,s)}pong(e,t,s){if(this.readyState===Nt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===Nt.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||ut,t,s)):Dt(this,e,s)}resume(){this.readyState!==Nt.CONNECTING&&this.readyState!==Nt.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,s){if(this.readyState===Nt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(s=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==Nt.OPEN)return void Dt(this,e,s);const r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[ct.extensionName]||(r.compress=!1),this._sender.send(e||ut,r,s)}terminate(){if(this.readyState!==Nt.CLOSED)if(this.readyState!==Nt.CONNECTING)this._socket&&(this._readyState=Nt.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";It(this,this._req,e)}}}Object.defineProperty(Nt,"CONNECTING",{enumerable:!0,value:Ot.indexOf("CONNECTING")}),Object.defineProperty(Nt.prototype,"CONNECTING",{enumerable:!0,value:Ot.indexOf("CONNECTING")}),Object.defineProperty(Nt,"OPEN",{enumerable:!0,value:Ot.indexOf("OPEN")}),Object.defineProperty(Nt.prototype,"OPEN",{enumerable:!0,value:Ot.indexOf("OPEN")}),Object.defineProperty(Nt,"CLOSING",{enumerable:!0,value:Ot.indexOf("CLOSING")}),Object.defineProperty(Nt.prototype,"CLOSING",{enumerable:!0,value:Ot.indexOf("CLOSING")}),Object.defineProperty(Nt,"CLOSED",{enumerable:!0,value:Ot.indexOf("CLOSED")}),Object.defineProperty(Nt.prototype,"CLOSED",{enumerable:!0,value:Ot.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(Nt.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(Nt.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[pt])return t[mt];return null},set(t){for(const t of this.listeners(e))if(t[pt]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[pt]:!0})}})})),Nt.prototype.addEventListener=gt,Nt.prototype.removeEventListener=St;var Lt=Nt;function Pt(e,t,s,r){const i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Tt[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,!Tt.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Tt.join(", ")})`);let o;if(t instanceof at)o=t;else try{o=new at(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===o.protocol?o.protocol="ws:":"https:"===o.protocol&&(o.protocol="wss:"),e._url=o.href;const n="wss:"===o.protocol,a="ws+unix:"===o.protocol;let c;if("ws:"===o.protocol||n||a?a&&!o.pathname?c="The URL's pathname is empty":o.hash&&(c="The URL contains a fragment identifier"):c='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"',c){const t=new SyntaxError(c);if(0===e._redirects)throw t;return void Bt(e,t)}const h=n?443:80,l=ot(16).toString("base64"),d=n?tt.request:st.request,f=new Set;let u,_;if(i.createConnection=i.createConnection||(n?Ut:Rt),i.defaultPort=i.defaultPort||h,i.port=o.port||h,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(u=new ct(!0!==i.perMessageDeflate?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=wt({[ct.extensionName]:u.offer()})),s.length){for(const e of s){if("string"!=typeof e||!Ct.test(e)||f.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");f.add(e)}i.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(o.username||o.password)&&(i.auth=`${o.username}:${o.password}`),a){const e=i.path.split(":");i.socketPath=e[0],i.path=e[1]}if(i.followRedirects){if(0===e._redirects){e._originalIpc=a,e._originalSecure=n,e._originalHostOrSocketPath=a?i.socketPath:o.host;const t=r&&r.headers;if(r={...r,headers:{}},t)for(const[e,s]of Object.entries(t))r.headers[e.toLowerCase()]=s}else if(0===e.listenerCount("redirect")){const t=a?!!e._originalIpc&&i.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&o.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!n)&&(delete i.headers.authorization,delete i.headers.cookie,t||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),_=e._req=d(i),e._redirects&&e.emit("redirect",e.url,_)}else _=e._req=d(i);i.timeout&&_.on("timeout",(()=>{It(e,_,"Opening handshake has timed out")})),_.on("error",(t=>{null===_||_[xt]||(_=e._req=null,Bt(e,t))})),_.on("response",(o=>{const n=o.headers.location,a=o.statusCode;if(n&&i.followRedirects&&a>=300&&a<400){if(++e._redirects>i.maxRedirects)return void It(e,_,"Maximum redirects exceeded");let o;_.abort();try{o=new at(n,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${n}`);return void Bt(e,s)}Pt(e,o,s,r)}else e.emit("unexpected-response",_,o)||It(e,_,`Unexpected server response: ${o.statusCode}`)})),_.on("upgrade",((t,s,r)=>{if(e.emit("upgrade",t),e.readyState!==Nt.CONNECTING)return;_=e._req=null;const o=t.headers.upgrade;if(void 0===o||"websocket"!==o.toLowerCase())return void It(e,s,"Invalid Upgrade header");const n=nt("sha1").update(l+_t).digest("base64");if(t.headers["sec-websocket-accept"]!==n)return void It(e,s,"Invalid Sec-WebSocket-Accept header");const a=t.headers["sec-websocket-protocol"];let c;if(void 0!==a?f.size?f.has(a)||(c="Server sent an invalid subprotocol"):c="Server sent a subprotocol but none was requested":f.size&&(c="Server sent no subprotocol"),c)return void It(e,s,c);a&&(e._protocol=a);const h=t.headers["sec-websocket-extensions"];if(void 0!==h){if(!u){return void It(e,s,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=Et(h)}catch(t){return void It(e,s,"Invalid Sec-WebSocket-Extensions header")}const r=Object.keys(t);if(1!==r.length||r[0]!==ct.extensionName){return void It(e,s,"Server indicated an extension that was not requested")}try{u.accept(t[ct.extensionName])}catch(t){return void It(e,s,"Invalid Sec-WebSocket-Extensions header")}e._extensions[ct.extensionName]=u}e.setSocket(s,r,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})})),i.finishRequest?i.finishRequest(_,e):_.end()}function Bt(e,t){e._readyState=Nt.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function Rt(e){return e.path=e.socketPath,rt.connect(e)}function Ut(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=rt.isIP(e.host)?"":e.host),it.connect(e)}function It(e,t,s){e._readyState=Nt.CLOSING;const r=new Error(s);Error.captureStackTrace(r,It),t.setHeader?(t[xt]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(Bt,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Dt(e,t,s){if(t){const s=dt(t)?t.size:kt(t).length;e._socket?e._sender._bufferedBytes+=s:e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${Ot[e.readyState]})`);process.nextTick(s,t)}}function Wt(e,t){const s=this[yt];s._closeFrameReceived=!0,s._closeMessage=t,s._closeCode=e,void 0!==s._socket[yt]&&(s._socket.removeListener("data",Yt),process.nextTick(Vt,s._socket),1005===e?s.close():s.close(e,t))}function Mt(){const e=this[yt];e.isPaused||e._socket.resume()}function At(e){const t=this[yt];void 0!==t._socket[yt]&&(t._socket.removeListener("data",Yt),process.nextTick(Vt,t._socket),t.close(e[vt])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function Ft(){this[yt].emitClose()}function jt(e,t){this[yt].emit("message",e,t)}function $t(e){const t=this[yt];t._autoPong&&t.pong(e,!this._isServer,bt),t.emit("ping",e)}function Gt(e){this[yt].emit("pong",e)}function Vt(e){e.resume()}function qt(e){const t=this[yt];t.readyState!==Nt.CLOSED&&(t.readyState===Nt.OPEN&&(t._readyState=Nt.CLOSING,zt(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function zt(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),3e4)}function Ht(){const e=this[yt];let t;this.removeListener("close",Ht),this.removeListener("data",Yt),this.removeListener("end",Xt),e._readyState=Nt.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[yt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",Ft),e._receiver.on("finish",Ft))}function Yt(e){this[yt]._receiver.write(e)||this.pause()}function Xt(){const e=this[yt];e._readyState=Nt.CLOSING,e._receiver.end(),this.end()}function Kt(){const e=this[yt];this.removeListener("error",Kt),this.on("error",bt),e&&(e._readyState=Nt.CLOSING,this.destroy())}e(Lt);const{Duplex:Zt}=a;function Jt(e){e.emit("close")}function Qt(){!this.destroyed&&this._writableState.finished&&this.destroy()}function es(e){this.removeListener("error",es),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}var ts=function(e,t){let s=!0;const r=new Zt({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,s){const i=!s&&r._readableState.objectMode?t.toString():t;r.push(i)||e.pause()})),e.once("error",(function(e){r.destroyed||(s=!1,r.destroy(e))})),e.once("close",(function(){r.destroyed||r.push(null)})),r._destroy=function(t,i){if(e.readyState===e.CLOSED)return i(t),void process.nextTick(Jt,r);let o=!1;e.once("error",(function(e){o=!0,i(e)})),e.once("close",(function(){o||i(t),process.nextTick(Jt,r)})),s&&e.terminate()},r._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){r._final(t)}))},r._read=function(){e.isPaused&&e.resume()},r._write=function(t,s,i){e.readyState!==e.CONNECTING?e.send(t,i):e.once("open",(function(){r._write(t,s,i)}))},r.on("end",Qt),r.on("error",es),r};e(ts);const{tokenChars:ss}=se;var rs={parse:function(e){const t=new Set;let s=-1,r=-1,i=0;for(;i{const s=os.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),t.end(s)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function(){for(const s of Object.keys(t))e.removeListener(s,t[s])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(ps,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(ps,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{ps(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,r){t.on("error",ms);const i=e.headers["sec-websocket-key"],o=e.headers.upgrade,n=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void ys(this,e,t,405,"Invalid HTTP method")}if(void 0===o||"websocket"!==o.toLowerCase()){return void ys(this,e,t,400,"Invalid Upgrade header")}if(void 0===i||!us.test(i)){return void ys(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==n&&13!==n){return void ys(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void vs(t,400);const a=e.headers["sec-websocket-protocol"];let c=new Set;if(void 0!==a)try{c=hs.parse(a)}catch(s){return void ys(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const h=e.headers["sec-websocket-extensions"],l={};if(this.options.perMessageDeflate&&void 0!==h){const s=new cs(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=as.parse(h);e[cs.extensionName]&&(s.accept(e[cs.extensionName]),l[cs.extensionName]=s)}catch(s){return void ys(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const o={origin:e.headers[""+(8===n?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(o,((o,n,a,h)=>{if(!o)return vs(t,n||401,a,h);this.completeUpgrade(l,i,c,e,t,s,r)}));if(!this.options.verifyClient(o))return vs(t,401)}this.completeUpgrade(l,i,c,e,t,s,r)}completeUpgrade(e,t,s,r,i,o,n){if(!i.readable||!i.writable)return i.destroy();if(i[fs])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return vs(i,503);const a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ns("sha1").update(t+ds).digest("base64")}`],c=new this.options.WebSocket(null,void 0,this.options);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;e&&(a.push(`Sec-WebSocket-Protocol: ${e}`),c._protocol=e)}if(e[cs.extensionName]){const t=e[cs.extensionName].params,s=as.format({[cs.extensionName]:[t]});a.push(`Sec-WebSocket-Extensions: ${s}`),c._extensions=e}this.emit("headers",a,r),i.write(a.concat("\r\n").join("\r\n")),i.removeListener("error",ms),c.setSocket(i,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(c),c.on("close",(()=>{this.clients.delete(c),this._shouldEmitClose&&!this.clients.size&&process.nextTick(ps,this)}))),n(c,r)}};function ps(e){e._state=2,e.emit("close")}function ms(){this.destroy()}function vs(e,t,s,r){s=s||os.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${os.STATUS_CODES[t]}\r\n`+Object.keys(r).map((e=>`${e}: ${r[e]}`)).join("\r\n")+"\r\n\r\n"+s)}function ys(e,t,s,r,i){if(e.listenerCount("wsClientError")){const r=new Error(i);Error.captureStackTrace(r,ys),e.emit("wsClientError",r,s,t)}else vs(s,r,i)}e(_s);const bs=Lt;bs.createWebSocketStream=ts,bs.Server=_s,bs.Receiver=pe,bs.Sender=Pe,bs.WebSocket=bs,bs.WebSocketServer=bs.Server;var gs=bs;e(gs);var Ss="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{WebSocket:null};Ss.WebSocket||(Ss.WebSocket=gs.WebSocket); diff --git a/openChannel.js b/openChannel.js index ebb5418..487c7d3 100644 --- a/openChannel.js +++ b/openChannel.js @@ -1 +1 @@ -import{c as e,_ as n,b as t,af as r,Q as a,a as s,i,A as o,bn as u,bo as l,f as c,h,e as d,u as p,ak as f,U as C,z as v,p as _,q as g,g as y,C as m,aA as U,W as E,O as M,D as w,F as P,t as b,G as T,aM as N,a2 as D,aT as H,bi as I,w as O,s as x,bj as A,aB as L,V as R,ai as F,aO as k,a_ as S}from"./lib/__bundle-1db3fd0b.js";import{a3 as z,a4 as q,a5 as Q,a7 as G,a6 as j,a8 as B,a9 as K,aa as V,ae as W,af as X,ag as Y,ah as Z,P as $,z as J,as as ee,T as ne,ak as te}from"./lib/__bundle-e1a5e3f1.js";import{C as re,B as ae,U as se,a as ie,O as oe,P as ue,M as le,T as ce,R as he,b as de,A as pe}from"./lib/__bundle-e53b9010.js";import{B as fe}from"./lib/__bundle-123134d8.js";import"./lib/__bundle-acd77193.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),ve={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},_e=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:l,"/").concat(encodeURIComponent(t)),a.params={show_pinned_messages:!0},a}return e(t,n),t}(c),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),ye=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds,C=e.isEphemeral;return(t=n.call(this)||this).method=o.POST,t.path=l,t.params=d(p({channel_url:r,cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f,is_ephemeral:C})),t}return e(t,n),t}(c);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}e(t,n)}(h);var me=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),Ue=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"SYEV",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),Ee=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),Me=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"EXIT",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),we={},Pe=function(r){function o(e,a){var s=r.call(this,e,y(y({},a),{channelType:m.OPEN}))||this;return s.subscribeChannelEvent=U,s.unsubscribeChannelEvent=U,s.refreshChannel=function(){return n(s,void 0,void 0,(function(){return t(this,(function(e){return[2,U()]}))}))},s._openChannelCache=new Ce(e),s._openChannelHandlers=new Map,s._dispatcher.on((function(e){var n,t;if(e instanceof E)s._handleEvent(e).catch((function(e){if(M(e)&&"foreground"===s._sdkState.appState)throw e}));else if(e instanceof w&&e.stateType===P.CONNECTED){var r=s._openChannelCache.enteredChannels;try{for(var a=b(r),i=a.next();!i.done;i=a.next()){i.value.enter()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),we[e]||(we[e]=s),s}return e(o,r),o.of=function(e){return we[e]},o.prototype.buildOpenChannelFromSerializedData=function(e){var n=v(e);return new xe(this._iid,xe.payloadify(n))},o.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]}}))}))},o.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()]}}))}))},o.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,s,i,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=b(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 s=t.sent(),i={error:s},[3,7];case 6:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},o.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},o.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},Object.defineProperty(o.prototype,"handlers",{get:function(){return _([],g(this._openChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),o.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,s,i,o,u,l,c,h,d,p,f,C,v,_,g,y,U,E,w,P,O,x,L,R,F,k,S,$,J,ee,ne,te,ae,fe,Ce,ve,_e,ge,ye,me,Ee,we,Pe,be,Te,Ne,De,He,Ie,Oe,xe,Ae,Le,Re,Fe,ke,Se,ze,qe,Qe,Ge,je,Be,Ke,Ve,We,Xe,Ye,Ze,$e,Je,en,nn,tn=this;return t(this,(function(rn){switch(rn.label){case 0:switch(rn.trys.push([0,59,,60]),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,58];case 1:return i=null,"MESG"===e.code?i=e.as(Y):"FILE"===e.code?i=e.as(Z):"ADMM"!==e.code&&"BRDM"!=e.code||(i=e.as(pe)),i?(r=i.message,a=i.isMentioned,r.channelType!==m.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:s=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,i,o,u;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())i=n.value,this._openChannelCache.isEnteredChannel(s.url)&&(i.onMessageReceived&&i.onMessageReceived(s,r),a&&i.onMentionReceived&&i.onMentionReceived(s,r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}}return[2]}))}))})),rn.label=3;case 3:return[3,58];case 4:return i=null,"MEDI"===e.code?i=e.as(W):"FEDI"===e.code?i=e.as(X):"AEDI"===e.code&&(i=e.as(de)),i?(o=i.message,u=i.mentionCountChange,o.channelType!==m.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:l=rn.sent(),c=!1,l.lastPinnedMessage&&l.lastPinnedMessage.messageId===o.messageId&&l.lastPinnedMessage.updatedAt0&&r.onMentionReceived&&r.onMentionReceived(l,o))}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=6;case 6:return[3,58];case 7:return h=e.as(I),ne=h.channelUrl,te=h.channelType,d=h.messageId,te!==m.OPEN?[3,9]:[4,this.getChannel(ne,!0)];case 8:p=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(p.url)&&r.onMessageDeleted&&r.onMessageDeleted(p,d)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=9;case 9:return[3,58];case 10:return f=e.as(he),ne=f.channelUrl,te=f.channelType,C=f.event,te!==m.OPEN?[3,12]:[4,this.getChannel(ne,!0)];case 11:v=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated&&r.onReactionUpdated(v,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=12;case 12:return[3,58];case 13:return(_=e.as(ce).event).channelType!==m.OPEN?[3,15]:[4,this.getChannel(_.channelUrl,!0)];case 14:g=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(g.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(g,_)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=15;case 15:return[3,58];case 16:y=e.as(le).openChannelMemberCounts,U=[],rn.label=17;case 17:rn.trys.push([17,22,23,24]),E=b(y),w=E.next(),rn.label=18;case 18:return w.done?[3,21]:(P=w.value,ne=P.channelUrl,Ee=P.participantCount,O=P.updatedAt,[4,this.getChannelFromCache(ne)]);case 19:(x=rn.sent())&&x._updateParticipantCount(Ee,O)&&U.push(x),rn.label=20;case 20:return w=E.next(),[3,18];case 21:return[3,24];case 22:return L=rn.sent(),en={error:L},[3,24];case 23:try{w&&!w.done&&(nn=E.return)&&nn.call(E)}finally{if(en)throw en.error}return[7];case 24:return U.length>0?[4,this.upsertChannelsToCache(U)]:[3,26];case 25:R=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(R)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=26;case 26:return[3,58];case 27:return F=e.as(ue),k=F.event,S=F.status,ne=F.channelUrl,te=F.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,29];case 28:$=rn.sent(),this._dispatcher.dispatch(new H({event:k,source:D.EVENT_POLL_UPDATED})),T(S===A?function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted($,k.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated($,k)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),rn.label=29;case 29:return[3,58];case 30:return J=e.as(V),ee=J.event,ne=J.channelUrl,te=J.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,32];case 31:ae=rn.sent(),this._dispatcher.dispatch(new N({event:ee,source:D.EVENT_POLL_VOTED})),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(ae,ee)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=32;case 32:return[3,58];case 33:if(!(fe=e.as(re).event).isOpenChannelEvent)return[3,57];switch(fe.category){case ie.CHANNEL_ENTER:return[3,34];case ie.CHANNEL_EXIT:return[3,36];case ie.CHANNEL_OPERATOR_UPDATE:return[3,38];case ie.USER_CHANNEL_MUTE:case ie.USER_CHANNEL_UNMUTE:return[3,40];case ie.USER_CHANNEL_BAN:case ie.USER_CHANNEL_UNBAN:return[3,42];case ie.CHANNEL_FREEZE:case ie.CHANNEL_UNFREEZE:return[3,44];case ie.CHANNEL_DELETED:return[3,46];case ie.CHANNEL_PROP_CHANGED:return[3,49];case ie.CHANNEL_META_DATA_CHANGED:return[3,51];case ie.CHANNEL_META_COUNTERS_CHANGED:return[3,53];case ie.PINNED_MESSAGE_CHANGED:return[3,55]}return[3,57];case 34:return[4,this.getChannel(fe.channelUrl,!0)];case 35:return Ce=rn.sent(),ve=e.as(Ue),Ee=ve.participantCount,_e=ve.user,ge=Ce._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(Ce,_e),ge&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(Ce)})),[2]}))}))})),[3,57];case 36:return[4,this.getChannel(fe.channelUrl,!0)];case 37:return ye=rn.sent(),me=e.as(Me),Ee=me.participantCount,we=me.user,Pe=ye._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(ye,we),Pe&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ye)})),[2]}))}))})),[3,57];case 38:return[4,this.getChannel(fe.channelUrl,!0)];case 39:return be=rn.sent(),Te=e.as(oe).operators,be.operators=Te,this.upsertChannelsToCache([be]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(be,Te)})),[2]}))}))})),[3,57];case 40:return[4,this.getChannel(fe.channelUrl,!0)];case 41:return Ne=rn.sent(),De=fe.category===ie.USER_CHANNEL_MUTE,He=e.as(De?B:K).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){De?e.onUserMuted&&e.onUserMuted(Ne,He):e.onUserUnmuted&&e.onUserUnmuted(Ne,He)})),[2]}))}))})),[3,57];case 42:return[4,this.getChannel(fe.channelUrl,!0)];case 43:return Ie=rn.sent(),Oe=fe.category===ie.USER_CHANNEL_BAN,xe=e.as(Oe?G:j).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Oe?e.onUserBanned&&e.onUserBanned(Ie,xe):e.onUserUnbanned&&e.onUserUnbanned(Ie,xe)})),[2]}))}))})),[3,57];case 44:return[4,this.getChannel(fe.channelUrl,!0)];case 45:return Ae=rn.sent(),Le=e.as(Q).freeze,Ae.isFrozen=Le,this.upsertChannelsToCache([Ae]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Le?e.onChannelFrozen&&e.onChannelFrozen(Ae):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ae)})),[2]}))}))})),[3,57];case 46:return[4,this.getChannel(fe.channelUrl,!0)];case 47:return Re=rn.sent(),[4,this.removeChannelsFromCache([Re.url])];case 48:return rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Re.url,Re.channelType)})),[2]}))}))})),[3,57];case 49:return[4,this.getChannelWithoutCache(fe.channelUrl,!0)];case 50:return Fe=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Fe)})),[2]}))}))})),[3,57];case 51:return[4,this.getChannel(fe.channelUrl,!0)];case 52:return ke=rn.sent(),Se=e.as(q),ze=Se.created,qe=Se.updated,Qe=Se.deleted,ze&&ke._upsertCachedMetaData(ze,fe.ts),qe&&ke._upsertCachedMetaData(qe,fe.ts),Qe&&ke._removeFromCachedMetaData(Qe,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ze&&e.onMetaDataCreated&&e.onMetaDataCreated(ke,ze),qe&&e.onMetaDataUpdated&&e.onMetaDataUpdated(ke,qe),Qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(ke,Qe)})),[2]}))}))})),[3,57];case 53:return[4,this.getChannel(fe.channelUrl,!0)];case 54:return Ge=rn.sent(),je=e.as(z),Be=je.created,Ke=je.updated,Ve=je.deleted,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Be&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Ge,Be),Ke&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ge,Ke),Ve&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Ge,Ve)})),[2]}))}))})),[3,57];case 55:return[4,this.getChannel(fe.channelUrl,!0)];case 56:return We=rn.sent(),Xe=e.as(se),Ye=Xe.pinnedMessageIds,Ze=Xe.latestPinnedMessage,($e=Xe.ts)>We._pinnedMessagesUpdatedAt&&(We.pinnedMessageIds=Ye,We.lastPinnedMessage=Ze,We._pinnedMessagesUpdatedAt=$e,this.upsertChannelsToCache([We]),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelChanged&&r.onChannelChanged(We)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(We)})),[2]}))}))}))),[3,57];case 57:return[3,58];case 58:return[3,60];case 59:if(Je=rn.sent(),M(Je))throw Je;return[3,60];case 60:return[2]}}))}))},o.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},o.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},o.prototype.clearHandler=function(){this._openChannelHandlers.clear()},o.prototype.getChannel=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:O(s("string",e)).throw(x.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,r)];case 5:return[2,t.sent()]}}))}))},o.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,i;return t(this,(function(t){switch(t.label){case 0:return O(s("string",e)).throw(x.invalidParameters),n=new _e({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),i=a.as(ge).channel,[4,this.upsertChannelsToCache([i])];case 2:return[2,t.sent()[0]]}}))}))},o.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},ve),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)&&(s("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&s("boolean",e.isEphemeral,!0)}(n)).throw(x.invalidParameters),r=new ye(n),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(ge).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},o}(ae),be={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Te=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,s=e.limit;return(t=n.call(this)||this).method=o.GET,t.path="".concat(l,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:s},t}return e(t,n),t}(c),Ne=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,s=t.participants;return r.token=a,r.participants=s.map((function(n){return new $(e,n)})),r}return e(t,n),t}(h),De=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,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Te(y(y({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Ne),s=a.participants,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},a}(L),He=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=o.PUT,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f})),t}return e(t,n),t}(c),Ie=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),Oe=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=o.DELETE,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(c);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var xe=function(r){function o(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.lastPinnedMessage=null,a._pinnedMessagesUpdatedAt=0,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 C(e,n)})):[],a.lastPinnedMessage=n.latest_pinned_message?ne(a._iid,y({channel_type:a.channelType},n.latest_pinned_message)):null,a}return e(o,r),o.payloadify=function(e){return d(p(y(y({},J.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return C.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?ee(e.lastPinnedMessage):null})))},o.prototype.serialize=function(){return F(this)},o.prototype.isOperator=function(e){return e instanceof C?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},o.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},o.prototype.createParticipantListQuery=function(e){return new De(this._iid,this.url,e)},o.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Pe.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},o.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new me({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Ue),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Ee({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Me),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setExitedToCache(this),te.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},be),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)}(n)).throw(x.invalidParameters),r=R.of(this._iid).requestQueue,o=new He(y({channelUrl:this.url},n)),[4,r.send(o)];case 1:return u=t.sent(),l=u.as(Ie).channel,this._update(l),[4,Pe.of(this._iid).upsertChannelsToCache([l])];case 2:return t.sent(),[2,this]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(e,r,a,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=y(y({},be),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:s,customType:i}),[2,this.updateChannel(n)]}))}))},o.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Oe({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,Pe.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.updateUserMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateUserMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o.prototype.updateFileMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateFileMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o}(J),Ae=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=U,e.onUserExited=U,e.onChannelParticipantCountChanged=U,e.onPollUpdated=U,e.onPollVoted=U,e.onPollDeleted=U,e.onPinnedMessageUpdated=U,e}return e(t,n),t}(fe)),Le=function(n){function t(e){var t=this,r=e.token,a=e.limit,s=e.nameKeyword,i=e.urlKeyword,u=e.customTypes,c=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=o.GET,t.path=l,t.params=d({token:r,limit:a,name_contains:s,url_contains:i,custom_types:u,show_frozen:c,show_metadata:h,show_pinned_messages:!0}),t}return e(t,n),t}(c),Re=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,s=t.channels,i=t.ts;return r.token=a,s&&s.length>0&&(r.channels=s.map((function(n){return new xe(e,n)}))),r.ts="number"==typeof i?i:null,r}return e(t,n),t}(h),Fe=function(r){function i(e,n){var t,a,s,i,o,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,u.urlKeyword=null!==(i=n.urlKeyword)&&void 0!==i?i:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return e(i,r),i.prototype._validate=function(){return r.prototype._validate.call(this)&&s("boolean",this.includeFrozen)&&s("boolean",this.includeMetaData)&&s("string",this.nameKeyword,!0)&&s("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},i.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Le(p(y(y({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Re),s=a.channels,i=a.token,this._token=i,this._hasNext=!!i,[4,Pe.of(this._iid).upsertChannelsToCache(s)];case 2:return t.sent(),this._isLoading=!1,[2,s];case 3:return[2,[]];case 4:throw x.queryInProgress;case 5:return[3,7];case 6:throw x.invalidParameters;case 7:return[2]}}))}))},i}(k),ke=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,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new Pe(e,{sdkState:t,dispatcher:a,requestQueue:i,logger:o,cacheContext:l,sessionManager:s})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new Fe(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,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=y({},ve)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=s,n.customType=i,[2,this._manager.createChannel(n)]}))}))},a}(S);export{xe as OpenChannel,Ae as OpenChannelHandler,Fe as OpenChannelListQuery,ke as OpenChannelModule,De as ParticipantListQuery}; +import{c as e,_ as n,b as t,af as r,Q as a,a as s,i,A as o,bn as u,bo as l,f as c,h,e as d,u as p,ak as f,U as C,z as v,p as _,q as g,g as y,C as m,aA as U,W as E,O as M,D as w,F as P,t as T,G as b,aM as N,a2 as D,aT as H,bi as I,w as O,s as x,bj as A,aB as L,V as R,ai as F,aO as k,a_ as S}from"./lib/__bundle-c03282ec.js";import{a3 as z,a4 as q,a5 as Q,a7 as G,a6 as j,a8 as B,a9 as K,aa as V,ae as W,af as X,ag as Y,ah as Z,P as $,z as J,as as ee,T as ne,ak as te}from"./lib/__bundle-45809bc9.js";import{C as re,B as ae,U as se,a as ie,O as oe,P as ue,M as le,T as ce,R as he,b as de,A as pe}from"./lib/__bundle-5dbd9d35.js";import{B as fe}from"./lib/__bundle-75f48c2c.js";import"./lib/__bundle-acd77193.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),ve={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},_e=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:l,"/").concat(encodeURIComponent(t)),a.params={show_pinned_messages:!0},a}return e(t,n),t}(c),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),ye=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds,C=e.isEphemeral;return(t=n.call(this)||this).method=o.POST,t.path=l,t.params=d(p({channel_url:r,cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f,is_ephemeral:C})),t}return e(t,n),t}(c);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}e(t,n)}(h);var me=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),Ue=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"SYEV",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),Ee=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),Me=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"EXIT",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),we={},Pe=function(r){function o(e,a){var s=r.call(this,e,y(y({},a),{channelType:m.OPEN}))||this;return s.subscribeChannelEvent=U,s.unsubscribeChannelEvent=U,s.refreshChannel=function(){return n(s,void 0,void 0,(function(){return t(this,(function(e){return[2,U()]}))}))},s._openChannelCache=new Ce(e),s._openChannelHandlers=new Map,s._dispatcher.on((function(e){var n,t;if(e instanceof E)s._handleEvent(e).catch((function(e){if(M(e)&&"foreground"===s._sdkState.appState)throw e}));else if(e instanceof w&&e.stateType===P.CONNECTED){var r=s._openChannelCache.enteredChannels;try{for(var a=T(r),i=a.next();!i.done;i=a.next()){i.value.enter()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),we[e]||(we[e]=s),s}return e(o,r),o.of=function(e){return we[e]},o.prototype.buildOpenChannelFromSerializedData=function(e){var n=v(e);return new xe(this._iid,xe.payloadify(n))},o.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]}}))}))},o.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()]}}))}))},o.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,s,i,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=T(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 s=t.sent(),i={error:s},[3,7];case 6:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},o.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},o.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},Object.defineProperty(o.prototype,"handlers",{get:function(){return _([],g(this._openChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),o.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,s,i,o,u,l,c,h,d,p,f,C,v,_,g,y,U,E,w,P,O,x,L,R,F,k,S,$,J,ee,ne,te,ae,fe,Ce,ve,_e,ge,ye,me,Ee,we,Pe,Te,be,Ne,De,He,Ie,Oe,xe,Ae,Le,Re,Fe,ke,Se,ze,qe,Qe,Ge,je,Be,Ke,Ve,We,Xe,Ye,Ze,$e,Je,en,nn,tn=this;return t(this,(function(rn){switch(rn.label){case 0:switch(rn.trys.push([0,59,,60]),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,58];case 1:return i=null,"MESG"===e.code?i=e.as(Y):"FILE"===e.code?i=e.as(Z):"ADMM"!==e.code&&"BRDM"!=e.code||(i=e.as(pe)),i?(r=i.message,a=i.isMentioned,r.channelType!==m.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:s=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){var e,n,i,o,u;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())i=n.value,this._openChannelCache.isEnteredChannel(s.url)&&(i.onMessageReceived&&i.onMessageReceived(s,r),a&&i.onMentionReceived&&i.onMentionReceived(s,r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}}return[2]}))}))})),rn.label=3;case 3:return[3,58];case 4:return i=null,"MEDI"===e.code?i=e.as(W):"FEDI"===e.code?i=e.as(X):"AEDI"===e.code&&(i=e.as(de)),i?(o=i.message,u=i.mentionCountChange,o.channelType!==m.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:l=rn.sent(),c=!1,l.lastPinnedMessage&&l.lastPinnedMessage.messageId===o.messageId&&l.lastPinnedMessage.updatedAt0&&r.onMentionReceived&&r.onMentionReceived(l,o))}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=6;case 6:return[3,58];case 7:return h=e.as(I),ne=h.channelUrl,te=h.channelType,d=h.messageId,te!==m.OPEN?[3,9]:[4,this.getChannel(ne,!0)];case 8:p=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(p.url)&&r.onMessageDeleted&&r.onMessageDeleted(p,d)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=9;case 9:return[3,58];case 10:return f=e.as(he),ne=f.channelUrl,te=f.channelType,C=f.event,te!==m.OPEN?[3,12]:[4,this.getChannel(ne,!0)];case 11:v=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated&&r.onReactionUpdated(v,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=12;case 12:return[3,58];case 13:return(_=e.as(ce).event).channelType!==m.OPEN?[3,15]:[4,this.getChannel(_.channelUrl,!0)];case 14:g=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(g.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(g,_)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=15;case 15:return[3,58];case 16:y=e.as(le).openChannelMemberCounts,U=[],rn.label=17;case 17:rn.trys.push([17,22,23,24]),E=T(y),w=E.next(),rn.label=18;case 18:return w.done?[3,21]:(P=w.value,ne=P.channelUrl,Ee=P.participantCount,O=P.updatedAt,[4,this.getChannelFromCache(ne)]);case 19:(x=rn.sent())&&x._updateParticipantCount(Ee,O)&&U.push(x),rn.label=20;case 20:return w=E.next(),[3,18];case 21:return[3,24];case 22:return L=rn.sent(),en={error:L},[3,24];case 23:try{w&&!w.done&&(nn=E.return)&&nn.call(E)}finally{if(en)throw en.error}return[7];case 24:return U.length>0?[4,this.upsertChannelsToCache(U)]:[3,26];case 25:R=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(R)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=26;case 26:return[3,58];case 27:return F=e.as(ue),k=F.event,S=F.status,ne=F.channelUrl,te=F.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,29];case 28:$=rn.sent(),this._dispatcher.dispatch(new H({event:k,source:D.EVENT_POLL_UPDATED})),b(S===A?function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted($,k.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated($,k)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),rn.label=29;case 29:return[3,58];case 30:return J=e.as(V),ee=J.event,ne=J.channelUrl,te=J.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,32];case 31:ae=rn.sent(),this._dispatcher.dispatch(new N({event:ee,source:D.EVENT_POLL_VOTED})),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(ae,ee)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=32;case 32:return[3,58];case 33:if(!(fe=e.as(re).event).isOpenChannelEvent)return[3,57];switch(fe.category){case ie.CHANNEL_ENTER:return[3,34];case ie.CHANNEL_EXIT:return[3,36];case ie.CHANNEL_OPERATOR_UPDATE:return[3,38];case ie.USER_CHANNEL_MUTE:case ie.USER_CHANNEL_UNMUTE:return[3,40];case ie.USER_CHANNEL_BAN:case ie.USER_CHANNEL_UNBAN:return[3,42];case ie.CHANNEL_FREEZE:case ie.CHANNEL_UNFREEZE:return[3,44];case ie.CHANNEL_DELETED:return[3,46];case ie.CHANNEL_PROP_CHANGED:return[3,49];case ie.CHANNEL_META_DATA_CHANGED:return[3,51];case ie.CHANNEL_META_COUNTERS_CHANGED:return[3,53];case ie.PINNED_MESSAGE_CHANGED:return[3,55]}return[3,57];case 34:return[4,this.getChannel(fe.channelUrl,!0)];case 35:return Ce=rn.sent(),ve=e.as(Ue),Ee=ve.participantCount,_e=ve.user,ge=Ce._updateParticipantCount(Ee,fe.ts),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(Ce,_e),ge&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(Ce)})),[2]}))}))})),[3,57];case 36:return[4,this.getChannel(fe.channelUrl,!0)];case 37:return ye=rn.sent(),me=e.as(Me),Ee=me.participantCount,we=me.user,Pe=ye._updateParticipantCount(Ee,fe.ts),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(ye,we),Pe&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ye)})),[2]}))}))})),[3,57];case 38:return[4,this.getChannel(fe.channelUrl,!0)];case 39:return Te=rn.sent(),be=e.as(oe).operators,Te.operators=be,this.upsertChannelsToCache([Te]),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Te,be)})),[2]}))}))})),[3,57];case 40:return[4,this.getChannel(fe.channelUrl,!0)];case 41:return Ne=rn.sent(),De=fe.category===ie.USER_CHANNEL_MUTE,He=e.as(De?B:K).user,b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){De?e.onUserMuted&&e.onUserMuted(Ne,He):e.onUserUnmuted&&e.onUserUnmuted(Ne,He)})),[2]}))}))})),[3,57];case 42:return[4,this.getChannel(fe.channelUrl,!0)];case 43:return Ie=rn.sent(),Oe=fe.category===ie.USER_CHANNEL_BAN,xe=e.as(Oe?G:j).user,b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Oe?e.onUserBanned&&e.onUserBanned(Ie,xe):e.onUserUnbanned&&e.onUserUnbanned(Ie,xe)})),[2]}))}))})),[3,57];case 44:return[4,this.getChannel(fe.channelUrl,!0)];case 45:return Ae=rn.sent(),Le=e.as(Q).freeze,Ae.isFrozen=Le,this.upsertChannelsToCache([Ae]),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Le?e.onChannelFrozen&&e.onChannelFrozen(Ae):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ae)})),[2]}))}))})),[3,57];case 46:return[4,this.getChannel(fe.channelUrl,!0)];case 47:return Re=rn.sent(),[4,this.removeChannelsFromCache([Re.url])];case 48:return rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Re.url,Re.channelType)})),[2]}))}))})),[3,57];case 49:return[4,this.getChannelWithoutCache(fe.channelUrl,!0)];case 50:return Fe=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Fe)})),[2]}))}))})),[3,57];case 51:return[4,this.getChannel(fe.channelUrl,!0)];case 52:return ke=rn.sent(),Se=e.as(q),ze=Se.created,qe=Se.updated,Qe=Se.deleted,ze&&ke._upsertCachedMetaData(ze,fe.ts),qe&&ke._upsertCachedMetaData(qe,fe.ts),Qe&&ke._removeFromCachedMetaData(Qe,fe.ts),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ze&&e.onMetaDataCreated&&e.onMetaDataCreated(ke,ze),qe&&e.onMetaDataUpdated&&e.onMetaDataUpdated(ke,qe),Qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(ke,Qe)})),[2]}))}))})),[3,57];case 53:return[4,this.getChannel(fe.channelUrl,!0)];case 54:return Ge=rn.sent(),je=e.as(z),Be=je.created,Ke=je.updated,Ve=je.deleted,b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Be&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Ge,Be),Ke&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ge,Ke),Ve&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Ge,Ve)})),[2]}))}))})),[3,57];case 55:return[4,this.getChannel(fe.channelUrl,!0)];case 56:return We=rn.sent(),Xe=e.as(se),Ye=Xe.pinnedMessageIds,Ze=Xe.latestPinnedMessage,($e=Xe.ts)>We._pinnedMessagesUpdatedAt&&(We.pinnedMessageIds=Ye,We.lastPinnedMessage=Ze,We._pinnedMessagesUpdatedAt=$e,this.upsertChannelsToCache([We]),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelChanged&&r.onChannelChanged(We)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(We)})),[2]}))}))}))),[3,57];case 57:return[3,58];case 58:return[3,60];case 59:if(Je=rn.sent(),M(Je))throw Je;return[3,60];case 60:return[2]}}))}))},o.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},o.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},o.prototype.clearHandler=function(){this._openChannelHandlers.clear()},o.prototype.getChannel=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:O(s("string",e)).throw(x.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,r)];case 5:return[2,t.sent()]}}))}))},o.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,i;return t(this,(function(t){switch(t.label){case 0:return O(s("string",e)).throw(x.invalidParameters),n=new _e({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),i=a.as(ge).channel,[4,this.upsertChannelsToCache([i])];case 2:return[2,t.sent()[0]]}}))}))},o.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},ve),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)&&(s("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&s("boolean",e.isEphemeral,!0)}(n)).throw(x.invalidParameters),r=new ye(n),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(ge).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},o}(ae),Te={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},be=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,s=e.limit;return(t=n.call(this)||this).method=o.GET,t.path="".concat(l,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:s},t}return e(t,n),t}(c),Ne=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,s=t.participants;return r.token=a,r.participants=s.map((function(n){return new $(e,n)})),r}return e(t,n),t}(h),De=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,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new be(y(y({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Ne),s=a.participants,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},a}(L),He=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=o.PUT,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f})),t}return e(t,n),t}(c),Ie=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),Oe=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=o.DELETE,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(c);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var xe=function(r){function o(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.lastPinnedMessage=null,a._pinnedMessagesUpdatedAt=0,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 C(e,n)})):[],a.lastPinnedMessage=n.latest_pinned_message?ne(a._iid,y({channel_type:a.channelType},n.latest_pinned_message)):null,a}return e(o,r),o.payloadify=function(e){return d(p(y(y({},J.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return C.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?ee(e.lastPinnedMessage):null})))},o.prototype.serialize=function(){return F(this)},o.prototype.isOperator=function(e){return e instanceof C?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},o.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},o.prototype.createParticipantListQuery=function(e){return new De(this._iid,this.url,e)},o.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Pe.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},o.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new me({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Ue),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Ee({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Me),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setExitedToCache(this),te.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},Te),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)}(n)).throw(x.invalidParameters),r=R.of(this._iid).requestQueue,o=new He(y({channelUrl:this.url},n)),[4,r.send(o)];case 1:return u=t.sent(),l=u.as(Ie).channel,this._update(l),[4,Pe.of(this._iid).upsertChannelsToCache([l])];case 2:return t.sent(),[2,this]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(e,r,a,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=y(y({},Te),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:s,customType:i}),[2,this.updateChannel(n)]}))}))},o.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Oe({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,Pe.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.updateUserMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateUserMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o.prototype.updateFileMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateFileMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o}(J),Ae=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=U,e.onUserExited=U,e.onChannelParticipantCountChanged=U,e.onPollUpdated=U,e.onPollVoted=U,e.onPollDeleted=U,e.onPinnedMessageUpdated=U,e}return e(t,n),t}(fe)),Le=function(n){function t(e){var t=this,r=e.token,a=e.limit,s=e.nameKeyword,i=e.urlKeyword,u=e.customTypes,c=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=o.GET,t.path=l,t.params=d({token:r,limit:a,name_contains:s,url_contains:i,custom_types:u,show_frozen:c,show_metadata:h,show_pinned_messages:!0}),t}return e(t,n),t}(c),Re=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,s=t.channels,i=t.ts;return r.token=a,s&&s.length>0&&(r.channels=s.map((function(n){return new xe(e,n)}))),r.ts="number"==typeof i?i:null,r}return e(t,n),t}(h),Fe=function(r){function i(e,n){var t,a,s,i,o,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,u.urlKeyword=null!==(i=n.urlKeyword)&&void 0!==i?i:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return e(i,r),i.prototype._validate=function(){return r.prototype._validate.call(this)&&s("boolean",this.includeFrozen)&&s("boolean",this.includeMetaData)&&s("string",this.nameKeyword,!0)&&s("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},i.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Le(p(y(y({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Re),s=a.channels,i=a.token,this._token=i,this._hasNext=!!i,[4,Pe.of(this._iid).upsertChannelsToCache(s)];case 2:return t.sent(),this._isLoading=!1,[2,s];case 3:return[2,[]];case 4:throw x.queryInProgress;case 5:return[3,7];case 6:throw x.invalidParameters;case 7:return[2]}}))}))},i}(k),ke=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,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new Pe(e,{sdkState:t,dispatcher:a,requestQueue:i,logger:o,cacheContext:l,sessionManager:s})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new Fe(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,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=y({},ve)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=s,n.customType=i,[2,this._manager.createChannel(n)]}))}))},a}(S);export{xe as OpenChannel,Ae as OpenChannelHandler,Fe as OpenChannelListQuery,ke as OpenChannelModule,De as ParticipantListQuery}; diff --git a/package.json b/package.json index 8572194..e799bc7 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.14.4", + "version": "4.14.5", "description": "Sendbird SDK for JavaScript", "sideEffects": false, "name": "@sendbird/chat", diff --git a/poll.js b/poll.js index 783c8d1..a060bcc 100644 --- a/poll.js +++ b/poll.js @@ -1 +1 @@ -import{c as t,aN as e,_ as r,a_ as a,b as n,g as o,b0 as i,w as s,b1 as l,s as u,b2 as c,b3 as d,b4 as p,b5 as h}from"./lib/__bundle-1db3fd0b.js";export{ar as Poll,x as PollListQuery,b6 as PollOption,b7 as PollStatus,aI as PollVoteEvent,y as PollVoterListQuery}from"./lib/__bundle-1db3fd0b.js";export{P as PollUpdateEvent}from"./lib/__bundle-acd77193.js";var b=function(a){function b(){var t=null!==a&&a.apply(this,arguments)||this;return t.name="poll",t}return t(b,a),b.prototype.init=function(t,r){var n=r.sdkState,o=r.dispatcher,i=r.sessionManager,s=r.requestQueue,l=r.logger,u=r.onlineDetector,c=r.cacheContext;a.prototype.init.call(this,t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c}),this._manager=new e(t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c})},b.prototype.create=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},i),t),s(l(e)).throw(u.invalidParameters),[2,this._manager.create(e)]}))}))},b.prototype.get=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},c),t),s(d(e)).throw(u.invalidParameters),[2,this._manager.get(e)]}))}))},b.prototype.getOption=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},p),t),s(h(e)).throw(u.invalidParameters),[2,this._manager.getOption(e)]}))}))},b.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},b}(a);export{b as PollModule}; +import{c as t,aN as e,_ as r,a_ as a,b as n,g as o,b0 as i,w as s,b1 as l,s as u,b2 as c,b3 as p,b4 as d,b5 as h}from"./lib/__bundle-c03282ec.js";export{ar as Poll,x as PollListQuery,b6 as PollOption,b7 as PollStatus,aI as PollVoteEvent,y as PollVoterListQuery}from"./lib/__bundle-c03282ec.js";export{P as PollUpdateEvent}from"./lib/__bundle-acd77193.js";var g=function(a){function g(){var t=null!==a&&a.apply(this,arguments)||this;return t.name="poll",t}return t(g,a),g.prototype.init=function(t,r){var n=r.sdkState,o=r.dispatcher,i=r.sessionManager,s=r.requestQueue,l=r.logger,u=r.onlineDetector,c=r.cacheContext;a.prototype.init.call(this,t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c}),this._manager=new e(t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c})},g.prototype.create=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},i),t),s(l(e)).throw(u.invalidParameters),[2,this._manager.create(e)]}))}))},g.prototype.get=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},c),t),s(p(e)).throw(u.invalidParameters),[2,this._manager.get(e)]}))}))},g.prototype.getOption=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},d),t),s(h(e)).throw(u.invalidParameters),[2,this._manager.getOption(e)]}))}))},g.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},g}(a);export{g as PollModule}; diff --git a/sendbird.min.js b/sendbird.min.js index 7420bfd..2730e1d 100644 --- a/sendbird.min.js +++ b/sendbird.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Sendbird={})}(this,(function(e){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=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 i,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw i}}}}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(r){var a=Object.getOwnPropertyDescriptor(r,t);return a.get?a.get.call(arguments.length<3?e:n):a.value}},o.apply(null,arguments)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function d(){d=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",u=i.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 i=t&&t.prototype instanceof g?t:g,s=Object.create(i.prototype),o=new M(r||[]);return a(s,"_invoke",{value:T(e,n,o)}),s}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var f="suspendedStart",p="suspendedYield",v="executing",_="completed",m={};function g(){}function y(){}function E(){}var k={};c(k,s,(function(){return this}));var b=Object.getPrototypeOf,C=b&&b(b(O([])));C&&C!==n&&r.call(C,s)&&(k=C);var w=E.prototype=g.prototype=Object.create(k);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(a,i,s,o){var u=h(e[a],e,i);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,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var i;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return i=i?i.then(a,a):a()}})}function T(t,n,r){var a=f;return function(i,s){if(a===v)throw Error("Generator is already running");if(a===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var o=r.delegate;if(o){var u=I(o,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===f)throw a=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=v;var c=h(t,n,r);if("normal"===c.type){if(a=r.done?_:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(a=_,r.method="throw",r.arg=c.arg)}}}function I(t,n){var r=n.method,a=t.iterator[r];if(a===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,I(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=h(a,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function N(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 A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function M(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(N,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function n(){for(;++a=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(u&&c){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),A(n),m}},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;A(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:O(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),m}},t}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,s,o=[],u=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(o.push(r.value),o.length!==t);u=!0);}catch(e){c=!0,a=e}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw a}}return o}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t,n,r){var a=o(u(1&r?e.prototype:e),t,n);return 2&r?function(e){return a.apply(n,e)}:a}function v(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){var t=function(e,t){if("object"!=typeof e||!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:t+""}function m(e){return m="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},m(e)}function g(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function y(e){var t="function"==typeof Map?new Map:void 0;return y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(l())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var a=new(e.bind.apply(e,r));return n&&h(a,n.prototype),a}(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)},y(e)}function E(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var k,b="4.14.4",C=function(){function e(){r(this,e)}return i(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return b}},{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.SendbirdErrorCode=void 0,(k=e.SendbirdErrorCode||(e.SendbirdErrorCode={}))[k.NON_AUTHORIZED=400108]="NON_AUTHORIZED",k[k.INVALID_TOKEN=400111]="INVALID_TOKEN",k[k.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",k[k.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",k[k.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",k[k.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",k[k.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",k[k.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",k[k.SESSION_REVOKED=400310]="SESSION_REVOKED",k[k.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",k[k.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",k[k.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",k[k.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",k[k.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",k[k.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",k[k.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",k[k.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",k[k.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",k[k.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",k[k.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",k[k.LOST_INSTANCE=700100]="LOST_INSTANCE",k[k.CONNECTION_RENEW=700102]="CONNECTION_RENEW",k[k.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",k[k.INVALID_COMMAND=700700]="INVALID_COMMAND",k[k.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",k[k.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",k[k.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",k[k.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",k[k.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",k[k.INVALID_PARAMETER=800110]="INVALID_PARAMETER",k[k.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",k[k.NETWORK_ERROR=800120]="NETWORK_ERROR",k[k.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",k[k.MALFORMED_DATA=800130]="MALFORMED_DATA",k[k.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",k[k.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",k[k.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",k[k.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",k[k.ACK_TIMEOUT=800180]="ACK_TIMEOUT",k[k.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",k[k.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",k[k.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",k[k.REQUEST_FAILED=800220]="REQUEST_FAILED",k[k.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",k[k.REQUEST_CANCELED=800240]="REQUEST_CANCELED",k[k.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",k[k.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",k[k.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED",k[k.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",k[k.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",k[k.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",k[k.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",k[k.DATABASE_ERROR=800700]="DATABASE_ERROR",k[k.USER_DEACTIVATED=900021]="USER_DEACTIVATED",k[k.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";var w,x,S,T,I,N=function(e){return!(e instanceof A&&!e.shouldThrowOutside)},A=function(t){function a(e){var t,i=e.code,s=void 0===i?0:i,o=e.message,u=void 0===o?"":o;return r(this,a),(t=n(this,a,[u])).shouldThrowOutside=!1,t._detail="",t.name="SendbirdError",t.code=s,Object.setPrototypeOf(t,a.prototype),t}return c(a,t),i(a,[{key:"detail",get:function(){return this._detail}},{key:"setDetail",value:function(e){this._detail=e}},{key:"isInvalidTokenError",get:function(){return this.code===e.SendbirdErrorCode.INVALID_TOKEN}},{key:"isSessionExpiredError",get:function(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}},{key:"isSessionTokenExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_KEY_EXPIRED}},{key:"isSessionInvalidatedError",get:function(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}},{key:"isSessionRevokedError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_REVOKED}},{key:"isUserAuthDeactivedError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DEACTIVATED}},{key:"isUserAuthDeletedOrNotFoundError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}},{key:"isNetworkError",get:function(){return this.code===e.SendbirdErrorCode.NETWORK_ERROR||this.code===e.SendbirdErrorCode.NETWORK_ROUTING_ERROR}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new a({code:e.SendbirdErrorCode.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new a({code:e.SendbirdErrorCode.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"invalidCommand",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new a({code:e.SendbirdErrorCode.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{key:"connectionRenew",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"xmlHttpRequestNotSupported",get:function(){return new a({code:e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}},{key:"connectionRequired",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"channelTypeNotSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}},{key:"networkError",get:function(){return new a({code:e.SendbirdErrorCode.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new a({code:e.SendbirdErrorCode.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new a({code:e.SendbirdErrorCode.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new a({code:e.SendbirdErrorCode.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new a({code:e.SendbirdErrorCode.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new a({code:e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Request failed."})}},{key:"tooManyRequests",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}},{key:"alreadyConnectedAsAnotherUser",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}},{key:"fileUploadCanceled",get:function(){return new a({code:e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new a({code:e.SendbirdErrorCode.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}},{key:"statLogUploadLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}},{key:"malformedDataError",get:function(){return new a({code:e.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}}])}(y(Error)),M=[e.SendbirdErrorCode.CONNECTION_REQUIRED,e.SendbirdErrorCode.NETWORK_ERROR,e.SendbirdErrorCode.ACK_TIMEOUT,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,e.SendbirdErrorCode.REQUEST_CANCELED,e.SendbirdErrorCode.INTERNAL_SERVER_ERROR,e.SendbirdErrorCode.RATE_LIMIT_EXCEEDED,e.SendbirdErrorCode.UNKNOWN_SERVER_ERROR,e.SendbirdErrorCode.USER_DEACTIVATED,e.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],O=[e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.CONNECTION_REQUIRED],U=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},D=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||("string"!=typeof e?"object"===m(e)?R(e,t):L(e,t):m(t)===e)},R=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Object.values(e).includes(t)},L=function(e,t){return t instanceof e},P=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Array.isArray(t)&&t.every((function(t){return D(e,t)}))},F=function(e){return!!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))||"number"==typeof e&&13===e.toString().length},q=function(e){return e>0&&O.indexOf(e)>=0},H=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))return!0;var t="object"===m(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},G=function(e){return null==e},j=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,i=t.typingIndicatorInvalidateTime,s=void 0===i?1e4:i,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,d=t.websocketPayloadDecompression,h=void 0===d||d,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=s,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=h}),[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){D("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){D("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){D("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){D("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){D("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}])}(),V={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){return i((function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}),[{key:"_savePreferenceKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:v(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._version=n,this._keysAddress=e,a="".concat(e,".metadata.version"),r.next=5,this._store.get(a);case 5:return i=r.sent,r.next=8,this._store.get(e);case 8:if(r.t1=t=r.sent,r.t0=null!==r.t1,!r.t0){r.next=12;break}r.t0=void 0!==t;case 12:if(!r.t0){r.next=16;break}r.t2=t,r.next=17;break;case 16:r.t2=[];case 17:if(o=r.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},a=n.maxSize,i=void 0===a?256:a,s=n.clearOrder,o=void 0===s?e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT:s,u=n.customClearOrderComparator,c=n.enableAutoResend,l=void 0===c||c;r(this,t),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(i,64),u?(this._clearOrder=o,this._customClearOrderComparator=u):this._clearOrder=e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=l}),[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var t;return this._clearOrder===e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(t=this._customClearOrderComparator)&&void 0!==t?t:this._clearOrderComparatorUseMessageCollectionAccessedAt}},{key:"enableAutoResend",get:function(){return this._enableAutoResend}}])}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(K||(K={}));var Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue=function(){return i((function e(){r(this,e),this.isRefreshing=!1}),[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"hasChatServicePermission",get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(K.CHAT))}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}])}(),ce=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)}))},le=function(){return i((function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=ce()}),[{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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))}}])}(),de=function(){return i((function e(){r(this,e),this._container={}}),[{key:"on",value:function(e,t){return new le({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new le({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],i=s(n.keys());try{for(i.s();!(r=i.n()).done;){var o=r.value,u=n.get(o);u.handler(t),u.occurence>0&&(u.occurence--,0===u.occurence&&a.push(o))}}catch(e){i.e(e)}finally{i.f()}a.forEach((function(e){return n.delete(e)}))}}}])}(),he=function(){return i((function e(){r(this,e),this._dispatcher=new de}),[{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)}}])}(),fe=i((function e(){r(this,e)})),pe=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},ve=function(e){if(null!=e){if("object"===m(e)){if(Array.isArray(e)){for(var t=v(e),n=0;n3&&void 0!==arguments[3]?arguments[3]:"";return r(this,t),(s=n(this,t))._iid=e,s.code=a,s.payload=i,s.requestId=null!==(o=i.req_id)&&void 0!==o?o:u,s}return c(t,e),i(t,[{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,n){var r=n.substring(0,4),a={};try{a=JSON.parse(n.substring(4))}catch(e){r="NOOP"}finally{return new t(e,r,a)}}}])}(fe),Qe=function(e){function t(e){var a,i,s=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?{}:u;return r(this,t),(a=n(this,t)).code=s,a.payload=c,a.requestId=null!==(i=a.payload.req_id)&&void 0!==i?i:ce(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return c(t,e),i(t,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}])}(fe),We=function(e){function t(e){var a,i=e.userId,s=e.authToken,o=e.services,u=e.expiringSession,c=void 0===u||u;return r(this,t),(a=n(this,t)).path="".concat(ge,"/").concat(i,"/session_key"),a.method=_e.POST,a.params=pe({token:s,services:o,expiring_session:!!c}),a.requireAuth=!1,a}return c(t,e),i(t)}(je),Ye=function(e){function t(e){var a=e.authToken,i=e.expiringSession,s=void 0===i||i,o=e.requestId,u=void 0===o?void 0:o;return r(this,t),n(this,t,[{code:"LOGI",payload:pe({token:a,expiring_session:s?1:0,req_id:u}),ackRequired:!0}])}return c(t,e),i(t)}(Qe),Ze=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.key,o=a.expires_at,u=a.services;return i.key=s,i.expiresAt=o,i.services=u,i}return c(t,e),i(t)}(Ve),Xe=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"LOGI",i])).error=null,s.newKey=null,s.newKey=null!==(o=i.new_key)&&void 0!==o?o:null,s.error=i.error?new A(i):null,s}return c(t,e),i(t)}(Ke),Je=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).statLog=e,a}return c(t,e),i(t)}(fe),$e=function(e){function t(e){var a,i=e.request,s=e.deferred,o=e.error,u=void 0===o?A.requestFailed:o;return r(this,t),(a=n(this,t)).request=i,a.deferred=s,a.error=u,a}return c(t,e),i(t)}(fe);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",e.NOTIFICATION="noti:stats",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Ge||(Ge={}));var et,tt,nt,rt=function(){return i((function e(t){var n=t.type,a=t.data,i=t.ts,s=void 0===i?Date.now():i;r(this,e),this.type=n,this.createdAt=s,this.data=a}),null,[{key:"payloadify",value:function(e){return pe({stat_type:e.type,ts:e.createdAt,data:pe(e.data)})}}])}(),at=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},it=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};e.SendbirdProduct=void 0,(et=e.SendbirdProduct||(e.SendbirdProduct={})).CHAT="chat",et.CALLS="calls",et.DESK="desk",et.LIVE="live",et.UIKIT_CHAT="uikit-chat",et.UIKIT_LIVE="uikit-live",e.SendbirdPlatform=void 0,(tt=e.SendbirdPlatform||(e.SendbirdPlatform={})).ANDROID="android",tt.IOS="ios",tt.JS="js",tt.UNREAL="unreal",tt.UNITY="unity",tt.REACT_NATIVE="react-native",tt.FLUTTER="flutter",e.DeviceOsPlatform=void 0,(nt=e.DeviceOsPlatform||(e.DeviceOsPlatform={})).ANDROID="android",nt.IOS="ios",nt.WEB="web",nt.MOBILE_WEB="mobile_web",nt.WINDOWS="windows";var st=i((function e(){r(this,e)}));st.sendbirdSdkUserAgentWithExtension=function(t){var n=at()?e.SendbirdPlatform.REACT_NATIVE:e.SendbirdPlatform.JS,r={main_sdk_info:"chat/".concat(n,"/").concat(C.SDK_VERSION),device_os_platform:it()?"mobile-web":"web",os_version:C.OS_VERSION};if(t){var a=t.sendbirdExtensions,i=t.deviceOS,s=t.customData,o=void 0===s?{}:s;i.version&&(r.os_version=i.version),i.platform&&(r.device_os_platform=i.platform),a.length>0&&(r.extension_sdk_info=a.map((function(e){var t=e.product,n=e.platform,r=e.version;return"".concat(t,"/").concat(n,"/").concat(r)})).join(",")),Object.keys(r).forEach((function(e){return delete o[e]})),Object.keys(o).length>0&&(r=Object.assign(Object.assign({},r),o))}return Object.entries(r).map((function(e){var t=f(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join("&")},st.userAgentWithExtension=function(e){var t=at()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):it()?"omobile-web":"oweb";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)};var ot=i((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=function(e){n(e)}}))})),ut=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).requestId=e.requestId,a}return c(t,e),i(t)}(fe),ct=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),e.messageToken&&(a.params=pe({mesg_token:e.messageToken})),a}return c(t,e),i(t)}(je),lt=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"DELM",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(o=i.sender_id)&&void 0!==o?o:void 0,s}return c(t,e),i(t)}(Ke),dt=function(){return i((function e(t,n){var a=this,i=n.session,s=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._session=i,this._sdkState=s,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof ze&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}),[{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,i=n.sendbirdRuntimeEnvironment,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":st.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":st.sendbirdSdkUserAgentWithExtension(i)});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(s["Session-Key"]=this._session.sessionKey),s["App-Id"]=r,this._session&&this._session.authToken&&(s["Access-Token"]=this._session.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new Je(new rt({type:Ge.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:"_isBodyRequired",value:function(e){var t=e.method;return t!==_e.GET&&(t!==_e.DELETE||e instanceof ct)}},{key:"send",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=t.path,a=t.method,i=t.uploadProgressHandler,s=this._isBodyRequired(t),o=this._sdkState.api,u="".concat(o.host).concat(r).concat(s?"":t.query),c=s?t.payload:null,l=this._createHeader(t,c instanceof FormData?c:void 0),h=new AbortController,f=h.signal,this._abortControl.set(t.requestId,h),p=Date.now(),n.prev=10,!i){n.next=32;break}return n.next=14,Promise.resolve().then((function(){return pm}));case 14:return v=n.sent,_=v.xmlHttpRequest,n.prev=16,n.next=19,_(this._iid,{requestId:t.requestId,method:t.method,url:u,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i});case 19:return m=n.sent,this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",m);case 25:if(n.prev=25,n.t0=n.catch(16),!(n.t0 instanceof A&&n.t0.code===e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED)){n.next=31;break}this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),n.next=32;break;case 31:throw n.t0;case 32: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){n.next=36;break}return n.next=36,Promise.resolve().then((function(){return vm}));case 36:if("function"==typeof fetch){n.next=39;break}return n.next=39,Promise.resolve().then((function(){return Gm}));case 39:return n.next=41,fetch(u,{method:a,body:c,headers:l,signal:f});case 41:return g=n.sent,n.next=44,g.json();case 44:if(y=n.sent,!g.ok&&!g.redirected){n.next=51;break}return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",new Ve(this._iid,y));case 51:if(!y){n.next=70;break}if(!(E=new A(y)).isSessionExpiredError){n.next=62;break}if(this._dispatcher.dispatch(new Be({reason:E.code,message:E.message})),t instanceof We){n.next=59;break}return k=new ot,this._dispatcher.dispatch(new $e({request:t,deferred:k,error:E})),n.abrupt("return",k.promise);case 59:case 67:throw E;case 62:if(!E.isSessionInvalidatedError){n.next=67;break}throw this._dispatcher.dispatch(new Be({reason:E.code,message:E.message})),E;case 68:n.next=71;break;case 70:throw A.requestFailed;case 71:n.next=87;break;case 73:if(n.prev=73,n.t1=n.catch(10),this._statLogApiResult(t,p,n.t1),!(n.t1 instanceof A)){n.next=81;break}throw this._logger.debug("fail api request",n.t1),n.t1;case 81:if("AbortError"!==(null===n.t1||void 0===n.t1?void 0:n.t1.name)){n.next=85;break}throw A.requestCanceled;case 85:throw this._logger.debug("fail api request",n.t1),A.networkError;case 87:case"end":return n.stop()}}),n,this,[[10,73],[16,25]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new ut({requestId:e}))}},{key:"cancelAll",value:function(){var e,t=s(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(),this._dispatcher.dispatch(new ut({}))}}])}(),ht=function(){};function ft(e){let t=e.length;for(;--t>=0;)e[t]=0}const pt=256,vt=286,_t=30,mt=15,gt=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]),yt=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]),Et=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),kt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bt=new Array(576);ft(bt);const Ct=new Array(60);ft(Ct);const wt=new Array(512);ft(wt);const xt=new Array(256);ft(xt);const St=new Array(29);ft(St);const Tt=new Array(_t);function It(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 Nt,At,Mt;function Ot(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ft(Tt);const Ut=e=>e<256?wt[e]:wt[256+(e>>>7)],Dt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Rt=(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<{Rt(e,n[2*t],n[2*t+1])},Pt=(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,i,s=0;for(a=1;a<=mt;a++)s=s+n[a-1]<<1,r[a]=s;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=Pt(r[t]++,t))}},qt=e=>{let t;for(t=0;t{e.bi_valid>8?Dt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Gt=(e,t,n,r)=>{const a=2*t,i=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,i,s,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?Lt(e,a,t):(i=xt[a],Lt(e,i+pt+1,t),s=gt[i],0!==s&&(a-=St[i],Rt(e,a,s)),r--,i=Ut(r),Lt(e,i,n),s=yt[i],0!==s&&(r-=Tt[i],Rt(e,r,s)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,i=t.stat_desc.elems;let s,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)jt(e,n,s);u=i;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],jt(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,n[2*u]=n[2*s]+n[2*o],e.depth[u]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,n[2*s+1]=n[2*o+1]=u,e.heap[1]=u++,jt(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,i=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,d,h,f,p,v=0;for(h=0;h<=mt;h++)e.bl_count[h]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],h=n[2*n[2*l+1]+1]+1,h>u&&(h=u,v++),n[2*l+1]=h,l>r||(e.bl_count[h]++,f=0,l>=o&&(f=s[l-o]),p=n[2*l],e.opt_len+=p*(h+f),i&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(h=u-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(h=u;0!==h;h--)for(l=e.bl_count[h];0!==l;)d=e.heap[--c],d>r||(n[2*d+1]!==h&&(e.opt_len+=(h-n[2*d+1])*n[2*d],n[2*d+1]=h),l--)}})(e,t),Ft(n,c,e.bl_count)},Bt=(e,t,n)=>{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=s,s=t[2*(r+1)+1],++o{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),r=0;r<=n;r++)if(a=s,s=t[2*(r+1)+1],!(++o{Rt(e,0+(r?1:0),3),Ht(e),Dt(e,n),Dt(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Yt=(e,t,n,r)=>{let a,i,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(Bt(e,e.dyn_ltree,e.l_desc.max_code),Bt(e,e.dyn_dtree,e.d_desc.max_code),zt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*kt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=a&&(a=i)):a=i=n+5,n+4<=a&&-1!==t?Wt(e,t,n,r):4===e.strategy||i===a?(Rt(e,2+(r?1:0),3),Vt(e,bt,Ct)):(Rt(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(Rt(e,t-257,5),Rt(e,n-1,5),Rt(e,r-4,4),a=0;a{Qt||((()=>{let e,t,n,r,a;const i=new Array(16);for(n=0,r=0;r<28;r++)for(St[r]=n,e=0;e<1<>=7;r<_t;r++)for(Tt[r]=a<<7,e=0;e<1<(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*(xt[n]+pt+1)]++,e.dyn_dtree[2*Ut(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Rt(e,2,3),Lt(e,256,bt),(e=>{16===e.bi_valid?(Dt(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 Xt=(e,t,n,r)=>{let a=65535&e,i=e>>>16&65535,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{a=a+t[r++]|0,i=i+a|0}while(--s);a%=65521,i%=65521}return a|i<<16};const Jt=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 $t=(e,t,n,r)=>{const a=Jt,i=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return~e},en={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"},tn={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:nn,_tr_stored_block:rn,_tr_flush_block:an,_tr_tally:sn,_tr_align:on}=Zt,{Z_NO_FLUSH:un,Z_PARTIAL_FLUSH:cn,Z_FULL_FLUSH:ln,Z_FINISH:dn,Z_BLOCK:hn,Z_OK:fn,Z_STREAM_END:pn,Z_STREAM_ERROR:vn,Z_DATA_ERROR:_n,Z_BUF_ERROR:mn,Z_DEFAULT_COMPRESSION:gn,Z_FILTERED:yn,Z_HUFFMAN_ONLY:En,Z_RLE:kn,Z_FIXED:bn,Z_DEFAULT_STRATEGY:Cn,Z_UNKNOWN:wn,Z_DEFLATED:xn}=tn,Sn=258,Tn=262,In=42,Nn=113,An=666,Mn=(e,t)=>(e.msg=en[t],t),On=e=>2*e-(e>4?9:0),Un=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Dn=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 Rn=(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))},Pn=(e,t)=>{an(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Ln(e.strm)},Fn=(e,t)=>{e.pending_buf[e.pending++]=t},qn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Hn=(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=Xt(e.adler,t,a,n):2===e.state.wrap&&(e.adler=$t(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},Gn=(e,t)=>{let n,r,a=e.max_chain_length,i=e.strstart,s=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,d=e.prev,h=e.strstart+Sn;let f=c[i+s-1],p=c[i+s];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+s]===p&&c[n+s-1]===f&&c[n]===c[i]&&c[++n]===c[i+1]){i+=2,n++;do{}while(c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&is){if(e.match_start=t,s=r,r>=o)break;f=c[i+s-1],p=c[i+s]}}}while((t=d[t&l])>u&&0!=--a);return s<=e.lookahead?s:e.lookahead},jn=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),Dn(e),r+=t),0===e.strm.avail_in)break;if(n=Hn(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=Rn(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=Rn(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,i=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Ln(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(Hn(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 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&&(Hn(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,i=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=i||(r||t===dn)&&t!==un&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,s=t===dn&&0===e.strm.avail_in&&n===r?1:0,rn(e,e.block_start,n,s),e.block_start+=n,Ln(e.strm)),s?3:1)},zn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=Rn(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=Gn(e,n)),e.match_length>=3)if(r=sn(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=Rn(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=Rn(e,e.ins_h,e.window[e.strstart+1]);else r=sn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Pn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2},Bn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=Rn(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=sn(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=Rn(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&&(Pn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=sn(e,0,e.window[e.strstart-1]),r&&Pn(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=sn(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2};function Kn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const Qn=[new Kn(0,0,0,0,Vn),new Kn(4,4,8,4,zn),new Kn(4,5,16,8,zn),new Kn(4,6,32,32,zn),new Kn(4,4,16,16,Bn),new Kn(8,16,32,32,Bn),new Kn(8,16,128,128,Bn),new Kn(8,32,128,256,Bn),new Kn(32,128,258,1024,Bn),new Kn(32,258,258,4096,Bn)];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=xn,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 Yn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==In&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Nn&&t.status!==An?1:0},Zn=e=>{if(Yn(e))return Mn(e,vn);e.total_in=e.total_out=0,e.data_type=wn;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?In:Nn,e.adler=2===t.wrap?0:1,t.last_flush=-2,nn(t),fn},Xn=e=>{const t=Zn(e);var n;return t===fn&&((n=e.state).window_size=2*n.w_size,Un(n.head),n.max_lazy_match=Qn[n.level].max_lazy,n.good_match=Qn[n.level].good_length,n.nice_match=Qn[n.level].nice_length,n.max_chain_length=Qn[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},Jn=(e,t,n,r,a,i)=>{if(!e)return vn;let s=1;if(t===gn&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),a<1||a>9||n!==xn||r<8||r>15||t<0||t>9||i<0||i>bn||8===r&&1!==s)return Mn(e,vn);8===r&&(r=9);const o=new Wn;return e.state=o,o.strm=e,o.status=In,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<Jn(e,t,xn,15,8,Cn),deflateInit2:Jn,deflateReset:Xn,deflateResetKeep:Zn,deflateSetHeader:(e,t)=>Yn(e)||2!==e.state.wrap?vn:(e.state.gzhead=t,fn),deflate:(e,t)=>{if(Yn(e)||t>hn||t<0)return e?Mn(e,vn):vn;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===An&&t!==dn)return Mn(e,0===e.avail_out?mn:vn);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Ln(e),0===e.avail_out)return n.last_flush=-1,fn}else if(0===e.avail_in&&On(t)<=On(r)&&t!==dn)return Mn(e,mn);if(n.status===An&&0!==e.avail_in)return Mn(e,mn);if(n.status===In&&0===n.wrap&&(n.status=Nn),n.status===In){let t=xn+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=En||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,qn(n,t),0!==n.strstart&&(qn(n,e.adler>>>16),qn(n,65535&e.adler)),e.adler=1,n.status=Nn,Ln(e),0!==n.pending)return n.last_flush=-1,fn}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>=En||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=$t(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>=En||n.level<2?4:0),Fn(n,3),n.status=Nn,Ln(e),0!==n.pending)return n.last_flush=-1,fn;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=$t(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,Ln(e),0!==n.pending)return n.last_flush=-1,fn;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=$t(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=$t(e.adler,n.pending_buf,n.pending-r,r)),Ln(e),0!==n.pending)return n.last_flush=-1,fn;r=0}t=n.gzindexr&&(e.adler=$t(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=$t(e.adler,n.pending_buf,n.pending-r,r)),Ln(e),0!==n.pending)return n.last_flush=-1,fn;r=0}t=n.gzindexr&&(e.adler=$t(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Ln(e),0!==n.pending))return n.last_flush=-1,fn;Fn(n,255&e.adler),Fn(n,e.adler>>8&255),e.adler=0}if(n.status=Nn,Ln(e),0!==n.pending)return n.last_flush=-1,fn}if(0!==e.avail_in||0!==n.lookahead||t!==un&&n.status!==An){let r=0===n.level?Vn(n,t):n.strategy===En?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(jn(e),0===e.lookahead)){if(t===un)return 1;break}if(e.match_length=0,n=sn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Pn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===kn?((e,t)=>{let n,r,a,i;const s=e.window;for(;;){if(e.lookahead<=Sn){if(jn(e),e.lookahead<=Sn&&t===un)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=s[a],r===s[++a]&&r===s[++a]&&r===s[++a])){i=e.strstart+Sn;do{}while(r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=sn(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=sn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Pn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===dn?(Pn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Pn(e,!1),0===e.strm.avail_out)?1:2})(n,t):Qn[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),fn;if(2===r&&(t===cn?on(n):t!==hn&&(rn(n,0,0,!1),t===ln&&(Un(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Ln(e),0===e.avail_out))return n.last_flush=-1,fn}return t!==dn?fn:n.wrap<=0?pn:(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)):(qn(n,e.adler>>>16),qn(n,65535&e.adler)),Ln(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?fn:pn)},deflateEnd:e=>{if(Yn(e))return vn;const t=e.state.status;return e.state=null,t===Nn?Mn(e,_n):fn},deflateSetDictionary:(e,t)=>{let n=t.length;if(Yn(e))return vn;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==In||r.lookahead)return vn;if(1===a&&(e.adler=Xt(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 i=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,jn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Rn(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,jn(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=o,e.avail_in=i,r.wrap=a,fn},deflateInfo:"pako deflate (from Nodeca project)"};const er=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var tr={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)er(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;rr[254]=rr[254]=1;var ar={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,i,s=e.length,o=0;for(a=0;a>>6,t[i++]=128|63&n):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|63&n):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=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 i=new Array(2*n);for(a=0,r=0;r4)i[a++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?i[a++]=65533:t<65536?i[a++]=t:(t-=65536,i[a++]=55296|t>>10&1023,i[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&nr)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+rr[e[n]]>t?n:t}};var ir=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 sr=Object.prototype.toString,{Z_NO_FLUSH:or,Z_SYNC_FLUSH:ur,Z_FULL_FLUSH:cr,Z_FINISH:lr,Z_OK:dr,Z_STREAM_END:hr,Z_DEFAULT_COMPRESSION:fr,Z_DEFAULT_STRATEGY:pr,Z_DEFLATED:vr}=tn;function _r(e){this.options=tr.assign({level:fr,method:vr,chunkSize:16384,windowBits:15,memLevel:8,strategy:pr},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 ir,this.strm.avail_out=0;let n=$n.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==dr)throw new Error(en[n]);if(t.header&&$n.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?ar.string2buf(t.dictionary):"[object ArrayBuffer]"===sr.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=$n.deflateSetDictionary(this.strm,e),n!==dr)throw new Error(en[n]);this._dict_set=!0}}function mr(e,t){const n=new _r(t);if(n.push(e,!0),n.err)throw n.msg||en[n.err];return n.result}_r.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,i;if(this.ended)return!1;for(i=t===~~t?t:!0===t?lr:or,"string"==typeof e?n.input=ar.string2buf(e):"[object ArrayBuffer]"===sr.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),(i===ur||i===cr)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=$n.deflate(n,i),a===hr)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=$n.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===dr;if(0!==n.avail_out){if(i>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},_r.prototype.onData=function(e){this.chunks.push(e)},_r.prototype.onEnd=function(e){e===dr&&(this.result=tr.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var gr={Deflate:_r,deflate:mr,deflateRaw:function(e,t){return(t=t||{}).raw=!0,mr(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,mr(e,t)},constants:tn};const yr=16209;var Er=function(e,t){let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x;const S=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,i=a-(t-e.avail_out),s=a+(e.avail_out-257),o=S.dmax,u=S.wsize,c=S.whave,l=S.wnext,d=S.window,h=S.hold,f=S.bits,p=S.lencode,v=S.distcode,_=(1<>>24,h>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(64&y){if(32&y){S.mode=16191;break e}e.msg="invalid literal/length code",S.mode=yr;break e}g=p[(65535&g)+(h&(1<>>=y,f-=y),f<15&&(h+=w[n++]<>>24,h>>>=y,f-=y,y=g>>>16&255,16&y){if(k=65535&g,y&=15,fo){e.msg="invalid distance too far back",S.mode=yr;break e}if(h>>>=y,f-=y,y=a-i,k>y){if(y=k-y,y>c&&S.sane){e.msg="invalid distance too far back",S.mode=yr;break e}if(b=0,C=d,0===l){if(b+=u-y,y2;)x[a++]=C[b++],x[a++]=C[b++],x[a++]=C[b++],E-=3;E&&(x[a++]=C[b++],E>1&&(x[a++]=C[b++]))}else{b=a-k;do{x[a++]=x[b++],x[a++]=x[b++],x[a++]=x[b++],E-=3}while(E>2);E&&(x[a++]=x[b++],E>1&&(x[a++]=x[b++]))}break}if(64&y){e.msg="invalid distance code",S.mode=yr;break e}g=v[(65535&g)+(h&(1<>3,n-=E,f-=E<<3,h&=(1<{const u=o.bits;let c,l,d,h,f,p,v=0,_=0,m=0,g=0,y=0,E=0,k=0,b=0,C=0,w=0,x=null;const S=new Uint16Array(16),T=new Uint16Array(16);let I,N,A,M=null;for(v=0;v<=kr;v++)S[v]=0;for(_=0;_=1&&0===S[g];g--);if(y>g&&(y=g),0===g)return a[i++]=20971520,a[i++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(T[1]=0,v=1;v852||2===e&&C>592)return 1;for(;;){I=v-k,s[_]+1=p?(N=M[s[_]-p],A=x[s[_]-p]):(N=96,A=0),c=1<>k)+l]=I<<24|N<<16|A}while(0!==l);for(c=1<>=1;if(0!==c?(w&=c-1,w+=c):w=0,_++,0==--S[v]){if(v===g)break;v=t[n+s[_]]}if(v>y&&(w&h)!==d){for(0===k&&(k=y),f+=m,E=v-k,b=1<852||2===e&&C>592)return 1;d=w&h,a[d]=y<<24|E<<16|f-i}}return 0!==w&&(a[f+w]=v-k<<24|64<<16),o.bits=y,0};const{Z_FINISH:Tr,Z_BLOCK:Ir,Z_TREES:Nr,Z_OK:Ar,Z_STREAM_END:Mr,Z_NEED_DICT:Or,Z_STREAM_ERROR:Ur,Z_DATA_ERROR:Dr,Z_MEM_ERROR:Rr,Z_BUF_ERROR:Lr,Z_DEFLATED:Pr}=tn,Fr=16180,qr=16190,Hr=16191,Gr=16192,jr=16194,Vr=16199,zr=16200,Br=16206,Kr=16209,Qr=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 Yr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Zr=e=>{if(Yr(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,Ar},Xr=e=>{if(Yr(e))return Ur;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Zr(e)},Jr=(e,t)=>{let n;if(Yr(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,Xr(e))},$r=(e,t)=>{if(!e)return Ur;const n=new Wr;e.state=n,n.strm=e,n.window=null,n.mode=Fr;const r=Jr(e,t);return r!==Ar&&(e.state=null),r};let ea,ta,na=!0;const ra=e=>{if(na){ea=new Int32Array(512),ta=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(Sr(1,e.lens,0,288,ea,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Sr(2,e.lens,0,32,ta,0,e.work,{bits:5}),na=!1}e.lencode=ea,e.lenbits=9,e.distcode=ta,e.distbits=5},aa=(e,t,n,r)=>{let a;const i=e.state;return null===i.window&&(i.wsize=1<=i.wsize?(i.window.set(t.subarray(n-i.wsize,n),0),i.wnext=0,i.whave=i.wsize):(a=i.wsize-i.wnext,a>r&&(a=r),i.window.set(t.subarray(n-r,n-r+a),i.wnext),(r-=a)?(i.window.set(t.subarray(n-r,n),0),i.wnext=r,i.whave=i.wsize):(i.wnext+=a,i.wnext===i.wsize&&(i.wnext=0),i.whave$r(e,15),inflateInit2:$r,inflate:(e,t)=>{let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w=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(Yr(e)||!e.output||!e.input&&0!==e.avail_in)return Ur;n=e.state,n.mode===Hr&&(n.mode=Gr),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,d=o,h=u,C=Ar;e:for(;;)switch(n.mode){case Fr:if(0===n.wrap){n.mode=Gr;break}for(;l<16;){if(0===o)break e;o--,c+=r[i++]<>>8&255,n.check=$t(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=Kr;break}if((15&c)!==Pr){e.msg="unknown compression method",n.mode=Kr;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=Kr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=$t(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[i++]<>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=$t(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[i++]<>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=$t(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[i++]<>>8&255,n.check=$t(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(i,i+f),b)),512&n.flags&&4&n.wrap&&(n.check=$t(n.check,r,f,i)),o-=f,i+=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[i+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=Hr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[i++]<>>=7&l,l-=7&l,n.mode=Br;break}for(;l<3;){if(0===o)break e;o--,c+=r[i++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(ra(n),n.mode=Vr,t===Nr){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Kr}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[i++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Kr;break}if(n.length=65535&c,c=0,l=0,n.mode=jr,t===Nr)break e;case jr: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(i,i+f),s),o-=f,i+=f,u-=f,s+=f,n.length-=f;break}n.mode=Hr;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[i++]<>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Kr;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,S={bits:n.lenbits},C=Sr(0,n.lens,0,19,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid code lengths set",n.mode=Kr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=_,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=Kr;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=Kr;break}for(;f--;)n.lens[n.have++]=b}}if(n.mode===Kr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Kr;break}if(n.lenbits=9,S={bits:n.lenbits},C=Sr(1,n.lens,0,n.nlen,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid literal/lengths set",n.mode=Kr;break}if(n.distbits=6,n.distcode=n.distdyn,S={bits:n.distbits},C=Sr(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,S),n.distbits=S.bits,C){e.msg="invalid distances set",n.mode=Kr;break}if(n.mode=Vr,t===Nr)break e;case Vr:n.mode=zr;case zr:if(o>=6&&u>=258){e.next_out=s,e.avail_out=u,e.next_in=i,e.avail_in=o,n.hold=c,n.bits=l,Er(e,h),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===Hr&&(n.back=-1);break}for(n.back=0;w=n.lencode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=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=Hr;break}if(64&m){e.msg="invalid literal/length code",n.mode=Kr;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(T=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;w=n.distcode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=Kr;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(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=Kr;break}n.mode=16204;case 16204:if(0===u)break e;if(f=h-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Kr;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=s-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[s++]=v[p++]}while(--f);0===n.length&&(n.mode=zr);break;case 16205:if(0===u)break e;a[s++]=n.length,u--,n.mode=zr;break;case Br:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[i++]<{if(Yr(e))return Ur;let t=e.state;return t.window&&(t.window=null),e.state=null,Ar},inflateGetHeader:(e,t)=>{if(Yr(e))return Ur;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Ar):Ur},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,i;return Yr(e)?Ur:(r=e.state,0!==r.wrap&&r.mode!==qr?Ur:r.mode===qr&&(a=1,a=Xt(a,t,n,0),a!==r.check)?Dr:(i=aa(e,t,n,n),i?(r.mode=16210,Rr):(r.havedict=1,Ar)))},inflateInfo:"pako inflate (from Nodeca project)"};var sa=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 oa=Object.prototype.toString,{Z_NO_FLUSH:ua,Z_FINISH:ca,Z_OK:la,Z_STREAM_END:da,Z_NEED_DICT:ha,Z_STREAM_ERROR:fa,Z_DATA_ERROR:pa,Z_MEM_ERROR:va}=tn;function _a(e){this.options=tr.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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ir,this.strm.avail_out=0;let n=ia.inflateInit2(this.strm,t.windowBits);if(n!==la)throw new Error(en[n]);if(this.header=new sa,ia.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=ar.string2buf(t.dictionary):"[object ArrayBuffer]"===oa.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ia.inflateSetDictionary(this.strm,t.dictionary),n!==la)))throw new Error(en[n])}function ma(e,t){const n=new _a(t);if(n.push(e),n.err)throw n.msg||en[n.err];return n.result}_a.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let i,s,o;if(this.ended)return!1;for(s=t===~~t?t:!0===t?ca:ua,"[object ArrayBuffer]"===oa.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),i=ia.inflate(n,s),i===ha&&a&&(i=ia.inflateSetDictionary(n,a),i===la?i=ia.inflate(n,s):i===pa&&(i=ha));n.avail_in>0&&i===da&&n.state.wrap>0&&0!==e[n.next_in];)ia.inflateReset(n),i=ia.inflate(n,s);switch(i){case fa:case pa:case ha:case va:return this.onEnd(i),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||i===da))if("string"===this.options.to){let e=ar.utf8border(n.output,n.next_out),t=n.next_out-e,a=ar.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(i!==la||0!==o){if(i===da)return i=ia.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},_a.prototype.onData=function(e){this.chunks.push(e)},_a.prototype.onEnd=function(e){e===la&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=tr.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ga={Inflate:_a,inflate:ma,inflateRaw:function(e,t){return(t=t||{}).raw=!0,ma(e,t)},ungzip:ma,constants:tn};const{Deflate:ya,deflate:Ea,deflateRaw:ka,gzip:ba}=gr,{Inflate:Ca,inflate:wa,inflateRaw:xa,ungzip:Sa}=ga;var Ta,Ia={Deflate:ya,deflate:Ea,deflateRaw:ka,gzip:ba,Inflate:Ca,inflate:wa,inflateRaw:xa,ungzip:Sa,constants:tn},Na=function(e){return E(void 0,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Ia.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,n));case 2:case"end":return t.stop()}}),t)})))};e.ConnectionState=void 0,(Ta=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",Ta.OPEN="OPEN",Ta.CLOSED="CLOSED";var Aa,Ma=function(t){function a(e,t){var i,s=t.sdkState,o=t.dispatcher,u=t.logger;return r(this,a),(i=n(this,a)).lastActive=0,i._iid=e,i._sdkState=s,i._dispatcher=o,i._logger=u,i}return c(a,t),i(a,[{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:"ws",get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ke.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 Be(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return E(this,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){r._logger.debug("websocket open"),r.dispatch("open")},this._ws.onmessage=function(e){return E(r,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)){t.next=38;break}if(!(e.data instanceof Blob)){t.next=7;break}(r=new FileReader).readAsArrayBuffer(e.data),r.onloadend=function(){return E(u,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Na(r.result);case 3:t=e.sent,this._handleMessage(t),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),this.error(e.t0);case 10:case"end":return e.stop()}}),e,this,[[0,7]])})))},t.next=36;break;case 7:if(!(e.data instanceof ArrayBuffer)){t.next=20;break}return t.prev=8,t.next=11,Na(new Uint8Array(e.data));case 11:a=t.sent,this._handleMessage(a),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),this.error(t.t0);case 18:t.next=36;break;case 20:if(!("undefined"!=typeof Buffer&&e.data instanceof Buffer)){t.next=35;break}return t.prev=21,i=e.data,s=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),t.next=26,Na(s);case 26:o=t.sent,this._handleMessage(o),t.next=33;break;case 30:t.prev=30,t.t1=t.catch(21),this.error(t.t1);case 33:t.next=36;break;case 35:"string"==typeof e.data&&this._handleMessage(e.data);case 36:t.next=39;break;case 38:this._handleMessage(e.data);case 39:case"end":return t.stop()}}),t,this,[[8,15],[21,30]])})))},this._ws.onerror=function(){r._logger.debug("websocket error"),r.dispatch("error",A.networkError)},this._ws.onclose=function(){r._logger.debug("websocket close"),r.dispatch("close")},this.lastActive=Date.now();case 6:case"end":return n.stop()}}),n,this)})))}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws?(t._ws.onopen=ht,t._ws.onmessage=ht,t._ws.onerror=ht,t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=void 0):n()):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)}}])}(de),Oa=function(e){function t(e){var a,i=e.all,s=e.feed,o=e.custom_types,u=e.ts;return r(this,t),(a=n(this,t)).all=i,a.feed=s,a.customTypes=o,a.ts=u,a}return c(t,e),i(t)}(fe),Ua=function(){return i((function e(t,n){var a=this,i=n.session,s=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=s,this._dispatcher=o,this._logger=u,this.apiClient=new dt(t,{session:i,sdkState:s,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new Ma(t,{sdkState:s,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new Oa(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new A({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(A.connectionClosed)})),a._ackStateMap.clear()}))}),[{key:"_sendApiRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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(n=new ot,e.ackRequired){a=function(t,a){i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),r&&(clearTimeout(r),r=null),t?(i._logger.debug("fail websocket request",e.requestId,t),n.reject(t)):(i._logger.debug("receive websocket ack",e.requestId,e),i._logger.debug("receive websocket ack",a),n.resolve(a)))};try{r=setTimeout((function(){return a(A.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return a(void 0,e)},reject:function(e){return a(e)}}),this.websocketClient.send(e)}catch(e){a(e)}}else try{this.websocketClient.send(e),n.resolve()}catch(e){n.reject(e)}return t.abrupt("return",n.promise);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof je)){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 Qe)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw A.invalidParameters;case 11:case"end":return t.stop()}}),t,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}])}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(Aa||(Aa={}));var Da,Ra,La=function(e){function t(e){var a,i=e.stateType;return r(this,t),(a=n(this,t)).stateType=i,a}return c(t,e),i(t)}(fe),Pa=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Fa=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),qa=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Ha=function(){return i((function e(t){var n,a,i,s;r(this,e),this.isEnabled=null!==(n=t.enabled)&&void 0!==n&&n,this.feedChannels=null!==(a=t.feed_channels)&&void 0!==a?a:{},this.templateListToken=null!==(i=t.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(s=t.settings_updated_at)&&void 0!==s?s:0}),null,[{key:"payloadify",value:function(e){return pe(ve({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}])}(),Ga=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},ja=function(){return i((function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}),null,[{key:"payloadify",value:function(e){return pe(ve({last_updated_at:e.lastUpdatedAt}))}}])}(),Va=function(){return i((function e(t){var n;r(this,e),this.token=null!==(n=t.template_list_token)&&void 0!==n?n:""}),null,[{key:"payloadify",value:function(e){return pe(ve({template_list_token:e.token}))}}])}(),za=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180};r(this,e),this.minStatCount=t.min_stat_count,this.minInterval=1e3*t.min_interval,this.maxStatCountPerRequest=t.max_stat_count_per_request,this.lowerThreshold=t.lower_threshold,this.requestDelayRange=1e3*t.request_delay_range}),null,[{key:"payloadify",value:function(e){return pe(ve({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}])}(),Ba=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}};r(this,e),this.default=new za(t.default),this.realTime=new za(t.realtime)}),null,[{key:"payloadify",value:function(e){return pe(ve({default:za.payloadify(e.default),realtime:za.payloadify(e.realTime)}))}}])}(),Ka=1048576;e.UnreadCountThreadingPolicy=void 0,(Da=e.UnreadCountThreadingPolicy||(e.UnreadCountThreadingPolicy={}))[Da.NONE=0]="NONE",Da[Da.INCLUDE_REPLY=1]="INCLUDE_REPLY",Da[Da.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Da[Da.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",e.LastMessageThreadingPolicy=void 0,(Ra=e.LastMessageThreadingPolicy||(e.LastMessageThreadingPolicy={}))[Ra.NONE=0]="NONE",Ra[Ra.INCLUDE_REPLY=1]="INCLUDE_REPLY",Ra[Ra.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Ra[Ra.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";var Qa,Wa=function(){return i((function t(){var n,a,i,s,o,u,c,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),this.emojiHash=l.emoji_hash||"",this.uploadSizeLimit=l.file_upload_size_limit?l.file_upload_size_limit*Ka:Number.MAX_SAFE_INTEGER,this.useReaction=!!l.use_reaction,this.applicationAttributes=null!==(n=l.application_attributes)&&void 0!==n?n:[],this.premiumFeatureList=null!==(a=l.premium_feature_list)&&void 0!==a?a:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(i=l.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(s=l.allow_sdk_log_ingestion)||void 0===s||s,this.unreadCountThreadingPolicy=null!==(o=l.unread_cnt_threading_policy)&&void 0!==o?o:e.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(u=l.last_msg_threading_policy)&&void 0!==u?u:e.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new ja(null!==(c=l.uikit_config)&&void 0!==c?c:{}),this.notificationInfo=l.notifications?new Ha(l.notifications):null,this.messageTemplateInfo=l.message_template?new Va(l.message_template):null,this.statConfigInfo=l.log_publish_config?new Ba(l.log_publish_config):new Ba}),null,[{key:"payloadify",value:function(e){return pe(ve({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ka,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?ja.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Ha.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Va.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Ba.payloadify(e.statConfigInfo):null}))}}])}(),Ya=function(){return i((function e(t){r(this,e),this._iid="",this._iid=t}),null,[{key:"payloadify",value:function(e){return{}}}])}(),Za=function(e){function t(e){var a,i=e.userId,s=e.metadata;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s},a}return c(t,e),i(t)}(je),Xa=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaData=a,i}return c(t,e),i(t)}(Ve),Ja=function(e){function t(e){var a,i=e.userId,s=e.metadata,o=e.upsert;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s,upsert:o},a}return c(t,e),i(t)}(je),$a=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metadata=a,i}return c(t,e),i(t)}(Ve),ei=function(e){function t(e){var a,i=e.userId,s=e.metadataKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata/").concat(s),a}return c(t,e),i(t)}(je),ti=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata"),a}return c(t,e),i(t)}(je),ni=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},ri=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ai=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(Qa=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",Qa.OFFLINE="offline",Qa.NON_AVAILABLE="nonavailable";var ii,si=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y;return r(this,a),(s=n(this,a,[t])).userId=null!==(u=null!==(o=i.guest_id)&&void 0!==o?o:i.user_id)&&void 0!==u?u:"",s.nickname=null!==(l=null!==(c=i.nickname)&&void 0!==c?c:i.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(h=null!==(d=i.profile_url)&&void 0!==d?d:i.image)&&void 0!==h?h:"",s.requireAuth=null!==(f=i.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=i.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,R(e.UserOnlineState,i.is_online)?s.connectionStatus=i.is_online:D("boolean",i.is_online)&&(s.connectionStatus=i.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(_=i.is_active)||void 0===_||_,s.lastSeenAt=null!==(m=i.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=i.preferred_languages?v(i.preferred_languages):null,s.friendDiscoveryKey=null!==(g=i.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=i.friend_name)&&void 0!==y?y:null,s}return c(a,t),i(a,[{key:"profileUrl",get:function(){var e=es.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return ni(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 D("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,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(this._isValidMetaData(e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Za({userId:r.userId,metadata:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(Xa),u=o.metaData,this._applyMetaData(u),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(this._isValidMetaData(e)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Ja({userId:a.userId,metadata:e,upsert:t}),n.next=5,i.send(s);case 5:return o=n.sent,u=o.as($a),c=u.metadata,this._applyMetaData(c),n.abrupt("return",this.metaData);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ei({userId:r.userId,metadataKey:e}),t.next=5,a.send(i);case 5:return this._applyMetaData((s={},u=!0,(o=_(o=e))in s?Object.defineProperty(s,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):s[o]=u,s),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var s,o,u}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ti({userId:n.userId}),e.next=4,r.send(a);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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})))}}])}(Ya),oi=function(e){function t(e){var a,i=e.userProfile;return r(this,t),(a=n(this,t)).userProfile=i,a}return c(t,e),i(t)}(fe),ui=function(){return i((function e(t,n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new Wa(n),this.user=new si(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=n.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(s=n.pong_timeout)&&void 0!==s?s: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!==(h=null===(d=n.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==h?h: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}),[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=es.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 oi({userProfile:this}))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign(Object.assign({},si.payloadify(e.user)),Wa.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})))}}])}(),ci=function(e){function t(e){var a,i=e.request,s=void 0===i||i,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c,d=e.statConfigInfo;return r(this,t),(a=n(this,t)).request=s,a.features=Object.assign({localCache:!0,notification:!0},u),a.options=Object.assign({ingestion:!0},l),a.statConfigInfo=d,a}return c(t,e),i(t)}(fe),li=function(e){function t(e,a,i){var s,o,u,c,l;return r(this,t),(s=n(this,t,[e,a,i])).error=null,s.services=[],s.userProfile=new ui(e,i),s.deviceTokenLastDeletedAt=null!==(o=i.device_token_last_deleted_at)&&void 0!==o?o:0,s.key=null!==(u=i.key)&&void 0!==u?u:"",s.ekey=null!==(c=i.ekey)&&void 0!==c?c:"",s.error=i.error?new A(i):null,s.services=null!==(l=i.services)&&void 0!==l?l:[],s}return c(t,e),i(t,[{key:"applyTo",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=13;break}if(!(n=es.of(e))){t.next=10;break}return r=n.sessionManager,a=n.dispatcher,t.next=6,r.login(this);case 6:this.userProfile.apply(),a.dispatch(new ci({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),t.next=11;break;case 10:throw A.lostInstance;case 11:t.next=14;break;case 13:throw this.error;case 14:case"end":return t.stop()}}),t,this)})))}}],[{key:"asError",value:function(e){return new t("","LOGI",Object.assign({user_id:"",error:!0},e))}}])}(Ke),di=function(){return i((function e(){r(this,e),this.type=Aa.NONE,this.name="none"}),[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,t){return t.resetReconnectCount,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,t){return t.error,t.autoReconnect,t.cause,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}(),hi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=12;break;case 5:if(t.prev=5,t.t0=t.catch(0),!(t.t0 instanceof A)){t.next=11;break}t.t0.throwOutside(),t.next=12;break;case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,null,[[0,5]])})))},fi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=7;break;case 5:t.prev=5,t.t0=t.catch(0);case 7:case"end":return t.stop()}}),t,null,[[0,5]])})))},pi=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t)).type=Aa.LOGOUT,e.name="logout",e._wasPreviouslyConnected=null===(a=i.wasPreviouslyConnected)||void 0===a||a,e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=e.sdkState.userId,t.next=4,e.logout();case 4:return t.next=6,e.changeState(new Si,n);case 6:this._wasPreviouslyConnected&&hi((function(){return E(a,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(r)}));case 1:case"end":return t.stop()}}),t)})))}));case 7:case"end":return t.stop()}}),t,this)})))}}])}(di),vi=function(e){function t(){var e;return r(this,t),(e=n(this,t)).type=Aa.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),t)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ci({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Ei,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new pi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(di),_i=function(e){function t(e){var a,i=e.autoReconnect;return r(this,t),(a=n(this,t)).type=Aa.INTERNAL_DISCONNECTED,a.name="internaldisconnected",a._autoReconnect=!1,a._autoReconnect=i,a}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new Ei,n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ci({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Ei,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new vi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new pi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(di),mi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),t)})))},gi=function(){return i((function e(){r(this,e)}),[{key:"calcTimeout",value:function(){return 0}}])}(),yi=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new gi;return E(void 0,void 0,void 0,d().mark((function r(){var a,i,s,o,u;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=0,i=null,s=function(e){return i=null!=e?e:new Error("Halted")},o=function(){a=0};case 4:if(!(-1===t||a0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,e&&(this._webSocketClosedCause=ii.ExternalDisconnectWebSocket),t.next=4,n.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause});case 4:case"end":return t.stop()}}),t,this)})))}},{key:"logout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),t.next=4,n.onLogout(this._context,e);case 4:case"end":return t.stop()}}),t,this)})))}}])}(),Ci=function(t){function a(e){var t,i=e.authToken;return r(this,a),(t=n(this,a)).type=Aa.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=i,t}return c(a,t),i(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(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ot,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,yi((function(n){return E(i,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._haltConnect=n,r.prev=1,r.next=4,t.connect(this._authToken);case 4:r.next=16;break;case 6:if(r.prev=6,r.t0=r.catch(1),t.clearLoginTimer(),!(r.t0 instanceof A)){r.next=15;break}r.t1=r.t0.code,r.next=r.t1===e.SendbirdErrorCode.CONNECTION_CANCELED?13:15;break;case 13:return n(r.t0),r.abrupt("return");case 15:throw r.t0;case 16:case"end":return r.stop()}}),r,this,[[1,6]])})))}),t.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,t.changeState(new ki,r);case 8:hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(),t.connectionHandlers.forEach((function(e){e.onConnected&&e.onConnected(t.sdkState.userId)}));case 2:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),N(n.t0)){n.next=23;break}return n.next=16,t.disconnect();case 16:if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===e.SendbirdErrorCode.CONNECTION_CANCELED){n.next=20;break}return n.next=20,t.changeState(new Si,r);case 20:hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new ot,this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){var n=t.error,r=void 0===n?null:n,a=t.autoReconnect,i=void 0!==a&&a,s=t.cause,o=void 0===s?null:s;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Date.now(),this._halt(null!=r?r:wi(o)),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new _i({autoReconnect:i}),n);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new pi,n);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._halt(wi((null==t?void 0:t.cause)||null)),r=Date.now(),!e.hasSession){n.next=7;break}return n.next=5,e.changeState(new vi,r);case 5:n.next=9;break;case 7:return n.next=9,e.changeState(new pi,r);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),this._halt(null!=t?t:A.connectionCanceled),n.next=4,e.changeState(new pi,r);case 4:case"end":return n.stop()}}),n,this)})))}}])}(di);function wi(e){var t=A.connectionCanceled;if(e){var n=null;switch(e){case ii.ExternalSetBackground:n="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case ii.ExternalDisconnectWebSocket:n="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}n&&t.setDetail(n)}return t}var xi,Si=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).type=Aa.INITIALIZED,e.name="initialized",e}return c(t,e),i(t,[{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.changeState(new Ci({authToken:t}),r);case 3:case"end":return n.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new pi({wasPreviouslyConnected:!1}),n);case 3:case"end":return t.stop()}}),t)})))}}])}(di),Ti=function(e){function t(){return r(this,t),n(this,t,[{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1}])}return c(t,e),i(t)}(Qe),Ii=function(){return i((function e(t){var n=t.pingDelegate,a=t.sdkState,i=t.logger;r(this,e),this.pingDelegate=n,this.sdkState=a,this._logger=i}),[{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 Ti;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)}}])}(),Ni=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"],Ai=function(e){function t(e,a){var i,s,o=a.sdkState,u=a.cacheContext,c=a.connectionHandlers,l=a.sessionManager,d=a.websocketClient,h=a.dispatcher,f=a.logger,p=a.entryState,v=void 0===p?new Si:p;return r(this,t),(i=n(this,t))._stateUpdatedAt=0,i._connectingAt=0,i._connectionRequestQueue=[],i._iid=e,i.sdkState=o,i.cacheContext=u,i.connectionHandlers=c,i._sessionManager=l,i._websocketClient=d,i._dispatcher=h,i._logger=f,i._currentState=v,(null===(s=i.sdkState.websocket)||void 0===s?void 0:s.pingerDisabled)||(i._pinger=new Ii({pingDelegate:{send:function(e){return i._websocketClient.send(e)},error:function(e){return i._websocketClient.error(e)}},sdkState:i.sdkState,logger:f})),i._websocketClient.on("open",(function(){i._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)i.clearLoginTimer(),i._dispatcher.dispatch(e.as(li))})).on("ping-refresh",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){i._logiProcessingTimer=setTimeout((function(){i._logiProcessingTimer=void 0,i._unresolvedLogi||i._rejectConnectionRequest(A.networkError)}),500)})),i._dispatcher.on((function(e){e instanceof li&&(i._unresolvedLogi=e,i._tryResolveConnectionRequest())})),i}return c(t,e),i(t,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.session.hasSession}},{key:"changeState",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>=this._stateUpdatedAt)){n.next=8;break}return this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new La({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),n.next=7,this._currentState.run(this);case 7:return n.abrupt("return",!0);case 8:return n.abrupt("return",!1);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._unresolvedLogi,!this._websocketClient.isOpen||!n){t.next=16;break}if(this._unresolvedLogi=void 0,n.error){t.next=13;break}return t.next=6,n.applyTo(this._iid);case 6: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=16;break;case 13:this._sessionManager.session.authToken=void 0,n.error.isSessionExpiredError||n.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Be({reason:n.error.code,message:n.error.message})):this._logger.warn("login failed: ".concat(n.error)),this._rejectConnectionRequest(n.error);case 16:case"end":return t.stop()}}),t,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=this.sdkState,n=t.appId,r=t.appVersion,a=t.userId,i=t.extensions,s=t.sendbirdRuntimeEnvironment,o=this.cacheContext.localCacheEnabled,u=this._sessionManager.session,c=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=i?i:{}).sb_uikit,d=st.userAgentWithExtension(i);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(u.hasSession?"":"&user_id=".concat(encodeURIComponent(a)),"&pmce=").concat(c?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent(st.sendbirdSdkUserAgentWithExtension(s)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(Ni))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new Je(new rt({type:Ge.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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(A.connectionCanceled)),r=new ot,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){s._loginTimer=void 0,s._rejectConnectionRequest(A.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),a=this._sessionManager.session,t&&(a.authToken=t,a.sessionKey=void 0),i=this._url(),a.sessionKey||a.authToken?this._websocketClient.connect(i,JSON.stringify(a.hasSession?{auth:a.sessionKey}:{token:a.authToken})):this._websocketClient.connect(i,JSON.stringify({}))),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(li.asError(A.connectionRenew))}},{key:"disconnect",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){return d().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.disconnect();case 4:return e.next=6,this._sessionManager.clear();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}])}(de),Mi=function(e){function t(e){var a,i=e.appId,s=e.userId,o=e.includeUIKitConfig,u=void 0!==o&&o,c=e.localCacheEnabled,l=void 0===c||c,d=e.expiringSession,h=void 0===d||d;return r(this,t),(a=n(this,t)).path="".concat(ye,"/").concat(s,"/authentication"),a.method=_e.POST,a.params=pe({expiring_session:!!h,include_logi:!0,include_extra_data:String(Ni),uikit_config:u,use_local_cache:l,app_id:i}),a.requireAuth=!1,a}return c(t,e),i(t)}(je),Oi=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).logi=new li(e,"LOGI",a),i}return c(t,e),i(t)}(Ve);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(xi||(xi={}));var Ui,Di,Ri=[We,Mi],Li=function(){return i((function e(t,n){var a=this,i=n.session,o=n.sdkState,u=n.dispatcher,c=n.logger,l=n.useFetchCompat,d=void 0!==l&&l;r(this,e),this._currentConnectionStateType=Aa.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Ua(t,{session:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:d}),this._session=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){var t;if(e instanceof La){var n=e.stateType;switch(a._currentConnectionStateType=n,n){case Aa.CONNECTED:a._resolveLazyCallQueue();break;case Aa.INITIALIZED:case Aa.INTERNAL_DISCONNECTED:case Aa.EXTERNAL_DISCONNECTED:case Aa.LOGOUT:a._rejectLazyCallQueue((null===(t=a._session)||void 0===t?void 0:t.hasSession)?A.connectionClosed:A.connectionRequired)}}else if(e instanceof Pa)a._session.hasChatServicePermission||a._resolveLazyCallQueue(xi.API);else if(e instanceof Fa||e instanceof qa)a._rejectLazyCallQueue(A.connectionClosed);else if(e instanceof $e){var r,i=e.request,o=e.deferred,u=e.error,c=s(Ri);try{for(c.s();!(r=c.n()).done;){if(i instanceof r.value)return void o.reject(u)}}catch(e){c.e(e)}finally{c.f()}a._lazyCallQueue.push({command:i,deferred:o})}}))}),[{key:"isReady",get:function(){return this._currentConnectionStateType===Aa.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===Aa.CONNECTING||this._currentConnectionStateType===Aa.RECONNECTING||this._session.isRefreshing}},{key:"_classifyLazyCallQueueByScope",value:function(e){var t,n=[],r=[];switch(e){case xi.ALL:t=null;break;case xi.WEBSOCKET:t=Qe;break;case xi.API:t=je}var a=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(a=!0),a?r.push(e):n.push(e)})),[n,r]}},{key:"_resolveLazyCallQueue",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xi.ALL,n=f(this._classifyLazyCallQueueByScope(t),2),r=n[0],a=n[1];this._lazyCallQueue=a,r.forEach((function(t){return E(e,void 0,void 0,d().mark((function e(){var n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.command,r=t.deferred,(a=t.timeout)&&clearTimeout(a),e.prev=2,e.next=5,this.send(n);case 5:i=e.sent,r.resolve(i),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),r.reject(e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])})))}))}},{key:"_rejectLazyCallQueue",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:xi.ALL,r=f(this._classifyLazyCallQueueByScope(n),2),a=r[0],i=r[1];this._lazyCallQueue=i,a.forEach((function(n){return E(t,void 0,void 0,d().mark((function t(){var r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n.deferred,a=n.timeout,clearTimeout(a),r.reject(e);case 3:case"end":return t.stop()}}),t)})))}))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Qe)){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:case 31:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),n=new ot,this._lazyCallQueue.push({command:e,deferred:n,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",n.promise);case 15:throw this._logger.debug("fail websocket request"),A.connectionRequired;case 17:case 44:t.next=47;break;case 19:if(!(e instanceof je)){t.next=46;break}if(!this._session.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!e.hasSessionKey){t.next=34;break}return this._logger.debug("send api request with tmp session key",e),t.next=31,this.commandRouter.send(e);case 34:if(!this.isLazyCallActivated){t.next=41;break}return this._logger.debug("wait api request",e),r=new ot,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 41:throw a=A.connectionRequired,this._logger.debug("fail api request",a),a;case 46:throw A.invalidCommand;case 47:case"end":return t.stop()}}),t,this)})))}},{key:"forceSend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._logger.debug("send forced request",e),!(e instanceof Qe||e instanceof je)){t.next=7;break}return t.next=4,this.commandRouter.send(e);case 4:return t.abrupt("return",t.sent);case 7:throw A.invalidCommand;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(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()}}])}(),Pi="sendbird@devicetokens",Fi=function(){return i((function e(t){var n=t.type,a=t.token,i=t.device_os,s=t.device_manufacturer,o=t.system_push_enabled;r(this,e),this.type=n,this.token=a,this.deviceOS=i,this.deviceManufacturer=s,this.systemPushEnabled=o}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}])}(),qi=new WeakMap,Hi=function(t){function a(e){var t,i=e._iid,s=e.session,o=e.cacheContext,u=e.sdkState,c=e.dispatcher,l=e.requestQueue,d=e.logger,h=e.pushNotificationAckManager;return r(this,a),(t=n(this,a))._currentConnectionStateType=Aa.INITIALIZED,t._isRefreshingAuthToken=!1,t.currentUser=null,t.session=s,t._iid=i,t._cacheContext=o,t._sdkState=u,t._dispatcher=c,t._requestQueue=l,t._logger=d,t._pushNotificationAckManager=h,t._deviceTokens=[],t._dispatcher.on((function(e){var n,r,a;if(e instanceof La){var i=e.stateType;t._currentConnectionStateType=i}else if(e instanceof Be&&t.handler&&!t.isSessionKeyRefreshing){if(t._currentConnectionStateType===Aa.CONNECTING)return;(null===(n=e.error)||void 0===n?void 0:n.isSessionInvalidatedError)?t.close():((null===(r=e.error)||void 0===r?void 0:r.isSessionTokenExpiredError)&&t.refreshAuthToken().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e})),(null===(a=e.error)||void 0===a?void 0:a.isSessionKeyExpiredError)&&(t._logger.debug("session expired"),t.handler.onSessionExpired&&t.handler.onSessionExpired(),t.refreshSessionKey().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e}))))}})),t}return c(a,t),i(a,[{key:"ekey",get:function(){return qi.get(this)}},{key:"deviceTokens",get:function(){return this._deviceTokens}},{key:"deviceTokenLastDeletedAt",get:function(){return this._deviceTokenLastDeletedAt}},{key:"indexOfDeviceToken",value:function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))}},{key:"hasDeviceToken",value:function(e,t){return this.indexOfDeviceToken(e,t)>=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new Ye({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(n);case 3:if(r=t.sent,a=r.as(Xe),i=a.newKey,!(s=a.error)){t.next=7;break}throw s;case 7:this.session.sessionKey=null!=i?i:this.session.sessionKey;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new We({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),t.next=3,yi((function(e){return E(r,void 0,void 0,d().mark((function t(){var r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(n);case 3:r=t.sent,a=r.as(Ze),i=a.key,s=a.services,this.session.sessionKey=i,this.session.services=s,t.next=16;break;case 9:if(t.prev=9,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=15;break}e(t.t0),t.next=16;break;case 15:throw t.t0;case 16:case"end":return t.stop()}}),t,this,[[0,9]])})))}),3);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKey",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._currentConnectionStateType!==Aa.CONNECTED){n.next=18;break}return n.prev=1,n.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),n.abrupt("return");case 8:return n.prev=8,n.t0=n.catch(1),n.prev=10,n.next=13,this._handleSessionRefreshError(n.t0,t);case 13:return n.abrupt("return");case 16:n.prev=16,n.t1=n.catch(10);case 18:return n.prev=18,n.next=21,this._refreshSessionKeyByApi(e);case 21:this.complete(),n.next=28;break;case 24:return n.prev=24,n.t2=n.catch(18),n.next=28,this._handleSessionRefreshError(n.t2,t);case 28:case"end":return n.stop()}}),n,this,[[1,8],[10,16],[18,24]])})))}},{key:"_receiveNewAuthToken",value:function(){var e,t=this,n=new ot;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var r=null,a=function(){r&&(clearTimeout(r),r=null)},i=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},s=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};r=setTimeout((function(){return s()}),1e3*this._sdkState.sessionTokenRefreshTimeout),hi((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(i,s);case 1:case"end":return e.stop()}}),e,this)})))}))}else n.resolve(null);return n.promise}},{key:"_handleSessionRefreshError",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(t instanceof A)){r.next=16;break}if(!t.isSessionTokenExpiredError&&t.code!==e.SendbirdErrorCode.APPLICATION_NOT_FOUND){r.next=16;break}if(this.session.authToken=void 0,!n){r.next=16;break}return r.next=6,this._receiveNewAuthToken();case 6:if(!(a=r.sent)){r.next=13;break}return this.session.authToken=a,r.next=11,this._refreshSessionKey(this.session.authToken,!1);case 11:r.next=15;break;case 13:return r.next=15,this.clear();case 15:return r.abrupt("return");case 16:throw t;case 17:case"end":return r.stop()}}),r,this)})))}},{key:"_isSessionRelatedError",value:function(e){return e instanceof A&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}},{key:"isSessionKeyRefreshing",get:function(){return this.session.isRefreshing}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"isSessionExpiring",get:function(){return!!this.handler}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.session.authToken=t,a=new Mi({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!t||this.isSessionExpiring}),r.next=4,this._requestQueue.commandRouter.send(a);case 4:if(i=r.sent,s=i.as(Oi),(o=s.logi).error){r.next=12;break}if(this.session.hasChatServicePermission){r.next=10;break}return r.next=10,o.applyTo(this._iid);case 10:r.next=13;break;case 12:throw o.error;case 13:case"end":return r.stop()}}),r,this)})))}},{key:"login",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=e.key,a=e.ekey,i=e.services,s=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.session.sessionKey=r,this.session.services=i,qi.set(this,a),this._deviceTokenCacheEnabled=null===(t=null==s?void 0:s.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){n.next=21;break}return n.next=9,c.get(Pi);case 9:if((l=n.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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return t=this._cacheContext.preference,e.next=4,t.set(Pi,{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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.session.clear(),this.close(),qi.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:this._pushNotificationAckManager.clear();case 9:case"end":return e.stop()}}),e,this)})))}}])}(de),Gi=function(e,t){if(null!==e&&null!==t){var n,r=Object.keys(e),a=Object.keys(t),i={},o=s(v(new Set([].concat(r,a))));try{for(o.s();!(n=o.n()).done;){var u=n.value,c=m(e[u]),l=m(t[u]);"undefined"===c?i[u]=t[u]:"undefined"===l?i[u]=e[u]:c!==l?i[u]=t[u]:"object"===c&&e[u]&&t[u]?i[u]=Gi(e[u],t[u]):i[u]=t[u]}}catch(e){o.e(e)}finally{o.f()}return i}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"}(Ui||(Ui={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(Di||(Di={}));var ji,Vi=function(e){function t(e){var a,i=e.deviceId,s=e.statLogs;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Oe),a.params={device_id:i,log_entries:s.map((function(e){return rt.payloadify(e)}))},a}return c(t,e),i(t)}(je),zi=function(){return i((function e(t){var n=t.deviceId,a=t.cacheContext,i=t.requestQueue;r(this,e),this.queue=[],this.flushWaitQueue=[],this.enabledState=Ui.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=n,this.cacheContext=a,this.requestQueue=i,this.logInfo={deviceId:n,statLogs:[],generation:1,lastFlushedAt:0},this.limit=100}),[{key:"isEnabled",get:function(){return this.enabledState===Ui.ENABLED}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:(n=t.sent)&&(this.logInfo=n);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_mergeQueue",value:function(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}},{key:"_isDuplicateStat",value:function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}},{key:"_flush",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=!0,!(t.length>0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Vi({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Ui.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ui.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}},{key:"_save",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(v(this.queue),v(this.flushWaitQueue)),e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:t.map((function(e){return rt.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save();case 4:case"end":return e.stop()}}),e,this)})))}}])}(),Bi=function(e){function t(e){var a,i,s,o,u,c=e.type,l=e.data,d=e.ts,h=void 0===d?Date.now():d;return r(this,t),(a=n(this,t,[{type:c,data:l,ts:h}])).date=new Date(h),a.key="".concat((i=a.date,s=i.getFullYear(),o=String(i.getMonth()+1).padStart(2,"0"),u=String(i.getDate()).padStart(2,"0"),"".concat(s).concat(o).concat(u)),"_").concat(c),a}return c(t,e),i(t)}(rt),Ki=function(e){function t(e){var a=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,t),n(this,t,[{deviceId:a,cacheContext:i,requestQueue:s}])}return c(t,e),i(t,[{key:"_isSendable",get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var n=this,r=Object.create(null,{init:{get:function(){return p(t,"init",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.init.call(this,e+".daily");case 2:this.queue=this.logInfo.statLogs.map((function(e){return new rt({type:e.stat_type,ts:e.ts,data:e.data})}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),!t.localCacheStat){n.next=7;break}this.enabledState=t.enabledStat?Ui.ENABLED:Ui.COLLECT_ONLY,n.next=10;break;case 7:return this.enabledState=Ui.DISABLED,n.next=10,this.clear();case 10:if(!this.isEnabled||!this._isSendable){n.next=25;break}return n.next=13,this._getUploadStats();case 13:r=n.sent,a=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),i=0;case 16:if(!(i0&&void 0!==arguments[0]&&arguments[0];if(this.queue.length=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var n=this,r=Object.create(null,{init:{get:function(){return p(t,"init",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.init.call(this,e+".realtime");case 2:this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new rt({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this._mergeQueue(),!t.notificationStat){n.next=6;break}this.enabledState=t.enabledStat?Ui.ENABLED:Ui.COLLECT_ONLY,n.next=9;break;case 6:return this.enabledState=Ui.DISABLED,n.next=9,this.clear();case 9:if(!this.isEnabled||!this._isSendable){n.next=15;break}return r=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),n.next=13,mi(r);case 13:return n.next=15,this._flush(this.queue);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState!==Ui.DISABLED){t.next=2;break}return t.abrupt("return",!0);case 2:if(n=this.enabledState===Ui.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,!this._isDuplicateStat(e)){t.next=5;break}return t.abrupt("return",!0);case 5:if(n.push(e),this.enabledState===Ui.PENDING){t.next=9;break}return t.next=9,this._save();case 9:if(!this.isEnabled){t.next=15;break}if(this._mergeQueue(),!this.isEnabled||!this._isSendable){t.next=15;break}return t.next=14,this._flush(n);case 14:return t.abrupt("return",t.sent);case 15:return t.abrupt("return",!0);case 16:case"end":return t.stop()}}),t,this)})))}}])}(zi),Yi=function(){return i((function e(t){var n=t.cacheContext,a=t.requestQueue,i=t.dispatcher,s=t.logger;r(this,e),this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=ce(),this.cacheContext=n,this.requestQueue=a,this.dispatcher=i,this.logger=s,this._dailyStatCollector=new Ki({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Qi({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._realTimeStatCollector=new Wi({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}),[{key:"_migration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cacheContext.preference.get(this.key);case 2:if(!(t=e.sent)){e.next=18;break}return n=[],t.statLogs.forEach((function(e){e.stat_type===Ge.FEATURE_LOCALCACHE&&n.push(new rt({type:e.stat_type,ts:e.ts,data:e.data}))})),e.next=8,this.cacheContext.preference.set(this.key+".daily",{deviceId:t.deviceId,statLogs:n.map((function(e){return rt.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 8:return r=[],t.statLogs.forEach((function(e){e.stat_type!==Ge.FEATURE_LOCALCACHE&&e.stat_type!==Ge.NOTIFICATION&&(e.stat_type===Ge.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),r.push(new rt({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=12,this.cacheContext.preference.set(this.key+".default",{deviceId:t.deviceId,statLogs:r.map((function(e){return rt.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 12:return a=[],t.statLogs.forEach((function(e){var t;e.stat_type===Ge.NOTIFICATION&&(e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),a.push(new rt({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=16,this.cacheContext.preference.set(this.key+".realtime",{deviceId:t.deviceId,statLogs:a.map((function(e){return rt.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 16:return e.next=18,this.cacheContext.preference.remove(this.key);case 18:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this._migration();case 3:return t.next=5,this._dailyStatCollector.init(this.key);case 5:return t.next=7,this._defaultStatCollector.init(this.key);case 7:return t.next=9,this._realTimeStatCollector.init(this.key);case 9:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e instanceof Je?(r=e.statLog,this.put(r)):e instanceof ci&&(a=e.request,i=e.features,s=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=a,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._realTimeStatCollector.setConfig(null!==(n=this._statConfig.realTime)&&void 0!==n?n:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:s.ingestion}));case 1:case"end":return t.stop()}}),t,this)})))})));case 10:case"end":return t.stop()}}),t,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=!0,!(e instanceof Bi)){t.next=8;break}if(!this._collectFeatureLocalCacheStat){t.next=6;break}return t.next=5,this._dailyStatCollector.put(e);case 5:n=t.sent;case 6:t.next=26;break;case 8:t.t0=e.type,t.next=t.t0===Ge.API_RESULT||t.t0===Ge.WEBSOCKET_CONNECT?11:t.t0===Ge.FEATURE_LOCALCACHE||t.t0===Ge.FEATURE_LOCALCACHE_EVENT?16:t.t0===Ge.NOTIFICATION?21:26;break;case 11:if(!this._collectRequestStat){t.next=15;break}return t.next=14,this._defaultStatCollector.put(e);case 14:n=t.sent;case 15:return t.abrupt("break",26);case 16:if(!this._collectFeatureLocalCacheStat){t.next=20;break}return t.next=19,this._defaultStatCollector.put(e);case 19:n=t.sent;case 20:return t.abrupt("break",26);case 21:if(!this._collectionNotificationStat){t.next=25;break}return t.next=24,this._realTimeStatCollector.put(e);case 24:n=t.sent;case 25:return t.abrupt("break",26);case 26:n?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Ui.COLLECT_ONLY,this._defaultStatCollector.enabledState=Ui.COLLECT_ONLY,this._realTimeStatCollector.enabledState=Ui.COLLECT_ONLY,this.logger.debug(A.statLogUploadLimitExceededError)));case 27:case"end":return t.stop()}}),t,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}])}(),Zi=function(){return i((function e(t){var n=t.limit,a=void 0===n?5:n;r(this,e),this.workersByKey={},this.limit=a}),[{key:"run",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.workersByKey[e]||(this.workersByKey[e]=[]),!(this.workersByKey[e].length0:void 0,i.lastRepliedAt=null!==(c=a.last_replied_at)&&void 0!==c?c:0,i.updatedAt=null!==(l=a.updated_at)&&void 0!==l?l:0,i}return c(t,e),i(t,[{key:"_isUpdateRequired",get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}},{key:"_updateFrom",value:function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((function(e){return si.payloadify(e)})):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}}])}(Ya);e.ReactionEventOperation=void 0,(Xi=e.ReactionEventOperation||(e.ReactionEventOperation={})).ADD="add",Xi.DELETE="delete";var ss,os=i((function t(n){r(this,t),this.messageId=0,this.operation=null,this.updatedAt=0;var a=D("string",n.msg_id)?parseInt(n.msg_id):n.msg_id,i=n.user_id,s=n.operation?n.operation.toLowerCase():null,o=n.reaction,u=n.updated_at;a&&D("string",i)&&D("string",s)&&R(e.ReactionEventOperation,s)&&D("string",o)&&o&&D("number",u)&&(this.messageId=a,this.userId=i,this.key=o,this.operation=s,this.updatedAt=u)})),us=function(){return i((function e(t){var n;r(this,e);var a=t.key,i=null!==(n=v(t.user_ids))&&void 0!==n?n:[],o=t.updated_at;D("string",a)&&a&&P("string",i)&&i.length>0&&D("number",o)&&(this.key=a,this.userIds=i,this.updatedAt=o);var u,c={},l=s(this.userIds);try{for(l.s();!(u=l.n()).done;){c[u.value]=this.updatedAt}}catch(e){l.e(e)}finally{l.f()}this._version=c}),[{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 pe(ve({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}}])}(),cs=function(){return i((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)}),null,[{key:"payloadify",value:function(e){var t,n;return pe(ve({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}))}}])}(),ls=function(){return i((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 cs(t["og:image"]))}),null,[{key:"payloadify",value:function(e){return pe(ve({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?cs.payloadify(e.defaultImage):null}))}}])}(),ds=function(){return i((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}),[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return pe(ve({name:e.name,volume:e.volume}))}}])}();e.FeedbackRating=void 0,(ss=e.FeedbackRating||(e.FeedbackRating={})).GOOD="good",ss.BAD="bad";var hs,fs=function(){function e(t){r(this,e),this.id=t.id,this.rating=t.rating,this.comment=t.comment}return i(e,null,[{key:"_getStatus",value:function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}},{key:"_isSubmitted",value:function(t){return"SUBMITTED"===e._getStatus(t)}},{key:"_getPayloadByStatus",value:function(e){return"NO_FEEDBACK"===e?{}:null}},{key:"payloadify",value:function(e){return pe(ve({id:e.id,rating:e.rating,comment:e.comment}))}}])}(),ps=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i])).isBlockedByMe=!1,s.role=R(e.Role,i.role)?i.role:e.Role.NONE,s.isBlockedByMe=null!==(o=i.is_blocked_by_me)&&void 0!==o&&o,s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}])}(si),vs=function(){return i((function e(t){r(this,e),this.key=t.key,this.value=P("string",t.value)?v(t.value):[]}),null,[{key:"payloadify",value:function(e){var t;return pe(ve({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}])}(),_s=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"}},ms=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;r(this,a),(s=n(this,a,[t])).channelType=e.ChannelType.BASE,s.messageType=e.MessageType.BASE,s.mentionType=null,s.mentionedUsers=null,s.mentionedUserIds=null,s.mentionedMessageTemplate=void 0,s.metaArrays=[],s.extendedMessage={},s.createdAt=0,s.updatedAt=0,s.channelUrl=i.channel_url,s.channelType=R(e.ChannelType,i.channel_type)?i.channel_type:e.ChannelType.GROUP,i.channel&&(i.channel.channel_url&&(s.channelUrl=i.channel.channel_url),i.channel.channel_type&&(s.channelType=i.channel.channel_type)),s.data=null!==(o=i.data)&&void 0!==o?o:"",s.customType=null!==(u=i.custom_type)&&void 0!==u?u:"",s.mentionType=R(e.MentionType,i.mention_type)?i.mention_type:null,s.mentionedUsers=i.mentioned_users?i.mentioned_users.map((function(e){return new si(s._iid,e)})):null,s.mentionedUserIds=null!==(c=i.mentioned_user_ids)&&void 0!==c?c:null,s.mentionedUsers&&!s.mentionedUserIds&&(s.mentionedUserIds=s.mentionedUsers.map((function(e){return e.userId}))),s.mentionedMessageTemplate=i.mentioned_message_template;var _=null!==(l=i.metaarray)&&void 0!==l?l:{},m=null!==(d=i.metaarray_key_order)&&void 0!==d?d:Object.keys(_).sort((function(e,t){return e.localeCompare(t)}));s.metaArrays=[];for(var g=0;g0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,items:e.items.map((function(e){return Bs.payloadify(e)})),version:e.version,is_submitted:e._isSubmitted}))}},{key:"isMessageFormPayload",value:function(e){return Boolean(null==e?void 0:e.message_form)}}])}(),Bs=function(){return i((function e(t){r(this,e);var n=t.id,a=t.name,i=t.required,s=t.sort_order,o=t.placeholder,u=t.style,c=t.item_type,l=t.validators,d=t.value,h=t.values;this.id=n,this.name=a,this.required=i,this.sortOrder=s,this.placeholder=o,0===Object.keys(u).length?this.style={layout:c}:this.style=pe({layout:u.layout,options:u.options,defaultOptions:u.default_options,resultCount:u.result_count}),h?this.submittedValues=h:d&&(this.submittedValues=[d]),this._validators=l}),[{key:"isValid",value:function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case Is.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case Is.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case Is.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case Is.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case Is.DECIMAL_PLACE:if(0===e.length)return!1;var r=Number(e);return!(isNaN(r)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(r,t.max_decimal_place));default:return!0}}))}(e,t._validators);return n}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:pe({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}])}(),Ks=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Re,"/").concat(e.formId,"/submit"),a.params=pe({message_id:e.messageId,items:e.items}),a}return c(t,e),i(t)}(je);e.ScheduledStatus=void 0,(js=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",js.SENT="sent",js.FAILED="failed",js.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Vs||(Vs={}));var Qs,Ws=function(t){function a(e,t){var i,s,o,u,c,l,d,h,f;return r(this,a),(i=n(this,a,[e,t])).parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.threadInfo=null,i.reactions=[],i.appleCriticalAlertOptions=null,i.scheduledInfo=null,i.suggestedReplies=null,i.myFeedback=null,i.myFeedbackStatus="NOT_APPLICABLE",i.messageForm=null,i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(o=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==o?o:0,i.parentMessageId=null!==(u="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==u?u:0,i.threadInfo=t.thread_info?new is(i._iid,t.thread_info):null,i.reactions=t.reactions?t.reactions.map((function(e){return new us(e)})):[],i.ogMetaData=t.og_tag?new ls(t.og_tag):null,i.silent=null!==(c=t.silent)&&void 0!==c&&c,i.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,i.appleCriticalAlertOptions=t.apple_critical_alert_options?new ds(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(i.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},i._scheduledStatus=t.scheduled_status),i._isContinuousMessages=null!==(d=t.is_continuous_messages)&&void 0!==d&&d,i.myFeedback=fs._isSubmitted(t.feedback)?new fs(t.feedback):null,i.myFeedbackStatus=fs._getStatus(t.feedback),i.suggestedReplies=null!==(f=null===(h=t.extended_message_payload)||void 0===h?void 0:h.suggested_replies)&&void 0!==f?f:null,i.messageForm=zs.isMessageFormPayload(t.extended_message_payload)?new zs(i.messageId,t.extended_message_payload.message_form):null,i}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.messageId===e.messageId}},{key:"applyThreadInfoUpdateEvent",value:function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}},{key:"applyReactionEvent",value:function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1}},{key:"_triggerThreadInfoUpdatedEvent",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=es.of(this._iid),(r=n.dispatcher).dispatch(new Gs({channelType:e.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),r.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"markThreadAsRead",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new ks({channelUrl:this.channelUrl,messageId:this.messageId}),e.next=4,n.send(r);case 4:if(!this.threadInfo||0===this.threadInfo.unreadReplyCount){e.next=8;break}return this.threadInfo.unreadReplyCount=0,e.next=8,this._triggerThreadInfoUpdatedEvent();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setPushNotificationEnabled",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new bs({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),t.next=4,r.send(a);case 4:this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"submitMessageForm",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=es.of(this._iid),a=r.requestQueue,i=null,s=null,o=this.messageForm,t||!o){n.next=13;break}if(o.isSubmittable){n.next=7;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});case 7:if(!o.isSubmitted){n.next=9;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});case 9:i=o.id,s=o.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[]),n.next=14;break;case 13:t&&(i=t.formId,s=Object.entries(t.answers).reduce((function(t,n){var r=f(n,2),a=r[0],i=r[1],s=Number(a);if(Number.isNaN(s))throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return t.push({form_item_id:s,value:i}),t}),[]));case 14:if(i&&s){n.next=16;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});case 16:return u=new Ks({messageId:this.messageId,formId:i,items:s}),n.next=19,a.send(u);case 19:case"end":return n.stop()}}),n,this)})))}},{key:"submitFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Cs({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(ws),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new xs({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t.id,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(Ss),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ts({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t}),n.next=4,a.send(s);case 4:this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new Os({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}));case 7:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?is.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return us.payloadify(e)})),og_tag:e.ogMetaData?ls.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?ds.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(t=e.scheduledInfo)||void 0===t?void 0:t.scheduledMessageId,scheduled_at:null===(n=e.scheduledInfo)||void 0===n?void 0:n.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?fs.payloadify(e.myFeedback):fs._getPayloadByStatus(e.myFeedbackStatus)})))}},{key:"_getParentMessageInfoPayload",value:function(e){return pe(ve({type:_s(e.messageType),ts:e.createdAt,user:e.sender?ps.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Hs.payloadify(e)})):null}))}}])}(ms),Ys=function(t){function a(t,i){var s,o,u,c,l;if(r(this,a),(s=n(this,a,[t,i])).reqId="",s.replyToChannel=!1,s.errorCode=0,s.sender=i.user?new ps(s._iid,i.user):i.sender_id,s.reqId=null!==(u=null!==(o=i.req_id)&&void 0!==o?o:i.request_id)&&void 0!==u?u:"",s.replyToChannel=null!==(c=i.is_reply_to_channel)&&void 0!==c&&c,i.request_state&&R(e.SendingStatus,i.request_state)&&(s.sendingStatus=i.request_state),!s.sendingStatus)if(s.messageId>0)s.sendingStatus=e.SendingStatus.SUCCEEDED;else if(s.scheduledInfo)switch(i.scheduled_status&&(s._scheduledStatus=i.scheduled_status),i.scheduled_status){case Vs.SENT:case Vs.IN_QUEUE:s.sendingStatus=e.SendingStatus.SUCCEEDED;break;case Vs.PENDING:s.sendingStatus=e.SendingStatus.SCHEDULED;break;case Vs.FAILED:case Vs.REMOVED:s.sendingStatus=e.SendingStatus.FAILED;break;case Vs.CANCELED:s.sendingStatus=e.SendingStatus.CANCELED}else s.sendingStatus=e.SendingStatus.PENDING;return s.errorCode=null!==(l=i.error_code)&&void 0!==l?l:0,s._messageToken=i.mesg_token,s}return c(a,t),i(a,[{key:"isResendable",get:function(){return(this.sendingStatus===e.SendingStatus.FAILED||this.sendingStatus===e.SendingStatus.CANCELED)&&((t=this.errorCode)>0&&M.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 pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{user:ps.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}}])}(Ws),Zs={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Xs=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)},Js=function(t){function a(t,i){var s,o,u,c,l;if(r(this,a),(s=n(this,a,[t,i])).translations={},s.message=null!==(o=i.message)&&void 0!==o?o:"",s.messageType=e.MessageType.ADMIN,s.translations=null!==(u=i.translations)&&void 0!==u?u:{},i.parent_message_info){var d=i.parent_message_info;s.parentMessage=ho(t,pe(ve(Object.assign(Object.assign({},d),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:d.file,url:null===(c=d.file)||void 0===c?void 0:c.url,require_auth:null===(l=d.file)||void 0===l?void 0:l.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(Ws),$s=function(){return i((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&&D("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,vendor:e.vendor,detail:e.detail}))}}])}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Qs||(Qs={}));var eo,to="removed",no=function(e){switch(e){case"open":return Qs.OPEN;case"closed":return Qs.CLOSED;default:return null}},ro=function(e){return!e||!!e.text&&D("string",e.text)},ao=function(e){function t(e,a){var i,s,o,u,c,l,d,h;return r(this,t),(i=n(this,t,[e])).pollId=0,i.id=0,i.text=null,i.voteCount=0,i.createdBy=null,i.createdAt=0,i.updatedAt=0,i._lastVotedAt=0,i.pollId=null!==(s=a.poll_id)&&void 0!==s?s:0,i.id=null!==(o=a.id)&&void 0!==o?o:0,i.text=null!==(u=a.text)&&void 0!==u?u:null,i.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,i.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,i.createdAt=null!==(d=a.created_at)&&void 0!==d?d:0,i.updatedAt=null!==(h=a.updated_at)&&void 0!==h?h:0,i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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})))}}])}(Ya),io=function(e){function t(e,a){var i,s,o,u,c,l,d,h,f,p,v,_,m,g;return r(this,t),(i=n(this,t,[e])).id=0,i.title=null,i.createdAt=0,i.updatedAt=0,i.closeAt=-1,i.status=Qs.CLOSED,i.messageId=0,i.data=null,i.voterCount=-1,i.options=[],i.createdBy=null,i.allowUserSuggestion=!1,i.allowMultipleVotes=!1,i.votedPollOptionIds=[],i.id=null!==(s=a.id)&&void 0!==s?s:0,i.title=null!==(o=a.title)&&void 0!==o?o:null,i.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,i.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,i.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,i.status=null!==(d=no(a.status))&&void 0!==d?d:Qs.CLOSED,i.messageId=null!==(h=a.message_id)&&void 0!==h?h:0,i.data=null!==(f=a.data)&&void 0!==f?f:null,i.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,i.options=a.options?a.options.map((function(e){return new ao(i._iid,e)})):[],i.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,i.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,i.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,i.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],i}return c(t,e),i(t,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,i,s,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=no(e.status))&&void 0!==a?a:this.status,this.data=null!==(i=e.data)&&void 0!==i?i:this.data,this.voterCount=null!==(s=e.voter_count)&&void 0!==s?s:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new ao(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var i=t[r];a>=i._lastVotedAt&&(i.voteCount=e.vote_count,i._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0}},{key:"serialize",value:function(){return ni(this)}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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 ao.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}])}(Ya),so=function(){return i((function e(t){r(this,e),this.status=t.status,t.original_message_info&&(this.originalMessageInfo={createdAt:t.original_message_info.ts,messageId:t.original_message_info.id})}),null,[{key:"payloadify",value:function(e){return pe({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}])}(),oo=function(t){function a(t,i){var o,u,c,l,d,h;if(r(this,a),(o=n(this,a,[t,i])).message="",o.messageParams=null,o.translations={},o.translationTargetLanguages=[],o.messageSurvivalSeconds=-1,o.plugins=[],o._poll=null,o.message=i.message,o.messageType=e.MessageType.USER,o.translations=null!==(u=i.translations)&&void 0!==u?u:{},o.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(o.translations).length&&o.translationTargetLanguages.length>0){var f,p=s(o.translationTargetLanguages);try{for(p.s();!(f=p.n()).done;){var v=f.value;o.translations[v]=""}}catch(e){p.e(e)}finally{p.f()}}if(o.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,o.plugins=i.plugins?i.plugins.map((function(e){return new $s(e)})):[],o._poll=i.poll?new io(o._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;o.parentMessage=ho(t,pe(ve(Object.assign(Object.assign({},_),{created_at:_.ts,message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(o.messageReviewInfo=new so(i.review_info)),o}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return $s.payloadify(e)})),poll:e._poll?io.payloadify(e._poll):null,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null,review_info:e.messageReviewInfo?so.payloadify(e.messageReviewInfo):void 0})))}}])}(Ys),uo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p;if(r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.fileInfoList=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE,s.data=null!==(c=null!==(u=null===(o=i.file)||void 0===o?void 0:o.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",s.fileInfoList=null!==(d=null===(l=i.files)||void 0===l?void 0:l.map((function(e){return new Hs(t,e)})))&&void 0!==d?d:[],s.messageSurvivalSeconds=null!==(h=i.message_survival_seconds)&&void 0!==h?h:-1,i.parent_message_info){var v=i.parent_message_info;s.parentMessage=ho(t,pe(ve(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===(f=v.file)||void 0===f?void 0:f.url,require_auth:null===(p=v.file)||void 0===p?void 0:p.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n,r,i,s,o;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{file:{name:null!==(n=null===(t=e.fileInfoList[0])||void 0===t?void 0:t.fileName)&&void 0!==n?n:"",size:null!==(i=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.fileSize)&&void 0!==i?i:0,type:null!==(o=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Hs.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([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)}}])}(Ys);!function(e){e.SENT="SENT",e.READ="READ"}(eo||(eo={}));var co=function(t){function a(t,i){var s,o,u;if(r(this,a),(s=n(this,a,[t,i])).notificationData=null,s.notificationId=i.notification_message_id,s.messageType=e.MessageType.ADMIN,s.messageStatus=null!==(o=i.message_status)&&void 0!==o?o:eo.SENT,s.priority=null!==(u=i.priority)&&void 0!==u?u:se.NORMAL,s.notificationEventDeadline=i.notification_event_deadline,0===s.extendedMessage.sub_type)try{var c=JSON.parse(s.extendedMessage.sub_data),l=c.label,d=c.tags,h=void 0===d?[]:d,f=c.template_key,p=c.template_variables;s.notificationData={label:l,tags:h,templateKey:f,templateVariables:p}}catch(e){}return s}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.notificationId===e.notificationId}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}}])}(ms),lo=function(t){if(t.notificationId)return co.payloadify(t);switch(t.messageType){case e.MessageType.USER:return oo.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?uo.payloadify(t):fo.payloadify(t);case e.MessageType.ADMIN:return Js.payloadify(t);default:throw A.unknown}},ho=function(e,t){if(t.notification_message_id)return new co(e,t);switch(t.type){case"MESG":return new oo(e,t);case"FILE":return uo._isMultipleFilesMessagePayload(t)?new uo(e,t):new fo(e,t);case"ADMM":case"BRDM":return new Js(e,t);default:return null}},fo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var k=i.file;if(s.plainUrl=(null!==(u=null!==(o=null==k?void 0:k.url)&&void 0!==o?o:i.url)&&void 0!==u?u:"").split("?auth=")[0],s.name=null!==(l=null!==(c=null==k?void 0:k.name)&&void 0!==c?c:i.name)&&void 0!==l?l:"File",s.size=null!==(h=null!==(d=null==k?void 0:k.size)&&void 0!==d?d:i.size)&&void 0!==h?h:0,s.data=null!==(p=null!==(f=null==k?void 0:k.data)&&void 0!==f?f:i.custom)&&void 0!==p?p:"",s.type=k?null!==(v=k.type)&&void 0!==v?v:"":null!==(_=i.type)&&void 0!==_?_:"",s.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,s.thumbnails=i.thumbnails?i.thumbnails.map((function(e){var t;return new ns(s._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),s.requireAuth)})):[],s.messageSurvivalSeconds=null!==(g=i.message_survival_seconds)&&void 0!==g?g:-1,i.parent_message_info){var b=i.parent_message_info;s.parentMessage=ho(t,pe(ve(Object.assign(Object.assign({},b),{created_at:b.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:b.file,url:null===(y=b.file)||void 0===y?void 0:y.url,require_auth:null===(E=b.file)||void 0===E?void 0:E.require_auth}))))}return s}return c(a,t),i(a,[{key:"url",get:function(){var e=es.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Zs),t),ai(this.messageId>0&&D("number",e)&&Xs(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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.plainUrl,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(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(Ys),po=function(e){function t(e,a){var i,s=a.file,o=a.fileUrl,u=a.fileName,c=a.fileSize,l=a.mimeType,d=a.thumbnailSizes,h=a._uploadedMetaData,f=a._thumbnails;return r(this,t),(i=n(this,t,[e]))._plainUrl=o,i.file=s,i.fileName=u,i.fileSize=c,i.mimeType=l,i.thumbnailSizes=d,i._uploadedMetaData=h,i._thumbnails=f,i}return c(t,e),i(t,[{key:"fileUrl",get:function(){var e,t=es.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e}},{key:"toJSON",value:function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}],[{key:"getPlainUrl",value:function(e){return e instanceof t?e._plainUrl:e.fileUrl}}])}(Ya),vo=function(t){function a(t){var i,s,o,u;r(this,a);var c=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?c=t.mentionedUserIds:t.mentionedUsers&&(c=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FILE",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,files:t.files?yo(t.files):null,url:t.url,name:null!==(i=t.fileName)&&void 0!==i?i:"",type:null!==(s=t.mimeType)&&void 0!==s?s:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:null===(u=t._thumbnails)||void 0===u?void 0:u.map((function(e){return ns.payloadify(e)})),require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:c,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.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 c(a,t),i(a)}(Qe),_o=function(t){function a(t){var i,s,o;r(this,a),i=n(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})))),i.method=_e.POST,i.path="".concat(Le(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),i.params=pe(ve({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?yo(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===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return ns.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return vs.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage})),i}return c(a,t),i(a)}(je),mo=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"FILE",i])).message=i.files&&i.files.length>=2?new uo(e,i):new fo(e,i);var d=es.of(e).sdkState;return s.isMentioned=Fe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),go=function(e){function t(e,a){var i,s,o,u,c;r(this,t),(i=n(this,t,[e,a])).message=a.files&&a.files.length>=2?new uo(e,a):new fo(e,a);var l=es.of(e).sdkState;return i.isMentioned=Fe(i.message.mentionType,null!==(u=null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:null===(o=i.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),i.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,i}return c(t,e),i(t)}(Ve);function yo(e){return e.map((function(e){var t,n;return pe(ve({url:po.getPlainUrl(e),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 ns.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var Eo;!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"}(Eo||(Eo={}));var ko=function(){return i((function e(t,n){var a=this,i=n.sdkState,s=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._iid=t,this._sdkState=i,this._requestQueue=o,this._cacheContext=c,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof La&&(a._connectionState=e.stateType)})),this._onlineDetector=u}),[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===Aa.CONNECTED||this._connectionState===Aa.CONNECTING||this._connectionState===Aa.RECONNECTING}},{key:"_sendFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=this._createSendFileMessageRequestParams(e,t),!this._shouldSendThroughWebSocket){n.next=10;break}return a=new vo(r),n.next=5,this._requestQueue.send(a);case 5:return i=n.sent,s=i.as(mo),o=s.message,n.abrupt("return",o);case 10:return u=new _o(Object.assign(Object.assign({},r),{userId:this._sdkState.userId})),n.next=13,this._requestQueue.send(u);case 13:return c=n.sent,l=c.as(go),h=l.message,n.abrupt("return",h);case 16:case"end":return n.stop()}}),n,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(t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(a=this._queueMap.get(t.url))){r.next=58;break}if(a.isResolving){r.next=57;break}a.isResolving=!0,i=[],o=!0,u=s(a.messageQueue),r.prev=7,u.s();case 9:if((c=u.n()).done){r.next=40;break}l=c.value,r.t0=l.state,r.next=r.t0===Eo.PENDING||r.t0===Eo.UPLOADING?14:r.t0===Eo.UPLOADED?17:r.t0===Eo.FAILED?35:38;break;case 14:return o=!1,i.push(l),r.abrupt("break",38);case 17:if(!o){r.next=33;break}return r.prev=18,l.state=Eo.SENDING,r.next=22,this._sendFileMessage(t,l);case 22:return h=r.sent,l.deferred.resolve(h),r.next=26,mi(100);case 26:r.next=31;break;case 28:r.prev=28,r.t1=r.catch(18),l.deferred.reject(r.t1);case 31:r.next=34;break;case 33:i.push(l);case 34:return r.abrupt("break",38);case 35:return f=null!==(n=l.error)&&void 0!==n?n:A.unknown,l.deferred.reject(f.code===e.SendbirdErrorCode.REQUEST_CANCELED?A.fileUploadCanceled:f),r.abrupt("break",38);case 38:r.next=9;break;case 40:r.next=45;break;case 42:r.prev=42,r.t2=r.catch(7),u.e(r.t2);case 45:return r.prev=45,u.f(),r.finish(45);case 48:if(p=a.isResolveRequestPending,a.messageQueue=i,a.isResolving=!1,a.isResolveRequestPending=!1,!p){r.next=55;break}return r.next=55,this._resolveMessageQueue(t);case 55:r.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return r.stop()}}),r,this,[[7,42,45,48],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(r=this._queueMap.get(e.url))){n.next=30;break}if(!(a=r.messageQueue.find((function(e){return e.state===Eo.PENDING})))){n.next=30;break}if(!a.multipleFileUploadInfo){n.next=19;break}if(i=a.multipleFileUploadInfo,s=i.uploadIndex,o=i.uploadCount,u=i.requestHandler,c=a.params,l=c.fileInfoList[s],!H(l.file)||(null===(t=l._uploadedMetaData)||void 0===t?void 0:t.isUploaded)){n.next=13;break}return n.next=11,this._tryUploadNextItemAndUpdateItemState(e,r,a);case 11:n.next=14;break;case 13:a.state=s=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=new rs({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),s.next=3,this._requestQueue.send(o);case 3:u=s.sent,c=u.as(as),l=c.url,h=c.fileSize,f=void 0===h?n.fileSize:h,p=c.thumbnails,v=void 0===p?[]:p,_=c.requireAuth,m=void 0!==_&&_,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i:n.file.size,n.fileUrl=l,n.fileSize=f,n.requireAuth=m,n._thumbnails=v;case 12:case"end":return s.stop()}}),s,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[o],c=new rs({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),s.next=5,this._requestQueue.send(c);case 5:l=s.sent,h=l.as(as),f=h.url,p=h.fileSize,v=void 0===p?u.fileSize:p,_=h.thumbnails,m=h.requireAuth,g=void 0!==m&&m,u.fileName=null!==(r=u.fileName)&&void 0!==r?r: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=f,u.fileSize=v,u._thumbnails=_,u._uploadedMetaData=Object.assign(Object.assign({},u._uploadedMetaData),{requireAuth:g,isUploaded:!0}),u instanceof po||(n.fileInfoList[o]=new po(this._iid,u));case 16:case"end":return s.stop()}}),s,this)})))}},{key:"request",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),o=new ot,u={requestId:t,params:n,state:Eo.PENDING,deferred:o},bo(n)&&(c=n,l=Object.assign({uploadIndex:0,uploadCount:c.fileInfoList.length},r),u.multipleFileUploadInfo=l),s.messageQueue.push(u),this._uploadNextPendingItem(e),a.abrupt("return",o.promise);case 8:case"end":return a.stop()}}),a,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}))]:v(n.messageQueue),i=s(a);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o)switch(o.state){case Eo.PENDING:if(o.state=Eo.FAILED,o.error=A.requestCanceled,o.multipleFileUploadInfo&&!o.multipleFileUploadInfo.isCopy){var u=o.multipleFileUploadInfo,c=u.uploadIndex,l=u.requestHandler,d=o.params.fileInfoList[c];null==l||l._triggerOnFileUploaded(o.requestId,c,d,A.fileUploadCanceled)}this._resolveMessageQueue(e);break;case Eo.UPLOADING:this._requestQueue.cancel(o.requestId),this._dispatcher.dispatch(new ut({requestId:o.requestId}))}}}catch(e){i.e(e)}finally{i.f()}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new ut({requestId:t})))}}])}();function bo(e){return"fileInfoList"in e}var Co,wo={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},xo=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&R(e.ReplyType,t.replyType)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)&&D("boolean",t.showSubchannelMessagesOnly)},So={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},To=function(t){return R(e.ReplyType,t.replyType)&&D("boolean",t.includeReactions)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)},Io=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:d,include_poll_details:!0},a}return c(t,e),i(t)}(je),No=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?ho(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(Ve),Ao=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,d=e.isInclusive,h=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,E=e.includeThreadInfo,k=e.includeParentMessageInfo,b=e.showSubchannelMessagesOnly,C=e.checkingHasNext,w=e.checkingContinuousMessages;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages"),a.params=pe(ve({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,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:E,include_parent_message_info:k,show_subchannel_message_only:b,include_poll_details:!0,checking_has_next:C,checking_continuous_messages:w})),a}return c(t,e),i(t)}(je),Mo=function(e){function t(e,a){var i;return r(this,t),i=n(this,t,[e,a]),void 0!==a.is_continuous_messages&&(i.isContinuousMessages=a.is_continuous_messages),void 0!==a.has_next&&(i.hasNext=a.has_next),i.messages=a.messages.map((function(t){return ho(e,t)})),i}return c(t,e),i(t)}(Ve),Oo=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,d=e.includeReactions,h=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:d,include_thread_info:h,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return c(t,e),i(t)}(je),Uo=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedMessages=a.updated.map((function(t){return ho(e,t)})),i.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(Ve),Do=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledMessageId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s)),a.params={},a}return c(t,e),i(t)}(je),Ro=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?ho(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(Ve);e.RestrictionType=void 0,(Co=e.RestrictionType||(e.RestrictionType={})).MUTED="muted",Co.BANNED="banned";var Lo=function(){return i((function t(n){var a,i,s,o;r(this,t),this.restrictionType=null,R(e.RestrictionType,n.restriction_type)&&(this.restrictionType=n.restriction_type),this.description=null!==(a=n.description)&&void 0!==a?a:null,this.endAt=null!==(s=null!==(i=n.end_at)&&void 0!==i?i:n.muted_end_at)&&void 0!==s?s:-1,this.remainingDuration=null!==(o=n.remaining_duration)&&void 0!==o?o:-1}),null,[{key:"payloadify",value:function(e){return pe(ve({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}])}(),Po=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).restrictionInfo=new Lo(a),i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),Lo.payloadify(e.restrictionInfo))))}}])}(si),Fo=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.isMuted=null!==(s=a.is_muted)&&void 0!==s&&s,i}return c(t,e),i(t)}(si),qo=function(){return i((function e(){r(this,e),this._onPending=ht,this._onFailed=ht,this._onSucceeded=ht}),[{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}}])}(),Ho={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},Go=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(si,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(vs,t.metaArrays,!0)&&D("number",t.parentMessageId,!0)&&D("boolean",t.isReplyToChannel)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ds,t.appleCriticalAlertOptions,!0)&&D("boolean",t.isPinnedMessage,!0)},jo=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Vo=Object.assign(Object.assign({},Ho),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function zo(t){var n,r,a;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(t.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var Bo,Ko=function(e){var t;return pe(ve({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),extendedMessagePayload:e.extendedMessagePayload}))},Qo=function(e){return Go(e)&&D("string",e.message)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)&&D("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Bo||(Bo={}));var Wo=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Yo=function(e){return e===Bo.BLOB||e===Bo.FILE},Zo=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Xo=Object.assign(Object.assign({},Ho),{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});function Jo(t){var n,r,a,i;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.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,_thumbnails:t.thumbnails}))}var $o,eu=function(e,t){var n;return e.messageParams?(!e.url&&H(t)&&(e.messageParams.file=t),e.messageParams):pe(ve({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}}))}))},tu=function(e){return Go(e)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},nu={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},ru=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(si,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(vs,t.metaArrays,!0)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ds,t.appleCriticalAlertOptions,!0)},au=Object.assign(Object.assign({},nu),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),iu=function(e){return ru(e)&&D("string",e.message,!0)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)},su=Object.assign({},nu),ou=function(e){return ru(e)},uu=function(){return i((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}),[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return D("number",this.limit)&&this.limit>0}}])}(),cu=function(t){function a(e,t,i,s){var o;return r(this,a),(o=n(this,a,[e,s])).channelUrl=t,o.channelType=i,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl)&&R(e.ChannelType,this.channelType)}}])}(uu),lu=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={token:o,limit:u},a}return c(t,e),i(t)}(je),du=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).operators=a.operators.map((function(t){return new si(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(Ve),hu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=es.of(this._iid),r=n.requestQueue,a=new lu(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(du),o=s.operators,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(cu),fu=function(t){function a(t,i,s,o){var u,c,l,d,h,f,p,v,_,m,g;return r(this,a),(u=n(this,a,[t,i,s,o])).reverse=!1,u.messageTypeFilter=e.MessageTypeFilter.ALL,u.customTypesFilter=null,u.senderUserIdsFilter=null,u.replyType=e.ReplyType.NONE,u.includeMetaArray=!1,u.includeReactions=!1,u.includeParentMessageInfo=!1,u.includeThreadInfo=!1,u.showSubchannelMessagesOnly=!1,u._edge=Number.MAX_SAFE_INTEGER,u.reverse=null!==(c=o.reverse)&&void 0!==c&&c,u.messageTypeFilter=null!==(l=o.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,u.customTypesFilter=null!==(d=o.customTypesFilter)&&void 0!==d?d:null,u.senderUserIdsFilter=null!==(h=o.senderUserIdsFilter)&&void 0!==h?h:null,u.replyType=null!==(f=o.replyType)&&void 0!==f?f:e.ReplyType.NONE,u.includeMetaArray=null!==(p=o.includeMetaArray)&&void 0!==p&&p,u.includeReactions=null!==(v=o.includeReactions)&&void 0!==v&&v,u.includeParentMessageInfo=null!==(_=o.includeParentMessageInfo)&&void 0!==_&&_,u.includeThreadInfo=null!==(m=o.includeThreadInfo)&&void 0!==m&&m,u.showSubchannelMessagesOnly=null!==(g=o.showSubchannelMessagesOnly)&&void 0!==g&&g,u}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.reverse)&&R(e.MessageTypeFilter,this.messageTypeFilter)&&R(e.ReplyType,this.replyType)&&P("string",this.customTypesFilter,!0)&&P("string",this.senderUserIdsFilter,!0)&&D("boolean",this.includeMetaArray)&&D("boolean",this.includeReactions)&&D("boolean",this.includeParentMessageInfo)&&D("boolean",this.includeThreadInfo)&&D("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,t=nh.of(this._iid),e.next=7,t.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,ve({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));case 7:return n=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(v(n.map((function(e){return e.createdAt}))))),this._hasNext=n.length>=this.limit,this._isLoading=!1,e.abrupt("return",n);case 12:return e.abrupt("return",[]);case 15:throw A.queryInProgress;case 16:e.next=19;break;case 18:throw A.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}])}(cu),pu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={limit:o,token:u},a}return c(t,e),i(t)}(je),vu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).mutedUsers=[];var s=a.next,o=a.muted_list;return i.token=s,o&&o.length>0&&(i.mutedUsers=o.map((function(t){return new Po(e,t)}))),i}return c(t,e),i(t)}(Ve),_u=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new pu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(vu),s=i.mutedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),mu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({limit:o,token:u}),a}return c(t,e),i(t)}(je),gu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).bannedUsers=[];var s=a.next,o=a.banned_list;return i.token=s,o&&o.length>0&&(i.bannedUsers=o.map((function(t){return new Po(e,t.user)}))),i}return c(t,e),i(t)}(Ve),yu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new mu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(gu),s=i.bannedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu);e.ReportCategory=void 0,($o=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",$o.HARASSING="harassing",$o.SUSPICIOUS="suspicious",$o.INAPPROPRIATE="inappropriate";var Eu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(je),ku=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(je),bu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute/").concat(o),a}return c(t,e),i(t)}(je),Cu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.startAt=0,i.endAt=0;var s=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return i.isMuted=s,i.startAt=o,i.endAt=u,i.remainingDuration=c,i.description=l,i}return c(t,e),i(t)}(Ve),wu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={keys:o,include_ts:!0},a}return c(t,e),i(t)}(je),xu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(Ve),Su=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0},a}return c(t,e),i(t)}(je),Tu=function(e){function t(e,a){var i,s,o;return r(this,t),(i=n(this,t,[e,a])).metaData=null!==(s=a.metadata)&&void 0!==s?s:{},i.ts=null!==(o=a.ts)&&void 0!==o?o:null,i}return c(t,e),i(t)}(Ve),Iu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata,u=e.upsert;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return c(t,e),i(t)}(je),Nu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(Ve),Au=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),Mu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(o),a.params={include_ts:!0},a}return c(t,e),i(t)}(je),Ou=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(Ve),Uu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={include_ts:!0},a}return c(t,e),i(t)}(je),Du=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(Ve),Ru=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={keys:o},a}return c(t,e),i(t)}(je),Lu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(Ve),Pu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o},a}return c(t,e),i(t)}(je),Fu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(Ve),qu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,d=void 0===l?"set":l;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o,upsert:c,mode:d},a}return c(t,e),i(t)}(je),Hu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(Ve),Gu=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),ju=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(o),a.params={},a}return c(t,e),i(t)}(je),Vu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={},a}return c(t,e),i(t)}(je),zu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return c(t,e),i(t)}(je),Bu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),s}return c(t,e),i(t)}(Ke),Ku=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(je),Qu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),s}return c(t,e),i(t)}(Ke),Wu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({user_id:o,seconds:u,description:c}),a}return c(t,e),i(t)}(je),Yu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),i.data.member_count&&(s.memberCount=i.data.member_count),i.data.joined_member_count&&(s.joinedMemberCount=i.data.joined_member_count),s}return c(t,e),i(t)}(Ke),Zu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(je),Xu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Po(e,i.data),s}return c(t,e),i(t)}(Ke),Ju=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.freezing;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Le(s),"/").concat(encodeURIComponent(i),"/freeze"),a.params={freeze:o},a}return c(t,e),i(t)}(je),$u=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).freeze=i.data.freeze,s}return c(t,e),i(t)}(Ke),ec=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return c(t,e),i(t)}(je),tc=function(t){function a(t){var i;r(this,a);var s=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,d=t.description;return(i=n(this,a)).method=_e.POST,i.path="".concat(Se,"/users/").concat(l),i.params={channel_url:s,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:d},i}return c(a,t),i(a)}(je),nc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,d=e.description,h=e.messageToken;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/messages/").concat(l),a.params=pe({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),a}return c(t,e),i(t)}(je),rc=function(t){function a(t){r(this,a);var i=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MESG",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:i,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,extended_message_payload:t.extendedMessagePayload}))}])}return c(a,t),i(a)}(Qe),ac=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"MESG",i])).message=new oo(e,i);var d=es.of(e).sdkState;return s.isMentioned=Fe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),ic=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MEDI",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))}])}return c(a,t),i(a)}(Qe),sc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"MEDI",i])).message=new oo(e,i);var h=es.of(e).sdkState;return s.mentionCountChange=qe({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),oc=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FEDI",ackRequired:!0,payload:pe(ve({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:i,apple_critical_alert_options:t.appleCriticalAlertOptions}))}])}return c(a,t),i(a)}(Qe),uc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"FEDI",i])).message=new fo(e,i);var h=es.of(e).sdkState;return s.mentionCountChange=qe({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),cc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(je),lc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new os(a),i}return c(t,e),i(t)}(Ve),dc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(je),hc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new os(Object.assign({},a)),i}return c(t,e),i(t)}(Ve),fc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return c(t,e),i(t)}(je),pc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new oo(e,a),i}return c(t,e),i(t)}(Ve),vc=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.POST,i.path="".concat(Le(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(je),_c=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new oo(e,a),i}return c(t,e),i(t)}(Ve),mc=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl;return i.method=_e.POST,i.path="".concat(Le(c),"/").concat(encodeURIComponent(l),"/scheduled_messages"),i.params=ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return ns.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),i}return c(a,t),i(a)}(je),gc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new fo(e,a),i}return c(t,e),i(t)}(Ve),yc=function(e){return D("string",e.title,!0)&&ro(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0)},Ec=function(e){function t(e){var a,i=e.pollId,s=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a.params={title:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(je),kc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),bc=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(je),Cc=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/close"),a}return c(t,e),i(t)}(je),wc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),xc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.optionText;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:i,channel_type:s,text:u},a}return c(t,e),i(t)}(je),Sc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Tc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId,o=e.optionText;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a.params={text:o},a}return c(t,e),i(t)}(je),Ic=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Nc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),Ac=function(t){function a(t){var i=t.reqId,s=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n(this,a,[{code:"VOTE",ackRequired:!0,payload:pe({req_id:i,channel_type:s===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})}])}return c(a,t),i(a)}(Qe),Mc=i((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})),Oc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"VOTE",i])).event=new Mc(i),s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),Uc=function(e){function t(e){var a,i=e.title,s=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=Ne,a.params={title:i,options:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(je),Dc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Rc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(je),Lc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new io(e,a),i}return c(t,e),i(t)}(Ve),Pc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(je),Fc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pollOption=new ao(e,a),i}return c(t,e),i(t)}(Ve),qc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/polls/changelogs"),a.params=pe({change_ts:o,token:u}),a}return c(t,e),i(t)}(je),Hc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedPolls=a.updated.map((function(t){return function(e,t){return new io(e,t)}(e,t)})),i.deletedPollIds=a.deleted.map((function(e){return e})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(Ve),Gc={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},jc=function(e){return D("string",e.title)&&(t=e.optionTexts,P("string",t)&&t.every((function(e){return""!==e.trim()})))&&ro(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0);var t},Vc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},zc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)&&t.pollId>0&&D("number",t.pollOptionId)&&t.pollOptionId>0},Bc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},Kc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)},Qc={},Wc=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,u=n.logger;r(this,e),this._iid=t,this._sdkState=a,this._sessionManager=s,this._requestQueue=o,this._dispatcher=i,this._logger=u,Qc[t]=this}),[{key:"buildPollFromSerializedData",value:function(e){var t=ri(e);return new io(this._iid,io.payloadify(t))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(Kc(e)).throw(A.invalidParameters),n=new Rc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Lc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(jc(e)).throw(A.invalidParameters),n=new Uc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Dc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(zc(e)).throw(A.invalidParameters),n=new Pc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Fc),i=a.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogs",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.SYNC_POLL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new qc(ve({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null})),e.next=3,this._requestQueue.send(i);case 3:return s=e.sent,o=s.as(Hc),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,u.length>0&&this._dispatcher.dispatch(new Ps({polls:u,source:a})),e.abrupt("return",{updatedPolls:u,deletedPollIds:c,hasMore:l,token:h});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Qc[e]}}])}(),Yc="GroupChannel",Zc="Message",Xc="NotificationMessage",Jc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=Ne,a.params={channel_url:i,channel_type:s,token:o,limit:u},a}return c(t,e),i(t)}(je),$c=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).polls=(null!==(s=a.polls)&&void 0!==s?s:[]).map((function(t){return new io(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(Ve),el=function(e){function t(e,a){return r(this,t),n(this,t,[e,a.channelUrl,a.channelType,a])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new Jc(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as($c),s=i.polls,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),tl=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:i,channel_type:s,token:c,limit:l},a}return c(t,e),i(t)}(je),nl=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).voters=(null!==(s=a.voters)&&void 0!==s?s:[]).map((function(t){return new si(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(Ve),rl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a.channelUrl,a.channelType,a])).pollId=a.pollId,i.pollOptionId=a.pollOptionId,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("number",this.pollId)&&D("number",this.pollOptionId)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new tl(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(nl),s=i.voters,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu);var al,il=Object.assign(Object.assign({},Ho),{fileInfoList:[]}),sl=function(e){return(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},ol=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._onFileUploaded=ht,e}return c(t,e),i(t,[{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(t,"onPending",this,3)([e]),this}},{key:"onFailed",value:function(e){return p(t,"onFailed",this,3)([e]),this}},{key:"onSucceeded",value:function(e){return p(t,"onSucceeded",this,3)([e]),this}}])}(qo),ul=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e])).message=null,i.message=ho(e,a.message),i}return c(t,e),i(t)}(Ya),cl=function(e){function t(e){var a;r(this,t);var i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,d=e.includeParentMessageInfo,h=e.includeThreadInfo,f=e.includePollDetails;return(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/pinned_messages"),a.params=pe({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),a}return c(t,e),i(t)}(je),ll=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.pinned_messages,o=a.has_more,u=a.next;return i.pinnedMessages=s.map((function(t){return new ul(e,t)})),i.hasMore=o,i.token=u,i}return c(t,e),i(t)}(Ve),dl=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s])).includeMetaArray=s.includeMetaArray,o.includeReactions=s.includeReactions,o.includeParentMessageInfo=s.includeParentMessageInfo,o.includeThreadInfo=s.includeThreadInfo,o.includePollDetails=s.includePollDetails,o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeMetaArray,!0)&&D("boolean",this.includeReactions,!0)&&D("boolean",this.includeParentMessageInfo,!0)&&D("boolean",this.includeThreadInfo,!0)&&D("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new cl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(ll),s=i.pinnedMessages,o=i.hasMore,u=i.token,this._token=u,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(cu),hl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(je),fl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(je);!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(al||(al={}));var pl,vl=function(t){function a(t,i){var s,o,u,c,l,d,h,f;return r(this,a),(s=n(this,a,[t]))._name="",s._createdAt=0,s.pinnedMessageIds=[],s.channelType=e.ChannelType.BASE,s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s._messageCollectionLastAccessedAt=0,s._url=i.channel_url,s._name=null!==(o=i.name)&&void 0!==o?o:"",s._createdAt=1e3*i.created_at,s.coverUrl=null!==(u=i.cover_url)&&void 0!==u?u:"",s.customType=null!==(c=i.custom_type)&&void 0!==c?c:"",s.data=null!==(l=i.data)&&void 0!==l?l:"",s.isFrozen=null!==(d=i.freeze)&&void 0!==d&&d,s.isEphemeral=null!==(h=i.is_ephemeral)&&void 0!==h&&h,s.creator=i.created_by?new si(s._iid,i.created_by):null,i.metadata&&Object.keys(i.metadata).length>0&&i.ts?(s._cachedMetaData=new Map,Object.keys(i.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:i.metadata[e],isRemoved:!1,updatedAt:i.ts})}))):"string"==typeof i.metadata&&(s._cachedMetaData=new Map(Object.entries(JSON.parse(i.metadata)))),s.pinnedMessageIds=null!==(f=i.pinned_message_ids)&&void 0!==f?f:[],s}return c(a,t),i(a,[{key:"url",get:function(){return this._url}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"createdAt",get:function(){return this._createdAt}},{key:"toJSON",value:function(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}},{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"isFeedChannel",value:function(){return this.channelType===e.ChannelType.FEED}},{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:"_serializeCachedMetaData",value:function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=pe(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:"_updateCachedMetaData",value:function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(a,i){var s;a.updatedAt<=t&&(n._cachedMetaData.set(i,{value:null!==(s=e[i])&&void 0!==s?s:a.value,isRemoved:!e[i],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}}},{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 hu(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new _u(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yu(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new fu(this._iid,this.url,this.channelType,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new dl(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Eu({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"removeOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new ku({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyMutedInfo",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new bu({channelUrl:this.url,channelType:this.channelType,userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Cu),o=s.isMuted,u=s.startAt,c=s.endAt,l=s.remainingDuration,h=s.description,e.abrupt("return",{isMuted:o,startAt:u,endAt:c,remainingDuration:l,description:h});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new wu({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(xu),o=s.metadata,u=s.ts,this._upsertCachedMetaData(o,u),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new wu({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(xu),s=i.metadata,o=i.ts,this._updateCachedMetaData(s,o),e.abrupt("return",s);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Su({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Tu),o=s.metaData,this._upsertCachedMetaData(o,0),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=new Iu({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Nu),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Mu({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:i=t.sent,s=i.as(Ou),o=s.ts,this._removeFromCachedMetaData([e],o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Uu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Du),s=i.ts,this._removeFromCachedMetaData(v(this._cachedMetaData.keys()),s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Ru({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(Lu),o=s.metaCounter,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Ru({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Lu),s=i.metaCounter,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Pu({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Fu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaCounters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=new qu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Hu),u=o.metaCounter,n.abrupt("return",u);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new qu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Hu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new qu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Hu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new ju({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Vu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.muteUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"muteUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new zu({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unmuteUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Ku({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"banUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.banUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"banUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new Wu({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unbanUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unbanUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new Zu({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"freeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Ju({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,n.send(r);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Ju({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,n.send(r);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},wo),t),ai(D("number",e)&&xo(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessagesByMessageId(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},wo),t),ai(D("number",e)&&xo(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessagesByTimestamp(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},So),t),ai(D("number",e)&&To(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},So),t),ai(D("string",e)&&To(r)).throw(A.invalidParameters),a=nh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,i=es.of(this._iid).sessionManager;return pe(ve({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 vs.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:i.currentUser?ps.payloadify(i.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 si.payloadify(e)}))}))}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var i,o=s(t.translationTargetLanguages);try{for(o.s();!(i=o.n()).done;){a[i.value]=""}}catch(e){o.e(e)}finally{o.f()}}var u=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a,extended_message_payload:t.extendedMessagePayload})),c=new oo(this._iid,u);return c.messageParams=t,c}},{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,i,s,o,u,c,l,d=pe(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===(i=t.file)||void 0===i?void 0:i.name,size:null!==(s=t.fileSize)&&void 0!==s?s: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:null===(l=t._thumbnails)||void 0===l?void 0:l.map((function(e){return ns.payloadify(e)}))})),h=new fo(this._iid,d);return h.messageParams=t,h}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,file:t.fileInfoList.length>0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0})),i=new uo(this._iid,a);return i.messageParams=t,i}},{key:"_validateFailedFileMessageHasFile",value:function(e,t){var n;return Boolean(e.url)||H(t)||H(null===(n=e.messageParams)||void 0===n?void 0:n.file)}},{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.SendbirdErrorCode.REQUEST_CANCELED||n.code===e.SendbirdErrorCode.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({},Vo),e);return ai(Qo(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:al.SEND,a=arguments.length>2?arguments[2]:void 0,i=es.of(this._iid),s=i.dispatcher,o=i.requestQueue,u=null!=a?a:this._generateRequestId(),c=Date.now(),l=new qo;return mi(2).then((function(){var a=n._createPendingUserMessage(t,u,c);s.dispatch(new Os({messages:[a],source:r===al.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a));case 1:case"end":return e.stop()}}),e)})))}));var i=new rc(Object.assign(Object.assign({},t),{channelUrl:n.url,channelType:n.channelType,reqId:u}));o.send(i).then((function(t){var r=t.as(ac).message;s.dispatch(new Os({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().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)})))}))})).catch((function(r){if(N(r))throw r;mi(2).then((function(){var a=n._createPendingUserMessage(t,u,c),i=es.of(n._iid).cacheContext,o=i.localCacheEnabled&&i.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,o),s.dispatch(new Os({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),l}},{key:"_autoResendUserMessage",value:function(e){return ai(e instanceof oo&&!!e.messageParams).throw(A.invalidParameters),this._sendUserMessage(e.messageParams,al.SEND,e.reqId)}},{key:"resendUserMessage",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof oo&&!e.scheduledInfo).throw(A.invalidParameters),r=new ot,a=null!==(t=e.messageParams)&&void 0!==t?t:Ko(e),this._sendUserMessage(a,al.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"updateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},au),t),ai(D("number",e)&&iu(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new ic(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(sc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"copyUserMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ai(t instanceof a&&n instanceof oo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),ai(!n.poll).throw(A.notSupportedError),u=new ot,c=null!==(r=n.messageParams)&&void 0!==r?r:ve(Object.assign(Object.assign({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(s=n.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),t._sendUserMessage(c).onSucceeded((function(e){u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 6:case"end":return o.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof oo&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new fc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(pc),u=o.message,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_createScheduledUserMessage",value:function(e,t){var n=this,r=es.of(this._iid).requestQueue,a=Date.now(),i=this._generateRequestId();mi(2).then((function(){var r=n._createPendingScheduledUserMessage(e,i,a);hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))}));var s=new vc(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(_c).message;hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;mi(2).then((function(){var s=n._createPendingScheduledUserMessage(e,i,a);n._markMessageAsFailed(s,r),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},Xo),e);return ai(tu(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},il),e),r=es.of(this._iid);ai(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return Go(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return sl(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 ai(!a).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:al.SEND,a=arguments.length>2?arguments[2]:void 0,i=es.of(this._iid).dispatcher,s=nh.of(this._iid).fileMessageQueue,o=null!=a?a:this._generateRequestId(),u=Date.now(),c=new qo;return mi(2).then((function(){var a=n._createPendingFileMessage(t,o,u);i.dispatch(new Os({messages:[a],source:r===al.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a));case 1:case"end":return e.stop()}}),e)})))})),s.request(n,o,t).then((function(t){i.dispatch(new Os({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;mi(2).then((function(){var a=n._createPendingFileMessage(t,o,u),s=es.of(n._iid).cacheContext,l=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,l),i.dispatch(new Os({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:r.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),hi((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_autoResendFileMessage",value:function(e){ai(e instanceof fo&&!!e.messageParams).throw(A.invalidParameters);var t=es.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,al.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(t,n,r){var a=this,i=es.of(this._iid).dispatcher,s=nh.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new ol;return mi(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);i.dispatch(new Os({messages:[r],source:n===al.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(r));case 1:case"end":return e.stop()}}),e)})))})),s.request(a,o,t,{requestHandler:c,isCopy:n===al.COPY}).then((function(t){i.dispatch(new Os({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(n){if(N(n))throw n;mi(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);a._markMessageAsFailed(r,n),i.dispatch(new Os({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(n,r));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_createScheduledFileMessage",value:function(e,t,n,r){var a=this,i=es.of(this._iid).requestQueue,s=new mc(Object.assign(Object.assign({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(s).then((function(e){var n=e.as(gc).message;hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(N(i))throw i;mi(2).then((function(){var s=a._createPendingScheduledFileMessage(e,n,r);a._markMessageAsFailed(s,i),hi((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(i,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){ai(e.every((function(e){return tu(Object.assign(Object.assign({},Xo),e))}))).throw(A.invalidParameters);var t,n=new qo,r=s(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,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._validateFailedFileMessageHasFile(e,t),ai(e instanceof fo&&r&&!e.scheduledInfo).throw(A.invalidParameters),a=new ot,i=eu(e,t),this._sendFileMessage(i,al.RESEND,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),n.abrupt("return",a.promise);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"resendMessage",value:function(e,t){var n,r;if(ai(e instanceof Ys&&!e.scheduledInfo&&e.isResendable).throw(A.invalidParameters),e.isUserMessage()){var a=null!==(n=e.messageParams)&&void 0!==n?n:Ko(e);return this._sendUserMessage(a,al.RESEND,e.reqId)}if(e.isFileMessage()){var i=this._validateFailedFileMessageHasFile(e,t);ai(i).throw(A.invalidParameters);var s=null!==(r=e.messageParams)&&void 0!==r?r:eu(e,t);return this._sendFileMessage(s,al.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"updateFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},su),t),ai(D("number",e)&&ou(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new oc(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(uc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"uploadFile",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=ce(),(i=new rs({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a),t.next=7,r.send(i);case 7:return s=t.sent,o=s.as(as),u=o.url,c=o.thumbnails,t.abrupt("return",{requestId:a,url:u,thumbnails:c});case 10:case"end":return t.stop()}}),t,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=nh.of(this._iid),n.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"copyFileMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ai(t instanceof a&&n instanceof fo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),u=new ot,c=ve(Object.assign(Object.assign({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=n.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),t._sendFileMessage(c).onSucceeded((function(e){return u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 5:case"end":return o.stop()}}),o,this)})))}},{key:"copyMessage",value:function(t,n){ai(t instanceof a&&n instanceof Ys&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters);var r=n,i=t;if(r.isUserMessage()){ai(!r.poll).throw(A.notSupportedError);var s=zo(r);return i._sendUserMessage(s)}if(r.isFileMessage()){var o=Jo(r);return i._sendFileMessage(o)}if(n.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"deleteMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ai(e instanceof Ws).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return n=es.of(this._iid),r=n.requestQueue,a=new ct({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof Ys?e._messageToken:void 0}),t.next=6,r.send(a);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"addReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof Ws&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new cc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(lc),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(e instanceof Ws&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new dc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(hc),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_updateUserMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=es.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new ic({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(sc),f=h.message,o.dispatch(new Os({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=es.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new oc({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(uc),f=h.message,o.dispatch(new Os({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new vs({key:e})})),!(e instanceof fo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"add",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"add",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new vs({key:e})})),!(e instanceof fo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"remove",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"remove",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&t.every((function(e){return e instanceof vs}))).throw(A.invalidParameters),!(e instanceof fo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"add",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"add",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(e instanceof Ws&&e.messageId>0&&t.every((function(e){return e instanceof vs}))).throw(A.invalidParameters),!(e instanceof fo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"remove",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"remove",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"report",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(R(e.ReportCategory,t)&&D("string",n)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new ec({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:t,description:n}),r.next=5,s.send(o);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"reportUser",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ai(t instanceof si&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=es.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new tc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.userId,category:n,description:r}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"reportMessage",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ai(t instanceof Ys&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=es.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new nc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r,messageToken:t._messageToken}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"updatePoll",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("number",e)&&yc(t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new Ec(Object.assign({pollId:e},t)),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(kc),u=o.poll,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deletePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ai(n).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new bc({pollId:e}),t.next=6,a.send(i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"closePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ai(n).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new Cc({pollId:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(wc),u=o.poll,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"addPollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("string",t)&&""!==t.trim(),ai(r).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new xc({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(Sc),c=u.poll,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updatePollOption",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",e)&&D("number",t)&&D("string",n)&&""!==n.trim(),ai(a).throw(A.invalidParameters),i=es.of(this._iid),s=i.requestQueue,o=new Tc({pollId:e,pollOptionId:t,optionText:n}),r.next=6,s.send(o);case 6:return u=r.sent,c=u.as(Ic),l=c.poll,r.abrupt("return",l);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"deletePollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("number",t),ai(r).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new Nc({pollId:e,pollOptionId:t}),n.next=6,i.send(s);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"votePoll",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",t)&&P("number",n),ai(a).throw(A.invalidParameters),i=es.of(this._iid),s=i.requestQueue,o=i.dispatcher,u=new Ac({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:n}),r.next=6,s.send(u);case 6:return c=r.sent,l=c.as(Oc),h=l.event,o.dispatch(new qs({event:h,source:e.CollectionEventSource.EVENT_POLL_VOTED})),r.abrupt("return",h);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("number",e)).throw(A.invalidParameters),n=Wc.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e,!0)),n=Wc.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new el(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 rl(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}},{key:"pinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("number",e)&&e>0).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new hl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unpinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("number",e)&&e>0).throw(A.invalidParameters),n=es.of(this._iid),r=n.requestQueue,a=new fl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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?si.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}}])}(Ya),_l=i((function e(t){r(this,e),this.key=t.key,this.url=t.url})),ml=i((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 _l(e)})):[]})),gl=i((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new ml(e)})):[]})),yl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onConnected=ht,this.onReconnectStarted=ht,this.onReconnectSucceeded=ht,this.onReconnectFailed=ht,this.onDisconnected=ht}))),El=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onSessionExpired=ht,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=ht,this.onSessionRefreshed=ht,this.onSessionClosed=ht}))),kl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onFriendsDiscovered=ht,this.onTotalUnreadMessageCountChanged=ht,this.onTotalUnreadMessageCountUpdated=ht}))),bl=function(e){function t(e){var a,i=e.limit,s=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=ge,a.params=pe({limit:i,token:s,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return c(t,e),i(t)}(je),Cl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new si(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(Ve),wl=function(e){function t(e,a){var i,s,o,u;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.metaDataKeyFilter=null,i.metaDataValuesFilter=null,i.nicknameStartsWithFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i.metaDataKeyFilter=null!==(o=a.metaDataKeyFilter)&&void 0!==o?o:null,i.metaDataValuesFilter=null!==(u=a.metaDataValuesFilter)&&void 0!==u?u:null,i.nicknameStartsWithFilter=a.nicknameStartsWithFilter||null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)&&D("string",this.metaDataKeyFilter,!0)&&P("string",this.metaDataValuesFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new bl(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Cl),s=i.users,o=i.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),xl=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token,u=e.userIdsFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/block"),a.params=pe({limit:s,token:o,user_ids:u}),a}return c(t,e),i(t)}(je),Sl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new si(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(Ve),Tl=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new xl(ve(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token}))),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Sl),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),Il=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={limit:s,token:o},a}return c(t,e),i(t)}(je),Nl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).hasMore=a.has_more,i.users=a.users.map((function(t){return new si(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(Ve),Al=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Il(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Nl),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),Ml={},Ol=function(){return i((function e(t){var n=t.dbname,a=t.itemSizeLimit,i=void 0===a?1048576:a,s=t.cacheLimit,o=void 0===s?256:s,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,d=void 0===l?10:l,h=t.blockHashConstant,f=void 0===h?11:h,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),Ml[n]||(this.itemSizeLimit=i,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=d,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,Ml[n]=this),Ml[n]}),null,[{key:"get",value:function(e){return Ml[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"}(pl||(pl={}));var Ul,Dl=function(e){function t(e){var a,i=e.code,s=void 0===i?pl.UNKNOWN_ERROR:i,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,t),(a=n(this,t,[u])).code=s,Object.setPrototypeOf(a,t.prototype),a}return c(t,e),i(t,null,[{key:"storeNotDefined",get:function(){return new t({code:pl.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new t({code:pl.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new t({code:pl.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new t({code:pl.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new t({code:pl.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new t({code:pl.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new t({code:pl.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new t({code:pl.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new t({code:pl.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new t({code:pl.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new t({code:pl.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new t({code:pl.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new t({code:pl.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new t({code:pl.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new t({code:pl.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new t({code:pl.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new t({code:pl.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new t({code:pl.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new t({code:pl.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new t({code:pl.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new t({code:pl.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new t({code:pl.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new t({code:pl.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new t({code:pl.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new t({code:pl.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}])}(y(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ul||(Ul={}));var Rl,Ll=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===m(e)&&null!==e){if(t.has(e))throw Dl.circularReferenceFound;var n;if(t.set(e,!0),Array.isArray(e))n=e.map((function(e){return Ll(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]=Ll(e[r],t);return t.delete(e),n}return e},Pl=function(e,t){if(null==t)return 1;if(null==e)return-1;if(m(e)!==m(t))throw Dl.compareTypesNotMatch;var n=0;switch(m(e)){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Fl=function(e,t){for(var n=0,r=0;r>>0)%t},ql=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Hl=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!Hl(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Hl(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"===m(e[r])){var a=e[r];for(var i in a)switch(i){case"/eq":case"=":if(t[r]!==a[i])return!1;break;case"/neq":case"!=":if(t[r]===a[i])return!1;break;case"/gt":case">":var s=t[r],o=a[i];if(!(Pl(s,o)>0))return!1;break;case"/gte":case">=":var u=t[r],c=a[i];if(!(Pl(u,c)>=0))return!1;break;case"/lt":case"<":var l=t[r],d=a[i];if(!(Pl(l,d)<0))return!1;break;case"/lte":case"<=":var h=t[r],f=a[i];if(!(Pl(h,f)<=0))return!1;break;case"/in":var p=t[r];if(!a[i].includes(p))return!1;break;case"/nin":var v=t[r];if(a[i].includes(v))return!1;break;case"/contain":var _=t[r],g=a[i];if(!_.includes(g))return!1;break;case"/regex":var y=t[r];if(!a[i].test(y))return!1;break;case"/where":var E=t[r];if(!(0,a[i])(E))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)},Gl=function(){},jl=function(){return Promise.resolve()},Vl=function(e){return e},zl=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Rl||(Rl={}));var Bl,Kl,Ql,Wl=function(){return i((function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,i=t.initialNextValue,s=void 0===i?null:i,o=t.iterator,u=t.map,c=void 0===u?Vl:u,l=t.backward,d=void 0===l?jl:l,h=t.forward,f=void 0===h?jl:h,p=t.complete,v=void 0===p?Gl:p;r(this,e),this._prevValue=a,this._nextValue=s,this._error=null,this._map=c,this._backward=d,this._forward=f,this._iterator=o,this._complete=v}),[{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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,t=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,t=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}])}(),Yl=function(){return i((function e(t){var n=t.condition,a=void 0===n?{}:n,i=t.backward,s=void 0!==i&&i,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=s,this._blockManager=o,this._indexer=u}),[{key:"findOptimizedStartPosition",value: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 a in this._indexer.fields){var i=this._indexer.fields[a],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),this.condition[i])if("object"===m(this.condition[i])){var o=s>0?n:t;for(var u in this.condition[i])if(o.includes(u))for(var c=r;c>=0;c--)if(s*Pl(this._indexer.origin[c].columnValues[a],this.condition[i][u])<=0){r=c;break}}else for(var l=r;l>=0;l--)if(s*Pl(this._indexer.origin[l].columnValues[a],this.condition[i])<=0){r=l;break}}return Math.min(r+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var h=function(r){var a=e._indexer.fields[r],i=1;if("-"===a[0]&&(a=a.slice(1),i=-1),e.condition[a])if("object"===m(e.condition[a]))Object.keys(e.condition[a]).forEach((function(s){if((i>0?t:n).includes(s))for(var o=d;o=0){d=o;break}}));else for(var s=d;s=0){d=s;break}},f=0;f0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Math.max(e.offset||0,0),0!==(r="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){t.next=6;break}return t.abrupt("return",[]);case 6:if(!(r<0)){t.next=8;break}throw Dl.collectionQueryNotValid;case 8:return t.prev=8,a=[],t.next=12,this._mutex.lock();case 12:return t.next=14,this._iterator.each((function(e){return E(i,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===n?(a.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(td(e,t)).concat(n,".").concat(r)},rd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=i}),[{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(n=t.sent)){t.next=19;break}if(r=n.data,a=n.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(r);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(s=[],o=atob(r.split(",")[1]),u=0;u1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,new Promise((function(n){var r=nd(o.dbname,o.collectionName,t),a=new FileReader;a.onload=function(){n({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return r=n.sent,a=r.blobId,i=r.data,s=r.type,n.next=8,this.store.set({key:a,value:{data:i,type:s}});case 8:return n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=td(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return n=e.sent,e.next=6,Promise.all(n.filter((function(e){return e.startsWith(t)})).map((function(e){return E(r,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}])}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Bl||(Bl={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Kl||(Kl={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Ql||(Ql={}));var ad,id,sd=[Kl.PENDING,Kl.VOLATILE],od={},ud=function(){return i((function e(t){var n=t.dbname,a=t.limit,i=void 0===a?256:a;return r(this,e),od[n]||(this.dbname=n,this._items=[],this._limit=i,od[n]=this),od[n]}),[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ql.DEFAULT;return E(this,void 0,void 0,d().mark((function r(){var a,i;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=this.get(t)){r.next=8;break}return r.next=4,e.get(t);case 4:(i=r.sent)&&(a={key:t,value:i,state:n===Ql.PERSISTENT?Kl.PERSISTENT:Kl.VOLATILE},this.put(a)),r.next=9;break;case 8:n===Ql.PERSISTENT&&(a.state=Kl.PERSISTENT);case 9:return r.abrupt("return",a);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ql.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===Ql.PERSISTENT&&(r.state=Kl.PERSISTENT),t!==Ql.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)sd.includes(this._items[t].state)&&sd.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===Kl.VOLATILE})),r=n.length-this._limit;if(r>0){var a,i=[],o=s(this._items);try{for(o.s();!(a=o.n()).done;){var u=a.value;u.state===Kl.VOLATILE&&r>0?r--:i.push(u)}}catch(e){o.e(e)}finally{o.f()}this._items=i}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clearForDatabase",value:function(e){this.clearByCondition((function(t){return t.key.startsWith(Xl(e))}))}},{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!==Kl.VOLATILE}))}}],[{key:"get",value:function(e){return od[e]}}])}(),cd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=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(Jl(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Jl(e,t),"/trans.recordset")}(n,a),this._store=i}),[{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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(n=t.t0).push.apply(n,v(e)),t.abrupt("return",this._reduceRecordSet(n));case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],i=[],s=a.requests.length-1;s>=0;s--){var o=a.requests[s],u=o.data;n[u.key]||(i.unshift(o),n[u.key]=!0)}i.length>0&&(a.requests=i,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ud.get(this.dbname),a=t.generation,i=t.requests,s=null,n.prev=3,n.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:a})})));case 6:for(o=n.sent,u=0;u0)){e.next=20;break}for(n=[],r={},a=t.length-1;a>=0;a--)i=t[a],s=i.data,r[s.key]||(r[s.key]=!0,n.unshift(i));return o={generation:this.generation,requests:n},e.next=8,this._getReducedRecordset([o]);case 8:return u=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:u});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(c=ud.get(this.dbname),l=0;l1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=i,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||Fl)(e,r)}(e,i,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(ed(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=ud.get(this.dbname),r=this.metadata.blockLevel;case 2:if(!(r>0)){t.next=15;break}return a=this.createBlockId(e,r),t.next=6,n.find(this._store,a);case 6:if(!(i=t.sent)){t.next=12;break}if(s=ld.createFromCacheItem(i),!(null==s?void 0:s.getItemByKey(e))){t.next=12;break}return t.abrupt("return",s);case 12:r--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"getFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return n=t.sent,t.abrupt("return",n?n.getItemByKey(e):null);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"putToBlock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Ol.get(this.dbname),a=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/r.itemSizeLimit),s=ud.get(this.dbname),n.next=6,s.find(this._store,a);case 6:if(o=n.sent,!(null==(u=o?ld.createFromCacheItem(o):new ld({blockId:a,keyName:this.keyName,items:[],limit:i}))?void 0:u.add(t))){n.next=11;break}return this._transaction.requestWrite({key:u.blockId,value:u.serialize()}),n.abrupt("return",!0);case 11:return n.abrupt("return",!1);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"removeFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(n=t.sent)){t.next=7;break}if(!n.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:n.blockId,value:n.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"clearAllBlocks",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ed(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return n=e.sent,r=n.filter((function(e){return e.startsWith(t)})),e.next=7,this._store.removeMany(r);case 7:return e.next=9,this._transaction.clear();case 9:ud.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(t)}));case 11:case"end":return e.stop()}}),e,this)})))}}])}(),hd={},fd=function(){return i((function e(t){var n=this,a=t.dbname,i=t.collectionName,s=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(Jl(e,t),"/index.").concat(n)}(a,i,o.join(">"));return hd[l]||(this.dbname=a,this.collectionName=i,this.keyName=s,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Bl.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Bl.ERROR,this.indexerKey,(function(){return n.abort()}))),hd[l]}),[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=f(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=f(this.indexOf(n),2),a=r[0];if(r[1]){var i=this._table[a].keys.indexOf(t);if(i>-1)return this._table[a].keys.splice(i,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,n,r,a=[],i=s(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),n=e[o],r=void 0,r=m(n),null!==n&&"undefined"!==r&&"boolean"!==r&&"number"!==r&&"string"!==r)throw Dl.indexTypesNotMatch;a.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return a}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Pl(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,d().mark((function e(){var t,n,r,a,i,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ud.get(this.dbname),e.next=3,t.find(this._store,this.indexerKey,Ql.PERSISTENT);case 3:if(n=e.sent){e.next=33;break}return r=ed(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:a=e.sent,i=s(a),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=22;break}if(!(u=o.value).startsWith(r)){e.next=20;break}return e.next=17,t.find(this._store,u,Ql.NO_CACHE);case 17:if(c=e.sent,l=ld.createFromCacheItem(c)){h=s(l.items);try{for(h.s();!(f=h.n()).done;)p=f.value,this._addItem(p)}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=n.value,this._table=Ll(this._origin);case 35:hd[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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ud.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete hd[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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=Ll(this._origin)}},{key:"abort",value:function(){this._table=Ll(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 hd)delete hd[e]}}])}(),pd=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},vd=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"}(ad||(ad={})),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"}(id||(id={}));var _d,md={},gd=function(){return i((function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=ad.PROCESSING,this._queue=[],this._activationQueue=[],md[t]&&!a.forceCreate||(this.nodeId=vd(),this.key=t,pd()&&(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;if(null==t?void 0:t.isNestDbMessage){var r=t.nodeId,a=t.requestId,i=t.key,o=t.op,u=t.data;if(r!==n.nodeId&&i===n.key)switch(o){case id.NEWNODE:n._sendSync();break;case id.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case id.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var c,l=u.currentItemRequestId,d=s(u.queue);try{var h=function(){var e=c.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:id.REQUEST_LOCK,ts:e.ts})};for(d.s();!(c=d.n()).done;)h()}catch(e){d.e(e)}finally{d.f()}n._currentItem=n._queue.find((function(e){return e.requestId===l})),n._completeSync()}break;case id.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 id.REQUEST_LOCK:n._requestLock(t);break;case id.ACQUIRE_LOCK:var f=n._queue.find((function(e){return e.requestId===a}));n._acquire(f);break;case id.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(id.REMOVENODE)}))),md[t]=this),md[t]}),[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==ad.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:vd(),key:this.key,op:e,data:n.data,ts:Date.now()};return pd()&&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(id.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(id.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var i in t._queue)if(t._queue[i].ts>r.ts){t._queue.splice(parseInt(i),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(id.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,d().mark((function e(){var t=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){t._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=ad.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(id.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(id.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return t=this._send(id.REQUEST_LOCK),e.next=5,this._requestLock(t);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)}}])}(),yd=function(){function e(t){var n=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=Ul.INIT,this._indexers=[],this.dbname=a,this.name=i,this.keyName=s,this.indexes=[[s]].concat(v(u.filter((function(e){return fd.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new gd(function(e,t){return"".concat(Jl(e,t),".lock")}(a,i)),this._blobContainer=new rd({dbname:a,collectionName:i,store:c}),this._transaction=new cd({dbname:a,collectionName:i,store:c})}return i(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===Ul.READY}},{key:"init",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l,h,f,p,_=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,n=Ol.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return r=t.sent,this._metadata=r||{keyName:this.keyName,blockLevel:1,blockHashBase:n.blockHashBase,blockHashMultiplier:n.blockHashMultiplier,blockHashConstant:n.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new dd({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),a=v(this.indexes),i=[],o=a.map((function(e){return fd.createKey(e)})),u=r?r.indexes.map((function(e){return fd.createKey(e)})):[],c=s(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(fd.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(f=[]).push.apply(f,v(a.map((function(e){var t=new fd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()})))),f.push.apply(f,v(i.map((function(e){return new fd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()})))),t.next=22,Promise.all(f);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return p=$l(this.dbname,this.name),this._metadata.indexes=a,t.next=29,this._store.set({key:p,value:this._metadata});case 29:this._state=Ul.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),t,this,[[2,33]])})))}},{key:"close",value:function(){this._state=Ul.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=fd.createKey(e),r=s(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===fd.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Dl.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=$l(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:t,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:r=s(this._indexers),t.prev=14,r.s();case 16:if((a=r.n()).done){t.next=22;break}return i=a.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),r.e(t.t0);case 27:return t.prev=27,r.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Dl.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),t,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(r=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:a=s(this._indexers),t.prev=14,a.s();case 16:if((i=a.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),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(n,e);case 34:u=s(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(r),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(r);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()}}),t,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(!(r=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:a=s(this._indexers),t.prev=8,a.s();case 10:if((i=a.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(r),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(r);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),a.e(t.t0);case 24:return t.prev=24,a.f(),t.finish(24);case 27:case"end":return t.stop()}}),t,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(n=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:r=s(this._indexers),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return i=a.value,t.next=13,i.removeItem(n);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:case"end":return t.stop()}}),t,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:t=s(this._indexers),e.prev=3,t.s();case 5:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=9,r.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return n=t.sent,this._mutex.unlock(),t.abrupt("return",Ll(n));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Dl.collectionNotReady;case 18:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new Zl({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Dl.collectionNotReady}},{key:"insertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Dl.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Ll(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 Dl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Dl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestInsert(Ll(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Dl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Dl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Ll(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 Dl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Dl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestUpsert(Ll(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Dl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Dl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Ll(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 Dl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"updateIf",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.isReady){n.next=31;break}return n.next=3,this._mutex.lock();case 3:return n.prev=3,r=e.where,a=void 0===r?{}:r,i=e.index,s=void 0===i?null:i,o=e.backward,u=void 0!==o&&o,c=[],l=new Yl({condition:a,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(s)}),n.next=9,l.each((function(e){return E(v,void 0,void 0,d().mark((function n(){var r,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.error){n.next=4;break}if(e.hasNext){if(r=e.nextValue,Hl(a,r)&&t.set){if("function"!=typeof t.set)for(i in t.set)r[i]=t.set[i];else t.set(r);c.push(r)}e.next()}else e.stop();n.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return n.stop()}}),n)})))}));case 9:h=0,f=c;case 10:if(!(h1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return v(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)),i=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(i).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:i}),r}))}},{key:"_resetIfEncryptionChanged",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(this._encryptionCheckKey);case 2:if(t=e.sent,n={encrypted:Cd.map((function(e){var t;return null===(t=s.encryption)||void 0===t?void 0:t.encrypt(e)}))},!t){e.next=22;break}if(!t.encrypted||!Array.isArray(t.encrypted)){e.next=20;break}e.t0=d().keys(t.encrypted);case 7:if((e.t1=e.t0()).done){e.next=18;break}if(r=e.t1.value,a=JSON.stringify(t.encrypted[r]),i=JSON.stringify(n.encrypted[r]),a===i){e.next=16;break}return bd.warning("Encryption algorithm has changed. Stored data would be cleared."),e.next=15,this.clear();case 15:return e.abrupt("break",18);case 16:e.next=7;break;case 18:e.next=22;break;case 20:return e.next=22,this.clear();case 22:return e.next=24,this.set({key:this._encryptionCheckKey,value:n});case 24:case"end":return e.stop()}}),e,this)})))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=0,e.next=3,this._getAllRawKeys();case 3:n=e.sent,r=s(n),e.prev=5,r.s();case 7:if((a=r.n()).done){e.next=15;break}return i=a.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(t+=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),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})).filter((function(e){return!n._reservedKeys.includes(e)})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=21;break}if(t.prev=5,a=r.data,!((null==(i=r.metadata)?void 0:i.shards)&&i.shards>1)){t.next=13;break}return t.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return E(o,void 0,void 0,d().mark((function n(){var r,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>0)){n.next=10;break}return r=this._getRawKey(e,".".concat(t)),n.next=4,this._getRaw(r);case 4:if(i=n.sent){n.next=7;break}throw Dl.storeBrokenIntegrity;case 7:return n.abrupt("return",i.data);case 10:return n.abrupt("return",a);case 11:case"end":return n.stop()}}),n,this)})))})));case 10:t.t0=t.sent,t.next=14;break;case 13:t.t0=[a];case 14:return s=t.t0,t.abrupt("return",this.encryption.decrypt(JSON.parse(s.join(""))));case 18:return t.prev=18,t.t1=t.catch(5),t.abrupt("return",null);case 21:return t.abrupt("return",null);case 22:case"end":return t.stop()}}),t,this,[[5,18]])})))}},{key:"set",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._shardify(e),t.next=3,this._setRaw(n);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[],t.next=3,this._setRaw(n.concat.apply(n,v(e.map((function(e){return r._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=12;break}return a=r.metadata,i=this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return o._getRawKey(e,".".concat(t))})),t.next=9,this._removeRaw(i);case 9:return null==(s=ud.get(this.dbname))||s.remove(e),t.abrupt("return",!0);case 12:return t.abrupt("return",!1);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"removeMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=ud.get(this.dbname),r=[],a=s(e),t.prev=3,o=d().mark((function e(){var t,a,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.value,a=u._getRawKey(t,".0"),e.next=4,u._getRaw(a);case 4:(s=e.sent)&&(o=s.metadata,r.push.apply(r,v(u._generateShardPostfixArray(null==o?void 0:o.shards).map((function(e){return u._getRawKey(t,".".concat(e))}))))),null==n||n.remove(t);case 7:case"end":return e.stop()}}),e)})),a.s();case 6:if((i=a.n()).done){t.next=10;break}return t.delegateYield(o(),"t0",8);case 8:t.next=6;break;case 10:t.next=15;break;case 12:t.prev=12,t.t1=t.catch(3),a.e(t.t1);case 15:return t.prev=15,a.f(),t.finish(15);case 18:if(!(r.length>0)){t.next=21;break}return t.next=21,this._removeRaw(r);case 21:return t.abrupt("return",e);case 22:case"end":return t.stop()}}),t,this,[[3,12,15,18]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==(t=ud.get(this.dbname))||t.clearForDatabase(this.dbname);case 2:case"end":return e.stop()}}),e,this)})))}}])}(),xd={},Sd=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:4194304})]);var s=i.delay,o=void 0===s?1:s;return e.delay=o,e.observer={},e}return c(t,e),i(t,[{key:"rawData",get:function(){return xd[this.dbname]},set:function(e){xd[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!xd[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(xd[this.dbname]));case 4:throw Dl.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!xd[this.dbname]){t.next=6;break}return t.next=3,ql(this.delay);case 3:return t.abrupt("return",xd[this.dbname][e]?Object.assign({key:e},xd[this.dbname][e]):null);case 6:throw Dl.storeNotAvailable;case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!xd[this.dbname]){t.next=7;break}return t.next=3,ql(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,i=a.key,o=a.data,u=a.metadata,xd[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Dl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!xd[this.dbname]){t.next=7;break}return t.next=3,ql(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,xd[this.dbname][a]&&delete xd[this.dbname][a]}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Dl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,xd[this.dbname]||(xd[this.dbname]={}),t.next=4,this._resetIfEncryptionChanged();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(t,"set",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=this.observer[e.key])||"function"!=typeof n.set){t.next=5;break}if(!(a=n.set())){t.next=5;break}throw a;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(t,"setMany",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((a=n.n()).done){t.next=12;break}if(i=a.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),n.e(t.t0);case 17:return t.prev=17,n.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),t,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,ql(this.delay);case 4:xd[this.dbname]={};case 5:case"end":return e.stop()}}),e,this)})))}}])}(wd),Td="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(_d||(_d={}));var Id,Nd=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:104857600})]))._storeName=Td,e._state=_d.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 c(t,e),i(t,[{key:"state",get:function(){return this._state}},{key:"isTransactionInactiveError",value:function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}},{key:"_putToObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.put(t);a.addEventListener("success",(function(e){n(e.target.result)})),a.addEventListener("error",(function(){r("Failed to write.")}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_deleteFromObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.delete(t);a.addEventListener("success",(function(){return n(t)})),a.addEventListener("error",(function(e){return r(e.target.error)}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=_d.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Td,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=_d.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=_d.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=_d.UNINITIALIZED,r(e.target.error)}))}else r(Dl.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().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===_d.UNINITIALIZED||t.t0===_d.OPEN?7:t.t0===_d.OPENING||t.t0===_d.CLOSED?8:9;break;case 7:throw Dl.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){n._openJobQueue.push((function(){return t(n._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()}}),t,this)})))}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readonly");case 2:return t=e.sent,e.next=5,new Promise((function(e,n){var r=t.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return n(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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readonly");case 2:return n=t.sent,t.next=5,new Promise((function(t,r){var a=n.get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return r(e.target.error)}))}));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._putToObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._putToObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._deleteFromObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._deleteFromObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{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,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(t="undefined"!=typeof window?window:null)?void 0:t.indexedDB)||(null==t?void 0:t.mozIndexedDB)||(null==t?void 0:t.webkitIndexedDB)||(null==t?void 0:t.msIndexedDB))){e.next=16;break}if(this._indexedDb=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB,!this._window||!pd()){e.next=13;break}if(!(pd()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!t.PointerEvent&&!t.MSPointerEvent){e.next=7;break}throw Dl.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(n._indexedDb)try{var r=n._indexedDb.open("_testMozilla");r.onerror=function(){return t(Dl.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),n._indexedDb){var a=n._indexedDb.deleteDatabase("_testMozilla");a.onerror=function(){return e()},a.onsuccess=function(){return e()}}else t(Dl.storeNotAvailable)}}catch(e){t(Dl.storeNotAvailableInPrivateBrowsing)}else t(Dl.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Dl.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,d().mark((function t(){return d().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:return t.next=7,this._resetIfEncryptionChanged();case 7:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,this._getObjectStore("readwrite");case 4:return t=e.sent,e.next=7,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))}}])}(wd),Ad=function(e){function t(e){var a;r(this,t);var i=e.AsyncStorage,s=e.itemSizeLimit,o=void 0===s?2097152:s,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof Ys))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}if(t instanceof Ws)switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof Ys&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}])}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Rd||(Rd={}));var Fd,qd=function(e){switch(e){case Rd.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Rd.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Hd=Object.assign(Object.assign({},Vo),{scheduledAt:void 0}),Gd=Object.assign(Object.assign({},Ho),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),jd="UnsentMessage",Vd={},zd=function(e){function t(e){var a;return r(this,t),(a=n(this,t,[e]))._mutex=new gd("unsendmessagecache.lock"),Vd[e]=a,a}return c(t,e),i(t,[{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(jd);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 oo?(e.messageParams&&(n.messageParams=jo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},jo(t)),{scheduledAt:t.scheduledAt})))):e instanceof fo?(e.messageParams&&(n.messageParams=Zo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},Zo(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof uo&&e.messageParams&&(n.messageParams=function(e){return pe({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)}),nh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(i=nh.of(this._iid),s=this._deserialize(e),!e.messageParams){a.next=32;break}if(!(s instanceof oo)){a.next=8;break}o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),a.next=32;break;case 8:if(!(s instanceof fo)){a.next=26;break}if(!(u=e.messageParams).fileKey||"string"!=typeof u.fileKey||!Yo(null!==(t=u.fileType)&&void 0!==t?t:"")){a.next=23;break}return a.next=13,this.collection.getBlob(u.fileKey);case 13:if(a.t1=n=a.sent,a.t0=null!==a.t1,!a.t0){a.next=17;break}a.t0=void 0!==n;case 17:if(!a.t0){a.next=21;break}a.t2=n,a.next=22;break;case 21:a.t2=void 0;case 22:u.file=a.t2;case 23:s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(u,s),a.next=32;break;case 26:if(!(s instanceof uo)){a.next=32;break}if(!(c=e.messageParams)||!c.fileInfoList){a.next=32;break}return s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(c,s),a.next=32,Promise.all(s.messageParams.fileInfoList.map((function(e){return E(f,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)||!Yo(null!==(a=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==a?a:"")){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()}}),t,this)})))})));case 32:if(!(s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){a.next=54;break}if(!(s instanceof oo)){a.next=38;break}l=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(l,s),a.next=54;break;case 38:if(!(s instanceof fo)){a.next=54;break}if(!(h=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof h.fileKey||"string"!=typeof h.fileType||!Yo(h.fileType)){a.next=53;break}return a.next=43,this.collection.getBlob(h.fileKey);case 43:if(a.t4=r=a.sent,a.t3=null!==a.t4,!a.t3){a.next=47;break}a.t3=void 0!==r;case 47:if(!a.t3){a.next=51;break}a.t5=r,a.next=52;break;case 51:a.t5=void 0;case 52:h.file=a.t5;case 53:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(h,s);case 54:return a.abrupt("return",s);case 55:case"end":return a.stop()}}),a,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new Pd:n,a=e.order,i=void 0===a?Rd.CHANNEL_LATEST:a,s=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return E(this,void 0,void 0,d().mark((function e(){var n,a,o,l,h,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=qd(i),a={"/where":function(e){return!!(i!==Rd.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(f._deserialize(e))}},t&&(a.channelUrl=t),s&&(a.sendingStatus=s),o={where:a,index:n,backward:u},e.next=8,this.collection.query(o);case 8:return l=e.sent,e.next=11,l.fetch({});case 11:return h=e.sent,e.abrupt("return",Promise.all(h.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Pd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({filter:t,order:Rd.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof fo||e instanceof uo)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return n=this._serialize(e),t.next=10,this.collection.upsertOne(n);case 10:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:n=t.sent;case 5:if(!(n.length>0)){t.next=9;break}return n.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(n);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof fo)){t.next=19;break}if(!e.messageParams){t.next=9;break}if(!(n=e.messageParams).file||!Wo(n.file)){t.next=9;break}return t.next=6,this.collection.saveBlob(n.file,e.reqId);case 6:r=t.sent,n.fileKey=r,n.fileType=Bo.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){t.next=17;break}if(!(a=e.scheduledInfo.scheduledMessageParams).file||!Wo(a.file)){t.next=17;break}return t.next=14,this.collection.saveBlob(a.file,e.reqId);case 14:i=t.sent,a.fileKey=i,a.fileType=Bo.BLOB;case 17:t.next=24;break;case 19:if(!(e instanceof uo)){t.next=24;break}if(!((s=e.messageParams)&&s.fileInfoList&&Array.isArray(s.fileInfoList))){t.next=24;break}return t.next=24,Promise.all(s.fileInfoList.map((function(t,n){return E(o,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!t.file||!Wo(t.file)){r.next=7;break}return r.next=3,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n));case 3:a=r.sent,t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=a,t._uploadedMetaData.fileType=Bo.BLOB;case 7:case"end":return r.stop()}}),r,this)})))})));case 24:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Vd[e]&&!n||(Vd[e]=new t(e)),Vd[e]}}])}(Ya),Bd={},Kd=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Bd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return es.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"_unsentMessageCache",get:function(){return zd.of(this._iid)}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ai(!!e).throw(A.databaseError),e.collection(Zc)}},{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)}),nh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new Pd:i,o=e.order,u=void 0===o?Rd.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,h=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,d().mark((function e(){var r,i,o,c,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r=qd(u),i={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Rd.CHANNEL_LATEST:if(_&&e.createdAt!==n)return!1;if(l){if(g&&e.createdAtn||!g&&e.createdAt>=n)return!1;break;case Rd.NEWEST_CHILD_MESSAGE:if(!h||0===e.parentMessageId||e.parentMessageId!==h)return!1}return!(p&&!e._poll)&&s.match(f._deserialize(e))}},index:r,backward:l},e.next=5,this.collection.query(i);case 5:return o=e.sent,e.next=8,o.fetch({limit:null!=a?a:void 0});case 8:return c=e.sent,e.abrupt("return",Promise.all(c.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}))));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Pd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:Rd.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=30;break}return n.next=3,this.saveBlobs(e);case 3:r=s(e),n.prev=4,r.s();case 6:if((a=r.n()).done){n.next=15;break}if(i=a.value,!(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)){n.next=13;break}return n.next=11,this.get(i.messageId);case 11:(null==(o=n.sent)?void 0:o.threadInfo)&&i.threadInfo._updateFrom(o.threadInfo);case 13:n.next=6;break;case 15:n.next=20;break;case 17:n.prev=17,n.t0=n.catch(4),r.e(n.t0);case 20:return n.prev=20,r.f(),n.finish(20);case 23:return u=e.map((function(e){return c._serialize(e)})),n.next=26,this.collection.upsertMany(u);case 26:return n.next=28,this.upsertChildMessages(e);case 28:return n.next=30,this._unsentMessageCache.upsertChildMessages(e);case 30:case"end":return n.stop()}}),n,this,[[4,17,20,23]])})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!((null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)&&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()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove("".concat(a));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:qd(Rd.CHANNEL_LATEST)});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:qd(Rd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=qd(Rd.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof fo&&e.messageParams)){t.next=7;break}if(!(n=e.messageParams).file||!Wo(n.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(n.file,e.reqId);case 5:r=t.sent,n.fileKey=r;case 7:case"end":return t.stop()}}),t,this)})))})));case 2:case"end":return t.stop()}}),t)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=0,r=this._cacheContext.preference,t.next=4,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return a=t.sent,t.next=7,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return s=t.sent,t.next=13,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return o=t.sent,a&&(n+=JSON.stringify(a).length),i&&(n+=JSON.stringify(i).length),s&&(n+=JSON.stringify(s).length),o&&(n+=JSON.stringify(o).length),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Bd[e]&&!n||(Bd[e]=new t(e)),Bd[e]}}])}(Ya),Qd={},Wd=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Qd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return es.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ai(!!e).throw(A.databaseError),e.collection(Xc)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign({},e.serialize())}},{key:"_deserialize",value:function(e){return nh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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(e);case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new Pd:i,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,h=e.inclusive,f=void 0===h||h;return E(this,void 0,void 0,d().mark((function e(){var r,i,o,c=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(f&&e.createdAtn||!f&&e.createdAt>=n)return!1}return s.match(c._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},e.next=5,this.collection.query(r);case 5:return i=e.sent,e.next=8,i.fetch({limit:null!=a?a:void 0});case 8:return o=e.sent,e.abrupt("return",o.map((function(e){return c._deserialize(e)})));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=4;break}return n=e.map((function(e){return r._serialize(e)})),t.next=4,this.collection.upsertMany(n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"markAsReadByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,messageStatus:eo.SENT,createdAt:{"<":t}}},{set:{messageStatus:eo.READ}});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"markAsReadByMessageIds",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=5;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:eo.SENT}},{set:{messageStatus:eo.READ}});case 3:return r=n.sent,n.abrupt("return",r.length);case 5:return n.abrupt("return",0);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:["channelUrl","-createdAt","-notificationId"]});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:qd(Rd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=["channelUrl","-createdAt","-notificationId"],i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Qd[e]&&!n||(Qd[e]=new t(e)),Qd[e]}}])}(Ya),Yd={},Zd=function(t){function a(t){var i;return r(this,a),(i=n(this,a,[t]))._observers=new Map,i._dispatcherContext=i._dispatcher.on((function(t){return E(i,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,N,A,M,O=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof Os)){n.next=19;break}if(r=t.messages,a=t.source,i=t.isWebSocketEventComing,s=r.filter((function(t){return t instanceof Ws&&t.channelType!==e.ChannelType.OPEN&&t.messageId>0})),o=r.filter((function(t){return t instanceof Ws&&t.channelType!==e.ChannelType.OPEN&&0===t.messageId})),u=r.filter((function(e){return e instanceof co})),!(s.length>0)){n.next=9;break}return n.next=8,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(s);case 2:return e.next=4,this._unsentMessageCache.remove(s.map((function(e){return e instanceof Ys?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e,this)})))}));case 8:i||this._broadcastUpdateEvent(s,a);case 9:if(!(o.length>0)){n.next=13;break}return n.next=12,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.upsert(o);case 2:case"end":return e.stop()}}),e,this)})))}));case 12:i||this._broadcastUpdateEvent(o,a);case 13:if(!(u.length>0)){n.next=17;break}return n.next=16,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._notificationCache.upsert(u);case 2:case"end":return e.stop()}}),e,this)})))}));case 16:i||this._broadcastUpdateEvent(u,a);case 17:n.next=71;break;case 19:if(!(t instanceof Us)){n.next=28;break}return c=t.messageIds,l=t.source,h=t.isWebSocketEventComing,f=c.filter((function(e){return"number"==typeof e})),p=c.filter((function(e){return"string"==typeof e})),n.next=25,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(f.length>0)){e.next=3;break}return e.next=3,this._messageCache.remove(f);case 3:if(!(p.length>0)){e.next=6;break}return e.next=6,this._notificationCache.remove(p);case 6:case"end":return e.stop()}}),e,this)})))}));case 25:h||this._broadcastRemoveEvent(c,l),n.next=71;break;case 28:if(!(t instanceof Ls)){n.next=35;break}return v=t.reqId,_=t.source,n.next=32,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.remove([v]);case 2:case"end":return e.stop()}}),e,this)})))}));case 32:this._broadcastRemoveUnsentEvent(v,_),n.next=71;break;case 35:if(!(t instanceof Ps)){n.next=48;break}if(m=t.polls,g=t.source,!this._cacheContext.localCacheEnabled){n.next=45;break}return y=m.map((function(e){return e.messageId})),n.next=41,Promise.all(y.map((function(e){return O._messageCache.get(e)})));case 41:return k=n.sent.filter((function(e){return e})),k.length>0&&m.forEach((function(e){var t=k.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=45,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(k);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 45:this._broadcastPollChangeLogEvent(m,g),n.next=71;break;case 48:if(!(t instanceof Fs)){n.next=59;break}return b=t.event,C=t.source,n.next=52,this._messageCache.get(b.messageId);case 52:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollUpdateEvent(b))){n.next=56;break}return n.next=56,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 56:this._broadcastPollUpdateEvent(b,C),n.next=71;break;case 59:if(!(t instanceof qs)){n.next=70;break}return x=t.event,S=t.source,n.next=63,this._messageCache.get(x.messageId);case 63:if(!((T=n.sent)&&T.isUserMessage()&&T.poll&&T.poll.applyPollVoteEvent(x))){n.next=67;break}return n.next=67,fi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([T]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 67:this._broadcastPollVoteEvent(x,S),n.next=71;break;case 70:t instanceof Ds?(I=t.event,N=t.source,I.messageId>0&&this._broadcastReactionUpdateEvent(I,N)):t instanceof Rs&&(A=t.event,M=t.source,this._broadcastThreadUpdateEvent(A,M));case 71:case"end":return n.stop()}}),n,this)})))})),i}return c(a,t),i(a,[{key:"_cacheContext",get:function(){return es.of(this._iid).cacheContext}},{key:"_dispatcher",get:function(){return es.of(this._iid).dispatcher}},{key:"_messageCache",get:function(){return Kd.of(this._iid)}},{key:"_unsentMessageCache",get:function(){return zd.of(this._iid)}},{key:"_notificationCache",get:function(){return Wd.of(this._iid)}},{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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=s(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=s(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=s(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=s(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=s(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:"_broadcastReactionUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastThreadUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(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()}}],[{key:"of",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Yd[e]&&!n||(Yd[e]&&(null===(t=Yd[e]._dispatcherContext)||void 0===t||t.close()),Yd[e]=new a(e)),Yd[e]}}])}(Ya),Xd=function(e){function t(e){var a;r(this,t);var i=e.reverse,s=void 0!==i&&i,o=e.limit,u=void 0===o?20:o,c=e.keys,l=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ue),a.params=pe({token:l,limit:u,reverse:s,order:oe.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),a}return c(t,e),i(t)}(je),Jd=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.next,o=a.has_more,u=void 0!==o&&o,c=a.templates;return i.nextToken=s,i.hasMore=u,i.templates=c.map((function(e){return{template:JSON.stringify(e)}})),i}return c(t,e),i(t)}(Ve),$d=function(e){function t(e){var a;r(this,t);var i=e.key;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ue,"/").concat(i),a}return c(t,e),i(t)}(je),eh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).template=JSON.stringify(a),i}return c(t,e),i(t)}(Ve),th={},nh=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.requestQueue,o=n.onlineDetector,u=n.cacheContext;r(this,e),this._iid=t,this._sdkState=a,this._requestQueue=s,this._dispatcher=i,this._cacheContext=u,Kd.of(t),zd.of(t),Zd.of(t),this.fileMessageQueue=new ko(t,{sdkState:a,dispatcher:i,requestQueue:s,onlineDetector:o,cacheContext:u}),th[t]=this}),[{key:"buildMessageFromSerializedData",value:function(t){var n=ri(t);if(n.notificationId)return new co(this._iid,co.payloadify(n));switch(n.messageType){case e.MessageType.USER:return new oo(this._iid,oo.payloadify(n));case e.MessageType.FILE:return uo._isMultipleFilesMessageSerializedData(n)?new uo(this._iid,uo.payloadify(n)):new fo(this._iid,fo.payloadify(n));case e.MessageType.ADMIN:return new Js(this._iid,Js.payloadify(n))}throw A.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return pe(ve({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 pe(ve({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){var n=this;return pe({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.map((function(e){return new po(n._iid,e)}))})}},{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=ri(e);return new ps(this._iid,ps.payloadify(t))}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Io(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(No),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Do(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Ro),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessagesByMessageId",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Ao(Object.assign(Object.assign({channelType:n,channelUrl:t,token:String(r)},wo),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Mo),c=u.messages,this._dispatcher.dispatch(new Os({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Ao(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},wo),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Mo),c=u.messages,this._dispatcher.dispatch(new Os({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0;return E(this,void 0,void 0,d().mark((function e(){var u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new Ao(Object.assign(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},wo),a),{checkingHasNext:s,checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.as(Mo),h=l.messages,f=l.isContinuousMessages,p=l.hasNext,this._dispatcher.dispatch(new Os({messages:h,source:i})),e.abrupt("return",{messages:h,isContinuousMessages:f,hasNext:p});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_THREADED_MESSAGE;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=new Ao(Object.assign(Object.assign(Object.assign({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:n},Zs),r),{replyType:e.ReplyType.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),i.next=3,this._requestQueue.send(s);case 3:return o=i.sent,u=o.as(Mo),c=u.messages,(l=c.slice(1)).forEach((function(e){e.parentMessage=t})),this._dispatcher.dispatch(new Os({messages:l,source:a})),i.abrupt("return",{parentMessage:c[0],threadedMessages:l});case 9:case"end":return i.stop()}}),i,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new Xd(Object.assign({token:e},t)),n.next=3,this._requestQueue.send(r);case 3:return a=n.sent,i=a.as(Jd),s=i.hasMore,o=i.nextToken,u=i.templates,n.abrupt("return",{hasMore:s,token:o,templates:u});case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new $d({key:e}),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(eh),i=a.template,t.abrupt("return",{template:i});case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageChangelogs",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Oo(pe(ve(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null},So),a)))),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Uo),c=u.updatedMessages,l=u.deletedMessagesInfo,h=u.hasMore,f=u.nextToken,p=l.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new Os({messages:c,source:i})),p.length>0&&this._dispatcher.dispatch(new Us({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:c,deletedMessageIds:p,hasMore:h,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return th[e]}}])}(),rh=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e])).targetMessageId=0;var s=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return s&&D("object",s)&&D("number",o)&&D("string",u)&&D("string",c)&&(i.threadInfo=new is(e,s),i.targetMessageId=o,i.channelUrl=u,i.channelType=c),i}return c(t,e),i(t)}(Ya),ah={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},ih=function(t){return D("string",t.channelUrl)&&R(e.ChannelType,t.channelType)&&D("number",t.messageId)&&D("boolean",t.includeReactions,!0)&&D("boolean",t.includeMetaArray,!0)&&D("boolean",t.includeParentMessageInfo,!0)&&D("boolean",t.includeThreadInfo,!0)},sh=function(e){function t(e){var a,i=e.channelCustomType,s=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,d=e.order,h=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(xe,"/messages"),a.params={custom_type:i,query:s,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:h,message_ts_to:f,sort_field:d,advanced_query:p,target_fields:v,after:_},a}return c(t,e),i(t)}(je),oh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).messages=a.results.map((function(t){return ho(e,t)})),i.hasNext=a.has_next,i.nextToken=a.end_cursor,i.totalCount=a.total_count,i}return c(t,e),i(t)}(Ve);e.MessageSearchOrder=void 0,(Fd=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",Fd.TIMESTAMP="ts";var uh,ch,lh,dh=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;return r(this,a),(s=n(this,a,[t,i])).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=i.keyword,s.reverse=null!==(o=i.reverse)&&void 0!==o&&o,s.exactMatch=null!==(u=i.exactMatch)&&void 0!==u&&u,s.channelUrl=null!==(c=i.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=i.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(d=i.messageTimestampFrom)&&void 0!==d?d:null,s.messageTimestampTo=null!==(h=i.messageTimestampTo)&&void 0!==h?h:null,s.order=null!==(f=i.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=i.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=i.targetFields)&&void 0!==v?v:null,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.keyword)&&this.keyword.length>0&&D("boolean",this.reverse)&&D("boolean",this.exactMatch)&&D("string",this.channelUrl)&&D("string",this.channelCustomType)&&(D("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(D("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&R(e.MessageSearchOrder,this.order)&&D("boolean",this.advancedQuery)&&P("string",this.targetFields,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new sh(ve(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(oh),s=i.messages,o=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,e.abrupt("return",s);case 15:return e.abrupt("return",[]);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}])}(uu),hh=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/messages/parent_thread_message"),a.params=pe(ve({limit:o,token:u})),a}return c(t,e),i(t)}(je),fh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).token=a.next,i.messages=a.messages.map((function(t){return ho(e,t)})),i}return c(t,e),i(t)}(Ve),ph=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s]))._edge="",o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new hh({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(fh),s=i.messages,o=i.token,this._edge=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(cu),vh={channelUrl:"",scheduledMessageId:0},_h=function(e){return D("string",e.channelUrl)&&""!==e.channelUrl&&D("number",e.scheduledMessageId)&&e.scheduledMessageId>0},mh={reverse:!1,limit:20},gh=function(e){return D("boolean",e.reverse,!0)&&D("number",e.limit,!0)&&P("string",e.keys,!0)},yh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="message",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new nh(e,{sdkState:r,dispatcher:a,requestQueue:s,onlineDetector:u,cacheContext:c})}},{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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},ah),e),ai(ih(n)).throw(A.invalidParameters),t.next=4,this._manager.getMessage(n);case 4:if(!((r=t.sent)instanceof Ws||r instanceof co||null===r)){t.next=7;break}return t.abrupt("return",r);case 7:throw"Unknown message type is given.";case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},vh),e),ai(_h(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},mh),t),ai(D("string",e,!0)&&gh(r)).throw(A.invalidParameters),n.abrupt("return",this._manager.getMessageTemplatesByToken(e,r));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getMessageTemplate(e));case 2:case"end":return t.stop()}}),t,this)})))}}])}(ts),Eh=i((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})),kh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="poll",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new Wc(e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c})}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Gc),e),ai(jc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.create(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Bc),e),ai(Kc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.get(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Vc),e),ai(zc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getOption(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}])}(ts),bh={profileImage:void 0,profileUrl:void 0,nickname:void 0},Ch=function(e){return H(e.profileImage,!0)&&D("string",e.profileUrl,!0)&&D("string",e.nickname,!0)};e.GroupChannelListOrder=void 0,(uh=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",uh.CHRONOLOGICAL="chronological",uh.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",uh.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(ch=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",ch.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",ch.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(lh=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",lh.SCHEDULED_AT="scheduled_at";var wh,xh=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"]}},Sh=function(t){return{v2:function(){return E(void 0,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.commitSchema([{collectionName:Yc,keyName:"url",index:[xh(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),xh(e.GroupChannelListOrder.CHRONOLOGICAL),xh(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Zc,keyName:"messageId",index:[qd(Rd.CHANNEL_LATEST),qd(Rd.NEWEST_CHILD_MESSAGE)]},{collectionName:jd,keyName:"reqId",index:[qd(Rd.CHANNEL_LATEST),qd(Rd.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))},v3:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:"FeedChannel",keyName:"url",index:[["-lastMessageUpdatedAt","-createdAt","syncIndex"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))},v4:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:Xc,keyName:"notificationId",index:[["channelUrl","-createdAt","-notificationId"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}},Th=function(t){return function(n,r){return E(void 0,void 0,void 0,d().mark((function a(){var i,s,o,u,c;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=n,a.next=1===a.t0||2===a.t0||3===a.t0||4===a.t0?3:5===a.t0?5:6===a.t0?9:26;break;case 3:return r(),a.abrupt("break",27);case 5:return a.next=7,t.reset();case 7:return r(),a.abrupt("break",27);case 9:return a.prev=9,i=Sh(t),s=i.v2,o=i.v3,u=i.v4,a.next=13,s();case 13:return a.next=15,o();case 15:return a.next=17,u();case 17:return c=t.collection(Zc),a.next=20,c.removeIf({where:{channelType:e.ChannelType.OPEN}});case 20:a.next=24;break;case 22:a.prev=22,a.t1=a.catch(9);case 24:return r(),a.abrupt("break",27);case 26:r();case 27:case"end":return a.stop()}}),a,null,[[9,22]])})))}},Ih=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Nh=function(e){function t(e){var a,i=e.getVisibilityState,s=void 0===i?Ih:i,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,d=e.pauseCheckDelay,h=void 0===d?3e4:d;return r(this,t),(a=n(this,t))._pauseCheckDelay=3e4,a._currentState="visible",a._getVisibilityState=s,a._pauseCheckDelay=h,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(a),a}return c(t,e),i(t,[{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})}}])}(de),Ah=function(){return i((function e(t){var n=this,a=t.logger,i=t.connectionDelegate,s=void 0===i?null:i;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,s&&(this.connectionDelegate=s)}),[{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,d().mark((function e(){return d().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:_e.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}])}(),Mh=function(e){function t(e){var a,i=e.message;return r(this,t),(a=n(this,t)).message=i,a}return c(t,e),i(t)}(fe),Oh={},Uh=function(){return i((function e(t,n){var a=this,i=n.localCacheEnabled,s=n.enableAutoResend,o=n.dispatcher,u=n.sdkState,c=n.logger;r(this,e),this._iid=t,Oh[t]=this,this._localCacheEnabled=i,this._enableAutoResend=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=o,this._logger=c,this._sdkState=u,this._localCacheEnabled&&o.on((function(e){if(e instanceof La)switch(e.stateType){case Aa.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case Aa.INTERNAL_DISCONNECTED:case Aa.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}),[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._enableAutoResend){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this._fetchAllCachedPendingMessages();case 4:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)0===(i=a.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=e.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new Os({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){r.e(e)}finally{r.f()}case 7:case"end":return t.stop()}}),t,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)i=a.value,this._enableAutoResend&&i.errorCode&&q(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,this._enableAutoResend&&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 Os({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return t.stop()}}),t,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&this._enableAutoResend&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!q(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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=zd.of(this._iid),(r=new Pd).replyType=e.ReplyType.ALL,t.next=5,n.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0,filter:r});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&this._enableAutoResend&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),t=this._autoResendQueue[0],this._dispatcher.dispatch(new Mh({message:t})),this._logger.debug("processing auto-resend for message request id: ",t.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Oh[e]}}])}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(wh||(wh={}));var Dh,Rh=function(){return i((function e(t){r(this,e),this.category=t.cat,this.data=t.data}),null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new si(e,r),blockee:new si(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 si(e,t)})):[]}}}])}(),Lh=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Ph=function(e){function t(e,a){var i,s=a.userId;return r(this,t),(i=n(this,t))._iid=e,i.userId=s,i}return c(t,e),i(t)}(fe),Fh=function(e){function t(){return r(this,t),n(this,t)}return c(t,e),i(t)}(fe),qh=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"USEV",i])).event=new Rh(i),s}return c(t,e),i(t)}(Ke),Hh=function(e){function t(e){var a,i=e.userId,s=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i)),a.params=pe(ve({nickname:s,profile_url:o,profile_file:u,preferred_languages:c})),a}return c(t,e),i(t)}(je),Gh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).user=new si(e,Object.assign({},a)),i}return c(t,e),i(t)}(Ve),jh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a.params=pe({apns_device_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(je),Vh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a.params=pe({gcm_reg_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(je),zh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),Bh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),Kh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a}return c(t,e),i(t)}(je),Qh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a}return c(t,e),i(t)}(je),Wh=function(e){function t(e){var a,i=e.userId,s=e.type,o=e.token,u=e.ts;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/").concat(encodeURIComponent(s),"/device_tokens"),a.params={created_ts:u,token:o},a}return c(t,e),i(t)}(je),Yh=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).pushTokens={type:i.type?e.PushTokenType[i.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:i.device_tokens,hasMore:i.has_more,token:i.token},s}return c(a,t),i(a)}(Ve),Zh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a}return c(t,e),i(t)}(je),Xh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(Ve),Jh=function(e){function t(e){var a,i=e.userId,s=e.willAutoAccept;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a.params={auto_accept:s},a}return c(t,e),i(t)}(je),$h=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(Ve),ef=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(je),tf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(Ve),nf=function(e){function t(e){var a,i=e.userId,s=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,d=e.timezone;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={do_not_disturb:s,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:d},a}return c(t,e),i(t)}(je),rf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(Ve),af=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(je),sf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(Ve),of=function(e){function t(e){var a,i=e.userId,s=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={snooze_enabled:s,snooze_start_ts:o,snooze_end_ts:u},a}return c(t,e),i(t)}(je),uf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(Ve),cf=function(e){function t(e){var a,i=e.userId,s=e.blockedUserId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block"),a.params={target_id:s},a}return c(t,e),i(t)}(je),lf=function(e){function t(e){var a,i=e.userId,s=e.unblockedUserId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),df=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(je),hf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(Ve),ff=function(e){function t(e){var a,i=e.userId,s=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={push_trigger_option:s},a}return c(t,e),i(t)}(je),pf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(Ve),vf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a}return c(t,e),i(t)}(je),_f=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(Ve),mf=function(e){function t(e){var a,i=e.userId,s=e.templateName;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a.params={name:s},a}return c(t,e),i(t)}(je),gf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(Ve),yf=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends/changelogs"),a.params={token:s},a}return c(t,e),i(t)}(je),Ef=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).changelogs={addedUsers:a.added.map((function(t){return new si(e,t)})),updatedUsers:a.updated.map((function(t){return new si(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},i}return c(t,e),i(t)}(Ve),kf=function(e){function t(e){var a,i=e.userId,s=e.discoveries;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discoveries:s.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return c(t,e),i(t)}(je),bf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).friendDiscoveryRequestId=a.friend_discovery_request_id,i}return c(t,e),i(t)}(Ve),Cf=function(e){function t(e){var a,i=e.userId,s=e.discoveryKeys;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discovery_keys:s},a}return c(t,e),i(t)}(je),wf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(je),xf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new si(e,t)})),i}return c(t,e),i(t)}(Ve),Sf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(je),Tf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={},a}return c(t,e),i(t)}(je),If=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).allowFriendDiscovery=a.allow_friend_discovery,i}return c(t,e),i(t)}(Ve),Nf=function(e){function t(e){var a,i=e.userId,s=e.allowFriendDiscovery;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={allow_friend_discovery:s},a}return c(t,e),i(t)}(je),Af=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path=Ie,e}return c(t,e),i(t)}(je),Mf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiContainer=new gl(a),i}return c(t,e),i(t)}(Ve),Of=function(e){function t(e){var a,i=e.categoryId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ie,"/").concat(i),a}return c(t,e),i(t)}(je),Uf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiCategory=new ml(a),i}return c(t,e),i(t)}(Ve),Df=function(e){function t(e){var a,i=e.key;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Te,"/").concat(i),a}return c(t,e),i(t)}(je),Rf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emoji=new _l(a),i}return c(t,e),i(t)}(Ve),Lf=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path="".concat(Me),e}return c(t,e),i(t)}(je),Pf=function(e){function t(e,a){var i,s;r(this,t);var o=null!=a?a:{};return(i=n(this,t,[e,a])).uikitConfiguration={string:JSON.stringify(o),json:o},i.updatedAt=null!==(s=null==a?void 0:a.updated_at)&&void 0!==s?s:0,i}return c(t,e),i(t)}(Ve);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(Dh||(Dh={}));var Ff,qf=function(e){function t(e){var a,i=e.deviceToken,s=e.pushTrackingId,o=e.messageId,u=e.allowedPushNotification,c=e.channelKey,l=e.templateKey,d=e.eventType,h=e.notificationEventDeadline;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=De,a.params=pe({device_token:i,push_tracking_id:s,message_id:o,allowed_push_notification:u,channel_key:c,template_key:l,event_type:d,notification_event_deadline:h}),a}return c(t,e),i(t)}(je);var Hf,Gf=function(){function t(e,n,a){var i=this;r(this,t),this._storeInitialized=!1,this._iid=e,this.options=n;var s=es.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,l=s.sessionManager,h=s.requestQueue,f=s.logger,p=s.userEventHandlers,v=s.appStateToggleEnabled;this._onlineDetector=new Ah({logger:f,connectionDelegate:{reconnect:function(){return E(i,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=es.of(e),r=n.sdkState,a=n.connectionManager,(i=n.sessionManager).session.hasSession){t.next=14;break}return t.prev=2,t.next=5,a.connect(i.session.authToken);case 5:t.next=12;break;case 7:if(t.prev=7,t.t0=t.catch(2),!N(t.t0)){t.next=11;break}throw t.t0;case 11:f.debug("connect failed by reconnect event = ",t.t0);case 12:t.next=25;break;case 14:if("foreground"!==r.appState){t.next=25;break}return t.prev=15,t.next=18,a.resetAndReconnect();case 18:t.next=25;break;case 20:if(t.prev=20,t.t1=t.catch(15),!N(t.t1)){t.next=24;break}throw t.t1;case 24:f.debug("resetAndReconnect failed by reconnect event = ",t.t1);case 25:c.dispatch(new Lh);case 26:case"end":return t.stop()}}),t,null,[[2,7],[15,20]])})))},disconnect:function(){fi((function(){return E(i,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(e),r=n.connectionManager,t.next=3,r.disconnect();case 3:case"end":return t.stop()}}),t)})))}))}}});var _=new Uh(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,dispatcher:c,sdkState:o,logger:f});a.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:l,requestQueue:h,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new Nh({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()})),c.on((function(t){var n;if(t instanceof La){if(t.stateType===Aa.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof Ke){if("USEV"===t.code){var r=t.as(qh).event;if(r.category===wh.FRIEND_DISCOVERED){var a=Rh.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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(t instanceof Oa){var s=es.of(i._iid).subscribedUnreadMessageCount,c=!1,l=t.ts;"number"==typeof l&&l>s.ts&&(s.all!==t.all&&(c=!0),s.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){s.customTypes[e]!==t.customTypes[e]&&(c=!0),s.customTypes[e]=t.customTypes[e]})),c=c&&s.ts>0,s.ts=l),c&&hi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:s.all,feedChannelCount:s.feed,customTypeUnreadCount:s.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else t instanceof oi?(u.preference.set(i._getUserProfileCacheKey(o.userId),ui.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(Ga(i.appId),{value:!0})):t instanceof Be&&t.error&&t.error.isSessionInvalidatedError&&(f.debug("session revoked."),i._internalDisconnect(t.error))}))}return i(t,[{key:"appId",get:function(){return es.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=es.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=es.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!es.of(this._iid).debugMode}},{key:"logLevel",get:function(){return es.of(this._iid).logger.level},set:function(e){es.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return es.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=es.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return es.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=es.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=es.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=es.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:"_getNestDBVersion",value:function(){return 7}},{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:"_internalDisconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.connectionManager,a=n.sdkState,i=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),t.next=6,r.logout(e);case 6:return t.next=8,this.clearCachedData();case 8:a.appState="foreground";case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getMemoryStoreForDebugging",value:function(){var e=es.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Sd?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=es.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)}},{key:"addSendbirdExtensions",value:function(e,t,n){var r=es.of(this._iid),a=r.logger,i=r.sdkState,s=new RegExp("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");if(0===e.length)return a.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!s.test(e.version)})))return a.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(var o=0,u=Object.entries(n);o2&&void 0!==arguments[2]?arguments[2]:{};return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(ai(D("string",e)&&D("string",t,!0)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,s=a.cacheContext,o=a.connectionManager,u=n.errorForOtherUser,!i.userId||i.userId===e){r.next=10;break}if(u){r.next=9;break}return r.next=7,o.logout();case 7:r.next=10;break;case 9:throw u;case 10:return r.prev=10,r.next=13,this.initializeCache(e);case 13:c=es.of(this._iid),c.dispatcher.dispatch(new Fh),r.next=22;break;case 17:r.prev=17,r.t0=r.catch(10),l=es.of(this._iid),h=l.logger,s.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 22:case"end":return r.stop()}}),r,this,[[10,17]])})))}},{key:"authenticateFeed",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.authenticate(e,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=es.of(this._iid),i=a.sessionManager,s=a.connectionManager,r.next=3,this._ready(e,t,{errorForOtherUser:s.isConnected?A.alreadyConnectedAsAnotherUser:void 0});case 3:if(null===(n=i.session.services)||void 0===n?void 0:n.includes(K.CHAT)){r.next=7;break}return t||i.handler||(o=new El,this.setSessionHandler(o)),r.next=7,i.authenticate(e,t);case 7:return r.abrupt("return",this.currentUser);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"connect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._ready(e,t);case 2:return n.prev=2,r=es.of(this._iid),a=r.connectionManager,n.next=6,a.connect(t);case 6:return n.prev=6,this._onlineDetector.start(),this._appStateChangeDetector.start(),n.finish(6);case 10:return n.abrupt("return",this.currentUser);case 11:case"end":return n.stop()}}),n,this,[[2,,6,10]])})))}},{key:"reconnect",value:function(){var e=es.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._internalDisconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.connectionManager,r=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),e.next=6,n.disconnectWebSocket(!0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=es.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().catch((function(e){r.debug("setBackgroundState error = ",e)})))}},{key:"setForegroundState",value:function(){var e=es.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,a=e.logger;"background"===n.appState&&(n.appState="foreground",a.debug("going foreground state"),t.resetAndReconnect().catch((function(e){a.debug("setForgroundState error = ",e)})),r.dispatch(new Lh))}},{key:"setSessionHandler",value:function(e){ai(e instanceof El).throw(A.invalidParameters),es.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){ai(D("string",e)&&t instanceof kl).throw(A.invalidParameters),es.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){es.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){es.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){ai(D("string",e)&&t instanceof yl).throw(A.invalidParameters),es.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){es.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){es.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new wl(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Tl(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Al(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new dh(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new el(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new rl(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=ri(e);return new si(this._iid,si.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Object.assign(Object.assign({},bh),e),ai(Ch(n)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Hh(Object.assign({userId:a.userId},n)),t.next=7,i.send(s);case 7:return o=t.sent,u=o.as(Gh),c=u.user,this.currentUser&&(n.nickname&&(this.currentUser.nickname=c.nickname),(n.profileUrl||n.profileImage)&&(this.currentUser.plainProfileUrl=c.profileUrl)),t.abrupt("return",c);case 13:throw A.connectionRequired;case 14:case"end":return t.stop()}}),t,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ai(P("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Hh({userId:r.userId,preferredLanguages:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Gh),u=o.user,this.currentUser&&(this.currentUser.preferredLanguages=u.preferredLanguages),t.abrupt("return",u);case 12:throw A.connectionRequired;case 13:case"end":return t.stop()}}),t,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ai(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ai(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.ANDROID,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=es.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.FCM,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new Vh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,fi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.FCM,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._fcmPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._fcmPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=es.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Bh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,fi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.FCM,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=es.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Qh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,fi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.FCM),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ai(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ai(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.IOS,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=es.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.APNS,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new jh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,fi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.APNS,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._apnsPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._apnsPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ai(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=es.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new zh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,fi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.APNS,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._apnsPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._apnsPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=es.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Kh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,fi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.APNS),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markPushNotificationAsDelivered",value:function(e){var t,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k,b;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=es.of(this._iid),i=a.logger,s=a.sessionManager,o=a.requestQueue,u=a.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=Dh.DELIVERED,l=u.parseData(e),h=l.pushTrackingId,f=l.sessionTopics,p=l.sessionKey,v=l.messageId,_=l.channelKey,m=l.templateKey,g=l.notificationEventDeadline,p){r.next=7;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 7:if(f.includes(ji.PUSH_ACKNOWLEDGEMENT)){r.next=10;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 10:if(!u.isAcked(h,c)){r.next=13;break}return i.info("already delivered push notification:",h),r.abrupt("return");case 13:return y=Boolean(_),E=n&&y,k=null===(t=s.deviceTokens[0])||void 0===t?void 0:t.token,b=new qf({deviceToken:null!=k?k:"",pushTrackingId:h,eventType:c,messageId:v,channelKey:_,templateKey:m,notificationEventDeadline:g,allowedPushNotification:E}),p&&(b.headers["Session-Key"]=p),r.prev=18,r.next=21,o.send(b);case 21:u.markAsAcked(h,c),r.next=28;break;case 24:throw r.prev=24,r.t0=r.catch(18),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(h,". error: ").concat(r.t0)),r.t0;case 28:case"end":return r.stop()}}),r,this,[[18,24]])})))}},{key:"markPushNotificationAsClicked",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=es.of(this._iid),a=r.logger,i=r.sessionManager,s=r.requestQueue,o=r.pushNotificationAckManager,a.debug("markPushNotificationAsClicked:",e),u=Dh.CLICKED,c=o.parseData(e),l=c.pushTrackingId,h=c.sessionTopics,f=c.sessionKey,p=c.messageId,v=c.channelKey,_=c.templateKey,m=c.notificationEventDeadline,f){n.next=7;break}throw a.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 7:if(h.includes(ji.PUSH_ACKNOWLEDGEMENT)){n.next=10;break}throw a.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 10:if(!o.isAcked(l,u)){n.next=13;break}return a.info("already clicked push notification:",l),n.abrupt("return");case 13:return g=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,y=new qf({deviceToken:null!=g?g:"",pushTrackingId:l,eventType:u,messageId:p,channelKey:v,templateKey:_,notificationEventDeadline:m}),f&&(y.headers["Session-Key"]=f),n.prev=16,n.next=19,s.send(y);case 19:o.markAsAcked(l,u),n.next=26;break;case 22:throw n.prev=22,n.t0=n.catch(16),a.debug("failed to mark push notification as clicked. push tracking id: ".concat(l,". error: ").concat(n.t0)),n.t0;case 26:case"end":return n.stop()}}),n,this,[[16,22]])})))}},{key:"getChannelInvitationPreference",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Zh({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Xh),o=s.autoAccept,e.abrupt("return",{autoAccept:o});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("boolean",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Jh({userId:r.userId,willAutoAccept:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as($h),u=o.autoAccept,t.abrupt("return",{autoAccept:u});case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getDoNotDisturb",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ef({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(tf),o=s.preference,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return ai(D("boolean",e)&&D("number",t)&&D("number",n)&&D("number",r)&&D("number",a)&&D("string",i)).throw(A.invalidParameters),o=es.of(this._iid),u=o.sdkState,c=o.requestQueue,l=new nf({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:a,timezone:i}),s.next=5,c.send(l);case 5:return h=s.sent,f=h.as(rf),p=f.preference,s.abrupt("return",p);case 8:case"end":return s.stop()}}),s,this)})))}},{key:"getSnoozePeriod",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new af({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(sf),o=s.snoozePeriod,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("boolean",e)&&D("number",t)&&D("number",n)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new of({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),r.next=5,s.send(o);case 5:return u=r.sent,c=u.as(uf),l=c.snoozePeriod,r.abrupt("return",l);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"getMyPushTokensByToken",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p,v,_;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",t)&&R(e.PushTokenType,n)).throw(A.invalidParameters),a=es.of(this._iid),i=a.sdkState,o=a.requestQueue,u=a.sessionManager,c=new Wh({userId:i.userId,type:n,token:t}),r.next=5,o.send(c);case 5:l=r.sent,h=l.as(Yh),f=h.pushTokens,p=s(f.deviceTokens);try{for(p.s();!(v=p.n()).done;)_=v.value,u.setDeviceToken(f.type,_)}catch(e){p.e(e)}finally{p.f()}return r.next=11,u.saveDeviceToken();case 11:return r.abrupt("return",f);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"getPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new df({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(hf).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new ff({userId:a.userId,pushTriggerOption:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(pf).pushTriggerOption);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"getPushTemplate",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new vf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(_f).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.PushTemplate,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new mf({userId:a.userId,templateName:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(gf).name);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"blockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(e instanceof si||D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new cf({userId:r.userId,blockedUserId:e instanceof si?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(e instanceof si||D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new lf({userId:r.userId,unblockedUserId:e instanceof si?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new yf({userId:r.userId,token:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(Ef),u=o.changelogs,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Tf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(If),o=s.allowFriendDiscovery,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("boolean",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Nf({userId:r.userId,allowFriendDiscovery:e}),t.next=5,a.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new kf({userId:r.userId,discoveries:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(bf),u=o.friendDiscoveryRequestId,t.abrupt("return",u);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Cf({userId:r.userId,discoveryKeys:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"addFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new wf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(xf),u=o.users,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(P("string",e)).throw(A.invalidParameters),n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Sf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getAllEmoji",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Af,e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Mf),s=i.emojiContainer,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Of({categoryId:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Uf),o=s.emojiCategory,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getEmoji",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.requestQueue,a=new Df({key:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Rf),o=s.emoji,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getUIKitConfiguration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),ai(t.hasExtension("sb_uikit")).throw(A.notSupportedError),n=t.requestQueue,r=new Lf,e.next=6,n.send(r);case 6:return a=e.sent,i=a.as(Pf),s=i.uikitConfiguration,e.abrupt("return",s);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(n){var r=n.appId,a=n.appVersion,i=n.modules,s=void 0===i?[]:i,o=n.options,u=void 0===o?new j:o,c=n.debugMode,l=void 0!==c&&c,d=n.customApiHost,h=n.customWebSocketHost,f=n.newInstance,p=void 0!==f&&f,_=n.logLevel,m=n.localCacheEnabled,g=void 0!==m&&m,y=n.localCacheConfig,E=void 0===y?new W:y,k=n.localCacheEncryption,b=n.useAsyncStorageStore,C=void 0===b?null:b,w=n.useMMKVStorageStore,x=void 0===w?null:w,S=n.appStateToggleEnabled,T=void 0===S||S;if(!Ff||p){var I="su-".concat(ce()),N=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},A=new Ld;A.level=null!=_?_:e.LogLevel.WARN;var M=new Sd({encryption:N});l||(at()?x?M=new Md({MMKV:x,encryption:N}):C&&(M=new Ad({AsyncStorage:C,encryption:N}),A.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):M=new Nd({encryption:N})),new es(I,{appId:r,appVersion:a,options:u,apiHost:null!=d?d:"https://api-".concat(r,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(r,".sendbird.com"),store:M,encryption:N,logger:A,localCacheEnabled:g,localCacheConfig:E,debugMode:l,appStateToggleEnabled:T});var O=[new yh,new kh],U=new t(I,u,[].concat(v(s),O));return Ff||(Ff=U),U}return Ff}},{key:"instance",get:function(){return Ff}},{key:"version",get:function(){return b}}])}();e.MemberState=void 0,(Hf=e.MemberState||(e.MemberState={})).NONE="none",Hf.JOINED="joined",Hf.INVITED="invited",Hf.LEFT="left";var jf,Vf,zf,Bf,Kf,Qf,Wf,Yf,Zf=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).state=null,s.role=null,s.isMuted=!1,s.isBlockedByMe=!1,s.isBlockingMe=!1,s.state=R(e.MemberState,i.state)?i.state:null,s.role=R(e.Role,i.role)?i.role:null,"boolean"==typeof i.is_muted&&(s.isMuted=i.is_muted),"boolean"==typeof i.is_blocked_by_me&&(s.isBlockedByMe=i.is_blocked_by_me),"boolean"==typeof i.is_blocking_me&&(s.isBlockingMe=i.is_blocking_me),s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}])}(Po),Xf=function(t){function a(t,i){var s,o,u;return r(this,a),(s=n(this,a,[t])).channelUrl=null!==(o=i.channel_url)&&void 0!==o?o:"",s.channelType=null!==(u=i.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,s.member=new si(s._iid,i.user),s.deliveryAt=i.ts,s}return c(a,t),i(a)}(Ya);e.PublicChannelFilter=void 0,(jf=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",jf.PUBLIC="public",jf.PRIVATE="private",e.MyMemberStateFilter=void 0,(Vf=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",Vf.JOINED="joined_only",Vf.INVITED="invited_only",Vf.INVITED_BY_FRIEND="invited_by_friend",Vf.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(zf=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",zf.SUPER="super",zf.NON_SUPER="nonsuper",zf.BROADCAST_ONLY="broadcast_only",zf.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(Bf=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",Bf.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(Kf=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",Kf.UNHIDDEN="unhidden_only",Kf.HIDDEN="hidden_only",Kf.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Kf.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(Qf=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",Qf.OPERATOR="operator",Qf.NONOPERATOR="nonoperator",e.QueryType=void 0,(Wf=e.QueryType||(e.QueryType={})).AND="AND",Wf.OR="OR",e.GroupChannelSearchField=void 0,(Yf=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",Yf.CHANNEL_NAME="channel_name";var Jf,$f=function(){function t(n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m,g;r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(a=null==n?void 0:n.includeEmpty)&&void 0!==a&&a,this.nicknameContainsFilter=null!==(i=null==n?void 0:n.nicknameContainsFilter)&&void 0!==i?i:null,this.nicknameStartsWithFilter=null!==(s=null==n?void 0:n.nicknameStartsWithFilter)&&void 0!==s?s:null,this.nicknameExactMatchFilter=null!==(o=null==n?void 0:n.nicknameExactMatchFilter)&&void 0!==o?o:null,this.channelNameContainsFilter=null!==(u=null==n?void 0:n.channelNameContainsFilter)&&void 0!==u?u:"",this.myMemberStateFilter=null!==(c=null==n?void 0:n.myMemberStateFilter)&&void 0!==c?c:e.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(l=null==n?void 0:n.customTypesFilter)&&void 0!==l?l:null,this.channelUrlsFilter=null!==(d=null==n?void 0:n.channelUrlsFilter)&&void 0!==d?d:null,this.superChannelFilter=null!==(h=null==n?void 0:n.superChannelFilter)&&void 0!==h?h:e.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(f=null==n?void 0:n.publicChannelFilter)&&void 0!==f?f:e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(p=null==n?void 0:n.customTypeStartsWithFilter)&&void 0!==p?p:null,this.unreadChannelFilter=null!==(v=null==n?void 0:n.unreadChannelFilter)&&void 0!==v?v:e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==n?void 0:n.hiddenChannelFilter)&&void 0!==_?_:e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(m=null==n?void 0:n.includeFrozen)||void 0===m||m,(null==n?void 0:n.createdAfter)&&(this.createdAfter=n.createdAfter),(null==n?void 0:n.createdBefore)&&(this.createdBefore=n.createdBefore),this.includeMetaData=null===(g=null==n?void 0:n.includeMetaData)||void 0===g||g}return i(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,i=r.fields;if(a&&i&&i.length>0&&!i.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var s=this._userIdsFilter,o=s.userIds,u=s.includeMode,c=s.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=v(e).sort(),r=v(t).sort(),a=0;a0&&!this.customTypesFilter.includes("*")&&!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 d=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(d)})))return!1}if(this.nicknameStartsWithFilter){var h=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(h)})))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.ALL:if("none"===t.myMemberState)return!1;break;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!(this.createdAfter&&t.createdAtthis.createdBefore)}}])}(),ep=function(t){function a(e,t){var i,s=t.sdkState,o=t.cacheContext;return r(this,a),(i=n(this,a,[e]))._channels=new Map,i._sdkState=s,i._cacheContext=o,i}return c(a,t),i(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ai(!!e).throw(A.databaseError),e.collection(Yc)}},{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 Cv.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return v(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>n||s&&t.createdAtn||s&&t.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)n._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});n._update(e),r.push(n)}else s._channels.set(e.url,e),r.push(e)})),!this.localCacheEnabled){n.next=7;break}for(a=[],i=0;i0)){r.next=76;break}return r.next=76,this.upsert(a);case 76:case"end":return r.stop()}}),r,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!0);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"unblock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!1);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"markAsRead",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v(this._channels.keys());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=s(t),n.prev=2,a.s();case 4:if((i=a.n()).done){n.next=12;break}return o=i.value,n.next=8,this.get(o);case 8:(null==(u=n.sent)?void 0:u._updateUnreadMemberState(this._sdkState.userId,e))&&(u._updateUnreadCount(0,0),r.push(u));case 10:n.next=4;break;case 12:n.next=17;break;case 14:n.prev=14,n.t0=n.catch(2),a.e(n.t0);case 17:return n.prev=17,a.f(),n.finish(17);case 20:if(!(r.length>0)){n.next=23;break}return n.next=23,this.upsert(r);case 23:case"end":return n.stop()}}),n,this,[[2,14,17,20]])})))}}])}(Ya);!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"}(Jf||(Jf={}));var tp,np=function(){return i((function e(t){var n;r(this,e),this.channelUrl=t.channel_url,this.channelType=t.channel_type,this.category=t.cat,this.data=null!==(n=t.data)&&void 0!==n?n:{},this.ts=t.ts}),[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}])}(),rp={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},ap=function(e){return P("string",e.invitedUserIds,!0)&&D("string",e.channelUrl,!0)&&D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isSuper,!0)&&D("boolean",e.isBroadcast,!0)&&D("boolean",e.isExclusive,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isStrict,!0)&&D("boolean",e.isDiscoverable,!0)&&D("boolean",e.isEphemeral,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},ip={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},sp=function(e){return P("string",e.customTypes,!0)&&D("boolean",e.includeEmpty,!0)&&D("boolean",e.includeFrozen,!0)&&D("boolean",e.includeMetaData,!0)&&D("boolean",e.includeChatNotification,!0)},op={myMemberStateFilter:e.MyMemberStateFilter.ALL},up=function(t){return R(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(tp=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",tp.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",tp.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",tp.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",tp.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",tp.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",tp.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",tp.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",tp.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var cp,lp={keys:[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,e.UnreadItemKey.NONSUPER_INVITATION_COUNT,e.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},dp=function(t){return P(e.UnreadItemKey,t.keys)&&P("string",t.customTypeFilters,!0)&&P("string",t.customTypesFilter,!0)},hp={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},fp=function(t){return P("string",t.channelCustomTypesFilter,!0)&&R(e.SuperChannelFilter,t.superChannelFilter)},pp={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},vp=function(t){return D("string",t.channelUrl,!0)&&P(e.ScheduledStatus,t.scheduledStatus,!0)&&R(e.MessageTypeFilter,t.messageTypeFilter)},_p=Object.assign({},e.CollectionEventSource),mp=function(t){return t.startsWith("EVENT_")||t===e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.CollectionEventSource.REFRESH_CHANNEL},gp=function(e){function t(e){var a,i=e.channels,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.ts;return r(this,t),(a=n(this,t)).channels=i,a.context=s,a.isWebSocketEventComing=u,a.ts=c,a}return c(t,e),i(t)}(fe),yp=function(e){function t(e){var a,i=e.channelUrls,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,t),(a=n(this,t)).channelUrls=i,a.context=s,a.isWebSocketEventComing=u,a}return c(t,e),i(t)}(fe),Ep=function(){return i((function t(n){var a=this,i=n.groupChannelCache,o=n.messageCache,u=n.unsentMessageCache,c=n.dispatcher;r(this,t),this._observers=new Map,c.on((function(t){return E(a,void 0,void 0,d().mark((function n(){var r,a,c,l,h,f,p,v,_,m,g,y,k,b,C,w=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof gp)){n.next=47;break}if(r=t.channels,a=t.context,c=t.isWebSocketEventComing,l=r.filter((function(e){return e instanceof E_})),a.source!==e.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY&&a.source!==e.CollectionEventSource.EVENT_CHANNEL_HIDDEN){n.next=23;break}h=s(l),n.prev=5,h.s();case 7:if((f=h.n()).done){n.next=13;break}return p=f.value,n.next=11,o.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),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:n.next=41;break;case 23:v=i.filterOffsetChanged(l),_=s(v),n.prev=25,_.s();case 27:if((m=_.n()).done){n.next=33;break}return g=m.value,n.next=31,o.removeUnderOffset(g.url,g.messageOffsetTimestamp);case 31:n.next=27;break;case 33:n.next=38;break;case 35:n.prev=35,n.t1=n.catch(25),_.e(n.t1);case 38:return n.prev=38,_.f(),n.finish(38);case 41:return n.next=43,i.upsert(l,t.ts);case 43:y=n.sent,c||this._broadcastUpdateEvent(y,a),n.next=59;break;case 47:if(!(t instanceof yp)){n.next=56;break}return k=t.channelUrls,b=t.context,C=t.isWebSocketEventComing,n.next=51,i.remove(k);case 51:return n.next=53,fi((function(){return E(w,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(k),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=7,o.removeMessagesOfChannel(r);case 7:return e.next=9,u.removeMessagesOfChannel(r);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 53:C||this._broadcastRemoveEvent(k,b),n.next=59;break;case 56:if(!(t instanceof Ph)){n.next=59;break}return n.next=59,i.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 59:case"end":return n.stop()}}),n,this,[[5,15,18,21],[25,35,38,41]])})))}))}),[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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:"_broadcastRemoveEvent",value:function(e,t){var n,r=s(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()}}])}(),kp=function(e){function t(e){var a,i=e.userId,s=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c;r(this,t),a=n(this,t);var d=Object.assign(Object.assign({},ip),u),h=d.customTypes,f=d.includeEmpty,p=d.includeFrozen;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels/changelogs"),a.params=pe(ve({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:s||null,token:o,custom_types:h,show_empty:f,show_frozen:p,include_chat_notification:l})),a}return c(t,e),i(t)}(je),bp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedChannels=a.updated.map((function(t){return new E_(e,Object.assign(t,{ts:a.ts}))})),i.deletedChannelUrls=a.deleted,i.hasMore=a.has_more,i.token=a.next,i.ts=a.ts,i}return c(t,e),i(t)}(Ve),Cp=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall,o=e.showLatestMessage;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?be:ke,"/").concat(encodeURIComponent(i)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=o&&o},a}return c(t,e),i(t)}(je),wp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),xp={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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,createdAfter:void 0,createdBefore:void 0},Sp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,d=e.superChannelFilter,h=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,E=e.customTypeStartsWithFilter,k=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,C=e.metadataKey,w=e.metadataValues,x=e.metadataValueStartsWith,S=e.includeFrozen,T=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter,A=e.includeChatNotification,M=void 0!==A&&A,O=e.includeLeftChannel,U=void 0!==O&&O,D=e.createdAfter,R=e.createdBefore;return(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels"),a.params=pe({token:s,limit:o,order:null!=u?u:xp.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:xp.includeEmpty,member_state_filter:null!=l?l:xp.myMemberStateFilter,super_mode:null!=d?d:xp.superChannelFilter,public_mode:null!=h?h:xp.publicChannelFilter,unread_filter:null!=f?f:xp.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:E,hidden_mode:k,metadata_order_key:b,metadata_key:C,metadata_values:w,metadata_value_startswith:x,show_frozen:S,show_metadata:T,include_chat_notification:M,include_left_channel:U,created_after:D,created_before:R}),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 c(t,e),i(t)}(je),Tp=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new E_(e,t)}))),i.ts=null!=u?u:0,i}return c(t,e),i(t)}(Ve),Ip=function(t){function a(t){var i,s=t.userId,o=t.filter;r(this,a),i=n(this,a);var u=o.myMemberStateFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/group_channel_count"),i.params={state:null!=u?u:e.MyMemberStateFilter.ALL},i}return c(a,t),i(a)}(je),Np=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).groupChannelCount=a.group_channel_count,i}return c(t,e),i(t)}(Ve),Ap=function(e){function t(e){var a,i=e.userId,s=e.filter;r(this,t),a=n(this,t);var o=s.keys,u=s.customTypeFilters,c=s.customTypesFilter;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_item_count"),a.params=pe({item_keys:o,custom_types:null!=c?c:u}),a}return c(t,e),i(t)}(je),Mp=function(t){function a(t,i){var s;return r(this,a),s=n(this,a,[t,i]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=i[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),s}return c(a,t),i(a)}(Ve),Op=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_channel_count"),a}return c(t,e),i(t)}(je),Up=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i}return c(t,e),i(t)}(Ve),Dp=function(t){function a(t){var i,s=t.userId,o=t.filter,u=t.includeFeedChannel,c=void 0!==u&&u;r(this,a),i=n(this,a);var l=o.channelCustomTypesFilter,d=o.superChannelFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/unread_message_count"),i.params={super_mode:null!=d?d:e.SuperChannelFilter.ALL,custom_types:l,include_feed_channel:c},i}return c(a,t),i(a)}(je),Rp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i.unreadFeedCount=a.unread_feed_count,i}return c(t,e),i(t)}(Ve),Lp=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledStatus,o=e.messageTypeFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ae,"/count"),a.params={channel_url:i,status:Fp(s)},o&&(a.params.message_type=o),a}return c(t,e),i(t)}(je),Pp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).count=a.count,i}return c(t,e),i(t)}(Ve),Fp=function(t){if(!t)return[];var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(Vs.PENDING);break;case e.ScheduledStatus.SENT:n.push(Vs.IN_QUEUE),n.push(Vs.SENT);break;case e.ScheduledStatus.CANCELED:n.push(Vs.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(Vs.FAILED)}})),n},qp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,d=e.isBroadcast,h=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,_=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,E=e.data,k=e.customType,b=e.messageSurvivalSeconds,C=e.invitedUserIds,w=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path=ke,a.params=pe({user_ids:[i].concat(v(null!=C?C:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:d,is_exclusive:f,is_public:h,is_discoverable:p,strict:_,is_ephemeral:m,access_code:g,name:y,data:E,custom_type:k,operator_ids:w,message_survival_seconds:b}),a}return c(t,e),i(t)}(je),Hp=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i.isCreated=null===(s=a.is_created)||void 0===s||s,i}return c(t,e),i(t)}(Ve),Gp=function(e){function t(e){var a,i=e.userId,s=e.channelUrls;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/mark_as_read_all"),a.params={channel_urls:s},a}return c(t,e),i(t)}(je),jp=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).event=new np(i),s}return c(t,e),i(t)}(Ke),Vp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/join"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(je),zp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),Bp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.users,f=void 0===h?null:h;return s.memberCount=c,s.joinedMemberCount=d,s.members=Array.isArray(f)?f.map((function(t){return new Zf(e,t)})):[new Zf(e,i.data)],s}return c(t,e),i(t)}(jp),Kp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.shouldRemoveOperatorStatus;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/leave"),a.params={user_id:s,should_remove_operator_status:o},a}return c(t,e),i(t)}(je),Qp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l;return s.memberCount=c,s.joinedMemberCount=d,s.member=new Zf(s._iid,i.data),s}return c(t,e),i(t)}(jp),Wp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/invite"),a.params={user_ids:s},a}return c(t,e),i(t)}(je),Yp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),Zp=function(e){function t(e,a,i){var s;r(this,t),(s=n(this,t,[e,a,i])).inviter=null;var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.inviter,f=o.invitees,p=void 0===f?[]:f;return s.memberCount=c,s.joinedMemberCount=d,h&&Object.keys(h).length>0&&(s.inviter=new si(e,h)),s.invitees=p.map((function(t){return new Zf(e,t)})),s}return c(t,e),i(t)}(jp),Xp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/decline"),a.params={user_id:s},a}return c(t,e),i(t)}(je),Jp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=o.joined_member_count,l=o.inviter,d=o.invitee;return s.memberCount=null!=u?u:0,s.joinedMemberCount=null!=c?c:0,s.inviter=new si(e,l),s.invitee=new Zf(e,d),s}return c(t,e),i(t)}(jp),$p={hidePreviousMessages:!1,allowAutoUnhide:!0},ev=function(e){return D("boolean",e.hidePreviousMessages,!0)&&D("boolean",e.allowAutoUnhide,!0)},tv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a.params={user_id:s,hide_previous_messages:null!=o?o:$p.hidePreviousMessages,allow_auto_unhide:null!=u?u:$p.allowAutoUnhide},a}return c(t,e),i(t)}(je),nv=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(Ve),rv=function(e){function t(e,a,i){var s,o,u,c;return r(this,t),(s=n(this,t,[e,"SYEV",i])).allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,i.data&&(s.allowAutoUnhide=null!==(o=i.data.allow_auto_unhide)&&void 0!==o?o:null,s.hidePreviousMessages=null!==(u=i.data.hide_previous_messages)&&void 0!==u?u:null),s.messageOffsetTimestamp=null!==(c=i.ts_message_offset)&&void 0!==c?c:null,s}return c(t,e),i(t)}(Ke),av=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(Qe),iv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new si(e,i.data),s}return c(t,e),i(t)}(Ke),sv=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(Qe),ov=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new si(e,i.data),s}return c(t,e),i(t)}(Ke),uv=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data.operators,u=void 0===o?[]:o;return s.operators=u.map((function(e){return new si(s._iid,e)})),s}return c(t,e),i(t)}(jp),cv=function(e){function t(e){var a=e.channelUrl,i=e.messageId;return r(this,t),n(this,t,[{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:i}}])}return c(t,e),i(t)}(Qe),lv=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x,S,T,I,N;return r(this,a),(s=n(this,a,[t,i])).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.includeChatNotification=!1,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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.includeChatNotification=null!==(l=i.includeChatNotification)&&void 0!==l&&l,s.channelUrlsFilter=null!==(d=i.channelUrlsFilter)&&void 0!==d?d:null,s.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(f=i.customTypeStartsWithFilter)&&void 0!==f?f:"",s.nicknameContainsFilter=null!==(p=i.nicknameContainsFilter)&&void 0!==p?p:null,s.nicknameStartsWithFilter=null!==(v=i.nicknameStartsWithFilter)&&void 0!==v?v:null,s.nicknameExactMatchFilter=null!==(_=i.nicknameExactMatchFilter)&&void 0!==_?_:null,s.channelNameContainsFilter=null!==(m=i.channelNameContainsFilter)&&void 0!==m?m:"",s.myMemberStateFilter=null!==(g=i.myMemberStateFilter)&&void 0!==g?g:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(y=i.unreadChannelFilter)&&void 0!==y?y:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(E=i.superChannelFilter)&&void 0!==E?E:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=i.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=i.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(C=i.searchFilter)&&void 0!==C?C:{fields:[],query:null},s.userIdsFilter=null!==(w=i.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(x=i.metadataKey)&&void 0!==x?x:null,s.metadataValues=null!==(S=i.metadataValues)&&void 0!==S?S:null,s.metadataOrderKeyFilter=null!==(T=i.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(I=i.metadataValueStartsWith)&&void 0!==I?I:null,s.order=null!==(N=i.order)&&void 0!==N?N:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i.createdAfter&&(s.createdAfter=i.createdAfter),i.createdBefore&&(s.createdBefore=i.createdBefore),s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter)&&D("string",this.nicknameContainsFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)&&D("string",this.nicknameExactMatchFilter,!0)&&R(e.MyMemberStateFilter,this.myMemberStateFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicChannelFilter,this.publicChannelFilter)&&R(e.UnreadChannelFilter,this.unreadChannelFilter)&&R(e.HiddenChannelFilter,this.hiddenChannelFilter)&&P(e.GroupChannelSearchField,this.searchFilter.fields)&&D("string",this.searchFilter.query,!0)&&P("string",this.userIdsFilter.userIds)&&D("boolean",this.userIdsFilter.includeMode)&&R(e.QueryType,this.userIdsFilter.queryType)&&R(e.GroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)&&F(this.createdAfter,!0)&&F(this.createdBefore,!0)}},{key:"serialize",value:function(){return ni(this)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._validate()){t.next=20;break}if(this._isLoading){t.next=17;break}if(!this._hasNext){t.next=14;break}return this._isLoading=!0,n=Cv.of(this._iid),t.next=7,n.getMyGroupChannels(this._token,ve(Object.assign({},this)),this.limit,e.CollectionEventSource.REQUEST_CHANNEL,!0);case 7:return r=t.sent,a=r.channels,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,t.abrupt("return",a);case 14:return t.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:t.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return t.stop()}}),t,this)})))}}])}(uu),dv=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"SYEV",i])).pinnedMessageIds=[],s.latestPinnedMessage=null,s.ts=0,i.data&&(s.pinnedMessageIds=null!==(o=i.data.pinned_message_ids)&&void 0!==o?o:[],s.latestPinnedMessage=i.data.latest_pinned_message?ho(e,Object.assign({},i.data.latest_pinned_message)):null),s.ts=i.ts,s}return c(t,e),i(t)}(Ke),hv=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e]))._logger=a.logger,i._sdkState=a.sdkState,i._sessionManager=a.sessionManager,i._requestQueue=a.requestQueue,i._dispatcher=a.dispatcher,i._cacheContext=a.cacheContext,i._channelType=a.channelType,i}return c(t,e),i(t,[{key:"_messageBroadcast",get:function(){return Zd.of(this._iid)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"getMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null);case 1:case"end":return e.stop()}}),e)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r,a,i){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",0);case 1:case"end":return e.stop()}}),e)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}(Ya),fv=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"ADMM",i])).message=new Js(e,i);var d=es.of(e).sdkState;return s.isMentioned=Fe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),pv=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"AEDI",i])).message=new Js(e,i);var h=es.of(e).sdkState;return s.mentionCountChange=qe({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),vv=function(e){function t(e){var a,i=e.channelUrl,s=e.userId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/messages/mark_as_delivered"),a.params=pe({userId:s}),a}return c(t,e),i(t)}(je),_v=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"DLVR",i])).channelUrl=i.channel_url,s.deliveredStateUpdate=i.updated,s}return c(t,e),i(t)}(Ke),mv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MRCT",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.event=new os(i),s}return c(t,e),i(t)}(Ke),gv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MTHD",i])).event=new rh(e,i),s}return c(t,e),i(t)}(Ke),yv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MCNT",i])).groupChannelMemberCounts=i.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=i.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return c(t,e),i(t)}(Ke),Ev=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"PEDI",i])).event=new Eh(e,i),s.status=no(i.poll.status)||i.poll.status,s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),kv=function(){return i((function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,i=t.bottom,s=void 0===i?0:i;r(this,e),this.top=a,this.bottom=s}),[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0&&r.onMentionReceived&&r.onMentionReceived(T,w)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 63:return a.abrupt("break",344);case 64:if(D=t.as(lt),R=D.channelUrl,L=D.channelType,P=D.messageId,F=D.silent,q=D.messageCreatedAt,H=D.senderId,L!==e.ChannelType.GROUP){a.next=73;break}return a.next=68,this.getChannel(R,!0);case 68:G=a.sent,j=H===this._sdkState.userId,F||j||q>0&&G.myLastRead0&&G._updateUnreadCount(G.unreadMessageCount-1,0),this._dispatcher.dispatch(new Us({messageIds:[P],source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onMessageDeleted&&r.onMessageDeleted(G,P)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 73:return a.abrupt("break",344);case 74:if(V=t.as(Es),(z=V.readStatus).channelType!==e.ChannelType.GROUP){a.next=82;break}return B=this._groupChannelCache.isCachedInMemory(z.channelUrl),a.next=79,this.getChannel(z.channelUrl,!0);case 79:K=a.sent,B&&K._updateUnreadMemberState(z.reader.userId,z.readAt),z.reader.userId===this._sdkState.userId?B?(K.unreadMessageCount>0||K.unreadMentionCount>0)&&(K._updateUnreadCount(0,0),this._dispatcher.dispatch(new gp({channels:[K],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(K)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==K.unreadMessageCount&&0!==K.unreadMentionCount||(this._dispatcher.dispatch(new gp({channels:[K],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(K)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new gp({channels:[K],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUnreadMemberStatusUpdated&&r.onUnreadMemberStatusUpdated(K)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 82:return a.abrupt("break",344);case 83:return Q=t.as(_v),W=Q.channelUrl,Y=Q.deliveredStateUpdate,Z=void 0===Y?{}:Y,X=this._groupChannelCache.isCachedInMemory(W),a.next=87,this.getChannel(W,!0);case 87:return J=a.sent,X&&Object.keys(Z).forEach((function(e){J._updateUndeliveredMemberState(e,Z[e])})),Object.keys(Z).some((function(e){return e!==mn._sdkState.userId}))&&(this._dispatcher.dispatch(new gp({channels:[J],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELIVERED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUndeliveredMemberStatusUpdated&&r.onUndeliveredMemberStatusUpdated(J)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 91:if($=t.as(mv),ee=$.channelUrl,te=$.channelType,ne=$.event,te!==e.ChannelType.GROUP){a.next=101;break}return a.next=95,this.getChannel(ee,!0);case 95:return re=a.sent,a.next=98,this.getMessageFromCache(ne.messageId);case 98:(ae=a.sent)?ae instanceof Ws&&(ae.applyReactionEvent(ne),this._dispatcher.dispatch(new Os({messages:[ae],source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new Ds({event:ne,source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onReactionUpdated&&r.onReactionUpdated(re,ne)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 101:return a.abrupt("break",344);case 102:if(ie=t.as(gv),(se=ie.event).channelType!==e.ChannelType.GROUP){a.next=112;break}return a.next=106,this.getChannel(se.channelUrl,!0);case 106:return oe=a.sent,a.next=109,this.getMessageFromCache(se.targetMessageId);case 109:(ue=a.sent)?ue instanceof Ws&&(ue.applyThreadInfoUpdateEvent(se),this._dispatcher.dispatch(new Os({messages:[ue],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new Rs({event:se,source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onThreadInfoUpdated&&r.onThreadInfoUpdated(oe,se)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 112:return a.abrupt("break",344);case 113:ce=t.as(yv),le=ce.groupChannelMemberCounts,de=[],he=s(le),a.prev=116,he.s();case 118:if((fe=he.n()).done){a.next=127;break}return pe=fe.value,ve=pe.channelUrl,_e=pe.memberCount,me=pe.joinedMemberCount,ge=pe.updatedAt,a.next=123,this.getChannelFromCache(ve);case 123:(ye=a.sent)&&ye._setLatestMemberCount(_e,me,ge)&&de.push(ye);case 125:a.next=118;break;case 127:a.next=132;break;case 129:a.prev=129,a.t2=a.catch(116),he.e(a.t2);case 132:return a.prev=132,he.f(),a.finish(132);case 135:return de.length>0&&(this._dispatcher.dispatch(new gp({channels:de,context:{source:e.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(de)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 137:if(Ee=t.as(Ev),ke=Ee.event,be=Ee.status,Ce=Ee.channelUrl,we=Ee.channelType,!Ce||we!==e.ChannelType.GROUP){a.next=144;break}return a.next=141,this.getChannel(Ce,!0);case 141:xe=a.sent,this._dispatcher.dispatch(new Fs({event:ke,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),hi(be===to?function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(xe,ke.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(xe,ke)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 144:return a.abrupt("break",344);case 145:if(Se=t.as(Oc),Te=Se.event,Ie=Se.channelUrl,Ne=Se.channelType,!Ie||Ne!==e.ChannelType.GROUP){a.next=152;break}return a.next=149,this.getChannel(Ie,!0);case 149:Ae=a.sent,this._dispatcher.dispatch(new qs({event:Te,source:e.CollectionEventSource.EVENT_POLL_VOTED})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(Ae,Te)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 152:return a.abrupt("break",344);case 153:if(Me=t.as(jp),!(Oe=Me.event).isGroupChannelEvent){a.next=332;break}a.t3=Oe.category,a.next=a.t3===Jf.CHANNEL_JOIN?158:a.t3===Jf.CHANNEL_LEAVE?167:a.t3===Jf.CHANNEL_OPERATOR_UPDATE?183:a.t3===Jf.CHANNEL_INVITE?194:a.t3===Jf.CHANNEL_DECLINE_INVITE?204:a.t3===Jf.TYPING_START||a.t3===Jf.TYPING_END?212:a.t3===Jf.USER_CHANNEL_MUTE||a.t3===Jf.USER_CHANNEL_UNMUTE?221:a.t3===Jf.USER_CHANNEL_BAN?248:a.t3===Jf.USER_CHANNEL_UNBAN?263:a.t3===Jf.CHANNEL_FREEZE||a.t3===Jf.CHANNEL_UNFREEZE?271:a.t3===Jf.CHANNEL_HIDE?279:a.t3===Jf.CHANNEL_UNHIDE?289:a.t3===Jf.CHANNEL_DELETED?296:a.t3===Jf.CHANNEL_PROP_CHANGED?302:a.t3===Jf.CHANNEL_META_DATA_CHANGED?308:a.t3===Jf.CHANNEL_META_COUNTERS_CHANGED?317:a.t3===Jf.PINNED_MESSAGE_CHANGED?326:332;break;case 158:return a.next=160,this.getChannel(Oe.channelUrl,!0);case 160:return Ue=a.sent,De=t.as(Bp),Re=De.memberCount,Le=De.joinedMemberCount,Pe=De.members,Fe=!1,Pe.forEach((function(t){Ue.isExclusive||Ue.isSuper||Ue.isBroadcast?Fe=Fe||Ue._setLatestMemberCount(Re,Le,Oe.ts):(t.state=e.MemberState.JOINED,Ue.addMember(t,Oe.ts),mn._updateJoinedMemberCount(Ue)),t.userId===mn._sdkState.userId&&(Ue.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new gp({channels:[Ue],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:Pe}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=s(Pe);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ue,r)}}catch(e){n.e(e)}finally{n.f()}Ue.isBroadcast&&Fe&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ue])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 167:if(!(qe=this._leftChannels.get(Oe.channelUrl))){a.next=172;break}a.t4=qe.channel,a.next=175;break;case 172:return a.next=174,this.getChannel(Oe.channelUrl,!0);case 174:a.t4=a.sent;case 175:return He=a.t4,Ge=t.as(Qp),je=Ge.memberCount,Ve=Ge.joinedMemberCount,ze=Ge.member,Be=!1,Ke=es.of(this._iid),Qe=Ke.appInfo,He.isExclusive||He.isSuper||He.isBroadcast?Be=He._setLatestMemberCount(je,Ve,Oe.ts):((null==Qe?void 0:Qe.enabledChannelMemberShipHistory)?((We=He.members.find((function(e){return e.userId===ze.userId})))&&(We.state=e.MemberState.LEFT),He.memberCount=je):He.removeMember(ze),this._updateJoinedMemberCount(He)),ze.userId===this._sdkState.userId?(He.myMemberState=e.MemberState.NONE,He.invitedAt=0,He.joinedAt=0,He._updateUnreadCount(0,0),He.isPublic?this._dispatcher.dispatch(new gp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})):(this._markAsLeave(He),this._dispatcher.dispatch(new yp({channelUrls:[He.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})))):this._dispatcher.dispatch(new gp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(He,ze),He.isBroadcast&&Be&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([He])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 183:return a.next=185,this.getChannel(Oe.channelUrl,!0);case 185:Ye=a.sent,Ze=t.as(uv),Xe=Ze.operators,Je=Xe.map((function(e){return e.userId})),$e=s(Ye.members);try{for($e.s();!(et=$e.n()).done;)(tt=et.value).role=Je.includes(tt.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){$e.e(e)}finally{$e.f()}return Ye.myRole=Je.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new gp({channels:[Ye],context:{source:e.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Xe}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ye,Xe)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 194:return a.next=196,this.getChannel(Oe.channelUrl,!0);case 196:nt=a.sent,rt=t.as(Zp),at=rt.memberCount,it=rt.joinedMemberCount,st=rt.inviter,(ot=rt.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),ut=s(ot);try{for(ut.s();!(ct=ut.n()).done;)dt=ct.value,nt.isExclusive||nt.isSuper||nt.isBroadcast?nt._setLatestMemberCount(at,it,Oe.ts):nt.addMember(dt,Oe.ts),this._sdkState.userId===dt.userId&&(nt.hiddenState=e.HiddenState.UNHIDDEN,nt.myMemberState!==e.MemberState.JOINED&&(nt.myMemberState=e.MemberState.INVITED),nt.invitedAt=Oe.ts)}catch(e){ut.e(e)}finally{ut.f()}return this._dispatcher.dispatch(new gp({channels:[nt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:st,invitees:ot}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(nt,st,ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 204:return a.next=206,this.getChannel(Oe.channelUrl,!0);case 206:return ht=a.sent,ft=t.as(Jp),pt=ft.memberCount,vt=ft.joinedMemberCount,_t=ft.inviter,mt=ft.invitee,ht.isExclusive||ht.isSuper||ht.isBroadcast?ht._setLatestMemberCount(pt,vt,Oe.ts):ht.removeMember(mt),this._sdkState.userId===mt.userId?(ht.invitedAt=0,ht.myMemberState=e.MemberState.NONE,ht.isPublic?this._dispatcher.dispatch(new gp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})):this._dispatcher.dispatch(new yp({channelUrls:[ht.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}}))):this._dispatcher.dispatch(new gp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ht,_t,mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 212:return a.next=214,this.getChannel(Oe.channelUrl,!0);case 214:return gt=a.sent,yt=Oe.category===Jf.TYPING_START,Et=t.as(yt?iv:ov),kt=Et.user,gt._updateTypingStatus(kt,yt?Oe.ts:0),this._dispatcher.dispatch(new gp({channels:[gt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(gt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 221:return a.next=223,this.getChannel(Oe.channelUrl,!0);case 223:bt=a.sent,Ct=Oe.category===Jf.USER_CHANNEL_MUTE,wt=t.as(Ct?Bu:Qu),(xt=wt.user).userId===this._sdkState.userId&&(bt.myMutedState=Ct?e.MutedState.MUTED:e.MutedState.UNMUTED,bt._myMutedRemainingTime=xt.restrictionInfo.remainingDuration),St=s(bt.members),a.prev=228,St.s();case 230:if((Tt=St.n()).done){a.next=237;break}if((It=Tt.value).userId!==xt.userId){a.next=235;break}return It.isMuted=Ct,a.abrupt("break",237);case 235:a.next=230;break;case 237:a.next=242;break;case 239:a.prev=239,a.t5=a.catch(228),St.e(a.t5);case 242:return a.prev=242,St.f(),a.finish(242);case 245:return this._dispatcher.dispatch(new gp({channels:[bt],context:{source:Ct?e.CollectionEventSource.EVENT_CHANNEL_MUTED:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:xt}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ct?e.onUserMuted&&e.onUserMuted(bt,xt):e.onUserUnmuted&&e.onUserUnmuted(bt,xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 248:if(!(Nt=this._leftChannels.get(Oe.channelUrl))){a.next=253;break}a.t6=Nt.channel,a.next=256;break;case 253:return a.next=255,this.getChannel(Oe.channelUrl,!0);case 255:a.t6=a.sent;case 256:return At=a.t6,this._markAsLeave(At),Mt=t.as(Yu),Ot=Mt.user,Ot.userId===this._sdkState.userId&&this._dispatcher.dispatch(new yp({channelUrls:[At.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_BANNED,user:Ot}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(At,Ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 263:return a.next=265,this.getChannel(Oe.channelUrl,!0);case 265:return Ut=a.sent,Dt=t.as(Xu),Rt=Dt.user,Rt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new yp({channelUrls:[Ut.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:Rt}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(Ut,Rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 271:return a.next=273,this.getChannel(Oe.channelUrl,!0);case 273:return Lt=a.sent,Pt=t.as($u),Ft=Pt.freeze,Lt.isFrozen=Ft,this._dispatcher.dispatch(new gp({channels:[Lt],context:{source:Ft?e.CollectionEventSource.EVENT_CHANNEL_FROZEN:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ft?e.onChannelFrozen&&e.onChannelFrozen(Lt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 279:return a.next=281,this.getChannel(Oe.channelUrl,!0);case 281:return qt=a.sent,Ht=t.as(rv),Gt=Ht.allowAutoUnhide,jt=Ht.hidePreviousMessages,Vt=Ht.messageOffsetTimestamp,null!==Gt&&(qt.hiddenState=Gt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==jt&&jt&&qt._updateUnreadCount(0,0),null!==Vt&&(qt.messageOffsetTimestamp=Vt),this._dispatcher.dispatch(new gp({channels:[qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 289:return a.next=291,this.getChannel(Oe.channelUrl,!0);case 291:return(zt=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new gp({channels:[zt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(zt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 296:return a.next=298,this.getChannel(Oe.channelUrl,!0);case 298:return Bt=a.sent,this._dispatcher.dispatch(new yp({channelUrls:[Oe.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Bt.url,Bt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 302:return a.next=304,this.getChannelWithoutCache(Oe.channelUrl,!0);case 304:return Kt=a.sent,this._dispatcher.dispatch(new gp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Kt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 308:return a.next=310,this.getChannel(Oe.channelUrl,!0);case 310:return Qt=a.sent,Wt=t.as(Au),Yt=Wt.created,Zt=Wt.updated,Xt=Wt.deleted,Yt&&(Qt._upsertCachedMetaData(Yt,Oe.ts),this._dispatcher.dispatch(new gp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:Yt},ts:Oe.ts}))),Zt&&(Qt._upsertCachedMetaData(Zt,Oe.ts),this._dispatcher.dispatch(new gp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:Zt},ts:Oe.ts}))),Xt&&(Qt._removeFromCachedMetaData(Xt,Oe.ts),this._dispatcher.dispatch(new gp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:Xt},ts:Oe.ts}))),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Yt&&e.onMetaDataCreated&&e.onMetaDataCreated(Qt,Yt),Zt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Qt,Zt),Xt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Qt,Xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 317:return a.next=319,this.getChannel(Oe.channelUrl,!0);case 319:return Jt=a.sent,$t=t.as(Gu),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&this._dispatcher.dispatch(new gp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:en}})),tn&&this._dispatcher.dispatch(new gp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:tn}})),nn&&this._dispatcher.dispatch(new gp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:nn}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){en&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Jt,en),tn&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Jt,tn),nn&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Jt,nn)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 326:return a.next=328,this.getChannel(Oe.channelUrl,!0);case 328:return rn=a.sent,an=t.as(dv),sn=an.pinnedMessageIds,on=an.latestPinnedMessage,(un=an.ts)>rn._pinnedMessagesUpdatedAt&&(rn.pinnedMessageIds=null!=sn?sn:[],rn.lastPinnedMessage=on,rn._pinnedMessagesUpdatedAt=un,this._dispatcher.dispatch(new gp({channels:[rn],context:{source:e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED}})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(rn)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),hi((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(rn)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",332);case 332:return a.abrupt("break",344);case 333:cn=t.as(qh),ln=cn.event,a.t7=ln.category,a.next=a.t7===wh.USER_BLOCK?337:a.t7===wh.USER_UNBLOCK?340:343;break;case 337:return dn=Rh.getDataAsUserBlockEvent(this._iid,ln),hn=dn.blocker,fn=dn.blockee,this._groupChannelCache.block(hn.userId,fn.userId),a.abrupt("break",343);case 340:return pn=Rh.getDataAsUserBlockEvent(this._iid,ln),vn=pn.blocker,_n=pn.blockee,this._groupChannelCache.unblock(vn.userId,_n.userId),a.abrupt("break",343);case 343:return a.abrupt("break",344);case 344:a.next=350;break;case 346:if(a.prev=346,a.t8=a.catch(0),!N(a.t8)){a.next=350;break}throw a.t8;case 350:case"end":return a.stop()}}),a,this,[[0,346],[18,29,32,35],[116,129,132,135],[228,239,242,245]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ai(D("string",t)).throw(A.invalidParameters),a=new Cp({channelUrl:t,isInternalCall:n}),r.next=4,this._requestQueue.send(a);case 4:i=r.sent,s=i.as(wp),o=s.channel,u=o.unreadMessageCount,c=o.unreadMentionCount,r.t0=o.myCountPreference,r.next=r.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:r.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:r.t0===e.CountPreference.OFF?14:17;break;case 10:return c=0,r.abrupt("break",17);case 12:return u=0,r.abrupt("break",17);case 14:return u=0,c=0,r.abrupt("break",17);case 17:return o._updateUnreadCount(u,c),r.next=20,this.upsertChannelsToCache([o]);case 20:return r.abrupt("return",r.sent[0]);case 21:case"end":return r.stop()}}),r,this)})))}},{key:"refreshChannel",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REFRESH_CHANNEL,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,s=new Cp({channelUrl:t,isInternalCall:n,showLatestMessage:a}),i.next=4,this._requestQueue.send(s);case 4:if(o=i.sent,u=o.as(wp),(c=u.channel).myMemberState!==e.MemberState.NONE){i.next=10;break}this._dispatcher.dispatch(new yp({channelUrls:[c.url],context:{source:r}})),i.next=14;break;case 10:return i.next=12,this.upsertChannelsToCache([c]);case 12:l=i.sent,this._dispatcher.dispatch(new gp({channels:l,context:{source:r}}));case 14:i.next=19;break;case 16:i.prev=16,i.t0=i.catch(0),i.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&i.t0.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new yp({channelUrls:[t],context:{source:r}}));case 19:case"end":return i.stop()}}),i,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_CHANNEL,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p,v;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.createdAfter&&(n.createdAfter=Math.floor(n.createdAfter/1e3)),n.createdBefore&&(n.createdBefore=Math.floor(n.createdBefore/1e3)),s=!1,i&&(o=es.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(s=!0)),l=new Sp(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:r,includeLeftChannel:i&&s})),e.next=7,this._requestQueue.send(l);case 7:return h=e.sent,f=h.as(Tp),p=f.channels,v=f.token,this._dispatcher.dispatch(new gp({channels:p,context:{source:a}})),e.abrupt("return",{channels:p,token:v});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Object.assign(Object.assign({},ip),n),ai((D("string",t)||D("number",t))&&sp(a)).throw(A.invalidParameters),i=new kp(ve({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,filter:a})),e.next=5,this._requestQueue.send(i);case 5:return s=e.sent,o=s.as(bp),u=o.updatedChannels,c=o.deletedChannelUrls,l=o.hasMore,h=o.ts,u.length>0&&this._dispatcher.dispatch(new gp({channels:u,context:{source:r},ts:h})),c.length>0&&this._dispatcher.dispatch(new yp({channelUrls:c,context:{source:r}})),e.abrupt("return",{updatedChannels:u,deletedChannelUrls:c,hasMore:l,token:o.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},op),e),ai(up(n)).throw(A.invalidParameters),r=new Ip({userId:this._sdkState.userId,filter:n}),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Np),s=i.groupChannelCount,t.abrupt("return",s);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},lp),e),ai(dp(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Ap({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Mp),c=u.groupChannelUnreadMentionCount,l=u.groupChannelUnreadMessageCount,h=u.groupChannelInvitationCount,f=u.superGroupChannelUnreadMentionCount,p=u.superGroupChannelUnreadMessageCount,v=u.superGroupChannelInvitationCount,_=u.nonSuperGroupChannelUnreadMentionCount,m=u.nonSuperGroupChannelUnreadMessageCount,g=u.nonSuperGroupChannelInvitationCount,t.abrupt("return",pe({groupChannelUnreadMentionCount:c,groupChannelUnreadMessageCount:l,groupChannelInvitationCount:h,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Op({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Up),o=s.unreadCount,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},hp),e),ai(fp(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Dp({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Rp),c=u.unreadCount,t.abrupt("return",c);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},pp),e),ai(vp(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new Lp(n),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Pp),u=o.count,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=es.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=es.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=es.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},rp),e),ai(ap(n)).throw(A.invalidParameters),n.isPublic||(n.accessCode=void 0),r=new qp(Object.assign({userId:this._sdkState.userId},n)),t.next=6,this._requestQueue.send(r);case 6:return a=t.sent,i=a.as(Hp),s=i.channel,t.next=10,this.upsertChannelsToCache([s]);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Date.now(),ai(t-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Gp({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(n);case 6:r=this._groupChannelCache.channels,a=s(r);try{for(a.s();!(i=a.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0)}catch(e){a.e(e)}finally{a.f()}if(!(r.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(r);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),ai(P("string",e)&&n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new Gp({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,i=[],o=s(a);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,n),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()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return n=t.sent,t.next=5,n.markAsDelivered();case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._messageCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0});case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),r,this)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:100,i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return E(this,void 0,void 0,d().mark((function s(){return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i});case 2:return s.abrupt("return",s.sent);case 3:case"end":return s.stop()}}),s,this)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.countBetween(e,t,new kv({top:n,bottom:r}));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:t});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return bv[e]||(bv[e]=new a(e,es.of(e))),bv[e]}},{key:"clear",value:function(e){bv[e]&&delete bv[e]}}])}(hv),wv=function(e,t){return t instanceof Ys?e.findIndex((function(e){return e instanceof Ys&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},xv=function(e,t){return e.findIndex((function(e){return e instanceof Ws?e.messageId===t:e instanceof co?e.notificationId===t:void 0}))},Sv=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(i<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(cp||(cp={}));var Tv=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t))._state=cp.IDLE,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=a,i}return c(t,e),i(t,[{key:"isIdle",get:function(){return this._state===cp.IDLE}},{key:"isRunning",get:function(){return this._state===cp.RUNNING}},{key:"isDone",get:function(){return this._state===cp.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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:n=t.sent,this._retryCount=0,this.dispatch("progress",n),n.hasNext?this._run(n.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(E=_.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(y=u.range).intersect.apply(y,v(E)))?this.extendRange(_):this._metadata={range:new kv({top:Math.min.apply(Math,v(E)),bottom:Math.max.apply(Math,v(E))}),previousComplete:!1}),h.hasNext=_.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(h.nextToken=this._metadata.range.top,this._metadata.previousComplete=_.length0&&(y=f.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(_=o.range).intersect.apply(_,v(y)))?this.extendRange(f):this._metadata={range:new kv({top:Math.min.apply(Math,v(y)),bottom:Math.max.apply(Math,v(y))}),previousComplete:!1}),l.hasNext=f.length>=this._limit,this._metadata&&(l.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",l),n.next=15,this.saveMetadata();case 15:n.next=21;break;case 17:throw n.prev=17,n.t0=n.catch(4),m.debug("message background next sync error",n.t0),n.t0;case 21:return n.prev=21,g.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:s.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=p.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.finish(21);case 24:return n.abrupt("return",l);case 25:case"end":return n.stop()}}),n,this,[[4,17,21,24]])})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=_.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 kv({})}},{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,v(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,v(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{range:new kv(r.range),previousComplete:r.previousComplete}:{range:new kv({}),previousComplete:!1};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,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.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,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now(),i=es.of(this._iid),s=i.logger,o=i.sessionManager;i.cacheContext.localCacheEnabled&&o.session.hasSession&&(s.debug("message background sync resume()"),this._prevSyncLoopCount=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(){es.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 Iv[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n){return Iv[e]||(Iv[e]={}),Iv[e][n.url]||(Iv[e][n.url]=new t({_iid:e,channel:n})),Iv[e][n.url].ref++,Iv[e][n.url]}},{key:"clear",value:function(e,t){Iv[e]&&Iv[e][t]&&(Iv[e][t].close(),delete Iv[e])}}])}(),Av={},Mv=function(){function t(n){var a=this,i=n._iid,s=n.channel,o=n.includeParams;r(this,t),this.ref=0,this._iid=i,this._channel=s,this._includeParams=o;var u,c,l=es.of(this._iid),h=l.logger,f=l.sdkState,p=l.dispatcher;this._metadataKey=(u=f.userId,c=s.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var v=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(f.userId,this._channel.url);this._sync=new Tv(v,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,a=nh.of(this._iid),t.next=8,a.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:e.ReplyType.ALL},this._includeParams),e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,s=i.updatedMessages,o=i.deletedMessageIds,u=i.hasMore,c=i.token,r.hasNext=u,r.nextToken=c,(s.length>0||o.length>0)&&this._metadata&&(this._metadata.token=c),h.debug("message changelog sync progress",r),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),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",r);case 29:case"end":return t.stop()}}),t,this,[[4,21]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.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=es.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){es.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Av[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n,r){return Av[e]||(Av[e]={}),Av[e][n.url]||(Av[e][n.url]=new t({_iid:e,channel:n,includeParams:r})),Av[e][n.url].ref++,Av[e][n.url]}},{key:"clear",value:function(e,t){Av[e]&&Av[e][t]&&(Av[e][t].close(),delete Av[e])}}])}(),Ov={},Uv=function(){function e(t){var n=this,a=t._iid,i=t.channel,s=t.hasPollMessage;r(this,e),this.ref=0,this._iid=a,this._channel=i;var o,u,c=es.of(this._iid),l=c.logger,h=c.sdkState,f=c.dispatcher;this._metadataKey=(o=h.userId,u=i.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new Tv(p,(function(){return E(n,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o,u,c,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(l.debug("poll changelog sync from",null===(t=this._metadata)||void 0===t?void 0:t.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,s();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return r={hasNext:!1,nextToken:0},e.abrupt("return",r);case 12:return this._metadata||(a=es.of(this._iid),i=a.firstConnectedAt,this._metadata={token:i}),e.prev=13,o=Wc.of(this._iid),e.next=17,o.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return u=e.sent,c=u.hasMore,h=u.token,n.hasNext=c,n.nextToken=h,this._metadata.token=h,l.debug("poll changelog sync progress",n),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),l.debug("poll changelog sync error",e.t1),!(e.t1 instanceof 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",n);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)n.resume();else n.pause()}))}return i(e,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{token:r.token}:void 0;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){es.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){es.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 Ov[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Ov[t]||(Ov[t]={}),Ov[t][n.url]||(Ov[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Ov[t][n.url].ref++,Ov[t][n.url]}}])}(),Dv=function(t){function a(t){var i,s,o,u,c,l,d,h,f,p,v;return r(this,a),(i=n(this,a)).method=_e.GET,i.path="".concat(Le(t.channelType),"/").concat(t.channelUrl,"/messages_gap"),i.params=pe({prev_start_ts:t.prevStart,prev_end_ts:t.prevEnd,prev_cache_count:t.prevCount,next_start_ts:t.nextStart,next_end_ts:t.nextEnd,next_cache_count:t.nextCount,huge_gap_threshold:null!==(s=t.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(o=t.customTypes)&&void 0!==o?o:["*"],message_type:null!==(u=t.messageType)&&void 0!==u?u:null,include_reply_type:null!==(c=t.replyType)&&void 0!==c?c:e.ReplyType.NONE,include_reactions:null===(l=t.includeReactions)||void 0===l||l,include_meta_array:null===(d=t.includeMetaArray)||void 0===d||d,include_thread_info:null===(h=t.includeThreadInfo)||void 0===h||h,include_parent_message_info:null===(f=t.includeParentMessageInfo)||void 0===f||f,with_sorted_meta_array:null===(p=t.includeMetaArray)||void 0===p||p,show_subchannel_messages_only:null!==(v=t.showSubchannelMessagesOnly)&&void 0!==v&&v,include_poll_details:!0,checking_continuous_messages:t.checkingContinuousMessages}),i}return c(a,t),i(a)}(je),Rv=function(e){function t(e,a){var i,s,o,u,c,l,d;return r(this,t),(i=n(this,t,[e,a])).isHugeGap=a.is_huge_gap,i.prevMessages=(null!==(s=a.prev_messages)&&void 0!==s?s:[]).map((function(t){return ho(e,t)})),i.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,i.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,i.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return ho(e,t)})),i.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,i.isContinuousNextMessages=null!==(d=a.is_continuous_next_messages)&&void 0!==d&&d,i}return c(t,e),i(t)}(Ve),Lv={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var Pv,Fv,qv,Hv=function(){return i((function e(){r(this,e),this._onCacheResult=ht,this._onApiResult=ht}),[{key:"_invokeResponse",value:function(e,t,n){var r=this;hi((function(){return E(r,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next="local"===r.t0?3:"remote"===r.t0?5:7;break;case 3:return this._onCacheResult(t,n),r.abrupt("break",7);case 5:return this._onApiResult(t,n),r.abrupt("break",7);case 7:case"end":return r.stop()}}),r,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}])}(),Gv=function(){return i((function t(n,a){var i=this,o=a.filter,u=a.startingPoint,c=a.limit,l=a.prevResultLimit,h=a.nextResultLimit,f=a.channel,p=a.channelManager,_=a.disableBackgroundSync,m=void 0!==_&&_;r(this,t),this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=n,this._key="mc-".concat(ce()),this._isDisposed=!1,this.filter=null!=o?o:new Pd,this._channel=f,this._syncRange=new kv({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof u&&Number.isFinite(u)?u:Number.MAX_SAFE_INTEGER,this._limit=c||100,this._prevResultLimit=null!=l?l:Math.floor(this._limit/2),this._nextResultLimit=null!=h?h:Math.floor(this._limit/2),this._channelManager=p;var g=es.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(t,n){var r=n.source,a=t.findIndex((function(e){return e.isIdentical(i.channel)}));a>=0&&(i._replaceChannelOfCollection(t[a]),i.channel._runIfHandleableWithGroupChannel((function(t){switch(r){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:for(var a=!1,s=0;s=t.messageOffsetTimestamp){a=!0;var o=s;if(o>0){var u=i._messages.splice(0,o);i._removeMessagesFromView(u.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!a&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.CollectionEventSource.EVENT_CHANNEL_UNMUTED:var c=es.of(i._iid).sdkState,l=n.user;c.userId===l.userId&&i._clearCheckMyMutedTimer();break;case e.CollectionEventSource.EVENT_CHANNEL_MUTED:var h=es.of(i._iid).sdkState,f=n.user;h.userId===f.userId&&-1!==t._myMutedRemainingTime&&i._startCheckMyMutedTimer(t._myMutedRemainingTime);break;case e.CollectionEventSource.EVENT_CHANNEL_LEFT:t.isPublic&&i._clearCheckMyMutedTimer()}hi((function(){return E(i,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:mp(r)&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelUpdated)&&this._handler.onChannelUpdated(n,this.channel);case 1:case"end":return e.stop()}}),e,this)})))}))})),i._postprocessChannelUpdateEvent(t[a],r))},onRemove:function(e,t){var n=e.indexOf(i.channel.url);n>=0&&(i._clearCheckMyMutedTimer(),hi((function(){return E(i,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url);case 1:case"end":return e.stop()}}),e,this)})))})),i._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],o=[],u=s(t);try{for(u.s();!(r=u.n()).done;){var c=r.value;c.channelUrl===i._channel.url&&(i.filter.match(c)?a.push(c):o.push(i.keyOf(c)))}}catch(e){u.e(e)}finally{u.f()}if(Ms(n)){if(a.length>0)switch(n){case e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.CollectionEventSource.EVENT_MESSAGE_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.CollectionEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}o.length>0&&i._removeMessagesFromView(o,n)}i._postprocessMessageUpdateEvent(t,n)},onRemove:function(e,t){i._removeMessagesFromView(e,t),i._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:function(e,t){i._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){i._applyThreadInfoEventToView(e,t)}});var y=es.of(this._iid),k=y.cacheContext,b=y.dispatcher,C=y.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),b.dispatch(new gp({channels:[this._channel],context:{source:e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Nv.of(this._iid,this._channel),!m&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=Mv.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Uv.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Tv(this._key,(function(t){return E(i,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,C.run("message-fill-sync-".concat(f.url,"-prev"),(function(){return E(r,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._getRemoteMessages(t,{prevLimit:this._prevResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:k.localCacheEnabled});case 2:if(s=n.sent,o=s.messages,u=s.isContinuousMessages,!(o.length>0)){n.next=10;break}return c=Math.min.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:o.length>=this._prevResultLimit&&this.viewTop0)){n.next=10;break}return c=Math.max.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:!(o.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>c,nextToken:this._syncRange.bottom});case 10:return k.localCacheEnabled&&g.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=k.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:k.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.abrupt("return",{hasNext:!1,nextToken:0});case 12:case"end":return n.stop()}}),n,this)})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=b.on((function(e){if(e instanceof La)switch(e.stateType){case Aa.CONNECTED:fi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._activate();case 1:case"end":return e.stop()}}),e,this)})))}));break;case Aa.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}}))}),[{key:"keyOf",value:function(e){return 0}},{key:"changelogIncludeParams",get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}},{key:"_postprocessChannelUpdateEvent",value:function(e,t){}},{key:"_postprocessChannelRemoveEvent",value:function(e){}},{key:"_postprocessMessageUpdateEvent",value:function(e,t){}},{key:"_postprocessMessageRemoveEvent",value:function(e){}},{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return v(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,v(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,v(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"_activate",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),n.logger.debug("check huge gap"),this._checkHugeGap(),t.next=5,this._refreshChannel(e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_replaceChannelOfCollection",value:function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}},{key:"_shouldStartBackgroundSync",value:function(){var e=es.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}},{key:"_setBaseMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n instanceof Ws&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,t){var n,r=this,a=[],i=s(e);try{for(i.s();!(n=i.n()).done;){var o=n.value,u=xv(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c.isUserMessage()&&c.applyPoll(o),a.push(c)}}}catch(e){i.e(e)}finally{i.f()}return a.length>0&&Ms(t)&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},a.length>0&&(null===(r=(n=this._handler).onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,a));case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_applyPollUpdateEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollUpdateEvent(e)&&Ms(t)&&hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollVoteEvent(e)&&Ms(t)&&hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyReactionEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ms(t)&&(a.applyReactionEvent(e),hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_applyThreadInfoEventToView",value:function(e,t){var n=this,r=xv(this._messages,e.targetMessageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ms(t)&&(a.applyThreadInfoUpdateEvent(e),hi((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_removeMessagesFromView",value:function(e,t){var n,r=this,a=[],i=[],o=s(e);try{var u=function(){var e=n.value,t=r._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var s=r._messages[t];a.push(r.keyOf(s)),i.push(s),r._messages.splice(t,1)}};for(o.s();!(n=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return Ms(t)&&i.length>0&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===r||r.call(n,s,this.channel,a,i);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,t){var n=t.prevLimit,r=void 0===n?0:n,a=t.nextLimit,i=void 0===a?0:a,s=t.inclusive,o=void 0===s||s;return E(this,void 0,void 0,d().mark((function t(){var n,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!o){t.next=5;break}return t.next=4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter);case 4:n=t.sent;case 5:if(!(r>0)){t.next=11;break}return t.next=8,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r,!1);case 8:t.t0=t.sent,t.next=12;break;case 11:t.t0=[];case 12:if(a=t.t0,!(i>0)){t.next=19;break}return t.next=16,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,i,!1);case 16:t.t1=t.sent,t.next=20;break;case 19:t.t1=[];case 20:return s=t.t1,t.abrupt("return",{messages:[].concat(v(n),v(a),v(s)).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:a.length,nextMessagesCount:s.length});case 22:case"end":return t.stop()}}),t,this)})))}},{key:"_getRemoteMessages",value:function(t,n){var r=n.prevLimit,a=void 0===r?0:r,i=n.nextLimit,s=void 0===i?0:i,o=n.source,u=void 0===o?e.CollectionEventSource.REQUEST_MESSAGE:o,c=n.reverse,l=void 0!==c&&c,h=n.checkingHasNext,f=void 0!==h&&h,p=n.checkingContinuousMessages,v=void 0!==p&&p;return E(this,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=nh.of(this._iid),!(a>0||s>0)){e.next=7;break}return e.next=4,n._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,t,ve(Object.assign(Object.assign(Object.assign({},this.filter),Lv),{isInclusive:!0,reverse:l,prevResultSize:a,nextResultSize:s})),u,f,v);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 t,n,r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,_,m,g,y,k,b,C,w,x,S,T,I,N,M,O,U,D=this;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(o=es.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=o.cacheContext,h=o.statManager,f=o.logger,!(this._messages.length>0)){s.next=25;break}return p=this._syncRange.top,_=this.viewTop,m=this._syncRange.bottom,g=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,s.next=8,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,_,p);case 8:return y=s.sent,s.next=11,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,m,g);case 11:return k=s.sent,s.prev=12,s.next=15,yi((function(){return E(D,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,h,f,b,C,w,x,S,T,I,N,A,M=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Dv(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:_,prevEnd:p,prevCount:y,nextStart:m,nextEnd:g,nextCount:k,checkingContinuousMessages:l.localCacheEnabled},this.filter),Lv)),t.next=3,c.send(r);case 3:a=t.sent,i=a.as(Rv),s=i.isHugeGap,o=i.prevMessages,h=void 0===o?[]:o,f=i.prevHasMore,b=i.isContinuousPrevMessages,C=i.nextMessages,w=void 0===C?[]:C,x=i.nextHasmore,S=i.isContinuousNextMessages,s?hi((function(){return E(M,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this._handler)||void 0===t?void 0:t.onHugeGapDetected)&&this._handler.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(T=this.viewTop,I=this.viewBottom,N=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,T].concat(v(h.map((function(e){return e.createdAt}))))),A=Math.max.apply(Math,[0,I].concat(v(w.map((function(e){return e.createdAt}))))),u.dispatch(new Os({messages:h,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),u.dispatch(new Os({messages:w,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(N,A),(b||S)&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(N,A)),f&&this._prevFill.start(N),x&&this._nextFill.start(A));case 6:case"end":return t.stop()}}),t,this)})))}),1);case 15:s.next=20;break;case 17:s.prev=17,s.t0=s.catch(12),f.debug("Failed HugeGap Check ",s.t0);case 20:return s.prev=20,l.localCacheEnabled&&h.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(t=l.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(20);case 23:s.next=42;break;case 25:return b=Date.now(),s.prev=26,s.next=29,this._getRemoteMessages(b,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled});case 29:if(C=s.sent,w=C.messages,x=C.isContinuousMessages,S=C.hasNext,w.length>0){for(I=w.map((function(e){return e.createdAt})),N=0,M=0,O=0;O=b&&M++;this._hasPrevious=N>=this._prevResultLimit,this._hasNext=null!=S?S:M>=this._nextResultLimit,(T=this._syncRange).extends.apply(T,v(I)),x&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(w,e.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;s.next=39;break;case 36:s.prev=36,s.t1=s.catch(26),s.t1 instanceof A&&s.t1.code===e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 39:return s.prev=39,l.localCacheEnabled&&h.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=l.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(39);case 42:case"end":return s.stop()}}),s,this,[[12,17,20,23],[26,36,39,42]])})))}},{key:"_loadUnsentMessages",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter);case 2:this._unsentMessages=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1);case 2:if(!(e.sent.length>0)){e.next=5;break}return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.logger,n.prev=1,n.next=4,this._channelManager.refreshChannel(this.channel.url,!0,e,t);case 4:n.next=9;break;case 6:n.prev=6,n.t0=n.catch(1),a.warn("Failed to refresh channel",n.t0);case 9:case"end":return n.stop()}}),n,this,[[1,6]])})))}},{key:"_startCheckMyMutedTimer",value:function(t){var n=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=void 0,n=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:r=t.sent,n=!r.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),n=!0;case 12:return t.prev=12,n&&(a=es.of(this._iid),i=a.sessionManager,this.channel._runIfHandleableWithGroupChannel((function(t){var n,r;t.myMutedState=e.MutedState.UNMUTED;var a={source:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i.currentUser};null===(r=null===(n=s._handler)||void 0===n?void 0:n.onChannelUpdated)||void 0===r||r.call(n,a,s.channel)}))),t.finish(12);case 15:case"end":return t.stop()}}),t,this,[[2,9,12,15]])})))}),t+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}},{key:"_setHasNextAndHasPrevious",value:function(e,t){for(var n=e.map((function(e){return e.createdAt})),r=0,a=0,i=0;ithis._startingPoint&&a++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=t?t:a>=this._nextResultLimit}},{key:"initialize",value:function(t){var n=this,r=new Hv;this._messages=[],this._unsentMessages=[],this._syncRange=new kv({}),this._hasNext=!0,this._hasPrevious=!0;var a=[],i={messages:[],prevMessagesCount:0,nextMessagesCount:0};return hi((function(){return E(n,void 0,void 0,d().mark((function n(){var s,o,u,c,l,h=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,null===(s=this._backgroundSync)||void 0===s?void 0:s.loadMetadata();case 2:o=n.sent,u=es.of(this._iid),c=u.cacheContext,l=u.statManager,n.t0=t,n.next=n.t0===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API?7:9;break;case 7:return this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(t){return E(h,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=t,a=this._filterUnderOffsetMessage(i.messages),this._addMessagesToView(a,e.CollectionEventSource.REQUEST_MESSAGE),n.next=5,this._loadUnsentMessages();case 5:r._invokeResponse("local",null,a);case 6:case"end":return n.stop()}}),n,this)})))})).catch((function(e){if(N(e))throw e;r._invokeResponse("local",e,null)})).finally((function(){return E(h,void 0,void 0,d().mark((function n(){var s,u,c,h,f,p,_,m,g=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return c=es.of(this._iid),h=c.cacheContext,f=!0,p=!0,_=!1,h.localCacheEnabled&&a.length>0&&(m=o.range).includes.apply(m,v(a.map((function(e){return e.createdAt}))))&&(!o.previousComplete&&i.prevMessagesCounto.range.bottom||i.nextMessagesCount=e._latestMessageInfo.createdAt&&(p=!1)})),p?(f=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled}).then((function(t){var n,a,i,s=t.messages,o=t.isContinuousMessages,u=t.hasNext,c=g._filterUnderOffsetMessage(s);(g._messages=[],c.length>0)?(g._setHasNextAndHasPrevious(c,u),(i=g._syncRange).extends.apply(i,v(c.map((function(e){return e.createdAt})))),o&&(null===(n=g._backgroundSync)||void 0===n?void 0:n.range.overlap(g._syncRange))&&(null===(a=g._backgroundSync)||void 0===a||a.range.extends(g._syncRange.top,g._syncRange.bottom)),g._addMessagesToView(c,e.CollectionEventSource.REQUEST_MESSAGE)):(g._hasPrevious=!1,g._hasNext=!1);r._invokeResponse("remote",null,c)})).catch((function(e){if(N(e))throw e;r._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(a),r._invokeResponse("remote",null,a)),h.localCacheEnabled&&l.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:f?"cache_hit":"cache_miss",max_db_size:null!==(u=null===(s=h.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==u?u:0,message_init_policy:t,use_local_cache:h.localCacheEnabled,collection_id:this._key}}));case 10:case"end":return n.stop()}}),n,this)})))})),n.abrupt("break",9);case 9:l.put(new Bi({type:Ge.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message_init_policy:t,message:!0}}}));case 10:case"end":return n.stop()}}),n,this)})))})),r}},{key:"loadPrevious",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=es.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasPrevious){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingPrevious){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingPrevious=!0,c=this.viewTop,l=[],a.next=13,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{prevLimit:this._prevResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._prevResultLimit,s.localCacheEnabled&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=es.of(this._iid),s=i.cacheContext,e.next=3,this._getRemoteMessages(c,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:s.localCacheEnabled});case 3:u=e.sent,(l=this._filterUnderOffsetMessage(u.messages)).length>0&&((h=this._syncRange).extends.apply(h,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&u.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top))),l=l.filter((function(e){return wv(p._messages,e)<0})),this._hasPrevious=l.length>=this._prevResultLimit,f&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(r=s.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasPrevious=l.length>=this._prevResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingPrevious=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"loadNext",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=es.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasNext){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingNext){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingNext=!0,c=this.viewBottom,l=[],a.next=13,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{nextLimit:this._nextResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._nextResultLimit,s.localCacheEnabled&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,fi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p,_=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=es.of(this._iid),u=s.cacheContext,e.next=3,this._getRemoteMessages(c,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:u.localCacheEnabled});case 3:h=e.sent,(l=this._filterUnderOffsetMessage(h.messages)).length>0&&((p=this._syncRange).extends.apply(p,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.bottom))),l=l.filter((function(e){return wv(_._messages,e)<0})),this._hasNext=null!==(r=h.hasNext)&&void 0!==r?r:l.length>=this._nextResultLimit,f&&o.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(i=null===(a=u.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:u.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasNext=l.length>=this._nextResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingNext=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"removeFailedMessage",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:return n.next=4,this._channelManager.removeFailedMessageFromCache(t);case 4:(r=this._unsentMessages.findIndex((function(e){return e.reqId===t})))>-1&&this._unsentMessages.splice(r,1);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=this;if(!this._isDisposed){this._isDisposed=!0;var i=es.of(this._iid),s=i.cacheContext,o=i.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(t){t.myMemberState!==e.MemberState.NONE&&(a._channel._updateMessageCollectionLastAccessedAt(),o.dispatch(new gp({channels:[a._channel],context:{source:e.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}}])}(),jv=function(t){function a(e,t){return r(this,a),n(this,a,[e,Object.assign(Object.assign({},t),{channelManager:Cv.of(e)})])}return c(a,t),i(a,[{key:"keyOf",value:function(e){return e.messageId}},{key:"initialize",value:function(e){var t=this;return fi((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),p(a,"initialize",this,3)([e])}},{key:"setMessageCollectionHandler",value:function(e){this._setBaseMessageCollectionHandler(e)}},{key:"_activate",value:function(){var e=this,t=Object.create(null,{_activate:{get:function(){return p(a,"_activate",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t._activate.call(this);case 2:return e.next=4,fi((function(){return E(n,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_addMessagesToView",value:function(t,n){var r,a=this,i=this._filterUnderOffsetMessage(t),o=[],u=[],c=s(i);try{for(c.s();!(r=c.n()).done;){var l=r.value;if(n===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(wv(this._messages,l)<0){wv(this._unsentMessages,l)<0&&o.push(l);var h=Sv(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ys){wv(this._unsentMessages,l)<0&&wv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var f=wv(this._messages,l);if(f<0){var p=wv(this._unsentMessages,l);p<0?o.push(l):(this._unsentMessages.splice(p,1),u.push(l));var _=Sv(this._messages,l);this._messages.splice(_,0,l)}else u.push(l),this._messages[f]=l;if(l.updatedAt>0){var m=this._updateChildMessagesInView(l);u.push.apply(u,v(m))}}else if(l instanceof Ys){var g=wv(this._unsentMessages,l);g<0?wv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[g]=l)}}}catch(e){c.e(e)}finally{c.f()}Ms(n)&&hi((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:n},o.length>0&&(null===(r=null===(t=this._handler)||void 0===t?void 0:t.onMessagesAdded)||void 0===r||r.call(t,s,this.channel,o)),u.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateMessagesToView",value:function(e,t){var n,r=this,a=[],i=[],o=[],u=s(e);try{for(u.s();!(n=u.n()).done;){var c=n.value;if(c.messageId>0){var l=wv(this._messages,c);if(l>=0)i.push(c),this._messages[l]=c;else{var h=wv(this._unsentMessages,c);if(h>=0){var p=f(this._unsentMessages.splice(h,1),1)[0];if(this.hasNext&&p)o.push(p);else{i.push(c);var _=Sv(this._messages,c);this._messages.splice(_,0,c)}}else{var m=this._messages.map((function(e){return e.createdAt}));(c.createdAtMath.max.apply(Math,v(m))&&!this._hasNext)&&a.push(c)}}}else if(c instanceof Ys){var g=wv(this._unsentMessages,c);g>=0&&(i.push(c),this._unsentMessages[g]=c)}}}catch(e){u.e(e)}finally{u.f()}return Ms(t)&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c={source:t},i.length>0?null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,c,this.channel,i):o.length>0?null===(u=null===(s=this._handler)||void 0===s?void 0:s.onMessagesDeleted)||void 0===u||u.call(s,c,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t);case 2:case"end":return e.stop()}}),e,this)})))})),i}}])}(Gv),Vv={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},zv=function(e){return D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isDiscoverable,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},Bv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,d=e.nicknameStartsWithFilter,h=e.operatorFilter;return(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/members"),a.params={token:s,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:d,operator_filter:h,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return c(t,e),i(t)}(je),Kv=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).members=[];var s=a.next,o=a.members;return i.token=s,o&&o.length>0&&(i.members=o.map((function(t){return new Zf(e,t)}))),i}return c(t,e),i(t)}(Ve);e.MutedMemberFilter=void 0,(Pv=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",Pv.MUTED="muted",Pv.UNMUTED="unmuted",e.MemberListOrder=void 0,(Fv=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",Fv.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(qv=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",qv.JOINED="joined_only",qv.INVITED="invited_only",qv.INVITED_BY_FRIEND="invited_by_friend",qv.INVITED_BY_NON_FRIEND="invited_by_non_friend";var Qv,Wv,Yv=function(t){function a(t,i,s){var o,u,c,l,d;return r(this,a),(o=n(this,a,[t,i,e.ChannelType.GROUP,s])).mutedMemberFilter=e.MutedMemberFilter.ALL,o.memberStateFilter=e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null,o.operatorFilter=e.OperatorFilter.ALL,o.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o.mutedMemberFilter=null!==(u=s.mutedMemberFilter)&&void 0!==u?u:e.MutedMemberFilter.ALL,o.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,o.order=null!==(d=s.order)&&void 0!==d?d:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R(e.MutedMemberFilter,this.mutedMemberFilter)&&R(e.MemberStateFilter,this.memberStateFilter)&&(D("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&R(e.OperatorFilter,this.operatorFilter)&&R(e.MemberListOrder,this.order)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new Bv(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Kv),s=i.members,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),Zv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/accept"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(je),Xv=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).channel=new E_(t,i),s.channel.myMemberState=e.MemberState.JOINED,s}return c(a,t),i(a)}(Ve),Jv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,d=e.accessCode,h=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a.params=pe({is_distinct:s,is_public:o,is_discoverable:u,name:h,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:d,operator_ids:v,message_survival_seconds:_}),a}return c(t,e),i(t)}(je),$v=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new E_(e,a),i}return c(t,e),i(t)}(Ve),e_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(je),t_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a}return c(t,e),i(t)}(je),n_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.countPreference;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:o},a}return c(t,e),i(t)}(je),r_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).countPreference=a.count_preference,i}return c(t,e),i(t)}(Ve),a_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.locale;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/reset_user_history"),a.params=pe({locale:s}),a}return c(t,e),i(t)}(je),i_=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(Ve),s_=Object.assign(Object.assign({},nu),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),o_=function(e){return ru(e)&&D("number",e.scheduledAt,!0)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},u_=Object.assign(Object.assign({},au),{scheduledAt:void 0}),c_=function(e){return iu(e)&&D("number",e.scheduledAt,!0)},l_=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl,d=t.scheduledMessageId;return i.method=_e.PUT,i.path="".concat(Le(c),"/").concat(encodeURIComponent(l),"/scheduled_messages/").concat(encodeURIComponent(d)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return ns.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(je),d_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new fo(e,a),i}return c(t,e),i(t)}(Ve),h_=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.PUT,i.path="".concat(Le(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return vs.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ds.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(je),f_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.DELETE,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(je),p_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.POST,a.path="".concat(Le(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return c(t,e),i(t)}(je),v_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:o},a}return c(t,e),i(t)}(je),__=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(Ve),m_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(je),g_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(Ve);e.CountPreference=void 0,(Qv=e.CountPreference||(e.CountPreference={})).ALL="all",Qv.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Qv.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Qv.OFF="off",e.HiddenState=void 0,(Wv=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",Wv.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Wv.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var y_,E_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y,E,k,b,C,w,x,S,T;(r(this,a),(s=n(this,a,[t,i]))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s._hasBotInfo={general:!1,ai:!1},s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isChatNotification=!1,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.totalUnreadReplyCount=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.lastPinnedMessage=null,s._latestMessageInfo=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(o=i.is_distinct)&&void 0!==o&&o,s.isSuper=null!==(u=i.is_super)&&void 0!==u&&u,s.isBroadcast=null!==(c=i.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=i.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(d=i.is_public)&&void 0!==d&&d,s.isDiscoverable=null!==(h=i.is_discoverable)&&void 0!==h?h:s.isPublic,s.isChatNotification=null!==(f=i.is_chat_notification)&&void 0!==f&&f,s.isAccessCodeRequired=null!==(p=i.is_access_code_required)&&void 0!==p&&p,s.isPushEnabled=null!==(_=i.is_push_enabled)&&void 0!==_&&_,Array.isArray(i.members))&&(T=s.members).push.apply(T,v(i.members.map((function(e){return new Zf(s._iid,e)}))));return s.memberCount=null!==(m=i.member_count)&&void 0!==m?m:0,s.joinedMemberCount=null!==(g=i.joined_member_count)&&void 0!==g?g:0,s.hiddenState=R(e.HiddenState,i.hidden_state)?i.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(y=i.ts_message_offset)&&void 0!==y?y:0,s.messageSurvivalSeconds=null!==(E=i.message_survival_seconds)&&void 0!==E?E:-1,s.lastMessage=i.last_message?ho(s._iid,Object.assign({channel_type:s.channelType},i.last_message)):null,i.read_receipt&&Object.keys(i.read_receipt).forEach((function(e){D("number",i.read_receipt[e])&&s._updateUnreadMemberState(e,i.read_receipt[e])})),i.delivery_receipt&&Object.keys(i.delivery_receipt).forEach((function(e){D("number",i.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,i.delivery_receipt[e])})),s.myMemberState=R(e.MemberState,i.member_state)?i.member_state:e.MemberState.NONE,s.myRole=R(e.Role,i.my_role)?i.my_role:e.Role.NONE,R(e.MutedState,i.is_muted)?s.myMutedState=i.is_muted:D("boolean",i.is_muted)?s.myMutedState=i.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=R(e.CountPreference,i.count_preference)?i.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=R(e.PushTriggerOption,i.push_trigger_option)?i.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=i.user_last_read)&&void 0!==k?k:0,s.inviter=i.inviter?new si(s._iid,i.inviter):null,s.invitedAt=null!==(b=i.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(C=i.joined_ts)&&void 0!==C?C:0,s._updateUnreadCount(null!==(w=i.unread_message_count)&&void 0!==w?w:0,null!==(x=i.unread_mention_count)&&void 0!==x?x:0),s.totalUnreadReplyCount=null!==(S=i.total_unread_thread_message_count)&&void 0!==S?S:0,s.lastPinnedMessage=i.latest_pinned_message?ho(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,i.latest_message&&(s._latestMessageInfo={messageId:i.latest_message.message_id,createdAt:i.latest_message.created_at}),s._hasBotInfo={general:!!i.has_bot,ai:!!i.has_ai_bot},s}return c(a,t),i(a,[{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=s(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=s(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"hasBot",get:function(){return this._hasBotInfo.general}},{key:"hasAiBot",get:function(){return this._hasBotInfo.ai}},{key:"_shouldUpdateLastMessageWith",value:function(t){if(t.silent)return!1;var n=es.of(this._iid).appInfo;switch(null==n?void 0:n.lastMessageThreadingPolicy){case e.LastMessageThreadingPolicy.NONE:case e.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case e.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(t.parentMessageId>0)return!1;break;case e.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof Ys&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case e.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof Ys&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}},{key:"_updateLastMessage",value:function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}},{key:"_updateUnreadCount",value:function(t,n){if("number"==typeof t&&t>=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=es.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=es.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return ni(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new jv(this._iid,Object.assign(Object.assign({},e),{channel:this}))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Yv(this._iid,this.url,e)}},{key:"createThreadedParentMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ph(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 Zf?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 Ys&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=es.of(this._iid).sdkState,a=t.createdAt,i=0,o=s(this.members);try{for(o.s();!(n=o.n()).done;){var u=n.value;if(r.userId!==u.userId&&u.state===e.MemberState.JOINED&&t.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=es.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ys?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o>=e.createdAt&&i.push(s)}})),i}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=es.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ys?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o0&&void 0!==arguments[0]&&arguments[0],n=es.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 i=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new gs(e._iid,{channel_url:e.url,channel_type:e.channelType,user:Zf.payloadify(a),ts:null!=i?i:0})}})),r}},{key:"getDeliveryStatus",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=es.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 i=e._undeliveredMemberStateMap.get(a.userId);r[a.userId]=new Xf(e._iid,{channel_url:e.url,channel_type:e.channelType,user:Zf.payloadify(a),ts:null!=i?i: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=es.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,i){var s=a.ts;n-s>=t&&(e._typingStatus.delete(i),r=!0)})),r}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._refresh());case 1:case"end":return e.stop()}}),e,this)})))}},{key:"_refresh",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Cp({channelUrl:this.url}),n.next=4,a.send(s);case 4:return o=n.sent,u=o.as(wp),c=u.channel,this._update(c),t||i.dispatch(new gp({channels:[c],context:{source:e.CollectionEventSource.REFRESH_CHANNEL}})),n.abrupt("return",this);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"freeze",value:function(){var t=this,n=Object.create(null,{freeze:{get:function(){return p(a,"freeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.freeze.call(this);case 2:r=es.of(this._iid),r.dispatcher.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"unfreeze",value:function(){var t=this,n=Object.create(null,{unfreeze:{get:function(){return p(a,"unfreeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.unfreeze.call(this);case 2:r=es.of(this._iid),r.dispatcher.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannel",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Vv),t),ai(zv(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new Jv(Object.assign({channelUrl:this.url},r)),n.next=6,s.send(o);case 6:return u=n.sent,c=u.as($v),l=c.channel,this._update(l),i.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(e.every((function(e){return e instanceof si}))).throw(A.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"inviteWithUserIds",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(P("string",t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.requestQueue,s=r.sessionManager,o=new Wp({channelUrl:this.url,userIds:t}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.as(Yp),l=c.channel,this._update(l),a.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:s.currentUser,invitees:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"join",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",t,!0)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Vp({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(zp),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"leave",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=es.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Kp({channelUrl:this.url,userId:a.userId,shouldRemoveOperatorStatus:t}),n.next=4,i.send(s);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return n.stop()}}),n,this)})))}},{key:"acceptInvitation",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",t,!0)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Zv({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(Xv),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new gp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"declineInvitation",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Xp({channelUrl:this.url,userId:r.userId}),t.next=4,a.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"sendUserMessage",this,3)([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){s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),Cv.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"updateUserMessage",value:function(t,n){var r=this,i=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=es.of(this._iid),s=a.dispatcher,r.next=3,i.updateUserMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Cv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new gp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Cv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Os({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"_autoResendUserMessage",this,3)([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 a=Cv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"sendFileMessage",this,3)([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 a=Cv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new ol,i=es.of(this._iid).dispatcher;return p(a,"sendMultipleFilesMessage",this,3)([t]).onPending((function(e){r._trigger(e)})).onFailed((function(e,t){r._triggerFailed(e,t)})).onSucceeded((function(t){var a=Cv.of(n._iid);n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(t,n){var r=this,i=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=es.of(this._iid),s=a.dispatcher,r.next=3,i.updateFileMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Cv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new gp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Cv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Os({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new qo,i=es.of(this._iid).dispatcher,s=Uh.of(this._iid);return p(a,"_autoResendFileMessage",this,3)([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 a=Cv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new gp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"deleteMessage",value:function(t){var n=this,r=Object.create(null,{deleteMessage:{get:function(){return p(a,"deleteMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.deleteMessage.call(this,t);case 2:0===t.messageId&&t instanceof Ys&&(a=es.of(this._iid),a.dispatcher.dispatch(new Ls({reqId:t.reqId,source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"hide",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},$p),t),ai(ev(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new tv(Object.assign({channelUrl:this.url,userId:s.userId},r)),n.next=6,o.send(u);case 6:return c=n.sent,l=c.as(nv),h=l.messageOffsetTimestamp,this.hiddenState=r.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,r.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),i.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),n.abrupt("return",this);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"unhide",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new t_({channelUrl:this.url}),t.next=4,a.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,r.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new e_({channelUrl:this.url}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.sdkState,a=n.dispatcher,i=n.requestQueue,s=new ys({channelUrl:this.url}),t.next=4,i.send(s);case 4:o=t.sent,u=o.as(Es),c=u.readStatus,this._updateUnreadMemberState(r.userId,c.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Cv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)}))),a.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new vv({channelUrl:this.url,userId:n.userId}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=es.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingStarted>=r)){e.next=8;break}return this._typingStarted=a,this._typingEnded=0,i=new av({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=es.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingEnded>=r)){e.next=8;break}return this._typingStarted=0,this._typingEnded=a,i=new sv({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Hd),e),ai(function(e){return Qo(e)&&D("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new qo;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},u_),t),ai(c_(r)).throw(A.invalidParameters),a=es.of(this._iid),i=a.requestQueue,s=new h_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(_c),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createScheduledFileMessage",value:function(e){var t=this;e=Object.assign(Object.assign({},Gd),e),ai(function(e){return Go(e)&&D("number",e.scheduledAt)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(A.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new qo;return mi(2).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);hi((function(){return E(t,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a._trigger(i));case 1:case"end":return e.stop()}}),e)})))}))})),H(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a}},{key:"updateScheduledFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Object.assign(Object.assign({},s_),t),ai(o_(r)).throw(A.invalidParameters),!H(r.file)){n.next=5;break}return n.next=5,this._uploadFileAndUpdateParams(r);case 5:return a=new l_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),i=es.of(this._iid),s=i.requestQueue,n.next=9,s.send(a);case 9:return o=n.sent,u=o.as(d_),c=u.message,n.abrupt("return",c);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new f_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=es.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new p_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=es.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new m_({userId:n.userId,channelUrl:this.url}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(g_),o=s.pushTriggerOption,this.myPushTriggerOption=o,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new v_({userId:i.userId,channelUrl:this.url,pushTriggerOption:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(__),l=c.pushTriggerOption,this.myPushTriggerOption=l,a.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"setMyCountPreference",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(R(e.CountPreference,t)).throw(A.invalidParameters),r=es.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new n_({channelUrl:this.url,userId:i.userId,countPreference:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(r_),l=c.countPreference,this.myCountPreference=l,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),a.dispatch(new gp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"resetMyHistory",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=es.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=n.sdkState,s=new a_({channelUrl:this.url,locale:i.localeForChatbot}),t.next=4,a.send(s);case 4:return o=t.sent,u=o.as(i_),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,this.lastMessage&&this.lastMessage.createdAt=this._limit&&!!b,h.nextToken=b,this._metadata&&(this._metadata.token=b,(C=this._metadata.range).extends.apply(C,v(k.map((function(e){return e.createdAt})))),this._metadata.completed=!h.hasNext),f.debug("channel background sync progress",h),t.next=30,this.saveMetadata();case 30:t.next=39;break;case 32:if(t.prev=32,t.t1=t.catch(6),f.debug("channel background sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=38;break}return t.next=38,this.clearMetaData();case 38:throw t.t1;case 39:return t.prev=39,_.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(o=null===(s=p.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==o?o:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:null!==(c=null===(u=m.order)||void 0===u?void 0:u.toString())&&void 0!==c?c:"",collection_id:l.userId}})),t.finish(39);case 42:t.next=46;break;case 44:h.hasNext=!1,h.nextToken="";case 46:return t.abrupt("return",h);case 47:case"end":return t.stop()}}),t,this,[[6,32,39,42],[8,15]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 kv({})}},{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,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata={token:r?r.token:"",range:new kv(r?r.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!r&&r.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.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=es.of(this._iid),r=n.logger;n.sessionManager.session.hasSession&&(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(){es.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 k_[this._iid])}}],[{key:"of",value:function(e){return k_[e]||(k_[e]=new t({_iid:e})),k_[e].ref++,k_[e]}},{key:"clear",value:function(e){k_[e]&&(k_[e].close(),delete k_[e])}}])}(),C_={},w_=function(){function t(n){var a=this,i=n._iid;r(this,t),this.ref=0,this._iid=i;var s,o=es.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher,h=o.cacheContext,f=o.statManager;this._metadataKey=(s=c.userId,"sendbird:".concat(s,"@groupchannel/changelogs.meta")),this._subscribers=new de;var p=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(c.userId);this._sync=new Tv(p,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,l,p,v,_,m,g;return d().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 u.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,s={includeEmpty:!0,includeMetaData:!0},t.prev=6,t.next=9,h.preference.get(Ga(c.appId));case 9:o=t.sent,s.includeChatNotification=Boolean(o),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(6),s.includeChatNotification=!1;case 16:return l=Cv.of(this._iid),t.next=19,l.getMyGroupChannelChangeLogs(null!==(a=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==a?a:"",s,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 19:return p=t.sent,v=p.updatedChannels,_=p.deletedChannelUrls,m=p.hasMore,g=p.token,this._subscribers.dispatch("progress",{updatedChannels:v,deletedChannelUrls:_,hasMore:m,token:g}),i.hasNext=m,i.nextToken=g,this._metadata&&(this._metadata.token=g),u.debug("channel changelog sync progress",i),t.next=31,this.saveMetadata();case 31:h.localCacheEnabled&&f.put(new rt({type:Ge.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:v.length>0||_.length>0?"cache_miss":"cache_hit",max_db_size:v.length,use_local_cache:h.localCacheEnabled,starting_point:0,message_init_policy:_.length.toString(),collection_id:c.userId}})),t.next=41;break;case 34:if(t.prev=34,t.t1=t.catch(4),u.debug("channel changelog sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=40;break}return t.next=40,this.clearMetadata();case 40:throw t.t1;case 41:return t.abrupt("return",i);case 42:case"end":return t.stop()}}),t,this,[[4,34],[6,13]])})))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=l.on((function(e){if(e instanceof La)if(e.stateType===Aa.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"isRunning",get:function(){return this._sync.isRunning}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=es.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=es.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"on",value:function(e,t){return this._subscribers.on(e,t)}},{key:"resume",value:function(){es.of(this._iid).sessionManager.session.hasSession&&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 C_[this._iid])}}],[{key:"of",value:function(e){return C_[e]||(C_[e]=new t({_iid:e})),C_[e].ref++,C_[e]}},{key:"clear",value:function(e){C_[e]&&(C_[e].close(),delete C_[e])}}])}(),x_=function(t,n){var r,a,i,s;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!==(s=null===(i=t.lastMessage)||void 0===i?void 0:i.createdAt)&&void 0!==s?s:t.createdAt}},S_=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},T_=function(e,t,n){if(e.length>0){for(var r=S_(e,t),a=0,i=e.length-1,s=Math.floor((a+i)/2);a0)i=s,s=Math.floor((a+i)/2);else{if(!(o<0))return{place:s,oldPosition:r};a=s+1,s=Math.floor((a+i)/2)}}return{place:I_(e[s],t,n)>=0?s:s+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},I_=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(t.lastMessage&&n.lastMessage){var a=n.lastMessage.createdAt-t.lastMessage.createdAt;return 0===a?n.createdAt-t.createdAt:a}return 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 i=t.name.localeCompare(n.name);return 0===i?t.createdAt-n.createdAt:i;default:return 0}},N_=function(){return i((function t(n,a){var i=this,s=a.filter,o=void 0===s?new $f:s,u=a.order,c=void 0===u?e.GroupChannelListOrder.LATEST_LAST_MESSAGE:u,l=a.limit,h=void 0===l?100:l,f=a.includeChangesOnInitialLoad,p=void 0!==f&&f;r(this,t),this.channels=[],this._isInitialized=!1,this._iid=n,this._key="gcc-".concat(ce()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=o,this.order=c,this._hasMore=!0,this._token="",this._limit=h;var v=es.of(this._iid),_=v.sdkState,m=v.cacheContext,g=v.dispatcher;m.localCacheEnabled&&(this._backgroundSync=b_.of(n),this._backgroundSync.resume()),this._changelogSync=w_.of(n),this._changelogSync.resume(),Cv.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(mp(n)){var r=e.filter((function(e){return i.filter.match(e,_.userId)})),a=e.filter((function(e){return!i.filter.match(e,_.userId)})).map((function(e){return e.url}));r.length>0&&i._addChannelsToView(r,t),a.length>0&&i._removeChannelsFromView(a,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),g.on((function(e){e instanceof La&&(e.stateType===Aa.CONNECTED?i._isGetRemoteChannelsSucceeded||E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._revokeLoadMore();case 2:case"end":return e.stop()}}),e,this)}))):e.stateType===Aa.LOGOUT&&i.dispose())}))}),[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(t,n){var r,a=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=s(t);try{for(l.s();!(r=l.n()).done;){var h=r.value,f=S_(this.channels,h);f>=0&&this.channels.splice(f,1);var p=T_(this.channels,h,this.order).place;if(f<0)p===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(p,0,h));else switch(n.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&p===this.channels.length?c.push(h):(this.channels.splice(p,0,h),u.push(h));break;default:this.channels.splice(p,0,h),u.push(h)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var v,_=s(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=S_(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}mp(n.source)&&hi((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsAdded)&&this._handler.onChannelsAdded(n,o),u.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,u),c.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,c.map((function(e){return e.url})));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,t){var n,r=this,a=[],i=s(e);try{var o=function(){var e=n.value,t=r.channels.findIndex((function(t){return t.url===e}));t>=0&&(a.push(r.channels[t].url),r.channels.splice(t,1))};for(i.s();!(n=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return mp(t.source)&&a.length>0&&hi((function(){return E(r,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(t,a);case 1:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_getLocalChannels",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Cv.of(this._iid),n=this.channels.length>0?x_(this.channels[this.channels.length-1],this.order):null,e.next=4,t.getChannelsFromCache(n,this.filter,this.order,this._limit,n?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,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Cv.of(this._iid),e.next=3,t.getMyGroupChannels(this._token,ve(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);case 3:return n=e.sent,r=n.channels,a=n.token,this._token=a,this._hasMore=!!a,e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:n=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(n,{source:e.CollectionEventSource.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()}}),t,this,[[2,10]])})))}},{key:"loadMore",value:function(){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(r=null,!this._includeChangesOnInitialLoad||0!==this.channels.length){n.next=9;break}if(!this._changelogSync.isRunning){n.next=9;break}return n.next=7,new Promise((function(e){C._changelogSyncSubscriberContext=C._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}));case 7:r=n.sent,null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close();case 9:if(a=es.of(this._iid),i=a.cacheContext,o=a.connectionManager,u=a.statManager,this._isInitialized){n.next=16;break}if(this._isInitialized=!0,!i.localCacheEnabled){n.next=15;break}return n.next=15,this._backgroundSync.loadMetadata();case 15:u.put(new Bi({type:Ge.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}}));case 16:if(c=[],!this._hasMore){n.next=35;break}if(!i.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed){n.next=24;break}return n.next=21,fi((function(){return E(C,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:c=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 21:this._hasMore=c.length>=this._limit,n.next=34;break;case 24:return n.prev=24,n.next=27,this._getRemoteChannels();case 27:c=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=34;break;case 31:n.prev=31,n.t0=n.catch(24),this._isGetRemoteChannelsSucceeded=!1;case 34:this._addChannelsToView(c,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0);case 35:if(r){l=s(r.updatedChannels);try{for(l.s();!(h=l.n()).done;)f=h.value,(p=S_(c,f))>=0?c[p]=f:(v=T_(c,f,this.order),_=v.place,c.splice(_,0,f))}catch(e){l.e(e)}finally{l.f()}m=c.map((function(e){return e.url})),g=s(r.deletedChannelUrls);try{for(g.s();!(y=g.n()).done;)k=y.value,(b=m.indexOf(k))>=0&&(c.splice(b,1),m.splice(b,1))}catch(e){g.e(e)}finally{g.f()}}return n.abrupt("return",c);case 37:case"end":return n.stop()}}),n,this,[[24,31]])})))}},{key:"dispose",value:function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),Cv.of(this._iid).unsubscribeChannelEvent(this._key))}}])}(),A_=function(t){function a(t){var i;r(this,a);var s=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,d=t.channelNameContainsFilter,h=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,E=t.includeFrozen,k=t.includeMetaData;return(i=n(this,a)).method=_e.GET,i.path=ke,i.params=pe(ve({token:s,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:d,channel_urls:h,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:E,show_metadata:k})),i}return c(a,t),i(a)}(je),M_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new E_(e,t)}))),i.ts="number"==typeof u?u:0,i}return c(t,e),i(t)}(Ve);e.MembershipFilter=void 0,(y_=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",y_.JOINED="joined";var O_,U_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;return r(this,a),(s=n(this,a,[t,i])).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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=i.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(d=i.customTypesFilter)&&void 0!==d?d:null,s.customTypeStartsWithFilter=null!==(h=i.customTypeStartsWithFilter)&&void 0!==h?h:null,s.channelNameContainsFilter=null!==(f=i.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=i.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=i.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=i.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=i.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=i.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=i.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(E=i.order)&&void 0!==E?E:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter,!0)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter,!0)&&R(e.MembershipFilter,this.membershipFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicGroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=es.of(this._iid),r=n.requestQueue,a=new A_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(M_),o=s.channels,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(uu),D_=i((function e(){r(this,e),this.onUserMuted=ht,this.onUserUnmuted=ht,this.onUserBanned=ht,this.onUserUnbanned=ht,this.onChannelChanged=ht,this.onChannelDeleted=ht,this.onChannelFrozen=ht,this.onChannelUnfrozen=ht,this.onOperatorUpdated=ht,this.onChannelMemberCountChanged=ht,this.onMetaDataCreated=ht,this.onMetaDataUpdated=ht,this.onMetaDataDeleted=ht,this.onMetaCounterCreated=ht,this.onMetaCounterUpdated=ht,this.onMetaCounterDeleted=ht,this.onMessageReceived=ht,this.onMessageUpdated=ht,this.onMessageDeleted=ht,this.onMentionReceived=ht,this.onReactionUpdated=ht,this.onThreadInfoUpdated=ht})),R_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserJoined=ht,e.onUserLeft=ht,e.onUserReceivedInvitation=ht,e.onUserDeclinedInvitation=ht,e.onChannelHidden=ht,e.onUnreadMemberStatusUpdated=ht,e.onUndeliveredMemberStatusUpdated=ht,e.onTypingStatusUpdated=ht,e.onPollUpdated=ht,e.onPollVoted=ht,e.onPollDeleted=ht,e.onPinnedMessageUpdated=ht,e}return c(t,e),i(t)}(D_),L_=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(R_),P_=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,d=e.scheduledStatus;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ae),a.params=pe(ve({token:i,limit:s,reverse:u,channel_url:c,order:o,message_type:l,status:d})),a}return c(t,e),i(t)}(je),F_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).scheduledMessages=[];var s=a.next,o=a.scheduled_messages;return i.token=s,i.scheduledMessages=o.map((function(t){return ho(e,t)})),i}return c(t,e),i(t)}(Ve),q_=function(t){function a(t,i){var s,o,u,c,l,d;return r(this,a),(s=n(this,a,[t,i])).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(o=i.channelUrl)&&void 0!==o?o:null,s.order=null!==(u=i.order)&&void 0!==u?u:null,s.reverse=null!==(c=i.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=i.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(d=i.messageTypeFilter)&&void 0!==d?d:e.MessageTypeFilter.ALL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl,!0)&&(R(e.ScheduledMessageListOrder,this.order)||null===this.order)&&D("boolean",this.reverse)&&(P(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&R(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new P_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(F_),s=i.scheduledMessages,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(uu),H_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="groupChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new Cv(e,{sdkState:r,cacheContext:c,dispatcher:a,sessionManager:i,requestQueue:s,logger:o})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new N_(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new lv(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new U_(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new q_(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){ai(D("string",e)&&t instanceof L_).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){ai(D("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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},ip),t),ai(D("string",e)&&sp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},ip),t),ai(D("number",e)&&sp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},op),e),ai(up(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},rp),e),ai(ap(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.createChannel(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},rp),e),ai(ap(n)).throw(A.invalidParameters),n&&(n.isDistinct=!0),t.abrupt("return",this.createChannel(n));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithUserIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=Object.assign(Object.assign({},rp),{invitedUserIds:e,isDistinct:t,name:n,data:a,customType:i}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,s.abrupt("return",this.createChannel(o));case 3:case"end":return s.stop()}}),s,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:ai(P("string",e)).throw(A.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),t.next=3,this.getChannel(e);case 3:return n=t.sent,t.next=6,n.markAsDelivered();case 6:case"end":return t.stop()}}),t,this)})))}}])}(ts),G_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return c(t,e),i(t,[{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,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0: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)})),t.abrupt("return",n);case 3:case"end":return t.stop()}}),t)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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)})))}}])}(Ya),j_={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},V_=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&(D("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&D("boolean",e.isEphemeral,!0)},z_=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?we:Ce,"/").concat(encodeURIComponent(i)),a.params={show_pinned_messages:!0},a}return c(t,e),i(t)}(je),B_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new om(e,a),i}return c(t,e),i(t)}(Ve),K_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,d=e.isEphemeral;return(a=n(this,t)).method=_e.POST,a.path=Ce,a.params=pe(ve({channel_url:i,cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:d})),a}return c(t,e),i(t)}(je),Q_=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"ENTR",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(Qe),W_=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new si(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(jp),Y_=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"EXIT",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(Qe),Z_=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"EXIT",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new si(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(jp),X_={},J_=function(t){function a(t,i){var o;return r(this,a),(o=n(this,a,[t,Object.assign(Object.assign({},i),{channelType:e.ChannelType.OPEN})])).subscribeChannelEvent=ht,o.unsubscribeChannelEvent=ht,o.refreshChannel=function(){return E(o,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}}),e)})))},o._openChannelCache=new G_(t),o._openChannelHandlers=new Map,o._dispatcher.on((function(e){if(e instanceof Ke)o._handleEvent(e).catch((function(e){if(N(e)&&"foreground"===o._sdkState.appState)throw e}));else if(e instanceof La&&e.stateType===Aa.CONNECTED){var t,n=s(o._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),X_[t]||(X_[t]=o),o}return c(a,t),i(a,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=ri(e);return new om(this._iid,om.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._openChannelCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((r=n.n()).done){t.next=9;break}return a=r.value,t.next=7,this._openChannelCache.remove(a);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),n.e(t.t0);case 14:return t.prev=14,n.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"handlers",get:function(){return v(this._openChannelHandlers.values())}},{key:"_handleEvent",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,A,M,O,U,D,R,L,P,F,q,H,G,j,V,z,B,K,Q,W,Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue,ce,le,de,he,fe,pe,ve,_e,me,ge,ye,Ee,ke,be,Ce,we,xe,Se,Te,Ie,Ne,Ae,Me,Oe,Ue,De,Re,Le,Pe,Fe,qe,He,Ge,je=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,n.t0=t.code,n.next="MESG"===n.t0||"FILE"===n.t0||"ADMM"===n.t0||"BRDM"===n.t0?4:"MEDI"===n.t0||"FEDI"===n.t0||"AEDI"===n.t0?14:"DELM"===n.t0?26:"MRCT"===n.t0?33:"MTHD"===n.t0?40:"MCNT"===n.t0?47:"PEDI"===n.t0?75:"VOTE"===n.t0?83:"SYEV"===n.t0?91:174;break;case 4:if(r=null,"MESG"===t.code?r=t.as(ac):"FILE"===t.code?r=t.as(mo):"ADMM"!==t.code&&"BRDM"!=t.code||(r=t.as(fv)),!r){n.next=13;break}if(i=(a=r).message,o=a.isMentioned,i.channelType!==e.ChannelType.OPEN){n.next=13;break}return n.next=11,this.getChannel(i.channelUrl,!0);case 11:u=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(u.url)&&(r.onMessageReceived&&r.onMessageReceived(u,i),o&&r.onMentionReceived&&r.onMentionReceived(u,i))}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return n.abrupt("break",174);case 14:if(c=null,"MEDI"===t.code?c=t.as(sc):"FEDI"===t.code?c=t.as(uc):"AEDI"===t.code&&(c=t.as(pv)),!c){n.next=25;break}if(h=(l=c).message,f=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){n.next=25;break}return n.next=21,this.getChannel(h.channelUrl,!0);case 21:p=n.sent,v=!1,p.lastPinnedMessage&&p.lastPinnedMessage.messageId===h.messageId&&p.lastPinnedMessage.updatedAt0&&i.onMentionReceived&&i.onMentionReceived(p,h))}catch(e){r.e(e)}finally{r.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 25:return n.abrupt("break",174);case 26:if(_=t.as(lt),m=_.channelUrl,g=_.channelType,y=_.messageId,g!==e.ChannelType.OPEN){n.next=32;break}return n.next=30,this.getChannel(m,!0);case 30:k=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(k.url)&&r.onMessageDeleted&&r.onMessageDeleted(k,y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 32:return n.abrupt("break",174);case 33:if(b=t.as(mv),C=b.channelUrl,w=b.channelType,x=b.event,w!==e.ChannelType.OPEN){n.next=39;break}return n.next=37,this.getChannel(C,!0);case 37:S=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(S.url)&&r.onReactionUpdated&&r.onReactionUpdated(S,x)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 39:return n.abrupt("break",174);case 40:if(T=t.as(gv),(I=T.event).channelType!==e.ChannelType.OPEN){n.next=46;break}return n.next=44,this.getChannel(I.channelUrl,!0);case 44:A=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(A.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(A,I)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 46:return n.abrupt("break",174);case 47:M=t.as(yv),O=M.openChannelMemberCounts,U=[],D=s(O),n.prev=50,D.s();case 52:if((R=D.n()).done){n.next=61;break}return L=R.value,P=L.channelUrl,F=L.participantCount,q=L.updatedAt,n.next=57,this.getChannelFromCache(P);case 57:(H=n.sent)&&H._updateParticipantCount(F,q)&&U.push(H);case 59:n.next=52;break;case 61:n.next=66;break;case 63:n.prev=63,n.t1=n.catch(50),D.e(n.t1);case 66:return n.prev=66,D.f(),n.finish(66);case 69:if(!(U.length>0)){n.next=74;break}return n.next=72,this.upsertChannelsToCache(U);case 72:G=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(G)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 74:return n.abrupt("break",174);case 75:if(j=t.as(Ev),V=j.event,z=j.status,B=j.channelUrl,K=j.channelType,!B||K!==e.ChannelType.OPEN){n.next=82;break}return n.next=79,this.getChannel(B,!0);case 79:Q=n.sent,this._dispatcher.dispatch(new Fs({event:V,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),hi(z===to?function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(Q,V.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(Q,V)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 82:return n.abrupt("break",174);case 83:if(W=t.as(Oc),Y=W.event,Z=W.channelUrl,X=W.channelType,!Z||X!==e.ChannelType.OPEN){n.next=90;break}return n.next=87,this.getChannel(Z,!0);case 87:J=n.sent,this._dispatcher.dispatch(new qs({event:Y,source:e.CollectionEventSource.EVENT_POLL_VOTED})),hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(J,Y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 90:return n.abrupt("break",174);case 91:if($=t.as(jp),!(ee=$.event).isOpenChannelEvent){n.next=173;break}n.t2=ee.category,n.next=n.t2===Jf.CHANNEL_ENTER?96:n.t2===Jf.CHANNEL_EXIT?103:n.t2===Jf.CHANNEL_OPERATOR_UPDATE?110:n.t2===Jf.USER_CHANNEL_MUTE||n.t2===Jf.USER_CHANNEL_UNMUTE?118:n.t2===Jf.USER_CHANNEL_BAN||n.t2===Jf.USER_CHANNEL_UNBAN?125:n.t2===Jf.CHANNEL_FREEZE||n.t2===Jf.CHANNEL_UNFREEZE?132:n.t2===Jf.CHANNEL_DELETED?140:n.t2===Jf.CHANNEL_PROP_CHANGED?147:n.t2===Jf.CHANNEL_META_DATA_CHANGED?152:n.t2===Jf.CHANNEL_META_COUNTERS_CHANGED?161:n.t2===Jf.PINNED_MESSAGE_CHANGED?167:173;break;case 96:return n.next=98,this.getChannel(ee.channelUrl,!0);case 98:return te=n.sent,ne=t.as(W_),re=ne.participantCount,ae=ne.user,ie=te._updateParticipantCount(re,ee.ts),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(te,ae),ie&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(te)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 103:return n.next=105,this.getChannel(ee.channelUrl,!0);case 105:return se=n.sent,oe=t.as(Z_),ue=oe.participantCount,ce=oe.user,le=se._updateParticipantCount(ue,ee.ts),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(se,ce),le&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 110:return n.next=112,this.getChannel(ee.channelUrl,!0);case 112:return de=n.sent,he=t.as(uv),fe=he.operators,de.operators=fe,this.upsertChannelsToCache([de]),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(de,fe)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 118:return n.next=120,this.getChannel(ee.channelUrl,!0);case 120:return pe=n.sent,ve=ee.category===Jf.USER_CHANNEL_MUTE,_e=t.as(ve?Bu:Qu),me=_e.user,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ve?e.onUserMuted&&e.onUserMuted(pe,me):e.onUserUnmuted&&e.onUserUnmuted(pe,me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 125:return n.next=127,this.getChannel(ee.channelUrl,!0);case 127:return ge=n.sent,ye=ee.category===Jf.USER_CHANNEL_BAN,Ee=t.as(ye?Yu:Xu),ke=Ee.user,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ye?e.onUserBanned&&e.onUserBanned(ge,ke):e.onUserUnbanned&&e.onUserUnbanned(ge,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 132:return n.next=134,this.getChannel(ee.channelUrl,!0);case 134:return be=n.sent,Ce=t.as($u),we=Ce.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().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)})))})),n.abrupt("break",173);case 140:return n.next=142,this.getChannel(ee.channelUrl,!0);case 142:return xe=n.sent,n.next=145,this.removeChannelsFromCache([xe.url]);case 145:return hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(xe.url,xe.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 147:return n.next=149,this.getChannelWithoutCache(ee.channelUrl,!0);case 149:return Se=n.sent,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 152:return n.next=154,this.getChannel(ee.channelUrl,!0);case 154:return Te=n.sent,Ie=t.as(Au),Ne=Ie.created,Ae=Ie.updated,Me=Ie.deleted,Ne&&Te._upsertCachedMetaData(Ne,ee.ts),Ae&&Te._upsertCachedMetaData(Ae,ee.ts),Me&&Te._removeFromCachedMetaData(Me,ee.ts),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ne&&e.onMetaDataCreated&&e.onMetaDataCreated(Te,Ne),Ae&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Te,Ae),Me&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Te,Me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 161:return n.next=163,this.getChannel(ee.channelUrl,!0);case 163:return Oe=n.sent,Ue=t.as(Gu),De=Ue.created,Re=Ue.updated,Le=Ue.deleted,hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){De&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Oe,De),Re&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Oe,Re),Le&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Oe,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 167:return n.next=169,this.getChannel(ee.channelUrl,!0);case 169:return Pe=n.sent,Fe=t.as(dv),qe=Fe.pinnedMessageIds,He=Fe.latestPinnedMessage,(Ge=Fe.ts)>Pe._pinnedMessagesUpdatedAt&&(Pe.pinnedMessageIds=qe,Pe.lastPinnedMessage=He,Pe._pinnedMessagesUpdatedAt=Ge,this.upsertChannelsToCache([Pe]),hi((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Pe)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),hi((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(Pe)}));case 1:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",173);case 173:return n.abrupt("break",174);case 174:n.next=180;break;case 176:if(n.prev=176,n.t3=n.catch(0),!N(n.t3)){n.next=180;break}throw n.t3;case 180:case"end":return n.stop()}}),n,this,[[0,176],[50,63,66,69]])})))}},{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){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ai(D("string",e)).throw(A.invalidParameters),r=new z_({channelUrl:e,isInternalCall:t}),n.next=4,this._requestQueue.send(r);case 4:return a=n.sent,i=a.as(B_),s=i.channel,n.next=8,this.upsertChannelsToCache([s]);case 8:return n.abrupt("return",n.sent[0]);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},j_),e),ai(V_(n)).throw(A.invalidParameters),r=new K_(n),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(B_),s=i.channel,this.upsertChannelsToCache([s]),t.abrupt("return",s);case 9:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return X_[e]}}])}(hv),$_={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},em=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)},tm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ce,"/").concat(encodeURIComponent(i),"/participants"),a.params={token:s,limit:o},a}return c(t,e),i(t)}(je),nm=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).participants=[];var s=a.next,o=a.participants;return i.token=s,i.participants=o.map((function(t){return new Fo(e,t)})),i}return c(t,e),i(t)}(Ve),rm=function(t){function a(t,i,s){return r(this,a),n(this,a,[t,i,e.ChannelType.OPEN,s])}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new tm(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(nm),s=i.participants,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(cu),am=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a.params=pe(ve({cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l})),a}return c(t,e),i(t)}(je),im=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new om(e,a),i}return c(t,e),i(t)}(Ve),sm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(je),om=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i]))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(o=i.participant_count)&&void 0!==o?o:0,s.operators=Array.isArray(i.operators)?i.operators.map((function(e){return new si(t,e)})):[],s.lastPinnedMessage=i.latest_pinned_message?ho(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,s}return c(a,t),i(a,[{key:"serialize",value:function(){return ni(this)}},{key:"isOperator",value:function(e){return e instanceof si?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 rm(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=J_.of(this._iid),e.next=3,t.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Q_({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(W_),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),J_.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,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new Y_({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Z_),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),J_.of(this._iid).setExitedToCache(this),nh.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,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},$_),e),ai(em(n)).throw(A.invalidParameters),r=es.of(this._iid),a=r.requestQueue,i=new am(Object.assign({channelUrl:this.url},n)),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(im),u=o.channel,this._update(u),c=J_.of(this._iid),t.next=12,c.upsertChannelsToCache([u]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=Object.assign(Object.assign({},$_),{name:e,coverUrlOrImage:t,data:n,operatorUserIds:r,customType:a}),i.abrupt("return",this.updateChannel(s));case 2:case"end":return i.stop()}}),i,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es.of(this._iid),n=t.requestQueue,r=new sm({channelUrl:this.url}),e.next=4,n.send(r);case 4:return a=J_.of(this._iid),e.next=7,a.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"updateUserMessage",value:function(e,t){var n=this,r=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateUserMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&J_.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&J_.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFileMessage",value:function(e,t){var n=this,r=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateFileMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&J_.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&J_.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},vl.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return si.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?lo(e.lastPinnedMessage):null})))}}])}(vl),um=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserEntered=ht,e.onUserExited=ht,e.onChannelParticipantCountChanged=ht,e.onPollUpdated=ht,e.onPollVoted=ht,e.onPollDeleted=ht,e.onPinnedMessageUpdated=ht,e}return c(t,e),i(t)}(D_),cm=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(um),lm=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,d=e.includeMetaData;return(a=n(this,t)).method=_e.GET,a.path=Ce,a.params=pe({token:i,limit:s,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:d,show_pinned_messages:!0}),a}return c(t,e),i(t)}(je),dm=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return new om(e,t)}))),i.ts="number"==typeof u?u:null,i}return c(t,e),i(t)}(Ve),hm=function(e){function t(e,a){var i,s,o,u,c,l;return r(this,t),(i=n(this,t,[e,a])).includeFrozen=!0,i.includeMetaData=!0,i.nameKeyword=null,i.urlKeyword=null,i.customTypes=null,i.includeFrozen=null===(s=a.includeFrozen)||void 0===s||s,i.includeMetaData=null===(o=a.includeMetaData)||void 0===o||o,i.nameKeyword=null!==(u=a.nameKeyword)&&void 0!==u?u:null,i.urlKeyword=null!==(c=a.urlKeyword)&&void 0!==c?c:null,i.customTypes=null!==(l=a.customTypes)&&void 0!==l?l:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.nameKeyword,!0)&&D("string",this.urlKeyword,!0)&&P("string",this.customTypes,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,t=es.of(this._iid),n=t.requestQueue,r=new lm(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(dm),s=i.channels,o=i.token,this._token=o,this._hasNext=!!o,u=J_.of(this._iid),e.next=15,u.upsertChannelsToCache(s);case 15:return this._isLoading=!1,e.abrupt("return",s);case 17:return e.abrupt("return",[]);case 20:throw A.queryInProgress;case 21:e.next=24;break;case 23:throw A.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}])}(uu),fm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="openChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new J_(e,{sdkState:r,dispatcher:a,requestQueue:s,logger:o,cacheContext:c,sessionManager:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new hm(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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return(s=Object.assign({},j_)).name=e,s.coverUrlOrImage=t,s.data=n,s.operatorUserIds=r,s.customType=a,i.abrupt("return",this._manager.createChannel(s));case 7:case"end":return i.stop()}}),i,this)})))}}])}(ts),pm=Object.freeze({__proto__:null,xmlHttpRequest:function(e,t){return new Promise((function(n,r){if("undefined"!=typeof XMLHttpRequest){var a=es.of(e),i=a.dispatcher,s=a.logger,o=t.requestId,u=t.method,c=t.url,l=t.headers,d=void 0===l?{}:l,h=t.data,f=void 0===h?"":h,p=t.uploadProgressHandler,v=!1,_=new XMLHttpRequest;_.open(u,c),Object.keys(d).forEach((function(e){_.setRequestHeader(e,d[e])})),p&&_.upload.addEventListener("progress",(function(e){e.lengthComputable?p(o,e.loaded,e.total):s.debug("Progress computing failed: `Content-Length` header is not given.")})),_.onabort=function(){r(A.requestCanceled)},_.onerror=function(e){r(A.networkError)},_.onreadystatechange=function(){if(_.readyState===XMLHttpRequest.DONE&&!v)if(0===_.status||_.status>=200&&_.status<400)try{var t=JSON.parse(_.responseText);n(new Ve(e,t))}catch(s){r(A.networkError)}else try{var a=JSON.parse(_.responseText);if(a){var s=new A(a);if(s.isSessionExpiredError){if(i.dispatch(new Be({reason:s.code,message:s.message})),!(_ instanceof We)){var o=new ot;return i.dispatch(new $e({request:_,deferred:o,error:s})),o.promise}}else s.isSessionInvalidatedError&&i.dispatch(new Be({reason:s.code,message:s.message}));r(s)}else r(A.requestFailed)}catch(s){r(A.requestFailed)}},i.on((function(e){e instanceof ut&&(e.requestId&&e.requestId!==o||(v=!0,_.abort()))})),_.send(f)}else r(A.xmlHttpRequestNotSupported)}))}});O_=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 wm(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 xm(e){return"string"!=typeof e&&(e=String(e)),e}function Sm(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return gm&&(t[Symbol.iterator]=function(){return t}),t}function Tm(e){this.map={},e instanceof Tm?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 Im(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function Nm(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Am(e){var t=new FileReader,n=Nm(t);return t.readAsArrayBuffer(e),n}function Mm(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Om(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:ym&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:Em&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:mm&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():km&&ym&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Mm(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):km&&(ArrayBuffer.prototype.isPrototypeOf(e)||Cm(e))?this._bodyArrayBuffer=Mm(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):mm&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},ym&&(this.blob=function(){var e=Im(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=Im(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(ym)return this.blob().then(Am);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,n,r,a,i=Im(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Nm(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),a=r?r[1]:"utf-8",t.readAsText(e,a),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||function(){if("AbortController"in _m)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 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 Rm(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 Lm(e,t){if(!(this instanceof Lm))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 Tm(t.headers),this.url=t.url||"",this._initBody(e)}Dm.prototype.clone=function(){return new Dm(this,{body:this._bodyInit})},Om.call(Dm.prototype),Om.call(Lm.prototype),Lm.prototype.clone=function(){return new Lm(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Tm(this.headers),url:this.url})},Lm.error=function(){var e=new Lm(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var Pm=[301,302,303,307,308];Lm.redirect=function(e,t){if(-1===Pm.indexOf(t))throw new RangeError("Invalid status code");return new Lm(null,{status:t,headers:{location:e}})};var Fm=_m.DOMException;try{new Fm}catch(Mn){(Fm=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),Fm.prototype.constructor=Fm}function qm(e,t){return new Promise((function(n,r){var a=new Dm(e,t);if(a.signal&&a.signal.aborted)return r(new Fm("Aborted","AbortError"));var i=new XMLHttpRequest;function s(){i.abort()}if(i.onload=function(){var e,t,r={statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new Tm,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();try{t.append(r,a)}catch(e){console.warn("Response "+e.message)}}})),t)};0===a.url.indexOf("file://")&&(i.status<200||i.status>599)?r.status=200:r.status=i.status,r.url="responseURL"in i?i.responseURL:r.headers.get("X-Request-URL");var s="response"in i?i.response:i.responseText;setTimeout((function(){n(new Lm(s,r))}),0)},i.onerror=function(){setTimeout((function(){r(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){r(new TypeError("Network request timed out"))}),0)},i.onabort=function(){setTimeout((function(){r(new Fm("Aborted","AbortError"))}),0)},i.open(a.method,function(e){try{return""===e&&_m.location.href?_m.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?i.withCredentials=!0:"omit"===a.credentials&&(i.withCredentials=!1),"responseType"in i&&(ym?i.responseType="blob":km&&(i.responseType="arraybuffer")),t&&"object"===m(t.headers)&&!(t.headers instanceof Tm||_m.Headers&&t.headers instanceof _m.Headers)){var o=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){o.push(wm(e)),i.setRequestHeader(e,xm(t.headers[e]))})),a.headers.forEach((function(e,t){-1===o.indexOf(t)&&i.setRequestHeader(t,e)}))}else a.headers.forEach((function(e,t){i.setRequestHeader(t,e)}));a.signal&&(a.signal.addEventListener("abort",s),i.onreadystatechange=function(){4===i.readyState&&a.signal.removeEventListener("abort",s)}),i.send(void 0===a._bodyInit?null:a._bodyInit)}))}qm.polyfill=!0,_m.fetch||(_m.fetch=qm,_m.Headers=Tm,_m.Request=Dm,_m.Response=Lm);var Hm="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null};Hm.fetch||(Hm.fetch=qm);var Gm=Object.freeze({__proto__:null});e.AdminMessage=Js,e.AppInfo=Wa,e.AppleCriticalAlertOptions=ds,e.ApplicationUserListQuery=wl,e.BannedUserListQuery=yu,e.BaseChannel=vl,e.BaseMessage=Ws,e.BlockedUserListQuery=Tl,e.CachedChannelInfo=Q,e.ConnectionHandler=yl,e.DeliveryStatus=Xf,e.Emoji=_l,e.EmojiCategory=ml,e.EmojiContainer=gl,e.Feedback=fs,e.FileMessage=fo,e.FriendListQuery=Al,e.GroupChannel=E_,e.GroupChannelCollection=N_,e.GroupChannelEventSource=_p,e.GroupChannelFilter=$f,e.GroupChannelHandler=L_,e.GroupChannelListQuery=lv,e.GroupChannelModule=H_,e.LocalCacheConfig=W,e.Member=Zf,e.MemberListQuery=Yv,e.MemoryStore=Sd,e.MessageCollection=jv,e.MessageCollectionInitHandler=Hv,e.MessageEventSource=As,e.MessageFilter=Pd,e.MessageForm=zs,e.MessageFormItem=Bs,e.MessageMetaArray=vs,e.MessageModule=yh,e.MessageRequestHandler=qo,e.MessageReviewInfo=so,e.MessageSearchQuery=dh,e.MultipleFilesMessage=uo,e.MultipleFilesMessageRequestHandler=ol,e.MutedUserListQuery=_u,e.NotificationInfo=Ha,e.OGImage=cs,e.OGMetaData=ls,e.OpenChannel=om,e.OpenChannelHandler=cm,e.OpenChannelListQuery=hm,e.OpenChannelModule=fm,e.OperatorListQuery=hu,e.Participant=Fo,e.ParticipantListQuery=rm,e.PinnedMessage=ul,e.PinnedMessageListQuery=dl,e.Plugin=$s,e.PreviousMessageListQuery=fu,e.PublicGroupChannelListQuery=U_,e.Reaction=us,e.ReactionEvent=os,e.ReadStatus=gs,e.RestrictedUser=Po,e.RestrictionInfo=Lo,e.ScheduledMessageListQuery=q_,e.SendbirdChat=Gf,e.SendbirdChatOptions=j,e.SendbirdError=A,e.Sender=ps,e.SessionHandler=El,e.ThreadInfo=is,e.ThreadInfoUpdateEvent=rh,e.ThreadedParentMessageListQuery=ph,e.Thumbnail=ns,e.UIKitConfigInfo=ja,e.UploadedFileInfo=Hs,e.User=si,e.UserEventHandler=kl,e.UserMessage=oo,Object.defineProperty(e,"__esModule",{value:!0})})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Sendbird={})}(this,(function(e){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=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 i,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw i}}}}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(r){var a=Object.getOwnPropertyDescriptor(r,t);return a.get?a.get.call(arguments.length<3?e:n):a.value}},o.apply(null,arguments)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function d(){d=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",u=i.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 i=t&&t.prototype instanceof g?t:g,s=Object.create(i.prototype),o=new M(r||[]);return a(s,"_invoke",{value:T(e,n,o)}),s}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var f="suspendedStart",p="suspendedYield",v="executing",_="completed",m={};function g(){}function y(){}function E(){}var k={};c(k,s,(function(){return this}));var b=Object.getPrototypeOf,C=b&&b(b(O([])));C&&C!==n&&r.call(C,s)&&(k=C);var w=E.prototype=g.prototype=Object.create(k);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(a,i,s,o){var u=h(e[a],e,i);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,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var i;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return i=i?i.then(a,a):a()}})}function T(t,n,r){var a=f;return function(i,s){if(a===v)throw Error("Generator is already running");if(a===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var o=r.delegate;if(o){var u=I(o,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===f)throw a=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=v;var c=h(t,n,r);if("normal"===c.type){if(a=r.done?_:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(a=_,r.method="throw",r.arg=c.arg)}}}function I(t,n){var r=n.method,a=t.iterator[r];if(a===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,I(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=h(a,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function N(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 A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function M(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(N,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function n(){for(;++a=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(u&&c){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),A(n),m}},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;A(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:O(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),m}},t}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,s,o=[],u=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(o.push(r.value),o.length!==t);u=!0);}catch(e){c=!0,a=e}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw a}}return o}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t,n,r){var a=o(u(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof a?function(e){return a.apply(n,e)}:a}function v(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){var t=function(e,t){if("object"!=typeof e||!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:t+""}function m(e){return m="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},m(e)}function g(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function y(e){var t="function"==typeof Map?new Map:void 0;return y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(l())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var a=new(e.bind.apply(e,r));return n&&h(a,n.prototype),a}(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)},y(e)}function E(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var k,b="4.14.5",C=function(){function e(){r(this,e)}return i(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return b}},{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.SendbirdErrorCode=void 0,(k=e.SendbirdErrorCode||(e.SendbirdErrorCode={}))[k.NON_AUTHORIZED=400108]="NON_AUTHORIZED",k[k.INVALID_TOKEN=400111]="INVALID_TOKEN",k[k.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",k[k.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",k[k.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",k[k.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",k[k.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",k[k.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",k[k.SESSION_REVOKED=400310]="SESSION_REVOKED",k[k.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",k[k.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",k[k.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",k[k.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",k[k.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",k[k.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",k[k.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",k[k.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",k[k.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",k[k.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",k[k.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",k[k.LOST_INSTANCE=700100]="LOST_INSTANCE",k[k.CONNECTION_RENEW=700102]="CONNECTION_RENEW",k[k.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",k[k.INVALID_COMMAND=700700]="INVALID_COMMAND",k[k.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",k[k.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",k[k.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",k[k.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",k[k.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",k[k.INVALID_PARAMETER=800110]="INVALID_PARAMETER",k[k.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",k[k.NETWORK_ERROR=800120]="NETWORK_ERROR",k[k.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",k[k.MALFORMED_DATA=800130]="MALFORMED_DATA",k[k.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",k[k.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",k[k.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",k[k.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",k[k.ACK_TIMEOUT=800180]="ACK_TIMEOUT",k[k.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",k[k.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",k[k.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",k[k.REQUEST_FAILED=800220]="REQUEST_FAILED",k[k.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",k[k.REQUEST_CANCELED=800240]="REQUEST_CANCELED",k[k.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",k[k.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",k[k.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED",k[k.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",k[k.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",k[k.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",k[k.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",k[k.DATABASE_ERROR=800700]="DATABASE_ERROR",k[k.USER_DEACTIVATED=900021]="USER_DEACTIVATED",k[k.CHANNEL_IS_FROZEN=900050]="CHANNEL_IS_FROZEN",k[k.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";var w,x,S,T,I,N=function(e){return!(e instanceof A&&!e.shouldThrowOutside)},A=function(t){function a(e){var t,i=e.code,s=void 0===i?0:i,o=e.message,u=void 0===o?"":o;return r(this,a),(t=n(this,a,[u])).shouldThrowOutside=!1,t._detail="",t.name="SendbirdError",t.code=s,Object.setPrototypeOf(t,a.prototype),t}return c(a,t),i(a,[{key:"detail",get:function(){return this._detail}},{key:"setDetail",value:function(e){this._detail=e}},{key:"isInvalidTokenError",get:function(){return this.code===e.SendbirdErrorCode.INVALID_TOKEN}},{key:"isSessionExpiredError",get:function(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}},{key:"isSessionTokenExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_KEY_EXPIRED}},{key:"isSessionInvalidatedError",get:function(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}},{key:"isSessionRevokedError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_REVOKED}},{key:"isUserAuthDeactivedError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DEACTIVATED}},{key:"isUserAuthDeletedOrNotFoundError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}},{key:"isNetworkError",get:function(){return this.code===e.SendbirdErrorCode.NETWORK_ERROR||this.code===e.SendbirdErrorCode.NETWORK_ROUTING_ERROR}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new a({code:e.SendbirdErrorCode.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new a({code:e.SendbirdErrorCode.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"invalidCommand",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new a({code:e.SendbirdErrorCode.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{key:"connectionRenew",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"xmlHttpRequestNotSupported",get:function(){return new a({code:e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}},{key:"connectionRequired",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"channelTypeNotSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}},{key:"networkError",get:function(){return new a({code:e.SendbirdErrorCode.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new a({code:e.SendbirdErrorCode.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new a({code:e.SendbirdErrorCode.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new a({code:e.SendbirdErrorCode.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new a({code:e.SendbirdErrorCode.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new a({code:e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Request failed."})}},{key:"tooManyRequests",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}},{key:"alreadyConnectedAsAnotherUser",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}},{key:"fileUploadCanceled",get:function(){return new a({code:e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new a({code:e.SendbirdErrorCode.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}},{key:"statLogUploadLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}},{key:"malformedDataError",get:function(){return new a({code:e.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}}])}(y(Error)),M=[e.SendbirdErrorCode.CONNECTION_REQUIRED,e.SendbirdErrorCode.NETWORK_ERROR,e.SendbirdErrorCode.ACK_TIMEOUT,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,e.SendbirdErrorCode.REQUEST_CANCELED,e.SendbirdErrorCode.INTERNAL_SERVER_ERROR,e.SendbirdErrorCode.RATE_LIMIT_EXCEEDED,e.SendbirdErrorCode.UNKNOWN_SERVER_ERROR,e.SendbirdErrorCode.USER_DEACTIVATED,e.SendbirdErrorCode.CHANNEL_IS_FROZEN,e.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],O=[e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.CONNECTION_REQUIRED,e.SendbirdErrorCode.CHANNEL_IS_FROZEN],U=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},D=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||("string"!=typeof e?"object"===m(e)?R(e,t):L(e,t):m(t)===e)},R=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Object.values(e).includes(t)},L=function(e,t){return t instanceof e},P=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Array.isArray(t)&&t.every((function(t){return D(e,t)}))},F=function(e){return!!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))||"number"==typeof e&&13===e.toString().length},q=function(e){return e>0&&O.indexOf(e)>=0},H=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))return!0;var t="object"===m(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},G=function(e){return null==e},j=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,i=t.typingIndicatorInvalidateTime,s=void 0===i?1e4:i,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,d=t.websocketPayloadDecompression,h=void 0===d||d,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=s,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=h}),[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){D("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){D("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){D("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){D("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){D("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}])}(),V={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){return i((function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}),[{key:"_savePreferenceKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:v(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._version=n,this._keysAddress=e,a="".concat(e,".metadata.version"),r.next=5,this._store.get(a);case 5:return i=r.sent,r.next=8,this._store.get(e);case 8:if(r.t1=t=r.sent,r.t0=null!==r.t1,!r.t0){r.next=12;break}r.t0=void 0!==t;case 12:if(!r.t0){r.next=16;break}r.t2=t,r.next=17;break;case 16:r.t2=[];case 17:if(o=r.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},a=n.maxSize,i=void 0===a?256:a,s=n.clearOrder,o=void 0===s?e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT:s,u=n.customClearOrderComparator,c=n.enableAutoResend,l=void 0===c||c;r(this,t),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(i,64),u?(this._clearOrder=o,this._customClearOrderComparator=u):this._clearOrder=e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=l}),[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var t;return this._clearOrder===e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(t=this._customClearOrderComparator)&&void 0!==t?t:this._clearOrderComparatorUseMessageCollectionAccessedAt}},{key:"enableAutoResend",get:function(){return this._enableAutoResend}}])}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(Q||(Q={}));var Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue=function(){return i((function e(){r(this,e),this.isRefreshing=!1}),[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"hasChatServicePermission",get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(Q.CHAT))}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}])}(),ce=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)}))},le=function(){return i((function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=ce()}),[{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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))}}])}(),de=function(){return i((function e(){r(this,e),this._container={}}),[{key:"on",value:function(e,t){return new le({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new le({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],i=s(n.keys());try{for(i.s();!(r=i.n()).done;){var o=r.value,u=n.get(o);u.handler(t),u.occurence>0&&(u.occurence--,0===u.occurence&&a.push(o))}}catch(e){i.e(e)}finally{i.f()}a.forEach((function(e){return n.delete(e)}))}}}])}(),he=function(){return i((function e(){r(this,e),this._dispatcher=new de}),[{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)}}])}(),fe=i((function e(){r(this,e)})),pe=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},ve=function(e){if(null!=e){if("object"===m(e)){if(Array.isArray(e)){for(var t=v(e),n=0;n3&&void 0!==arguments[3]?arguments[3]:"";return r(this,t),(s=n(this,t))._iid=e,s.code=a,s.payload=i,s.requestId=null!==(o=i.req_id)&&void 0!==o?o:u,s}return c(t,e),i(t,[{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,n){var r=n.substring(0,4),a={};try{a=JSON.parse(n.substring(4))}catch(e){r="NOOP"}finally{return new t(e,r,a)}}}])}(fe),We=function(e){function t(e){var a,i,s=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?{}:u;return r(this,t),(a=n(this,t)).code=s,a.payload=c,a.requestId=null!==(i=a.payload.req_id)&&void 0!==i?i:ce(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return c(t,e),i(t,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}])}(fe),Ye=function(e){function t(e){var a,i=e.userId,s=e.authToken,o=e.services,u=e.expiringSession,c=void 0===u||u;return r(this,t),(a=n(this,t)).path="".concat(ge,"/").concat(i,"/session_key"),a.method=_e.POST,a.params=pe({token:s,services:o,expiring_session:!!c}),a.requireAuth=!1,a}return c(t,e),i(t)}(Ve),Ze=function(e){function t(e){var a=e.authToken,i=e.expiringSession,s=void 0===i||i,o=e.requestId,u=void 0===o?void 0:o;return r(this,t),n(this,t,[{code:"LOGI",payload:pe({token:a,expiring_session:s?1:0,req_id:u}),ackRequired:!0}])}return c(t,e),i(t)}(We),Xe=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.key,o=a.expires_at,u=a.services;return i.key=s,i.expiresAt=o,i.services=u,i}return c(t,e),i(t)}(ze),Je=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"LOGI",i])).error=null,s.newKey=null,s.newKey=null!==(o=i.new_key)&&void 0!==o?o:null,s.error=i.error?new A(i):null,s}return c(t,e),i(t)}(Ke),$e=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).statLog=e,a}return c(t,e),i(t)}(fe),et=function(e){function t(e){var a,i=e.request,s=e.deferred,o=e.error,u=void 0===o?A.requestFailed:o;return r(this,t),(a=n(this,t)).request=i,a.deferred=s,a.error=u,a}return c(t,e),i(t)}(fe);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",e.NOTIFICATION="noti:stats",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(je||(je={}));var tt,nt,rt,at=function(){return i((function e(t){var n=t.type,a=t.data,i=t.ts,s=void 0===i?Date.now():i;r(this,e),this.type=n,this.createdAt=s,this.data=a}),null,[{key:"payloadify",value:function(e){return pe({stat_type:e.type,ts:e.createdAt,data:pe(e.data)})}}])}(),it=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},st=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};e.SendbirdProduct=void 0,(tt=e.SendbirdProduct||(e.SendbirdProduct={})).CHAT="chat",tt.CALLS="calls",tt.DESK="desk",tt.LIVE="live",tt.UIKIT_CHAT="uikit-chat",tt.UIKIT_LIVE="uikit-live",e.SendbirdPlatform=void 0,(nt=e.SendbirdPlatform||(e.SendbirdPlatform={})).ANDROID="android",nt.IOS="ios",nt.JS="js",nt.UNREAL="unreal",nt.UNITY="unity",nt.REACT_NATIVE="react-native",nt.FLUTTER="flutter",e.DeviceOsPlatform=void 0,(rt=e.DeviceOsPlatform||(e.DeviceOsPlatform={})).ANDROID="android",rt.IOS="ios",rt.WEB="web",rt.MOBILE_WEB="mobile_web",rt.WINDOWS="windows";var ot=i((function e(){r(this,e)}));ot.sendbirdSdkUserAgentWithExtension=function(t){var n=it()?e.SendbirdPlatform.REACT_NATIVE:e.SendbirdPlatform.JS,r={main_sdk_info:"chat/".concat(n,"/").concat(C.SDK_VERSION),device_os_platform:st()?"mobile-web":"web",os_version:C.OS_VERSION};if(t){var a=t.sendbirdExtensions,i=t.deviceOS,s=t.customData,o=void 0===s?{}:s;i.version&&(r.os_version=i.version),i.platform&&(r.device_os_platform=i.platform),a.length>0&&(r.extension_sdk_info=a.map((function(e){var t=e.product,n=e.platform,r=e.version;return"".concat(t,"/").concat(n,"/").concat(r)})).join(",")),Object.keys(r).forEach((function(e){return delete o[e]})),Object.keys(o).length>0&&(r=Object.assign(Object.assign({},r),o))}return Object.entries(r).map((function(e){var t=f(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join("&")},ot.userAgentWithExtension=function(e){var t=it()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):st()?"omobile-web":"oweb";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)};var ut=i((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=function(e){n(e)}}))})),ct=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).requestId=e.requestId,a}return c(t,e),i(t)}(fe),lt=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),e.messageToken&&(a.params=pe({mesg_token:e.messageToken})),a}return c(t,e),i(t)}(Ve),dt=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"DELM",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(o=i.sender_id)&&void 0!==o?o:void 0,s}return c(t,e),i(t)}(Ke),ht=function(){return i((function e(t,n){var a=this,i=n.session,s=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._session=i,this._sdkState=s,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof Be&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}),[{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,i=n.sendbirdRuntimeEnvironment,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":ot.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":ot.sendbirdSdkUserAgentWithExtension(i)});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(s["Session-Key"]=this._session.sessionKey),s["App-Id"]=r,this._session&&this._session.authToken&&(s["Access-Token"]=this._session.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){e.path.includes("/sdk/statistics")||this._dispatcher.dispatch(new $e(new at({type:je.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:"_isBodyRequired",value:function(e){var t=e.method;return t!==_e.GET&&(t!==_e.DELETE||e instanceof lt)}},{key:"send",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=t.path,a=t.method,i=t.uploadProgressHandler,s=this._isBodyRequired(t),o=this._sdkState.api,u="".concat(o.host).concat(r).concat(s?"":t.query),c=s?t.payload:null,l=this._createHeader(t,c instanceof FormData?c:void 0),h=new AbortController,f=h.signal,this._abortControl.set(t.requestId,h),p=Date.now(),n.prev=10,!i){n.next=32;break}return n.next=14,Promise.resolve().then((function(){return ym}));case 14:return v=n.sent,_=v.xmlHttpRequest,n.prev=16,n.next=19,_(this._iid,{requestId:t.requestId,method:t.method,url:u,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i});case 19:return m=n.sent,this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",m);case 25:if(n.prev=25,n.t0=n.catch(16),!(n.t0 instanceof A&&n.t0.code===e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED)){n.next=31;break}this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),n.next=32;break;case 31:throw n.t0;case 32: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){n.next=36;break}return n.next=36,Promise.resolve().then((function(){return Em}));case 36:if("function"==typeof fetch){n.next=39;break}return n.next=39,Promise.resolve().then((function(){return Qm}));case 39:return n.next=41,fetch(u,{method:a,body:c,headers:l,signal:f});case 41:return g=n.sent,n.next=44,g.json();case 44:if(y=n.sent,!g.ok&&!g.redirected){n.next=51;break}return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",new ze(this._iid,y));case 51:if(!y){n.next=70;break}if(!(E=new A(y)).isSessionExpiredError){n.next=62;break}if(this._dispatcher.dispatch(new Qe({reason:E.code,message:E.message})),t instanceof Ye){n.next=59;break}return k=new ut,this._dispatcher.dispatch(new et({request:t,deferred:k,error:E})),n.abrupt("return",k.promise);case 59:case 67:throw E;case 62:if(!E.isSessionInvalidatedError){n.next=67;break}throw this._dispatcher.dispatch(new Qe({reason:E.code,message:E.message})),E;case 68:n.next=71;break;case 70:throw A.requestFailed;case 71:n.next=87;break;case 73:if(n.prev=73,n.t1=n.catch(10),this._statLogApiResult(t,p,n.t1),!(n.t1 instanceof A)){n.next=81;break}throw this._logger.debug("fail api request",n.t1),n.t1;case 81:if("AbortError"!==(null===n.t1||void 0===n.t1?void 0:n.t1.name)){n.next=85;break}throw A.requestCanceled;case 85:throw this._logger.debug("fail api request",n.t1),A.networkError;case 87:case"end":return n.stop()}}),n,this,[[10,73],[16,25]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new ct({requestId:e}))}},{key:"cancelAll",value:function(){var e,t=s(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(),this._dispatcher.dispatch(new ct({}))}}])}(),ft=function(){};function pt(e){let t=e.length;for(;--t>=0;)e[t]=0}const vt=256,_t=286,mt=30,gt=15,yt=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]),Et=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]),kt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),bt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ct=new Array(576);pt(Ct);const wt=new Array(60);pt(wt);const xt=new Array(512);pt(xt);const St=new Array(256);pt(St);const Tt=new Array(29);pt(Tt);const It=new Array(mt);function Nt(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let At,Mt,Ot;function Ut(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}pt(It);const Dt=e=>e<256?xt[e]:xt[256+(e>>>7)],Rt=(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])},Ft=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},qt=(e,t,n)=>{const r=new Array(16);let a,i,s=0;for(a=1;a<=gt;a++)s=s+n[a-1]<<1,r[a]=s;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=Ft(r[t]++,t))}},Ht=e=>{let t;for(t=0;t<_t;t++)e.dyn_ltree[2*t]=0;for(t=0;t{e.bi_valid>8?Rt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},jt=(e,t,n,r)=>{const a=2*t,i=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,i,s,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?Pt(e,a,t):(i=St[a],Pt(e,i+vt+1,t),s=yt[i],0!==s&&(a-=Tt[i],Lt(e,a,s)),r--,i=Dt(r),Pt(e,i,n),s=Et[i],0!==s&&(r-=It[i],Lt(e,r,s)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,i=t.stat_desc.elems;let s,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)Vt(e,n,s);u=i;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Vt(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,n[2*u]=n[2*s]+n[2*o],e.depth[u]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,n[2*s+1]=n[2*o+1]=u,e.heap[1]=u++,Vt(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,i=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,d,h,f,p,v=0;for(h=0;h<=gt;h++)e.bl_count[h]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],h=n[2*n[2*l+1]+1]+1,h>u&&(h=u,v++),n[2*l+1]=h,l>r||(e.bl_count[h]++,f=0,l>=o&&(f=s[l-o]),p=n[2*l],e.opt_len+=p*(h+f),i&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(h=u-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(h=u;0!==h;h--)for(l=e.bl_count[h];0!==l;)d=e.heap[--c],d>r||(n[2*d+1]!==h&&(e.opt_len+=(h-n[2*d+1])*n[2*d],n[2*d+1]=h),l--)}})(e,t),qt(n,c,e.bl_count)},Qt=(e,t,n)=>{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=s,s=t[2*(r+1)+1],++o{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),r=0;r<=n;r++)if(a=s,s=t[2*(r+1)+1],!(++o{Lt(e,0+(r?1:0),3),Gt(e),Rt(e,n),Rt(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Zt=(e,t,n,r)=>{let a,i,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(Qt(e,e.dyn_ltree,e.l_desc.max_code),Qt(e,e.dyn_dtree,e.d_desc.max_code),Bt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*bt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=a&&(a=i)):a=i=n+5,n+4<=a&&-1!==t?Yt(e,t,n,r):4===e.strategy||i===a?(Lt(e,2+(r?1:0),3),zt(e,Ct,wt)):(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{Wt||((()=>{let e,t,n,r,a;const i=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*(St[n]+vt+1)]++,e.dyn_dtree[2*Dt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Lt(e,2,3),Pt(e,256,Ct),(e=>{16===e.bi_valid?(Rt(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 Jt=(e,t,n,r)=>{let a=65535&e,i=e>>>16&65535,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{a=a+t[r++]|0,i=i+a|0}while(--s);a%=65521,i%=65521}return a|i<<16};const $t=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 en=(e,t,n,r)=>{const a=$t,i=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return~e},tn={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"},nn={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:rn,_tr_stored_block:an,_tr_flush_block:sn,_tr_tally:on,_tr_align:un}=Xt,{Z_NO_FLUSH:cn,Z_PARTIAL_FLUSH:ln,Z_FULL_FLUSH:dn,Z_FINISH:hn,Z_BLOCK:fn,Z_OK:pn,Z_STREAM_END:vn,Z_STREAM_ERROR:_n,Z_DATA_ERROR:mn,Z_BUF_ERROR:gn,Z_DEFAULT_COMPRESSION:yn,Z_FILTERED:En,Z_HUFFMAN_ONLY:kn,Z_RLE:bn,Z_FIXED:Cn,Z_DEFAULT_STRATEGY:wn,Z_UNKNOWN:xn,Z_DEFLATED:Sn}=nn,Tn=258,In=262,Nn=42,An=113,Mn=666,On=(e,t)=>(e.msg=tn[t],t),Un=e=>2*e-(e>4?9:0),Dn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Rn=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))},Fn=(e,t)=>{sn(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Pn(e.strm)},qn=(e,t)=>{e.pending_buf[e.pending++]=t},Hn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Gn=(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=Jt(e.adler,t,a,n):2===e.state.wrap&&(e.adler=en(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},jn=(e,t)=>{let n,r,a=e.max_chain_length,i=e.strstart,s=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-In?e.strstart-(e.w_size-In):0,c=e.window,l=e.w_mask,d=e.prev,h=e.strstart+Tn;let f=c[i+s-1],p=c[i+s];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+s]===p&&c[n+s-1]===f&&c[n]===c[i]&&c[++n]===c[i+1]){i+=2,n++;do{}while(c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&is){if(e.match_start=t,s=r,r>=o)break;f=c[i+s-1],p=c[i+s]}}}while((t=d[t&l])>u&&0!=--a);return s<=e.lookahead?s:e.lookahead},Vn=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-In)&&(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),Rn(e),r+=t),0===e.strm.avail_in)break;if(n=Gn(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,i=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=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,Pn(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&&(Gn(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 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&&(Gn(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,i=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=i||(r||t===hn)&&t!==cn&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,s=t===hn&&0===e.strm.avail_in&&n===r?1:0,an(e,e.block_start,n,s),e.block_start+=n,Pn(e.strm)),s?3:1)},Bn=(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-In&&(e.match_length=jn(e,n)),e.match_length>=3)if(r=on(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=on(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2},Qn=(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=on(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&&(Fn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=on(e,0,e.window[e.strstart-1]),r&&Fn(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=on(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2};function Kn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const Wn=[new Kn(0,0,0,0,zn),new Kn(4,4,8,4,Bn),new Kn(4,5,16,8,Bn),new Kn(4,6,32,32,Bn),new Kn(4,4,16,16,Qn),new Kn(8,16,32,32,Qn),new Kn(8,16,128,128,Qn),new Kn(8,32,128,256,Qn),new Kn(32,128,258,1024,Qn),new Kn(32,258,258,4096,Qn)];function Yn(){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=Sn,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),Dn(this.dyn_ltree),Dn(this.dyn_dtree),Dn(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),Dn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Dn(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 Zn=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!==An&&t.status!==Mn?1:0},Xn=e=>{if(Zn(e))return On(e,_n);e.total_in=e.total_out=0,e.data_type=xn;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:An,e.adler=2===t.wrap?0:1,t.last_flush=-2,rn(t),pn},Jn=e=>{const t=Xn(e);var n;return t===pn&&((n=e.state).window_size=2*n.w_size,Dn(n.head),n.max_lazy_match=Wn[n.level].max_lazy,n.good_match=Wn[n.level].good_length,n.nice_match=Wn[n.level].nice_length,n.max_chain_length=Wn[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},$n=(e,t,n,r,a,i)=>{if(!e)return _n;let s=1;if(t===yn&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),a<1||a>9||n!==Sn||r<8||r>15||t<0||t>9||i<0||i>Cn||8===r&&1!==s)return On(e,_n);8===r&&(r=9);const o=new Yn;return e.state=o,o.strm=e,o.status=Nn,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<$n(e,t,Sn,15,8,wn),deflateInit2:$n,deflateReset:Jn,deflateResetKeep:Xn,deflateSetHeader:(e,t)=>Zn(e)||2!==e.state.wrap?_n:(e.state.gzhead=t,pn),deflate:(e,t)=>{if(Zn(e)||t>fn||t<0)return e?On(e,_n):_n;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Mn&&t!==hn)return On(e,0===e.avail_out?gn:_n);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Pn(e),0===e.avail_out)return n.last_flush=-1,pn}else if(0===e.avail_in&&Un(t)<=Un(r)&&t!==hn)return On(e,gn);if(n.status===Mn&&0!==e.avail_in)return On(e,gn);if(n.status===Nn&&0===n.wrap&&(n.status=An),n.status===Nn){let t=Sn+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=kn||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,Hn(n,t),0!==n.strstart&&(Hn(n,e.adler>>>16),Hn(n,65535&e.adler)),e.adler=1,n.status=An,Pn(e),0!==n.pending)return n.last_flush=-1,pn}if(57===n.status)if(e.adler=0,qn(n,31),qn(n,139),qn(n,8),n.gzhead)qn(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)),qn(n,255&n.gzhead.time),qn(n,n.gzhead.time>>8&255),qn(n,n.gzhead.time>>16&255),qn(n,n.gzhead.time>>24&255),qn(n,9===n.level?2:n.strategy>=kn||n.level<2?4:0),qn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(qn(n,255&n.gzhead.extra.length),qn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=en(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(qn(n,0),qn(n,0),qn(n,0),qn(n,0),qn(n,0),qn(n,9===n.level?2:n.strategy>=kn||n.level<2?4:0),qn(n,3),n.status=An,Pn(e),0!==n.pending)return n.last_flush=-1,pn;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=en(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,Pn(e),0!==n.pending)return n.last_flush=-1,pn;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=en(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=en(e.adler,n.pending_buf,n.pending-r,r)),Pn(e),0!==n.pending)return n.last_flush=-1,pn;r=0}t=n.gzindexr&&(e.adler=en(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=en(e.adler,n.pending_buf,n.pending-r,r)),Pn(e),0!==n.pending)return n.last_flush=-1,pn;r=0}t=n.gzindexr&&(e.adler=en(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&&(Pn(e),0!==n.pending))return n.last_flush=-1,pn;qn(n,255&e.adler),qn(n,e.adler>>8&255),e.adler=0}if(n.status=An,Pn(e),0!==n.pending)return n.last_flush=-1,pn}if(0!==e.avail_in||0!==n.lookahead||t!==cn&&n.status!==Mn){let r=0===n.level?zn(n,t):n.strategy===kn?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Vn(e),0===e.lookahead)){if(t===cn)return 1;break}if(e.match_length=0,n=on(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===bn?((e,t)=>{let n,r,a,i;const s=e.window;for(;;){if(e.lookahead<=Tn){if(Vn(e),e.lookahead<=Tn&&t===cn)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=s[a],r===s[++a]&&r===s[++a]&&r===s[++a])){i=e.strstart+Tn;do{}while(r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=on(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=on(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2})(n,t):Wn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=Mn),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),pn;if(2===r&&(t===ln?un(n):t!==fn&&(an(n,0,0,!1),t===dn&&(Dn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Pn(e),0===e.avail_out))return n.last_flush=-1,pn}return t!==hn?pn:n.wrap<=0?vn:(2===n.wrap?(qn(n,255&e.adler),qn(n,e.adler>>8&255),qn(n,e.adler>>16&255),qn(n,e.adler>>24&255),qn(n,255&e.total_in),qn(n,e.total_in>>8&255),qn(n,e.total_in>>16&255),qn(n,e.total_in>>24&255)):(Hn(n,e.adler>>>16),Hn(n,65535&e.adler)),Pn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?pn:vn)},deflateEnd:e=>{if(Zn(e))return _n;const t=e.state.status;return e.state=null,t===An?On(e,mn):pn},deflateSetDictionary:(e,t)=>{let n=t.length;if(Zn(e))return _n;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==Nn||r.lookahead)return _n;if(1===a&&(e.adler=Jt(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(Dn(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 i=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Vn(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,Vn(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=o,e.avail_in=i,r.wrap=a,pn},deflateInfo:"pako deflate (from Nodeca project)"};const tr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var nr=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)tr(n,t)&&(e[t]=n[t])}}return e},rr=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;ir[254]=ir[254]=1;var sr=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,i,s=e.length,o=0;for(a=0;a>>6,t[i++]=128|63&n):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|63&n):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|63&n);return t},or=(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 i=new Array(2*n);for(a=0,r=0;r4)i[a++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?i[a++]=65533:t<65536?i[a++]=t:(t-=65536,i[a++]=55296|t>>10&1023,i[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&ar)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+ir[e[n]]>t?n:t};var cr=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 lr=Object.prototype.toString,{Z_NO_FLUSH:dr,Z_SYNC_FLUSH:hr,Z_FULL_FLUSH:fr,Z_FINISH:pr,Z_OK:vr,Z_STREAM_END:_r,Z_DEFAULT_COMPRESSION:mr,Z_DEFAULT_STRATEGY:gr,Z_DEFLATED:yr}=nn;function Er(e){this.options=nr({level:mr,method:yr,chunkSize:16384,windowBits:15,memLevel:8,strategy:gr},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 cr,this.strm.avail_out=0;let n=er.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==vr)throw new Error(tn[n]);if(t.header&&er.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?sr(t.dictionary):"[object ArrayBuffer]"===lr.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=er.deflateSetDictionary(this.strm,e),n!==vr)throw new Error(tn[n]);this._dict_set=!0}}function kr(e,t){const n=new Er(t);if(n.push(e,!0),n.err)throw n.msg||tn[n.err];return n.result}Er.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,i;if(this.ended)return!1;for(i=t===~~t?t:!0===t?pr:dr,"string"==typeof e?n.input=sr(e):"[object ArrayBuffer]"===lr.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),(i===hr||i===fr)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=er.deflate(n,i),a===_r)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=er.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===vr;if(0!==n.avail_out){if(i>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},Er.prototype.onData=function(e){this.chunks.push(e)},Er.prototype.onEnd=function(e){e===vr&&(this.result=rr(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var br={Deflate:Er,deflate:kr,deflateRaw:function(e,t){return(t=t||{}).raw=!0,kr(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,kr(e,t)},constants:nn};const Cr=16209;var wr=function(e,t){let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x;const S=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,i=a-(t-e.avail_out),s=a+(e.avail_out-257),o=S.dmax,u=S.wsize,c=S.whave,l=S.wnext,d=S.window,h=S.hold,f=S.bits,p=S.lencode,v=S.distcode,_=(1<>>24,h>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(64&y){if(32&y){S.mode=16191;break e}e.msg="invalid literal/length code",S.mode=Cr;break e}g=p[(65535&g)+(h&(1<>>=y,f-=y),f<15&&(h+=w[n++]<>>24,h>>>=y,f-=y,y=g>>>16&255,16&y){if(k=65535&g,y&=15,fo){e.msg="invalid distance too far back",S.mode=Cr;break e}if(h>>>=y,f-=y,y=a-i,k>y){if(y=k-y,y>c&&S.sane){e.msg="invalid distance too far back",S.mode=Cr;break e}if(b=0,C=d,0===l){if(b+=u-y,y2;)x[a++]=C[b++],x[a++]=C[b++],x[a++]=C[b++],E-=3;E&&(x[a++]=C[b++],E>1&&(x[a++]=C[b++]))}else{b=a-k;do{x[a++]=x[b++],x[a++]=x[b++],x[a++]=x[b++],E-=3}while(E>2);E&&(x[a++]=x[b++],E>1&&(x[a++]=x[b++]))}break}if(64&y){e.msg="invalid distance code",S.mode=Cr;break e}g=v[(65535&g)+(h&(1<>3,n-=E,f-=E<<3,h&=(1<{const u=o.bits;let c,l,d,h,f,p,v=0,_=0,m=0,g=0,y=0,E=0,k=0,b=0,C=0,w=0,x=null;const S=new Uint16Array(16),T=new Uint16Array(16);let I,N,A,M=null;for(v=0;v<=xr;v++)S[v]=0;for(_=0;_=1&&0===S[g];g--);if(y>g&&(y=g),0===g)return a[i++]=20971520,a[i++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(T[1]=0,v=1;v852||2===e&&C>592)return 1;for(;;){I=v-k,s[_]+1=p?(N=M[s[_]-p],A=x[s[_]-p]):(N=96,A=0),c=1<>k)+l]=I<<24|N<<16|A}while(0!==l);for(c=1<>=1;if(0!==c?(w&=c-1,w+=c):w=0,_++,0==--S[v]){if(v===g)break;v=t[n+s[_]]}if(v>y&&(w&h)!==d){for(0===k&&(k=y),f+=m,E=v-k,b=1<852||2===e&&C>592)return 1;d=w&h,a[d]=y<<24|E<<16|f-i}}return 0!==w&&(a[f+w]=v-k<<24|64<<16),o.bits=y,0};const{Z_FINISH:Mr,Z_BLOCK:Or,Z_TREES:Ur,Z_OK:Dr,Z_STREAM_END:Rr,Z_NEED_DICT:Lr,Z_STREAM_ERROR:Pr,Z_DATA_ERROR:Fr,Z_MEM_ERROR:qr,Z_BUF_ERROR:Hr,Z_DEFLATED:Gr}=nn,jr=16180,Vr=16190,zr=16191,Br=16192,Qr=16194,Kr=16199,Wr=16200,Yr=16206,Zr=16209,Xr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Jr(){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},ea=e=>{if($r(e))return Pr;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=jr,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,Dr},ta=e=>{if($r(e))return Pr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ea(e)},na=(e,t)=>{let n;if($r(e))return Pr;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Pr:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,ta(e))},ra=(e,t)=>{if(!e)return Pr;const n=new Jr;e.state=n,n.strm=e,n.window=null,n.mode=jr;const r=na(e,t);return r!==Dr&&(e.state=null),r};let aa,ia,sa=!0;const oa=e=>{if(sa){aa=new Int32Array(512),ia=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(Ar(1,e.lens,0,288,aa,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Ar(2,e.lens,0,32,ia,0,e.work,{bits:5}),sa=!1}e.lencode=aa,e.lenbits=9,e.distcode=ia,e.distbits=5},ua=(e,t,n,r)=>{let a;const i=e.state;return null===i.window&&(i.wsize=1<=i.wsize?(i.window.set(t.subarray(n-i.wsize,n),0),i.wnext=0,i.whave=i.wsize):(a=i.wsize-i.wnext,a>r&&(a=r),i.window.set(t.subarray(n-r,n-r+a),i.wnext),(r-=a)?(i.window.set(t.subarray(n-r,n),0),i.wnext=r,i.whave=i.wsize):(i.wnext+=a,i.wnext===i.wsize&&(i.wnext=0),i.whavera(e,15),inflateInit2:ra,inflate:(e,t)=>{let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w=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($r(e)||!e.output||!e.input&&0!==e.avail_in)return Pr;n=e.state,n.mode===zr&&(n.mode=Br),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,d=o,h=u,C=Dr;e:for(;;)switch(n.mode){case jr:if(0===n.wrap){n.mode=Br;break}for(;l<16;){if(0===o)break e;o--,c+=r[i++]<>>8&255,n.check=en(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=Zr;break}if((15&c)!==Gr){e.msg="unknown compression method",n.mode=Zr;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=Zr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=en(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[i++]<>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=en(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[i++]<>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=en(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[i++]<>>8&255,n.check=en(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(i,i+f),b)),512&n.flags&&4&n.wrap&&(n.check=en(n.check,r,f,i)),o-=f,i+=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[i+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=zr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[i++]<>>=7&l,l-=7&l,n.mode=Yr;break}for(;l<3;){if(0===o)break e;o--,c+=r[i++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(oa(n),n.mode=Kr,t===Ur){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Zr}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[i++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Zr;break}if(n.length=65535&c,c=0,l=0,n.mode=Qr,t===Ur)break e;case Qr: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(i,i+f),s),o-=f,i+=f,u-=f,s+=f,n.length-=f;break}n.mode=zr;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[i++]<>>=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=Zr;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},C=Ar(0,n.lens,0,19,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid code lengths set",n.mode=Zr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=_,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=Zr;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=Zr;break}for(;f--;)n.lens[n.have++]=b}}if(n.mode===Zr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Zr;break}if(n.lenbits=9,S={bits:n.lenbits},C=Ar(1,n.lens,0,n.nlen,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid literal/lengths set",n.mode=Zr;break}if(n.distbits=6,n.distcode=n.distdyn,S={bits:n.distbits},C=Ar(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,S),n.distbits=S.bits,C){e.msg="invalid distances set",n.mode=Zr;break}if(n.mode=Kr,t===Ur)break e;case Kr:n.mode=Wr;case Wr:if(o>=6&&u>=258){e.next_out=s,e.avail_out=u,e.next_in=i,e.avail_in=o,n.hold=c,n.bits=l,wr(e,h),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===zr&&(n.back=-1);break}for(n.back=0;w=n.lencode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=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=zr;break}if(64&m){e.msg="invalid literal/length code",n.mode=Zr;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(;w=n.distcode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=Zr;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=Zr;break}n.mode=16204;case 16204:if(0===u)break e;if(f=h-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Zr;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=s-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[s++]=v[p++]}while(--f);0===n.length&&(n.mode=Wr);break;case 16205:if(0===u)break e;a[s++]=n.length,u--,n.mode=Wr;break;case Yr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[i++]<{if($r(e))return Pr;let t=e.state;return t.window&&(t.window=null),e.state=null,Dr},inflateGetHeader:(e,t)=>{if($r(e))return Pr;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Dr):Pr},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,i;return $r(e)?Pr:(r=e.state,0!==r.wrap&&r.mode!==Vr?Pr:r.mode===Vr&&(a=1,a=Jt(a,t,n,0),a!==r.check)?Fr:(i=ua(e,t,n,n),i?(r.mode=16210,qr):(r.havedict=1,Dr)))},inflateInfo:"pako inflate (from Nodeca project)"};var la=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 da=Object.prototype.toString,{Z_NO_FLUSH:ha,Z_FINISH:fa,Z_OK:pa,Z_STREAM_END:va,Z_NEED_DICT:_a,Z_STREAM_ERROR:ma,Z_DATA_ERROR:ga,Z_MEM_ERROR:ya}=nn;function Ea(e){this.options=nr({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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new cr,this.strm.avail_out=0;let n=ca.inflateInit2(this.strm,t.windowBits);if(n!==pa)throw new Error(tn[n]);if(this.header=new la,ca.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=sr(t.dictionary):"[object ArrayBuffer]"===da.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ca.inflateSetDictionary(this.strm,t.dictionary),n!==pa)))throw new Error(tn[n])}function ka(e,t){const n=new Ea(t);if(n.push(e),n.err)throw n.msg||tn[n.err];return n.result}Ea.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let i,s,o;if(this.ended)return!1;for(s=t===~~t?t:!0===t?fa:ha,"[object ArrayBuffer]"===da.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),i=ca.inflate(n,s),i===_a&&a&&(i=ca.inflateSetDictionary(n,a),i===pa?i=ca.inflate(n,s):i===ga&&(i=_a));n.avail_in>0&&i===va&&n.state.wrap>0&&0!==e[n.next_in];)ca.inflateReset(n),i=ca.inflate(n,s);switch(i){case ma:case ga:case _a:case ya:return this.onEnd(i),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||i===va))if("string"===this.options.to){let e=ur(n.output,n.next_out),t=n.next_out-e,a=or(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(i!==pa||0!==o){if(i===va)return i=ca.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Ea.prototype.onData=function(e){this.chunks.push(e)},Ea.prototype.onEnd=function(e){e===pa&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=rr(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ba={Inflate:Ea,inflate:ka,inflateRaw:function(e,t){return(t=t||{}).raw=!0,ka(e,t)},ungzip:ka,constants:nn};const{Deflate:Ca,deflate:wa,deflateRaw:xa,gzip:Sa}=br,{Inflate:Ta,inflate:Ia,inflateRaw:Na,ungzip:Aa}=ba;var Ma,Oa={Deflate:Ca,deflate:wa,deflateRaw:xa,gzip:Sa,Inflate:Ta,inflate:Ia,inflateRaw:Na,ungzip:Aa,constants:nn},Ua=function(e){return E(void 0,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Oa.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,n));case 2:case"end":return t.stop()}}),t)})))};e.ConnectionState=void 0,(Ma=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",Ma.OPEN="OPEN",Ma.CLOSED="CLOSED";var Da,Ra=function(t){function a(e,t){var i,s=t.sdkState,o=t.dispatcher,u=t.logger;return r(this,a),(i=n(this,a)).lastActive=0,i._iid=e,i._sdkState=s,i._dispatcher=o,i._logger=u,i}return c(a,t),i(a,[{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:"ws",get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ke.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 Qe(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return E(this,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){r._logger.debug("websocket open"),r.dispatch("open")},this._ws.onmessage=function(e){return E(r,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)){t.next=38;break}if(!(e.data instanceof Blob)){t.next=7;break}(r=new FileReader).readAsArrayBuffer(e.data),r.onloadend=function(){return E(u,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Ua(r.result);case 3:t=e.sent,this._handleMessage(t),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),this.error(e.t0);case 10:case"end":return e.stop()}}),e,this,[[0,7]])})))},t.next=36;break;case 7:if(!(e.data instanceof ArrayBuffer)){t.next=20;break}return t.prev=8,t.next=11,Ua(new Uint8Array(e.data));case 11:a=t.sent,this._handleMessage(a),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),this.error(t.t0);case 18:t.next=36;break;case 20:if(!("undefined"!=typeof Buffer&&e.data instanceof Buffer)){t.next=35;break}return t.prev=21,i=e.data,s=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),t.next=26,Ua(s);case 26:o=t.sent,this._handleMessage(o),t.next=33;break;case 30:t.prev=30,t.t1=t.catch(21),this.error(t.t1);case 33:t.next=36;break;case 35:"string"==typeof e.data&&this._handleMessage(e.data);case 36:t.next=39;break;case 38:this._handleMessage(e.data);case 39:case"end":return t.stop()}}),t,this,[[8,15],[21,30]])})))},this._ws.onerror=function(){r._logger.debug("websocket error"),r.dispatch("error",A.networkError)},this._ws.onclose=function(){r._logger.debug("websocket close"),r.dispatch("close")},this.lastActive=Date.now();case 6:case"end":return n.stop()}}),n,this)})))}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws?(t._ws.onopen=ft,t._ws.onmessage=ft,t._ws.onerror=ft,t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=void 0):n()):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)}}])}(de),La=function(e){function t(e){var a,i=e.all,s=e.feed,o=e.custom_types,u=e.ts;return r(this,t),(a=n(this,t)).all=i,a.feed=s,a.customTypes=o,a.ts=u,a}return c(t,e),i(t)}(fe),Pa=function(){return i((function e(t,n){var a=this,i=n.session,s=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=s,this._dispatcher=o,this._logger=u,this.apiClient=new ht(t,{session:i,sdkState:s,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new Ra(t,{sdkState:s,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new La(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()}))}),[{key:"_sendApiRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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(n=new ut,e.ackRequired){a=function(t,a){i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),r&&(clearTimeout(r),r=null),t?(i._logger.debug("fail websocket request",e.requestId,t),n.reject(t)):(i._logger.debug("receive websocket ack",e.requestId,e),i._logger.debug("receive websocket ack",a),n.resolve(a)))};try{r=setTimeout((function(){return a(A.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return a(void 0,e)},reject:function(e){return a(e)}}),this.websocketClient.send(e)}catch(e){a(e)}}else try{this.websocketClient.send(e),n.resolve()}catch(e){n.reject(e)}return t.abrupt("return",n.promise);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ve)){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 We)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw A.invalidParameters;case 11:case"end":return t.stop()}}),t,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}])}();!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"}(Da||(Da={}));var Fa,qa,Ha=function(e){function t(e){var a,i=e.stateType;return r(this,t),(a=n(this,t)).stateType=i,a}return c(t,e),i(t)}(fe),Ga=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),ja=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Va=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),za=function(){return i((function e(t){var n,a,i,s;r(this,e),this.isEnabled=null!==(n=t.enabled)&&void 0!==n&&n,this.feedChannels=null!==(a=t.feed_channels)&&void 0!==a?a:{},this.templateListToken=null!==(i=t.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(s=t.settings_updated_at)&&void 0!==s?s:0}),null,[{key:"payloadify",value:function(e){return pe(ve({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}])}(),Ba=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},Qa=function(){return i((function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}),null,[{key:"payloadify",value:function(e){return pe(ve({last_updated_at:e.lastUpdatedAt}))}}])}(),Ka=function(){return i((function e(t){var n;r(this,e),this.token=null!==(n=t.template_list_token)&&void 0!==n?n:""}),null,[{key:"payloadify",value:function(e){return pe(ve({template_list_token:e.token}))}}])}(),Wa=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180};r(this,e),this.minStatCount=t.min_stat_count,this.minInterval=1e3*t.min_interval,this.maxStatCountPerRequest=t.max_stat_count_per_request,this.lowerThreshold=t.lower_threshold,this.requestDelayRange=1e3*t.request_delay_range}),null,[{key:"payloadify",value:function(e){return pe(ve({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}])}(),Ya=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}};r(this,e),this.default=new Wa(t.default),this.realTime=new Wa(t.realtime)}),null,[{key:"payloadify",value:function(e){return pe(ve({default:Wa.payloadify(e.default),realtime:Wa.payloadify(e.realTime)}))}}])}(),Za=1048576;e.UnreadCountThreadingPolicy=void 0,(Fa=e.UnreadCountThreadingPolicy||(e.UnreadCountThreadingPolicy={}))[Fa.NONE=0]="NONE",Fa[Fa.INCLUDE_REPLY=1]="INCLUDE_REPLY",Fa[Fa.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Fa[Fa.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",e.LastMessageThreadingPolicy=void 0,(qa=e.LastMessageThreadingPolicy||(e.LastMessageThreadingPolicy={}))[qa.NONE=0]="NONE",qa[qa.INCLUDE_REPLY=1]="INCLUDE_REPLY",qa[qa.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",qa[qa.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";var Xa,Ja=function(){return i((function t(){var n,a,i,s,o,u,c,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),this.emojiHash=l.emoji_hash||"",this.uploadSizeLimit=l.file_upload_size_limit?l.file_upload_size_limit*Za:Number.MAX_SAFE_INTEGER,this.useReaction=!!l.use_reaction,this.applicationAttributes=null!==(n=l.application_attributes)&&void 0!==n?n:[],this.premiumFeatureList=null!==(a=l.premium_feature_list)&&void 0!==a?a:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(i=l.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(s=l.allow_sdk_log_ingestion)||void 0===s||s,this.unreadCountThreadingPolicy=null!==(o=l.unread_cnt_threading_policy)&&void 0!==o?o:e.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(u=l.last_msg_threading_policy)&&void 0!==u?u:e.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new Qa(null!==(c=l.uikit_config)&&void 0!==c?c:{}),this.notificationInfo=l.notifications?new za(l.notifications):null,this.messageTemplateInfo=l.message_template?new Ka(l.message_template):null,this.statConfigInfo=l.log_publish_config?new Ya(l.log_publish_config):new Ya}),null,[{key:"payloadify",value:function(e){return pe(ve({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Za,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?Qa.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?za.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Ka.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Ya.payloadify(e.statConfigInfo):null}))}}])}(),$a=function(){return i((function e(t){r(this,e),this._iid="",this._iid=t}),null,[{key:"payloadify",value:function(e){return{}}}])}(),ei=function(e){function t(e){var a,i=e.userId,s=e.metadata;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s},a}return c(t,e),i(t)}(Ve),ti=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaData=a,i}return c(t,e),i(t)}(ze),ni=function(e){function t(e){var a,i=e.userId,s=e.metadata,o=e.upsert;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s,upsert:o},a}return c(t,e),i(t)}(Ve),ri=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metadata=a,i}return c(t,e),i(t)}(ze),ai=function(e){function t(e){var a,i=e.userId,s=e.metadataKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata/").concat(s),a}return c(t,e),i(t)}(Ve),ii=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata"),a}return c(t,e),i(t)}(Ve),si=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},oi=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ui=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(Xa=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",Xa.OFFLINE="offline",Xa.NON_AVAILABLE="nonavailable";var ci,li=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y;return r(this,a),(s=n(this,a,[t])).userId=null!==(u=null!==(o=i.guest_id)&&void 0!==o?o:i.user_id)&&void 0!==u?u:"",s.nickname=null!==(l=null!==(c=i.nickname)&&void 0!==c?c:i.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(h=null!==(d=i.profile_url)&&void 0!==d?d:i.image)&&void 0!==h?h:"",s.requireAuth=null!==(f=i.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=i.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,R(e.UserOnlineState,i.is_online)?s.connectionStatus=i.is_online:D("boolean",i.is_online)&&(s.connectionStatus=i.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(_=i.is_active)||void 0===_||_,s.lastSeenAt=null!==(m=i.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=i.preferred_languages?v(i.preferred_languages):null,s.friendDiscoveryKey=null!==(g=i.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=i.friend_name)&&void 0!==y?y:null,s}return c(a,t),i(a,[{key:"profileUrl",get:function(){var e=ss.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return si(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 D("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,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(this._isValidMetaData(e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ei({userId:r.userId,metadata:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(ti),u=o.metaData,this._applyMetaData(u),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(this._isValidMetaData(e)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new ni({userId:a.userId,metadata:e,upsert:t}),n.next=5,i.send(s);case 5:return o=n.sent,u=o.as(ri),c=u.metadata,this._applyMetaData(c),n.abrupt("return",this.metaData);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ai({userId:r.userId,metadataKey:e}),t.next=5,a.send(i);case 5:return this._applyMetaData((s={},u=!0,(o=_(o=e))in s?Object.defineProperty(s,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):s[o]=u,s),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var s,o,u}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ii({userId:n.userId}),e.next=4,r.send(a);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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})))}}])}($a),di=function(e){function t(e){var a,i=e.userProfile;return r(this,t),(a=n(this,t)).userProfile=i,a}return c(t,e),i(t)}(fe),hi=function(){return i((function e(t,n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new Ja(n),this.user=new li(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=n.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(s=n.pong_timeout)&&void 0!==s?s: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!==(h=null===(d=n.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==h?h: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}),[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=ss.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 di({userProfile:this}))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign(Object.assign({},li.payloadify(e.user)),Ja.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})))}}])}(),fi=function(e){function t(e){var a,i=e.request,s=void 0===i||i,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c,d=e.statConfigInfo;return r(this,t),(a=n(this,t)).request=s,a.features=Object.assign({localCache:!0,notification:!0},u),a.options=Object.assign({ingestion:!0},l),a.statConfigInfo=d,a}return c(t,e),i(t)}(fe),pi=function(e){function t(e,a,i){var s,o,u,c,l;return r(this,t),(s=n(this,t,[e,a,i])).error=null,s.services=[],s.userProfile=new hi(e,i),s.deviceTokenLastDeletedAt=null!==(o=i.device_token_last_deleted_at)&&void 0!==o?o:0,s.key=null!==(u=i.key)&&void 0!==u?u:"",s.ekey=null!==(c=i.ekey)&&void 0!==c?c:"",s.error=i.error?new A(i):null,s.services=null!==(l=i.services)&&void 0!==l?l:[],s}return c(t,e),i(t,[{key:"applyTo",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=13;break}if(!(n=ss.of(e))){t.next=10;break}return r=n.sessionManager,a=n.dispatcher,t.next=6,r.login(this);case 6:this.userProfile.apply(),a.dispatch(new fi({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),t.next=11;break;case 10:throw A.lostInstance;case 11:t.next=14;break;case 13:throw this.error;case 14:case"end":return t.stop()}}),t,this)})))}}],[{key:"asError",value:function(e){return new t("","LOGI",Object.assign({user_id:"",error:!0},e))}}])}(Ke),vi=function(){return i((function e(){r(this,e),this.type=Da.NONE,this.name="none"}),[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,t){return t.resetReconnectCount,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,t){return t.error,t.autoReconnect,t.cause,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}(),_i=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=12;break;case 5:if(t.prev=5,t.t0=t.catch(0),!(t.t0 instanceof A)){t.next=11;break}t.t0.throwOutside(),t.next=12;break;case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,null,[[0,5]])})))},mi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=7;break;case 5:t.prev=5,t.t0=t.catch(0);case 7:case"end":return t.stop()}}),t,null,[[0,5]])})))},gi=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t)).type=Da.LOGOUT,e.name="logout",e._wasPreviouslyConnected=null===(a=i.wasPreviouslyConnected)||void 0===a||a,e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=e.sdkState.userId,t.next=4,e.logout();case 4:return t.next=6,e.changeState(new Ai,n);case 6:this._wasPreviouslyConnected&&_i((function(){return E(a,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(r)}));case 1:case"end":return t.stop()}}),t)})))}));case 7:case"end":return t.stop()}}),t,this)})))}}])}(vi),yi=function(e){function t(){var e;return r(this,t),(e=n(this,t)).type=Da.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),t)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ti({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new wi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new gi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(vi),Ei=function(e){function t(e){var a,i=e.autoReconnect;return r(this,t),(a=n(this,t)).type=Da.INTERNAL_DISCONNECTED,a.name="internaldisconnected",a._autoReconnect=!1,a._autoReconnect=i,a}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new wi,n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ti({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new wi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new yi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new gi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(vi),ki=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),t)})))},bi=function(){return i((function e(){r(this,e)}),[{key:"calcTimeout",value:function(){return 0}}])}(),Ci=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new bi;return E(void 0,void 0,void 0,d().mark((function r(){var a,i,s,o,u;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=0,i=null,s=function(e){return i=null!=e?e:new Error("Halted")},o=function(){a=0};case 4:if(!(-1===t||a0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,e&&(this._webSocketClosedCause=ci.ExternalDisconnectWebSocket),t.next=4,n.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause});case 4:case"end":return t.stop()}}),t,this)})))}},{key:"logout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),t.next=4,n.onLogout(this._context,e);case 4:case"end":return t.stop()}}),t,this)})))}}])}(),Ti=function(t){function a(e){var t,i=e.authToken;return r(this,a),(t=n(this,a)).type=Da.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=i,t}return c(a,t),i(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(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ut,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,Ci((function(n){return E(i,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._haltConnect=n,r.prev=1,r.next=4,t.connect(this._authToken);case 4:r.next=16;break;case 6:if(r.prev=6,r.t0=r.catch(1),t.clearLoginTimer(),!(r.t0 instanceof A)){r.next=15;break}r.t1=r.t0.code,r.next=r.t1===e.SendbirdErrorCode.CONNECTION_CANCELED?13:15;break;case 13:return n(r.t0),r.abrupt("return");case 15:throw r.t0;case 16:case"end":return r.stop()}}),r,this,[[1,6]])})))}),t.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,t.changeState(new xi,r);case 8:_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(),t.connectionHandlers.forEach((function(e){e.onConnected&&e.onConnected(t.sdkState.userId)}));case 2:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),N(n.t0)){n.next=23;break}return n.next=16,t.disconnect();case 16:if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===e.SendbirdErrorCode.CONNECTION_CANCELED){n.next=20;break}return n.next=20,t.changeState(new Ai,r);case 20:_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new ut,this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){var n=t.error,r=void 0===n?null:n,a=t.autoReconnect,i=void 0!==a&&a,s=t.cause,o=void 0===s?null:s;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Date.now(),this._halt(null!=r?r:Ii(o)),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Ei({autoReconnect:i}),n);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new gi,n);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._halt(Ii((null==t?void 0:t.cause)||null)),r=Date.now(),!e.hasSession){n.next=7;break}return n.next=5,e.changeState(new yi,r);case 5:n.next=9;break;case 7:return n.next=9,e.changeState(new gi,r);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),this._halt(null!=t?t:A.connectionCanceled),n.next=4,e.changeState(new gi,r);case 4:case"end":return n.stop()}}),n,this)})))}}])}(vi);function Ii(e){var t=A.connectionCanceled;if(e){var n=null;switch(e){case ci.ExternalSetBackground:n="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case ci.ExternalDisconnectWebSocket:n="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}n&&t.setDetail(n)}return t}var Ni,Ai=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).type=Da.INITIALIZED,e.name="initialized",e}return c(t,e),i(t,[{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.changeState(new Ti({authToken:t}),r);case 3:case"end":return n.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new gi({wasPreviouslyConnected:!1}),n);case 3:case"end":return t.stop()}}),t)})))}}])}(vi),Mi=function(e){function t(){return r(this,t),n(this,t,[{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1}])}return c(t,e),i(t)}(We),Oi=function(){return i((function e(t){var n=t.pingDelegate,a=t.sdkState,i=t.logger;r(this,e),this.pingDelegate=n,this.sdkState=a,this._logger=i}),[{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 Mi;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)}}])}(),Ui=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"],Di=function(e){function t(e,a){var i,s,o=a.sdkState,u=a.cacheContext,c=a.connectionHandlers,l=a.sessionManager,d=a.websocketClient,h=a.dispatcher,f=a.logger,p=a.entryState,v=void 0===p?new Ai:p;return r(this,t),(i=n(this,t))._stateUpdatedAt=0,i._connectingAt=0,i._connectedAt=0,i._logiReceivedAt=0,i._connectionRequestQueue=[],i._iid=e,i.sdkState=o,i.cacheContext=u,i.connectionHandlers=c,i._sessionManager=l,i._websocketClient=d,i._dispatcher=h,i._logger=f,i._currentState=v,(null===(s=i.sdkState.websocket)||void 0===s?void 0:s.pingerDisabled)||(i._pinger=new Oi({pingDelegate:{send:function(e){return i._websocketClient.send(e)},error:function(e){return i._websocketClient.error(e)}},sdkState:i.sdkState,logger:f})),i._websocketClient.on("open",(function(){i._connectedAt=Date.now(),i._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)i.clearLoginTimer(),i._dispatcher.dispatch(e.as(pi))})).on("ping-refresh",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){i._logiProcessingTimer=setTimeout((function(){i._logiProcessingTimer=void 0,i._unresolvedLogi||i._rejectConnectionRequest(A.networkError)}),500)})),i._dispatcher.on((function(e){e instanceof pi&&(i._unresolvedLogi=e,i._tryResolveConnectionRequest())})),i}return c(t,e),i(t,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.session.hasSession}},{key:"changeState",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>=this._stateUpdatedAt)){n.next=8;break}return this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Ha({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),n.next=7,this._currentState.run(this);case 7:return n.abrupt("return",!0);case 8:return n.abrupt("return",!1);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._unresolvedLogi,!this._websocketClient.isOpen||!n){t.next=17;break}if(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),n.error){t.next=14;break}return t.next=7,n.applyTo(this._iid);case 7: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=17;break;case 14:this._sessionManager.session.authToken=void 0,n.error.isSessionExpiredError||n.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Qe({reason:n.error.code,message:n.error.message})):this._logger.warn("login failed: ".concat(n.error)),this._rejectConnectionRequest(n.error);case 17:case"end":return t.stop()}}),t,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=this.sdkState,n=t.appId,r=t.appVersion,a=t.userId,i=t.extensions,s=t.sendbirdRuntimeEnvironment,o=this.cacheContext.localCacheEnabled,u=this._sessionManager.session,c=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=i?i:{}).sb_uikit,d=ot.userAgentWithExtension(i);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(u.hasSession?"":"&user_id=".concat(encodeURIComponent(a)),"&pmce=").concat(c?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent(ot.sendbirdSdkUserAgentWithExtension(s)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(Ui))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new $e(new at({type:je.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:this._connectedAt>0?this._connectedAt-this._connectingAt:0,logi_latency:this._logiReceivedAt>0?this._logiReceivedAt-this._connectedAt:void 0,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(A.connectionCanceled)),r=new ut,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout((function(){s._loginTimer=void 0,s._rejectConnectionRequest(A.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),a=this._sessionManager.session,t&&(a.authToken=t,a.sessionKey=void 0),i=this._url(),a.sessionKey||a.authToken?this._websocketClient.connect(i,JSON.stringify(a.hasSession?{auth:a.sessionKey}:{token:a.authToken})):this._websocketClient.connect(i,JSON.stringify({}))),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(pi.asError(A.connectionRenew))}},{key:"disconnect",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){return d().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.disconnect();case 4:return e.next=6,this._sessionManager.clear();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}])}(de),Ri=function(e){function t(e){var a,i=e.appId,s=e.userId,o=e.includeUIKitConfig,u=void 0!==o&&o,c=e.localCacheEnabled,l=void 0===c||c,d=e.expiringSession,h=void 0===d||d;return r(this,t),(a=n(this,t)).path="".concat(ye,"/").concat(s,"/authentication"),a.method=_e.POST,a.params=pe({expiring_session:!!h,include_logi:!0,include_extra_data:String(Ui),uikit_config:u,use_local_cache:l,app_id:i}),a.requireAuth=!1,a}return c(t,e),i(t)}(Ve),Li=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).logi=new pi(e,"LOGI",a),i}return c(t,e),i(t)}(ze);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(Ni||(Ni={}));var Pi,Fi,qi=[Ye,Ri],Hi=function(){return i((function e(t,n){var a=this,i=n.session,o=n.sdkState,u=n.dispatcher,c=n.logger,l=n.useFetchCompat,d=void 0!==l&&l;r(this,e),this._currentConnectionStateType=Da.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Pa(t,{session:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:d}),this._session=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){var t;if(e instanceof Ha){var n=e.stateType;switch(a._currentConnectionStateType=n,n){case Da.CONNECTED:a._resolveLazyCallQueue();break;case Da.INITIALIZED:case Da.INTERNAL_DISCONNECTED:case Da.EXTERNAL_DISCONNECTED:case Da.LOGOUT:a._rejectLazyCallQueue((null===(t=a._session)||void 0===t?void 0:t.hasSession)?A.connectionClosed:A.connectionRequired)}}else if(e instanceof Ga)a._session.hasChatServicePermission||a._resolveLazyCallQueue(Ni.API);else if(e instanceof ja||e instanceof Va)a._rejectLazyCallQueue(A.connectionClosed);else if(e instanceof et){var r,i=e.request,o=e.deferred,u=e.error,c=s(qi);try{for(c.s();!(r=c.n()).done;){if(i instanceof r.value)return void o.reject(u)}}catch(e){c.e(e)}finally{c.f()}a._lazyCallQueue.push({command:i,deferred:o})}}))}),[{key:"isReady",get:function(){return this._currentConnectionStateType===Da.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===Da.CONNECTING||this._currentConnectionStateType===Da.RECONNECTING||this._session.isRefreshing}},{key:"_classifyLazyCallQueueByScope",value:function(e){var t,n=[],r=[];switch(e){case Ni.ALL:t=null;break;case Ni.WEBSOCKET:t=We;break;case Ni.API:t=Ve}var a=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(a=!0),a?r.push(e):n.push(e)})),[n,r]}},{key:"_resolveLazyCallQueue",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ni.ALL,n=f(this._classifyLazyCallQueueByScope(t),2),r=n[0],a=n[1];this._lazyCallQueue=a,r.forEach((function(t){return E(e,void 0,void 0,d().mark((function e(){var n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.command,r=t.deferred,(a=t.timeout)&&clearTimeout(a),e.prev=2,e.next=5,this.send(n);case 5:i=e.sent,r.resolve(i),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),r.reject(e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])})))}))}},{key:"_rejectLazyCallQueue",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ni.ALL,r=f(this._classifyLazyCallQueueByScope(n),2),a=r[0],i=r[1];this._lazyCallQueue=i,a.forEach((function(n){return E(t,void 0,void 0,d().mark((function t(){var r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n.deferred,a=n.timeout,clearTimeout(a),r.reject(e);case 3:case"end":return t.stop()}}),t)})))}))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof We)){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:case 31:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),n=new ut,this._lazyCallQueue.push({command:e,deferred:n,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",n.promise);case 15:throw this._logger.debug("fail websocket request"),A.connectionRequired;case 17:case 44:t.next=47;break;case 19:if(!(e instanceof Ve)){t.next=46;break}if(!this._session.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!e.hasSessionKey){t.next=34;break}return this._logger.debug("send api request with tmp session key",e),t.next=31,this.commandRouter.send(e);case 34:if(!this.isLazyCallActivated){t.next=41;break}return this._logger.debug("wait api request",e),r=new ut,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 41:throw a=A.connectionRequired,this._logger.debug("fail api request",a),a;case 46:throw A.invalidCommand;case 47:case"end":return t.stop()}}),t,this)})))}},{key:"forceSend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._logger.debug("send forced request",e),!(e instanceof We||e instanceof Ve)){t.next=7;break}return t.next=4,this.commandRouter.send(e);case 4:return t.abrupt("return",t.sent);case 7:throw A.invalidCommand;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(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()}}])}(),Gi="sendbird@devicetokens",ji=function(){return i((function e(t){var n=t.type,a=t.token,i=t.device_os,s=t.device_manufacturer,o=t.system_push_enabled;r(this,e),this.type=n,this.token=a,this.deviceOS=i,this.deviceManufacturer=s,this.systemPushEnabled=o}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}])}(),Vi=new WeakMap,zi=function(t){function a(e){var t,i=e._iid,s=e.session,o=e.cacheContext,u=e.sdkState,c=e.dispatcher,l=e.requestQueue,d=e.logger,h=e.pushNotificationAckManager;return r(this,a),(t=n(this,a))._currentConnectionStateType=Da.INITIALIZED,t._isRefreshingAuthToken=!1,t.currentUser=null,t.session=s,t._iid=i,t._cacheContext=o,t._sdkState=u,t._dispatcher=c,t._requestQueue=l,t._logger=d,t._pushNotificationAckManager=h,t._deviceTokens=[],t._dispatcher.on((function(e){var n,r,a;if(e instanceof Ha){var i=e.stateType;t._currentConnectionStateType=i}else if(e instanceof Qe&&t.handler&&!t.isSessionKeyRefreshing){if(t._currentConnectionStateType===Da.CONNECTING)return;(null===(n=e.error)||void 0===n?void 0:n.isSessionInvalidatedError)?t.close():((null===(r=e.error)||void 0===r?void 0:r.isSessionTokenExpiredError)&&t.refreshAuthToken().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e})),(null===(a=e.error)||void 0===a?void 0:a.isSessionKeyExpiredError)&&(t._logger.debug("session expired"),t.handler.onSessionExpired&&t.handler.onSessionExpired(),t.refreshSessionKey().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e}))))}})),t}return c(a,t),i(a,[{key:"ekey",get:function(){return Vi.get(this)}},{key:"deviceTokens",get:function(){return this._deviceTokens}},{key:"deviceTokenLastDeletedAt",get:function(){return this._deviceTokenLastDeletedAt}},{key:"indexOfDeviceToken",value:function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))}},{key:"hasDeviceToken",value:function(e,t){return this.indexOfDeviceToken(e,t)>=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new Ze({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(n);case 3:if(r=t.sent,a=r.as(Je),i=a.newKey,!(s=a.error)){t.next=7;break}throw s;case 7:this.session.sessionKey=null!=i?i:this.session.sessionKey;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Ye({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),t.next=3,Ci((function(e){return E(r,void 0,void 0,d().mark((function t(){var r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(n);case 3:r=t.sent,a=r.as(Xe),i=a.key,s=a.services,this.session.sessionKey=i,this.session.services=s,t.next=16;break;case 9:if(t.prev=9,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=15;break}e(t.t0),t.next=16;break;case 15:throw t.t0;case 16:case"end":return t.stop()}}),t,this,[[0,9]])})))}),3);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKey",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._currentConnectionStateType!==Da.CONNECTED){n.next=18;break}return n.prev=1,n.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),n.abrupt("return");case 8:return n.prev=8,n.t0=n.catch(1),n.prev=10,n.next=13,this._handleSessionRefreshError(n.t0,t);case 13:return n.abrupt("return");case 16:n.prev=16,n.t1=n.catch(10);case 18:return n.prev=18,n.next=21,this._refreshSessionKeyByApi(e);case 21:this.complete(),n.next=28;break;case 24:return n.prev=24,n.t2=n.catch(18),n.next=28,this._handleSessionRefreshError(n.t2,t);case 28:case"end":return n.stop()}}),n,this,[[1,8],[10,16],[18,24]])})))}},{key:"_receiveNewAuthToken",value:function(){var e,t=this,n=new ut;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var r=null,a=function(){r&&(clearTimeout(r),r=null)},i=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},s=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};r=setTimeout((function(){return s()}),1e3*this._sdkState.sessionTokenRefreshTimeout),_i((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(i,s);case 1:case"end":return e.stop()}}),e,this)})))}))}else n.resolve(null);return n.promise}},{key:"_handleSessionRefreshError",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(t instanceof A)){r.next=16;break}if(!t.isSessionTokenExpiredError&&t.code!==e.SendbirdErrorCode.APPLICATION_NOT_FOUND){r.next=16;break}if(this.session.authToken=void 0,!n){r.next=16;break}return r.next=6,this._receiveNewAuthToken();case 6:if(!(a=r.sent)){r.next=13;break}return this.session.authToken=a,r.next=11,this._refreshSessionKey(this.session.authToken,!1);case 11:r.next=15;break;case 13:return r.next=15,this.clear();case 15:return r.abrupt("return");case 16:throw t;case 17:case"end":return r.stop()}}),r,this)})))}},{key:"_isSessionRelatedError",value:function(e){return e instanceof A&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}},{key:"isSessionKeyRefreshing",get:function(){return this.session.isRefreshing}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"isSessionExpiring",get:function(){return!!this.handler}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.session.authToken=t,a=new Ri({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!t||this.isSessionExpiring}),r.next=4,this._requestQueue.commandRouter.send(a);case 4:if(i=r.sent,s=i.as(Li),(o=s.logi).error){r.next=12;break}if(this.session.hasChatServicePermission){r.next=10;break}return r.next=10,o.applyTo(this._iid);case 10:r.next=13;break;case 12:throw o.error;case 13:case"end":return r.stop()}}),r,this)})))}},{key:"login",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=e.key,a=e.ekey,i=e.services,s=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.session.sessionKey=r,this.session.services=i,Vi.set(this,a),this._deviceTokenCacheEnabled=null===(t=null==s?void 0:s.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){n.next=21;break}return n.next=9,c.get(Gi);case 9:if((l=n.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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return t=this._cacheContext.preference,e.next=4,t.set(Gi,{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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.session.clear(),this.close(),Vi.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:this._pushNotificationAckManager.clear();case 9:case"end":return e.stop()}}),e,this)})))}}])}(de),Bi=function(e,t){if(null!==e&&null!==t){var n,r=Object.keys(e),a=Object.keys(t),i={},o=s(v(new Set([].concat(r,a))));try{for(o.s();!(n=o.n()).done;){var u=n.value,c=m(e[u]),l=m(t[u]);"undefined"===c?i[u]=t[u]:"undefined"===l?i[u]=e[u]:c!==l?i[u]=t[u]:"object"===c&&e[u]&&t[u]?i[u]=Bi(e[u],t[u]):i[u]=t[u]}}catch(e){o.e(e)}finally{o.f()}return i}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"}(Pi||(Pi={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(Fi||(Fi={}));var Qi,Ki=100,Wi=function(){return i((function e(t){var n=t.deviceId,a=t.cacheContext,i=t.requestQueue;r(this,e),this.queue=[],this.flushWaitQueue=[],this.enabledState=Pi.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=n,this.cacheContext=a,this.requestQueue=i,this.logInfo={deviceId:n,statLogs:[],generation:1,lastFlushedAt:0},this.limit=Ki}),[{key:"isEnabled",get:function(){return this.enabledState===Pi.ENABLED}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:(n=t.sent)&&(this.logInfo=n);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_mergeQueue",value:function(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}},{key:"_isDuplicateStat",value:function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}},{key:"_save",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(v(this.queue),v(this.flushWaitQueue)),e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:t.map((function(e){return at.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save();case 4:case"end":return e.stop()}}),e,this)})))}}])}(),Yi=function(e){function t(e){var a,i,s,o,u,c=e.type,l=e.data,d=e.ts,h=void 0===d?Date.now():d;return r(this,t),(a=n(this,t,[{type:c,data:l,ts:h}])).date=new Date(h),a.key="".concat((i=a.date,s=i.getFullYear(),o=String(i.getMonth()+1).padStart(2,"0"),u=String(i.getDate()).padStart(2,"0"),"".concat(s).concat(o).concat(u)),"_").concat(c),a}return c(t,e),i(t)}(at),Zi=function(e){function t(e){var a,i=e.deviceId,s=e.statLogs;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Oe),a.params={device_id:i,log_entries:s.map((function(e){return at.payloadify(e)}))},a}return c(t,e),i(t)}(Ve),Xi=function(t){function a(e){var t=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:i,requestQueue:s}])}return c(a,t),i(a,[{key:"_isSendable",get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var t=this,n=Object.create(null,{init:{get:function(){return p(a,"init",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.init.call(this,e+".daily");case 2:this.queue=this.logInfo.statLogs.map((function(e){return new at({type:e.stat_type,ts:e.ts,data:e.data})}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),!t.localCacheStat){n.next=7;break}this.enabledState=t.enabledStat?Pi.ENABLED:Pi.COLLECT_ONLY,n.next=10;break;case 7:return this.enabledState=Pi.DISABLED,n.next=10,this.clear();case 10:if(!this.isEnabled||!this._isSendable){n.next=25;break}return n.next=13,this._getUploadStats();case 13:r=n.sent,a=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),i=0;case 16:if(!(i0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Zi({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Ki,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Pi.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Pi.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}(Wi),Ji=function(t){function a(e){var t=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:i,requestQueue:s}])}return c(a,t),i(a,[{key:"_isSendable",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.queue.length0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Zi({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Ki,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Pi.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Pi.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}(Wi),$i=function(e){function t(e){var a,i=e.deviceId,s=e.statLogs;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Ue),a.params={device_id:i,log_entries:s.map((function(e){return at.payloadify(e)}))},a}return c(t,e),i(t)}(Ve),es=function(t){function a(e){var t=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:i,requestQueue:s}])}return c(a,t),i(a,[{key:"_isSendable",get:function(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var t=this,n=Object.create(null,{init:{get:function(){return p(a,"init",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.init.call(this,e+".realtime");case 2:this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new at({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this._mergeQueue(),!t.notificationStat){n.next=6;break}this.enabledState=t.enabledStat?Pi.ENABLED:Pi.COLLECT_ONLY,n.next=9;break;case 6:return this.enabledState=Pi.DISABLED,n.next=9,this.clear();case 9:if(!this.isEnabled||!this._isSendable){n.next=15;break}return r=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),n.next=13,ki(r);case 13:return n.next=15,this._flush(this.queue);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState!==Pi.DISABLED){t.next=2;break}return t.abrupt("return",!0);case 2:if(n=this.enabledState===Pi.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,!this._isDuplicateStat(e)){t.next=5;break}return t.abrupt("return",!0);case 5:if(n.push(e),this.enabledState===Pi.PENDING){t.next=9;break}return t.next=9,this._save();case 9:if(!this.isEnabled){t.next=15;break}if(this._mergeQueue(),!this.isEnabled||!this._isSendable){t.next=15;break}return t.next=14,this._flush(n);case 14:return t.abrupt("return",t.sent);case 15:return t.abrupt("return",!0);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"_flush",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=!0,!(t.length>0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new $i({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Ki,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Pi.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Pi.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}(Wi),ts=function(){return i((function e(t){var n=t.cacheContext,a=t.requestQueue,i=t.dispatcher,s=t.logger;r(this,e),this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=ce(),this.cacheContext=n,this.requestQueue=a,this.dispatcher=i,this.logger=s,this._dailyStatCollector=new Xi({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Ji({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new es({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}),[{key:"_migration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cacheContext.preference.get(this.key);case 2:if(!(t=e.sent)){e.next=18;break}return n=[],t.statLogs.forEach((function(e){e.stat_type===je.FEATURE_LOCALCACHE&&n.push(new at({type:e.stat_type,ts:e.ts,data:e.data}))})),e.next=8,this.cacheContext.preference.set(this.key+".daily",{deviceId:t.deviceId,statLogs:n.map((function(e){return at.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 8:return r=[],t.statLogs.forEach((function(e){e.stat_type!==je.FEATURE_LOCALCACHE&&e.stat_type!==je.NOTIFICATION&&(e.stat_type===je.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),r.push(new at({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=12,this.cacheContext.preference.set(this.key+".default",{deviceId:t.deviceId,statLogs:r.map((function(e){return at.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 12:return a=[],t.statLogs.forEach((function(e){var t;e.stat_type===je.NOTIFICATION&&(e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),a.push(new at({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=16,this.cacheContext.preference.set(this.key+".realtime",{deviceId:t.deviceId,statLogs:a.map((function(e){return at.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 16:return e.next=18,this.cacheContext.preference.remove(this.key);case 18:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this._migration();case 3:return t.next=5,this._dailyStatCollector.init(this.key);case 5:return t.next=7,this._defaultStatCollector.init(this.key);case 7:return t.next=9,this._notificationStatCollector.init(this.key);case 9:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e instanceof $e?(r=e.statLog,this.put(r)):e instanceof fi&&(a=e.request,i=e.features,s=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=a,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._notificationStatCollector.setConfig(null!==(n=this._statConfig.realTime)&&void 0!==n?n:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:s.ingestion}));case 1:case"end":return t.stop()}}),t,this)})))})));case 10:case"end":return t.stop()}}),t,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=!0,!(e instanceof Yi)){t.next=8;break}if(!this._collectFeatureLocalCacheStat){t.next=6;break}return t.next=5,this._dailyStatCollector.put(e);case 5:n=t.sent;case 6:t.next=26;break;case 8:t.t0=e.type,t.next=t.t0===je.API_RESULT||t.t0===je.WEBSOCKET_CONNECT?11:t.t0===je.FEATURE_LOCALCACHE||t.t0===je.FEATURE_LOCALCACHE_EVENT?16:t.t0===je.NOTIFICATION?21:26;break;case 11:if(!this._collectRequestStat){t.next=15;break}return t.next=14,this._defaultStatCollector.put(e);case 14:n=t.sent;case 15:return t.abrupt("break",26);case 16:if(!this._collectFeatureLocalCacheStat){t.next=20;break}return t.next=19,this._defaultStatCollector.put(e);case 19:n=t.sent;case 20:return t.abrupt("break",26);case 21:if(!this._collectionNotificationStat){t.next=25;break}return t.next=24,this._notificationStatCollector.put(e);case 24:n=t.sent;case 25:return t.abrupt("break",26);case 26:n?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Pi.COLLECT_ONLY,this._defaultStatCollector.enabledState=Pi.COLLECT_ONLY,this._notificationStatCollector.enabledState=Pi.COLLECT_ONLY,this.logger.debug(A.statLogUploadLimitExceededError)));case 27:case"end":return t.stop()}}),t,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}])}(),ns=function(){return i((function e(t){var n=t.limit,a=void 0===n?5:n;r(this,e),this.workersByKey={},this.limit=a}),[{key:"run",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.workersByKey[e]||(this.workersByKey[e]=[]),!(this.workersByKey[e].length0:void 0,i.lastRepliedAt=null!==(c=a.last_replied_at)&&void 0!==c?c:0,i.updatedAt=null!==(l=a.updated_at)&&void 0!==l?l:0,i}return c(t,e),i(t,[{key:"_isUpdateRequired",get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}},{key:"_updateFrom",value:function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((function(e){return li.payloadify(e)})):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}}])}($a);e.ReactionEventOperation=void 0,(rs=e.ReactionEventOperation||(e.ReactionEventOperation={})).ADD="add",rs.DELETE="delete";var hs,fs=i((function t(n){r(this,t),this.messageId=0,this.operation=null,this.updatedAt=0;var a=D("string",n.msg_id)?parseInt(n.msg_id):n.msg_id,i=n.user_id,s=n.operation?n.operation.toLowerCase():null,o=n.reaction,u=n.updated_at;a&&D("string",i)&&D("string",s)&&R(e.ReactionEventOperation,s)&&D("string",o)&&o&&D("number",u)&&(this.messageId=a,this.userId=i,this.key=o,this.operation=s,this.updatedAt=u)})),ps=function(){return i((function e(t){var n;r(this,e);var a=t.key,i=null!==(n=v(t.user_ids))&&void 0!==n?n:[],o=t.updated_at;D("string",a)&&a&&P("string",i)&&i.length>0&&D("number",o)&&(this.key=a,this.userIds=i,this.updatedAt=o);var u,c={},l=s(this.userIds);try{for(l.s();!(u=l.n()).done;){c[u.value]=this.updatedAt}}catch(e){l.e(e)}finally{l.f()}this._version=c}),[{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 pe(ve({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}}])}(),vs=function(){return i((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)}),null,[{key:"payloadify",value:function(e){var t,n;return pe(ve({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}))}}])}(),_s=function(){return i((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 vs(t["og:image"]))}),null,[{key:"payloadify",value:function(e){return pe(ve({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?vs.payloadify(e.defaultImage):null}))}}])}(),ms=function(){return i((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}),[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return pe(ve({name:e.name,volume:e.volume}))}}])}();e.FeedbackRating=void 0,(hs=e.FeedbackRating||(e.FeedbackRating={})).GOOD="good",hs.BAD="bad";var gs,ys=function(){function e(t){r(this,e),this.id=t.id,this.rating=t.rating,this.comment=t.comment}return i(e,null,[{key:"_getStatus",value:function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}},{key:"_isSubmitted",value:function(t){return"SUBMITTED"===e._getStatus(t)}},{key:"_getPayloadByStatus",value:function(e){return"NO_FEEDBACK"===e?{}:null}},{key:"payloadify",value:function(e){return pe(ve({id:e.id,rating:e.rating,comment:e.comment}))}}])}(),Es=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i])).isBlockedByMe=!1,s.role=R(e.Role,i.role)?i.role:e.Role.NONE,s.isBlockedByMe=null!==(o=i.is_blocked_by_me)&&void 0!==o&&o,s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}])}(li),ks=function(){return i((function e(t){r(this,e),this.key=t.key,this.value=P("string",t.value)?v(t.value):[]}),null,[{key:"payloadify",value:function(e){var t;return pe(ve({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}])}(),bs=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"}},Cs=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;r(this,a),(s=n(this,a,[t])).channelType=e.ChannelType.BASE,s.messageType=e.MessageType.BASE,s.mentionType=null,s.mentionedUsers=null,s.mentionedUserIds=null,s.mentionedMessageTemplate=void 0,s.metaArrays=[],s.extendedMessage={},s.createdAt=0,s.updatedAt=0,s.channelUrl=i.channel_url,s.channelType=R(e.ChannelType,i.channel_type)?i.channel_type:e.ChannelType.GROUP,i.channel&&(i.channel.channel_url&&(s.channelUrl=i.channel.channel_url),i.channel.channel_type&&(s.channelType=i.channel.channel_type)),s.data=null!==(o=i.data)&&void 0!==o?o:"",s.customType=null!==(u=i.custom_type)&&void 0!==u?u:"",s.mentionType=R(e.MentionType,i.mention_type)?i.mention_type:null,s.mentionedUsers=i.mentioned_users?i.mentioned_users.map((function(e){return new li(s._iid,e)})):null,s.mentionedUserIds=null!==(c=i.mentioned_user_ids)&&void 0!==c?c:null,s.mentionedUsers&&!s.mentionedUserIds&&(s.mentionedUserIds=s.mentionedUsers.map((function(e){return e.userId}))),s.mentionedMessageTemplate=i.mentioned_message_template;var _=null!==(l=i.metaarray)&&void 0!==l?l:{},m=null!==(d=i.metaarray_key_order)&&void 0!==d?d:Object.keys(_).sort((function(e,t){return e.localeCompare(t)}));s.metaArrays=[];for(var g=0;g0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,items:e.items.map((function(e){return Xs.payloadify(e)})),version:e.version,is_submitted:e._isSubmitted}))}},{key:"isMessageFormPayload",value:function(e){return Boolean(null==e?void 0:e.message_form)}}])}(),Xs=function(){return i((function e(t){r(this,e);var n=t.id,a=t.name,i=t.required,s=t.sort_order,o=t.placeholder,u=t.style,c=t.item_type,l=t.validators,d=t.value,h=t.values;this.id=n,this.name=a,this.required=i,this.sortOrder=s,this.placeholder=o,0===Object.keys(u).length?this.style={layout:c}:this.style=pe({layout:u.layout,options:u.options,defaultOptions:u.default_options,resultCount:u.result_count}),h?this.submittedValues=h:d&&(this.submittedValues=[d]),this._validators=l}),[{key:"isValid",value:function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case Ds.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case Ds.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case Ds.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case Ds.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case Ds.DECIMAL_PLACE:if(0===e.length)return!1;var r=Number(e);return!(isNaN(r)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(r,t.max_decimal_place));default:return!0}}))}(e,t._validators);return n}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:pe({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}])}(),Js=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le,"/").concat(e.formId,"/submit"),a.params=pe({message_id:e.messageId,items:e.items}),a}return c(t,e),i(t)}(Ve);e.ScheduledStatus=void 0,(Ws=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",Ws.SENT="sent",Ws.FAILED="failed",Ws.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 $s,eo=function(t){function a(e,t){var i,s,o,u,c,l,d,h,f,p;return r(this,a),(i=n(this,a,[e,t])).parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.threadInfo=null,i.reactions=[],i.appleCriticalAlertOptions=null,i.scheduledInfo=null,i.suggestedReplies=null,i.myFeedback=null,i.myFeedbackStatus="NOT_APPLICABLE",i.messageForm=null,i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(o=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==o?o:0,i.parentMessageId=null!==(u="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==u?u:0,i.threadInfo=t.thread_info?new ds(i._iid,t.thread_info):null,i.reactions=t.reactions?t.reactions.map((function(e){return new ps(e)})):[],i.ogMetaData=t.og_tag?new _s(t.og_tag):null,i.silent=null!==(c=t.silent)&&void 0!==c&&c,i.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,i.appleCriticalAlertOptions=t.apple_critical_alert_options?new ms(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(i.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},i._scheduledStatus=t.scheduled_status),i._isContinuousMessages=null!==(d=t.is_continuous_messages)&&void 0!==d&&d,i.myFeedback=ys._isSubmitted(t.feedback)?new ys(t.feedback):null,i.myFeedbackStatus=ys._getStatus(t.feedback),i.suggestedReplies=null!==(f=null===(h=t.extended_message_payload)||void 0===h?void 0:h.suggested_replies)&&void 0!==f?f:null,i.messageForm=Zs.isMessageFormPayload(t.extended_message_payload)?new Zs(i.messageId,t.extended_message_payload.message_form):null,i.message=null!==(p=t.message)&&void 0!==p?p:"",i}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.messageId===e.messageId}},{key:"applyThreadInfoUpdateEvent",value:function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}},{key:"applyReactionEvent",value:function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1}},{key:"_triggerThreadInfoUpdatedEvent",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=ss.of(this._iid),(r=n.dispatcher).dispatch(new Ks({channelType:e.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),r.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"markThreadAsRead",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Ts({channelUrl:this.channelUrl,messageId:this.messageId}),e.next=4,n.send(r);case 4:if(!this.threadInfo||0===this.threadInfo.unreadReplyCount){e.next=8;break}return this.threadInfo.unreadReplyCount=0,e.next=8,this._triggerThreadInfoUpdatedEvent();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setPushNotificationEnabled",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Is({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),t.next=4,r.send(a);case 4:this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"submitMessageForm",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=ss.of(this._iid),a=r.requestQueue,i=null,s=null,o=this.messageForm,t||!o){n.next=13;break}if(o.isSubmittable){n.next=7;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});case 7:if(!o.isSubmitted){n.next=9;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});case 9:i=o.id,s=o.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[]),n.next=14;break;case 13:t&&(i=t.formId,s=Object.entries(t.answers).reduce((function(t,n){var r=f(n,2),a=r[0],i=r[1],s=Number(a);if(Number.isNaN(s))throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return t.push({form_item_id:s,value:i}),t}),[]));case 14:if(i&&s){n.next=16;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});case 16:return u=new Js({messageId:this.messageId,formId:i,items:s}),n.next=19,a.send(u);case 19:case"end":return n.stop()}}),n,this)})))}},{key:"submitFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ns({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(As),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ms({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t.id,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(Os),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Us({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t}),n.next=4,a.send(s);case 4:this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}));case 7:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?ds.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return ps.payloadify(e)})),og_tag:e.ogMetaData?_s.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?ms.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(t=e.scheduledInfo)||void 0===t?void 0:t.scheduledMessageId,scheduled_at:null===(n=e.scheduledInfo)||void 0===n?void 0:n.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?ys.payloadify(e.myFeedback):ys._getPayloadByStatus(e.myFeedbackStatus),message:e.message})))}},{key:"_getParentMessageInfoPayload",value:function(e){return pe(ve({type:bs(e.messageType),ts:e.createdAt,user:e.sender?Es.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Qs.payloadify(e)})):null}))}}])}(Cs),to=function(t){function a(t,i){var s,o,u,c,l;if(r(this,a),(s=n(this,a,[t,i])).reqId="",s.replyToChannel=!1,s.errorCode=0,s.sender=i.user?new Es(s._iid,i.user):i.sender_id,s.reqId=null!==(u=null!==(o=i.req_id)&&void 0!==o?o:i.request_id)&&void 0!==u?u:"",s.replyToChannel=null!==(c=i.is_reply_to_channel)&&void 0!==c&&c,i.request_state&&R(e.SendingStatus,i.request_state)&&(s.sendingStatus=i.request_state),!s.sendingStatus)if(s.messageId>0)s.sendingStatus=e.SendingStatus.SUCCEEDED;else if(s.scheduledInfo)switch(i.scheduled_status&&(s._scheduledStatus=i.scheduled_status),i.scheduled_status){case Ys.SENT:case Ys.IN_QUEUE:s.sendingStatus=e.SendingStatus.SUCCEEDED;break;case Ys.PENDING:s.sendingStatus=e.SendingStatus.SCHEDULED;break;case Ys.FAILED:case Ys.REMOVED:s.sendingStatus=e.SendingStatus.FAILED;break;case Ys.CANCELED:s.sendingStatus=e.SendingStatus.CANCELED}else s.sendingStatus=e.SendingStatus.PENDING;return s.errorCode=null!==(l=i.error_code)&&void 0!==l?l:0,s._messageToken=i.mesg_token,s}return c(a,t),i(a,[{key:"isResendable",get:function(){return(this.sendingStatus===e.SendingStatus.FAILED||this.sendingStatus===e.SendingStatus.CANCELED)&&((t=this.errorCode)>0&&M.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 pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{user:Es.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}}])}(eo),no={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ro=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)},ao=function(t){function a(t,i){var s,o,u,c;if(r(this,a),(s=n(this,a,[t,i])).translations={},s.messageType=e.MessageType.ADMIN,s.translations=null!==(o=i.translations)&&void 0!==o?o:{},i.parent_message_info){var l=i.parent_message_info;s.parentMessage=go(t,pe(ve(Object.assign(Object.assign({},l),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:l.file,url:null===(u=l.file)||void 0===u?void 0:u.url,require_auth:null===(c=l.file)||void 0===c?void 0:c.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{translations:e.translations,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(eo),io=function(){return i((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&&D("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,vendor:e.vendor,detail:e.detail}))}}])}();!function(e){e.OPEN="open",e.CLOSED="closed"}($s||($s={}));var so,oo="removed",uo=function(e){switch(e){case"open":return $s.OPEN;case"closed":return $s.CLOSED;default:return null}},co=function(e){return!e||!!e.text&&D("string",e.text)},lo=function(e){function t(e,a){var i,s,o,u,c,l,d,h;return r(this,t),(i=n(this,t,[e])).pollId=0,i.id=0,i.text=null,i.voteCount=0,i.createdBy=null,i.createdAt=0,i.updatedAt=0,i._lastVotedAt=0,i.pollId=null!==(s=a.poll_id)&&void 0!==s?s:0,i.id=null!==(o=a.id)&&void 0!==o?o:0,i.text=null!==(u=a.text)&&void 0!==u?u:null,i.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,i.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,i.createdAt=null!==(d=a.created_at)&&void 0!==d?d:0,i.updatedAt=null!==(h=a.updated_at)&&void 0!==h?h:0,i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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})))}}])}($a),ho=function(e){function t(e,a){var i,s,o,u,c,l,d,h,f,p,v,_,m,g;return r(this,t),(i=n(this,t,[e])).id=0,i.title=null,i.createdAt=0,i.updatedAt=0,i.closeAt=-1,i.status=$s.CLOSED,i.messageId=0,i.data=null,i.voterCount=-1,i.options=[],i.createdBy=null,i.allowUserSuggestion=!1,i.allowMultipleVotes=!1,i.votedPollOptionIds=[],i.id=null!==(s=a.id)&&void 0!==s?s:0,i.title=null!==(o=a.title)&&void 0!==o?o:null,i.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,i.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,i.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,i.status=null!==(d=uo(a.status))&&void 0!==d?d:$s.CLOSED,i.messageId=null!==(h=a.message_id)&&void 0!==h?h:0,i.data=null!==(f=a.data)&&void 0!==f?f:null,i.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,i.options=a.options?a.options.map((function(e){return new lo(i._iid,e)})):[],i.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,i.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,i.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,i.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],i}return c(t,e),i(t,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,i,s,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=uo(e.status))&&void 0!==a?a:this.status,this.data=null!==(i=e.data)&&void 0!==i?i:this.data,this.voterCount=null!==(s=e.voter_count)&&void 0!==s?s:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new lo(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var i=t[r];a>=i._lastVotedAt&&(i.voteCount=e.vote_count,i._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0}},{key:"serialize",value:function(){return si(this)}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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 lo.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}])}($a),fo=function(){return i((function e(t){r(this,e),this.status=t.status,t.original_message_info&&(this.originalMessageInfo={createdAt:t.original_message_info.ts,messageId:t.original_message_info.id})}),null,[{key:"payloadify",value:function(e){return pe({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}])}(),po=function(t){function a(t,i){var o,u,c,l,d,h;if(r(this,a),(o=n(this,a,[t,i])).messageParams=null,o.translations={},o.translationTargetLanguages=[],o.messageSurvivalSeconds=-1,o.plugins=[],o._poll=null,o.messageType=e.MessageType.USER,o.translations=null!==(u=i.translations)&&void 0!==u?u:{},o.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(o.translations).length&&o.translationTargetLanguages.length>0){var f,p=s(o.translationTargetLanguages);try{for(p.s();!(f=p.n()).done;){var v=f.value;o.translations[v]=""}}catch(e){p.e(e)}finally{p.f()}}if(o.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,o.plugins=i.plugins?i.plugins.map((function(e){return new io(e)})):[],o._poll=i.poll?new ho(o._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;o.parentMessage=go(t,pe(ve(Object.assign(Object.assign({},_),{created_at:_.ts,message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(o.messageReviewInfo=new fo(i.review_info)),o}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return io.payloadify(e)})),poll:e._poll?ho.payloadify(e._poll):null,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null,review_info:e.messageReviewInfo?fo.payloadify(e.messageReviewInfo):void 0})))}}])}(to),vo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p;if(r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.fileInfoList=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE,s.data=null!==(c=null!==(u=null===(o=i.file)||void 0===o?void 0:o.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",s.fileInfoList=null!==(d=null===(l=i.files)||void 0===l?void 0:l.map((function(e){return new Qs(t,e)})))&&void 0!==d?d:[],s.messageSurvivalSeconds=null!==(h=i.message_survival_seconds)&&void 0!==h?h:-1,i.parent_message_info){var v=i.parent_message_info;s.parentMessage=go(t,pe(ve(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===(f=v.file)||void 0===f?void 0:f.url,require_auth:null===(p=v.file)||void 0===p?void 0:p.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n,r,i,s,o;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{file:{name:null!==(n=null===(t=e.fileInfoList[0])||void 0===t?void 0:t.fileName)&&void 0!==n?n:"",size:null!==(i=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.fileSize)&&void 0!==i?i:0,type:null!==(o=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Qs.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([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)}}])}(to);!function(e){e.SENT="SENT",e.READ="READ"}(so||(so={}));var _o=function(t){function a(t,i){var s,o,u;if(r(this,a),(s=n(this,a,[t,i])).notificationData=null,s.notificationId=i.notification_message_id,s.messageType=e.MessageType.ADMIN,s.messageStatus=null!==(o=i.message_status)&&void 0!==o?o:so.SENT,s.priority=null!==(u=i.priority)&&void 0!==u?u:se.NORMAL,s.notificationEventDeadline=i.notification_event_deadline,0===s.extendedMessage.sub_type)try{var c=JSON.parse(s.extendedMessage.sub_data),l=c.label,d=c.tags,h=void 0===d?[]:d,f=c.template_key,p=c.template_variables;s.notificationData={label:l,tags:h,templateKey:f,templateVariables:p}}catch(e){}return s}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.notificationId===e.notificationId}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}}])}(Cs),mo=function(t){if(t.notificationId)return _o.payloadify(t);switch(t.messageType){case e.MessageType.USER:return po.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?vo.payloadify(t):yo.payloadify(t);case e.MessageType.ADMIN:return ao.payloadify(t);default:throw A.unknown}},go=function(e,t){if(t.notification_message_id)return new _o(e,t);switch(t.type){case"MESG":return new po(e,t);case"FILE":return vo._isMultipleFilesMessagePayload(t)?new vo(e,t):new yo(e,t);case"ADMM":case"BRDM":return new ao(e,t);default:return null}},yo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var k=i.file;if(s.plainUrl=(null!==(u=null!==(o=null==k?void 0:k.url)&&void 0!==o?o:i.url)&&void 0!==u?u:"").split("?auth=")[0],s.name=null!==(l=null!==(c=null==k?void 0:k.name)&&void 0!==c?c:i.name)&&void 0!==l?l:"File",s.size=null!==(h=null!==(d=null==k?void 0:k.size)&&void 0!==d?d:i.size)&&void 0!==h?h:0,s.data=null!==(p=null!==(f=null==k?void 0:k.data)&&void 0!==f?f:i.custom)&&void 0!==p?p:"",s.type=k?null!==(v=k.type)&&void 0!==v?v:"":null!==(_=i.type)&&void 0!==_?_:"",s.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,s.thumbnails=i.thumbnails?i.thumbnails.map((function(e){var t;return new us(s._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),s.requireAuth)})):[],s.messageSurvivalSeconds=null!==(g=i.message_survival_seconds)&&void 0!==g?g:-1,i.parent_message_info){var b=i.parent_message_info;s.parentMessage=go(t,pe(ve(Object.assign(Object.assign({},b),{created_at:b.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:b.file,url:null===(y=b.file)||void 0===y?void 0:y.url,require_auth:null===(E=b.file)||void 0===E?void 0:E.require_auth}))))}return s}return c(a,t),i(a,[{key:"url",get:function(){var e=ss.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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.plainUrl,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(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(to),Eo=function(e){function t(e,a){var i,s=a.file,o=a.fileUrl,u=a.fileName,c=a.fileSize,l=a.mimeType,d=a.thumbnailSizes,h=a._uploadedMetaData,f=a._thumbnails;return r(this,t),(i=n(this,t,[e]))._plainUrl=o,i.file=s,i.fileName=u,i.fileSize=c,i.mimeType=l,i.thumbnailSizes=d,i._uploadedMetaData=h,i._thumbnails=f,i}return c(t,e),i(t,[{key:"fileUrl",get:function(){var e,t=ss.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e}},{key:"toJSON",value:function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}],[{key:"getPlainUrl",value:function(e){return e instanceof t?e._plainUrl:e.fileUrl}}])}($a),ko=function(t){function a(t){var i,s,o,u;r(this,a);var c=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?c=t.mentionedUserIds:t.mentionedUsers&&(c=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FILE",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,files:t.files?xo(t.files):null,url:t.url,name:null!==(i=t.fileName)&&void 0!==i?i:"",type:null!==(s=t.mimeType)&&void 0!==s?s:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:null===(u=t._thumbnails)||void 0===u?void 0:u.map((function(e){return us.payloadify(e)})),require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:c,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.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,message:t.message}))}])}return c(a,t),i(a)}(We),bo=function(t){function a(t){var i,s,o;r(this,a),i=n(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})))),i.method=_e.POST,i.path="".concat(Pe(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),i.params=pe(ve({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?xo(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===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return us.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return ks.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage})),i}return c(a,t),i(a)}(Ve),Co=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"FILE",i])).message=i.files&&i.files.length>=2?new vo(e,i):new yo(e,i);var d=ss.of(e).sdkState;return s.isMentioned=qe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),wo=function(e){function t(e,a){var i,s,o,u,c;r(this,t),(i=n(this,t,[e,a])).message=a.files&&a.files.length>=2?new vo(e,a):new yo(e,a);var l=ss.of(e).sdkState;return i.isMentioned=qe(i.message.mentionType,null!==(u=null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:null===(o=i.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),i.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,i}return c(t,e),i(t)}(ze);function xo(e){return e.map((function(e){var t,n;return pe(ve({url:Eo.getPlainUrl(e),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 us.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var So;!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"}(So||(So={}));var To=function(){return i((function e(t,n){var a=this,i=n.sdkState,s=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._iid=t,this._sdkState=i,this._requestQueue=o,this._cacheContext=c,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof Ha&&(a._connectionState=e.stateType)})),this._onlineDetector=u}),[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===Da.CONNECTED||this._connectionState===Da.CONNECTING||this._connectionState===Da.RECONNECTING}},{key:"_sendFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=this._createSendFileMessageRequestParams(e,t),!this._shouldSendThroughWebSocket){n.next=10;break}return a=new ko(r),n.next=5,this._requestQueue.send(a);case 5:return i=n.sent,s=i.as(Co),o=s.message,n.abrupt("return",o);case 10:return u=new bo(Object.assign(Object.assign({},r),{userId:this._sdkState.userId})),n.next=13,this._requestQueue.send(u);case 13:return c=n.sent,l=c.as(wo),h=l.message,n.abrupt("return",h);case 16:case"end":return n.stop()}}),n,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(t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(a=this._queueMap.get(t.url))){r.next=58;break}if(a.isResolving){r.next=57;break}a.isResolving=!0,i=[],o=!0,u=s(a.messageQueue),r.prev=7,u.s();case 9:if((c=u.n()).done){r.next=40;break}l=c.value,r.t0=l.state,r.next=r.t0===So.PENDING||r.t0===So.UPLOADING?14:r.t0===So.UPLOADED?17:r.t0===So.FAILED?35:38;break;case 14:return o=!1,i.push(l),r.abrupt("break",38);case 17:if(!o){r.next=33;break}return r.prev=18,l.state=So.SENDING,r.next=22,this._sendFileMessage(t,l);case 22:return h=r.sent,l.deferred.resolve(h),r.next=26,ki(100);case 26:r.next=31;break;case 28:r.prev=28,r.t1=r.catch(18),l.deferred.reject(r.t1);case 31:r.next=34;break;case 33:i.push(l);case 34:return r.abrupt("break",38);case 35:return f=null!==(n=l.error)&&void 0!==n?n:A.unknown,l.deferred.reject(f.code===e.SendbirdErrorCode.REQUEST_CANCELED?A.fileUploadCanceled:f),r.abrupt("break",38);case 38:r.next=9;break;case 40:r.next=45;break;case 42:r.prev=42,r.t2=r.catch(7),u.e(r.t2);case 45:return r.prev=45,u.f(),r.finish(45);case 48:if(p=a.isResolveRequestPending,a.messageQueue=i,a.isResolving=!1,a.isResolveRequestPending=!1,!p){r.next=55;break}return r.next=55,this._resolveMessageQueue(t);case 55:r.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return r.stop()}}),r,this,[[7,42,45,48],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(r=this._queueMap.get(e.url))){n.next=30;break}if(!(a=r.messageQueue.find((function(e){return e.state===So.PENDING})))){n.next=30;break}if(!a.multipleFileUploadInfo){n.next=19;break}if(i=a.multipleFileUploadInfo,s=i.uploadIndex,o=i.uploadCount,u=i.requestHandler,c=a.params,l=c.fileInfoList[s],!H(l.file)||(null===(t=l._uploadedMetaData)||void 0===t?void 0:t.isUploaded)){n.next=13;break}return n.next=11,this._tryUploadNextItemAndUpdateItemState(e,r,a);case 11:n.next=14;break;case 13:a.state=s=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=new cs({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),s.next=3,this._requestQueue.send(o);case 3:u=s.sent,c=u.as(ls),l=c.url,h=c.fileSize,f=void 0===h?n.fileSize:h,p=c.thumbnails,v=void 0===p?[]:p,_=c.requireAuth,m=void 0!==_&&_,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i:n.file.size,n.fileUrl=l,n.fileSize=f,n.requireAuth=m,n._thumbnails=v;case 12:case"end":return s.stop()}}),s,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[o],c=new cs({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),s.next=5,this._requestQueue.send(c);case 5:l=s.sent,h=l.as(ls),f=h.url,p=h.fileSize,v=void 0===p?u.fileSize:p,_=h.thumbnails,m=h.requireAuth,g=void 0!==m&&m,u.fileName=null!==(r=u.fileName)&&void 0!==r?r: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=f,u.fileSize=v,u._thumbnails=_,u._uploadedMetaData=Object.assign(Object.assign({},u._uploadedMetaData),{requireAuth:g,isUploaded:!0}),u instanceof Eo||(n.fileInfoList[o]=new Eo(this._iid,u));case 16:case"end":return s.stop()}}),s,this)})))}},{key:"request",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),o=new ut,u={requestId:t,params:n,state:So.PENDING,deferred:o},Io(n)&&(c=n,l=Object.assign({uploadIndex:0,uploadCount:c.fileInfoList.length},r),u.multipleFileUploadInfo=l),s.messageQueue.push(u),this._uploadNextPendingItem(e),a.abrupt("return",o.promise);case 8:case"end":return a.stop()}}),a,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}))]:v(n.messageQueue),i=s(a);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o)switch(o.state){case So.PENDING:if(o.state=So.FAILED,o.error=A.requestCanceled,o.multipleFileUploadInfo&&!o.multipleFileUploadInfo.isCopy){var u=o.multipleFileUploadInfo,c=u.uploadIndex,l=u.requestHandler,d=o.params.fileInfoList[c];null==l||l._triggerOnFileUploaded(o.requestId,c,d,A.fileUploadCanceled)}this._resolveMessageQueue(e);break;case So.UPLOADING:this._requestQueue.cancel(o.requestId),this._dispatcher.dispatch(new ct({requestId:o.requestId}))}}}catch(e){i.e(e)}finally{i.f()}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new ct({requestId:t})))}}])}();function Io(e){return"fileInfoList"in e}var No,Ao={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},Mo=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&R(e.ReplyType,t.replyType)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)&&D("boolean",t.showSubchannelMessagesOnly)},Oo={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Uo=function(t){return R(e.ReplyType,t.replyType)&&D("boolean",t.includeReactions)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)},Do=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:d,include_poll_details:!0},a}return c(t,e),i(t)}(Ve),Ro=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?go(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(ze),Lo=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,d=e.isInclusive,h=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,E=e.includeThreadInfo,k=e.includeParentMessageInfo,b=e.showSubchannelMessagesOnly,C=e.checkingHasNext,w=e.checkingContinuousMessages;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages"),a.params=pe(ve({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,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:E,include_parent_message_info:k,show_subchannel_message_only:b,include_poll_details:!0,checking_has_next:C,checking_continuous_messages:w})),a}return c(t,e),i(t)}(Ve),Po=function(e){function t(e,a){var i;return r(this,t),i=n(this,t,[e,a]),void 0!==a.is_continuous_messages&&(i.isContinuousMessages=a.is_continuous_messages),void 0!==a.has_next&&(i.hasNext=a.has_next),i.messages=a.messages.map((function(t){return go(e,t)})),i}return c(t,e),i(t)}(ze),Fo=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,d=e.includeReactions,h=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:d,include_thread_info:h,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return c(t,e),i(t)}(Ve),qo=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedMessages=a.updated.map((function(t){return go(e,t)})),i.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(ze),Ho=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledMessageId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s)),a.params={},a}return c(t,e),i(t)}(Ve),Go=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?go(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(ze);e.RestrictionType=void 0,(No=e.RestrictionType||(e.RestrictionType={})).MUTED="muted",No.BANNED="banned";var jo=function(){return i((function t(n){var a,i,s,o;r(this,t),this.restrictionType=null,R(e.RestrictionType,n.restriction_type)&&(this.restrictionType=n.restriction_type),this.description=null!==(a=n.description)&&void 0!==a?a:null,this.endAt=null!==(s=null!==(i=n.end_at)&&void 0!==i?i:n.muted_end_at)&&void 0!==s?s:-1,this.remainingDuration=null!==(o=n.remaining_duration)&&void 0!==o?o:-1}),null,[{key:"payloadify",value:function(e){return pe(ve({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}])}(),Vo=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).restrictionInfo=new jo(a),i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),jo.payloadify(e.restrictionInfo))))}}])}(li),zo=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.isMuted=null!==(s=a.is_muted)&&void 0!==s&&s,i}return c(t,e),i(t)}(li),Bo=function(){return i((function e(){r(this,e),this._onPending=ft,this._onFailed=ft,this._onSucceeded=ft}),[{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}}])}(),Qo={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},Ko=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(li,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(ks,t.metaArrays,!0)&&D("number",t.parentMessageId,!0)&&D("boolean",t.isReplyToChannel)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ms,t.appleCriticalAlertOptions,!0)&&D("boolean",t.isPinnedMessage,!0)},Wo=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Yo=Object.assign(Object.assign({},Qo),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function Zo(t){var n,r,a;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(t.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var Xo,Jo=function(e){var t;return pe(ve({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),extendedMessagePayload:e.extendedMessagePayload}))},$o=function(e){return Ko(e)&&D("string",e.message)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)&&D("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Xo||(Xo={}));var eu=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},tu=function(e){return e===Xo.BLOB||e===Xo.FILE},nu=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},ru=Object.assign(Object.assign({},Qo),{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,message:void 0});function au(t){var n,r,a,i;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.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,_thumbnails:t.thumbnails,message:t.message}))}var iu,su=function(e,t){var n;return e.messageParams?(!e.url&&H(t)&&(e.messageParams.file=t),e.messageParams):pe(ve({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}})),message:e.message}))},ou=function(e){return Ko(e)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&D("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},uu={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},cu=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(li,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(ks,t.metaArrays,!0)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ms,t.appleCriticalAlertOptions,!0)},lu=Object.assign(Object.assign({},uu),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),du=function(e){return cu(e)&&D("string",e.message,!0)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)},hu=Object.assign({},uu),fu=function(e){return cu(e)},pu=function(){return i((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}),[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return D("number",this.limit)&&this.limit>0}}])}(),vu=function(t){function a(e,t,i,s){var o;return r(this,a),(o=n(this,a,[e,s])).channelUrl=t,o.channelType=i,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl)&&R(e.ChannelType,this.channelType)}}])}(pu),_u=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={token:o,limit:u},a}return c(t,e),i(t)}(Ve),mu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).operators=a.operators.map((function(t){return new li(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(ze),gu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=ss.of(this._iid),r=n.requestQueue,a=new _u(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(mu),o=s.operators,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(vu),yu=function(t){function a(t,i,s,o){var u,c,l,d,h,f,p,v,_,m,g;return r(this,a),(u=n(this,a,[t,i,s,o])).reverse=!1,u.messageTypeFilter=e.MessageTypeFilter.ALL,u.customTypesFilter=null,u.senderUserIdsFilter=null,u.replyType=e.ReplyType.NONE,u.includeMetaArray=!1,u.includeReactions=!1,u.includeParentMessageInfo=!1,u.includeThreadInfo=!1,u.showSubchannelMessagesOnly=!1,u._edge=Number.MAX_SAFE_INTEGER,u.reverse=null!==(c=o.reverse)&&void 0!==c&&c,u.messageTypeFilter=null!==(l=o.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,u.customTypesFilter=null!==(d=o.customTypesFilter)&&void 0!==d?d:null,u.senderUserIdsFilter=null!==(h=o.senderUserIdsFilter)&&void 0!==h?h:null,u.replyType=null!==(f=o.replyType)&&void 0!==f?f:e.ReplyType.NONE,u.includeMetaArray=null!==(p=o.includeMetaArray)&&void 0!==p&&p,u.includeReactions=null!==(v=o.includeReactions)&&void 0!==v&&v,u.includeParentMessageInfo=null!==(_=o.includeParentMessageInfo)&&void 0!==_&&_,u.includeThreadInfo=null!==(m=o.includeThreadInfo)&&void 0!==m&&m,u.showSubchannelMessagesOnly=null!==(g=o.showSubchannelMessagesOnly)&&void 0!==g&&g,u}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.reverse)&&R(e.MessageTypeFilter,this.messageTypeFilter)&&R(e.ReplyType,this.replyType)&&P("string",this.customTypesFilter,!0)&&P("string",this.senderUserIdsFilter,!0)&&D("boolean",this.includeMetaArray)&&D("boolean",this.includeReactions)&&D("boolean",this.includeParentMessageInfo)&&D("boolean",this.includeThreadInfo)&&D("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,t=oh.of(this._iid),e.next=7,t.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,ve({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));case 7:return n=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(v(n.map((function(e){return e.createdAt}))))),this._hasNext=n.length>=this.limit,this._isLoading=!1,e.abrupt("return",n);case 12:return e.abrupt("return",[]);case 15:throw A.queryInProgress;case 16:e.next=19;break;case 18:throw A.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}])}(vu),Eu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={limit:o,token:u},a}return c(t,e),i(t)}(Ve),ku=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).mutedUsers=[];var s=a.next,o=a.muted_list;return i.token=s,o&&o.length>0&&(i.mutedUsers=o.map((function(t){return new Vo(e,t)}))),i}return c(t,e),i(t)}(ze),bu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Eu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(ku),s=i.mutedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),Cu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({limit:o,token:u}),a}return c(t,e),i(t)}(Ve),wu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).bannedUsers=[];var s=a.next,o=a.banned_list;return i.token=s,o&&o.length>0&&(i.bannedUsers=o.map((function(t){return new Vo(e,t.user)}))),i}return c(t,e),i(t)}(ze),xu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Cu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(wu),s=i.bannedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu);e.ReportCategory=void 0,(iu=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",iu.HARASSING="harassing",iu.SUSPICIOUS="suspicious",iu.INAPPROPRIATE="inappropriate";var Su=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(Ve),Tu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(Ve),Iu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute/").concat(o),a}return c(t,e),i(t)}(Ve),Nu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.startAt=0,i.endAt=0;var s=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return i.isMuted=s,i.startAt=o,i.endAt=u,i.remainingDuration=c,i.description=l,i}return c(t,e),i(t)}(ze),Au=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={keys:o,include_ts:!0},a}return c(t,e),i(t)}(Ve),Mu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(ze),Ou=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0},a}return c(t,e),i(t)}(Ve),Uu=function(e){function t(e,a){var i,s,o;return r(this,t),(i=n(this,t,[e,a])).metaData=null!==(s=a.metadata)&&void 0!==s?s:{},i.ts=null!==(o=a.ts)&&void 0!==o?o:null,i}return c(t,e),i(t)}(ze),Du=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata,u=e.upsert;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return c(t,e),i(t)}(Ve),Ru=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(ze),Lu=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),Pu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(o),a.params={include_ts:!0},a}return c(t,e),i(t)}(Ve),Fu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(ze),qu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={include_ts:!0},a}return c(t,e),i(t)}(Ve),Hu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(ze),Gu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={keys:o},a}return c(t,e),i(t)}(Ve),ju=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(ze),Vu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o},a}return c(t,e),i(t)}(Ve),zu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(ze),Bu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,d=void 0===l?"set":l;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o,upsert:c,mode:d},a}return c(t,e),i(t)}(Ve),Qu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(ze),Ku=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),Wu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(o),a.params={},a}return c(t,e),i(t)}(Ve),Yu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={},a}return c(t,e),i(t)}(Ve),Zu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return c(t,e),i(t)}(Ve),Xu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),s}return c(t,e),i(t)}(Ke),Ju=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(Ve),$u=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),s}return c(t,e),i(t)}(Ke),ec=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({user_id:o,seconds:u,description:c}),a}return c(t,e),i(t)}(Ve),tc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),i.data.member_count&&(s.memberCount=i.data.member_count),i.data.joined_member_count&&(s.joinedMemberCount=i.data.joined_member_count),s}return c(t,e),i(t)}(Ke),nc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(Ve),rc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),s}return c(t,e),i(t)}(Ke),ac=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.freezing;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/freeze"),a.params={freeze:o},a}return c(t,e),i(t)}(Ve),ic=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).freeze=i.data.freeze,s}return c(t,e),i(t)}(Ke),sc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Fe(s),"/").concat(encodeURIComponent(i)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return c(t,e),i(t)}(Ve),oc=function(t){function a(t){var i;r(this,a);var s=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,d=t.description;return(i=n(this,a)).method=_e.POST,i.path="".concat(Se,"/users/").concat(l),i.params={channel_url:s,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:d},i}return c(a,t),i(a)}(Ve),uc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,d=e.description,h=e.messageToken;return(a=n(this,t)).method=_e.POST,a.path="".concat(Fe(s),"/").concat(encodeURIComponent(i),"/messages/").concat(l),a.params=pe({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),a}return c(t,e),i(t)}(Ve),cc=function(t){function a(t){r(this,a);var i=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MESG",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:i,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,extended_message_payload:t.extendedMessagePayload}))}])}return c(a,t),i(a)}(We),lc=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"MESG",i])).message=new po(e,i);var d=ss.of(e).sdkState;return s.isMentioned=qe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),dc=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MEDI",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))}])}return c(a,t),i(a)}(We),hc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"MEDI",i])).message=new po(e,i);var h=ss.of(e).sdkState;return s.mentionCountChange=He({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),fc=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FEDI",ackRequired:!0,payload:pe(ve({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:i,apple_critical_alert_options:t.appleCriticalAlertOptions}))}])}return c(a,t),i(a)}(We),pc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"FEDI",i])).message=new yo(e,i);var h=ss.of(e).sdkState;return s.mentionCountChange=He({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),vc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(Ve),_c=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new fs(a),i}return c(t,e),i(t)}(ze),mc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(Ve),gc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new fs(Object.assign({},a)),i}return c(t,e),i(t)}(ze),yc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return c(t,e),i(t)}(Ve),Ec=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new po(e,a),i}return c(t,e),i(t)}(ze),kc=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.POST,i.path="".concat(Pe(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(Ve),bc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new po(e,a),i}return c(t,e),i(t)}(ze),Cc=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl;return i.method=_e.POST,i.path="".concat(Pe(c),"/").concat(encodeURIComponent(l),"/scheduled_messages"),i.params=ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return us.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),i}return c(a,t),i(a)}(Ve),wc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new yo(e,a),i}return c(t,e),i(t)}(ze),xc=function(e){return D("string",e.title,!0)&&co(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0)},Sc=function(e){function t(e){var a,i=e.pollId,s=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a.params={title:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(Ve),Tc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Ic=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(Ve),Nc=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/close"),a}return c(t,e),i(t)}(Ve),Ac=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Mc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.optionText;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:i,channel_type:s,text:u},a}return c(t,e),i(t)}(Ve),Oc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Uc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId,o=e.optionText;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a.params={text:o},a}return c(t,e),i(t)}(Ve),Dc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Rc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),Lc=function(t){function a(t){var i=t.reqId,s=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n(this,a,[{code:"VOTE",ackRequired:!0,payload:pe({req_id:i,channel_type:s===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})}])}return c(a,t),i(a)}(We),Pc=i((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})),Fc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"VOTE",i])).event=new Pc(i),s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),qc=function(e){function t(e){var a,i=e.title,s=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=Ne,a.params={title:i,options:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(Ve),Hc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Gc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(Ve),jc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Vc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(Ve),zc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pollOption=new lo(e,a),i}return c(t,e),i(t)}(ze),Bc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/polls/changelogs"),a.params=pe({change_ts:o,token:u}),a}return c(t,e),i(t)}(Ve),Qc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedPolls=a.updated.map((function(t){return function(e,t){return new ho(e,t)}(e,t)})),i.deletedPollIds=a.deleted.map((function(e){return e})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(ze),Kc={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Wc=function(e){return D("string",e.title)&&(t=e.optionTexts,P("string",t)&&t.every((function(e){return""!==e.trim()})))&&co(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0);var t},Yc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},Zc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)&&t.pollId>0&&D("number",t.pollOptionId)&&t.pollOptionId>0},Xc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},Jc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)},$c={},el=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,u=n.logger;r(this,e),this._iid=t,this._sdkState=a,this._sessionManager=s,this._requestQueue=o,this._dispatcher=i,this._logger=u,$c[t]=this}),[{key:"buildPollFromSerializedData",value:function(e){var t=oi(e);return new ho(this._iid,ho.payloadify(t))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(Jc(e)).throw(A.invalidParameters),n=new Gc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(jc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(Wc(e)).throw(A.invalidParameters),n=new qc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Hc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(Zc(e)).throw(A.invalidParameters),n=new Vc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(zc),i=a.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogs",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.SYNC_POLL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Bc(ve({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null})),e.next=3,this._requestQueue.send(i);case 3:return s=e.sent,o=s.as(Qc),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,u.length>0&&this._dispatcher.dispatch(new Vs({polls:u,source:a})),e.abrupt("return",{updatedPolls:u,deletedPollIds:c,hasMore:l,token:h});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return $c[e]}}])}(),tl="GroupChannel",nl="Message",rl="NotificationMessage",al=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=Ne,a.params={channel_url:i,channel_type:s,token:o,limit:u},a}return c(t,e),i(t)}(Ve),il=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).polls=(null!==(s=a.polls)&&void 0!==s?s:[]).map((function(t){return new ho(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(ze),sl=function(e){function t(e,a){return r(this,t),n(this,t,[e,a.channelUrl,a.channelType,a])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new al(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(il),s=i.polls,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),ol=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:i,channel_type:s,token:c,limit:l},a}return c(t,e),i(t)}(Ve),ul=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).voters=(null!==(s=a.voters)&&void 0!==s?s:[]).map((function(t){return new li(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(ze),cl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a.channelUrl,a.channelType,a])).pollId=a.pollId,i.pollOptionId=a.pollOptionId,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("number",this.pollId)&&D("number",this.pollOptionId)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new ol(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(ul),s=i.voters,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu);var ll,dl=Object.assign(Object.assign({},Qo),{fileInfoList:[],message:""}),hl=function(e){return(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},fl=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._onFileUploaded=ft,e}return c(t,e),i(t,[{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(t,"onPending",this,3)([e]),this}},{key:"onFailed",value:function(e){return p(t,"onFailed",this,3)([e]),this}},{key:"onSucceeded",value:function(e){return p(t,"onSucceeded",this,3)([e]),this}}])}(Bo),pl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e])).message=null,i.message=go(e,a.message),i}return c(t,e),i(t)}($a),vl=function(e){function t(e){var a;r(this,t);var i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,d=e.includeParentMessageInfo,h=e.includeThreadInfo,f=e.includePollDetails;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/pinned_messages"),a.params=pe({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),a}return c(t,e),i(t)}(Ve),_l=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.pinned_messages,o=a.has_more,u=a.next;return i.pinnedMessages=s.map((function(t){return new pl(e,t)})),i.hasMore=o,i.token=u,i}return c(t,e),i(t)}(ze),ml=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s])).includeMetaArray=s.includeMetaArray,o.includeReactions=s.includeReactions,o.includeParentMessageInfo=s.includeParentMessageInfo,o.includeThreadInfo=s.includeThreadInfo,o.includePollDetails=s.includePollDetails,o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeMetaArray,!0)&&D("boolean",this.includeReactions,!0)&&D("boolean",this.includeParentMessageInfo,!0)&&D("boolean",this.includeThreadInfo,!0)&&D("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new vl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(_l),s=i.pinnedMessages,o=i.hasMore,u=i.token,this._token=u,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(vu),gl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(Ve),yl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(Ve);!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(ll||(ll={}));var El,kl=function(t){function a(t,i){var s,o,u,c,l,d,h,f;return r(this,a),(s=n(this,a,[t]))._name="",s._createdAt=0,s.pinnedMessageIds=[],s.channelType=e.ChannelType.BASE,s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s._messageCollectionLastAccessedAt=0,s._url=i.channel_url,s._name=null!==(o=i.name)&&void 0!==o?o:"",s._createdAt=1e3*i.created_at,s.coverUrl=null!==(u=i.cover_url)&&void 0!==u?u:"",s.customType=null!==(c=i.custom_type)&&void 0!==c?c:"",s.data=null!==(l=i.data)&&void 0!==l?l:"",s.isFrozen=null!==(d=i.freeze)&&void 0!==d&&d,s.isEphemeral=null!==(h=i.is_ephemeral)&&void 0!==h&&h,s.creator=i.created_by?new li(s._iid,i.created_by):null,i.metadata&&Object.keys(i.metadata).length>0&&i.ts?(s._cachedMetaData=new Map,Object.keys(i.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:i.metadata[e],isRemoved:!1,updatedAt:i.ts})}))):"string"==typeof i.metadata&&(s._cachedMetaData=new Map(Object.entries(JSON.parse(i.metadata)))),s.pinnedMessageIds=null!==(f=i.pinned_message_ids)&&void 0!==f?f:[],s}return c(a,t),i(a,[{key:"url",get:function(){return this._url}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"createdAt",get:function(){return this._createdAt}},{key:"toJSON",value:function(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}},{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"isFeedChannel",value:function(){return this.channelType===e.ChannelType.FEED}},{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:"_serializeCachedMetaData",value:function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=pe(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:"_updateCachedMetaData",value:function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(a,i){var s;a.updatedAt<=t&&(n._cachedMetaData.set(i,{value:null!==(s=e[i])&&void 0!==s?s:a.value,isRemoved:!e[i],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}}},{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 gu(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new bu(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new xu(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yu(this._iid,this.url,this.channelType,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ml(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Su({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"removeOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Tu({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyMutedInfo",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Iu({channelUrl:this.url,channelType:this.channelType,userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Nu),o=s.isMuted,u=s.startAt,c=s.endAt,l=s.remainingDuration,h=s.description,e.abrupt("return",{isMuted:o,startAt:u,endAt:c,remainingDuration:l,description:h});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Au({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(Mu),o=s.metadata,u=s.ts,this._upsertCachedMetaData(o,u),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Au({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Mu),s=i.metadata,o=i.ts,this._updateCachedMetaData(s,o),e.abrupt("return",s);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Ou({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Uu),o=s.metaData,this._upsertCachedMetaData(o,0),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=new Du({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Ru),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Pu({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:i=t.sent,s=i.as(Fu),o=s.ts,this._removeFromCachedMetaData([e],o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new qu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Hu),s=i.ts,this._removeFromCachedMetaData(v(this._cachedMetaData.keys()),s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Gu({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(ju),o=s.metaCounter,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Gu({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(ju),s=i.metaCounter,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Vu({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(zu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaCounters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=new Bu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Qu),u=o.metaCounter,n.abrupt("return",u);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Bu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Qu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Bu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Qu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Wu({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Yu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.muteUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"muteUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new Zu({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unmuteUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Ju({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"banUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.banUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"banUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new ec({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unbanUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unbanUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new nc({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"freeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new ac({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,n.send(r);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new ac({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,n.send(r);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Ao),t),ui(D("number",e)&&Mo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessagesByMessageId(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Ao),t),ui(D("number",e)&&Mo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessagesByTimestamp(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Oo),t),ui(D("number",e)&&Uo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Oo),t),ui(D("string",e)&&Uo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,i=ss.of(this._iid).sessionManager;return pe(ve({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 ks.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:i.currentUser?Es.payloadify(i.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 li.payloadify(e)}))}))}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var i,o=s(t.translationTargetLanguages);try{for(o.s();!(i=o.n()).done;){a[i.value]=""}}catch(e){o.e(e)}finally{o.f()}}var u=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a,extended_message_payload:t.extendedMessagePayload})),c=new po(this._iid,u);return c.messageParams=t,c}},{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,i,s,o,u,c,l,d=pe(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===(i=t.file)||void 0===i?void 0:i.name,size:null!==(s=t.fileSize)&&void 0!==s?s: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:null===(l=t._thumbnails)||void 0===l?void 0:l.map((function(e){return us.payloadify(e)})),message:t.message})),h=new yo(this._iid,d);return h.messageParams=t,h}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,file:t.fileInfoList.length>0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0,message:t.message})),i=new vo(this._iid,a);return i.messageParams=t,i}},{key:"_validateFailedFileMessageHasFile",value:function(e,t){var n;return Boolean(e.url)||H(t)||H(null===(n=e.messageParams)||void 0===n?void 0:n.file)}},{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.SendbirdErrorCode.REQUEST_CANCELED||n.code===e.SendbirdErrorCode.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({},Yo),e);return ui($o(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ll.SEND,a=arguments.length>2?arguments[2]:void 0,i=ss.of(this._iid),s=i.dispatcher,o=i.requestQueue,u=null!=a?a:this._generateRequestId(),c=Date.now(),l=new Bo;return ki(2).then((function(){var a=n._createPendingUserMessage(t,u,c);s.dispatch(new Fs({messages:[a],source:r===ll.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a));case 1:case"end":return e.stop()}}),e)})))}));var i=new cc(Object.assign(Object.assign({},t),{channelUrl:n.url,channelType:n.channelType,reqId:u}));o.send(i).then((function(t){var r=t.as(lc).message;s.dispatch(new Fs({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().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)})))}))})).catch((function(r){if(N(r))throw r;ki(2).then((function(){var a=n._createPendingUserMessage(t,u,c),i=ss.of(n._iid).cacheContext,o=i.localCacheEnabled&&i.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,o),s.dispatch(new Fs({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),l}},{key:"_autoResendUserMessage",value:function(e){return ui(e instanceof po&&!!e.messageParams).throw(A.invalidParameters),this._sendUserMessage(e.messageParams,ll.SEND,e.reqId)}},{key:"resendUserMessage",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof po&&!e.scheduledInfo).throw(A.invalidParameters),r=new ut,a=null!==(t=e.messageParams)&&void 0!==t?t:Jo(e),this._sendUserMessage(a,ll.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"updateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},lu),t),ui(D("number",e)&&du(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new dc(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(hc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"copyUserMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ui(t instanceof a&&n instanceof po&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),ui(!n.poll).throw(A.notSupportedError),u=new ut,c=null!==(r=n.messageParams)&&void 0!==r?r:ve(Object.assign(Object.assign({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(s=n.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),t._sendUserMessage(c).onSucceeded((function(e){u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 6:case"end":return o.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof po&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new yc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(Ec),u=o.message,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_createScheduledUserMessage",value:function(e,t){var n=this,r=ss.of(this._iid).requestQueue,a=Date.now(),i=this._generateRequestId();ki(2).then((function(){var r=n._createPendingScheduledUserMessage(e,i,a);_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))}));var s=new kc(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(bc).message;_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;ki(2).then((function(){var s=n._createPendingScheduledUserMessage(e,i,a);n._markMessageAsFailed(s,r),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},ru),e);return ui(ou(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},dl),e),r=ss.of(this._iid);ui(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return Ko(e)&&D("string",e.message,!0)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return hl(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 ui(!a).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ll.SEND,a=arguments.length>2?arguments[2]:void 0,i=ss.of(this._iid).dispatcher,s=oh.of(this._iid).fileMessageQueue,o=null!=a?a:this._generateRequestId(),u=Date.now(),c=new Bo;return ki(2).then((function(){var a=n._createPendingFileMessage(t,o,u);i.dispatch(new Fs({messages:[a],source:r===ll.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a));case 1:case"end":return e.stop()}}),e)})))})),s.request(n,o,t).then((function(t){i.dispatch(new Fs({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;ki(2).then((function(){var a=n._createPendingFileMessage(t,o,u),s=ss.of(n._iid).cacheContext,l=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,l),i.dispatch(new Fs({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:r.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_autoResendFileMessage",value:function(e){ui(e instanceof yo&&!!e.messageParams).throw(A.invalidParameters);var t=ss.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,ll.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(t,n,r){var a=this,i=ss.of(this._iid).dispatcher,s=oh.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new fl;return ki(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);i.dispatch(new Fs({messages:[r],source:n===ll.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(r));case 1:case"end":return e.stop()}}),e)})))})),s.request(a,o,t,{requestHandler:c,isCopy:n===ll.COPY}).then((function(t){i.dispatch(new Fs({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(n){if(N(n))throw n;ki(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);a._markMessageAsFailed(r,n),i.dispatch(new Fs({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(n,r));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_createScheduledFileMessage",value:function(e,t,n,r){var a=this,i=ss.of(this._iid).requestQueue,s=new Cc(Object.assign(Object.assign({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(s).then((function(e){var n=e.as(wc).message;_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(N(i))throw i;ki(2).then((function(){var s=a._createPendingScheduledFileMessage(e,n,r);a._markMessageAsFailed(s,i),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(i,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){ui(e.every((function(e){return ou(Object.assign(Object.assign({},ru),e))}))).throw(A.invalidParameters);var t,n=new Bo,r=s(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,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._validateFailedFileMessageHasFile(e,t),ui(e instanceof yo&&r&&!e.scheduledInfo).throw(A.invalidParameters),a=new ut,i=su(e,t),this._sendFileMessage(i,ll.RESEND,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),n.abrupt("return",a.promise);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"resendMessage",value:function(e,t){var n,r;if(ui(e instanceof to&&!e.scheduledInfo&&e.isResendable).throw(A.invalidParameters),e.isUserMessage()){var a=null!==(n=e.messageParams)&&void 0!==n?n:Jo(e);return this._sendUserMessage(a,ll.RESEND,e.reqId)}if(e.isFileMessage()){var i=this._validateFailedFileMessageHasFile(e,t);ui(i).throw(A.invalidParameters);var s=null!==(r=e.messageParams)&&void 0!==r?r:su(e,t);return this._sendFileMessage(s,ll.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"updateFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},hu),t),ui(D("number",e)&&fu(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new fc(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(pc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"uploadFile",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=ce(),(i=new cs({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a),t.next=7,r.send(i);case 7:return s=t.sent,o=s.as(ls),u=o.url,c=o.thumbnails,t.abrupt("return",{requestId:a,url:u,thumbnails:c});case 10:case"end":return t.stop()}}),t,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=oh.of(this._iid),n.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"copyFileMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ui(t instanceof a&&n instanceof yo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),u=new ut,c=ve(Object.assign(Object.assign({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=n.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),t._sendFileMessage(c).onSucceeded((function(e){return u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 5:case"end":return o.stop()}}),o,this)})))}},{key:"copyMessage",value:function(t,n){ui(t instanceof a&&n instanceof to&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters);var r=n,i=t;if(r.isUserMessage()){ui(!r.poll).throw(A.notSupportedError);var s=Zo(r);return i._sendUserMessage(s)}if(r.isFileMessage()){var o=au(r);return i._sendFileMessage(o)}if(n.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"deleteMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ui(e instanceof eo).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return n=ss.of(this._iid),r=n.requestQueue,a=new lt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof to?e._messageToken:void 0}),t.next=6,r.send(a);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"addReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof eo&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new vc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(_c),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof eo&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new mc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(gc),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_updateUserMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=ss.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new dc({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(hc),f=h.message,o.dispatch(new Fs({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=ss.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new fc({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(pc),f=h.message,o.dispatch(new Fs({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new ks({key:e})})),!(e instanceof yo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"add",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"add",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new ks({key:e})})),!(e instanceof yo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"remove",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"remove",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&t.every((function(e){return e instanceof ks}))).throw(A.invalidParameters),!(e instanceof yo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"add",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"add",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&t.every((function(e){return e instanceof ks}))).throw(A.invalidParameters),!(e instanceof yo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"remove",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"remove",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"report",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(R(e.ReportCategory,t)&&D("string",n)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new sc({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:t,description:n}),r.next=5,s.send(o);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"reportUser",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ui(t instanceof li&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=ss.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new oc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.userId,category:n,description:r}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"reportMessage",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ui(t instanceof to&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=ss.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new uc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r,messageToken:t._messageToken}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"updatePoll",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("number",e)&&xc(t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Sc(Object.assign({pollId:e},t)),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(Tc),u=o.poll,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deletePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ui(n).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Ic({pollId:e}),t.next=6,a.send(i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"closePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ui(n).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Nc({pollId:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Ac),u=o.poll,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"addPollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("string",t)&&""!==t.trim(),ui(r).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new Mc({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(Oc),c=u.poll,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updatePollOption",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",e)&&D("number",t)&&D("string",n)&&""!==n.trim(),ui(a).throw(A.invalidParameters),i=ss.of(this._iid),s=i.requestQueue,o=new Uc({pollId:e,pollOptionId:t,optionText:n}),r.next=6,s.send(o);case 6:return u=r.sent,c=u.as(Dc),l=c.poll,r.abrupt("return",l);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"deletePollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("number",t),ui(r).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new Rc({pollId:e,pollOptionId:t}),n.next=6,i.send(s);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"votePoll",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",t)&&P("number",n),ui(a).throw(A.invalidParameters),i=ss.of(this._iid),s=i.requestQueue,o=i.dispatcher,u=new Lc({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:n}),r.next=6,s.send(u);case 6:return c=r.sent,l=c.as(Fc),h=l.event,o.dispatch(new Bs({event:h,source:e.CollectionEventSource.EVENT_POLL_VOTED})),r.abrupt("return",h);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("number",e)).throw(A.invalidParameters),n=el.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e,!0)),n=el.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new sl(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 cl(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}},{key:"pinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("number",e)&&e>0).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new gl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unpinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("number",e)&&e>0).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new yl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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?li.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}}])}($a),bl=i((function e(t){r(this,e),this.key=t.key,this.url=t.url})),Cl=i((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 bl(e)})):[]})),wl=i((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new Cl(e)})):[]})),xl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onConnected=ft,this.onReconnectStarted=ft,this.onReconnectSucceeded=ft,this.onReconnectFailed=ft,this.onDisconnected=ft}))),Sl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onSessionExpired=ft,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=ft,this.onSessionRefreshed=ft,this.onSessionClosed=ft}))),Tl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onFriendsDiscovered=ft,this.onTotalUnreadMessageCountChanged=ft,this.onTotalUnreadMessageCountUpdated=ft}))),Il=function(e){function t(e){var a,i=e.limit,s=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=ge,a.params=pe({limit:i,token:s,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return c(t,e),i(t)}(Ve),Nl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new li(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(ze),Al=function(e){function t(e,a){var i,s,o,u;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.metaDataKeyFilter=null,i.metaDataValuesFilter=null,i.nicknameStartsWithFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i.metaDataKeyFilter=null!==(o=a.metaDataKeyFilter)&&void 0!==o?o:null,i.metaDataValuesFilter=null!==(u=a.metaDataValuesFilter)&&void 0!==u?u:null,i.nicknameStartsWithFilter=a.nicknameStartsWithFilter||null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)&&D("string",this.metaDataKeyFilter,!0)&&P("string",this.metaDataValuesFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Il(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Nl),s=i.users,o=i.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),Ml=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token,u=e.userIdsFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/block"),a.params=pe({limit:s,token:o,user_ids:u}),a}return c(t,e),i(t)}(Ve),Ol=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new li(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(ze),Ul=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ml(ve(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token}))),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Ol),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),Dl=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={limit:s,token:o},a}return c(t,e),i(t)}(Ve),Rl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).hasMore=a.has_more,i.users=a.users.map((function(t){return new li(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(ze),Ll=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Dl(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Rl),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),Pl={},Fl=function(){return i((function e(t){var n=t.dbname,a=t.itemSizeLimit,i=void 0===a?1048576:a,s=t.cacheLimit,o=void 0===s?256:s,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,d=void 0===l?10:l,h=t.blockHashConstant,f=void 0===h?11:h,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),Pl[n]||(this.itemSizeLimit=i,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=d,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,Pl[n]=this),Pl[n]}),null,[{key:"get",value:function(e){return Pl[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"}(El||(El={}));var ql,Hl=function(e){function t(e){var a,i=e.code,s=void 0===i?El.UNKNOWN_ERROR:i,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,t),(a=n(this,t,[u])).code=s,Object.setPrototypeOf(a,t.prototype),a}return c(t,e),i(t,null,[{key:"storeNotDefined",get:function(){return new t({code:El.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new t({code:El.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new t({code:El.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new t({code:El.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new t({code:El.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new t({code:El.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new t({code:El.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new t({code:El.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new t({code:El.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new t({code:El.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new t({code:El.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new t({code:El.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new t({code:El.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new t({code:El.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new t({code:El.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new t({code:El.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new t({code:El.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new t({code:El.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new t({code:El.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new t({code:El.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new t({code:El.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new t({code:El.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new t({code:El.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new t({code:El.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new t({code:El.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}])}(y(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(ql||(ql={}));var Gl,jl=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===m(e)&&null!==e){if(t.has(e))throw Hl.circularReferenceFound;var n;return t.set(e,!0),Array.isArray(e)?n=e.map((function(e){return jl(e,t)})):e instanceof RegExp||e instanceof Date?n=e:(n={},Object.keys(e).forEach((function(r){n[r]=jl(e[r],t)}))),t.delete(e),n}return e},Vl=function(e,t){if(null==t)return 1;if(null==e)return-1;if(m(e)!==m(t))throw Hl.compareTypesNotMatch;var n=0;switch(m(e)){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},zl=function(e,t){for(var n=0,r=0;r>>0)%t},Bl=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Ql=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!Ql(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Ql(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"===m(e[r])){var a=e[r];for(var i in a)switch(i){case"/eq":case"=":if(t[r]!==a[i])return!1;break;case"/neq":case"!=":if(t[r]===a[i])return!1;break;case"/gt":case">":var s=t[r],o=a[i];if(!(Vl(s,o)>0))return!1;break;case"/gte":case">=":var u=t[r],c=a[i];if(!(Vl(u,c)>=0))return!1;break;case"/lt":case"<":var l=t[r],d=a[i];if(!(Vl(l,d)<0))return!1;break;case"/lte":case"<=":var h=t[r],f=a[i];if(!(Vl(h,f)<=0))return!1;break;case"/in":var p=t[r];if(!a[i].includes(p))return!1;break;case"/nin":var v=t[r];if(a[i].includes(v))return!1;break;case"/contain":var _=t[r],g=a[i];if(!_.includes(g))return!1;break;case"/regex":var y=t[r];if(!a[i].test(y))return!1;break;case"/where":var E=t[r];if(!(0,a[i])(E))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)},Kl=function(){},Wl=function(){return Promise.resolve()},Yl=function(e){return e},Zl=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Gl||(Gl={}));var Xl,Jl,$l,ed=function(){return i((function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,i=t.initialNextValue,s=void 0===i?null:i,o=t.iterator,u=t.map,c=void 0===u?Yl:u,l=t.backward,d=void 0===l?Wl:l,h=t.forward,f=void 0===h?Wl:h,p=t.complete,v=void 0===p?Kl:p;r(this,e),this._prevValue=a,this._nextValue=s,this._error=null,this._map=c,this._backward=d,this._forward=f,this._iterator=o,this._complete=v}),[{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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,t=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,t=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}])}(),td=function(){return i((function e(t){var n=t.condition,a=void 0===n?{}:n,i=t.backward,s=void 0!==i&&i,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=s,this._blockManager=o,this._indexer=u}),[{key:"findOptimizedStartPosition",value: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 a=0;a0?n:t;for(var u in this.condition[i])if(o.includes(u))for(var c=r;c>=0;c--)if(s*Vl(this._indexer.origin[c].columnValues[a],this.condition[i][u])<=0){r=c;break}}else for(var l=r;l>=0;l--)if(s*Vl(this._indexer.origin[l].columnValues[a],this.condition[i])<=0){r=l;break}}return Math.min(r+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var h=function(r){var a=e._indexer.fields[r],i=1;if("-"===a[0]&&(a=a.slice(1),i=-1),e.condition[a])if("object"===m(e.condition[a]))Object.keys(e.condition[a]).forEach((function(s){if((i>0?t:n).includes(s))for(var o=d;o=0){d=o;break}}));else for(var s=d;s=0){d=s;break}},f=0;f0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Math.max(e.offset||0,0),0!==(r="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){t.next=6;break}return t.abrupt("return",[]);case 6:if(!(r<0)){t.next=8;break}throw Hl.collectionQueryNotValid;case 8:return t.prev=8,a=[],t.next=12,this._mutex.lock();case 12:return t.next=14,this._iterator.each((function(e){return E(i,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===n?(a.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(od(e,t)).concat(n,".").concat(r)},cd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=i}),[{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(n=t.sent)){t.next=19;break}if(r=n.data,a=n.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(r);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(s=[],o=atob(r.split(",")[1]),u=0;u1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,new Promise((function(n){var r=ud(o.dbname,o.collectionName,t),a=new FileReader;a.onload=function(){n({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return r=n.sent,a=r.blobId,i=r.data,s=r.type,n.next=8,this.store.set({key:a,value:{data:i,type:s}});case 8:return n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=od(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return n=e.sent,e.next=6,Promise.all(n.filter((function(e){return e.startsWith(t)})).map((function(e){return E(r,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}])}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Xl||(Xl={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Jl||(Jl={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}($l||($l={}));var ld,dd,hd=[Jl.PENDING,Jl.VOLATILE],fd={},pd=function(){return i((function e(t){var n=t.dbname,a=t.limit,i=void 0===a?256:a;return r(this,e),fd[n]||(this.dbname=n,this._items=[],this._limit=i,fd[n]=this),fd[n]}),[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$l.DEFAULT;return E(this,void 0,void 0,d().mark((function r(){var a,i;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=this.get(t)){r.next=8;break}return r.next=4,e.get(t);case 4:(i=r.sent)&&(a={key:t,value:i,state:n===$l.PERSISTENT?Jl.PERSISTENT:Jl.VOLATILE},this.put(a)),r.next=9;break;case 8:n===$l.PERSISTENT&&(a.state=Jl.PERSISTENT);case 9:return r.abrupt("return",a);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$l.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===$l.PERSISTENT&&(r.state=Jl.PERSISTENT),t!==$l.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)hd.includes(this._items[t].state)&&hd.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===Jl.VOLATILE})),r=n.length-this._limit;if(r>0){var a,i=[],o=s(this._items);try{for(o.s();!(a=o.n()).done;){var u=a.value;u.state===Jl.VOLATILE&&r>0?r--:i.push(u)}}catch(e){o.e(e)}finally{o.f()}this._items=i}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clearForDatabase",value:function(e){this.clearByCondition((function(t){return t.key.startsWith(rd(e))}))}},{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!==Jl.VOLATILE}))}}],[{key:"get",value:function(e){return fd[e]}}])}(),vd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=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(ad(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(ad(e,t),"/trans.recordset")}(n,a),this._store=i}),[{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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(n=t.t0).push.apply(n,v(e)),t.abrupt("return",this._reduceRecordSet(n));case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],i=[],s=a.requests.length-1;s>=0;s--){var o=a.requests[s],u=o.data;n[u.key]||(i.unshift(o),n[u.key]=!0)}i.length>0&&(a.requests=i,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=pd.get(this.dbname),a=t.generation,i=t.requests,s=null,n.prev=3,n.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:a})})));case 6:for(o=n.sent,u=0;u0)){e.next=20;break}for(n=[],r={},a=t.length-1;a>=0;a--)i=t[a],s=i.data,r[s.key]||(r[s.key]=!0,n.unshift(i));return o={generation:this.generation,requests:n},e.next=8,this._getReducedRecordset([o]);case 8:return u=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:u});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(c=pd.get(this.dbname),l=0;l1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=i,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||zl)(e,r)}(e,i,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(sd(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=pd.get(this.dbname),r=this.metadata.blockLevel;case 2:if(!(r>0)){t.next=15;break}return a=this.createBlockId(e,r),t.next=6,n.find(this._store,a);case 6:if(!(i=t.sent)){t.next=12;break}if(s=_d.createFromCacheItem(i),!(null==s?void 0:s.getItemByKey(e))){t.next=12;break}return t.abrupt("return",s);case 12:r--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"getFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return n=t.sent,t.abrupt("return",n?n.getItemByKey(e):null);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"putToBlock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Fl.get(this.dbname),a=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/r.itemSizeLimit),s=pd.get(this.dbname),n.next=6,s.find(this._store,a);case 6:if(o=n.sent,!(null==(u=o?_d.createFromCacheItem(o):new _d({blockId:a,keyName:this.keyName,items:[],limit:i}))?void 0:u.add(t))){n.next=11;break}return this._transaction.requestWrite({key:u.blockId,value:u.serialize()}),n.abrupt("return",!0);case 11:return n.abrupt("return",!1);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"removeFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(n=t.sent)){t.next=7;break}if(!n.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:n.blockId,value:n.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"clearAllBlocks",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=sd(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return n=e.sent,r=n.filter((function(e){return e.startsWith(t)})),e.next=7,this._store.removeMany(r);case 7:return e.next=9,this._transaction.clear();case 9:pd.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(t)}));case 11:case"end":return e.stop()}}),e,this)})))}}])}(),gd=function(){return i((function e(t){var n=this,a=t.dbname,i=t.collectionName,s=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(ad(e,t),"/index.").concat(n)}(a,i,o.join(">"));this.dbname=a,this.collectionName=i,this.keyName=s,this.fields=o,this.indexerKey=l,this._store=c,this._transaction=u,this._transaction.on(Xl.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Xl.ERROR,this.indexerKey,(function(){return n.abort()}))}),[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=f(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=f(this.indexOf(n),2),a=r[0];if(r[1]){var i=this._table[a].keys.indexOf(t);if(i>-1)return this._table[a].keys.splice(i,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,n,r,a=[],i=s(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),n=e[o],r=void 0,r=m(n),null!==n&&"undefined"!==r&&"boolean"!==r&&"number"!==r&&"string"!==r)throw Hl.indexTypesNotMatch;a.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return a}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Vl(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,d().mark((function e(){var t,n,r,a,i,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=pd.get(this.dbname),e.next=3,t.find(this._store,this.indexerKey,$l.PERSISTENT);case 3:if(n=e.sent){e.next=33;break}return r=sd(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:a=e.sent,i=s(a),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=22;break}if(!(u=o.value).startsWith(r)){e.next=20;break}return e.next=17,t.find(this._store,u,$l.NO_CACHE);case 17:if(c=e.sent,l=_d.createFromCacheItem(c)){h=s(l.items);try{for(h.s();!(f=h.n()).done;)p=f.value,this._addItem(p)}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=n.value,this._table=jl(this._origin);case 35:case"end":return e.stop()}}),e,this,[[10,24,27,30]])})))}},{key:"drop",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return pd.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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=jl(this._origin)}},{key:"abort",value:function(){this._table=jl(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}}])}(),yd=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},Ed=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"}(ld||(ld={})),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"}(dd||(dd={}));var kd,bd={},Cd=function(){return i((function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=ld.PROCESSING,this._queue=[],this._activationQueue=[],bd[t]&&!a.forceCreate||(this.nodeId=Ed(),this.key=t,yd()&&(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;if(null==t?void 0:t.isNestDbMessage){var r=t.nodeId,a=t.requestId,i=t.key,o=t.op,u=t.data;if(r!==n.nodeId&&i===n.key)switch(o){case dd.NEWNODE:n._sendSync();break;case dd.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case dd.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var c,l=u.currentItemRequestId,d=s(u.queue);try{var h=function(){var e=c.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:dd.REQUEST_LOCK,ts:e.ts})};for(d.s();!(c=d.n()).done;)h()}catch(e){d.e(e)}finally{d.f()}n._currentItem=n._queue.find((function(e){return e.requestId===l})),n._completeSync()}break;case dd.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 dd.REQUEST_LOCK:n._requestLock(t);break;case dd.ACQUIRE_LOCK:var f=n._queue.find((function(e){return e.requestId===a}));n._acquire(f);break;case dd.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(dd.REMOVENODE)}))),bd[t]=this),bd[t]}),[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==ld.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:Ed(),key:this.key,op:e,data:n.data,ts:Date.now()};return yd()&&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(dd.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){for(var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(dd.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1,i=0;ir.ts){t._queue.splice(i,0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(dd.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,d().mark((function e(){var t=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){t._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=ld.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(dd.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(dd.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return t=this._send(dd.REQUEST_LOCK),e.next=5,this._requestLock(t);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)}}])}(),wd=function(){function e(t){var n=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=ql.INIT,this._indexers=[],this.dbname=a,this.name=i,this.keyName=s,this.indexes=[[s]].concat(v(u.filter((function(e){return gd.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new Cd(function(e,t){return"".concat(ad(e,t),".lock")}(a,i)),this._blobContainer=new cd({dbname:a,collectionName:i,store:c}),this._transaction=new vd({dbname:a,collectionName:i,store:c})}return i(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===ql.READY}},{key:"init",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l,h,f,p,_=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,n=Fl.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return r=t.sent,this._metadata=r||{keyName:this.keyName,blockLevel:1,blockHashBase:n.blockHashBase,blockHashMultiplier:n.blockHashMultiplier,blockHashConstant:n.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new md({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),a=v(this.indexes),i=[],o=a.map((function(e){return gd.createKey(e)})),u=r?r.indexes.map((function(e){return gd.createKey(e)})):[],c=s(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(gd.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(f=[]).push.apply(f,v(a.map((function(e){var t=new gd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()})))),f.push.apply(f,v(i.map((function(e){return new gd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()})))),t.next=22,Promise.all(f);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return p=id(this.dbname,this.name),this._metadata.indexes=a,t.next=29,this._store.set({key:p,value:this._metadata});case 29:this._state=ql.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),t,this,[[2,33]])})))}},{key:"close",value:function(){this._state=ql.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=gd.createKey(e),r=s(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===gd.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Hl.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=id(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:t,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:r=s(this._indexers),t.prev=14,r.s();case 16:if((a=r.n()).done){t.next=22;break}return i=a.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),r.e(t.t0);case 27:return t.prev=27,r.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Hl.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),t,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(r=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:a=s(this._indexers),t.prev=14,a.s();case 16:if((i=a.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),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(n,e);case 34:u=s(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(r),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(r);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()}}),t,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(!(r=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:a=s(this._indexers),t.prev=8,a.s();case 10:if((i=a.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(r),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(r);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),a.e(t.t0);case 24:return t.prev=24,a.f(),t.finish(24);case 27:case"end":return t.stop()}}),t,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(n=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:r=s(this._indexers),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return i=a.value,t.next=13,i.removeItem(n);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:case"end":return t.stop()}}),t,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:t=s(this._indexers),e.prev=3,t.s();case 5:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=9,r.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return n=t.sent,this._mutex.unlock(),t.abrupt("return",jl(n));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Hl.collectionNotReady;case 18:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new nd({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Hl.collectionNotReady}},{key:"insertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Hl.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(jl(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 Hl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Hl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestInsert(jl(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Hl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Hl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(jl(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 Hl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Hl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestUpsert(jl(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Hl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Hl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(jl(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 Hl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"updateIf",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.isReady){n.next=31;break}return n.next=3,this._mutex.lock();case 3:return n.prev=3,r=e.where,a=void 0===r?{}:r,i=e.index,s=void 0===i?null:i,o=e.backward,u=void 0!==o&&o,c=[],l=new td({condition:a,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(s)}),n.next=9,l.each((function(e){return E(v,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.error){n.next=4;break}e.hasNext?(r=e.nextValue,Ql(a,r)&&t.set&&("function"!=typeof t.set?Object.keys(t.set).forEach((function(e){var n;r[e]=null===(n=t.set)||void 0===n?void 0:n[e]})):t.set(r),c.push(r)),e.next()):e.stop(),n.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return n.stop()}}),n)})))}));case 9:h=0,f=c;case 10:if(!(h1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return v(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)),i=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(i).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:i}),r}))}},{key:"_resetIfEncryptionChanged",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(this._encryptionCheckKey);case 2:if(t=e.sent,n={encrypted:Id.map((function(e){var t;return null===(t=s.encryption)||void 0===t?void 0:t.encrypt(e)}))},!t){e.next=22;break}if(!t.encrypted||!Array.isArray(t.encrypted)){e.next=20;break}e.t0=d().keys(t.encrypted);case 7:if((e.t1=e.t0()).done){e.next=18;break}if(r=e.t1.value,a=JSON.stringify(t.encrypted[r]),i=JSON.stringify(n.encrypted[r]),a===i){e.next=16;break}return Td.warning("Encryption algorithm has changed. Stored data would be cleared."),e.next=15,this.clear();case 15:return e.abrupt("break",18);case 16:e.next=7;break;case 18:e.next=22;break;case 20:return e.next=22,this.clear();case 22:return e.next=24,this.set({key:this._encryptionCheckKey,value:n});case 24:case"end":return e.stop()}}),e,this)})))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=0,e.next=3,this._getAllRawKeys();case 3:n=e.sent,r=s(n),e.prev=5,r.s();case 7:if((a=r.n()).done){e.next=15;break}return i=a.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(t+=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),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})).filter((function(e){return!n._reservedKeys.includes(e)})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=21;break}if(t.prev=5,a=r.data,!((null==(i=r.metadata)?void 0:i.shards)&&i.shards>1)){t.next=13;break}return t.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return E(o,void 0,void 0,d().mark((function n(){var r,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>0)){n.next=10;break}return r=this._getRawKey(e,".".concat(t)),n.next=4,this._getRaw(r);case 4:if(i=n.sent){n.next=7;break}throw Hl.storeBrokenIntegrity;case 7:return n.abrupt("return",i.data);case 10:return n.abrupt("return",a);case 11:case"end":return n.stop()}}),n,this)})))})));case 10:t.t0=t.sent,t.next=14;break;case 13:t.t0=[a];case 14:return s=t.t0,t.abrupt("return",this.encryption.decrypt(JSON.parse(s.join(""))));case 18:return t.prev=18,t.t1=t.catch(5),t.abrupt("return",null);case 21:return t.abrupt("return",null);case 22:case"end":return t.stop()}}),t,this,[[5,18]])})))}},{key:"set",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._shardify(e),t.next=3,this._setRaw(n);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[],t.next=3,this._setRaw(n.concat.apply(n,v(e.map((function(e){return r._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=12;break}return a=r.metadata,i=this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return o._getRawKey(e,".".concat(t))})),t.next=9,this._removeRaw(i);case 9:return null==(s=pd.get(this.dbname))||s.remove(e),t.abrupt("return",!0);case 12:return t.abrupt("return",!1);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"removeMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=pd.get(this.dbname),r=[],a=s(e),t.prev=3,o=d().mark((function e(){var t,a,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.value,a=u._getRawKey(t,".0"),e.next=4,u._getRaw(a);case 4:(s=e.sent)&&(o=s.metadata,r.push.apply(r,v(u._generateShardPostfixArray(null==o?void 0:o.shards).map((function(e){return u._getRawKey(t,".".concat(e))}))))),null==n||n.remove(t);case 7:case"end":return e.stop()}}),e)})),a.s();case 6:if((i=a.n()).done){t.next=10;break}return t.delegateYield(o(),"t0",8);case 8:t.next=6;break;case 10:t.next=15;break;case 12:t.prev=12,t.t1=t.catch(3),a.e(t.t1);case 15:return t.prev=15,a.f(),t.finish(15);case 18:if(!(r.length>0)){t.next=21;break}return t.next=21,this._removeRaw(r);case 21:return t.abrupt("return",e);case 22:case"end":return t.stop()}}),t,this,[[3,12,15,18]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==(t=pd.get(this.dbname))||t.clearForDatabase(this.dbname);case 2:case"end":return e.stop()}}),e,this)})))}}])}(),Ad={},Md=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:4194304})]);var s=i.delay,o=void 0===s?1:s;return e.delay=o,e.observer={},e}return c(t,e),i(t,[{key:"rawData",get:function(){return Ad[this.dbname]},set:function(e){Ad[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Ad[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(Ad[this.dbname]));case 4:throw Hl.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ad[this.dbname]){t.next=6;break}return t.next=3,Bl(this.delay);case 3:return t.abrupt("return",Ad[this.dbname][e]?Object.assign({key:e},Ad[this.dbname][e]):null);case 6:throw Hl.storeNotAvailable;case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ad[this.dbname]){t.next=7;break}return t.next=3,Bl(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,i=a.key,o=a.data,u=a.metadata,Ad[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Hl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ad[this.dbname]){t.next=7;break}return t.next=3,Bl(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,Ad[this.dbname][a]&&delete Ad[this.dbname][a]}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Hl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,Ad[this.dbname]||(Ad[this.dbname]={}),t.next=4,this._resetIfEncryptionChanged();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(t,"set",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=this.observer[e.key])||"function"!=typeof n.set){t.next=5;break}if(!(a=n.set())){t.next=5;break}throw a;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(t,"setMany",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((a=n.n()).done){t.next=12;break}if(i=a.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),n.e(t.t0);case 17:return t.prev=17,n.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),t,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,Bl(this.delay);case 4:Ad[this.dbname]={};case 5:case"end":return e.stop()}}),e,this)})))}}])}(Nd),Od="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(kd||(kd={}));var Ud,Dd=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:104857600})]))._storeName=Od,e._state=kd.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 c(t,e),i(t,[{key:"state",get:function(){return this._state}},{key:"isTransactionInactiveError",value:function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}},{key:"_putToObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.put(t);a.addEventListener("success",(function(e){n(e.target.result)})),a.addEventListener("error",(function(){r("Failed to write.")}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_deleteFromObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.delete(t);a.addEventListener("success",(function(){return n(t)})),a.addEventListener("error",(function(e){return r(e.target.error)}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=kd.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Od,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=kd.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=kd.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=kd.UNINITIALIZED,r(e.target.error)}))}else r(Hl.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().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===kd.UNINITIALIZED||t.t0===kd.OPEN?7:t.t0===kd.OPENING||t.t0===kd.CLOSED?8:9;break;case 7:throw Hl.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){n._openJobQueue.push((function(){return t(n._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()}}),t,this)})))}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readonly");case 2:return t=e.sent,e.next=5,new Promise((function(e,n){var r=t.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return n(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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readonly");case 2:return n=t.sent,t.next=5,new Promise((function(t,r){var a=n.get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return r(e.target.error)}))}));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._putToObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._putToObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._deleteFromObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._deleteFromObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{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,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(t="undefined"!=typeof window?window:null)?void 0:t.indexedDB)||(null==t?void 0:t.mozIndexedDB)||(null==t?void 0:t.webkitIndexedDB)||(null==t?void 0:t.msIndexedDB))){e.next=16;break}if(this._indexedDb=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB,!this._window||!yd()){e.next=13;break}if(!(yd()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!t.PointerEvent&&!t.MSPointerEvent){e.next=7;break}throw Hl.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(n._indexedDb)try{var r=n._indexedDb.open("_testMozilla");r.onerror=function(){return t(Hl.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),n._indexedDb){var a=n._indexedDb.deleteDatabase("_testMozilla");a.onerror=function(){return e()},a.onsuccess=function(){return e()}}else t(Hl.storeNotAvailable)}}catch(e){t(Hl.storeNotAvailableInPrivateBrowsing)}else t(Hl.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Hl.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,d().mark((function t(){return d().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:return t.next=7,this._resetIfEncryptionChanged();case 7:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,this._getObjectStore("readwrite");case 4:return t=e.sent,e.next=7,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))}}])}(Nd),Rd=function(e){function t(e){var a;r(this,t);var i=e.AsyncStorage,s=e.itemSizeLimit,o=void 0===s?2097152:s,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof to))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}if(t instanceof eo)switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof to&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}])}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Hd||(Hd={}));var Vd,zd=function(e){switch(e){case Hd.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Hd.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Bd=Object.assign(Object.assign({},Yo),{scheduledAt:void 0}),Qd=Object.assign(Object.assign({},Qo),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Kd="UnsentMessage",Wd={},Yd=function(e){function t(e){var a;return r(this,t),(a=n(this,t,[e]))._mutex=new Cd("unsendmessagecache.lock"),Wd[e]=a,a}return c(t,e),i(t,[{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Kd);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 po?(e.messageParams&&(n.messageParams=Wo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},Wo(t)),{scheduledAt:t.scheduledAt})))):e instanceof yo?(e.messageParams&&(n.messageParams=nu(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},nu(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof vo&&e.messageParams&&(n.messageParams=function(e){return pe({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)}),oh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(i=oh.of(this._iid),s=this._deserialize(e),!e.messageParams){a.next=32;break}if(!(s instanceof po)){a.next=8;break}o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),a.next=32;break;case 8:if(!(s instanceof yo)){a.next=26;break}if(!(u=e.messageParams).fileKey||"string"!=typeof u.fileKey||!tu(null!==(t=u.fileType)&&void 0!==t?t:"")){a.next=23;break}return a.next=13,this.collection.getBlob(u.fileKey);case 13:if(a.t1=n=a.sent,a.t0=null!==a.t1,!a.t0){a.next=17;break}a.t0=void 0!==n;case 17:if(!a.t0){a.next=21;break}a.t2=n,a.next=22;break;case 21:a.t2=void 0;case 22:u.file=a.t2;case 23:s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(u,s),a.next=32;break;case 26:if(!(s instanceof vo)){a.next=32;break}if(!(c=e.messageParams)||!c.fileInfoList){a.next=32;break}return s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(c,s),a.next=32,Promise.all(s.messageParams.fileInfoList.map((function(e){return E(f,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)||!tu(null!==(a=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==a?a:"")){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()}}),t,this)})))})));case 32:if(!(s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){a.next=54;break}if(!(s instanceof po)){a.next=38;break}l=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(l,s),a.next=54;break;case 38:if(!(s instanceof yo)){a.next=54;break}if(!(h=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof h.fileKey||"string"!=typeof h.fileType||!tu(h.fileType)){a.next=53;break}return a.next=43,this.collection.getBlob(h.fileKey);case 43:if(a.t4=r=a.sent,a.t3=null!==a.t4,!a.t3){a.next=47;break}a.t3=void 0!==r;case 47:if(!a.t3){a.next=51;break}a.t5=r,a.next=52;break;case 51:a.t5=void 0;case 52:h.file=a.t5;case 53:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(h,s);case 54:return a.abrupt("return",s);case 55:case"end":return a.stop()}}),a,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new jd:n,a=e.order,i=void 0===a?Hd.CHANNEL_LATEST:a,s=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return E(this,void 0,void 0,d().mark((function e(){var n,a,o,l,h,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=zd(i),a={"/where":function(e){return!!(i!==Hd.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(f._deserialize(e))}},t&&(a.channelUrl=t),s&&(a.sendingStatus=s),o={where:a,index:n,backward:u},e.next=8,this.collection.query(o);case 8:return l=e.sent,e.next=11,l.fetch({});case 11:return h=e.sent,e.abrupt("return",Promise.all(h.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new jd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({filter:t,order:Hd.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof yo||e instanceof vo)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return n=this._serialize(e),t.next=10,this.collection.upsertOne(n);case 10:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:n=t.sent;case 5:if(!(n.length>0)){t.next=9;break}return n.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(n);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof yo)){t.next=19;break}if(!e.messageParams){t.next=9;break}if(!(n=e.messageParams).file||!eu(n.file)){t.next=9;break}return t.next=6,this.collection.saveBlob(n.file,e.reqId);case 6:r=t.sent,n.fileKey=r,n.fileType=Xo.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){t.next=17;break}if(!(a=e.scheduledInfo.scheduledMessageParams).file||!eu(a.file)){t.next=17;break}return t.next=14,this.collection.saveBlob(a.file,e.reqId);case 14:i=t.sent,a.fileKey=i,a.fileType=Xo.BLOB;case 17:t.next=24;break;case 19:if(!(e instanceof vo)){t.next=24;break}if(!((s=e.messageParams)&&s.fileInfoList&&Array.isArray(s.fileInfoList))){t.next=24;break}return t.next=24,Promise.all(s.fileInfoList.map((function(t,n){return E(o,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!t.file||!eu(t.file)){r.next=7;break}return r.next=3,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n));case 3:a=r.sent,t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=a,t._uploadedMetaData.fileType=Xo.BLOB;case 7:case"end":return r.stop()}}),r,this)})))})));case 24:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Wd[e]&&!n||(Wd[e]=new t(e)),Wd[e]}}])}($a),Zd={},Xd=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Zd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return ss.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"_unsentMessageCache",get:function(){return Yd.of(this._iid)}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ui(!!e).throw(A.databaseError),e.collection(nl)}},{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)}),oh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new jd:i,o=e.order,u=void 0===o?Hd.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,h=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,d().mark((function e(){var r,i,o,c,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r=zd(u),i={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Hd.CHANNEL_LATEST:if(_&&e.createdAt!==n)return!1;if(l){if(g&&e.createdAtn||!g&&e.createdAt>=n)return!1;break;case Hd.NEWEST_CHILD_MESSAGE:if(!h||0===e.parentMessageId||e.parentMessageId!==h)return!1}return!(p&&!e._poll)&&s.match(f._deserialize(e))}},index:r,backward:l},e.next=5,this.collection.query(i);case 5:return o=e.sent,e.next=8,o.fetch({limit:null!=a?a:void 0});case 8:return c=e.sent,e.abrupt("return",Promise.all(c.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}))));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new jd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:Hd.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=30;break}return n.next=3,this.saveBlobs(e);case 3:r=s(e),n.prev=4,r.s();case 6:if((a=r.n()).done){n.next=15;break}if(i=a.value,!(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)){n.next=13;break}return n.next=11,this.get(i.messageId);case 11:(null==(o=n.sent)?void 0:o.threadInfo)&&i.threadInfo._updateFrom(o.threadInfo);case 13:n.next=6;break;case 15:n.next=20;break;case 17:n.prev=17,n.t0=n.catch(4),r.e(n.t0);case 20:return n.prev=20,r.f(),n.finish(20);case 23:return u=e.map((function(e){return c._serialize(e)})),n.next=26,this.collection.upsertMany(u);case 26:return n.next=28,this.upsertChildMessages(e);case 28:return n.next=30,this._unsentMessageCache.upsertChildMessages(e);case 30:case"end":return n.stop()}}),n,this,[[4,17,20,23]])})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!((null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)&&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()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove("".concat(a));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:zd(Hd.CHANNEL_LATEST)});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:zd(Hd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=zd(Hd.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof yo&&e.messageParams)){t.next=7;break}if(!(n=e.messageParams).file||!eu(n.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(n.file,e.reqId);case 5:r=t.sent,n.fileKey=r;case 7:case"end":return t.stop()}}),t,this)})))})));case 2:case"end":return t.stop()}}),t)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=0,r=this._cacheContext.preference,t.next=4,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return a=t.sent,t.next=7,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return s=t.sent,t.next=13,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return o=t.sent,a&&(n+=JSON.stringify(a).length),i&&(n+=JSON.stringify(i).length),s&&(n+=JSON.stringify(s).length),o&&(n+=JSON.stringify(o).length),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Zd[e]&&!n||(Zd[e]=new t(e)),Zd[e]}}])}($a),Jd={},$d=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Jd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return ss.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ui(!!e).throw(A.databaseError),e.collection(rl)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign({},e.serialize())}},{key:"_deserialize",value:function(e){return oh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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(e);case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new jd:i,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,h=e.inclusive,f=void 0===h||h;return E(this,void 0,void 0,d().mark((function e(){var r,i,o,c=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(f&&e.createdAtn||!f&&e.createdAt>=n)return!1}return s.match(c._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},e.next=5,this.collection.query(r);case 5:return i=e.sent,e.next=8,i.fetch({limit:null!=a?a:void 0});case 8:return o=e.sent,e.abrupt("return",o.map((function(e){return c._deserialize(e)})));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=4;break}return n=e.map((function(e){return r._serialize(e)})),t.next=4,this.collection.upsertMany(n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"markAsReadByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,messageStatus:so.SENT,createdAt:{"<":t}}},{set:{messageStatus:so.READ}});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"markAsReadByMessageIds",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=5;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:so.SENT}},{set:{messageStatus:so.READ}});case 3:return r=n.sent,n.abrupt("return",r.length);case 5:return n.abrupt("return",0);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:["channelUrl","-createdAt","-notificationId"]});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:zd(Hd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=["channelUrl","-createdAt","-notificationId"],i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Jd[e]&&!n||(Jd[e]=new t(e)),Jd[e]}}])}($a),eh={},th=function(t){function a(t){var i;return r(this,a),(i=n(this,a,[t]))._observers=new Map,i._dispatcherContext=i._dispatcher.on((function(t){return E(i,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,N,A,M,O=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof Fs)){n.next=19;break}if(r=t.messages,a=t.source,i=t.isWebSocketEventComing,s=r.filter((function(t){return t instanceof eo&&t.channelType!==e.ChannelType.OPEN&&t.messageId>0})),o=r.filter((function(t){return t instanceof eo&&t.channelType!==e.ChannelType.OPEN&&0===t.messageId})),u=r.filter((function(e){return e instanceof _o})),!(s.length>0)){n.next=9;break}return n.next=8,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(s);case 2:return e.next=4,this._unsentMessageCache.remove(s.map((function(e){return e instanceof to?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e,this)})))}));case 8:i||this._broadcastUpdateEvent(s,a);case 9:if(!(o.length>0)){n.next=13;break}return n.next=12,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.upsert(o);case 2:case"end":return e.stop()}}),e,this)})))}));case 12:i||this._broadcastUpdateEvent(o,a);case 13:if(!(u.length>0)){n.next=17;break}return n.next=16,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._notificationCache.upsert(u);case 2:case"end":return e.stop()}}),e,this)})))}));case 16:i||this._broadcastUpdateEvent(u,a);case 17:n.next=71;break;case 19:if(!(t instanceof qs)){n.next=28;break}return c=t.messageIds,l=t.source,h=t.isWebSocketEventComing,f=c.filter((function(e){return"number"==typeof e})),p=c.filter((function(e){return"string"==typeof e})),n.next=25,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(f.length>0)){e.next=3;break}return e.next=3,this._messageCache.remove(f);case 3:if(!(p.length>0)){e.next=6;break}return e.next=6,this._notificationCache.remove(p);case 6:case"end":return e.stop()}}),e,this)})))}));case 25:h||this._broadcastRemoveEvent(c,l),n.next=71;break;case 28:if(!(t instanceof js)){n.next=35;break}return v=t.reqId,_=t.source,n.next=32,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.remove([v]);case 2:case"end":return e.stop()}}),e,this)})))}));case 32:this._broadcastRemoveUnsentEvent(v,_),n.next=71;break;case 35:if(!(t instanceof Vs)){n.next=48;break}if(m=t.polls,g=t.source,!this._cacheContext.localCacheEnabled){n.next=45;break}return y=m.map((function(e){return e.messageId})),n.next=41,Promise.all(y.map((function(e){return O._messageCache.get(e)})));case 41:return k=n.sent.filter((function(e){return e})),k.length>0&&m.forEach((function(e){var t=k.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=45,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(k);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 45:this._broadcastPollChangeLogEvent(m,g),n.next=71;break;case 48:if(!(t instanceof zs)){n.next=59;break}return b=t.event,C=t.source,n.next=52,this._messageCache.get(b.messageId);case 52:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollUpdateEvent(b))){n.next=56;break}return n.next=56,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 56:this._broadcastPollUpdateEvent(b,C),n.next=71;break;case 59:if(!(t instanceof Bs)){n.next=70;break}return x=t.event,S=t.source,n.next=63,this._messageCache.get(x.messageId);case 63:if(!((T=n.sent)&&T.isUserMessage()&&T.poll&&T.poll.applyPollVoteEvent(x))){n.next=67;break}return n.next=67,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([T]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 67:this._broadcastPollVoteEvent(x,S),n.next=71;break;case 70:t instanceof Hs?(I=t.event,N=t.source,I.messageId>0&&this._broadcastReactionUpdateEvent(I,N)):t instanceof Gs&&(A=t.event,M=t.source,this._broadcastThreadUpdateEvent(A,M));case 71:case"end":return n.stop()}}),n,this)})))})),i}return c(a,t),i(a,[{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"_dispatcher",get:function(){return ss.of(this._iid).dispatcher}},{key:"_messageCache",get:function(){return Xd.of(this._iid)}},{key:"_unsentMessageCache",get:function(){return Yd.of(this._iid)}},{key:"_notificationCache",get:function(){return $d.of(this._iid)}},{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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=s(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=s(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=s(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=s(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=s(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:"_broadcastReactionUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastThreadUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(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()}}],[{key:"of",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return eh[e]&&!n||(eh[e]&&(null===(t=eh[e]._dispatcherContext)||void 0===t||t.close()),eh[e]=new a(e)),eh[e]}}])}($a),nh=function(e){function t(e){var a;r(this,t);var i=e.reverse,s=void 0!==i&&i,o=e.limit,u=void 0===o?20:o,c=e.keys,l=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(De),a.params=pe({token:l,limit:u,reverse:s,order:oe.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),a}return c(t,e),i(t)}(Ve),rh=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.next,o=a.has_more,u=void 0!==o&&o,c=a.templates;return i.nextToken=s,i.hasMore=u,i.templates=c.map((function(e){return{template:JSON.stringify(e)}})),i}return c(t,e),i(t)}(ze),ah=function(e){function t(e){var a;r(this,t);var i=e.key;return(a=n(this,t)).method=_e.GET,a.path="".concat(De,"/").concat(i),a}return c(t,e),i(t)}(Ve),ih=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).template=JSON.stringify(a),i}return c(t,e),i(t)}(ze),sh={},oh=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.requestQueue,o=n.onlineDetector,u=n.cacheContext;r(this,e),this._iid=t,this._sdkState=a,this._requestQueue=s,this._dispatcher=i,this._cacheContext=u,Xd.of(t),Yd.of(t),th.of(t),this.fileMessageQueue=new To(t,{sdkState:a,dispatcher:i,requestQueue:s,onlineDetector:o,cacheContext:u}),sh[t]=this}),[{key:"buildMessageFromSerializedData",value:function(t){var n=oi(t);if(n.notificationId)return new _o(this._iid,_o.payloadify(n));switch(n.messageType){case e.MessageType.USER:return new po(this._iid,po.payloadify(n));case e.MessageType.FILE:return vo._isMultipleFilesMessageSerializedData(n)?new vo(this._iid,vo.payloadify(n)):new yo(this._iid,yo.payloadify(n));case e.MessageType.ADMIN:return new ao(this._iid,ao.payloadify(n))}throw A.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return pe(ve({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 pe(ve({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){var n=this;return pe({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.map((function(e){return new Eo(n._iid,e)}))})}},{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=oi(e);return new Es(this._iid,Es.payloadify(t))}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Do(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Ro),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Ho(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Go),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessagesByMessageId",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Lo(Object.assign(Object.assign({channelType:n,channelUrl:t,token:String(r)},Ao),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Po),c=u.messages,this._dispatcher.dispatch(new Fs({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Lo(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},Ao),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Po),c=u.messages,this._dispatcher.dispatch(new Fs({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0;return E(this,void 0,void 0,d().mark((function e(){var u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new Lo(Object.assign(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},Ao),a),{checkingHasNext:s,checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.as(Po),h=l.messages,f=l.isContinuousMessages,p=l.hasNext,this._dispatcher.dispatch(new Fs({messages:h,source:i})),e.abrupt("return",{messages:h,isContinuousMessages:f,hasNext:p});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_THREADED_MESSAGE;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=new Lo(Object.assign(Object.assign(Object.assign({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:n},no),r),{replyType:e.ReplyType.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),i.next=3,this._requestQueue.send(s);case 3:return o=i.sent,u=o.as(Po),c=u.messages,(l=c.slice(1)).forEach((function(e){e.parentMessage=t})),this._dispatcher.dispatch(new Fs({messages:l,source:a})),i.abrupt("return",{parentMessage:c[0],threadedMessages:l});case 9:case"end":return i.stop()}}),i,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new nh(Object.assign({token:e},t)),n.next=3,this._requestQueue.send(r);case 3:return a=n.sent,i=a.as(rh),s=i.hasMore,o=i.nextToken,u=i.templates,n.abrupt("return",{hasMore:s,token:o,templates:u});case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new ah({key:e}),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(ih),i=a.template,t.abrupt("return",{template:i});case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageChangelogs",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Fo(pe(ve(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null},Oo),a)))),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(qo),c=u.updatedMessages,l=u.deletedMessagesInfo,h=u.hasMore,f=u.nextToken,p=l.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new Fs({messages:c,source:i})),p.length>0&&this._dispatcher.dispatch(new qs({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:c,deletedMessageIds:p,hasMore:h,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return sh[e]}}])}(),uh=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e])).targetMessageId=0;var s=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return s&&D("object",s)&&D("number",o)&&D("string",u)&&D("string",c)&&(i.threadInfo=new ds(e,s),i.targetMessageId=o,i.channelUrl=u,i.channelType=c),i}return c(t,e),i(t)}($a),ch={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},lh=function(t){return D("string",t.channelUrl)&&R(e.ChannelType,t.channelType)&&D("number",t.messageId)&&D("boolean",t.includeReactions,!0)&&D("boolean",t.includeMetaArray,!0)&&D("boolean",t.includeParentMessageInfo,!0)&&D("boolean",t.includeThreadInfo,!0)},dh=function(e){function t(e){var a,i=e.channelCustomType,s=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,d=e.order,h=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(xe,"/messages"),a.params={custom_type:i,query:s,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:h,message_ts_to:f,sort_field:d,advanced_query:p,target_fields:v,after:_},a}return c(t,e),i(t)}(Ve),hh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).messages=a.results.map((function(t){return go(e,t)})),i.hasNext=a.has_next,i.nextToken=a.end_cursor,i.totalCount=a.total_count,i}return c(t,e),i(t)}(ze);e.MessageSearchOrder=void 0,(Vd=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",Vd.TIMESTAMP="ts";var fh,ph,vh,_h=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;return r(this,a),(s=n(this,a,[t,i])).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=i.keyword,s.reverse=null!==(o=i.reverse)&&void 0!==o&&o,s.exactMatch=null!==(u=i.exactMatch)&&void 0!==u&&u,s.channelUrl=null!==(c=i.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=i.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(d=i.messageTimestampFrom)&&void 0!==d?d:null,s.messageTimestampTo=null!==(h=i.messageTimestampTo)&&void 0!==h?h:null,s.order=null!==(f=i.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=i.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=i.targetFields)&&void 0!==v?v:null,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.keyword)&&this.keyword.length>0&&D("boolean",this.reverse)&&D("boolean",this.exactMatch)&&D("string",this.channelUrl)&&D("string",this.channelCustomType)&&(D("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(D("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&R(e.MessageSearchOrder,this.order)&&D("boolean",this.advancedQuery)&&P("string",this.targetFields,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new dh(ve(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(hh),s=i.messages,o=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,e.abrupt("return",s);case 15:return e.abrupt("return",[]);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}])}(pu),mh=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/parent_thread_message"),a.params=pe(ve({limit:o,token:u})),a}return c(t,e),i(t)}(Ve),gh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).token=a.next,i.messages=a.messages.map((function(t){return go(e,t)})),i}return c(t,e),i(t)}(ze),yh=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s]))._edge="",o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new mh({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(gh),s=i.messages,o=i.token,this._edge=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(vu),Eh={channelUrl:"",scheduledMessageId:0},kh=function(e){return D("string",e.channelUrl)&&""!==e.channelUrl&&D("number",e.scheduledMessageId)&&e.scheduledMessageId>0},bh={reverse:!1,limit:20},Ch=function(e){return D("boolean",e.reverse,!0)&&D("number",e.limit,!0)&&P("string",e.keys,!0)},wh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="message",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new oh(e,{sdkState:r,dispatcher:a,requestQueue:s,onlineDetector:u,cacheContext:c})}},{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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},ch),e),ui(lh(n)).throw(A.invalidParameters),t.next=4,this._manager.getMessage(n);case 4:if(!((r=t.sent)instanceof eo||r instanceof _o||null===r)){t.next=7;break}return t.abrupt("return",r);case 7:throw"Unknown message type is given.";case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Eh),e),ui(kh(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},bh),t),ui(D("string",e,!0)&&Ch(r)).throw(A.invalidParameters),n.abrupt("return",this._manager.getMessageTemplatesByToken(e,r));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getMessageTemplate(e));case 2:case"end":return t.stop()}}),t,this)})))}}])}(os),xh=i((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})),Sh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="poll",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new el(e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c})}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Kc),e),ui(Wc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.create(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Xc),e),ui(Jc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.get(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Yc),e),ui(Zc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getOption(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}])}(os),Th={profileImage:void 0,profileUrl:void 0,nickname:void 0},Ih=function(e){return H(e.profileImage,!0)&&D("string",e.profileUrl,!0)&&D("string",e.nickname,!0)};e.GroupChannelListOrder=void 0,(fh=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",fh.CHRONOLOGICAL="chronological",fh.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",fh.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(ph=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",ph.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",ph.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(vh=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",vh.SCHEDULED_AT="scheduled_at";var Nh,Ah=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"]}},Mh=function(t){return{v2:function(){return E(void 0,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.commitSchema([{collectionName:tl,keyName:"url",index:[Ah(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),Ah(e.GroupChannelListOrder.CHRONOLOGICAL),Ah(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:nl,keyName:"messageId",index:[zd(Hd.CHANNEL_LATEST),zd(Hd.NEWEST_CHILD_MESSAGE)]},{collectionName:Kd,keyName:"reqId",index:[zd(Hd.CHANNEL_LATEST),zd(Hd.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))},v3:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:"FeedChannel",keyName:"url",index:[["-lastMessageUpdatedAt","-createdAt","syncIndex"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))},v4:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:rl,keyName:"notificationId",index:[["channelUrl","-createdAt","-notificationId"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}},Oh=function(t){return function(n,r){return E(void 0,void 0,void 0,d().mark((function a(){var i,s,o,u,c;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=n,a.next=1===a.t0||2===a.t0||3===a.t0||4===a.t0?3:5===a.t0?5:6===a.t0?9:26;break;case 3:return r(),a.abrupt("break",27);case 5:return a.next=7,t.reset();case 7:return r(),a.abrupt("break",27);case 9:return a.prev=9,i=Mh(t),s=i.v2,o=i.v3,u=i.v4,a.next=13,s();case 13:return a.next=15,o();case 15:return a.next=17,u();case 17:return c=t.collection(nl),a.next=20,c.removeIf({where:{channelType:e.ChannelType.OPEN}});case 20:a.next=24;break;case 22:a.prev=22,a.t1=a.catch(9);case 24:return r(),a.abrupt("break",27);case 26:r();case 27:case"end":return a.stop()}}),a,null,[[9,22]])})))}},Uh=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Dh=function(e){function t(e){var a,i=e.getVisibilityState,s=void 0===i?Uh:i,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,d=e.pauseCheckDelay,h=void 0===d?3e4:d;return r(this,t),(a=n(this,t))._pauseCheckDelay=3e4,a._currentState="visible",a._getVisibilityState=s,a._pauseCheckDelay=h,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(a),a}return c(t,e),i(t,[{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})}}])}(de),Rh=function(){return i((function e(t){var n=this,a=t.logger,i=t.connectionDelegate,s=void 0===i?null:i;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,s&&(this.connectionDelegate=s)}),[{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,d().mark((function e(){return d().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:_e.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}])}(),Lh=function(e){function t(e){var a,i=e.message;return r(this,t),(a=n(this,t)).message=i,a}return c(t,e),i(t)}(fe),Ph={},Fh=function(){return i((function e(t,n){var a=this,i=n.localCacheEnabled,s=n.enableAutoResend,o=n.dispatcher,u=n.sdkState,c=n.logger;r(this,e),this._iid=t,Ph[t]=this,this._localCacheEnabled=i,this._enableAutoResend=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=o,this._logger=c,this._sdkState=u,this._localCacheEnabled&&o.on((function(e){if(e instanceof Ha)switch(e.stateType){case Da.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case Da.INTERNAL_DISCONNECTED:case Da.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}),[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._enableAutoResend){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this._fetchAllCachedPendingMessages();case 4:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)0===(i=a.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=e.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new Fs({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){r.e(e)}finally{r.f()}case 7:case"end":return t.stop()}}),t,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)i=a.value,this._enableAutoResend&&i.errorCode&&q(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,this._enableAutoResend&&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 Fs({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return t.stop()}}),t,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&this._enableAutoResend&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!q(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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Yd.of(this._iid),(r=new jd).replyType=e.ReplyType.ALL,t.next=5,n.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0,filter:r});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&this._enableAutoResend&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),t=this._autoResendQueue[0],this._dispatcher.dispatch(new Lh({message:t})),this._logger.debug("processing auto-resend for message request id: ",t.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Ph[e]}}])}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Nh||(Nh={}));var qh,Hh=function(){return i((function e(t){r(this,e),this.category=t.cat,this.data=t.data}),null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new li(e,r),blockee:new li(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 li(e,t)})):[]}}}])}(),Gh=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),jh=function(e){function t(e,a){var i,s=a.userId;return r(this,t),(i=n(this,t))._iid=e,i.userId=s,i}return c(t,e),i(t)}(fe),Vh=function(e){function t(){return r(this,t),n(this,t)}return c(t,e),i(t)}(fe),zh=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"USEV",i])).event=new Hh(i),s}return c(t,e),i(t)}(Ke),Bh=function(e){function t(e){var a,i=e.userId,s=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i)),a.params=pe(ve({nickname:s,profile_url:o,profile_file:u,preferred_languages:c})),a}return c(t,e),i(t)}(Ve),Qh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).user=new li(e,Object.assign({},a)),i}return c(t,e),i(t)}(ze),Kh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a.params=pe({apns_device_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(Ve),Wh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a.params=pe({gcm_reg_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(Ve),Yh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),Zh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),Xh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a}return c(t,e),i(t)}(Ve),Jh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a}return c(t,e),i(t)}(Ve),$h=function(e){function t(e){var a,i=e.userId,s=e.type,o=e.token,u=e.ts;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/").concat(encodeURIComponent(s),"/device_tokens"),a.params={created_ts:u,token:o},a}return c(t,e),i(t)}(Ve),ef=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).pushTokens={type:i.type?e.PushTokenType[i.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:i.device_tokens,hasMore:i.has_more,token:i.token},s}return c(a,t),i(a)}(ze),tf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a}return c(t,e),i(t)}(Ve),nf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(ze),rf=function(e){function t(e){var a,i=e.userId,s=e.willAutoAccept;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a.params={auto_accept:s},a}return c(t,e),i(t)}(Ve),af=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(ze),sf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(Ve),of=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(ze),uf=function(e){function t(e){var a,i=e.userId,s=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,d=e.timezone;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={do_not_disturb:s,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:d},a}return c(t,e),i(t)}(Ve),cf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(ze),lf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(Ve),df=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(ze),hf=function(e){function t(e){var a,i=e.userId,s=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={snooze_enabled:s,snooze_start_ts:o,snooze_end_ts:u},a}return c(t,e),i(t)}(Ve),ff=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(ze),pf=function(e){function t(e){var a,i=e.userId,s=e.blockedUserId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block"),a.params={target_id:s},a}return c(t,e),i(t)}(Ve),vf=function(e){function t(e){var a,i=e.userId,s=e.unblockedUserId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),_f=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(Ve),mf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(ze),gf=function(e){function t(e){var a,i=e.userId,s=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={push_trigger_option:s},a}return c(t,e),i(t)}(Ve),yf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(ze),Ef=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a}return c(t,e),i(t)}(Ve),kf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(ze),bf=function(e){function t(e){var a,i=e.userId,s=e.templateName;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a.params={name:s},a}return c(t,e),i(t)}(Ve),Cf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(ze),wf=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends/changelogs"),a.params={token:s},a}return c(t,e),i(t)}(Ve),xf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).changelogs={addedUsers:a.added.map((function(t){return new li(e,t)})),updatedUsers:a.updated.map((function(t){return new li(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},i}return c(t,e),i(t)}(ze),Sf=function(e){function t(e){var a,i=e.userId,s=e.discoveries;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discoveries:s.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return c(t,e),i(t)}(Ve),Tf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).friendDiscoveryRequestId=a.friend_discovery_request_id,i}return c(t,e),i(t)}(ze),If=function(e){function t(e){var a,i=e.userId,s=e.discoveryKeys;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discovery_keys:s},a}return c(t,e),i(t)}(Ve),Nf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(Ve),Af=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new li(e,t)})),i}return c(t,e),i(t)}(ze),Mf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(Ve),Of=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={},a}return c(t,e),i(t)}(Ve),Uf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).allowFriendDiscovery=a.allow_friend_discovery,i}return c(t,e),i(t)}(ze),Df=function(e){function t(e){var a,i=e.userId,s=e.allowFriendDiscovery;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={allow_friend_discovery:s},a}return c(t,e),i(t)}(Ve),Rf=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path=Ie,e}return c(t,e),i(t)}(Ve),Lf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiContainer=new wl(a),i}return c(t,e),i(t)}(ze),Pf=function(e){function t(e){var a,i=e.categoryId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ie,"/").concat(i),a}return c(t,e),i(t)}(Ve),Ff=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiCategory=new Cl(a),i}return c(t,e),i(t)}(ze),qf=function(e){function t(e){var a,i=e.key;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Te,"/").concat(i),a}return c(t,e),i(t)}(Ve),Hf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emoji=new bl(a),i}return c(t,e),i(t)}(ze),Gf=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path="".concat(Me),e}return c(t,e),i(t)}(Ve),jf=function(e){function t(e,a){var i,s;r(this,t);var o=null!=a?a:{};return(i=n(this,t,[e,a])).uikitConfiguration={string:JSON.stringify(o),json:o},i.updatedAt=null!==(s=null==a?void 0:a.updated_at)&&void 0!==s?s:0,i}return c(t,e),i(t)}(ze);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(qh||(qh={}));var Vf,zf=function(e){function t(e){var a,i=e.deviceToken,s=e.pushTrackingId,o=e.messageId,u=e.allowedPushNotification,c=e.channelKey,l=e.templateKey,d=e.eventType,h=e.notificationEventDeadline;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=Re,a.params=pe({device_token:i,push_tracking_id:s,message_id:o,allowed_push_notification:u,channel_key:c,template_key:l,event_type:d,notification_event_deadline:h}),a}return c(t,e),i(t)}(Ve);var Bf,Qf=function(){function t(e,n,a){var i=this;r(this,t),this._storeInitialized=!1,this._iid=e,this.options=n;var s=ss.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,l=s.sessionManager,h=s.requestQueue,f=s.logger,p=s.userEventHandlers,v=s.appStateToggleEnabled;this._onlineDetector=new Rh({logger:f,connectionDelegate:{reconnect:function(){return E(i,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=ss.of(e),r=n.sdkState,a=n.connectionManager,(i=n.sessionManager).session.hasSession){t.next=14;break}return t.prev=2,t.next=5,a.connect(i.session.authToken);case 5:t.next=12;break;case 7:if(t.prev=7,t.t0=t.catch(2),!N(t.t0)){t.next=11;break}throw t.t0;case 11:f.debug("connect failed by reconnect event = ",t.t0);case 12:t.next=25;break;case 14:if("foreground"!==r.appState){t.next=25;break}return t.prev=15,t.next=18,a.resetAndReconnect();case 18:t.next=25;break;case 20:if(t.prev=20,t.t1=t.catch(15),!N(t.t1)){t.next=24;break}throw t.t1;case 24:f.debug("resetAndReconnect failed by reconnect event = ",t.t1);case 25:c.dispatch(new Gh);case 26:case"end":return t.stop()}}),t,null,[[2,7],[15,20]])})))},disconnect:function(){mi((function(){return E(i,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(e),r=n.connectionManager,t.next=3,r.disconnect();case 3:case"end":return t.stop()}}),t)})))}))}}});var _=new Fh(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,dispatcher:c,sdkState:o,logger:f});a.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:l,requestQueue:h,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new Dh({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()})),c.on((function(t){var n;if(t instanceof Ha){if(t.stateType===Da.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof Ke){if("USEV"===t.code){var r=t.as(zh).event;if(r.category===Nh.FRIEND_DISCOVERED){var a=Hh.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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(t instanceof La){var s=ss.of(i._iid).subscribedUnreadMessageCount,c=!1,l=t.ts;"number"==typeof l&&l>s.ts&&(s.all!==t.all&&(c=!0),s.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){s.customTypes[e]!==t.customTypes[e]&&(c=!0),s.customTypes[e]=t.customTypes[e]})),c=c&&s.ts>0,s.ts=l),c&&_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:s.all,feedChannelCount:s.feed,customTypeUnreadCount:s.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else t instanceof di?(u.preference.set(i._getUserProfileCacheKey(o.userId),hi.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(Ba(i.appId),{value:!0})):t instanceof Qe&&t.error&&t.error.isSessionInvalidatedError&&(f.debug("session revoked."),i._internalDisconnect(t.error))}))}return i(t,[{key:"appId",get:function(){return ss.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=ss.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=ss.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!ss.of(this._iid).debugMode}},{key:"logLevel",get:function(){return ss.of(this._iid).logger.level},set:function(e){ss.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return ss.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=ss.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return ss.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=ss.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=ss.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=ss.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:"_getNestDBVersion",value:function(){return 7}},{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:"_internalDisconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.connectionManager,a=n.sdkState,i=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),t.next=6,r.logout(e);case 6:return t.next=8,this.clearCachedData();case 8:a.appState="foreground";case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getMemoryStoreForDebugging",value:function(){var e=ss.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Md?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=ss.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)}},{key:"addSendbirdExtensions",value:function(e,t,n){var r=ss.of(this._iid),a=r.logger,i=r.sdkState,s=new RegExp("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");if(0===e.length)return a.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!s.test(e.version)})))return a.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(var o=0,u=Object.entries(n);o2&&void 0!==arguments[2]?arguments[2]:{};return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(ui(D("string",e)&&D("string",t,!0)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,s=a.cacheContext,o=a.connectionManager,u=n.errorForOtherUser,!i.userId||i.userId===e){r.next=10;break}if(u){r.next=9;break}return r.next=7,o.logout();case 7:r.next=10;break;case 9:throw u;case 10:return r.prev=10,r.next=13,this.initializeCache(e);case 13:c=ss.of(this._iid),c.dispatcher.dispatch(new Vh),r.next=22;break;case 17:r.prev=17,r.t0=r.catch(10),l=ss.of(this._iid),h=l.logger,s.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 22:case"end":return r.stop()}}),r,this,[[10,17]])})))}},{key:"authenticateFeed",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.authenticate(e,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=ss.of(this._iid),i=a.sessionManager,s=a.connectionManager,r.next=3,this._ready(e,t,{errorForOtherUser:s.isConnected?A.alreadyConnectedAsAnotherUser:void 0});case 3:if(null===(n=i.session.services)||void 0===n?void 0:n.includes(Q.CHAT)){r.next=7;break}return t||i.handler||(o=new Sl,this.setSessionHandler(o)),r.next=7,i.authenticate(e,t);case 7:return r.abrupt("return",this.currentUser);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"connect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._ready(e,t);case 2:return n.prev=2,r=ss.of(this._iid),a=r.connectionManager,n.next=6,a.connect(t);case 6:return n.prev=6,this._onlineDetector.start(),this._appStateChangeDetector.start(),n.finish(6);case 10:return n.abrupt("return",this.currentUser);case 11:case"end":return n.stop()}}),n,this,[[2,,6,10]])})))}},{key:"reconnect",value:function(){var e=ss.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._internalDisconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.connectionManager,r=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),e.next=6,n.disconnectWebSocket(!0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=ss.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().catch((function(e){r.debug("setBackgroundState error = ",e)})))}},{key:"setForegroundState",value:function(){var e=ss.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,a=e.logger;"background"===n.appState&&(n.appState="foreground",a.debug("going foreground state"),t.resetAndReconnect().catch((function(e){a.debug("setForgroundState error = ",e)})),r.dispatch(new Gh))}},{key:"setSessionHandler",value:function(e){ui(e instanceof Sl).throw(A.invalidParameters),ss.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){ui(D("string",e)&&t instanceof Tl).throw(A.invalidParameters),ss.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){ss.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){ss.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){ui(D("string",e)&&t instanceof xl).throw(A.invalidParameters),ss.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){ss.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){ss.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Al(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ul(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ll(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new _h(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new sl(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new cl(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=oi(e);return new li(this._iid,li.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Object.assign(Object.assign({},Th),e),ui(Ih(n)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Bh(Object.assign({userId:a.userId},n)),t.next=7,i.send(s);case 7:return o=t.sent,u=o.as(Qh),c=u.user,this.currentUser&&(n.nickname&&(this.currentUser.nickname=c.nickname),(n.profileUrl||n.profileImage)&&(this.currentUser.plainProfileUrl=c.profileUrl)),t.abrupt("return",c);case 13:throw A.connectionRequired;case 14:case"end":return t.stop()}}),t,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ui(P("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Bh({userId:r.userId,preferredLanguages:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Qh),u=o.user,this.currentUser&&(this.currentUser.preferredLanguages=u.preferredLanguages),t.abrupt("return",u);case 12:throw A.connectionRequired;case 13:case"end":return t.stop()}}),t,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ui(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ui(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.ANDROID,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=ss.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.FCM,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new Wh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,mi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.FCM,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._fcmPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._fcmPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=ss.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Zh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,mi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.FCM,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=ss.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Jh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,mi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.FCM),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ui(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ui(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.IOS,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=ss.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.APNS,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new Kh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,mi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.APNS,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._apnsPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._apnsPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=ss.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Yh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,mi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.APNS,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._apnsPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._apnsPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=ss.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Xh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,mi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.APNS),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markPushNotificationAsDelivered",value:function(e){var t,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k,b;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=ss.of(this._iid),i=a.logger,s=a.sessionManager,o=a.requestQueue,u=a.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=qh.DELIVERED,l=u.parseData(e),h=l.pushTrackingId,f=l.sessionTopics,p=l.sessionKey,v=l.messageId,_=l.channelKey,m=l.templateKey,g=l.notificationEventDeadline,p){r.next=7;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 7:if(f.includes(Qi.PUSH_ACKNOWLEDGEMENT)){r.next=10;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 10:if(!u.isAcked(h,c)){r.next=13;break}return i.info("already delivered push notification:",h),r.abrupt("return");case 13:return y=Boolean(_),E=n&&y,k=null===(t=s.deviceTokens[0])||void 0===t?void 0:t.token,b=new zf({deviceToken:null!=k?k:"",pushTrackingId:h,eventType:c,messageId:v,channelKey:_,templateKey:m,notificationEventDeadline:g,allowedPushNotification:E}),p&&(b.headers["Session-Key"]=p),r.prev=18,r.next=21,o.send(b);case 21:u.markAsAcked(h,c),r.next=28;break;case 24:throw r.prev=24,r.t0=r.catch(18),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(h,". error: ").concat(r.t0)),r.t0;case 28:case"end":return r.stop()}}),r,this,[[18,24]])})))}},{key:"markPushNotificationAsClicked",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=ss.of(this._iid),a=r.logger,i=r.sessionManager,s=r.requestQueue,o=r.pushNotificationAckManager,a.debug("markPushNotificationAsClicked:",e),u=qh.CLICKED,c=o.parseData(e),l=c.pushTrackingId,h=c.sessionTopics,f=c.sessionKey,p=c.messageId,v=c.channelKey,_=c.templateKey,m=c.notificationEventDeadline,f){n.next=7;break}throw a.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 7:if(h.includes(Qi.PUSH_ACKNOWLEDGEMENT)){n.next=10;break}throw a.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 10:if(!o.isAcked(l,u)){n.next=13;break}return a.info("already clicked push notification:",l),n.abrupt("return");case 13:return g=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,y=new zf({deviceToken:null!=g?g:"",pushTrackingId:l,eventType:u,messageId:p,channelKey:v,templateKey:_,notificationEventDeadline:m}),f&&(y.headers["Session-Key"]=f),n.prev=16,n.next=19,s.send(y);case 19:o.markAsAcked(l,u),n.next=26;break;case 22:throw n.prev=22,n.t0=n.catch(16),a.debug("failed to mark push notification as clicked. push tracking id: ".concat(l,". error: ").concat(n.t0)),n.t0;case 26:case"end":return n.stop()}}),n,this,[[16,22]])})))}},{key:"getChannelInvitationPreference",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new tf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(nf),o=s.autoAccept,e.abrupt("return",{autoAccept:o});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("boolean",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new rf({userId:r.userId,willAutoAccept:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(af),u=o.autoAccept,t.abrupt("return",{autoAccept:u});case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getDoNotDisturb",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new sf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(of),o=s.preference,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return ui(D("boolean",e)&&D("number",t)&&D("number",n)&&D("number",r)&&D("number",a)&&D("string",i)).throw(A.invalidParameters),o=ss.of(this._iid),u=o.sdkState,c=o.requestQueue,l=new uf({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:a,timezone:i}),s.next=5,c.send(l);case 5:return h=s.sent,f=h.as(cf),p=f.preference,s.abrupt("return",p);case 8:case"end":return s.stop()}}),s,this)})))}},{key:"getSnoozePeriod",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new lf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(df),o=s.snoozePeriod,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("boolean",e)&&D("number",t)&&D("number",n)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new hf({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),r.next=5,s.send(o);case 5:return u=r.sent,c=u.as(ff),l=c.snoozePeriod,r.abrupt("return",l);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"getMyPushTokensByToken",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p,v,_;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",t)&&R(e.PushTokenType,n)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,o=a.requestQueue,u=a.sessionManager,c=new $h({userId:i.userId,type:n,token:t}),r.next=5,o.send(c);case 5:l=r.sent,h=l.as(ef),f=h.pushTokens,p=s(f.deviceTokens);try{for(p.s();!(v=p.n()).done;)_=v.value,u.setDeviceToken(f.type,_)}catch(e){p.e(e)}finally{p.f()}return r.next=11,u.saveDeviceToken();case 11:return r.abrupt("return",f);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"getPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new _f({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(mf).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new gf({userId:a.userId,pushTriggerOption:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(yf).pushTriggerOption);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"getPushTemplate",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ef({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(kf).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.PushTemplate,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new bf({userId:a.userId,templateName:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(Cf).name);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"blockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(e instanceof li||D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new pf({userId:r.userId,blockedUserId:e instanceof li?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(e instanceof li||D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new vf({userId:r.userId,unblockedUserId:e instanceof li?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new wf({userId:r.userId,token:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(xf),u=o.changelogs,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Of({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Uf),o=s.allowFriendDiscovery,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("boolean",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Df({userId:r.userId,allowFriendDiscovery:e}),t.next=5,a.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Sf({userId:r.userId,discoveries:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(Tf),u=o.friendDiscoveryRequestId,t.abrupt("return",u);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new If({userId:r.userId,discoveryKeys:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"addFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Nf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(Af),u=o.users,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Mf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getAllEmoji",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Rf,e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Lf),s=i.emojiContainer,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Pf({categoryId:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Ff),o=s.emojiCategory,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getEmoji",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new qf({key:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Hf),o=s.emoji,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getUIKitConfiguration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),ui(t.hasExtension("sb_uikit")).throw(A.notSupportedError),n=t.requestQueue,r=new Gf,e.next=6,n.send(r);case 6:return a=e.sent,i=a.as(jf),s=i.uikitConfiguration,e.abrupt("return",s);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(n){var r=n.appId,a=n.appVersion,i=n.modules,s=void 0===i?[]:i,o=n.options,u=void 0===o?new j:o,c=n.debugMode,l=void 0!==c&&c,d=n.customApiHost,h=n.customWebSocketHost,f=n.newInstance,p=void 0!==f&&f,_=n.logLevel,m=n.localCacheEnabled,g=void 0!==m&&m,y=n.localCacheConfig,E=void 0===y?new W:y,k=n.localCacheEncryption,b=n.useAsyncStorageStore,C=void 0===b?null:b,w=n.useMMKVStorageStore,x=void 0===w?null:w,S=n.appStateToggleEnabled,T=void 0===S||S;if(!Vf||p){var I="su-".concat(ce()),N=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},A=new Gd;A.level=null!=_?_:e.LogLevel.WARN;var M=new Md({encryption:N});l||(it()?x?M=new Ld({MMKV:x,encryption:N}):C&&(M=new Rd({AsyncStorage:C,encryption:N}),A.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):M=new Dd({encryption:N})),new ss(I,{appId:r,appVersion:a,options:u,apiHost:null!=d?d:"https://api-".concat(r,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(r,".sendbird.com"),store:M,encryption:N,logger:A,localCacheEnabled:g,localCacheConfig:E,debugMode:l,appStateToggleEnabled:T});var O=[new wh,new Sh],U=new t(I,u,[].concat(v(s),O));return Vf||(Vf=U),U}return Vf}},{key:"instance",get:function(){return Vf}},{key:"version",get:function(){return b}}])}();e.MemberState=void 0,(Bf=e.MemberState||(e.MemberState={})).NONE="none",Bf.JOINED="joined",Bf.INVITED="invited",Bf.LEFT="left";var Kf,Wf,Yf,Zf,Xf,Jf,$f,ep,tp=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).state=null,s.role=null,s.isMuted=!1,s.isBlockedByMe=!1,s.isBlockingMe=!1,s.state=R(e.MemberState,i.state)?i.state:null,s.role=R(e.Role,i.role)?i.role:null,"boolean"==typeof i.is_muted&&(s.isMuted=i.is_muted),"boolean"==typeof i.is_blocked_by_me&&(s.isBlockedByMe=i.is_blocked_by_me),"boolean"==typeof i.is_blocking_me&&(s.isBlockingMe=i.is_blocking_me),s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}])}(Vo),np=function(t){function a(t,i){var s,o,u;return r(this,a),(s=n(this,a,[t])).channelUrl=null!==(o=i.channel_url)&&void 0!==o?o:"",s.channelType=null!==(u=i.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,s.member=new li(s._iid,i.user),s.deliveryAt=i.ts,s}return c(a,t),i(a)}($a);e.PublicChannelFilter=void 0,(Kf=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",Kf.PUBLIC="public",Kf.PRIVATE="private",e.MyMemberStateFilter=void 0,(Wf=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",Wf.JOINED="joined_only",Wf.INVITED="invited_only",Wf.INVITED_BY_FRIEND="invited_by_friend",Wf.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(Yf=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",Yf.SUPER="super",Yf.NON_SUPER="nonsuper",Yf.BROADCAST_ONLY="broadcast_only",Yf.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(Zf=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",Zf.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(Xf=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",Xf.UNHIDDEN="unhidden_only",Xf.HIDDEN="hidden_only",Xf.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Xf.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(Jf=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",Jf.OPERATOR="operator",Jf.NONOPERATOR="nonoperator",e.QueryType=void 0,($f=e.QueryType||(e.QueryType={})).AND="AND",$f.OR="OR",e.GroupChannelSearchField=void 0,(ep=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",ep.CHANNEL_NAME="channel_name";var rp,ap=function(){function t(n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m,g;r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(a=null==n?void 0:n.includeEmpty)&&void 0!==a&&a,this.nicknameContainsFilter=null!==(i=null==n?void 0:n.nicknameContainsFilter)&&void 0!==i?i:null,this.nicknameStartsWithFilter=null!==(s=null==n?void 0:n.nicknameStartsWithFilter)&&void 0!==s?s:null,this.nicknameExactMatchFilter=null!==(o=null==n?void 0:n.nicknameExactMatchFilter)&&void 0!==o?o:null,this.channelNameContainsFilter=null!==(u=null==n?void 0:n.channelNameContainsFilter)&&void 0!==u?u:"",this.myMemberStateFilter=null!==(c=null==n?void 0:n.myMemberStateFilter)&&void 0!==c?c:e.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(l=null==n?void 0:n.customTypesFilter)&&void 0!==l?l:null,this.channelUrlsFilter=null!==(d=null==n?void 0:n.channelUrlsFilter)&&void 0!==d?d:null,this.superChannelFilter=null!==(h=null==n?void 0:n.superChannelFilter)&&void 0!==h?h:e.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(f=null==n?void 0:n.publicChannelFilter)&&void 0!==f?f:e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(p=null==n?void 0:n.customTypeStartsWithFilter)&&void 0!==p?p:null,this.unreadChannelFilter=null!==(v=null==n?void 0:n.unreadChannelFilter)&&void 0!==v?v:e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==n?void 0:n.hiddenChannelFilter)&&void 0!==_?_:e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(m=null==n?void 0:n.includeFrozen)||void 0===m||m,(null==n?void 0:n.createdAfter)&&(this.createdAfter=n.createdAfter),(null==n?void 0:n.createdBefore)&&(this.createdBefore=n.createdBefore),this.includeMetaData=null===(g=null==n?void 0:n.includeMetaData)||void 0===g||g}return i(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,i=r.fields;if(a&&i&&i.length>0&&!i.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var s=this._userIdsFilter,o=s.userIds,u=s.includeMode,c=s.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=v(e).sort(),r=v(t).sort(),a=0;a0&&!this.customTypesFilter.includes("*")&&!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 d=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(d)})))return!1}if(this.nicknameStartsWithFilter){var h=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(h)})))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.ALL:if("none"===t.myMemberState)return!1;break;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!(this.createdAfter&&t.createdAtthis.createdBefore)}}])}(),ip=function(t){function a(e,t){var i,s=t.sdkState,o=t.cacheContext;return r(this,a),(i=n(this,a,[e]))._channels=new Map,i._sdkState=s,i._cacheContext=o,i}return c(a,t),i(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ui(!!e).throw(A.databaseError),e.collection(tl)}},{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 Iv.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return v(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>n||s&&t.createdAtn||s&&t.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)n._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});n._update(e),r.push(n)}else s._channels.set(e.url,e),r.push(e)})),!this.localCacheEnabled){n.next=7;break}for(a=[],i=0;i0)){r.next=76;break}return r.next=76,this.upsert(a);case 76:case"end":return r.stop()}}),r,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!0);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"unblock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!1);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"markAsRead",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v(this._channels.keys());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=s(t),n.prev=2,a.s();case 4:if((i=a.n()).done){n.next=12;break}return o=i.value,n.next=8,this.get(o);case 8:(null==(u=n.sent)?void 0:u._updateUnreadMemberState(this._sdkState.userId,e))&&(u._updateUnreadCount(0,0),r.push(u));case 10:n.next=4;break;case 12:n.next=17;break;case 14:n.prev=14,n.t0=n.catch(2),a.e(n.t0);case 17:return n.prev=17,a.f(),n.finish(17);case 20:if(!(r.length>0)){n.next=23;break}return n.next=23,this.upsert(r);case 23:case"end":return n.stop()}}),n,this,[[2,14,17,20]])})))}}])}($a);!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"}(rp||(rp={}));var sp,op=function(){return i((function e(t){var n;r(this,e),this.channelUrl=t.channel_url,this.channelType=t.channel_type,this.category=t.cat,this.data=null!==(n=t.data)&&void 0!==n?n:{},this.ts=t.ts}),[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}])}(),up={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},cp=function(e){return P("string",e.invitedUserIds,!0)&&D("string",e.channelUrl,!0)&&D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isSuper,!0)&&D("boolean",e.isBroadcast,!0)&&D("boolean",e.isExclusive,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isStrict,!0)&&D("boolean",e.isDiscoverable,!0)&&D("boolean",e.isEphemeral,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},lp={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},dp=function(e){return P("string",e.customTypes,!0)&&D("boolean",e.includeEmpty,!0)&&D("boolean",e.includeFrozen,!0)&&D("boolean",e.includeMetaData,!0)&&D("boolean",e.includeChatNotification,!0)},hp={myMemberStateFilter:e.MyMemberStateFilter.ALL},fp=function(t){return R(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(sp=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",sp.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",sp.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",sp.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",sp.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",sp.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",sp.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",sp.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",sp.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var pp,vp={keys:[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,e.UnreadItemKey.NONSUPER_INVITATION_COUNT,e.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},_p=function(t){return P(e.UnreadItemKey,t.keys)&&P("string",t.customTypeFilters,!0)&&P("string",t.customTypesFilter,!0)},mp={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},gp=function(t){return P("string",t.channelCustomTypesFilter,!0)&&R(e.SuperChannelFilter,t.superChannelFilter)},yp={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},Ep=function(t){return D("string",t.channelUrl,!0)&&P(e.ScheduledStatus,t.scheduledStatus,!0)&&R(e.MessageTypeFilter,t.messageTypeFilter)},kp=Object.assign({},e.CollectionEventSource),bp=function(t){return t.startsWith("EVENT_")||t===e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.CollectionEventSource.REFRESH_CHANNEL},Cp=function(e){function t(e){var a,i=e.channels,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.ts;return r(this,t),(a=n(this,t)).channels=i,a.context=s,a.isWebSocketEventComing=u,a.ts=c,a}return c(t,e),i(t)}(fe),wp=function(e){function t(e){var a,i=e.channelUrls,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,t),(a=n(this,t)).channelUrls=i,a.context=s,a.isWebSocketEventComing=u,a}return c(t,e),i(t)}(fe),xp=function(){return i((function t(n){var a=this,i=n.groupChannelCache,o=n.messageCache,u=n.unsentMessageCache,c=n.dispatcher;r(this,t),this._observers=new Map,c.on((function(t){return E(a,void 0,void 0,d().mark((function n(){var r,a,c,l,h,f,p,v,_,m,g,y,k,b,C,w=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof Cp)){n.next=47;break}if(r=t.channels,a=t.context,c=t.isWebSocketEventComing,l=r.filter((function(e){return e instanceof x_})),a.source!==e.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY&&a.source!==e.CollectionEventSource.EVENT_CHANNEL_HIDDEN){n.next=23;break}h=s(l),n.prev=5,h.s();case 7:if((f=h.n()).done){n.next=13;break}return p=f.value,n.next=11,o.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),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:n.next=41;break;case 23:v=i.filterOffsetChanged(l),_=s(v),n.prev=25,_.s();case 27:if((m=_.n()).done){n.next=33;break}return g=m.value,n.next=31,o.removeUnderOffset(g.url,g.messageOffsetTimestamp);case 31:n.next=27;break;case 33:n.next=38;break;case 35:n.prev=35,n.t1=n.catch(25),_.e(n.t1);case 38:return n.prev=38,_.f(),n.finish(38);case 41:return n.next=43,i.upsert(l,t.ts);case 43:y=n.sent,c||this._broadcastUpdateEvent(y,a),n.next=59;break;case 47:if(!(t instanceof wp)){n.next=56;break}return k=t.channelUrls,b=t.context,C=t.isWebSocketEventComing,n.next=51,i.remove(k);case 51:return n.next=53,mi((function(){return E(w,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(k),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=7,o.removeMessagesOfChannel(r);case 7:return e.next=9,u.removeMessagesOfChannel(r);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 53:C||this._broadcastRemoveEvent(k,b),n.next=59;break;case 56:if(!(t instanceof jh)){n.next=59;break}return n.next=59,i.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 59:case"end":return n.stop()}}),n,this,[[5,15,18,21],[25,35,38,41]])})))}))}),[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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:"_broadcastRemoveEvent",value:function(e,t){var n,r=s(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()}}])}(),Sp=function(e){function t(e){var a,i=e.userId,s=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c;r(this,t),a=n(this,t);var d=Object.assign(Object.assign({},lp),u),h=d.customTypes,f=d.includeEmpty,p=d.includeFrozen;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels/changelogs"),a.params=pe(ve({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:s||null,token:o,custom_types:h,show_empty:f,show_frozen:p,include_chat_notification:l})),a}return c(t,e),i(t)}(Ve),Tp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedChannels=a.updated.map((function(t){return new x_(e,Object.assign(t,{ts:a.ts}))})),i.deletedChannelUrls=a.deleted,i.hasMore=a.has_more,i.token=a.next,i.ts=a.ts,i}return c(t,e),i(t)}(ze),Ip=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall,o=e.showLatestMessage;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?be:ke,"/").concat(encodeURIComponent(i)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=o&&o},a}return c(t,e),i(t)}(Ve),Np=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),Ap={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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,createdAfter:void 0,createdBefore:void 0},Mp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,d=e.superChannelFilter,h=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,E=e.customTypeStartsWithFilter,k=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,C=e.metadataKey,w=e.metadataValues,x=e.metadataValueStartsWith,S=e.includeFrozen,T=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter,A=e.includeChatNotification,M=void 0!==A&&A,O=e.includeLeftChannel,U=void 0!==O&&O,D=e.createdAfter,R=e.createdBefore;return(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels"),a.params=pe({token:s,limit:o,order:null!=u?u:Ap.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:Ap.includeEmpty,member_state_filter:null!=l?l:Ap.myMemberStateFilter,super_mode:null!=d?d:Ap.superChannelFilter,public_mode:null!=h?h:Ap.publicChannelFilter,unread_filter:null!=f?f:Ap.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:E,hidden_mode:k,metadata_order_key:b,metadata_key:C,metadata_values:w,metadata_value_startswith:x,show_frozen:S,show_metadata:T,include_chat_notification:M,include_left_channel:U,created_after:D,created_before:R}),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 c(t,e),i(t)}(Ve),Op=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new x_(e,t)}))),i.ts=null!=u?u:0,i}return c(t,e),i(t)}(ze),Up=function(t){function a(t){var i,s=t.userId,o=t.filter;r(this,a),i=n(this,a);var u=o.myMemberStateFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/group_channel_count"),i.params={state:null!=u?u:e.MyMemberStateFilter.ALL},i}return c(a,t),i(a)}(Ve),Dp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).groupChannelCount=a.group_channel_count,i}return c(t,e),i(t)}(ze),Rp=function(e){function t(e){var a,i=e.userId,s=e.filter;r(this,t),a=n(this,t);var o=s.keys,u=s.customTypeFilters,c=s.customTypesFilter;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_item_count"),a.params=pe({item_keys:o,custom_types:null!=c?c:u}),a}return c(t,e),i(t)}(Ve),Lp=function(t){function a(t,i){var s;return r(this,a),s=n(this,a,[t,i]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=i[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),s}return c(a,t),i(a)}(ze),Pp=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_channel_count"),a}return c(t,e),i(t)}(Ve),Fp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i}return c(t,e),i(t)}(ze),qp=function(t){function a(t){var i,s=t.userId,o=t.filter,u=t.includeFeedChannel,c=void 0!==u&&u;r(this,a),i=n(this,a);var l=o.channelCustomTypesFilter,d=o.superChannelFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/unread_message_count"),i.params={super_mode:null!=d?d:e.SuperChannelFilter.ALL,custom_types:l,include_feed_channel:c},i}return c(a,t),i(a)}(Ve),Hp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i.unreadFeedCount=a.unread_feed_count,i}return c(t,e),i(t)}(ze),Gp=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledStatus,o=e.messageTypeFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ae,"/count"),a.params={channel_url:i,status:Vp(s)},o&&(a.params.message_type=o),a}return c(t,e),i(t)}(Ve),jp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).count=a.count,i}return c(t,e),i(t)}(ze),Vp=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},zp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,d=e.isBroadcast,h=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,_=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,E=e.data,k=e.customType,b=e.messageSurvivalSeconds,C=e.invitedUserIds,w=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path=ke,a.params=pe({user_ids:[i].concat(v(null!=C?C:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:d,is_exclusive:f,is_public:h,is_discoverable:p,strict:_,is_ephemeral:m,access_code:g,name:y,data:E,custom_type:k,operator_ids:w,message_survival_seconds:b}),a}return c(t,e),i(t)}(Ve),Bp=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i.isCreated=null===(s=a.is_created)||void 0===s||s,i}return c(t,e),i(t)}(ze),Qp=function(e){function t(e){var a,i=e.userId,s=e.channelUrls;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/mark_as_read_all"),a.params={channel_urls:s},a}return c(t,e),i(t)}(Ve),Kp=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).event=new op(i),s}return c(t,e),i(t)}(Ke),Wp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/join"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(Ve),Yp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),Zp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.users,f=void 0===h?null:h;return s.memberCount=c,s.joinedMemberCount=d,s.members=Array.isArray(f)?f.map((function(t){return new tp(e,t)})):[new tp(e,i.data)],s}return c(t,e),i(t)}(Kp),Xp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.shouldRemoveOperatorStatus;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/leave"),a.params={user_id:s,should_remove_operator_status:o},a}return c(t,e),i(t)}(Ve),Jp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l;return s.memberCount=c,s.joinedMemberCount=d,s.member=new tp(s._iid,i.data),s}return c(t,e),i(t)}(Kp),$p=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/invite"),a.params={user_ids:s},a}return c(t,e),i(t)}(Ve),ev=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),tv=function(e){function t(e,a,i){var s;r(this,t),(s=n(this,t,[e,a,i])).inviter=null;var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.inviter,f=o.invitees,p=void 0===f?[]:f;return s.memberCount=c,s.joinedMemberCount=d,h&&Object.keys(h).length>0&&(s.inviter=new li(e,h)),s.invitees=p.map((function(t){return new tp(e,t)})),s}return c(t,e),i(t)}(Kp),nv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/decline"),a.params={user_id:s},a}return c(t,e),i(t)}(Ve),rv=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=o.joined_member_count,l=o.inviter,d=o.invitee;return s.memberCount=null!=u?u:0,s.joinedMemberCount=null!=c?c:0,s.inviter=new li(e,l),s.invitee=new tp(e,d),s}return c(t,e),i(t)}(Kp),av={hidePreviousMessages:!1,allowAutoUnhide:!0},iv=function(e){return D("boolean",e.hidePreviousMessages,!0)&&D("boolean",e.allowAutoUnhide,!0)},sv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a.params={user_id:s,hide_previous_messages:null!=o?o:av.hidePreviousMessages,allow_auto_unhide:null!=u?u:av.allowAutoUnhide},a}return c(t,e),i(t)}(Ve),ov=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(ze),uv=function(e){function t(e,a,i){var s,o,u,c;return r(this,t),(s=n(this,t,[e,"SYEV",i])).allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,i.data&&(s.allowAutoUnhide=null!==(o=i.data.allow_auto_unhide)&&void 0!==o?o:null,s.hidePreviousMessages=null!==(u=i.data.hide_previous_messages)&&void 0!==u?u:null),s.messageOffsetTimestamp=null!==(c=i.ts_message_offset)&&void 0!==c?c:null,s}return c(t,e),i(t)}(Ke),cv=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(We),lv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new li(e,i.data),s}return c(t,e),i(t)}(Ke),dv=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(We),hv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new li(e,i.data),s}return c(t,e),i(t)}(Ke),fv=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data.operators,u=void 0===o?[]:o;return s.operators=u.map((function(e){return new li(s._iid,e)})),s}return c(t,e),i(t)}(Kp),pv=function(e){function t(e){var a=e.channelUrl,i=e.messageId;return r(this,t),n(this,t,[{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:i}}])}return c(t,e),i(t)}(We),vv=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x,S,T,I,N;return r(this,a),(s=n(this,a,[t,i])).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.includeChatNotification=!1,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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.includeChatNotification=null!==(l=i.includeChatNotification)&&void 0!==l&&l,s.channelUrlsFilter=null!==(d=i.channelUrlsFilter)&&void 0!==d?d:null,s.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(f=i.customTypeStartsWithFilter)&&void 0!==f?f:"",s.nicknameContainsFilter=null!==(p=i.nicknameContainsFilter)&&void 0!==p?p:null,s.nicknameStartsWithFilter=null!==(v=i.nicknameStartsWithFilter)&&void 0!==v?v:null,s.nicknameExactMatchFilter=null!==(_=i.nicknameExactMatchFilter)&&void 0!==_?_:null,s.channelNameContainsFilter=null!==(m=i.channelNameContainsFilter)&&void 0!==m?m:"",s.myMemberStateFilter=null!==(g=i.myMemberStateFilter)&&void 0!==g?g:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(y=i.unreadChannelFilter)&&void 0!==y?y:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(E=i.superChannelFilter)&&void 0!==E?E:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=i.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=i.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(C=i.searchFilter)&&void 0!==C?C:{fields:[],query:null},s.userIdsFilter=null!==(w=i.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(x=i.metadataKey)&&void 0!==x?x:null,s.metadataValues=null!==(S=i.metadataValues)&&void 0!==S?S:null,s.metadataOrderKeyFilter=null!==(T=i.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(I=i.metadataValueStartsWith)&&void 0!==I?I:null,s.order=null!==(N=i.order)&&void 0!==N?N:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i.createdAfter&&(s.createdAfter=i.createdAfter),i.createdBefore&&(s.createdBefore=i.createdBefore),s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter)&&D("string",this.nicknameContainsFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)&&D("string",this.nicknameExactMatchFilter,!0)&&R(e.MyMemberStateFilter,this.myMemberStateFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicChannelFilter,this.publicChannelFilter)&&R(e.UnreadChannelFilter,this.unreadChannelFilter)&&R(e.HiddenChannelFilter,this.hiddenChannelFilter)&&P(e.GroupChannelSearchField,this.searchFilter.fields)&&D("string",this.searchFilter.query,!0)&&P("string",this.userIdsFilter.userIds)&&D("boolean",this.userIdsFilter.includeMode)&&R(e.QueryType,this.userIdsFilter.queryType)&&R(e.GroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)&&F(this.createdAfter,!0)&&F(this.createdBefore,!0)}},{key:"serialize",value:function(){return si(this)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._validate()){t.next=20;break}if(this._isLoading){t.next=17;break}if(!this._hasNext){t.next=14;break}return this._isLoading=!0,n=Iv.of(this._iid),t.next=7,n.getMyGroupChannels(this._token,ve(Object.assign({},this)),this.limit,e.CollectionEventSource.REQUEST_CHANNEL,!0);case 7:return r=t.sent,a=r.channels,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,t.abrupt("return",a);case 14:return t.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:t.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return t.stop()}}),t,this)})))}}])}(pu),_v=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"SYEV",i])).pinnedMessageIds=[],s.latestPinnedMessage=null,s.ts=0,i.data&&(s.pinnedMessageIds=null!==(o=i.data.pinned_message_ids)&&void 0!==o?o:[],s.latestPinnedMessage=i.data.latest_pinned_message?go(e,Object.assign({},i.data.latest_pinned_message)):null),s.ts=i.ts,s}return c(t,e),i(t)}(Ke),mv=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e]))._logger=a.logger,i._sdkState=a.sdkState,i._sessionManager=a.sessionManager,i._requestQueue=a.requestQueue,i._dispatcher=a.dispatcher,i._cacheContext=a.cacheContext,i._channelType=a.channelType,i}return c(t,e),i(t,[{key:"_messageBroadcast",get:function(){return th.of(this._iid)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"getMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null);case 1:case"end":return e.stop()}}),e)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r,a,i){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",0);case 1:case"end":return e.stop()}}),e)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}($a),gv=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"ADMM",i])).message=new ao(e,i);var d=ss.of(e).sdkState;return s.isMentioned=qe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),yv=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"AEDI",i])).message=new ao(e,i);var h=ss.of(e).sdkState;return s.mentionCountChange=He({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),Ev=function(e){function t(e){var a,i=e.channelUrl,s=e.userId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/messages/mark_as_delivered"),a.params=pe({userId:s}),a}return c(t,e),i(t)}(Ve),kv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"DLVR",i])).channelUrl=i.channel_url,s.deliveredStateUpdate=i.updated,s}return c(t,e),i(t)}(Ke),bv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MRCT",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.event=new fs(i),s}return c(t,e),i(t)}(Ke),Cv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MTHD",i])).event=new uh(e,i),s}return c(t,e),i(t)}(Ke),wv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MCNT",i])).groupChannelMemberCounts=i.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=i.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return c(t,e),i(t)}(Ke),xv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"PEDI",i])).event=new xh(e,i),s.status=uo(i.poll.status)||i.poll.status,s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),Sv=function(){return i((function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,i=t.bottom,s=void 0===i?0:i;r(this,e),this.top=a,this.bottom=s}),[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0&&r.onMentionReceived&&r.onMentionReceived(T,w)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 63:return a.abrupt("break",344);case 64:if(D=t.as(dt),R=D.channelUrl,L=D.channelType,P=D.messageId,F=D.silent,q=D.messageCreatedAt,H=D.senderId,L!==e.ChannelType.GROUP){a.next=73;break}return a.next=68,this.getChannel(R,!0);case 68:G=a.sent,j=H===this._sdkState.userId,F||j||q>0&&G.myLastRead0&&G._updateUnreadCount(G.unreadMessageCount-1,0),this._dispatcher.dispatch(new qs({messageIds:[P],source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onMessageDeleted&&r.onMessageDeleted(G,P)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 73:return a.abrupt("break",344);case 74:if(V=t.as(Ss),(z=V.readStatus).channelType!==e.ChannelType.GROUP){a.next=82;break}return B=this._groupChannelCache.isCachedInMemory(z.channelUrl),a.next=79,this.getChannel(z.channelUrl,!0);case 79:Q=a.sent,B&&Q._updateUnreadMemberState(z.reader.userId,z.readAt),z.reader.userId===this._sdkState.userId?B?(Q.unreadMessageCount>0||Q.unreadMentionCount>0)&&(Q._updateUnreadCount(0,0),this._dispatcher.dispatch(new Cp({channels:[Q],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Q)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==Q.unreadMessageCount&&0!==Q.unreadMentionCount||(this._dispatcher.dispatch(new Cp({channels:[Q],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Q)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new Cp({channels:[Q],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUnreadMemberStatusUpdated&&r.onUnreadMemberStatusUpdated(Q)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 82:return a.abrupt("break",344);case 83:return K=t.as(kv),W=K.channelUrl,Y=K.deliveredStateUpdate,Z=void 0===Y?{}:Y,X=this._groupChannelCache.isCachedInMemory(W),a.next=87,this.getChannel(W,!0);case 87:return J=a.sent,X&&Object.keys(Z).forEach((function(e){J._updateUndeliveredMemberState(e,Z[e])})),Object.keys(Z).some((function(e){return e!==mn._sdkState.userId}))&&(this._dispatcher.dispatch(new Cp({channels:[J],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELIVERED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUndeliveredMemberStatusUpdated&&r.onUndeliveredMemberStatusUpdated(J)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 91:if($=t.as(bv),ee=$.channelUrl,te=$.channelType,ne=$.event,te!==e.ChannelType.GROUP){a.next=101;break}return a.next=95,this.getChannel(ee,!0);case 95:return re=a.sent,a.next=98,this.getMessageFromCache(ne.messageId);case 98:(ae=a.sent)?ae instanceof eo&&(ae.applyReactionEvent(ne),this._dispatcher.dispatch(new Fs({messages:[ae],source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new Hs({event:ne,source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onReactionUpdated&&r.onReactionUpdated(re,ne)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 101:return a.abrupt("break",344);case 102:if(ie=t.as(Cv),(se=ie.event).channelType!==e.ChannelType.GROUP){a.next=112;break}return a.next=106,this.getChannel(se.channelUrl,!0);case 106:return oe=a.sent,a.next=109,this.getMessageFromCache(se.targetMessageId);case 109:(ue=a.sent)?ue instanceof eo&&(ue.applyThreadInfoUpdateEvent(se),this._dispatcher.dispatch(new Fs({messages:[ue],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new Gs({event:se,source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onThreadInfoUpdated&&r.onThreadInfoUpdated(oe,se)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 112:return a.abrupt("break",344);case 113:ce=t.as(wv),le=ce.groupChannelMemberCounts,de=[],he=s(le),a.prev=116,he.s();case 118:if((fe=he.n()).done){a.next=127;break}return pe=fe.value,ve=pe.channelUrl,_e=pe.memberCount,me=pe.joinedMemberCount,ge=pe.updatedAt,a.next=123,this.getChannelFromCache(ve);case 123:(ye=a.sent)&&ye._setLatestMemberCount(_e,me,ge)&&de.push(ye);case 125:a.next=118;break;case 127:a.next=132;break;case 129:a.prev=129,a.t2=a.catch(116),he.e(a.t2);case 132:return a.prev=132,he.f(),a.finish(132);case 135:return de.length>0&&(this._dispatcher.dispatch(new Cp({channels:de,context:{source:e.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(de)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 137:if(Ee=t.as(xv),ke=Ee.event,be=Ee.status,Ce=Ee.channelUrl,we=Ee.channelType,!Ce||we!==e.ChannelType.GROUP){a.next=144;break}return a.next=141,this.getChannel(Ce,!0);case 141:xe=a.sent,this._dispatcher.dispatch(new zs({event:ke,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),_i(be===oo?function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(xe,ke.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(xe,ke)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 144:return a.abrupt("break",344);case 145:if(Se=t.as(Fc),Te=Se.event,Ie=Se.channelUrl,Ne=Se.channelType,!Ie||Ne!==e.ChannelType.GROUP){a.next=152;break}return a.next=149,this.getChannel(Ie,!0);case 149:Ae=a.sent,this._dispatcher.dispatch(new Bs({event:Te,source:e.CollectionEventSource.EVENT_POLL_VOTED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(Ae,Te)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 152:return a.abrupt("break",344);case 153:if(Me=t.as(Kp),!(Oe=Me.event).isGroupChannelEvent){a.next=332;break}a.t3=Oe.category,a.next=a.t3===rp.CHANNEL_JOIN?158:a.t3===rp.CHANNEL_LEAVE?167:a.t3===rp.CHANNEL_OPERATOR_UPDATE?183:a.t3===rp.CHANNEL_INVITE?194:a.t3===rp.CHANNEL_DECLINE_INVITE?204:a.t3===rp.TYPING_START||a.t3===rp.TYPING_END?212:a.t3===rp.USER_CHANNEL_MUTE||a.t3===rp.USER_CHANNEL_UNMUTE?221:a.t3===rp.USER_CHANNEL_BAN?248:a.t3===rp.USER_CHANNEL_UNBAN?263:a.t3===rp.CHANNEL_FREEZE||a.t3===rp.CHANNEL_UNFREEZE?271:a.t3===rp.CHANNEL_HIDE?279:a.t3===rp.CHANNEL_UNHIDE?289:a.t3===rp.CHANNEL_DELETED?296:a.t3===rp.CHANNEL_PROP_CHANGED?302:a.t3===rp.CHANNEL_META_DATA_CHANGED?308:a.t3===rp.CHANNEL_META_COUNTERS_CHANGED?317:a.t3===rp.PINNED_MESSAGE_CHANGED?326:332;break;case 158:return a.next=160,this.getChannel(Oe.channelUrl,!0);case 160:return Ue=a.sent,De=t.as(Zp),Re=De.memberCount,Le=De.joinedMemberCount,Pe=De.members,Fe=!1,Pe.forEach((function(t){Ue.isExclusive||Ue.isSuper||Ue.isBroadcast?Fe=Fe||Ue._setLatestMemberCount(Re,Le,Oe.ts):(t.state=e.MemberState.JOINED,Ue.addMember(t,Oe.ts),mn._updateJoinedMemberCount(Ue)),t.userId===mn._sdkState.userId&&(Ue.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new Cp({channels:[Ue],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:Pe}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=s(Pe);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ue,r)}}catch(e){n.e(e)}finally{n.f()}Ue.isBroadcast&&Fe&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ue])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 167:if(!(qe=this._leftChannels.get(Oe.channelUrl))){a.next=172;break}a.t4=qe.channel,a.next=175;break;case 172:return a.next=174,this.getChannel(Oe.channelUrl,!0);case 174:a.t4=a.sent;case 175:return He=a.t4,Ge=t.as(Jp),je=Ge.memberCount,Ve=Ge.joinedMemberCount,ze=Ge.member,Be=!1,Qe=ss.of(this._iid),Ke=Qe.appInfo,He.isExclusive||He.isSuper||He.isBroadcast?Be=He._setLatestMemberCount(je,Ve,Oe.ts):((null==Ke?void 0:Ke.enabledChannelMemberShipHistory)?((We=He.members.find((function(e){return e.userId===ze.userId})))&&(We.state=e.MemberState.LEFT),He.memberCount=je):He.removeMember(ze),this._updateJoinedMemberCount(He)),ze.userId===this._sdkState.userId?(He.myMemberState=e.MemberState.NONE,He.invitedAt=0,He.joinedAt=0,He._updateUnreadCount(0,0),He.isPublic?this._dispatcher.dispatch(new Cp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})):(this._markAsLeave(He),this._dispatcher.dispatch(new wp({channelUrls:[He.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})))):this._dispatcher.dispatch(new Cp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(He,ze),He.isBroadcast&&Be&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([He])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 183:return a.next=185,this.getChannel(Oe.channelUrl,!0);case 185:Ye=a.sent,Ze=t.as(fv),Xe=Ze.operators,Je=Xe.map((function(e){return e.userId})),$e=s(Ye.members);try{for($e.s();!(et=$e.n()).done;)(tt=et.value).role=Je.includes(tt.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){$e.e(e)}finally{$e.f()}return Ye.myRole=Je.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new Cp({channels:[Ye],context:{source:e.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Xe}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ye,Xe)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 194:return a.next=196,this.getChannel(Oe.channelUrl,!0);case 196:nt=a.sent,rt=t.as(tv),at=rt.memberCount,it=rt.joinedMemberCount,st=rt.inviter,(ot=rt.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),ut=s(ot);try{for(ut.s();!(ct=ut.n()).done;)lt=ct.value,nt.isExclusive||nt.isSuper||nt.isBroadcast?nt._setLatestMemberCount(at,it,Oe.ts):nt.addMember(lt,Oe.ts),this._sdkState.userId===lt.userId&&(nt.hiddenState=e.HiddenState.UNHIDDEN,nt.myMemberState!==e.MemberState.JOINED&&(nt.myMemberState=e.MemberState.INVITED),nt.invitedAt=Oe.ts)}catch(e){ut.e(e)}finally{ut.f()}return this._dispatcher.dispatch(new Cp({channels:[nt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:st,invitees:ot}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(nt,st,ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 204:return a.next=206,this.getChannel(Oe.channelUrl,!0);case 206:return ht=a.sent,ft=t.as(rv),pt=ft.memberCount,vt=ft.joinedMemberCount,_t=ft.inviter,mt=ft.invitee,ht.isExclusive||ht.isSuper||ht.isBroadcast?ht._setLatestMemberCount(pt,vt,Oe.ts):ht.removeMember(mt),this._sdkState.userId===mt.userId?(ht.invitedAt=0,ht.myMemberState=e.MemberState.NONE,ht.isPublic?this._dispatcher.dispatch(new Cp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})):this._dispatcher.dispatch(new wp({channelUrls:[ht.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}}))):this._dispatcher.dispatch(new Cp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ht,_t,mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 212:return a.next=214,this.getChannel(Oe.channelUrl,!0);case 214:return gt=a.sent,yt=Oe.category===rp.TYPING_START,Et=t.as(yt?lv:hv),kt=Et.user,gt._updateTypingStatus(kt,yt?Oe.ts:0),this._dispatcher.dispatch(new Cp({channels:[gt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(gt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 221:return a.next=223,this.getChannel(Oe.channelUrl,!0);case 223:bt=a.sent,Ct=Oe.category===rp.USER_CHANNEL_MUTE,wt=t.as(Ct?Xu:$u),(xt=wt.user).userId===this._sdkState.userId&&(bt.myMutedState=Ct?e.MutedState.MUTED:e.MutedState.UNMUTED,bt._myMutedRemainingTime=xt.restrictionInfo.remainingDuration),St=s(bt.members),a.prev=228,St.s();case 230:if((Tt=St.n()).done){a.next=237;break}if((It=Tt.value).userId!==xt.userId){a.next=235;break}return It.isMuted=Ct,a.abrupt("break",237);case 235:a.next=230;break;case 237:a.next=242;break;case 239:a.prev=239,a.t5=a.catch(228),St.e(a.t5);case 242:return a.prev=242,St.f(),a.finish(242);case 245:return this._dispatcher.dispatch(new Cp({channels:[bt],context:{source:Ct?e.CollectionEventSource.EVENT_CHANNEL_MUTED:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:xt}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ct?e.onUserMuted&&e.onUserMuted(bt,xt):e.onUserUnmuted&&e.onUserUnmuted(bt,xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 248:if(!(Nt=this._leftChannels.get(Oe.channelUrl))){a.next=253;break}a.t6=Nt.channel,a.next=256;break;case 253:return a.next=255,this.getChannel(Oe.channelUrl,!0);case 255:a.t6=a.sent;case 256:return At=a.t6,this._markAsLeave(At),Mt=t.as(tc),Ot=Mt.user,Ot.userId===this._sdkState.userId&&this._dispatcher.dispatch(new wp({channelUrls:[At.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_BANNED,user:Ot}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(At,Ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 263:return a.next=265,this.getChannel(Oe.channelUrl,!0);case 265:return Ut=a.sent,Dt=t.as(rc),Rt=Dt.user,Rt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new wp({channelUrls:[Ut.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:Rt}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(Ut,Rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 271:return a.next=273,this.getChannel(Oe.channelUrl,!0);case 273:return Lt=a.sent,Pt=t.as(ic),Ft=Pt.freeze,Lt.isFrozen=Ft,this._dispatcher.dispatch(new Cp({channels:[Lt],context:{source:Ft?e.CollectionEventSource.EVENT_CHANNEL_FROZEN:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ft?e.onChannelFrozen&&e.onChannelFrozen(Lt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 279:return a.next=281,this.getChannel(Oe.channelUrl,!0);case 281:return qt=a.sent,Ht=t.as(uv),Gt=Ht.allowAutoUnhide,jt=Ht.hidePreviousMessages,Vt=Ht.messageOffsetTimestamp,null!==Gt&&(qt.hiddenState=Gt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==jt&&jt&&qt._updateUnreadCount(0,0),null!==Vt&&(qt.messageOffsetTimestamp=Vt),this._dispatcher.dispatch(new Cp({channels:[qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 289:return a.next=291,this.getChannel(Oe.channelUrl,!0);case 291:return(zt=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new Cp({channels:[zt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(zt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 296:return a.next=298,this.getChannel(Oe.channelUrl,!0);case 298:return Bt=a.sent,this._dispatcher.dispatch(new wp({channelUrls:[Oe.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Bt.url,Bt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 302:return a.next=304,this.getChannelWithoutCache(Oe.channelUrl,!0);case 304:return Qt=a.sent,this._dispatcher.dispatch(new Cp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 308:return a.next=310,this.getChannel(Oe.channelUrl,!0);case 310:return Kt=a.sent,Wt=t.as(Lu),Yt=Wt.created,Zt=Wt.updated,Xt=Wt.deleted,Yt&&(Kt._upsertCachedMetaData(Yt,Oe.ts),this._dispatcher.dispatch(new Cp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:Yt},ts:Oe.ts}))),Zt&&(Kt._upsertCachedMetaData(Zt,Oe.ts),this._dispatcher.dispatch(new Cp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:Zt},ts:Oe.ts}))),Xt&&(Kt._removeFromCachedMetaData(Xt,Oe.ts),this._dispatcher.dispatch(new Cp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:Xt},ts:Oe.ts}))),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Yt&&e.onMetaDataCreated&&e.onMetaDataCreated(Kt,Yt),Zt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Kt,Zt),Xt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Kt,Xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 317:return a.next=319,this.getChannel(Oe.channelUrl,!0);case 319:return Jt=a.sent,$t=t.as(Ku),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&this._dispatcher.dispatch(new Cp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:en}})),tn&&this._dispatcher.dispatch(new Cp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:tn}})),nn&&this._dispatcher.dispatch(new Cp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:nn}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){en&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Jt,en),tn&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Jt,tn),nn&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Jt,nn)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 326:return a.next=328,this.getChannel(Oe.channelUrl,!0);case 328:return rn=a.sent,an=t.as(_v),sn=an.pinnedMessageIds,on=an.latestPinnedMessage,(un=an.ts)>rn._pinnedMessagesUpdatedAt&&(rn.pinnedMessageIds=null!=sn?sn:[],rn.lastPinnedMessage=on,rn._pinnedMessagesUpdatedAt=un,this._dispatcher.dispatch(new Cp({channels:[rn],context:{source:e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(rn)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(rn)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",332);case 332:return a.abrupt("break",344);case 333:cn=t.as(zh),ln=cn.event,a.t7=ln.category,a.next=a.t7===Nh.USER_BLOCK?337:a.t7===Nh.USER_UNBLOCK?340:343;break;case 337:return dn=Hh.getDataAsUserBlockEvent(this._iid,ln),hn=dn.blocker,fn=dn.blockee,this._groupChannelCache.block(hn.userId,fn.userId),a.abrupt("break",343);case 340:return pn=Hh.getDataAsUserBlockEvent(this._iid,ln),vn=pn.blocker,_n=pn.blockee,this._groupChannelCache.unblock(vn.userId,_n.userId),a.abrupt("break",343);case 343:return a.abrupt("break",344);case 344:a.next=350;break;case 346:if(a.prev=346,a.t8=a.catch(0),!N(a.t8)){a.next=350;break}throw a.t8;case 350:case"end":return a.stop()}}),a,this,[[0,346],[18,29,32,35],[116,129,132,135],[228,239,242,245]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",t)).throw(A.invalidParameters),a=new Ip({channelUrl:t,isInternalCall:n}),r.next=4,this._requestQueue.send(a);case 4:i=r.sent,s=i.as(Np),o=s.channel,u=o.unreadMessageCount,c=o.unreadMentionCount,r.t0=o.myCountPreference,r.next=r.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:r.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:r.t0===e.CountPreference.OFF?14:17;break;case 10:return c=0,r.abrupt("break",17);case 12:return u=0,r.abrupt("break",17);case 14:return u=0,c=0,r.abrupt("break",17);case 17:return o._updateUnreadCount(u,c),r.next=20,this.upsertChannelsToCache([o]);case 20:return r.abrupt("return",r.sent[0]);case 21:case"end":return r.stop()}}),r,this)})))}},{key:"refreshChannel",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REFRESH_CHANNEL,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,s=new Ip({channelUrl:t,isInternalCall:n,showLatestMessage:a}),i.next=4,this._requestQueue.send(s);case 4:if(o=i.sent,u=o.as(Np),(c=u.channel).myMemberState!==e.MemberState.NONE){i.next=10;break}this._dispatcher.dispatch(new wp({channelUrls:[c.url],context:{source:r}})),i.next=14;break;case 10:return i.next=12,this.upsertChannelsToCache([c]);case 12:l=i.sent,this._dispatcher.dispatch(new Cp({channels:l,context:{source:r}}));case 14:i.next=19;break;case 16:i.prev=16,i.t0=i.catch(0),i.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&i.t0.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new wp({channelUrls:[t],context:{source:r}}));case 19:case"end":return i.stop()}}),i,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_CHANNEL,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p,v;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.createdAfter&&(n.createdAfter=Math.floor(n.createdAfter/1e3)),n.createdBefore&&(n.createdBefore=Math.floor(n.createdBefore/1e3)),s=!1,i&&(o=ss.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(s=!0)),l=new Mp(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:r,includeLeftChannel:i&&s})),e.next=7,this._requestQueue.send(l);case 7:return h=e.sent,f=h.as(Op),p=f.channels,v=f.token,this._dispatcher.dispatch(new Cp({channels:p,context:{source:a}})),e.abrupt("return",{channels:p,token:v});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Object.assign(Object.assign({},lp),n),ui((D("string",t)||D("number",t))&&dp(a)).throw(A.invalidParameters),i=new Sp(ve({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,filter:a})),e.next=5,this._requestQueue.send(i);case 5:return s=e.sent,o=s.as(Tp),u=o.updatedChannels,c=o.deletedChannelUrls,l=o.hasMore,h=o.ts,u.length>0&&this._dispatcher.dispatch(new Cp({channels:u,context:{source:r},ts:h})),c.length>0&&this._dispatcher.dispatch(new wp({channelUrls:c,context:{source:r}})),e.abrupt("return",{updatedChannels:u,deletedChannelUrls:c,hasMore:l,token:o.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},hp),e),ui(fp(n)).throw(A.invalidParameters),r=new Up({userId:this._sdkState.userId,filter:n}),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Dp),s=i.groupChannelCount,t.abrupt("return",s);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},vp),e),ui(_p(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Rp({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Lp),c=u.groupChannelUnreadMentionCount,l=u.groupChannelUnreadMessageCount,h=u.groupChannelInvitationCount,f=u.superGroupChannelUnreadMentionCount,p=u.superGroupChannelUnreadMessageCount,v=u.superGroupChannelInvitationCount,_=u.nonSuperGroupChannelUnreadMentionCount,m=u.nonSuperGroupChannelUnreadMessageCount,g=u.nonSuperGroupChannelInvitationCount,t.abrupt("return",pe({groupChannelUnreadMentionCount:c,groupChannelUnreadMessageCount:l,groupChannelInvitationCount:h,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Pp({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Fp),o=s.unreadCount,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},mp),e),ui(gp(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new qp({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Hp),c=u.unreadCount,t.abrupt("return",c);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},yp),e),ui(Ep(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Gp(n),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(jp),u=o.count,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=ss.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=ss.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=ss.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},up),e),ui(cp(n)).throw(A.invalidParameters),n.isPublic||(n.accessCode=void 0),r=new zp(Object.assign({userId:this._sdkState.userId},n)),t.next=6,this._requestQueue.send(r);case 6:return a=t.sent,i=a.as(Bp),s=i.channel,t.next=10,this.upsertChannelsToCache([s]);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Date.now(),ui(t-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Qp({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(n);case 6:r=this._groupChannelCache.channels,a=s(r);try{for(a.s();!(i=a.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0)}catch(e){a.e(e)}finally{a.f()}if(!(r.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(r);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),ui(P("string",e)&&n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new Qp({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,i=[],o=s(a);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,n),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()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return n=t.sent,t.next=5,n.markAsDelivered();case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._messageCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0});case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),r,this)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:100,i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return E(this,void 0,void 0,d().mark((function s(){return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i});case 2:return s.abrupt("return",s.sent);case 3:case"end":return s.stop()}}),s,this)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.countBetween(e,t,new Sv({top:n,bottom:r}));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:t});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return Tv[e]||(Tv[e]=new a(e,ss.of(e))),Tv[e]}},{key:"clear",value:function(e){Tv[e]&&delete Tv[e]}}])}(mv),Nv=function(e,t){return t instanceof to?e.findIndex((function(e){return e instanceof to&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Av=function(e,t){return e.findIndex((function(e){return e instanceof eo?e.messageId===t:e instanceof _o?e.notificationId===t:void 0}))},Mv=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(i<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(pp||(pp={}));var Ov=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t))._state=pp.IDLE,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=a,i}return c(t,e),i(t,[{key:"isIdle",get:function(){return this._state===pp.IDLE}},{key:"isRunning",get:function(){return this._state===pp.RUNNING}},{key:"isDone",get:function(){return this._state===pp.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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:n=t.sent,this._retryCount=0,this.dispatch("progress",n),n.hasNext?this._run(n.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(E=_.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(y=u.range).intersect.apply(y,v(E)))?this.extendRange(_):this._metadata={range:new Sv({top:Math.min.apply(Math,v(E)),bottom:Math.max.apply(Math,v(E))}),previousComplete:!1}),h.hasNext=_.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(h.nextToken=this._metadata.range.top,this._metadata.previousComplete=_.length0&&(y=f.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(_=o.range).intersect.apply(_,v(y)))?this.extendRange(f):this._metadata={range:new Sv({top:Math.min.apply(Math,v(y)),bottom:Math.max.apply(Math,v(y))}),previousComplete:!1}),l.hasNext=f.length>=this._limit,this._metadata&&(l.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",l),n.next=15,this.saveMetadata();case 15:n.next=21;break;case 17:throw n.prev=17,n.t0=n.catch(4),m.debug("message background next sync error",n.t0),n.t0;case 21:return n.prev=21,g.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:s.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=p.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.finish(21);case 24:return n.abrupt("return",l);case 25:case"end":return n.stop()}}),n,this,[[4,17,21,24]])})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=_.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 Sv({})}},{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,v(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,v(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{range:new Sv(r.range),previousComplete:r.previousComplete}:{range:new Sv({}),previousComplete:!1};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,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.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,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now(),i=ss.of(this._iid),s=i.logger,o=i.sessionManager;i.cacheContext.localCacheEnabled&&o.session.hasSession&&(s.debug("message background sync resume()"),this._prevSyncLoopCount=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(){ss.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 Uv[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n){return Uv[e]||(Uv[e]={}),Uv[e][n.url]||(Uv[e][n.url]=new t({_iid:e,channel:n})),Uv[e][n.url].ref++,Uv[e][n.url]}},{key:"clear",value:function(e,t){Uv[e]&&Uv[e][t]&&(Uv[e][t].close(),delete Uv[e])}}])}(),Rv={},Lv=function(){function t(n){var a=this,i=n._iid,s=n.channel,o=n.includeParams;r(this,t),this.ref=0,this._iid=i,this._channel=s,this._includeParams=o;var u,c,l=ss.of(this._iid),h=l.logger,f=l.sdkState,p=l.dispatcher;this._metadataKey=(u=f.userId,c=s.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var v=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(f.userId,this._channel.url);this._sync=new Ov(v,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,a=oh.of(this._iid),t.next=8,a.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:e.ReplyType.ALL},this._includeParams),e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,s=i.updatedMessages,o=i.deletedMessageIds,u=i.hasMore,c=i.token,r.hasNext=u,r.nextToken=c,(s.length>0||o.length>0)&&this._metadata&&(this._metadata.token=c),h.debug("message changelog sync progress",r),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),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",r);case 29:case"end":return t.stop()}}),t,this,[[4,21]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.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=ss.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){ss.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Rv[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n,r){return Rv[e]||(Rv[e]={}),Rv[e][n.url]||(Rv[e][n.url]=new t({_iid:e,channel:n,includeParams:r})),Rv[e][n.url].ref++,Rv[e][n.url]}},{key:"clear",value:function(e,t){Rv[e]&&Rv[e][t]&&(Rv[e][t].close(),delete Rv[e])}}])}(),Pv={},Fv=function(){function e(t){var n=this,a=t._iid,i=t.channel,s=t.hasPollMessage;r(this,e),this.ref=0,this._iid=a,this._channel=i;var o,u,c=ss.of(this._iid),l=c.logger,h=c.sdkState,f=c.dispatcher;this._metadataKey=(o=h.userId,u=i.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new Ov(p,(function(){return E(n,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o,u,c,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(l.debug("poll changelog sync from",null===(t=this._metadata)||void 0===t?void 0:t.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,s();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return r={hasNext:!1,nextToken:0},e.abrupt("return",r);case 12:return this._metadata||(a=ss.of(this._iid),i=a.firstConnectedAt,this._metadata={token:i}),e.prev=13,o=el.of(this._iid),e.next=17,o.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return u=e.sent,c=u.hasMore,h=u.token,n.hasNext=c,n.nextToken=h,this._metadata.token=h,l.debug("poll changelog sync progress",n),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),l.debug("poll changelog sync error",e.t1),!(e.t1 instanceof 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",n);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)n.resume();else n.pause()}))}return i(e,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{token:r.token}:void 0;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ss.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){ss.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 Pv[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Pv[t]||(Pv[t]={}),Pv[t][n.url]||(Pv[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Pv[t][n.url].ref++,Pv[t][n.url]}}])}(),qv=function(t){function a(t){var i,s,o,u,c,l,d,h,f,p,v;return r(this,a),(i=n(this,a)).method=_e.GET,i.path="".concat(Pe(t.channelType),"/").concat(t.channelUrl,"/messages_gap"),i.params=pe({prev_start_ts:t.prevStart,prev_end_ts:t.prevEnd,prev_cache_count:t.prevCount,next_start_ts:t.nextStart,next_end_ts:t.nextEnd,next_cache_count:t.nextCount,huge_gap_threshold:null!==(s=t.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(o=t.customTypes)&&void 0!==o?o:["*"],message_type:null!==(u=t.messageType)&&void 0!==u?u:null,include_reply_type:null!==(c=t.replyType)&&void 0!==c?c:e.ReplyType.NONE,include_reactions:null===(l=t.includeReactions)||void 0===l||l,include_meta_array:null===(d=t.includeMetaArray)||void 0===d||d,include_thread_info:null===(h=t.includeThreadInfo)||void 0===h||h,include_parent_message_info:null===(f=t.includeParentMessageInfo)||void 0===f||f,with_sorted_meta_array:null===(p=t.includeMetaArray)||void 0===p||p,show_subchannel_messages_only:null!==(v=t.showSubchannelMessagesOnly)&&void 0!==v&&v,include_poll_details:!0,checking_continuous_messages:t.checkingContinuousMessages}),i}return c(a,t),i(a)}(Ve),Hv=function(e){function t(e,a){var i,s,o,u,c,l,d;return r(this,t),(i=n(this,t,[e,a])).isHugeGap=a.is_huge_gap,i.prevMessages=(null!==(s=a.prev_messages)&&void 0!==s?s:[]).map((function(t){return go(e,t)})),i.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,i.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,i.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return go(e,t)})),i.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,i.isContinuousNextMessages=null!==(d=a.is_continuous_next_messages)&&void 0!==d&&d,i}return c(t,e),i(t)}(ze),Gv={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var jv,Vv,zv,Bv=function(){return i((function e(){r(this,e),this._onCacheResult=ft,this._onApiResult=ft}),[{key:"_invokeResponse",value:function(e,t,n){var r=this;_i((function(){return E(r,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next="local"===r.t0?3:"remote"===r.t0?5:7;break;case 3:return this._onCacheResult(t,n),r.abrupt("break",7);case 5:return this._onApiResult(t,n),r.abrupt("break",7);case 7:case"end":return r.stop()}}),r,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}])}(),Qv=function(){return i((function t(n,a){var i=this,o=a.filter,u=a.startingPoint,c=a.limit,l=a.prevResultLimit,h=a.nextResultLimit,f=a.channel,p=a.channelManager,_=a.disableBackgroundSync,m=void 0!==_&&_;r(this,t),this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=n,this._key="mc-".concat(ce()),this._isDisposed=!1,this.filter=null!=o?o:new jd,this._channel=f,this._syncRange=new Sv({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof u&&Number.isFinite(u)?u:Number.MAX_SAFE_INTEGER,this._limit=c||100,this._prevResultLimit=null!=l?l:Math.floor(this._limit/2),this._nextResultLimit=null!=h?h:Math.floor(this._limit/2),this._channelManager=p;var g=ss.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(t,n){var r=n.source,a=t.findIndex((function(e){return e.isIdentical(i.channel)}));a>=0&&(i._replaceChannelOfCollection(t[a]),i.channel._runIfHandleableWithGroupChannel((function(t){switch(r){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:for(var a=!1,s=0;s=t.messageOffsetTimestamp){a=!0;var o=s;if(o>0){var u=i._messages.splice(0,o);i._removeMessagesFromView(u.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!a&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.CollectionEventSource.EVENT_CHANNEL_UNMUTED:var c=ss.of(i._iid).sdkState,l=n.user;c.userId===l.userId&&i._clearCheckMyMutedTimer();break;case e.CollectionEventSource.EVENT_CHANNEL_MUTED:var h=ss.of(i._iid).sdkState,f=n.user;h.userId===f.userId&&-1!==t._myMutedRemainingTime&&i._startCheckMyMutedTimer(t._myMutedRemainingTime);break;case e.CollectionEventSource.EVENT_CHANNEL_LEFT:t.isPublic&&i._clearCheckMyMutedTimer()}_i((function(){return E(i,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:bp(r)&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelUpdated)&&this._handler.onChannelUpdated(n,this.channel);case 1:case"end":return e.stop()}}),e,this)})))}))})),i._postprocessChannelUpdateEvent(t[a],r))},onRemove:function(e,t){var n=e.indexOf(i.channel.url);n>=0&&(i._clearCheckMyMutedTimer(),_i((function(){return E(i,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url);case 1:case"end":return e.stop()}}),e,this)})))})),i._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],o=[],u=s(t);try{for(u.s();!(r=u.n()).done;){var c=r.value;c.channelUrl===i._channel.url&&(i.filter.match(c)?a.push(c):o.push(i.keyOf(c)))}}catch(e){u.e(e)}finally{u.f()}if(Ps(n)){if(a.length>0)switch(n){case e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.CollectionEventSource.EVENT_MESSAGE_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.CollectionEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}o.length>0&&i._removeMessagesFromView(o,n)}i._postprocessMessageUpdateEvent(t,n)},onRemove:function(e,t){i._removeMessagesFromView(e,t),i._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:function(e,t){i._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){i._applyThreadInfoEventToView(e,t)}});var y=ss.of(this._iid),k=y.cacheContext,b=y.dispatcher,C=y.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),b.dispatch(new Cp({channels:[this._channel],context:{source:e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Dv.of(this._iid,this._channel),!m&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=Lv.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Fv.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Ov(this._key,(function(t){return E(i,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,C.run("message-fill-sync-".concat(f.url,"-prev"),(function(){return E(r,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._getRemoteMessages(t,{prevLimit:this._prevResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:k.localCacheEnabled});case 2:if(s=n.sent,o=s.messages,u=s.isContinuousMessages,!(o.length>0)){n.next=10;break}return c=Math.min.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:o.length>=this._prevResultLimit&&this.viewTop0)){n.next=10;break}return c=Math.max.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:!(o.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>c,nextToken:this._syncRange.bottom});case 10:return k.localCacheEnabled&&g.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=k.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:k.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.abrupt("return",{hasNext:!1,nextToken:0});case 12:case"end":return n.stop()}}),n,this)})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=b.on((function(e){if(e instanceof Ha)switch(e.stateType){case Da.CONNECTED:mi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._activate();case 1:case"end":return e.stop()}}),e,this)})))}));break;case Da.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}}))}),[{key:"keyOf",value:function(e){return 0}},{key:"changelogIncludeParams",get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}},{key:"_postprocessChannelUpdateEvent",value:function(e,t){}},{key:"_postprocessChannelRemoveEvent",value:function(e){}},{key:"_postprocessMessageUpdateEvent",value:function(e,t){}},{key:"_postprocessMessageRemoveEvent",value:function(e){}},{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return v(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,v(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,v(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"_activate",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),n.logger.debug("check huge gap"),this._checkHugeGap(),t.next=5,this._refreshChannel(e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_replaceChannelOfCollection",value:function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}},{key:"_shouldStartBackgroundSync",value:function(){var e=ss.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}},{key:"_setBaseMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n instanceof eo&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,t){var n,r=this,a=[],i=s(e);try{for(i.s();!(n=i.n()).done;){var o=n.value,u=Av(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c.isUserMessage()&&c.applyPoll(o),a.push(c)}}}catch(e){i.e(e)}finally{i.f()}return a.length>0&&Ps(t)&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},a.length>0&&(null===(r=(n=this._handler).onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,a));case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_applyPollUpdateEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollUpdateEvent(e)&&Ps(t)&&_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollVoteEvent(e)&&Ps(t)&&_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyReactionEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ps(t)&&(a.applyReactionEvent(e),_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_applyThreadInfoEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.targetMessageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ps(t)&&(a.applyThreadInfoUpdateEvent(e),_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_removeMessagesFromView",value:function(e,t){var n,r=this,a=[],i=[],o=s(e);try{var u=function(){var e=n.value,t=r._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var s=r._messages[t];a.push(r.keyOf(s)),i.push(s),r._messages.splice(t,1)}};for(o.s();!(n=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return Ps(t)&&i.length>0&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===r||r.call(n,s,this.channel,a,i);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,t){var n=t.prevLimit,r=void 0===n?0:n,a=t.nextLimit,i=void 0===a?0:a,s=t.inclusive,o=void 0===s||s;return E(this,void 0,void 0,d().mark((function t(){var n,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!o){t.next=5;break}return t.next=4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter);case 4:n=t.sent;case 5:if(!(r>0)){t.next=11;break}return t.next=8,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r,!1);case 8:t.t0=t.sent,t.next=12;break;case 11:t.t0=[];case 12:if(a=t.t0,!(i>0)){t.next=19;break}return t.next=16,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,i,!1);case 16:t.t1=t.sent,t.next=20;break;case 19:t.t1=[];case 20:return s=t.t1,t.abrupt("return",{messages:[].concat(v(n),v(a),v(s)).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:a.length,nextMessagesCount:s.length});case 22:case"end":return t.stop()}}),t,this)})))}},{key:"_getRemoteMessages",value:function(t,n){var r=n.prevLimit,a=void 0===r?0:r,i=n.nextLimit,s=void 0===i?0:i,o=n.source,u=void 0===o?e.CollectionEventSource.REQUEST_MESSAGE:o,c=n.reverse,l=void 0!==c&&c,h=n.checkingHasNext,f=void 0!==h&&h,p=n.checkingContinuousMessages,v=void 0!==p&&p;return E(this,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=oh.of(this._iid),!(a>0||s>0)){e.next=7;break}return e.next=4,n._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,t,ve(Object.assign(Object.assign(Object.assign({},this.filter),Gv),{isInclusive:!0,reverse:l,prevResultSize:a,nextResultSize:s})),u,f,v);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 t,n,r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,_,m,g,y,k,b,C,w,x,S,T,I,N,M,O,U,D=this;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(o=ss.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=o.cacheContext,h=o.statManager,f=o.logger,!(this._messages.length>0)){s.next=25;break}return p=this._syncRange.top,_=this.viewTop,m=this._syncRange.bottom,g=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,s.next=8,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,_,p);case 8:return y=s.sent,s.next=11,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,m,g);case 11:return k=s.sent,s.prev=12,s.next=15,Ci((function(){return E(D,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,h,f,b,C,w,x,S,T,I,N,A,M=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new qv(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:_,prevEnd:p,prevCount:y,nextStart:m,nextEnd:g,nextCount:k,checkingContinuousMessages:l.localCacheEnabled},this.filter),Gv)),t.next=3,c.send(r);case 3:a=t.sent,i=a.as(Hv),s=i.isHugeGap,o=i.prevMessages,h=void 0===o?[]:o,f=i.prevHasMore,b=i.isContinuousPrevMessages,C=i.nextMessages,w=void 0===C?[]:C,x=i.nextHasmore,S=i.isContinuousNextMessages,s?_i((function(){return E(M,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this._handler)||void 0===t?void 0:t.onHugeGapDetected)&&this._handler.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(T=this.viewTop,I=this.viewBottom,N=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,T].concat(v(h.map((function(e){return e.createdAt}))))),A=Math.max.apply(Math,[0,I].concat(v(w.map((function(e){return e.createdAt}))))),u.dispatch(new Fs({messages:h,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),u.dispatch(new Fs({messages:w,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(N,A),(b||S)&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(N,A)),f&&this._prevFill.start(N),x&&this._nextFill.start(A));case 6:case"end":return t.stop()}}),t,this)})))}),1);case 15:s.next=20;break;case 17:s.prev=17,s.t0=s.catch(12),f.debug("Failed HugeGap Check ",s.t0);case 20:return s.prev=20,l.localCacheEnabled&&h.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(t=l.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(20);case 23:s.next=42;break;case 25:return b=Date.now(),s.prev=26,s.next=29,this._getRemoteMessages(b,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled});case 29:if(C=s.sent,w=C.messages,x=C.isContinuousMessages,S=C.hasNext,w.length>0){for(I=w.map((function(e){return e.createdAt})),N=0,M=0,O=0;O=b&&M++;this._hasPrevious=N>=this._prevResultLimit,this._hasNext=null!=S?S:M>=this._nextResultLimit,(T=this._syncRange).extends.apply(T,v(I)),x&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(w,e.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;s.next=39;break;case 36:s.prev=36,s.t1=s.catch(26),s.t1 instanceof A&&s.t1.code===e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 39:return s.prev=39,l.localCacheEnabled&&h.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=l.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(39);case 42:case"end":return s.stop()}}),s,this,[[12,17,20,23],[26,36,39,42]])})))}},{key:"_loadUnsentMessages",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter);case 2:this._unsentMessages=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1);case 2:if(!(e.sent.length>0)){e.next=5;break}return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.logger,n.prev=1,n.next=4,this._channelManager.refreshChannel(this.channel.url,!0,e,t);case 4:n.next=9;break;case 6:n.prev=6,n.t0=n.catch(1),a.warn("Failed to refresh channel",n.t0);case 9:case"end":return n.stop()}}),n,this,[[1,6]])})))}},{key:"_startCheckMyMutedTimer",value:function(t){var n=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=void 0,n=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:r=t.sent,n=!r.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),n=!0;case 12:return t.prev=12,n&&(a=ss.of(this._iid),i=a.sessionManager,this.channel._runIfHandleableWithGroupChannel((function(t){var n,r;t.myMutedState=e.MutedState.UNMUTED;var a={source:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i.currentUser};null===(r=null===(n=s._handler)||void 0===n?void 0:n.onChannelUpdated)||void 0===r||r.call(n,a,s.channel)}))),t.finish(12);case 15:case"end":return t.stop()}}),t,this,[[2,9,12,15]])})))}),t+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}},{key:"_setHasNextAndHasPrevious",value:function(e,t){for(var n=e.map((function(e){return e.createdAt})),r=0,a=0,i=0;ithis._startingPoint&&a++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=t?t:a>=this._nextResultLimit}},{key:"initialize",value:function(t){var n=this,r=new Bv;this._messages=[],this._unsentMessages=[],this._syncRange=new Sv({}),this._hasNext=!0,this._hasPrevious=!0;var a=[],i={messages:[],prevMessagesCount:0,nextMessagesCount:0};return _i((function(){return E(n,void 0,void 0,d().mark((function n(){var s,o,u,c,l,h=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,null===(s=this._backgroundSync)||void 0===s?void 0:s.loadMetadata();case 2:o=n.sent,u=ss.of(this._iid),c=u.cacheContext,l=u.statManager,n.t0=t,n.next=n.t0===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API?7:9;break;case 7:return this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(t){return E(h,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=t,a=this._filterUnderOffsetMessage(i.messages),this._addMessagesToView(a,e.CollectionEventSource.REQUEST_MESSAGE),n.next=5,this._loadUnsentMessages();case 5:r._invokeResponse("local",null,a);case 6:case"end":return n.stop()}}),n,this)})))})).catch((function(e){if(N(e))throw e;r._invokeResponse("local",e,null)})).finally((function(){return E(h,void 0,void 0,d().mark((function n(){var s,u,c,h,f,p,_,m,g=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return c=ss.of(this._iid),h=c.cacheContext,f=!0,p=!0,_=!1,h.localCacheEnabled&&a.length>0&&(m=o.range).includes.apply(m,v(a.map((function(e){return e.createdAt}))))&&(!o.previousComplete&&i.prevMessagesCounto.range.bottom||i.nextMessagesCount=e._latestMessageInfo.createdAt&&(p=!1)})),p?(f=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled}).then((function(t){var n,a,i,s=t.messages,o=t.isContinuousMessages,u=t.hasNext,c=g._filterUnderOffsetMessage(s);(g._messages=[],c.length>0)?(g._setHasNextAndHasPrevious(c,u),(i=g._syncRange).extends.apply(i,v(c.map((function(e){return e.createdAt})))),o&&(null===(n=g._backgroundSync)||void 0===n?void 0:n.range.overlap(g._syncRange))&&(null===(a=g._backgroundSync)||void 0===a||a.range.extends(g._syncRange.top,g._syncRange.bottom)),g._addMessagesToView(c,e.CollectionEventSource.REQUEST_MESSAGE)):(g._hasPrevious=!1,g._hasNext=!1);r._invokeResponse("remote",null,c)})).catch((function(e){if(N(e))throw e;r._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(a),r._invokeResponse("remote",null,a)),h.localCacheEnabled&&l.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:f?"cache_hit":"cache_miss",max_db_size:null!==(u=null===(s=h.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==u?u:0,message_init_policy:t,use_local_cache:h.localCacheEnabled,collection_id:this._key}}));case 10:case"end":return n.stop()}}),n,this)})))})),n.abrupt("break",9);case 9:l.put(new Yi({type:je.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message_init_policy:t,message:!0}}}));case 10:case"end":return n.stop()}}),n,this)})))})),r}},{key:"loadPrevious",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=ss.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasPrevious){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingPrevious){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingPrevious=!0,c=this.viewTop,l=[],a.next=13,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{prevLimit:this._prevResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._prevResultLimit,s.localCacheEnabled&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ss.of(this._iid),s=i.cacheContext,e.next=3,this._getRemoteMessages(c,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:s.localCacheEnabled});case 3:u=e.sent,(l=this._filterUnderOffsetMessage(u.messages)).length>0&&((h=this._syncRange).extends.apply(h,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&u.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top))),l=l.filter((function(e){return Nv(p._messages,e)<0})),this._hasPrevious=l.length>=this._prevResultLimit,f&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(r=s.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasPrevious=l.length>=this._prevResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingPrevious=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"loadNext",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=ss.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasNext){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingNext){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingNext=!0,c=this.viewBottom,l=[],a.next=13,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{nextLimit:this._nextResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._nextResultLimit,s.localCacheEnabled&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p,_=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=ss.of(this._iid),u=s.cacheContext,e.next=3,this._getRemoteMessages(c,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:u.localCacheEnabled});case 3:h=e.sent,(l=this._filterUnderOffsetMessage(h.messages)).length>0&&((p=this._syncRange).extends.apply(p,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.bottom))),l=l.filter((function(e){return Nv(_._messages,e)<0})),this._hasNext=null!==(r=h.hasNext)&&void 0!==r?r:l.length>=this._nextResultLimit,f&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(i=null===(a=u.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:u.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasNext=l.length>=this._nextResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingNext=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"removeFailedMessage",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:return n.next=4,this._channelManager.removeFailedMessageFromCache(t);case 4:(r=this._unsentMessages.findIndex((function(e){return e.reqId===t})))>-1&&this._unsentMessages.splice(r,1);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=this;if(!this._isDisposed){this._isDisposed=!0;var i=ss.of(this._iid),s=i.cacheContext,o=i.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(t){t.myMemberState!==e.MemberState.NONE&&(a._channel._updateMessageCollectionLastAccessedAt(),o.dispatch(new Cp({channels:[a._channel],context:{source:e.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}}])}(),Kv=function(t){function a(e,t){return r(this,a),n(this,a,[e,Object.assign(Object.assign({},t),{channelManager:Iv.of(e)})])}return c(a,t),i(a,[{key:"keyOf",value:function(e){return e.messageId}},{key:"initialize",value:function(e){var t=this;return mi((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),p(a,"initialize",this,3)([e])}},{key:"setMessageCollectionHandler",value:function(e){this._setBaseMessageCollectionHandler(e)}},{key:"_activate",value:function(){var e=this,t=Object.create(null,{_activate:{get:function(){return p(a,"_activate",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t._activate.call(this);case 2:return e.next=4,mi((function(){return E(n,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_addMessagesToView",value:function(t,n){var r,a=this,i=this._filterUnderOffsetMessage(t),o=[],u=[],c=s(i);try{for(c.s();!(r=c.n()).done;){var l=r.value;if(n===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(Nv(this._messages,l)<0){Nv(this._unsentMessages,l)<0&&o.push(l);var h=Mv(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof to){Nv(this._unsentMessages,l)<0&&Nv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var f=Nv(this._messages,l);if(f<0){var p=Nv(this._unsentMessages,l);p<0?o.push(l):(this._unsentMessages.splice(p,1),u.push(l));var _=Mv(this._messages,l);this._messages.splice(_,0,l)}else u.push(l),this._messages[f]=l;if(l.updatedAt>0){var m=this._updateChildMessagesInView(l);u.push.apply(u,v(m))}}else if(l instanceof to){var g=Nv(this._unsentMessages,l);g<0?Nv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[g]=l)}}}catch(e){c.e(e)}finally{c.f()}Ps(n)&&_i((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:n},o.length>0&&(null===(r=null===(t=this._handler)||void 0===t?void 0:t.onMessagesAdded)||void 0===r||r.call(t,s,this.channel,o)),u.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateMessagesToView",value:function(e,t){var n,r=this,a=[],i=[],o=[],u=s(e);try{for(u.s();!(n=u.n()).done;){var c=n.value;if(c.messageId>0){var l=Nv(this._messages,c);if(l>=0)i.push(c),this._messages[l]=c;else{var h=Nv(this._unsentMessages,c);if(h>=0){var p=f(this._unsentMessages.splice(h,1),1)[0];if(this.hasNext&&p)o.push(p);else{i.push(c);var _=Mv(this._messages,c);this._messages.splice(_,0,c)}}else{var m=this._messages.map((function(e){return e.createdAt}));(c.createdAtMath.max.apply(Math,v(m))&&!this._hasNext)&&a.push(c)}}}else if(c instanceof to){var g=Nv(this._unsentMessages,c);g>=0&&(i.push(c),this._unsentMessages[g]=c)}}}catch(e){u.e(e)}finally{u.f()}return Ps(t)&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c={source:t},i.length>0?null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,c,this.channel,i):o.length>0?null===(u=null===(s=this._handler)||void 0===s?void 0:s.onMessagesDeleted)||void 0===u||u.call(s,c,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t);case 2:case"end":return e.stop()}}),e,this)})))})),i}}])}(Qv),Wv={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},Yv=function(e){return D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isDiscoverable,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},Zv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,d=e.nicknameStartsWithFilter,h=e.operatorFilter;return(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/members"),a.params={token:s,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:d,operator_filter:h,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return c(t,e),i(t)}(Ve),Xv=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).members=[];var s=a.next,o=a.members;return i.token=s,o&&o.length>0&&(i.members=o.map((function(t){return new tp(e,t)}))),i}return c(t,e),i(t)}(ze);e.MutedMemberFilter=void 0,(jv=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",jv.MUTED="muted",jv.UNMUTED="unmuted",e.MemberListOrder=void 0,(Vv=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",Vv.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(zv=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",zv.JOINED="joined_only",zv.INVITED="invited_only",zv.INVITED_BY_FRIEND="invited_by_friend",zv.INVITED_BY_NON_FRIEND="invited_by_non_friend";var Jv,$v,e_=function(t){function a(t,i,s){var o,u,c,l,d;return r(this,a),(o=n(this,a,[t,i,e.ChannelType.GROUP,s])).mutedMemberFilter=e.MutedMemberFilter.ALL,o.memberStateFilter=e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null,o.operatorFilter=e.OperatorFilter.ALL,o.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o.mutedMemberFilter=null!==(u=s.mutedMemberFilter)&&void 0!==u?u:e.MutedMemberFilter.ALL,o.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,o.order=null!==(d=s.order)&&void 0!==d?d:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R(e.MutedMemberFilter,this.mutedMemberFilter)&&R(e.MemberStateFilter,this.memberStateFilter)&&(D("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&R(e.OperatorFilter,this.operatorFilter)&&R(e.MemberListOrder,this.order)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Zv(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Xv),s=i.members,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),t_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/accept"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(Ve),n_=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).channel=new x_(t,i),s.channel.myMemberState=e.MemberState.JOINED,s}return c(a,t),i(a)}(ze),r_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,d=e.accessCode,h=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a.params=pe({is_distinct:s,is_public:o,is_discoverable:u,name:h,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:d,operator_ids:v,message_survival_seconds:_}),a}return c(t,e),i(t)}(Ve),a_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),i_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(Ve),s_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a}return c(t,e),i(t)}(Ve),o_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.countPreference;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:o},a}return c(t,e),i(t)}(Ve),u_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).countPreference=a.count_preference,i}return c(t,e),i(t)}(ze),c_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.locale;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/reset_user_history"),a.params=pe({locale:s}),a}return c(t,e),i(t)}(Ve),l_=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(ze),d_=Object.assign(Object.assign({},uu),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),h_=function(e){return cu(e)&&D("number",e.scheduledAt,!0)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},f_=Object.assign(Object.assign({},lu),{scheduledAt:void 0}),p_=function(e){return du(e)&&D("number",e.scheduledAt,!0)},v_=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl,d=t.scheduledMessageId;return i.method=_e.PUT,i.path="".concat(Pe(c),"/").concat(encodeURIComponent(l),"/scheduled_messages/").concat(encodeURIComponent(d)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return us.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(Ve),__=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new yo(e,a),i}return c(t,e),i(t)}(ze),m_=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.PUT,i.path="".concat(Pe(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(Ve),g_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.DELETE,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(Ve),y_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return c(t,e),i(t)}(Ve),E_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:o},a}return c(t,e),i(t)}(Ve),k_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(ze),b_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),C_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(ze);e.CountPreference=void 0,(Jv=e.CountPreference||(e.CountPreference={})).ALL="all",Jv.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Jv.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Jv.OFF="off",e.HiddenState=void 0,($v=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",$v.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",$v.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var w_,x_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y,E,k,b,C,w,x,S,T;(r(this,a),(s=n(this,a,[t,i]))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s._hasBotInfo={general:!1,ai:!1},s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isChatNotification=!1,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.totalUnreadReplyCount=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.lastPinnedMessage=null,s._latestMessageInfo=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(o=i.is_distinct)&&void 0!==o&&o,s.isSuper=null!==(u=i.is_super)&&void 0!==u&&u,s.isBroadcast=null!==(c=i.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=i.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(d=i.is_public)&&void 0!==d&&d,s.isDiscoverable=null!==(h=i.is_discoverable)&&void 0!==h?h:s.isPublic,s.isChatNotification=null!==(f=i.is_chat_notification)&&void 0!==f&&f,s.isAccessCodeRequired=null!==(p=i.is_access_code_required)&&void 0!==p&&p,s.isPushEnabled=null!==(_=i.is_push_enabled)&&void 0!==_&&_,Array.isArray(i.members))&&(T=s.members).push.apply(T,v(i.members.map((function(e){return new tp(s._iid,e)}))));return s.memberCount=null!==(m=i.member_count)&&void 0!==m?m:0,s.joinedMemberCount=null!==(g=i.joined_member_count)&&void 0!==g?g:0,s.hiddenState=R(e.HiddenState,i.hidden_state)?i.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(y=i.ts_message_offset)&&void 0!==y?y:0,s.messageSurvivalSeconds=null!==(E=i.message_survival_seconds)&&void 0!==E?E:-1,s.lastMessage=i.last_message?go(s._iid,Object.assign({channel_type:s.channelType},i.last_message)):null,i.read_receipt&&Object.keys(i.read_receipt).forEach((function(e){D("number",i.read_receipt[e])&&s._updateUnreadMemberState(e,i.read_receipt[e])})),i.delivery_receipt&&Object.keys(i.delivery_receipt).forEach((function(e){D("number",i.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,i.delivery_receipt[e])})),s.myMemberState=R(e.MemberState,i.member_state)?i.member_state:e.MemberState.NONE,s.myRole=R(e.Role,i.my_role)?i.my_role:e.Role.NONE,R(e.MutedState,i.is_muted)?s.myMutedState=i.is_muted:D("boolean",i.is_muted)?s.myMutedState=i.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=R(e.CountPreference,i.count_preference)?i.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=R(e.PushTriggerOption,i.push_trigger_option)?i.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=i.user_last_read)&&void 0!==k?k:0,s.inviter=i.inviter?new li(s._iid,i.inviter):null,s.invitedAt=null!==(b=i.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(C=i.joined_ts)&&void 0!==C?C:0,s._updateUnreadCount(null!==(w=i.unread_message_count)&&void 0!==w?w:0,null!==(x=i.unread_mention_count)&&void 0!==x?x:0),s.totalUnreadReplyCount=null!==(S=i.total_unread_thread_message_count)&&void 0!==S?S:0,s.lastPinnedMessage=i.latest_pinned_message?go(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,i.latest_message&&(s._latestMessageInfo={messageId:i.latest_message.message_id,createdAt:i.latest_message.created_at}),s._hasBotInfo={general:!!i.has_bot,ai:!!i.has_ai_bot},s}return c(a,t),i(a,[{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=s(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=s(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"hasBot",get:function(){return this._hasBotInfo.general}},{key:"hasAiBot",get:function(){return this._hasBotInfo.ai}},{key:"_shouldUpdateLastMessageWith",value:function(t){if(t.silent)return!1;var n=ss.of(this._iid).appInfo;switch(null==n?void 0:n.lastMessageThreadingPolicy){case e.LastMessageThreadingPolicy.NONE:case e.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case e.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(t.parentMessageId>0)return!1;break;case e.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof to&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case e.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof to&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}},{key:"_updateLastMessage",value:function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}},{key:"_updateUnreadCount",value:function(t,n){if("number"==typeof t&&t>=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=ss.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=ss.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return si(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Kv(this._iid,Object.assign(Object.assign({},e),{channel:this}))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new e_(this._iid,this.url,e)}},{key:"createThreadedParentMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yh(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 tp?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 to&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=ss.of(this._iid).sdkState,a=t.createdAt,i=0,o=s(this.members);try{for(o.s();!(n=o.n()).done;){var u=n.value;if(r.userId!==u.userId&&u.state===e.MemberState.JOINED&&t.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=ss.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof to?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o>=e.createdAt&&i.push(s)}})),i}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=ss.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof to?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o0&&void 0!==arguments[0]&&arguments[0],n=ss.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 i=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new ws(e._iid,{channel_url:e.url,channel_type:e.channelType,user:tp.payloadify(a),ts:null!=i?i:0})}})),r}},{key:"getDeliveryStatus",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=ss.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 i=e._undeliveredMemberStateMap.get(a.userId);r[a.userId]=new np(e._iid,{channel_url:e.url,channel_type:e.channelType,user:tp.payloadify(a),ts:null!=i?i: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=ss.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,i){var s=a.ts;n-s>=t&&(e._typingStatus.delete(i),r=!0)})),r}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._refresh());case 1:case"end":return e.stop()}}),e,this)})))}},{key:"_refresh",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ip({channelUrl:this.url}),n.next=4,a.send(s);case 4:return o=n.sent,u=o.as(Np),c=u.channel,this._update(c),t||i.dispatch(new Cp({channels:[c],context:{source:e.CollectionEventSource.REFRESH_CHANNEL}})),n.abrupt("return",this);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"freeze",value:function(){var t=this,n=Object.create(null,{freeze:{get:function(){return p(a,"freeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.freeze.call(this);case 2:r=ss.of(this._iid),r.dispatcher.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"unfreeze",value:function(){var t=this,n=Object.create(null,{unfreeze:{get:function(){return p(a,"unfreeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.unfreeze.call(this);case 2:r=ss.of(this._iid),r.dispatcher.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannel",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Wv),t),ui(Yv(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new r_(Object.assign({channelUrl:this.url},r)),n.next=6,s.send(o);case 6:return u=n.sent,c=u.as(a_),l=c.channel,this._update(l),i.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(e.every((function(e){return e instanceof li}))).throw(A.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"inviteWithUserIds",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(P("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.requestQueue,s=r.sessionManager,o=new $p({channelUrl:this.url,userIds:t}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.as(ev),l=c.channel,this._update(l),a.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:s.currentUser,invitees:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"join",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",t,!0)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Wp({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(Yp),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"leave",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Xp({channelUrl:this.url,userId:a.userId,shouldRemoveOperatorStatus:t}),n.next=4,i.send(s);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return n.stop()}}),n,this)})))}},{key:"acceptInvitation",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",t,!0)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new t_({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(n_),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"declineInvitation",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new nv({channelUrl:this.url,userId:r.userId}),t.next=4,a.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"sendUserMessage",this,3)([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){s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),Iv.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"updateUserMessage",value:function(t,n){var r=this,i=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=ss.of(this._iid),s=a.dispatcher,r.next=3,i.updateUserMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Iv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new Cp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Iv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Fs({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"_autoResendUserMessage",this,3)([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 a=Iv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"sendFileMessage",this,3)([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 a=Iv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new fl,i=ss.of(this._iid).dispatcher;return p(a,"sendMultipleFilesMessage",this,3)([t]).onPending((function(e){r._trigger(e)})).onFailed((function(e,t){r._triggerFailed(e,t)})).onSucceeded((function(t){var a=Iv.of(n._iid);n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(t,n){var r=this,i=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=ss.of(this._iid),s=a.dispatcher,r.next=3,i.updateFileMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Iv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new Cp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Iv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Fs({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"_autoResendFileMessage",this,3)([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 a=Iv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"deleteMessage",value:function(t){var n=this,r=Object.create(null,{deleteMessage:{get:function(){return p(a,"deleteMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.deleteMessage.call(this,t);case 2:0===t.messageId&&t instanceof to&&(a=ss.of(this._iid),a.dispatcher.dispatch(new js({reqId:t.reqId,source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"hide",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},av),t),ui(iv(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new sv(Object.assign({channelUrl:this.url,userId:s.userId},r)),n.next=6,o.send(u);case 6:return c=n.sent,l=c.as(ov),h=l.messageOffsetTimestamp,this.hiddenState=r.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,r.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),i.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),n.abrupt("return",this);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"unhide",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new s_({channelUrl:this.url}),t.next=4,a.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,r.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new i_({channelUrl:this.url}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.sdkState,a=n.dispatcher,i=n.requestQueue,s=new xs({channelUrl:this.url}),t.next=4,i.send(s);case 4:o=t.sent,u=o.as(Ss),c=u.readStatus,this._updateUnreadMemberState(r.userId,c.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Iv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)}))),a.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ev({channelUrl:this.url,userId:n.userId}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=ss.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingStarted>=r)){e.next=8;break}return this._typingStarted=a,this._typingEnded=0,i=new cv({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=ss.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingEnded>=r)){e.next=8;break}return this._typingStarted=0,this._typingEnded=a,i=new dv({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Bd),e),ui(function(e){return $o(e)&&D("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new Bo;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},f_),t),ui(p_(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new m_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(bc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createScheduledFileMessage",value:function(e){var t=this;e=Object.assign(Object.assign({},Qd),e),ui(function(e){return Ko(e)&&D("number",e.scheduledAt)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(A.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new Bo;return ki(2).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);_i((function(){return E(t,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a._trigger(i));case 1:case"end":return e.stop()}}),e)})))}))})),H(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a}},{key:"updateScheduledFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Object.assign(Object.assign({},d_),t),ui(h_(r)).throw(A.invalidParameters),!H(r.file)){n.next=5;break}return n.next=5,this._uploadFileAndUpdateParams(r);case 5:return a=new v_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),i=ss.of(this._iid),s=i.requestQueue,n.next=9,s.send(a);case 9:return o=n.sent,u=o.as(__),c=u.message,n.abrupt("return",c);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new g_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=ss.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new y_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=ss.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new b_({userId:n.userId,channelUrl:this.url}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(C_),o=s.pushTriggerOption,this.myPushTriggerOption=o,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new E_({userId:i.userId,channelUrl:this.url,pushTriggerOption:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(k_),l=c.pushTriggerOption,this.myPushTriggerOption=l,a.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"setMyCountPreference",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.CountPreference,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new o_({channelUrl:this.url,userId:i.userId,countPreference:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(u_),l=c.countPreference,this.myCountPreference=l,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),a.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"resetMyHistory",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=n.sdkState,s=new c_({channelUrl:this.url,locale:i.localeForChatbot}),t.next=4,a.send(s);case 4:return o=t.sent,u=o.as(l_),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,this.lastMessage&&this.lastMessage.createdAt=this._limit&&!!b,h.nextToken=b,this._metadata&&(this._metadata.token=b,(C=this._metadata.range).extends.apply(C,v(k.map((function(e){return e.createdAt})))),this._metadata.completed=!h.hasNext),f.debug("channel background sync progress",h),t.next=30,this.saveMetadata();case 30:t.next=39;break;case 32:if(t.prev=32,t.t1=t.catch(6),f.debug("channel background sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=38;break}return t.next=38,this.clearMetaData();case 38:throw t.t1;case 39:return t.prev=39,_.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(o=null===(s=p.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==o?o:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:null!==(c=null===(u=m.order)||void 0===u?void 0:u.toString())&&void 0!==c?c:"",collection_id:l.userId}})),t.finish(39);case 42:t.next=46;break;case 44:h.hasNext=!1,h.nextToken="";case 46:return t.abrupt("return",h);case 47:case"end":return t.stop()}}),t,this,[[6,32,39,42],[8,15]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 Sv({})}},{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,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata={token:r?r.token:"",range:new Sv(r?r.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!r&&r.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.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=ss.of(this._iid),r=n.logger;n.sessionManager.session.hasSession&&(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(){ss.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 S_[this._iid])}}],[{key:"of",value:function(e){return S_[e]||(S_[e]=new t({_iid:e})),S_[e].ref++,S_[e]}},{key:"clear",value:function(e){S_[e]&&(S_[e].close(),delete S_[e])}}])}(),I_={},N_=function(){function t(n){var a=this,i=n._iid;r(this,t),this.ref=0,this._iid=i;var s,o=ss.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher,h=o.cacheContext,f=o.statManager;this._metadataKey=(s=c.userId,"sendbird:".concat(s,"@groupchannel/changelogs.meta")),this._subscribers=new de;var p=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(c.userId);this._sync=new Ov(p,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,l,p,v,_,m,g;return d().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 u.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,s={includeEmpty:!0,includeMetaData:!0},t.prev=6,t.next=9,h.preference.get(Ba(c.appId));case 9:o=t.sent,s.includeChatNotification=Boolean(o),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(6),s.includeChatNotification=!1;case 16:return l=Iv.of(this._iid),t.next=19,l.getMyGroupChannelChangeLogs(null!==(a=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==a?a:"",s,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 19:return p=t.sent,v=p.updatedChannels,_=p.deletedChannelUrls,m=p.hasMore,g=p.token,this._subscribers.dispatch("progress",{updatedChannels:v,deletedChannelUrls:_,hasMore:m,token:g}),i.hasNext=m,i.nextToken=g,this._metadata&&(this._metadata.token=g),u.debug("channel changelog sync progress",i),t.next=31,this.saveMetadata();case 31:h.localCacheEnabled&&f.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:v.length>0||_.length>0?"cache_miss":"cache_hit",max_db_size:v.length,use_local_cache:h.localCacheEnabled,starting_point:0,message_init_policy:_.length.toString(),collection_id:c.userId}})),t.next=41;break;case 34:if(t.prev=34,t.t1=t.catch(4),u.debug("channel changelog sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=40;break}return t.next=40,this.clearMetadata();case 40:throw t.t1;case 41:return t.abrupt("return",i);case 42:case"end":return t.stop()}}),t,this,[[4,34],[6,13]])})))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=l.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"isRunning",get:function(){return this._sync.isRunning}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"on",value:function(e,t){return this._subscribers.on(e,t)}},{key:"resume",value:function(){ss.of(this._iid).sessionManager.session.hasSession&&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 I_[this._iid])}}],[{key:"of",value:function(e){return I_[e]||(I_[e]=new t({_iid:e})),I_[e].ref++,I_[e]}},{key:"clear",value:function(e){I_[e]&&(I_[e].close(),delete I_[e])}}])}(),A_=function(t,n){var r,a,i,s;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!==(s=null===(i=t.lastMessage)||void 0===i?void 0:i.createdAt)&&void 0!==s?s:t.createdAt}},M_=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},O_=function(e,t,n){if(e.length>0){for(var r=M_(e,t),a=0,i=e.length-1,s=Math.floor((a+i)/2);a0)i=s,s=Math.floor((a+i)/2);else{if(!(o<0))return{place:s,oldPosition:r};a=s+1,s=Math.floor((a+i)/2)}}return{place:U_(e[s],t,n)>=0?s:s+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},U_=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(t.lastMessage&&n.lastMessage){var a=n.lastMessage.createdAt-t.lastMessage.createdAt;return 0===a?n.createdAt-t.createdAt:a}return 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 i=t.name.localeCompare(n.name);return 0===i?t.createdAt-n.createdAt:i;default:return 0}},D_=function(){return i((function t(n,a){var i=this,s=a.filter,o=void 0===s?new ap:s,u=a.order,c=void 0===u?e.GroupChannelListOrder.LATEST_LAST_MESSAGE:u,l=a.limit,h=void 0===l?100:l,f=a.includeChangesOnInitialLoad,p=void 0!==f&&f;r(this,t),this.channels=[],this._isInitialized=!1,this._iid=n,this._key="gcc-".concat(ce()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=o,this.order=c,this._hasMore=!0,this._token="",this._limit=h;var v=ss.of(this._iid),_=v.sdkState,m=v.cacheContext,g=v.dispatcher;m.localCacheEnabled&&(this._backgroundSync=T_.of(n),this._backgroundSync.resume()),this._changelogSync=N_.of(n),this._changelogSync.resume(),Iv.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(bp(n)){var r=e.filter((function(e){return i.filter.match(e,_.userId)})),a=e.filter((function(e){return!i.filter.match(e,_.userId)})).map((function(e){return e.url}));r.length>0&&i._addChannelsToView(r,t),a.length>0&&i._removeChannelsFromView(a,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),g.on((function(e){e instanceof Ha&&(e.stateType===Da.CONNECTED?i._isGetRemoteChannelsSucceeded||E(i,void 0,void 0,d().mark((function e(){return d().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===Da.LOGOUT&&i.dispose())}))}),[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(t,n){var r,a=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=s(t);try{for(l.s();!(r=l.n()).done;){var h=r.value,f=M_(this.channels,h);f>=0&&this.channels.splice(f,1);var p=O_(this.channels,h,this.order).place;if(f<0)p===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(p,0,h));else switch(n.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&p===this.channels.length?c.push(h):(this.channels.splice(p,0,h),u.push(h));break;default:this.channels.splice(p,0,h),u.push(h)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var v,_=s(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=M_(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}bp(n.source)&&_i((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsAdded)&&this._handler.onChannelsAdded(n,o),u.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,u),c.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,c.map((function(e){return e.url})));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,t){var n,r=this,a=[],i=s(e);try{var o=function(){var e=n.value,t=r.channels.findIndex((function(t){return t.url===e}));t>=0&&(a.push(r.channels[t].url),r.channels.splice(t,1))};for(i.s();!(n=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return bp(t.source)&&a.length>0&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(t,a);case 1:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_getLocalChannels",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Iv.of(this._iid),n=this.channels.length>0?A_(this.channels[this.channels.length-1],this.order):null,e.next=4,t.getChannelsFromCache(n,this.filter,this.order,this._limit,n?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,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Iv.of(this._iid),e.next=3,t.getMyGroupChannels(this._token,ve(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);case 3:return n=e.sent,r=n.channels,a=n.token,this._token=a,this._hasMore=!!a,e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:n=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(n,{source:e.CollectionEventSource.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()}}),t,this,[[2,10]])})))}},{key:"loadMore",value:function(){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(r=null,!this._includeChangesOnInitialLoad||0!==this.channels.length){n.next=9;break}if(!this._changelogSync.isRunning){n.next=9;break}return n.next=7,new Promise((function(e){C._changelogSyncSubscriberContext=C._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}));case 7:r=n.sent,null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close();case 9:if(a=ss.of(this._iid),i=a.cacheContext,o=a.connectionManager,u=a.statManager,this._isInitialized){n.next=16;break}if(this._isInitialized=!0,!i.localCacheEnabled){n.next=15;break}return n.next=15,this._backgroundSync.loadMetadata();case 15:u.put(new Yi({type:je.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}}));case 16:if(c=[],!this._hasMore){n.next=35;break}if(!i.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed){n.next=24;break}return n.next=21,mi((function(){return E(C,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:c=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 21:this._hasMore=c.length>=this._limit,n.next=34;break;case 24:return n.prev=24,n.next=27,this._getRemoteChannels();case 27:c=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=34;break;case 31:n.prev=31,n.t0=n.catch(24),this._isGetRemoteChannelsSucceeded=!1;case 34:this._addChannelsToView(c,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0);case 35:if(r){l=s(r.updatedChannels);try{for(l.s();!(h=l.n()).done;)f=h.value,(p=M_(c,f))>=0?c[p]=f:(v=O_(c,f,this.order),_=v.place,c.splice(_,0,f))}catch(e){l.e(e)}finally{l.f()}m=c.map((function(e){return e.url})),g=s(r.deletedChannelUrls);try{for(g.s();!(y=g.n()).done;)k=y.value,(b=m.indexOf(k))>=0&&(c.splice(b,1),m.splice(b,1))}catch(e){g.e(e)}finally{g.f()}}return n.abrupt("return",c);case 37:case"end":return n.stop()}}),n,this,[[24,31]])})))}},{key:"dispose",value:function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),Iv.of(this._iid).unsubscribeChannelEvent(this._key))}}])}(),R_=function(t){function a(t){var i;r(this,a);var s=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,d=t.channelNameContainsFilter,h=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,E=t.includeFrozen,k=t.includeMetaData;return(i=n(this,a)).method=_e.GET,i.path=ke,i.params=pe(ve({token:s,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:d,channel_urls:h,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:E,show_metadata:k})),i}return c(a,t),i(a)}(Ve),L_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new x_(e,t)}))),i.ts="number"==typeof u?u:0,i}return c(t,e),i(t)}(ze);e.MembershipFilter=void 0,(w_=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",w_.JOINED="joined";var P_,F_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;return r(this,a),(s=n(this,a,[t,i])).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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=i.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(d=i.customTypesFilter)&&void 0!==d?d:null,s.customTypeStartsWithFilter=null!==(h=i.customTypeStartsWithFilter)&&void 0!==h?h:null,s.channelNameContainsFilter=null!==(f=i.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=i.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=i.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=i.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=i.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=i.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=i.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(E=i.order)&&void 0!==E?E:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter,!0)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter,!0)&&R(e.MembershipFilter,this.membershipFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicGroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=ss.of(this._iid),r=n.requestQueue,a=new R_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(L_),o=s.channels,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(pu),q_=i((function e(){r(this,e),this.onUserMuted=ft,this.onUserUnmuted=ft,this.onUserBanned=ft,this.onUserUnbanned=ft,this.onChannelChanged=ft,this.onChannelDeleted=ft,this.onChannelFrozen=ft,this.onChannelUnfrozen=ft,this.onOperatorUpdated=ft,this.onChannelMemberCountChanged=ft,this.onMetaDataCreated=ft,this.onMetaDataUpdated=ft,this.onMetaDataDeleted=ft,this.onMetaCounterCreated=ft,this.onMetaCounterUpdated=ft,this.onMetaCounterDeleted=ft,this.onMessageReceived=ft,this.onMessageUpdated=ft,this.onMessageDeleted=ft,this.onMentionReceived=ft,this.onReactionUpdated=ft,this.onThreadInfoUpdated=ft})),H_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserJoined=ft,e.onUserLeft=ft,e.onUserReceivedInvitation=ft,e.onUserDeclinedInvitation=ft,e.onChannelHidden=ft,e.onUnreadMemberStatusUpdated=ft,e.onUndeliveredMemberStatusUpdated=ft,e.onTypingStatusUpdated=ft,e.onPollUpdated=ft,e.onPollVoted=ft,e.onPollDeleted=ft,e.onPinnedMessageUpdated=ft,e}return c(t,e),i(t)}(q_),G_=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(H_),j_=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,d=e.scheduledStatus;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ae),a.params=pe(ve({token:i,limit:s,reverse:u,channel_url:c,order:o,message_type:l,status:d})),a}return c(t,e),i(t)}(Ve),V_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).scheduledMessages=[];var s=a.next,o=a.scheduled_messages;return i.token=s,i.scheduledMessages=o.map((function(t){return go(e,t)})),i}return c(t,e),i(t)}(ze),z_=function(t){function a(t,i){var s,o,u,c,l,d;return r(this,a),(s=n(this,a,[t,i])).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(o=i.channelUrl)&&void 0!==o?o:null,s.order=null!==(u=i.order)&&void 0!==u?u:null,s.reverse=null!==(c=i.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=i.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(d=i.messageTypeFilter)&&void 0!==d?d:e.MessageTypeFilter.ALL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl,!0)&&(R(e.ScheduledMessageListOrder,this.order)||null===this.order)&&D("boolean",this.reverse)&&(P(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&R(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new j_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(V_),s=i.scheduledMessages,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),B_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="groupChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new Iv(e,{sdkState:r,cacheContext:c,dispatcher:a,sessionManager:i,requestQueue:s,logger:o})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new D_(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new vv(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new F_(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new z_(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){ui(D("string",e)&&t instanceof G_).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){ui(D("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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},lp),t),ui(D("string",e)&&dp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},lp),t),ui(D("number",e)&&dp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},hp),e),ui(fp(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},up),e),ui(cp(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.createChannel(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},up),e),ui(cp(n)).throw(A.invalidParameters),n&&(n.isDistinct=!0),t.abrupt("return",this.createChannel(n));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithUserIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=Object.assign(Object.assign({},up),{invitedUserIds:e,isDistinct:t,name:n,data:a,customType:i}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,s.abrupt("return",this.createChannel(o));case 3:case"end":return s.stop()}}),s,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:ui(P("string",e)).throw(A.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.next=3,this.getChannel(e);case 3:return n=t.sent,t.next=6,n.markAsDelivered();case 6:case"end":return t.stop()}}),t,this)})))}}])}(os),Q_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return c(t,e),i(t,[{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,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0: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)})),t.abrupt("return",n);case 3:case"end":return t.stop()}}),t)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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),K_={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},W_=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&(D("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&D("boolean",e.isEphemeral,!0)},Y_=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?we:Ce,"/").concat(encodeURIComponent(i)),a.params={show_pinned_messages:!0},a}return c(t,e),i(t)}(Ve),Z_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new hm(e,a),i}return c(t,e),i(t)}(ze),X_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,d=e.isEphemeral;return(a=n(this,t)).method=_e.POST,a.path=Ce,a.params=pe(ve({channel_url:i,cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:d})),a}return c(t,e),i(t)}(Ve),J_=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"ENTR",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(We),$_=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new li(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(Kp),em=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"EXIT",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(We),tm=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"EXIT",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new li(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(Kp),nm={},rm=function(t){function a(t,i){var o;return r(this,a),(o=n(this,a,[t,Object.assign(Object.assign({},i),{channelType:e.ChannelType.OPEN})])).subscribeChannelEvent=ft,o.unsubscribeChannelEvent=ft,o.refreshChannel=function(){return E(o,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}}),e)})))},o._openChannelCache=new Q_(t),o._openChannelHandlers=new Map,o._dispatcher.on((function(e){if(e instanceof Ke)o._handleEvent(e).catch((function(e){if(N(e)&&"foreground"===o._sdkState.appState)throw e}));else if(e instanceof Ha&&e.stateType===Da.CONNECTED){var t,n=s(o._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),nm[t]||(nm[t]=o),o}return c(a,t),i(a,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=oi(e);return new hm(this._iid,hm.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._openChannelCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((r=n.n()).done){t.next=9;break}return a=r.value,t.next=7,this._openChannelCache.remove(a);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),n.e(t.t0);case 14:return t.prev=14,n.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"handlers",get:function(){return v(this._openChannelHandlers.values())}},{key:"_handleEvent",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,A,M,O,U,D,R,L,P,F,q,H,G,j,V,z,B,Q,K,W,Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue,ce,le,de,he,fe,pe,ve,_e,me,ge,ye,Ee,ke,be,Ce,we,xe,Se,Te,Ie,Ne,Ae,Me,Oe,Ue,De,Re,Le,Pe,Fe,qe,He,Ge,je=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,n.t0=t.code,n.next="MESG"===n.t0||"FILE"===n.t0||"ADMM"===n.t0||"BRDM"===n.t0?4:"MEDI"===n.t0||"FEDI"===n.t0||"AEDI"===n.t0?14:"DELM"===n.t0?26:"MRCT"===n.t0?33:"MTHD"===n.t0?40:"MCNT"===n.t0?47:"PEDI"===n.t0?75:"VOTE"===n.t0?83:"SYEV"===n.t0?91:174;break;case 4:if(r=null,"MESG"===t.code?r=t.as(lc):"FILE"===t.code?r=t.as(Co):"ADMM"!==t.code&&"BRDM"!=t.code||(r=t.as(gv)),!r){n.next=13;break}if(i=(a=r).message,o=a.isMentioned,i.channelType!==e.ChannelType.OPEN){n.next=13;break}return n.next=11,this.getChannel(i.channelUrl,!0);case 11:u=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(u.url)&&(r.onMessageReceived&&r.onMessageReceived(u,i),o&&r.onMentionReceived&&r.onMentionReceived(u,i))}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return n.abrupt("break",174);case 14:if(c=null,"MEDI"===t.code?c=t.as(hc):"FEDI"===t.code?c=t.as(pc):"AEDI"===t.code&&(c=t.as(yv)),!c){n.next=25;break}if(h=(l=c).message,f=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){n.next=25;break}return n.next=21,this.getChannel(h.channelUrl,!0);case 21:p=n.sent,v=!1,p.lastPinnedMessage&&p.lastPinnedMessage.messageId===h.messageId&&p.lastPinnedMessage.updatedAt0&&i.onMentionReceived&&i.onMentionReceived(p,h))}catch(e){r.e(e)}finally{r.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 25:return n.abrupt("break",174);case 26:if(_=t.as(dt),m=_.channelUrl,g=_.channelType,y=_.messageId,g!==e.ChannelType.OPEN){n.next=32;break}return n.next=30,this.getChannel(m,!0);case 30:k=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(k.url)&&r.onMessageDeleted&&r.onMessageDeleted(k,y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 32:return n.abrupt("break",174);case 33:if(b=t.as(bv),C=b.channelUrl,w=b.channelType,x=b.event,w!==e.ChannelType.OPEN){n.next=39;break}return n.next=37,this.getChannel(C,!0);case 37:S=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(S.url)&&r.onReactionUpdated&&r.onReactionUpdated(S,x)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 39:return n.abrupt("break",174);case 40:if(T=t.as(Cv),(I=T.event).channelType!==e.ChannelType.OPEN){n.next=46;break}return n.next=44,this.getChannel(I.channelUrl,!0);case 44:A=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(A.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(A,I)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 46:return n.abrupt("break",174);case 47:M=t.as(wv),O=M.openChannelMemberCounts,U=[],D=s(O),n.prev=50,D.s();case 52:if((R=D.n()).done){n.next=61;break}return L=R.value,P=L.channelUrl,F=L.participantCount,q=L.updatedAt,n.next=57,this.getChannelFromCache(P);case 57:(H=n.sent)&&H._updateParticipantCount(F,q)&&U.push(H);case 59:n.next=52;break;case 61:n.next=66;break;case 63:n.prev=63,n.t1=n.catch(50),D.e(n.t1);case 66:return n.prev=66,D.f(),n.finish(66);case 69:if(!(U.length>0)){n.next=74;break}return n.next=72,this.upsertChannelsToCache(U);case 72:G=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(G)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 74:return n.abrupt("break",174);case 75:if(j=t.as(xv),V=j.event,z=j.status,B=j.channelUrl,Q=j.channelType,!B||Q!==e.ChannelType.OPEN){n.next=82;break}return n.next=79,this.getChannel(B,!0);case 79:K=n.sent,this._dispatcher.dispatch(new zs({event:V,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),_i(z===oo?function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(K,V.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(K,V)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 82:return n.abrupt("break",174);case 83:if(W=t.as(Fc),Y=W.event,Z=W.channelUrl,X=W.channelType,!Z||X!==e.ChannelType.OPEN){n.next=90;break}return n.next=87,this.getChannel(Z,!0);case 87:J=n.sent,this._dispatcher.dispatch(new Bs({event:Y,source:e.CollectionEventSource.EVENT_POLL_VOTED})),_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(J,Y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 90:return n.abrupt("break",174);case 91:if($=t.as(Kp),!(ee=$.event).isOpenChannelEvent){n.next=173;break}n.t2=ee.category,n.next=n.t2===rp.CHANNEL_ENTER?96:n.t2===rp.CHANNEL_EXIT?103:n.t2===rp.CHANNEL_OPERATOR_UPDATE?110:n.t2===rp.USER_CHANNEL_MUTE||n.t2===rp.USER_CHANNEL_UNMUTE?118:n.t2===rp.USER_CHANNEL_BAN||n.t2===rp.USER_CHANNEL_UNBAN?125:n.t2===rp.CHANNEL_FREEZE||n.t2===rp.CHANNEL_UNFREEZE?132:n.t2===rp.CHANNEL_DELETED?140:n.t2===rp.CHANNEL_PROP_CHANGED?147:n.t2===rp.CHANNEL_META_DATA_CHANGED?152:n.t2===rp.CHANNEL_META_COUNTERS_CHANGED?161:n.t2===rp.PINNED_MESSAGE_CHANGED?167:173;break;case 96:return n.next=98,this.getChannel(ee.channelUrl,!0);case 98:return te=n.sent,ne=t.as($_),re=ne.participantCount,ae=ne.user,ie=te._updateParticipantCount(re,ee.ts),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(te,ae),ie&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(te)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 103:return n.next=105,this.getChannel(ee.channelUrl,!0);case 105:return se=n.sent,oe=t.as(tm),ue=oe.participantCount,ce=oe.user,le=se._updateParticipantCount(ue,ee.ts),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(se,ce),le&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 110:return n.next=112,this.getChannel(ee.channelUrl,!0);case 112:return de=n.sent,he=t.as(fv),fe=he.operators,de.operators=fe,this.upsertChannelsToCache([de]),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(de,fe)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 118:return n.next=120,this.getChannel(ee.channelUrl,!0);case 120:return pe=n.sent,ve=ee.category===rp.USER_CHANNEL_MUTE,_e=t.as(ve?Xu:$u),me=_e.user,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ve?e.onUserMuted&&e.onUserMuted(pe,me):e.onUserUnmuted&&e.onUserUnmuted(pe,me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 125:return n.next=127,this.getChannel(ee.channelUrl,!0);case 127:return ge=n.sent,ye=ee.category===rp.USER_CHANNEL_BAN,Ee=t.as(ye?tc:rc),ke=Ee.user,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ye?e.onUserBanned&&e.onUserBanned(ge,ke):e.onUserUnbanned&&e.onUserUnbanned(ge,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 132:return n.next=134,this.getChannel(ee.channelUrl,!0);case 134:return be=n.sent,Ce=t.as(ic),we=Ce.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().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)})))})),n.abrupt("break",173);case 140:return n.next=142,this.getChannel(ee.channelUrl,!0);case 142:return xe=n.sent,n.next=145,this.removeChannelsFromCache([xe.url]);case 145:return _i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(xe.url,xe.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 147:return n.next=149,this.getChannelWithoutCache(ee.channelUrl,!0);case 149:return Se=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 152:return n.next=154,this.getChannel(ee.channelUrl,!0);case 154:return Te=n.sent,Ie=t.as(Lu),Ne=Ie.created,Ae=Ie.updated,Me=Ie.deleted,Ne&&Te._upsertCachedMetaData(Ne,ee.ts),Ae&&Te._upsertCachedMetaData(Ae,ee.ts),Me&&Te._removeFromCachedMetaData(Me,ee.ts),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ne&&e.onMetaDataCreated&&e.onMetaDataCreated(Te,Ne),Ae&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Te,Ae),Me&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Te,Me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 161:return n.next=163,this.getChannel(ee.channelUrl,!0);case 163:return Oe=n.sent,Ue=t.as(Ku),De=Ue.created,Re=Ue.updated,Le=Ue.deleted,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){De&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Oe,De),Re&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Oe,Re),Le&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Oe,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 167:return n.next=169,this.getChannel(ee.channelUrl,!0);case 169:return Pe=n.sent,Fe=t.as(_v),qe=Fe.pinnedMessageIds,He=Fe.latestPinnedMessage,(Ge=Fe.ts)>Pe._pinnedMessagesUpdatedAt&&(Pe.pinnedMessageIds=qe,Pe.lastPinnedMessage=He,Pe._pinnedMessagesUpdatedAt=Ge,this.upsertChannelsToCache([Pe]),_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Pe)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(Pe)}));case 1:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",173);case 173:return n.abrupt("break",174);case 174:n.next=180;break;case 176:if(n.prev=176,n.t3=n.catch(0),!N(n.t3)){n.next=180;break}throw n.t3;case 180:case"end":return n.stop()}}),n,this,[[0,176],[50,63,66,69]])})))}},{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){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),r=new Y_({channelUrl:e,isInternalCall:t}),n.next=4,this._requestQueue.send(r);case 4:return a=n.sent,i=a.as(Z_),s=i.channel,n.next=8,this.upsertChannelsToCache([s]);case 8:return n.abrupt("return",n.sent[0]);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},K_),e),ui(W_(n)).throw(A.invalidParameters),r=new X_(n),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Z_),s=i.channel,this.upsertChannelsToCache([s]),t.abrupt("return",s);case 9:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return nm[e]}}])}(mv),am={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},im=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)},sm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ce,"/").concat(encodeURIComponent(i),"/participants"),a.params={token:s,limit:o},a}return c(t,e),i(t)}(Ve),om=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).participants=[];var s=a.next,o=a.participants;return i.token=s,i.participants=o.map((function(t){return new zo(e,t)})),i}return c(t,e),i(t)}(ze),um=function(t){function a(t,i,s){return r(this,a),n(this,a,[t,i,e.ChannelType.OPEN,s])}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new sm(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(om),s=i.participants,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),cm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a.params=pe(ve({cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l})),a}return c(t,e),i(t)}(Ve),lm=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new hm(e,a),i}return c(t,e),i(t)}(ze),dm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(Ve),hm=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i]))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(o=i.participant_count)&&void 0!==o?o:0,s.operators=Array.isArray(i.operators)?i.operators.map((function(e){return new li(t,e)})):[],s.lastPinnedMessage=i.latest_pinned_message?go(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,s}return c(a,t),i(a,[{key:"serialize",value:function(){return si(this)}},{key:"isOperator",value:function(e){return e instanceof li?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 um(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=rm.of(this._iid),e.next=3,t.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new J_({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as($_),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),rm.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,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new em({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(tm),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),rm.of(this._iid).setExitedToCache(this),oh.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,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},am),e),ui(im(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new cm(Object.assign({channelUrl:this.url},n)),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(lm),u=o.channel,this._update(u),c=rm.of(this._iid),t.next=12,c.upsertChannelsToCache([u]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=Object.assign(Object.assign({},am),{name:e,coverUrlOrImage:t,data:n,operatorUserIds:r,customType:a}),i.abrupt("return",this.updateChannel(s));case 2:case"end":return i.stop()}}),i,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new dm({channelUrl:this.url}),e.next=4,n.send(r);case 4:return a=rm.of(this._iid),e.next=7,a.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"updateUserMessage",value:function(e,t){var n=this,r=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateUserMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&rm.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&rm.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFileMessage",value:function(e,t){var n=this,r=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateFileMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&rm.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&rm.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},kl.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return li.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?mo(e.lastPinnedMessage):null})))}}])}(kl),fm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserEntered=ft,e.onUserExited=ft,e.onChannelParticipantCountChanged=ft,e.onPollUpdated=ft,e.onPollVoted=ft,e.onPollDeleted=ft,e.onPinnedMessageUpdated=ft,e}return c(t,e),i(t)}(q_),pm=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(fm),vm=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,d=e.includeMetaData;return(a=n(this,t)).method=_e.GET,a.path=Ce,a.params=pe({token:i,limit:s,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:d,show_pinned_messages:!0}),a}return c(t,e),i(t)}(Ve),_m=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return new hm(e,t)}))),i.ts="number"==typeof u?u:null,i}return c(t,e),i(t)}(ze),mm=function(e){function t(e,a){var i,s,o,u,c,l;return r(this,t),(i=n(this,t,[e,a])).includeFrozen=!0,i.includeMetaData=!0,i.nameKeyword=null,i.urlKeyword=null,i.customTypes=null,i.includeFrozen=null===(s=a.includeFrozen)||void 0===s||s,i.includeMetaData=null===(o=a.includeMetaData)||void 0===o||o,i.nameKeyword=null!==(u=a.nameKeyword)&&void 0!==u?u:null,i.urlKeyword=null!==(c=a.urlKeyword)&&void 0!==c?c:null,i.customTypes=null!==(l=a.customTypes)&&void 0!==l?l:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.nameKeyword,!0)&&D("string",this.urlKeyword,!0)&&P("string",this.customTypes,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new vm(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(_m),s=i.channels,o=i.token,this._token=o,this._hasNext=!!o,u=rm.of(this._iid),e.next=15,u.upsertChannelsToCache(s);case 15:return this._isLoading=!1,e.abrupt("return",s);case 17:return e.abrupt("return",[]);case 20:throw A.queryInProgress;case 21:e.next=24;break;case 23:throw A.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}])}(pu),gm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="openChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new rm(e,{sdkState:r,dispatcher:a,requestQueue:s,logger:o,cacheContext:c,sessionManager:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new mm(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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return(s=Object.assign({},K_)).name=e,s.coverUrlOrImage=t,s.data=n,s.operatorUserIds=r,s.customType=a,i.abrupt("return",this._manager.createChannel(s));case 7:case"end":return i.stop()}}),i,this)})))}}])}(os),ym=Object.freeze({__proto__:null,xmlHttpRequest:function(e,t){return new Promise((function(n,r){if("undefined"!=typeof XMLHttpRequest){var a=ss.of(e),i=a.dispatcher,s=a.logger,o=t.requestId,u=t.method,c=t.url,l=t.headers,d=void 0===l?{}:l,h=t.data,f=void 0===h?"":h,p=t.uploadProgressHandler,v=!1,_=new XMLHttpRequest;_.open(u,c),Object.keys(d).forEach((function(e){_.setRequestHeader(e,d[e])})),p&&_.upload.addEventListener("progress",(function(e){e.lengthComputable?p(o,e.loaded,e.total):s.debug("Progress computing failed: `Content-Length` header is not given.")})),_.onabort=function(){r(A.requestCanceled)},_.onerror=function(e){r(A.networkError)},_.onreadystatechange=function(){if(_.readyState===XMLHttpRequest.DONE&&!v)if(0===_.status||_.status>=200&&_.status<400)try{var t=JSON.parse(_.responseText);n(new ze(e,t))}catch(s){r(A.networkError)}else try{var a=JSON.parse(_.responseText);if(a){var s=new A(a);if(s.isSessionExpiredError){if(i.dispatch(new Qe({reason:s.code,message:s.message})),!(_ instanceof Ye)){var o=new ut;return i.dispatch(new et({request:_,deferred:o,error:s})),o.promise}}else s.isSessionInvalidatedError&&i.dispatch(new Qe({reason:s.code,message:s.message}));r(s)}else r(A.requestFailed)}catch(s){r(A.requestFailed)}},i.on((function(e){e instanceof ct&&(e.requestId&&e.requestId!==o||(v=!0,_.abort()))})),_.send(f)}else r(A.xmlHttpRequestNotSupported)}))}});P_=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 Nm(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 Am(e){return"string"!=typeof e&&(e=String(e)),e}function Mm(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return Cm&&(t[Symbol.iterator]=function(){return t}),t}function Om(e){this.map={},e instanceof Om?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 Um(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function Dm(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Rm(e){var t=new FileReader,n=Dm(t);return t.readAsArrayBuffer(e),n}function Lm(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Pm(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:wm&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:xm&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:bm&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():Sm&&wm&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Lm(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Sm&&(ArrayBuffer.prototype.isPrototypeOf(e)||Im(e))?this._bodyArrayBuffer=Lm(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):bm&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},wm&&(this.blob=function(){var e=Um(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=Um(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(wm)return this.blob().then(Rm);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,n,r,a,i=Um(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Dm(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),a=r?r[1]:"utf-8",t.readAsText(e,a),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||function(){if("AbortController"in km)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 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 Hm(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 Gm(e,t){if(!(this instanceof Gm))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 Om(t.headers),this.url=t.url||"",this._initBody(e)}qm.prototype.clone=function(){return new qm(this,{body:this._bodyInit})},Pm.call(qm.prototype),Pm.call(Gm.prototype),Gm.prototype.clone=function(){return new Gm(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Om(this.headers),url:this.url})},Gm.error=function(){var e=new Gm(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var jm=[301,302,303,307,308];Gm.redirect=function(e,t){if(-1===jm.indexOf(t))throw new RangeError("Invalid status code");return new Gm(null,{status:t,headers:{location:e}})};var Vm=km.DOMException;try{new Vm}catch(On){(Vm=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),Vm.prototype.constructor=Vm}function zm(e,t){return new Promise((function(n,r){var a=new qm(e,t);if(a.signal&&a.signal.aborted)return r(new Vm("Aborted","AbortError"));var i=new XMLHttpRequest;function s(){i.abort()}if(i.onload=function(){var e,t,r={statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new Om,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();try{t.append(r,a)}catch(e){console.warn("Response "+e.message)}}})),t)};0===a.url.indexOf("file://")&&(i.status<200||i.status>599)?r.status=200:r.status=i.status,r.url="responseURL"in i?i.responseURL:r.headers.get("X-Request-URL");var s="response"in i?i.response:i.responseText;setTimeout((function(){n(new Gm(s,r))}),0)},i.onerror=function(){setTimeout((function(){r(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){r(new TypeError("Network request timed out"))}),0)},i.onabort=function(){setTimeout((function(){r(new Vm("Aborted","AbortError"))}),0)},i.open(a.method,function(e){try{return""===e&&km.location.href?km.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?i.withCredentials=!0:"omit"===a.credentials&&(i.withCredentials=!1),"responseType"in i&&(wm?i.responseType="blob":Sm&&(i.responseType="arraybuffer")),t&&"object"===m(t.headers)&&!(t.headers instanceof Om||km.Headers&&t.headers instanceof km.Headers)){var o=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){o.push(Nm(e)),i.setRequestHeader(e,Am(t.headers[e]))})),a.headers.forEach((function(e,t){-1===o.indexOf(t)&&i.setRequestHeader(t,e)}))}else a.headers.forEach((function(e,t){i.setRequestHeader(t,e)}));a.signal&&(a.signal.addEventListener("abort",s),i.onreadystatechange=function(){4===i.readyState&&a.signal.removeEventListener("abort",s)}),i.send(void 0===a._bodyInit?null:a._bodyInit)}))}zm.polyfill=!0,km.fetch||(km.fetch=zm,km.Headers=Om,km.Request=qm,km.Response=Gm);var Bm="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null};Bm.fetch||(Bm.fetch=zm);var Qm=Object.freeze({__proto__:null});e.AdminMessage=ao,e.AppInfo=Ja,e.AppleCriticalAlertOptions=ms,e.ApplicationUserListQuery=Al,e.BannedUserListQuery=xu,e.BaseChannel=kl,e.BaseMessage=eo,e.BlockedUserListQuery=Ul,e.CachedChannelInfo=K,e.ConnectionHandler=xl,e.DeliveryStatus=np,e.Emoji=bl,e.EmojiCategory=Cl,e.EmojiContainer=wl,e.Feedback=ys,e.FileMessage=yo,e.FriendListQuery=Ll,e.GroupChannel=x_,e.GroupChannelCollection=D_,e.GroupChannelEventSource=kp,e.GroupChannelFilter=ap,e.GroupChannelHandler=G_,e.GroupChannelListQuery=vv,e.GroupChannelModule=B_,e.LocalCacheConfig=W,e.Member=tp,e.MemberListQuery=e_,e.MemoryStore=Md,e.MessageCollection=Kv,e.MessageCollectionInitHandler=Bv,e.MessageEventSource=Ls,e.MessageFilter=jd,e.MessageForm=Zs,e.MessageFormItem=Xs,e.MessageMetaArray=ks,e.MessageModule=wh,e.MessageRequestHandler=Bo,e.MessageReviewInfo=fo,e.MessageSearchQuery=_h,e.MultipleFilesMessage=vo,e.MultipleFilesMessageRequestHandler=fl,e.MutedUserListQuery=bu,e.NotificationInfo=za,e.OGImage=vs,e.OGMetaData=_s,e.OpenChannel=hm,e.OpenChannelHandler=pm,e.OpenChannelListQuery=mm,e.OpenChannelModule=gm,e.OperatorListQuery=gu,e.Participant=zo,e.ParticipantListQuery=um,e.PinnedMessage=pl,e.PinnedMessageListQuery=ml,e.Plugin=io,e.PreviousMessageListQuery=yu,e.PublicGroupChannelListQuery=F_,e.Reaction=ps,e.ReactionEvent=fs,e.ReadStatus=ws,e.RestrictedUser=Vo,e.RestrictionInfo=jo,e.ScheduledMessageListQuery=z_,e.SendbirdChat=Qf,e.SendbirdChatOptions=j,e.SendbirdError=A,e.Sender=Es,e.SessionHandler=Sl,e.ThreadInfo=ds,e.ThreadInfoUpdateEvent=uh,e.ThreadedParentMessageListQuery=yh,e.Thumbnail=us,e.UIKitConfigInfo=Qa,e.UploadedFileInfo=Qs,e.User=li,e.UserEventHandler=Tl,e.UserMessage=po,Object.defineProperty(e,"__esModule",{value:!0})})); From 1d46cdc83a8964fc464fa47a0269e1d27d908790 Mon Sep 17 00:00:00 2001 From: sendbird-sdk-deployment Date: Thu, 24 Oct 2024 07:05:49 +0000 Subject: [PATCH 3/3] Release - 4.14.6 --- CHANGELOG.md | 4 ++++ cjs/feedChannel.cjs | 2 +- cjs/groupChannel.cjs | 2 +- cjs/index.cjs | 2 +- cjs/lib/{__bundle-947cb619.cjs => __bundle-0a504be4.cjs} | 2 +- cjs/lib/{__bundle-0486c467.cjs => __bundle-2d1d7d4f.cjs} | 4 ++-- cjs/lib/{__bundle-05f697db.cjs => __bundle-3d28c10f.cjs} | 2 +- cjs/lib/{__bundle-2e006691.cjs => __bundle-4455b70a.cjs} | 2 +- cjs/lib/{__bundle-12c1cdf9.cjs => __bundle-73351257.cjs} | 2 +- cjs/lib/__bundle-785dde28.cjs | 1 + cjs/lib/{__bundle-0fbd5934.cjs => __bundle-90430bee.cjs} | 2 +- cjs/lib/{__bundle-4bcf4070.cjs => __bundle-ccb8334d.cjs} | 2 +- cjs/lib/__bundle-d1419fd1.cjs | 1 - cjs/lib/{__bundle-0f6b8ff3.cjs => __bundle-f1e6fb74.cjs} | 2 +- cjs/lib/{__bundle-d349e14c.cjs => __bundle-fdee1c40.cjs} | 2 +- cjs/message.cjs | 2 +- cjs/openChannel.cjs | 2 +- cjs/poll.cjs | 2 +- feedChannel.js | 2 +- groupChannel.js | 2 +- index.js | 2 +- lib/{__bundle-c03282ec.js => __bundle-0ca331b6.js} | 2 +- lib/{__bundle-b5ef7de4.js => __bundle-3f550679.js} | 2 +- lib/__bundle-5f5bca4c.js | 1 - lib/{__bundle-1a7e946b.js => __bundle-735270df.js} | 2 +- lib/{__bundle-45809bc9.js => __bundle-af65b142.js} | 2 +- lib/{__bundle-5dbd9d35.js => __bundle-bfc18da1.js} | 2 +- lib/__bundle-dfeaa7a2.js | 1 + lib/{__bundle-03052043.js => __bundle-e06a35d9.js} | 2 +- lib/{__bundle-75f48c2c.js => __bundle-e4c89c6a.js} | 2 +- message.js | 2 +- openChannel.js | 2 +- package.json | 2 +- poll.js | 2 +- sendbird.min.js | 2 +- 35 files changed, 37 insertions(+), 33 deletions(-) rename cjs/lib/{__bundle-947cb619.cjs => __bundle-0a504be4.cjs} (91%) rename cjs/lib/{__bundle-0486c467.cjs => __bundle-2d1d7d4f.cjs} (67%) rename cjs/lib/{__bundle-05f697db.cjs => __bundle-3d28c10f.cjs} (65%) rename cjs/lib/{__bundle-2e006691.cjs => __bundle-4455b70a.cjs} (54%) rename cjs/lib/{__bundle-12c1cdf9.cjs => __bundle-73351257.cjs} (97%) create mode 100644 cjs/lib/__bundle-785dde28.cjs rename cjs/lib/{__bundle-0fbd5934.cjs => __bundle-90430bee.cjs} (99%) rename cjs/lib/{__bundle-4bcf4070.cjs => __bundle-ccb8334d.cjs} (99%) delete mode 100644 cjs/lib/__bundle-d1419fd1.cjs rename cjs/lib/{__bundle-0f6b8ff3.cjs => __bundle-f1e6fb74.cjs} (88%) rename cjs/lib/{__bundle-d349e14c.cjs => __bundle-fdee1c40.cjs} (89%) rename lib/{__bundle-c03282ec.js => __bundle-0ca331b6.js} (69%) rename lib/{__bundle-b5ef7de4.js => __bundle-3f550679.js} (95%) delete mode 100644 lib/__bundle-5f5bca4c.js rename lib/{__bundle-1a7e946b.js => __bundle-735270df.js} (97%) rename lib/{__bundle-45809bc9.js => __bundle-af65b142.js} (99%) rename lib/{__bundle-5dbd9d35.js => __bundle-bfc18da1.js} (97%) create mode 100644 lib/__bundle-dfeaa7a2.js rename lib/{__bundle-03052043.js => __bundle-e06a35d9.js} (99%) rename lib/{__bundle-75f48c2c.js => __bundle-e4c89c6a.js} (89%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12e1f23..2ce9d0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v4.14.6 (Oct 24, 2024) +### **Improvements** +- Fixed a bug where `expiring_session=true` regardless of whether `SessionHandler` is registered when `authToken` exists +- Fixed typo in `markPushNotificationAsClicked` logs ## v4.14.5 (Oct 14, 2024) ### **Improvements** - Added `message` property in `FileMessageCreateParams` diff --git a/cjs/feedChannel.cjs b/cjs/feedChannel.cjs index 20aab54..54bb42b 100644 --- a/cjs/feedChannel.cjs +++ b/cjs/feedChannel.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),t=require("./lib/__bundle-4bcf4070.cjs"),n=require("./lib/__bundle-0fbd5934.cjs"),s=require("./lib/__bundle-d1419fd1.cjs"),i=require("./lib/__bundle-0f6b8ff3.cjs"),a=require("./lib/__bundle-12c1cdf9.cjs");require("./lib/__bundle-d349e14c.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class o{constructor(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}static payloadify(t){return e.deundefined(e.undefineNullProps({id:t.id,name:t.name,is_default:t.isDefault}))}get customType(){return this.isDefault?"*":String(this.id)}}class r extends e.InstancedObject{constructor(e,{sdkState:t,cacheContext:n,channelManager:s}){super(e),this._channels=new Map,this._sdkState=t,this._cacheContext=n,this._channelManager=s}get collection(){const{nestdb:n}=this._cacheContext;return e.unless(!!n).throw(e.SendbirdError.databaseError),n.collection(t.NESTDB_FEEDCHANNEL_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 this._channelManager.buildFeedChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}get(t){return e.__awaiter(this,void 0,void 0,(function*(){if(this._channels.has(t))return this._channels.get(t);if(this.localCacheEnabled){const e=yield this.collection.getByKey(t);if(e)return this._channels.set(t,this._deserialize(e)),this._channels.get(t)}}))}fetch({token:n,limit:i=t.DEFAULT_FEED_LIMIT,backward:a=!1,order:o="latest_last_message",borderlineChannelUrl:r}){return e.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const e={where:e=>{if(n&&"latest_last_message"===o)if(!a&&e.lastMessageUpdatedAt>n||a&&e.lastMessageUpdatedAtthis._deserialize(e)));return l.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),l}return[]}))}upsert(t){return e.__awaiter(this,void 0,void 0,(function*(){const n=[];if(t.forEach((t=>{if(this._channels.has(t.url)){const s=this._channels.get(t.url),i=e.deundefined(t);Object.assign(s,i,{_iid:this._iid}),n.push(s)}else this._channels.set(t.url,t),n.push(t)})),this.localCacheEnabled){const e=[];for(let t=0;te.__awaiter(this,void 0,void 0,(function*(){if(s instanceof l){const{channels:e,context:i,isWebSocketEventComing:a}=s,o=e.filter((e=>e instanceof x)),r=yield t.upsert(o);yield Promise.all(o.map((e=>n.markAsReadByTimestamp(e.url,e.myLastRead)))),a||this._broadcastUpdateEvent(r,i)}else if(s instanceof d){const{channelUrls:i,context:a,isWebSocketEventComing:o}=s;yield t.remove(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of i)yield n.removeMessagesOfChannel(e)})))),o||this._broadcastRemoveEvent(i,a)}else s instanceof i.DatabaseOpenCommand&&(yield t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const n of this._observers.values())n.onUpdate&&n.onUpdate(e,t)}_broadcastRemoveEvent(e,t){for(const n of this._observers.values())n.onRemove&&n.onRemove(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const h=!1;class u extends e.APIRequestCommand{constructor(t){super();const{userId:n,token:s,limit:i,includeEmpty:a}=t;this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(n)}/my_group_channels`,this.params=e.deundefined({token:s,limit:i,show_empty:null!=a?a:h,show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0,is_feed_channel:!0,order:"latest_last_message"})}}class _ extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:n,channels:s,ts:i}=t;this.token=n,this.ts=null!=i?i:0,this.channels=(null!=s?s:[]).map((t=>(t.ts=i,new x(e,t))))}}class g extends e.APIRequestCommand{constructor({channelUrl:t,isInternalCall:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${n?e.API_PATH_GROUP_CHANNELS_INTERNAL:e.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,is_feed_channel:!0}}}class f extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new x(e,t)}}const C={includeEmpty:!0},m=t=>e.isTypeOf("boolean",t.includeEmpty);class p extends e.APIRequestCommand{constructor({userId:t,ts:n,token:s,params:i}){super();const{includeEmpty:a}=Object.assign(Object.assign({},C),i);this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels/changelogs`,this.params=e.deundefined(e.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,is_feed_channel:!0,show_empty:a,change_ts:n||null,token:s}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((t=>new x(e,t))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next}}class E extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/settings`}}class y extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}const b=20;class M extends e.APIRequestCommand{constructor(t){const{reverse:n=!1,keys:s,limit:i=b,token:a}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates`,this.params=e.deundefined({token:a,keys:s,limit:i,reverse:n,order:"updated_at",show_ui_template:!0,show_color_variables:!0})}}class w extends e.APIResponseCommand{constructor(t,n){super(t,n);const{next:s,has_more:i=!1}=n,a=e.__rest(n,["next","has_more"]);this.nextToken=s,this.hasMore=i,this.notificationTemplateList={jsonString:JSON.stringify(a)}}}const T={reverse:!1,keys:void 0,limit:20};class S extends e.APIRequestCommand{constructor(t){const{key:n}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates/${n}`,this.params=e.deundefined({key:n})}}class I extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}class N extends e.WebSocketEventCommand{constructor(n,s,i){var a,o,r;super(n,"ADMM",i),this.message=new t.NotificationMessage(n,i);const{sdkState:l}=e.Vault.of(n);this.isMentioned=e.checkIfMentioned(this.message.mentionType,null!==(r=null!==(a=this.message.mentionedUserIds)&&void 0!==a?a:null===(o=this.message.mentionedUsers)||void 0===o?void 0:o.map((e=>e.userId)))&&void 0!==r?r:[],l.userId)}}class A extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS_USERS}/${encodeURIComponent(t)}/unread_message_count`}}const O={};class k extends a.BaseChannelManager{get _notificationMessageCache(){return t.NotificationMessageCache.of(this._iid)}constructor(n,s){super(n,Object.assign(Object.assign({},s),{channelType:e.ChannelType.FEED})),this._feedChannelHandlers=new Map,this._feedChannelCache=new r(this._iid,{sdkState:this._sdkState,cacheContext:this._cacheContext,channelManager:this}),this._feedChannelBroadcast=new c({feedChannelCache:this._feedChannelCache,dispatcher:this._dispatcher,notificationMessageCache:t.NotificationMessageCache.of(n)}),this._dispatcher.on((t=>{t instanceof e.WebSocketEventCommand&&this._handleEvent(t).catch((t=>{if(e.isThrowingOutside(t))throw t}))})),O[n]||(O[n]=this)}static of(t){return O[t]||(O[t]=new k(t,e.Vault.of(t))),O[t]}static clear(e){O[e]&&delete O[e]}get handlers(){return[...this._feedChannelHandlers.values()]}buildFeedChannelFromSerializedData(t){const n=e.deserialize(t);return new x(this._iid,x.payloadify(n))}addHandler(e,t){this._feedChannelHandlers.set(e,t)}removeHandler(e){this._feedChannelHandlers.delete(e)}clearHandler(){this._feedChannelHandlers.clear()}getMyFeedChannels(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){const e=new u(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:s})),i=yield this._requestQueue.send(e),{channels:a,token:o}=i.as(_);return{channels:a,token:o}}))}getChannel(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(t);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(t,n)}))}getChannelFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),null!==(n=yield this._feedChannelCache.get(t))&&void 0!==n?n:null}))}getChannelWithoutCache(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const s=new g({channelUrl:t,isInternalCall:n}),i=yield this._requestQueue.send(s),{channel:a}=i.as(f),[o]=yield this.upsertChannelsToCache([a]);return o}))}getMyFeedChannelChangeLogs(t,n,s=e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},C),n);e.unless((e.isTypeOf("string",t)||e.isTypeOf("number",t))&&m(i)).throw(e.SendbirdError.invalidParameters);const a=new p(e.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,params:i})),o=yield this._requestQueue.send(a),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}=o.as(v);return r.length>0&&this._dispatcher.dispatch(new l({channels:r,context:{source:s}})),c.length>0&&this._dispatcher.dispatch(new d({channelUrls:c,context:{source:s}})),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}}))}getTotalUnreadMessageCount(t){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},n.TotalUnreadMessageCountParamsDefault),t);e.unless(n.validateTotalUnreadMessageCountParams(s)).throw(e.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:a}=e.Vault.of(this._iid),o=new n.GetTotalUnreadMessageCountRequestCommand({userId:i.userId,filter:s,includeFeedChannel:!0}),r=yield a.send(o),{unreadFeedCount:l=0}=r.as(n.GetTotalUnreadMessageCountResponseCommand);return l}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),i=new A({userId:t.userId}),a=yield s.send(i),{unreadFeedCount:o=0}=a.as(n.GetTotalUnreadMessageCountResponseCommand);return o}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){const e=new E,t=yield this._requestQueue.send(e),{jsonString:n}=t.as(y);return{jsonString:n}}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},T),n);e.unless(e.isTypeOf("string",t)&&(t=>e.isTypeOf("boolean",t.reverse,!0)&&e.isArrayOf("string",t.keys,!0)&&e.isTypeOf("number",t.limit,!0))(s)).throw(e.SendbirdError.invalidParameters);const i=new M({token:t,keys:s.keys,reverse:s.reverse,limit:s.limit}),a=yield this._requestQueue.send(i),{hasMore:o,nextToken:r,notificationTemplateList:l}=a.as(w);return{hasMore:o,token:r,notificationTemplateList:l}}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=new S({key:t}),s=yield this._requestQueue.send(n),{jsonString:i}=s.as(I);return{jsonString:i}}))}upsertChannelsToCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._feedChannelCache.upsert(t)}))}removeChannelsFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this._feedChannelCache.remove(t)}))}getNotificationMessageFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.get(t)}))}refreshChannel(t,s=!0,i=e.CollectionEventSource.REFRESH_CHANNEL){return e.__awaiter(this,void 0,void 0,(function*(){try{const e=new g({channelUrl:t,isInternalCall:s}),a=yield this._requestQueue.send(e),{channel:o}=a.as(f);if(o.myMemberState===n.MemberState.NONE)this._dispatcher.dispatch(new d({channelUrls:[o.url],context:{source:i}}));else{const e=yield this.upsertChannelsToCache([o]);this._dispatcher.dispatch(new l({channels:e,context:{source:i}}))}}catch(n){n.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&n.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new d({channelUrls:[t],context:{source:i}}))}}))}refreshNotificationCollections(){this._dispatcher.dispatch(new s.NotificationCollectionRefreshCommand)}subscribeChannelEvent(e,t){this._feedChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._feedChannelBroadcast.unsubscribe(e)}_handleEvent(n){return e.__awaiter(this,void 0,void 0,(function*(){switch(n.code){case"ADMM":case"BRDM":{const s="ADMM"===n.code||"BRDM"===n.code?n.as(N):null;if(s&&s.message.channelType===this._channelType){const{message:n,isMentioned:i}=s,a=yield this.getChannel(n.channelUrl,!0);a._runIfHandleableWithGroupChannel((s=>{var o;n instanceof t.NotificationMessage&&i&&(null===(o=n.mentionedUsers)||void 0===o||o.forEach((e=>{for(const t of s.members)if(e.userId===t.userId){e.nickname=t.nickname,e.plainProfileUrl=t.plainProfileUrl,e.metaData=t.metaData;break}}))),this._dispatcher.dispatch(new l({channels:[a],context:{source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),this._dispatcher.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageReceived&&e.onMessageReceived(a,n),i&&e.onMentionReceived&&e.onMentionReceived(a,n)}))))}))}break}case"READ":{const s="READ"===n.code?n.as(t.ReadEventCommand):null;if(s&&s.readStatus.channelType===this._channelType){const{readStatus:t}=s,n=this._feedChannelCache.isCachedInMemory(t.channelUrl),i=yield this.getChannel(t.channelUrl,!0);i._runIfHandleableWithGroupChannel((s=>{n&&s._updateUnreadMemberState(t.reader.userId,t.readAt),t.reader.userId===this._sdkState.userId&&(n?(s.unreadMessageCount>0||s.unreadMentionCount>0)&&(s._updateUnreadCount(0,0),this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))):0!==s.unreadMessageCount&&0!==s.unreadMentionCount||(this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))))}))}break}case"SYEV":{const t="SYEV"===n.code?n.as(a.ChannelEventCommand):null;if(t&&t.event.channelType===this._channelType){const{event:n}=t;switch(n.category){case a.ChannelEventCategory.CHANNEL_DELETED:{const t=yield this.getChannel(n.channelUrl,!0);this._dispatcher.dispatch(new d({channelUrls:[n.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(t.url,t.channelType)}))}))));break}case a.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const t=yield this.getChannelWithoutCache(n.channelUrl,!0);this._dispatcher.dispatch(new l({channels:[t],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(t)}))}))));break}}}break}}}))}getMessageFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(n=yield this._notificationMessageCache.get(t))&&void 0!==n?n:null}))}getExactlyMatchingMessagesForTokenFromCache(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:t,token:n,filter:s,exactMatch:!0})}))}getMessagesFromCache(n,s,i,a,o=t.DEFAULT_NOTIFICATION_LIMIT,r=!0){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:n,token:s,limit:o,filter:a,backward:"next"===i,inclusive:r})}))}}class R extends n.BaseMessageCollection{keyOf(e){return e.notificationId}get changelogIncludeParams(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}constructor(t,n){super(t,Object.assign(Object.assign({},n),{channelManager:k.of(t)}));const{connectionManager:i,dispatcher:a}=e.Vault.of(this._iid);this._notificationCollectionEventContext=a.on((t=>{t instanceof s.NotificationCollectionRefreshCommand&&e.sleep(10).then((()=>{i.isConnected||i.isConnecting||this.refresh()}))}))}dispose(){super.dispose(),this._notificationCollectionEventContext.close()}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_postprocessChannelUpdateEvent(e,n){const s=this._messages.filter((n=>n.messageStatus===t.NotificationMessageStatus.SENT&&n.createdAt<=e.myLastRead));if(s.length>0){for(const e of s)e.messageStatus=t.NotificationMessageStatus.READ;this._updateMessagesToView(s,n)}}_postprocessMessageUpdateEvent(n,s){switch(s){case e.CollectionEventSource.EVENT_CHANNEL_READ:{const e=[],i=this._messages.map((e=>e.notificationId));for(const{notificationId:s}of n){const n=i.indexOf(s);n>=0&&(this._messages[n].messageStatus=t.NotificationMessageStatus.READ,e.push(this._messages[n]))}e.length>0&&this._updateMessagesToView(e,s);break}}}_addMessagesToView(t,s){const i=this._filterUnderOffsetMessage(t),a=[],o=[];for(const t of i)if(s===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(n.indexOfMessage(this._messages,t)<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}}else{const e=n.indexOfMessage(this._messages,t);if(e<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}else this._messages[e]=t,o.push(t)}e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n,i;const r={source:s};a.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===t||t.call(e,r,this.channel,a)),o.length>0&&(null===(i=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===i||i.call(n,r,this.channel,o))}))))}_updateMessagesToView(t,s){const i=[];for(const e of t){const t=n.indexOfMessage(this._messages,e);t>=0&&(i.push(e),this._messages[t]=e)}return e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t;const n={source:s};i.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===t||t.call(e,n,this.channel,i))})))),i}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._activate()}))}}class x extends t.BaseChannel{static payloadify(e){var s;return Object.assign(Object.assign({},n.GroupChannel.payloadify(null!==(s=e._groupChannel)&&void 0!==s?s:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((e=>o.payloadify(e))),last_message:e.lastMessage?t.NotificationMessage.payloadify(e.lastMessage):null})}constructor(s,i){var a,r;super(s,i),this.channelType=e.ChannelType.FEED,this._groupChannel=new n.GroupChannel(s,i),this.isCategoryFilterEnabled=null!==(a=i.is_category_filter_enabled)&&void 0!==a&&a,this.isTemplateLabelEnabled=null===(r=i.is_template_label_enabled)||void 0===r||r,this.notificationCategories=i.categories?i.categories.map((e=>new o(e))):[],this.lastMessage=i.last_message?t.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},i.last_message)):null}get groupChannel(){return this._groupChannel}get url(){return this._groupChannel.url}get name(){return this._groupChannel.name}set name(e){this._groupChannel.name=e}get createdAt(){return this._groupChannel.createdAt}get members(){return this._groupChannel.members}get memberCount(){return this._groupChannel.memberCount}get myMemberState(){return this._groupChannel.myMemberState}get myLastRead(){return this._groupChannel.myLastRead}get unreadMessageCount(){return this._groupChannel.unreadMessageCount}serialize(){var t,n;return Object.assign(Object.assign({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((t=>e.serialize(t))),lastMessage:null!==(n=null===(t=this.lastMessage)||void 0===t?void 0:t.serialize())&&void 0!==n?n:null})}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannel._refresh(!0),this}))}markAsRead(n){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,dispatcher:i,requestQueue:a}=e.Vault.of(this._iid),o=null==n?void 0:n.filter((e=>!e||e.messageStatus===t.NotificationMessageStatus.SENT)).map((e=>e.notificationId));if(!o||o.length>0){const r=new t.ReadAPIRequestCommand({userId:s.userId,channelUrl:this.url,channelType:e.ChannelType.FEED,notificationIds:o}),d=yield a.send(r),{unreadMessageCount:c,readAt:h}=d.as(t.ReadAPIResponseCommand);if(n){if("number"==typeof c){this._groupChannel._updateUnreadCount(c,this._groupChannel.unreadMentionCount);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}n.forEach((e=>{e.messageStatus=t.NotificationMessageStatus.READ})),i.dispatch(new e.MessageUpdateEventCommand({messages:n,source:e.CollectionEventSource.EVENT_CHANNEL_READ}))}else if(this._groupChannel._updateUnreadMemberState(s.userId,h),this._groupChannel.unreadMessageCount!==c){this._groupChannel._updateUnreadCount(c,0);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}i.dispatch(new l({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}))}}))}markAsClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this.logClicked(t)}))}logClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30)for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}))}))}logImpression(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.logViewed(t)}))}logViewed(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30){for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}));return!0}return!1}))}logCustom(t,n){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:s}=e.Vault.of(this._iid);if(0{Object.prototype.hasOwnProperty.call(this,t)&&(this[t]=e[t])}))}}class D extends e.BaseListQuery{constructor(e,t){var n;super(e,t),this.includeEmpty=h,this.includeEmpty=null!==(n=t.includeEmpty)&&void 0!==n?n:h}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)}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 t=k.of(this._iid),n=e.undefineNullProps(Object.assign({},this)),{channels:s,token:i}=yield t.getMyFeedChannels(this._token,n,this.limit);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class F extends e.Module{constructor(){super(...arguments),this.name="feedChannel"}init(e,t){super.init(e,t),this._manager=new k(e,t)}buildFeedChannelFromSerializedData(e){return this._manager.buildFeedChannelFromSerializedData(e)}createMyFeedChannelListQuery(e={}){return new D(this._iid,e)}addFeedChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof P).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeFeedChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}removeAllFeedChannelHandlers(){this._manager.clearHandler()}getChannel(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getMyFeedChannelChangeLogsByTimestamp(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("number",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getMyFeedChannelChangeLogsByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("string",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.getTotalUnreadNotificationCount()}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadNotificationCount()}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getGlobalNotificationChannelSetting()}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplateListByToken(t,n)}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplate(t)}))}refreshNotificationCollections(){this._manager.refreshNotificationCollections()}}exports.NotificationMessage=t.NotificationMessage,Object.defineProperty(exports,"NotificationMessageStatus",{enumerable:!0,get:function(){return t.NotificationMessageStatus}}),exports.FeedChannel=x,exports.FeedChannelHandler=P,exports.FeedChannelListQuery=D,exports.FeedChannelModule=F,exports.NotificationCategory=o,exports.NotificationCollection=R; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-2d1d7d4f.cjs"),t=require("./lib/__bundle-ccb8334d.cjs"),n=require("./lib/__bundle-90430bee.cjs"),s=require("./lib/__bundle-785dde28.cjs"),i=require("./lib/__bundle-f1e6fb74.cjs"),a=require("./lib/__bundle-73351257.cjs");require("./lib/__bundle-fdee1c40.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class o{constructor(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}static payloadify(t){return e.deundefined(e.undefineNullProps({id:t.id,name:t.name,is_default:t.isDefault}))}get customType(){return this.isDefault?"*":String(this.id)}}class r extends e.InstancedObject{constructor(e,{sdkState:t,cacheContext:n,channelManager:s}){super(e),this._channels=new Map,this._sdkState=t,this._cacheContext=n,this._channelManager=s}get collection(){const{nestdb:n}=this._cacheContext;return e.unless(!!n).throw(e.SendbirdError.databaseError),n.collection(t.NESTDB_FEEDCHANNEL_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 this._channelManager.buildFeedChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}get(t){return e.__awaiter(this,void 0,void 0,(function*(){if(this._channels.has(t))return this._channels.get(t);if(this.localCacheEnabled){const e=yield this.collection.getByKey(t);if(e)return this._channels.set(t,this._deserialize(e)),this._channels.get(t)}}))}fetch({token:n,limit:i=t.DEFAULT_FEED_LIMIT,backward:a=!1,order:o="latest_last_message",borderlineChannelUrl:r}){return e.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const e={where:e=>{if(n&&"latest_last_message"===o)if(!a&&e.lastMessageUpdatedAt>n||a&&e.lastMessageUpdatedAtthis._deserialize(e)));return l.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),l}return[]}))}upsert(t){return e.__awaiter(this,void 0,void 0,(function*(){const n=[];if(t.forEach((t=>{if(this._channels.has(t.url)){const s=this._channels.get(t.url),i=e.deundefined(t);Object.assign(s,i,{_iid:this._iid}),n.push(s)}else this._channels.set(t.url,t),n.push(t)})),this.localCacheEnabled){const e=[];for(let t=0;te.__awaiter(this,void 0,void 0,(function*(){if(s instanceof l){const{channels:e,context:i,isWebSocketEventComing:a}=s,o=e.filter((e=>e instanceof x)),r=yield t.upsert(o);yield Promise.all(o.map((e=>n.markAsReadByTimestamp(e.url,e.myLastRead)))),a||this._broadcastUpdateEvent(r,i)}else if(s instanceof d){const{channelUrls:i,context:a,isWebSocketEventComing:o}=s;yield t.remove(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of i)yield n.removeMessagesOfChannel(e)})))),o||this._broadcastRemoveEvent(i,a)}else s instanceof i.DatabaseOpenCommand&&(yield t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const n of this._observers.values())n.onUpdate&&n.onUpdate(e,t)}_broadcastRemoveEvent(e,t){for(const n of this._observers.values())n.onRemove&&n.onRemove(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const h=!1;class u extends e.APIRequestCommand{constructor(t){super();const{userId:n,token:s,limit:i,includeEmpty:a}=t;this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(n)}/my_group_channels`,this.params=e.deundefined({token:s,limit:i,show_empty:null!=a?a:h,show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0,is_feed_channel:!0,order:"latest_last_message"})}}class _ extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:n,channels:s,ts:i}=t;this.token=n,this.ts=null!=i?i:0,this.channels=(null!=s?s:[]).map((t=>(t.ts=i,new x(e,t))))}}class g extends e.APIRequestCommand{constructor({channelUrl:t,isInternalCall:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${n?e.API_PATH_GROUP_CHANNELS_INTERNAL:e.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,is_feed_channel:!0}}}class f extends e.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new x(e,t)}}const C={includeEmpty:!0},m=t=>e.isTypeOf("boolean",t.includeEmpty);class p extends e.APIRequestCommand{constructor({userId:t,ts:n,token:s,params:i}){super();const{includeEmpty:a}=Object.assign(Object.assign({},C),i);this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels/changelogs`,this.params=e.deundefined(e.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,is_feed_channel:!0,show_empty:a,change_ts:n||null,token:s}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((t=>new x(e,t))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next}}class E extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/settings`}}class y extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}const b=20;class M extends e.APIRequestCommand{constructor(t){const{reverse:n=!1,keys:s,limit:i=b,token:a}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates`,this.params=e.deundefined({token:a,keys:s,limit:i,reverse:n,order:"updated_at",show_ui_template:!0,show_color_variables:!0})}}class w extends e.APIResponseCommand{constructor(t,n){super(t,n);const{next:s,has_more:i=!1}=n,a=e.__rest(n,["next","has_more"]);this.nextToken=s,this.hasMore=i,this.notificationTemplateList={jsonString:JSON.stringify(a)}}}const T={reverse:!1,keys:void 0,limit:20};class S extends e.APIRequestCommand{constructor(t){const{key:n}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates/${n}`,this.params=e.deundefined({key:n})}}class I extends e.APIResponseCommand{constructor(e,t){super(e,t),this.jsonString=JSON.stringify(t)}}class N extends e.WebSocketEventCommand{constructor(n,s,i){var a,o,r;super(n,"ADMM",i),this.message=new t.NotificationMessage(n,i);const{sdkState:l}=e.Vault.of(n);this.isMentioned=e.checkIfMentioned(this.message.mentionType,null!==(r=null!==(a=this.message.mentionedUserIds)&&void 0!==a?a:null===(o=this.message.mentionedUsers)||void 0===o?void 0:o.map((e=>e.userId)))&&void 0!==r?r:[],l.userId)}}class A extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS_USERS}/${encodeURIComponent(t)}/unread_message_count`}}const O={};class k extends a.BaseChannelManager{get _notificationMessageCache(){return t.NotificationMessageCache.of(this._iid)}constructor(n,s){super(n,Object.assign(Object.assign({},s),{channelType:e.ChannelType.FEED})),this._feedChannelHandlers=new Map,this._feedChannelCache=new r(this._iid,{sdkState:this._sdkState,cacheContext:this._cacheContext,channelManager:this}),this._feedChannelBroadcast=new c({feedChannelCache:this._feedChannelCache,dispatcher:this._dispatcher,notificationMessageCache:t.NotificationMessageCache.of(n)}),this._dispatcher.on((t=>{t instanceof e.WebSocketEventCommand&&this._handleEvent(t).catch((t=>{if(e.isThrowingOutside(t))throw t}))})),O[n]||(O[n]=this)}static of(t){return O[t]||(O[t]=new k(t,e.Vault.of(t))),O[t]}static clear(e){O[e]&&delete O[e]}get handlers(){return[...this._feedChannelHandlers.values()]}buildFeedChannelFromSerializedData(t){const n=e.deserialize(t);return new x(this._iid,x.payloadify(n))}addHandler(e,t){this._feedChannelHandlers.set(e,t)}removeHandler(e){this._feedChannelHandlers.delete(e)}clearHandler(){this._feedChannelHandlers.clear()}getMyFeedChannels(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){const e=new u(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:s})),i=yield this._requestQueue.send(e),{channels:a,token:o}=i.as(_);return{channels:a,token:o}}))}getChannel(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(t);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(t,n)}))}getChannelFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),null!==(n=yield this._feedChannelCache.get(t))&&void 0!==n?n:null}))}getChannelWithoutCache(t,n=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const s=new g({channelUrl:t,isInternalCall:n}),i=yield this._requestQueue.send(s),{channel:a}=i.as(f),[o]=yield this.upsertChannelsToCache([a]);return o}))}getMyFeedChannelChangeLogs(t,n,s=e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},C),n);e.unless((e.isTypeOf("string",t)||e.isTypeOf("number",t))&&m(i)).throw(e.SendbirdError.invalidParameters);const a=new p(e.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,params:i})),o=yield this._requestQueue.send(a),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}=o.as(v);return r.length>0&&this._dispatcher.dispatch(new l({channels:r,context:{source:s}})),c.length>0&&this._dispatcher.dispatch(new d({channelUrls:c,context:{source:s}})),{updatedChannels:r,deletedChannelUrls:c,hasMore:h,token:u}}))}getTotalUnreadMessageCount(t){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},n.TotalUnreadMessageCountParamsDefault),t);e.unless(n.validateTotalUnreadMessageCountParams(s)).throw(e.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:a}=e.Vault.of(this._iid),o=new n.GetTotalUnreadMessageCountRequestCommand({userId:i.userId,filter:s,includeFeedChannel:!0}),r=yield a.send(o),{unreadFeedCount:l=0}=r.as(n.GetTotalUnreadMessageCountResponseCommand);return l}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),i=new A({userId:t.userId}),a=yield s.send(i),{unreadFeedCount:o=0}=a.as(n.GetTotalUnreadMessageCountResponseCommand);return o}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){const e=new E,t=yield this._requestQueue.send(e),{jsonString:n}=t.as(y);return{jsonString:n}}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},T),n);e.unless(e.isTypeOf("string",t)&&(t=>e.isTypeOf("boolean",t.reverse,!0)&&e.isArrayOf("string",t.keys,!0)&&e.isTypeOf("number",t.limit,!0))(s)).throw(e.SendbirdError.invalidParameters);const i=new M({token:t,keys:s.keys,reverse:s.reverse,limit:s.limit}),a=yield this._requestQueue.send(i),{hasMore:o,nextToken:r,notificationTemplateList:l}=a.as(w);return{hasMore:o,token:r,notificationTemplateList:l}}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=new S({key:t}),s=yield this._requestQueue.send(n),{jsonString:i}=s.as(I);return{jsonString:i}}))}upsertChannelsToCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._feedChannelCache.upsert(t)}))}removeChannelsFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this._feedChannelCache.remove(t)}))}getNotificationMessageFromCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.get(t)}))}refreshChannel(t,s=!0,i=e.CollectionEventSource.REFRESH_CHANNEL){return e.__awaiter(this,void 0,void 0,(function*(){try{const e=new g({channelUrl:t,isInternalCall:s}),a=yield this._requestQueue.send(e),{channel:o}=a.as(f);if(o.myMemberState===n.MemberState.NONE)this._dispatcher.dispatch(new d({channelUrls:[o.url],context:{source:i}}));else{const e=yield this.upsertChannelsToCache([o]);this._dispatcher.dispatch(new l({channels:e,context:{source:i}}))}}catch(n){n.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&n.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new d({channelUrls:[t],context:{source:i}}))}}))}refreshNotificationCollections(){this._dispatcher.dispatch(new s.NotificationCollectionRefreshCommand)}subscribeChannelEvent(e,t){this._feedChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._feedChannelBroadcast.unsubscribe(e)}_handleEvent(n){return e.__awaiter(this,void 0,void 0,(function*(){switch(n.code){case"ADMM":case"BRDM":{const s="ADMM"===n.code||"BRDM"===n.code?n.as(N):null;if(s&&s.message.channelType===this._channelType){const{message:n,isMentioned:i}=s,a=yield this.getChannel(n.channelUrl,!0);a._runIfHandleableWithGroupChannel((s=>{var o;n instanceof t.NotificationMessage&&i&&(null===(o=n.mentionedUsers)||void 0===o||o.forEach((e=>{for(const t of s.members)if(e.userId===t.userId){e.nickname=t.nickname,e.plainProfileUrl=t.plainProfileUrl,e.metaData=t.metaData;break}}))),this._dispatcher.dispatch(new l({channels:[a],context:{source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),this._dispatcher.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageReceived&&e.onMessageReceived(a,n),i&&e.onMentionReceived&&e.onMentionReceived(a,n)}))))}))}break}case"READ":{const s="READ"===n.code?n.as(t.ReadEventCommand):null;if(s&&s.readStatus.channelType===this._channelType){const{readStatus:t}=s,n=this._feedChannelCache.isCachedInMemory(t.channelUrl),i=yield this.getChannel(t.channelUrl,!0);i._runIfHandleableWithGroupChannel((s=>{n&&s._updateUnreadMemberState(t.reader.userId,t.readAt),t.reader.userId===this._sdkState.userId&&(n?(s.unreadMessageCount>0||s.unreadMentionCount>0)&&(s._updateUnreadCount(0,0),this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))):0!==s.unreadMessageCount&&0!==s.unreadMentionCount||(this._dispatcher.dispatch(new l({channels:[i],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))))}))}break}case"SYEV":{const t="SYEV"===n.code?n.as(a.ChannelEventCommand):null;if(t&&t.event.channelType===this._channelType){const{event:n}=t;switch(n.category){case a.ChannelEventCategory.CHANNEL_DELETED:{const t=yield this.getChannel(n.channelUrl,!0);this._dispatcher.dispatch(new d({channelUrls:[n.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(t.url,t.channelType)}))}))));break}case a.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const t=yield this.getChannelWithoutCache(n.channelUrl,!0);this._dispatcher.dispatch(new l({channels:[t],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(t)}))}))));break}}}break}}}))}getMessageFromCache(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(n=yield this._notificationMessageCache.get(t))&&void 0!==n?n:null}))}getExactlyMatchingMessagesForTokenFromCache(t,n,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:t,token:n,filter:s,exactMatch:!0})}))}getMessagesFromCache(n,s,i,a,o=t.DEFAULT_NOTIFICATION_LIMIT,r=!0){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._notificationMessageCache.fetch({channelUrl:n,token:s,limit:o,filter:a,backward:"next"===i,inclusive:r})}))}}class R extends n.BaseMessageCollection{keyOf(e){return e.notificationId}get changelogIncludeParams(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}constructor(t,n){super(t,Object.assign(Object.assign({},n),{channelManager:k.of(t)}));const{connectionManager:i,dispatcher:a}=e.Vault.of(this._iid);this._notificationCollectionEventContext=a.on((t=>{t instanceof s.NotificationCollectionRefreshCommand&&e.sleep(10).then((()=>{i.isConnected||i.isConnecting||this.refresh()}))}))}dispose(){super.dispose(),this._notificationCollectionEventContext.close()}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_postprocessChannelUpdateEvent(e,n){const s=this._messages.filter((n=>n.messageStatus===t.NotificationMessageStatus.SENT&&n.createdAt<=e.myLastRead));if(s.length>0){for(const e of s)e.messageStatus=t.NotificationMessageStatus.READ;this._updateMessagesToView(s,n)}}_postprocessMessageUpdateEvent(n,s){switch(s){case e.CollectionEventSource.EVENT_CHANNEL_READ:{const e=[],i=this._messages.map((e=>e.notificationId));for(const{notificationId:s}of n){const n=i.indexOf(s);n>=0&&(this._messages[n].messageStatus=t.NotificationMessageStatus.READ,e.push(this._messages[n]))}e.length>0&&this._updateMessagesToView(e,s);break}}}_addMessagesToView(t,s){const i=this._filterUnderOffsetMessage(t),a=[],o=[];for(const t of i)if(s===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(n.indexOfMessage(this._messages,t)<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}}else{const e=n.indexOfMessage(this._messages,t);if(e<0){const e=n.placeOfMessage(this._messages,t);this._messages.splice(e,0,t),a.push(t)}else this._messages[e]=t,o.push(t)}e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n,i;const r={source:s};a.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===t||t.call(e,r,this.channel,a)),o.length>0&&(null===(i=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===i||i.call(n,r,this.channel,o))}))))}_updateMessagesToView(t,s){const i=[];for(const e of t){const t=n.indexOfMessage(this._messages,e);t>=0&&(i.push(e),this._messages[t]=e)}return e.shouldGiveEvent(s)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t;const n={source:s};i.length>0&&(null===(t=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===t||t.call(e,n,this.channel,i))})))),i}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._activate()}))}}class x extends t.BaseChannel{static payloadify(e){var s;return Object.assign(Object.assign({},n.GroupChannel.payloadify(null!==(s=e._groupChannel)&&void 0!==s?s:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((e=>o.payloadify(e))),last_message:e.lastMessage?t.NotificationMessage.payloadify(e.lastMessage):null})}constructor(s,i){var a,r;super(s,i),this.channelType=e.ChannelType.FEED,this._groupChannel=new n.GroupChannel(s,i),this.isCategoryFilterEnabled=null!==(a=i.is_category_filter_enabled)&&void 0!==a&&a,this.isTemplateLabelEnabled=null===(r=i.is_template_label_enabled)||void 0===r||r,this.notificationCategories=i.categories?i.categories.map((e=>new o(e))):[],this.lastMessage=i.last_message?t.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},i.last_message)):null}get groupChannel(){return this._groupChannel}get url(){return this._groupChannel.url}get name(){return this._groupChannel.name}set name(e){this._groupChannel.name=e}get createdAt(){return this._groupChannel.createdAt}get members(){return this._groupChannel.members}get memberCount(){return this._groupChannel.memberCount}get myMemberState(){return this._groupChannel.myMemberState}get myLastRead(){return this._groupChannel.myLastRead}get unreadMessageCount(){return this._groupChannel.unreadMessageCount}serialize(){var t,n;return Object.assign(Object.assign({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((t=>e.serialize(t))),lastMessage:null!==(n=null===(t=this.lastMessage)||void 0===t?void 0:t.serialize())&&void 0!==n?n:null})}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannel._refresh(!0),this}))}markAsRead(n){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,dispatcher:i,requestQueue:a}=e.Vault.of(this._iid),o=null==n?void 0:n.filter((e=>!e||e.messageStatus===t.NotificationMessageStatus.SENT)).map((e=>e.notificationId));if(!o||o.length>0){const r=new t.ReadAPIRequestCommand({userId:s.userId,channelUrl:this.url,channelType:e.ChannelType.FEED,notificationIds:o}),d=yield a.send(r),{unreadMessageCount:c,readAt:h}=d.as(t.ReadAPIResponseCommand);if(n){if("number"==typeof c){this._groupChannel._updateUnreadCount(c,this._groupChannel.unreadMentionCount);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}n.forEach((e=>{e.messageStatus=t.NotificationMessageStatus.READ})),i.dispatch(new e.MessageUpdateEventCommand({messages:n,source:e.CollectionEventSource.EVENT_CHANNEL_READ}))}else if(this._groupChannel._updateUnreadMemberState(s.userId,h),this._groupChannel.unreadMessageCount!==c){this._groupChannel._updateUnreadCount(c,0);k.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}i.dispatch(new l({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}))}}))}markAsClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this.logClicked(t)}))}logClicked(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30)for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}))}))}logImpression(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.logViewed(t)}))}logViewed(t){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:n}=e.Vault.of(this._iid);if(t.length<=30){for(const s of t)s&&s.notificationId&&s.notificationData&&n.put(new e.StatLog({type:e.StatType.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:s.notificationData.templateKey,channel_url:this.url,message_id:s.notificationId,tags:s.notificationData.tags,source:"notification",message_ts:s.createdAt,notification_event_deadline:s.notificationEventDeadline}}));return!0}return!1}))}logCustom(t,n){return e.__awaiter(this,void 0,void 0,(function*(){const{statManager:s}=e.Vault.of(this._iid);if(0{Object.prototype.hasOwnProperty.call(this,t)&&(this[t]=e[t])}))}}class D extends e.BaseListQuery{constructor(e,t){var n;super(e,t),this.includeEmpty=h,this.includeEmpty=null!==(n=t.includeEmpty)&&void 0!==n?n:h}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)}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 t=k.of(this._iid),n=e.undefineNullProps(Object.assign({},this)),{channels:s,token:i}=yield t.getMyFeedChannels(this._token,n,this.limit);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class F extends e.Module{constructor(){super(...arguments),this.name="feedChannel"}init(e,t){super.init(e,t),this._manager=new k(e,t)}buildFeedChannelFromSerializedData(e){return this._manager.buildFeedChannelFromSerializedData(e)}createMyFeedChannelListQuery(e={}){return new D(this._iid,e)}addFeedChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof P).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeFeedChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}removeAllFeedChannelHandlers(){this._manager.clearHandler()}getChannel(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getMyFeedChannelChangeLogsByTimestamp(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("number",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getMyFeedChannelChangeLogsByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),n);return e.unless(e.isTypeOf("string",t)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(t,s)}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.getTotalUnreadNotificationCount()}))}getTotalUnreadNotificationCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadNotificationCount()}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getGlobalNotificationChannelSetting()}))}getNotificationTemplateListByToken(t,n={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplateListByToken(t,n)}))}getNotificationTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplate(t)}))}refreshNotificationCollections(){this._manager.refreshNotificationCollections()}}exports.NotificationMessage=t.NotificationMessage,Object.defineProperty(exports,"NotificationMessageStatus",{enumerable:!0,get:function(){return t.NotificationMessageStatus}}),exports.FeedChannel=x,exports.FeedChannelHandler=P,exports.FeedChannelListQuery=D,exports.FeedChannelModule=F,exports.NotificationCategory=o,exports.NotificationCollection=R; diff --git a/cjs/groupChannel.cjs b/cjs/groupChannel.cjs index 11b4918..32ef1f7 100644 --- a/cjs/groupChannel.cjs +++ b/cjs/groupChannel.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),t=require("./lib/__bundle-0fbd5934.cjs"),n=require("./lib/__bundle-4bcf4070.cjs"),i=require("./lib/__bundle-0f6b8ff3.cjs"),s=require("./lib/__bundle-947cb619.cjs");require("./lib/__bundle-12c1cdf9.cjs"),require("./lib/__bundle-dae7bdf2.cjs"),require("./lib/__bundle-d349e14c.cjs");const r={};class a{constructor({_iid:n,limit:s=100}){this.ref=0,this._iid=n,this._limit=s;const{sdkState:r,dispatcher:a,logger:o,cacheContext:l,statManager:d}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${r.userId}@groupchannel/sync.meta`;const h=(e=>`sendbird:${e}@groupchannel/sync`)(r.userId);this._sync=new t.Sync(h,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,s,a,h,u,c,p,_;const g={hasNext:!0,nextToken:""};if(yield this.loadMetadata(),o.debug("channel background sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),null===(s=this._metadata)||void 0===s?void 0:s.completed)g.hasNext=!1,g.nextToken="";else{const n={includeEmpty:!0,includeMetaData:!0,order:i.GroupChannelListOrder.CHRONOLOGICAL};try{if(n.order===i.GroupChannelListOrder.LATEST_LAST_MESSAGE)try{const t=yield l.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(r.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const s=t.GroupChannelManager.of(this._iid),{channels:d,token:u}=yield s.getMyGroupChannels(null!==(h=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==h?h:"",n,this._limit,e.CollectionEventSource.SYNC_CHANNEL_BACKGROUND);g.hasNext=d.length>=this._limit&&!!u,g.nextToken=u,this._metadata&&(this._metadata.token=u,this._metadata.range.extends(...d.map((e=>e.createdAt))),this._metadata.completed=!g.hasNext),o.debug("channel background sync progress",g),yield this.saveMetadata()}catch(t){throw o.debug("channel background sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetaData()),t}finally{d.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=l.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:null!==(_=null===(p=n.order)||void 0===p?void 0:p.toString())&&void 0!==_?_:"",collection_id:r.userId}}))}}return g})))),this._connectionEventContext=a.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return r[e]||(r[e]=new a({_iid:e})),r[e].ref++,r[e]}static clear(e){r[e]&&(r[e].close(),delete r[e])}get range(){var e,n;return null!==(n=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==n?n:new t.TimeRange({})}get completed(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:n}=e.Vault.of(this._iid),i=yield n.preference.get(this._metadataKey);this._metadata={token:i?i.token:"",range:new t.TimeRange(i?i.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!i&&i.completed}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetaData(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){var t,n;const{logger:i,sessionManager:s}=e.Vault.of(this._iid);s.session.hasSession&&(i.debug("channel background sync resume()"),this._sync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.token)&&void 0!==n?n:""))}pause(){const{logger:t}=e.Vault.of(this._iid);t.debug("channel background sync stop()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete r[this._iid])}}const o={};class l{constructor({_iid:n}){this.ref=0,this._iid=n;const{logger:i,sdkState:s,dispatcher:r,cacheContext:a,statManager:o}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${s.userId}@groupchannel/changelogs.meta`,this._subscribers=new e.EventDispatcher;const l=(e=>`sendbird:${e}@groupchannel/changelogs`)(s.userId);this._sync=new t.Sync(l,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,r,l;const d={hasNext:!0,nextToken:0};yield this.loadMetadata(),i.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token);try{const n={includeEmpty:!0,includeMetaData:!0};try{const t=yield a.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(s.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const h=t.GroupChannelManager.of(this._iid),{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}=yield h.getMyGroupChannelChangeLogs(null!==(l=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==l?l:"",n,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);this._subscribers.dispatch("progress",{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}),d.hasNext=p,d.nextToken=_,this._metadata&&(this._metadata.token=_),i.debug("channel changelog sync progress",d),yield this.saveMetadata(),a.localCacheEnabled&&o.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:u.length>0||c.length>0?"cache_miss":"cache_hit",max_db_size:u.length,use_local_cache:a.localCacheEnabled,starting_point:0,message_init_policy:c.length.toString(),collection_id:s.userId}}))}catch(t){throw i.debug("channel changelog sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetadata()),t}return d})))),this._sync.on("stop",(()=>{this._subscribers.dispatch("pause")})),this._connectionEventContext=r.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return o[e]||(o[e]=new l({_iid:e})),o[e].ref++,o[e]}static clear(e){o[e]&&(o[e].close(),delete o[e])}get isRunning(){return this._sync.isRunning}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t,firstConnectedAt:n}=e.Vault.of(this._iid),i=yield t.preference.get(this._metadataKey);this._metadata={token:i?i.token:n}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}on(e,t){return this._subscribers.on(e,t)}resume(){const{sessionManager:t}=e.Vault.of(this._iid);t.session.hasSession&&this._sync.start(0)}pause(){this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete o[this._iid])}}const d=(e,t)=>e.findIndex((e=>e.isIdentical(t))),h=(e,t,n)=>{if(e.length>0){const i=d(e,t);let s=0,r=e.length-1,a=Math.floor((s+r)/2);for(;s0)r=a,a=Math.floor((s+r)/2);else{if(!(o<0))return{place:a,oldPosition:i};s=a+1,a=Math.floor((s+r)/2)}}return{place:u(e[a],t,n)>=0?a:a+1,oldPosition:i}}return{place:e.length,oldPosition:-1}},u=(e,t,n)=>{switch(n){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(e.lastMessage&&t.lastMessage){const n=t.lastMessage.createdAt-e.lastMessage.createdAt;return 0===n?t.createdAt-e.createdAt:n}return e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:{const n=e.name.localeCompare(t.name);return 0===n?e.createdAt-t.createdAt:n}default:return 0}};class c{constructor(s,{filter:r=new t.GroupChannelFilter,order:o=i.GroupChannelListOrder.LATEST_LAST_MESSAGE,limit:d=n.DEFAULT_GROUPCHANNEL_LIMIT,includeChangesOnInitialLoad:h=!1}){this.channels=[],this._isInitialized=!1,this._iid=s,this._key=`gcc-${e.uuid()}`,this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=h,this.filter=r,this.order=o,this._hasMore=!0,this._token="",this._limit=d;const{sdkState:u,cacheContext:c,dispatcher:p}=e.Vault.of(this._iid);c.localCacheEnabled&&(this._backgroundSync=a.of(s),this._backgroundSync.resume()),this._changelogSync=l.of(s),this._changelogSync.resume();t.GroupChannelManager.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:(e,n)=>{const{source:i}=n;if(t.shouldGiveEvent(i)){const t=e.filter((e=>this.filter.match(e,u.userId))),i=e.filter((e=>!this.filter.match(e,u.userId))).map((e=>e.url));t.length>0&&this._addChannelsToView(t,n),i.length>0&&this._removeChannelsFromView(i,n)}},onRemove:(e,t)=>{this._removeChannelsFromView(e,t)}}),p.on((t=>{t instanceof e.ConnectionStateChangeCommand&&(t.stateType===e.ConnectionStateType.CONNECTED?this._isGetRemoteChannelsSucceeded||(()=>{e.__awaiter(this,void 0,void 0,(function*(){yield this._revokeLoadMore()}))})():t.stateType===e.ConnectionStateType.LOGOUT&&this.dispose())}))}get hasMore(){return!this._isDisposed&&this._hasMore}setGroupChannelCollectionHandler(e){this._handler=e}_addChannelsToView(n,s,r=!1){const a=[],o=[],l=[];for(const t of n){const n=d(this.channels,t);n>=0&&this.channels.splice(n,1);const{place:u}=h(this.channels,t,this.order);if(n<0)u===this.channels.length?!r&&this._hasMore||(a.push(t),this.channels.push(t)):(a.push(t),this.channels.splice(u,0,t));else switch(s.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&u===this.channels.length?l.push(t):(this.channels.splice(u,0,t),o.push(t));break;default:this.channels.splice(u,0,t),o.push(t)}}if(l.length>0)for(const e of l){const t=d(this.channels,e);-1!==t&&this.channels.splice(t,1)}t.shouldGiveEvent(s.source)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n;a.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(s,a),o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(s,o),l.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(s,l.map((e=>e.url)))}))))}_removeChannelsFromView(n,i){const s=[];for(const e of n){const t=this.channels.findIndex((t=>t.url===e));t>=0&&(s.push(this.channels[t].url),this.channels.splice(t,1))}return t.shouldGiveEvent(i.source)&&s.length>0&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,s)})))),s}_getLocalChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.GroupChannelManager.of(this._iid),n=this.channels.length>0?((e,t)=>{var n,s,r,a;switch(t){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(s=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==s?s:e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(a=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:e.createdAt}})(this.channels[this.channels.length-1],this.order):null;return yield e.getChannelsFromCache(n,this.filter,this.order,this._limit,n?this.channels[this.channels.length-1].url:void 0)}))}_getRemoteChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const n=t.GroupChannelManager.of(this._iid),{channels:i,token:s}=yield n.getMyGroupChannels(this._token,e.undefineNullProps(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);return this._token=s,this._hasMore=!!s,i}))}_revokeLoadMore(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._isDisposed)try{const t=yield this._getRemoteChannels();this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(t,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}catch(e){this._isGetRemoteChannelsSucceeded=!1}}))}loadMore(){var t;return e.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new e.SendbirdError({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});let n=null;this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning&&(n=yield new Promise((e=>{this._changelogSyncSubscriberContext=this._changelogSync.on("progress",(t=>e(t))).on("pause",(()=>e(null)))})),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close());const{cacheContext:i,connectionManager:s,statManager:r}=e.Vault.of(this._iid);this._isInitialized||(this._isInitialized=!0,i.localCacheEnabled&&(yield this._backgroundSync.loadMetadata()),r.put(new e.DailyRecordStatLog({type:e.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}})));let a=[];if(this._hasMore){if(!i.localCacheEnabled||s.isConnected&&!this._backgroundSync.completed)try{a=yield this._getRemoteChannels(),this._isGetRemoteChannelsSucceeded=!0}catch(e){this._isGetRemoteChannelsSucceeded=!1}else yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){a=yield this._getLocalChannels()})))),this._hasMore=a.length>=this._limit;this._addChannelsToView(a,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}if(n){for(const e of n.updatedChannels){const t=d(a,e);if(t>=0)a[t]=e;else{const{place:t}=h(a,e,this.order);a.splice(t,0,e)}}const e=a.map((e=>e.url));for(const t of n.deletedChannelUrls){const n=e.indexOf(t);n>=0&&(a.splice(n,1),e.splice(n,1))}}return a}))}dispose(){var e,n,i;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===(n=this._changelogSync)||void 0===n||n.close(),null===(i=this._changelogSyncSubscriberContext)||void 0===i||i.close();t.GroupChannelManager.of(this._iid).unsubscribeChannelEvent(this._key)}}class p extends e.APIRequestCommand{constructor(n){const{token:i,limit:s,order:r,includeEmpty:a,membershipFilter:o,channelNameContainsFilter:l,channelUrlsFilter:d,customTypesFilter:h,customTypeStartsWithFilter:u,superChannelFilter:c,metadataOrderKeyFilter:p,metadataKey:_,metadataValues:g,metadataValueStartsWith:m,includeFrozen:C,includeMetaData:f}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_GROUP_CHANNELS,this.params=e.deundefined(e.undefineNullProps({token:i,limit:s,order:r,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:a,public_mode:t.PublicChannelFilter.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:d,custom_types:h,custom_type_startswith:u,super_mode:c,metadata_order_key:p,metadata_key:_,metadata_values:g,metadata_value_startswith:m,show_frozen:C,show_metadata:f}))}}class _ extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:i,channels:s,ts:r}=n;this.token=i,s&&s.length>0&&(this.channels=s.map((n=>(n.ts=r,new t.GroupChannel(e,n))))),this.ts="number"==typeof r?r:0}}var g;exports.MembershipFilter=void 0,(g=exports.MembershipFilter||(exports.MembershipFilter={})).ALL="all",g.JOINED="joined";class m extends e.BaseListQuery{constructor(e,n){var s,r,a,o,l,d,h,u,c,p,_,g,m,C;super(e,n),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=t.SuperChannelFilter.ALL,this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=i.PublicGroupChannelListOrder.CHRONOLOGICAL,this.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,this.customTypesFilter=null!==(l=n.customTypesFilter)&&void 0!==l?l:null,this.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,this.channelNameContainsFilter=null!==(h=n.channelNameContainsFilter)&&void 0!==h?h:null,this.membershipFilter=null!==(u=n.membershipFilter)&&void 0!==u?u:exports.MembershipFilter.ALL,this.superChannelFilter=null!==(c=n.superChannelFilter)&&void 0!==c?c:t.SuperChannelFilter.ALL,this.metadataKey=null!==(p=n.metadataKey)&&void 0!==p?p:null,this.metadataValues=null!==(_=n.metadataValues)&&void 0!==_?_:null,this.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,this.metadataValueStartsWith=null!==(m=n.metadataValueStartsWith)&&void 0!==m?m:null,this.order=null!==(C=n.order)&&void 0!==C?C:i.PublicGroupChannelListOrder.CHRONOLOGICAL}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.channelNameContainsFilter,!0)&&e.isArrayOf("string",this.channelUrlsFilter,!0)&&e.isArrayOf("string",this.customTypesFilter,!0)&&e.isTypeOf("string",this.customTypeStartsWithFilter,!0)&&e.isEnumOf(exports.MembershipFilter,this.membershipFilter)&&e.isEnumOf(t.SuperChannelFilter,this.superChannelFilter)&&e.isEnumOf(i.PublicGroupChannelListOrder,this.order)&&e.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&e.isTypeOf("string",this.metadataKey,!0)&&e.isArrayOf("string",this.metadataValues,!0)&&e.isTypeOf("string",this.metadataValueStartsWith,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;{const t=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),n=new p(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{channels:s,token:r}=i.as(_);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return t}}throw e.SendbirdError.invalidParameters}))}}class C extends s.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserJoined=e.noop,this.onUserLeft=e.noop,this.onUserReceivedInvitation=e.noop,this.onUserDeclinedInvitation=e.noop,this.onChannelHidden=e.noop,this.onUnreadMemberStatusUpdated=e.noop,this.onUndeliveredMemberStatusUpdated=e.noop,this.onTypingStatusUpdated=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop,this.onPinnedMessageUpdated=e.noop}}class f extends C{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class y extends e.APIRequestCommand{constructor(t){const{token:n,limit:i,order:s,reverse:r,channelUrl:a,messageTypeFilter:o,scheduledStatus:l}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_SCHEDULED_MESSAGES}`,this.params=e.deundefined(e.undefineNullProps({token:n,limit:i,reverse:r,channel_url:a,order:s,message_type:o,status:l}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.scheduledMessages=[];const{next:i,scheduled_messages:s}=t;this.token=i,this.scheduledMessages=s.map((t=>n.parseMessagePayload(e,t)))}}class b extends e.BaseListQuery{constructor(t,n){var i,s,r,a,o;super(t,n),this.channelUrl=null,this.order=null,this.reverse=!1,this.scheduledStatus=null,this.messageTypeFilter=e.MessageTypeFilter.ALL,this.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,this.order=null!==(s=n.order)&&void 0!==s?s:null,this.reverse=null!==(r=n.reverse)&&void 0!==r&&r,this.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,this.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:e.MessageTypeFilter.ALL}_validate(){return super._validate()&&e.isTypeOf("string",this.channelUrl,!0)&&(e.isEnumOf(i.ScheduledMessageListOrder,this.order)||null===this.order)&&e.isTypeOf("boolean",this.reverse)&&(e.isArrayOf(n.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&e.isEnumOf(e.MessageTypeFilter,this.messageTypeFilter)}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),n=new y(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{scheduledMessages:s,token:r}=i.as(v);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class S extends e.Module{constructor(){super(...arguments),this.name="groupChannel"}init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}){super.init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}),this._manager=new t.GroupChannelManager(e,{sdkState:n,cacheContext:l,dispatcher:i,sessionManager:s,requestQueue:r,logger:a})}createGroupChannelCollection(e={}){return new c(this._iid,e)}createMyGroupChannelListQuery(e={}){return new t.GroupChannelListQuery(this._iid,e)}createPublicGroupChannelListQuery(e={}){return new m(this._iid,e)}createScheduledMessageListQuery(e={}){return new b(this._iid,e)}addGroupChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof f).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeGroupChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}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(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getChannelWithoutCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannelWithoutCache(t)}))}getMyGroupChannelChangeLogsByToken(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("string",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getMyGroupChannelChangeLogsByTimestamp(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("number",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getGroupChannelCount(n){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCountParamsDefault),n);return e.unless(t.validateGroupChannelCountParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.getGroupChannelCount(i)}))}getUnreadItemCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getUnreadItemCount(t)}))}getTotalUnreadChannelCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadChannelCount()}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadMessageCount(t)}))}getTotalScheduledMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalScheduledMessageCount(t)}))}getSubscribedTotalUnreadMessageCount(){return this._manager.getSubscribedTotalUnreadMessageCount()}getSubscribedCustomTypeTotalUnreadMessageCount(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}getSubscribedCustomTypeUnreadMessageCount(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.createChannel(i)}))}createDistinctChannelIfNotExist(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),i&&(i.isDistinct=!0),this.createChannel(i)}))}createChannelWithUserIds(n,i=!1,s,r,a="",o=""){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),{invitedUserIds:n,isDistinct:i,name:s,data:a,customType:o});return"string"==typeof r?e.coverUrl=r:e.coverImage=r,this.createChannel(e)}))}markAsReadAll(){return e.__awaiter(this,void 0,void 0,(function*(){this._manager.markAsReadAll()}))}markAsReadWithChannelUrls(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.markAsReadWithChannelUrls(t)}))}markAsDelivered(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=yield this.getChannel(t);yield n.markAsDelivered()}))}}exports.MessageEventSource=e.MessageEventSource,Object.defineProperty(exports,"MutedState",{enumerable:!0,get:function(){return e.MutedState}}),Object.defineProperty(exports,"CountPreference",{enumerable:!0,get:function(){return t.CountPreference}}),exports.DeliveryStatus=t.DeliveryStatus,exports.GroupChannel=t.GroupChannel,exports.GroupChannelEventSource=t.GroupChannelEventSource,exports.GroupChannelFilter=t.GroupChannelFilter,exports.GroupChannelListQuery=t.GroupChannelListQuery,Object.defineProperty(exports,"GroupChannelSearchField",{enumerable:!0,get:function(){return t.GroupChannelSearchField}}),Object.defineProperty(exports,"HiddenChannelFilter",{enumerable:!0,get:function(){return t.HiddenChannelFilter}}),Object.defineProperty(exports,"HiddenState",{enumerable:!0,get:function(){return t.HiddenState}}),exports.Member=t.Member,Object.defineProperty(exports,"MemberListOrder",{enumerable:!0,get:function(){return t.MemberListOrder}}),exports.MemberListQuery=t.MemberListQuery,Object.defineProperty(exports,"MemberState",{enumerable:!0,get:function(){return t.MemberState}}),Object.defineProperty(exports,"MemberStateFilter",{enumerable:!0,get:function(){return t.MemberStateFilter}}),exports.MessageCollection=t.MessageCollection,exports.MessageCollectionInitHandler=t.MessageCollectionInitHandler,Object.defineProperty(exports,"MessageCollectionInitPolicy",{enumerable:!0,get:function(){return t.MessageCollectionInitPolicy}}),Object.defineProperty(exports,"MutedMemberFilter",{enumerable:!0,get:function(){return t.MutedMemberFilter}}),Object.defineProperty(exports,"MyMemberStateFilter",{enumerable:!0,get:function(){return t.MyMemberStateFilter}}),Object.defineProperty(exports,"OperatorFilter",{enumerable:!0,get:function(){return t.OperatorFilter}}),Object.defineProperty(exports,"PublicChannelFilter",{enumerable:!0,get:function(){return t.PublicChannelFilter}}),Object.defineProperty(exports,"QueryType",{enumerable:!0,get:function(){return t.QueryType}}),Object.defineProperty(exports,"SuperChannelFilter",{enumerable:!0,get:function(){return t.SuperChannelFilter}}),Object.defineProperty(exports,"UnreadChannelFilter",{enumerable:!0,get:function(){return t.UnreadChannelFilter}}),Object.defineProperty(exports,"UnreadItemKey",{enumerable:!0,get:function(){return t.UnreadItemKey}}),exports.MessageFilter=n.MessageFilter,exports.PinnedMessage=n.PinnedMessage,exports.PinnedMessageListQuery=n.PinnedMessageListQuery,exports.ReadStatus=n.ReadStatus,Object.defineProperty(exports,"ScheduledStatus",{enumerable:!0,get:function(){return n.ScheduledStatus}}),Object.defineProperty(exports,"GroupChannelListOrder",{enumerable:!0,get:function(){return i.GroupChannelListOrder}}),Object.defineProperty(exports,"PublicGroupChannelListOrder",{enumerable:!0,get:function(){return i.PublicGroupChannelListOrder}}),Object.defineProperty(exports,"ScheduledMessageListOrder",{enumerable:!0,get:function(){return i.ScheduledMessageListOrder}}),exports.GroupChannelCollection=c,exports.GroupChannelHandler=f,exports.GroupChannelModule=S,exports.PublicGroupChannelListQuery=m,exports.ScheduledMessageListQuery=b; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-2d1d7d4f.cjs"),t=require("./lib/__bundle-90430bee.cjs"),n=require("./lib/__bundle-ccb8334d.cjs"),i=require("./lib/__bundle-f1e6fb74.cjs"),s=require("./lib/__bundle-0a504be4.cjs");require("./lib/__bundle-73351257.cjs"),require("./lib/__bundle-dae7bdf2.cjs"),require("./lib/__bundle-fdee1c40.cjs");const r={};class a{constructor({_iid:n,limit:s=100}){this.ref=0,this._iid=n,this._limit=s;const{sdkState:r,dispatcher:a,logger:o,cacheContext:l,statManager:d}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${r.userId}@groupchannel/sync.meta`;const h=(e=>`sendbird:${e}@groupchannel/sync`)(r.userId);this._sync=new t.Sync(h,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,s,a,h,u,c,p,_;const g={hasNext:!0,nextToken:""};if(yield this.loadMetadata(),o.debug("channel background sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),null===(s=this._metadata)||void 0===s?void 0:s.completed)g.hasNext=!1,g.nextToken="";else{const n={includeEmpty:!0,includeMetaData:!0,order:i.GroupChannelListOrder.CHRONOLOGICAL};try{if(n.order===i.GroupChannelListOrder.LATEST_LAST_MESSAGE)try{const t=yield l.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(r.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const s=t.GroupChannelManager.of(this._iid),{channels:d,token:u}=yield s.getMyGroupChannels(null!==(h=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==h?h:"",n,this._limit,e.CollectionEventSource.SYNC_CHANNEL_BACKGROUND);g.hasNext=d.length>=this._limit&&!!u,g.nextToken=u,this._metadata&&(this._metadata.token=u,this._metadata.range.extends(...d.map((e=>e.createdAt))),this._metadata.completed=!g.hasNext),o.debug("channel background sync progress",g),yield this.saveMetadata()}catch(t){throw o.debug("channel background sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetaData()),t}finally{d.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=l.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:null!==(_=null===(p=n.order)||void 0===p?void 0:p.toString())&&void 0!==_?_:"",collection_id:r.userId}}))}}return g})))),this._connectionEventContext=a.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return r[e]||(r[e]=new a({_iid:e})),r[e].ref++,r[e]}static clear(e){r[e]&&(r[e].close(),delete r[e])}get range(){var e,n;return null!==(n=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==n?n:new t.TimeRange({})}get completed(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:n}=e.Vault.of(this._iid),i=yield n.preference.get(this._metadataKey);this._metadata={token:i?i.token:"",range:new t.TimeRange(i?i.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!i&&i.completed}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetaData(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){var t,n;const{logger:i,sessionManager:s}=e.Vault.of(this._iid);s.session.hasSession&&(i.debug("channel background sync resume()"),this._sync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.token)&&void 0!==n?n:""))}pause(){const{logger:t}=e.Vault.of(this._iid);t.debug("channel background sync stop()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete r[this._iid])}}const o={};class l{constructor({_iid:n}){this.ref=0,this._iid=n;const{logger:i,sdkState:s,dispatcher:r,cacheContext:a,statManager:o}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${s.userId}@groupchannel/changelogs.meta`,this._subscribers=new e.EventDispatcher;const l=(e=>`sendbird:${e}@groupchannel/changelogs`)(s.userId);this._sync=new t.Sync(l,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,r,l;const d={hasNext:!0,nextToken:0};yield this.loadMetadata(),i.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token);try{const n={includeEmpty:!0,includeMetaData:!0};try{const t=yield a.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(s.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const h=t.GroupChannelManager.of(this._iid),{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}=yield h.getMyGroupChannelChangeLogs(null!==(l=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==l?l:"",n,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);this._subscribers.dispatch("progress",{updatedChannels:u,deletedChannelUrls:c,hasMore:p,token:_}),d.hasNext=p,d.nextToken=_,this._metadata&&(this._metadata.token=_),i.debug("channel changelog sync progress",d),yield this.saveMetadata(),a.localCacheEnabled&&o.put(new e.StatLog({type:e.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:u.length>0||c.length>0?"cache_miss":"cache_hit",max_db_size:u.length,use_local_cache:a.localCacheEnabled,starting_point:0,message_init_policy:c.length.toString(),collection_id:s.userId}}))}catch(t){throw i.debug("channel changelog sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetadata()),t}return d})))),this._sync.on("stop",(()=>{this._subscribers.dispatch("pause")})),this._connectionEventContext=r.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return o[e]||(o[e]=new l({_iid:e})),o[e].ref++,o[e]}static clear(e){o[e]&&(o[e].close(),delete o[e])}get isRunning(){return this._sync.isRunning}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t,firstConnectedAt:n}=e.Vault.of(this._iid),i=yield t.preference.get(this._metadataKey);this._metadata={token:i?i.token:n}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}on(e,t){return this._subscribers.on(e,t)}resume(){const{sessionManager:t}=e.Vault.of(this._iid);t.session.hasSession&&this._sync.start(0)}pause(){this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete o[this._iid])}}const d=(e,t)=>e.findIndex((e=>e.isIdentical(t))),h=(e,t,n)=>{if(e.length>0){const i=d(e,t);let s=0,r=e.length-1,a=Math.floor((s+r)/2);for(;s0)r=a,a=Math.floor((s+r)/2);else{if(!(o<0))return{place:a,oldPosition:i};s=a+1,a=Math.floor((s+r)/2)}}return{place:u(e[a],t,n)>=0?a:a+1,oldPosition:i}}return{place:e.length,oldPosition:-1}},u=(e,t,n)=>{switch(n){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(e.lastMessage&&t.lastMessage){const n=t.lastMessage.createdAt-e.lastMessage.createdAt;return 0===n?t.createdAt-e.createdAt:n}return e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt-e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:{const n=e.name.localeCompare(t.name);return 0===n?e.createdAt-t.createdAt:n}default:return 0}};class c{constructor(s,{filter:r=new t.GroupChannelFilter,order:o=i.GroupChannelListOrder.LATEST_LAST_MESSAGE,limit:d=n.DEFAULT_GROUPCHANNEL_LIMIT,includeChangesOnInitialLoad:h=!1}){this.channels=[],this._isInitialized=!1,this._iid=s,this._key=`gcc-${e.uuid()}`,this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=h,this.filter=r,this.order=o,this._hasMore=!0,this._token="",this._limit=d;const{sdkState:u,cacheContext:c,dispatcher:p}=e.Vault.of(this._iid);c.localCacheEnabled&&(this._backgroundSync=a.of(s),this._backgroundSync.resume()),this._changelogSync=l.of(s),this._changelogSync.resume();t.GroupChannelManager.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:(e,n)=>{const{source:i}=n;if(t.shouldGiveEvent(i)){const t=e.filter((e=>this.filter.match(e,u.userId))),i=e.filter((e=>!this.filter.match(e,u.userId))).map((e=>e.url));t.length>0&&this._addChannelsToView(t,n),i.length>0&&this._removeChannelsFromView(i,n)}},onRemove:(e,t)=>{this._removeChannelsFromView(e,t)}}),p.on((t=>{t instanceof e.ConnectionStateChangeCommand&&(t.stateType===e.ConnectionStateType.CONNECTED?this._isGetRemoteChannelsSucceeded||(()=>{e.__awaiter(this,void 0,void 0,(function*(){yield this._revokeLoadMore()}))})():t.stateType===e.ConnectionStateType.LOGOUT&&this.dispose())}))}get hasMore(){return!this._isDisposed&&this._hasMore}setGroupChannelCollectionHandler(e){this._handler=e}_addChannelsToView(n,s,r=!1){const a=[],o=[],l=[];for(const t of n){const n=d(this.channels,t);n>=0&&this.channels.splice(n,1);const{place:u}=h(this.channels,t,this.order);if(n<0)u===this.channels.length?!r&&this._hasMore||(a.push(t),this.channels.push(t)):(a.push(t),this.channels.splice(u,0,t));else switch(s.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&u===this.channels.length?l.push(t):(this.channels.splice(u,0,t),o.push(t));break;default:this.channels.splice(u,0,t),o.push(t)}}if(l.length>0)for(const e of l){const t=d(this.channels,e);-1!==t&&this.channels.splice(t,1)}t.shouldGiveEvent(s.source)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,t,n;a.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(s,a),o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(s,o),l.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(s,l.map((e=>e.url)))}))))}_removeChannelsFromView(n,i){const s=[];for(const e of n){const t=this.channels.findIndex((t=>t.url===e));t>=0&&(s.push(this.channels[t].url),this.channels.splice(t,1))}return t.shouldGiveEvent(i.source)&&s.length>0&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,s)})))),s}_getLocalChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.GroupChannelManager.of(this._iid),n=this.channels.length>0?((e,t)=>{var n,s,r,a;switch(t){case i.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(s=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==s?s:e.createdAt;case i.GroupChannelListOrder.CHRONOLOGICAL:return e.createdAt;case i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(a=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:e.createdAt}})(this.channels[this.channels.length-1],this.order):null;return yield e.getChannelsFromCache(n,this.filter,this.order,this._limit,n?this.channels[this.channels.length-1].url:void 0)}))}_getRemoteChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const n=t.GroupChannelManager.of(this._iid),{channels:i,token:s}=yield n.getMyGroupChannels(this._token,e.undefineNullProps(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);return this._token=s,this._hasMore=!!s,i}))}_revokeLoadMore(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._isDisposed)try{const t=yield this._getRemoteChannels();this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(t,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}catch(e){this._isGetRemoteChannelsSucceeded=!1}}))}loadMore(){var t;return e.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new e.SendbirdError({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});let n=null;this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning&&(n=yield new Promise((e=>{this._changelogSyncSubscriberContext=this._changelogSync.on("progress",(t=>e(t))).on("pause",(()=>e(null)))})),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close());const{cacheContext:i,connectionManager:s,statManager:r}=e.Vault.of(this._iid);this._isInitialized||(this._isInitialized=!0,i.localCacheEnabled&&(yield this._backgroundSync.loadMetadata()),r.put(new e.DailyRecordStatLog({type:e.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}})));let a=[];if(this._hasMore){if(!i.localCacheEnabled||s.isConnected&&!this._backgroundSync.completed)try{a=yield this._getRemoteChannels(),this._isGetRemoteChannelsSucceeded=!0}catch(e){this._isGetRemoteChannelsSucceeded=!1}else yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){a=yield this._getLocalChannels()})))),this._hasMore=a.length>=this._limit;this._addChannelsToView(a,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0)}if(n){for(const e of n.updatedChannels){const t=d(a,e);if(t>=0)a[t]=e;else{const{place:t}=h(a,e,this.order);a.splice(t,0,e)}}const e=a.map((e=>e.url));for(const t of n.deletedChannelUrls){const n=e.indexOf(t);n>=0&&(a.splice(n,1),e.splice(n,1))}}return a}))}dispose(){var e,n,i;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===(n=this._changelogSync)||void 0===n||n.close(),null===(i=this._changelogSyncSubscriberContext)||void 0===i||i.close();t.GroupChannelManager.of(this._iid).unsubscribeChannelEvent(this._key)}}class p extends e.APIRequestCommand{constructor(n){const{token:i,limit:s,order:r,includeEmpty:a,membershipFilter:o,channelNameContainsFilter:l,channelUrlsFilter:d,customTypesFilter:h,customTypeStartsWithFilter:u,superChannelFilter:c,metadataOrderKeyFilter:p,metadataKey:_,metadataValues:g,metadataValueStartsWith:m,includeFrozen:C,includeMetaData:f}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_GROUP_CHANNELS,this.params=e.deundefined(e.undefineNullProps({token:i,limit:s,order:r,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:a,public_mode:t.PublicChannelFilter.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:d,custom_types:h,custom_type_startswith:u,super_mode:c,metadata_order_key:p,metadata_key:_,metadata_values:g,metadata_value_startswith:m,show_frozen:C,show_metadata:f}))}}class _ extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:i,channels:s,ts:r}=n;this.token=i,s&&s.length>0&&(this.channels=s.map((n=>(n.ts=r,new t.GroupChannel(e,n))))),this.ts="number"==typeof r?r:0}}var g;exports.MembershipFilter=void 0,(g=exports.MembershipFilter||(exports.MembershipFilter={})).ALL="all",g.JOINED="joined";class m extends e.BaseListQuery{constructor(e,n){var s,r,a,o,l,d,h,u,c,p,_,g,m,C;super(e,n),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=t.SuperChannelFilter.ALL,this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=i.PublicGroupChannelListOrder.CHRONOLOGICAL,this.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,this.customTypesFilter=null!==(l=n.customTypesFilter)&&void 0!==l?l:null,this.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,this.channelNameContainsFilter=null!==(h=n.channelNameContainsFilter)&&void 0!==h?h:null,this.membershipFilter=null!==(u=n.membershipFilter)&&void 0!==u?u:exports.MembershipFilter.ALL,this.superChannelFilter=null!==(c=n.superChannelFilter)&&void 0!==c?c:t.SuperChannelFilter.ALL,this.metadataKey=null!==(p=n.metadataKey)&&void 0!==p?p:null,this.metadataValues=null!==(_=n.metadataValues)&&void 0!==_?_:null,this.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,this.metadataValueStartsWith=null!==(m=n.metadataValueStartsWith)&&void 0!==m?m:null,this.order=null!==(C=n.order)&&void 0!==C?C:i.PublicGroupChannelListOrder.CHRONOLOGICAL}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.channelNameContainsFilter,!0)&&e.isArrayOf("string",this.channelUrlsFilter,!0)&&e.isArrayOf("string",this.customTypesFilter,!0)&&e.isTypeOf("string",this.customTypeStartsWithFilter,!0)&&e.isEnumOf(exports.MembershipFilter,this.membershipFilter)&&e.isEnumOf(t.SuperChannelFilter,this.superChannelFilter)&&e.isEnumOf(i.PublicGroupChannelListOrder,this.order)&&e.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&e.isTypeOf("string",this.metadataKey,!0)&&e.isArrayOf("string",this.metadataValues,!0)&&e.isTypeOf("string",this.metadataValueStartsWith,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;{const t=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),n=new p(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{channels:s,token:r}=i.as(_);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return t}}throw e.SendbirdError.invalidParameters}))}}class C extends s.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserJoined=e.noop,this.onUserLeft=e.noop,this.onUserReceivedInvitation=e.noop,this.onUserDeclinedInvitation=e.noop,this.onChannelHidden=e.noop,this.onUnreadMemberStatusUpdated=e.noop,this.onUndeliveredMemberStatusUpdated=e.noop,this.onTypingStatusUpdated=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop,this.onPinnedMessageUpdated=e.noop}}class f extends C{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class y extends e.APIRequestCommand{constructor(t){const{token:n,limit:i,order:s,reverse:r,channelUrl:a,messageTypeFilter:o,scheduledStatus:l}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_SCHEDULED_MESSAGES}`,this.params=e.deundefined(e.undefineNullProps({token:n,limit:i,reverse:r,channel_url:a,order:s,message_type:o,status:l}))}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t),this.scheduledMessages=[];const{next:i,scheduled_messages:s}=t;this.token=i,this.scheduledMessages=s.map((t=>n.parseMessagePayload(e,t)))}}class b extends e.BaseListQuery{constructor(t,n){var i,s,r,a,o;super(t,n),this.channelUrl=null,this.order=null,this.reverse=!1,this.scheduledStatus=null,this.messageTypeFilter=e.MessageTypeFilter.ALL,this.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,this.order=null!==(s=n.order)&&void 0!==s?s:null,this.reverse=null!==(r=n.reverse)&&void 0!==r&&r,this.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,this.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:e.MessageTypeFilter.ALL}_validate(){return super._validate()&&e.isTypeOf("string",this.channelUrl,!0)&&(e.isEnumOf(i.ScheduledMessageListOrder,this.order)||null===this.order)&&e.isTypeOf("boolean",this.reverse)&&(e.isArrayOf(n.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&e.isEnumOf(e.MessageTypeFilter,this.messageTypeFilter)}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),n=new y(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{scheduledMessages:s,token:r}=i.as(v);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class S extends e.Module{constructor(){super(...arguments),this.name="groupChannel"}init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}){super.init(e,{sdkState:n,dispatcher:i,sessionManager:s,requestQueue:r,logger:a,onlineDetector:o,cacheContext:l}),this._manager=new t.GroupChannelManager(e,{sdkState:n,cacheContext:l,dispatcher:i,sessionManager:s,requestQueue:r,logger:a})}createGroupChannelCollection(e={}){return new c(this._iid,e)}createMyGroupChannelListQuery(e={}){return new t.GroupChannelListQuery(this._iid,e)}createPublicGroupChannelListQuery(e={}){return new m(this._iid,e)}createScheduledMessageListQuery(e={}){return new b(this._iid,e)}addGroupChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof f).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeGroupChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}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(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getChannelWithoutCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannelWithoutCache(t)}))}getMyGroupChannelChangeLogsByToken(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("string",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getMyGroupChannelChangeLogsByTimestamp(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("number",n)&&t.validateGroupChannelChangeLogsParams(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,s)}))}getGroupChannelCount(n){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCountParamsDefault),n);return e.unless(t.validateGroupChannelCountParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.getGroupChannelCount(i)}))}getUnreadItemCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getUnreadItemCount(t)}))}getTotalUnreadChannelCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadChannelCount()}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadMessageCount(t)}))}getTotalScheduledMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalScheduledMessageCount(t)}))}getSubscribedTotalUnreadMessageCount(){return this._manager.getSubscribedTotalUnreadMessageCount()}getSubscribedCustomTypeTotalUnreadMessageCount(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}getSubscribedCustomTypeUnreadMessageCount(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.createChannel(i)}))}createDistinctChannelIfNotExist(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),i&&(i.isDistinct=!0),this.createChannel(i)}))}createChannelWithUserIds(n,i=!1,s,r,a="",o=""){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),{invitedUserIds:n,isDistinct:i,name:s,data:a,customType:o});return"string"==typeof r?e.coverUrl=r:e.coverImage=r,this.createChannel(e)}))}markAsReadAll(){return e.__awaiter(this,void 0,void 0,(function*(){this._manager.markAsReadAll()}))}markAsReadWithChannelUrls(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.markAsReadWithChannelUrls(t)}))}markAsDelivered(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=yield this.getChannel(t);yield n.markAsDelivered()}))}}exports.MessageEventSource=e.MessageEventSource,Object.defineProperty(exports,"MutedState",{enumerable:!0,get:function(){return e.MutedState}}),Object.defineProperty(exports,"CountPreference",{enumerable:!0,get:function(){return t.CountPreference}}),exports.DeliveryStatus=t.DeliveryStatus,exports.GroupChannel=t.GroupChannel,exports.GroupChannelEventSource=t.GroupChannelEventSource,exports.GroupChannelFilter=t.GroupChannelFilter,exports.GroupChannelListQuery=t.GroupChannelListQuery,Object.defineProperty(exports,"GroupChannelSearchField",{enumerable:!0,get:function(){return t.GroupChannelSearchField}}),Object.defineProperty(exports,"HiddenChannelFilter",{enumerable:!0,get:function(){return t.HiddenChannelFilter}}),Object.defineProperty(exports,"HiddenState",{enumerable:!0,get:function(){return t.HiddenState}}),exports.Member=t.Member,Object.defineProperty(exports,"MemberListOrder",{enumerable:!0,get:function(){return t.MemberListOrder}}),exports.MemberListQuery=t.MemberListQuery,Object.defineProperty(exports,"MemberState",{enumerable:!0,get:function(){return t.MemberState}}),Object.defineProperty(exports,"MemberStateFilter",{enumerable:!0,get:function(){return t.MemberStateFilter}}),exports.MessageCollection=t.MessageCollection,exports.MessageCollectionInitHandler=t.MessageCollectionInitHandler,Object.defineProperty(exports,"MessageCollectionInitPolicy",{enumerable:!0,get:function(){return t.MessageCollectionInitPolicy}}),Object.defineProperty(exports,"MutedMemberFilter",{enumerable:!0,get:function(){return t.MutedMemberFilter}}),Object.defineProperty(exports,"MyMemberStateFilter",{enumerable:!0,get:function(){return t.MyMemberStateFilter}}),Object.defineProperty(exports,"OperatorFilter",{enumerable:!0,get:function(){return t.OperatorFilter}}),Object.defineProperty(exports,"PublicChannelFilter",{enumerable:!0,get:function(){return t.PublicChannelFilter}}),Object.defineProperty(exports,"QueryType",{enumerable:!0,get:function(){return t.QueryType}}),Object.defineProperty(exports,"SuperChannelFilter",{enumerable:!0,get:function(){return t.SuperChannelFilter}}),Object.defineProperty(exports,"UnreadChannelFilter",{enumerable:!0,get:function(){return t.UnreadChannelFilter}}),Object.defineProperty(exports,"UnreadItemKey",{enumerable:!0,get:function(){return t.UnreadItemKey}}),exports.MessageFilter=n.MessageFilter,exports.PinnedMessage=n.PinnedMessage,exports.PinnedMessageListQuery=n.PinnedMessageListQuery,exports.ReadStatus=n.ReadStatus,Object.defineProperty(exports,"ScheduledStatus",{enumerable:!0,get:function(){return n.ScheduledStatus}}),Object.defineProperty(exports,"GroupChannelListOrder",{enumerable:!0,get:function(){return i.GroupChannelListOrder}}),Object.defineProperty(exports,"PublicGroupChannelListOrder",{enumerable:!0,get:function(){return i.PublicGroupChannelListOrder}}),Object.defineProperty(exports,"ScheduledMessageListOrder",{enumerable:!0,get:function(){return i.ScheduledMessageListOrder}}),exports.GroupChannelCollection=c,exports.GroupChannelHandler=f,exports.GroupChannelModule=S,exports.PublicGroupChannelListQuery=m,exports.ScheduledMessageListQuery=b; diff --git a/cjs/index.cjs b/cjs/index.cjs index 4da2e74..3d3564a 100644 --- a/cjs/index.cjs +++ b/cjs/index.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),t=require("./message.cjs"),s=require("./poll.cjs"),n=require("./lib/__bundle-4bcf4070.cjs"),i=require("./lib/__bundle-0f6b8ff3.cjs"),r=require("./lib/__bundle-d1419fd1.cjs"),o=require("./lib/__bundle-05f697db.cjs");require("./lib/__bundle-d349e14c.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class a{constructor(e){this.key=e.key,this.url=e.url}}class d{constructor(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((e=>new a(e))):[]}}class u{constructor(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((e=>new d(e))):[]}}class c{constructor(){this.onConnected=e.noop,this.onReconnectStarted=e.noop,this.onReconnectSucceeded=e.noop,this.onReconnectFailed=e.noop,this.onDisconnected=e.noop}}class l extends c{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class h{constructor(){this.onSessionExpired=e.noop,this.onSessionTokenRequired=e=>e(null),this.onSessionError=e.noop,this.onSessionRefreshed=e.noop,this.onSessionClosed=e.noop}}class p extends h{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class _{constructor(){this.onFriendsDiscovered=e.noop,this.onTotalUnreadMessageCountChanged=e.noop,this.onTotalUnreadMessageCountUpdated=e.noop}}class f extends _{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class m extends e.APIRequestCommand{constructor({limit:t,token:s,userIdsFilter:n,metaDataKeyFilter:i,metaDataValuesFilter:r,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:i,metadatavalues_in:r,nickname_startswith:o})}}class g 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 v extends e.BaseListQuery{constructor(e,t){var s,n,i;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!==(i=t.metaDataValuesFilter)&&void 0!==i?i: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.nicknameStartsWithFilter,!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 m(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),n=yield t.send(s),{users:i,next:r}=n.as(g);return this._token=r,this._hasNext=!!r,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}class y extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n,userIdsFilter:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/block`,this.params=e.deundefined({limit:s,token:n,user_ids:i})}}class S 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 I 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 y(e.undefineNullProps(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token}))),i=yield s.send(n),{users:r,next:o}=i.as(S);return this._token=o,this._hasNext=!!o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}class P 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 C 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 E 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 P(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token})),i=yield s.send(n),{users:r,hasMore:o,next:a}=i.as(C);return this._token=a,this._hasNext=o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}const b=2097152;class T extends n.BaseStore{constructor(t){var{AsyncStorage:s,itemSizeLimit:n=b}=t,i=e.__rest(t,["AsyncStorage","itemSizeLimit"]);super(Object.assign(Object.assign({},i),{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 n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){const t=Object.create(null,{clear:{get:()=>super.clear}});return e.__awaiter(this,void 0,void 0,(function*(){yield t.clear.call(this);const e=yield this.getAllKeys();yield this.removeMany(e)}))}}class A extends n.BaseStore{constructor(e){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:6291456})),this._mmkv=e.MMKV}_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._mmkv.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._mmkv.getString(this._getActualKey(t));return e?JSON.parse(e):null}))}_setRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t){const{key:t,data:s}=e;s.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(t),JSON.stringify(e))}}))}_removeRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t)this._mmkv.delete(this._getActualKey(e))}))}checkAvailability(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._mmkv)throw n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){const t=Object.create(null,{clear:{get:()=>super.clear}});return e.__awaiter(this,void 0,void 0,(function*(){yield t.clear.call(this);const e=yield this.getAllKeys();yield this.removeMany(e)}))}}const w={profileImage:void 0,profileUrl:void 0,nickname:void 0},k=t=>(s,o)=>e.__awaiter(void 0,void 0,void 0,(function*(){switch(s){case 1:case 2:case 3:case 4:default:o();break;case 5:yield t.reset(),o();break;case 6:try{const{v2:s,v3:o,v4:a}=(t=>({v2:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_GROUPCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_GROUPCHANNEL_COLLECTION_KEY,index:[i.getGroupChannelIndexBy(i.GroupChannelListOrder.LATEST_LAST_MESSAGE),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHRONOLOGICAL),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:n.NESTDB_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_POLL_COLLECTION_NAME,keyName:n.NESTDB_POLL_COLLECTION_KEY}])})),v3:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_FEEDCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_FEEDCHANNEL_COLLECTION_KEY,index:[r.getFeedChannelIndexBy("latest_last_message")]}])})),v4:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_NOTIFICATION_COLLECTION_NAME,keyName:n.NESTDB_NOTIFICATION_COLLECTION_KEY,index:[n.getNotificationMessageIndexBy()]}])}))}))(t);yield s(),yield o(),yield a();const d=t.collection(n.NESTDB_MESSAGE_COLLECTION_NAME);yield d.removeIf({where:{channelType:e.ChannelType.OPEN}})}catch(e){}o()}})),O=()=>"undefined"!=typeof document?document.visibilityState:"visible";class R extends e.EventDispatcher{constructor({getVisibilityState:e=O,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 U{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 D extends e.APIRequestCommand{constructor({userId:t,nickname:s,profileUrl:n,profileImage:i,preferredLanguages:r}){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:i,preferred_languages:r}))}}class M extends e.APIResponseCommand{constructor(t,s){super(t,s),this.user=new e.User(t,Object.assign({},s))}}class x extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`,this.params=e.deundefined({apns_device_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class N extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`,this.params=e.deundefined({gcm_reg_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class L 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 q 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 V extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`}}class $ extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`}}class H extends e.APIRequestCommand{constructor({userId:t,type:s,token:n,ts:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/${encodeURIComponent(s)}/device_tokens`,this.params={created_ts:i,token:n}}}class F 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 j extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`}}class K extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class z 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 Q extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class B extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class G 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 W extends e.APIRequestCommand{constructor({userId:t,doNotDisturbOn:s,startHour:n,startMin:i,endHour:r,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:i,end_hour:r,end_min:o,timezone:a}}}class J 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 Y extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class X 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 Z extends e.APIRequestCommand{constructor({userId:t,snoozeOn:s,startTs:n,endTs:i}){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:i}}}class ee 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 te 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 se 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 ne extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class ie extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class re 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 oe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class ae extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`}}class de extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class ue 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 ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class le 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 he 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 pe 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 _e extends e.APIResponseCommand{constructor(e,t){super(e,t),this.friendDiscoveryRequestId=t.friend_discovery_request_id}}class fe 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 me 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 ge extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s)))}}class ve 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 ye 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 Se extends e.APIResponseCommand{constructor(e,t){super(e,t),this.allowFriendDiscovery=t.allow_friend_discovery}}class Ie 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 Pe extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_EMOJI_CATEGORIES}}class Ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiContainer=new u(t)}}class Ee extends e.APIRequestCommand{constructor({categoryId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJI_CATEGORIES}/${t}`}}class be extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiCategory=new d(t)}}class Te extends e.APIRequestCommand{constructor({key:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJIS}/${t}`}}class Ae extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emoji=new a(t)}}class we extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_UIKIT_CONFIGURATION}`}}class ke 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}}var Oe;!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(Oe||(Oe={}));class Re extends e.APIRequestCommand{constructor({deviceToken:t,pushTrackingId:s,messageId:n,allowedPushNotification:i,channelKey:r,templateKey:o,eventType:a,notificationEventDeadline:d}){super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_PUSH_DELIVERY,this.params=e.deundefined({device_token:t,push_tracking_id:s,message_id:n,allowed_push_notification:i,channel_key:r,template_key:o,event_type:a,notification_event_deadline:d})}}let Ue;class De{constructor(t,s,n){this._storeInitialized=!1,this._iid=t,this.options=s;const{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,userEventHandlers:h,appStateToggleEnabled:p}=e.Vault.of(t);this._onlineDetector=new U({logger:l,connectionDelegate:{reconnect:()=>e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,connectionManager:n,sessionManager:i}=e.Vault.of(t);if(i.session.hasSession){if("foreground"===s.appState)try{yield n.resetAndReconnect()}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("resetAndReconnect failed by reconnect event = ",t)}}else try{yield n.connect(i.session.authToken)}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("connect failed by reconnect event = ",t)}d.dispatch(new r.NotificationCollectionRefreshCommand)})),disconnect:()=>{e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s}=e.Vault.of(t);yield s.disconnect()}))))}}});const _=new i.AutoResendManager(t,{localCacheEnabled:a.localCacheEnabled,enableAutoResend:a.localCacheConfig.enableAutoResend,dispatcher:d,sdkState:o,logger:l});n.forEach((e=>{e.init(t,{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,onlineDetector:this._onlineDetector}),this[e.name]=e})),this._appStateChangeDetector=new R({isEnabled:p}),this._appStateChangeDetector.on("resume",(()=>{l.debug("the page resumes from freeze"),this.setForegroundState()})).on("pause",(()=>{l.debug("the page freezes"),this.setBackgroundState()})),d.on((s=>{var n;if(s instanceof e.ConnectionStateChangeCommand){if(s.stateType===e.ConnectionStateType.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(s instanceof e.WebSocketEventCommand)switch(s.code){case"USEV":{const{event:n}=s.as(i.UserEventCommand);switch(n.category){case i.UserEventCategory.FRIEND_DISCOVERED:{const{friendDiscoveries:s}=i.UserEvent.getDataAsFriendDiscoveredEvent(t,n);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.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 i=s.ts;"number"==typeof i&&i>t.ts&&(t.all!==s.all&&(n=!0),t.all=s.all>=0?s.all:0,s.customTypes&&Object.keys(s.customTypes).forEach((e=>{t.customTypes[e]!==s.customTypes[e]&&(n=!0),t.customTypes[e]=s.customTypes[e]})),n=n&&t.ts>0,t.ts=i),n&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.forEach((e=>{e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:t.all,feedChannelCount:t.feed,customTypeUnreadCount:t.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(t.all,t.customTypes)}))}))))}else s instanceof e.UserProfileUpdateCommand?(a.preference.set(this._getUserProfileCacheKey(o.userId),e.UserProfile.payloadify(s.userProfile)),(null===(n=s.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&a.preference.set(e.createChangelogIncludeChatNotificationsCacheKey(this.appId),{value:!0})):s instanceof e.SessionExpiredCommand&&s.error&&s.error.isSessionInvalidatedError&&(l.debug("session revoked."),this._internalDisconnect(s.error))}))}static init(i){const{appId:r,appVersion:o,modules:a=[],options:d=new e.SendbirdChatOptions,debugMode:u=!1,customApiHost:c,customWebSocketHost:l,newInstance:h=!1,logLevel:p,localCacheEnabled:_=!1,localCacheConfig:f=new e.LocalCacheConfig,localCacheEncryption:m,useAsyncStorageStore:g=null,useMMKVStorageStore:v=null,appStateToggleEnabled:y=!0}=i;if(!Ue||h){const i=`su-${e.uuid()}`,h=null!=m?m:{encrypt:e=>e,decrypt:e=>e},S=new n.Logger;S.level=null!=p?p:n.LogLevel.WARN;let I=new n.MemoryStore({encryption:h});u||(e.isReactNative()?v?I=new A({MMKV:v,encryption:h}):g&&(I=new T({AsyncStorage:g,encryption:h}),S.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):I=new n.IndexedDbStore({encryption:h})),new e.Vault(i,{appId:r,appVersion:o,options:d,apiHost:null!=c?c:`https://api-${r}.sendbird.com`,websocketHost:null!=l?l:`wss://ws-${r}.sendbird.com`,store:I,encryption:h,logger:S,localCacheEnabled:_,localCacheConfig:f,debugMode:u,appStateToggleEnabled:y});const P=[new t.MessageModule,new s.PollModule],C=new De(i,d,[...a,...P]);return Ue||(Ue=C),C}return Ue}static get instance(){return Ue}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}_getNestDBVersion(){return 7}_getPreferenceCacheKey(e){return`sendbird@${this.appId}/${e}.pref`}_getUserProfileCacheKey(e){return`sendbird@${this.appId}/${e}.profile`}_internalDisconnect(t){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),yield s.logout(t),yield this.clearCachedData(),n.appState="foreground"}))}getMemoryStoreForDebugging(){const{debugMode:t,cacheContext:s}=e.Vault.of(this._iid);if(t)return s.store instanceof n.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)}addSendbirdExtensions(t,s,n){const{logger:i,sdkState:r}=e.Vault.of(this._iid),o=new RegExp(e.SEMVER_REGEX_STRING);if(0===t.length)return i.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(t.find((e=>!o.test(e.version))))return i.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(const[e,t]of Object.entries(n))if(/&|=/.test(e)||/&|=/.test(t))return i.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1;return r.sendbirdRuntimeEnvironment={sendbirdExtensions:t,deviceOS:s,customData:n},!0}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 n.MemoryStore),yield this._safeInitializeStore(t)}}))}setLocaleForChatbot(t){const{sdkState:s}=e.Vault.of(this._iid),n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(t.trim());n&&(s.localeForChatbot=n)}initializeCache(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:r,dispatcher:o,logger:a}=e.Vault.of(this._iid);if(!s.userId||s.userId!==t){const d=`sendbird@${s.appId}/${t}.db`;try{if(r.localCacheEnabled){if(r.nestdb&&r.nestdb.state!==n.NestDBState.CLOSED&&r.nestdb.name===d)yield this._safeInitializeStore(d);else{const e=`sendbird@${s.appId}/${t}.db`,a=r.nestdb=new n.NestDB({name:e,version:this._getNestDBVersion(),store:r.store,config:new n.Config({dbname:e,itemSizeLimit:61440})});a.on("upgrade",k(a)),a.on("storeReplaced",(e=>{r.replaceStore(e),r.localCacheEnabled=!1,a.on("upgrade",k(a))})),yield a.open(),this._storeInitialized=!0,o.dispatch(new i.DatabaseOpenCommand(this._iid,{userId:t}))}s.userId=t}else yield this._safeInitializeStore(d),s.userId=t}catch(i){throw a.warn("Nest DB Open Failed. ",i),r.store instanceof n.MemoryStore||(r.replaceStore(new n.MemoryStore),r.localCacheEnabled=!1),yield this._safeInitializeStore(d),s.userId=t,e.SendbirdError.databaseError}finally{yield this._setupPreference(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=n.MessageCache.of(this._iid),i=n.UnsentMessageCache.of(this._iid);s&&i&&(yield Promise.all(t.map((t=>e.__awaiter(this,void 0,void 0,(function*(){yield s.removeMessagesOfChannel(t),yield i.removeMessagesOfChannel(t)}))))))}))}_setupPreference(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:n,statManager:i}=e.Vault.of(this._iid);yield n.preference.init(this._getPreferenceCacheKey(t),this._getNestDBVersion());const r=yield n.preference.get(this._getUserProfileCacheKey(t));if(r){new e.UserProfile(this._iid,r).apply()}yield i.init(`sendbird@${s.appId}/${t}.statlog`)}))}_ready(t,s,n={}){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:r,cacheContext:o,connectionManager:a}=e.Vault.of(this._iid),{errorForOtherUser:d}=n;if(r.userId&&r.userId!==t){if(d)throw d;yield a.logout()}try{yield this.initializeCache(t);const{dispatcher:s}=e.Vault.of(this._iid);s.dispatch(new i.ReduceDBSizeEventCommand)}catch(t){const{logger:s}=e.Vault.of(this._iid);o.localCacheEnabled=!1,s.warn("Cache initialization failed - cache is not available.")}}))}authenticateFeed(t,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.authenticate(t,s)}))}authenticate(t,s){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{sessionManager:i,connectionManager:r}=e.Vault.of(this._iid);if(yield this._ready(t,s,{errorForOtherUser:r.isConnected?e.SendbirdError.alreadyConnectedAsAnotherUser:void 0}),!(null===(n=i.session.services)||void 0===n?void 0:n.includes(e.SessionService.CHAT))){if(!s&&!i.handler){const e=new p;this.setSessionHandler(e)}yield i.authenticate(t,s)}return this.currentUser}))}connect(t,s){return e.__awaiter(this,void 0,void 0,(function*(){yield this._ready(t,s);try{const{connectionManager:t}=e.Vault.of(this._iid);yield t.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),i=n.session.hasSession;return i&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((()=>{s.appState="foreground"})).catch((()=>{}))),i}disconnect(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._internalDisconnect()}))}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(!0)}))}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().catch((e=>{n.debug("setBackgroundState error = ",e)})))}setForegroundState(){const{connectionManager:t,sdkState:s,dispatcher:n,logger:i}=e.Vault.of(this._iid);"background"===s.appState&&(s.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((e=>{i.debug("setForgroundState error = ",e)})),n.dispatch(new r.NotificationCollectionRefreshCommand))}setSessionHandler(t){e.unless(t instanceof p).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 f).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 l).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 v(this._iid,e)}createBlockedUserListQuery(e={}){return new I(this._iid,e)}createFriendListQuery(e={}){return new E(this._iid,e)}createMessageSearchQuery(e){return new n.MessageSearchQuery(this._iid,e)}createPollListQuery(t){return new e.PollListQuery(this._iid,Object.assign({},t))}createPollVoterListQuery(t){return new e.PollVoterListQuery(this._iid,Object.assign({},t))}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({},w),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),i=new D(Object.assign({userId:t.userId},s)),r=yield n.send(i),{user:o}=r.as(M);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),i=new D({userId:s.userId,preferredLanguages:t}),r=yield n.send(i),{user:o}=r.as(M);return this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),o}throw e.SendbirdError.connectionRequired}))}registerFCMPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.ANDROID}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.FCM,t))return e.PushTokenRegistrationState.SUCCESS;const o=new N({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.FCM,t,r),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:i}=e.Vault.of(this._iid),r=new q({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new $({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.FCM),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}registerAPNSPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.IOS}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.APNS,t))return e.PushTokenRegistrationState.SUCCESS;const o=new x({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.APNS,t,r),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:i}=e.Vault.of(this._iid),r=new L({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new V({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.APNS),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}markPushNotificationAsDelivered(t,s=!0){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:i,sessionManager:r,requestQueue:o,pushNotificationAckManager:a}=e.Vault.of(this._iid);i.debug("markPushNotificationAsDelivered:",t);const d=Oe.DELIVERED,{pushTrackingId:u,sessionTopics:c,sessionKey:l,messageId:h,channelKey:p,templateKey:_,notificationEventDeadline:f}=a.parseData(t);if(!l)throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(!c.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(a.isAcked(u,d))return void i.info("already delivered push notification:",u);const m=Boolean(p),g=s&&m,v=null===(n=r.deviceTokens[0])||void 0===n?void 0:n.token,y=new Re({deviceToken:null!=v?v:"",pushTrackingId:u,eventType:d,messageId:h,channelKey:p,templateKey:_,notificationEventDeadline:f,allowedPushNotification:g});l&&(y.headers["Session-Key"]=l);try{yield o.send(y),a.markAsAcked(u,d)}catch(e){throw i.debug(`failed to mark push notification as delivered. push tracking id: ${u}. error: ${e}`),e}}))}markPushNotificationAsClicked(t){var s;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:n,sessionManager:i,requestQueue:r,pushNotificationAckManager:o}=e.Vault.of(this._iid);n.debug("markPushNotificationAsClicked:",t);const a=Oe.CLICKED,{pushTrackingId:d,sessionTopics:u,sessionKey:c,messageId:l,channelKey:h,templateKey:p,notificationEventDeadline:_}=o.parseData(t);if(!c)throw n.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(!u.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw n.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(o.isAcked(d,a))return void n.info("already clicked push notification:",d);const f=null===(s=i.deviceTokens[0])||void 0===s?void 0:s.token,m=new Re({deviceToken:null!=f?f:"",pushTrackingId:d,eventType:a,messageId:l,channelKey:h,templateKey:p,notificationEventDeadline:_});c&&(m.headers["Session-Key"]=c);try{yield r.send(m),o.markAsAcked(d,a)}catch(e){throw n.debug(`failed to mark push notification as clicked. push tracking id: ${d}. error: ${e}`),e}}))}getChannelInvitationPreference(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new j({userId:t.userId}),i=yield s.send(n),{autoAccept:r}=i.as(K);return{autoAccept:r}}))}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),i=new z({userId:s.userId,willAutoAccept:t}),r=yield n.send(i),{autoAccept:o}=r.as(Q);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 B({userId:t.userId}),i=yield s.send(n),{preference:r}=i.as(G);return r}))}setDoNotDisturb(t,s=0,n=0,i=0,r=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",i)&&e.isTypeOf("number",r)&&e.isTypeOf("string",o)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:d}=e.Vault.of(this._iid),u=new W({userId:a.userId,doNotDisturbOn:t,startHour:s,startMin:n,endHour:i,endMin:r,timezone:o}),c=yield d.send(u),{preference:l}=c.as(J);return l}))}getSnoozePeriod(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new Y({userId:t.userId}),i=yield s.send(n),{snoozePeriod:r}=i.as(X);return r}))}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:i,requestQueue:r}=e.Vault.of(this._iid),o=new Z({userId:i.userId,snoozeOn:t,startTs:s,endTs:n}),a=yield r.send(o),{snoozePeriod:d}=a.as(ee);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:i,sessionManager:r}=e.Vault.of(this._iid),o=new H({userId:n.userId,type:s,token:t}),a=yield i.send(o),{pushTokens:d}=a.as(F);for(const e of d.deviceTokens)r.setDeviceToken(d.type,e);return yield r.saveDeviceToken(),d}))}getPushTriggerOption(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ne({userId:t.userId});return(yield s.send(n)).as(ie).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),i=new re({userId:s.userId,pushTriggerOption:t});return(yield n.send(i)).as(oe).pushTriggerOption}))}getPushTemplate(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ae({userId:t.userId});return(yield s.send(n)).as(de).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),i=new ue({userId:s.userId,templateName:t});return(yield n.send(i)).as(ce).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),i=new te({userId:s.userId,blockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new se({userId:s.userId,unblockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new le({userId:s.userId,token:t}),r=yield n.send(i),{changelogs:o}=r.as(he);return o}))}getAllowFriendDiscovery(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ye({userId:t.userId}),i=yield s.send(n),{allowFriendDiscovery:r}=i.as(Se);return r}))}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),i=new Ie({userId:s.userId,allowFriendDiscovery:t});return yield n.send(i),t}))}uploadFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),i=new pe({userId:s.userId,discoveries:t}),r=yield n.send(i),{friendDiscoveryRequestId:o}=r.as(_e);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),i=new fe({userId:s.userId,discoveryKeys:t});yield n.send(i)}))}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),i=new me({userId:s.userId,userIds:t}),r=yield n.send(i),{users:o}=r.as(ge);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),i=new ve({userId:s.userId,userIds:t});yield n.send(i)}))}getAllEmoji(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),s=new Pe,n=yield t.send(s),{emojiContainer:i}=n.as(Ce);return i}))}getEmojiCategory(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Ee({categoryId:t}),i=yield s.send(n),{emojiCategory:r}=i.as(be);return r}))}getEmoji(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Te({key:t}),i=yield s.send(n),{emoji:r}=i.as(Ae);return r}))}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 we,i=yield s.send(n),{uikitConfiguration:r}=i.as(ke);return r}))}}exports.AppInfo=e.AppInfo,exports.CachedChannelInfo=e.CachedChannelInfo,Object.defineProperty(exports,"CachedDataClearOrder",{enumerable:!0,get:function(){return e.CachedDataClearOrder}}),Object.defineProperty(exports,"ChannelType",{enumerable:!0,get:function(){return e.ChannelType}}),Object.defineProperty(exports,"CollectionEventSource",{enumerable:!0,get:function(){return e.CollectionEventSource}}),Object.defineProperty(exports,"ConnectionState",{enumerable:!0,get:function(){return e.ConnectionState}}),Object.defineProperty(exports,"DeviceOsPlatform",{enumerable:!0,get:function(){return e.DeviceOsPlatform}}),Object.defineProperty(exports,"LastMessageThreadingPolicy",{enumerable:!0,get:function(){return e.LastMessageThreadingPolicy}}),exports.LocalCacheConfig=e.LocalCacheConfig,exports.NotificationInfo=e.NotificationInfo,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,Object.defineProperty(exports,"SendbirdErrorCode",{enumerable:!0,get:function(){return e.SendbirdErrorCode}}),Object.defineProperty(exports,"SendbirdPlatform",{enumerable:!0,get:function(){return e.SendbirdPlatform}}),Object.defineProperty(exports,"SendbirdProduct",{enumerable:!0,get:function(){return e.SendbirdProduct}}),exports.UIKitConfigInfo=e.UIKitConfigInfo,Object.defineProperty(exports,"UnreadCountThreadingPolicy",{enumerable:!0,get:function(){return e.UnreadCountThreadingPolicy}}),exports.User=e.User,Object.defineProperty(exports,"UserOnlineState",{enumerable:!0,get:function(){return e.UserOnlineState}}),exports.BannedUserListQuery=n.BannedUserListQuery,exports.BaseChannel=n.BaseChannel,Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return n.LogLevel}}),exports.MemoryStore=n.MemoryStore,exports.MutedUserListQuery=n.MutedUserListQuery,exports.OperatorListQuery=n.OperatorListQuery,exports.Plugin=n.Plugin,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.Participant=o.Participant,exports.ApplicationUserListQuery=v,exports.BlockedUserListQuery=I,exports.ConnectionHandler=l,exports.Emoji=a,exports.EmojiCategory=d,exports.EmojiContainer=u,exports.FriendListQuery=E,exports.SessionHandler=p,exports.UserEventHandler=f,exports.default=De; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-2d1d7d4f.cjs"),t=require("./message.cjs"),s=require("./poll.cjs"),n=require("./lib/__bundle-ccb8334d.cjs"),i=require("./lib/__bundle-f1e6fb74.cjs"),r=require("./lib/__bundle-785dde28.cjs"),o=require("./lib/__bundle-3d28c10f.cjs");require("./lib/__bundle-fdee1c40.cjs"),require("./lib/__bundle-dae7bdf2.cjs");class a{constructor(e){this.key=e.key,this.url=e.url}}class d{constructor(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((e=>new a(e))):[]}}class u{constructor(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((e=>new d(e))):[]}}class c{constructor(){this.onConnected=e.noop,this.onReconnectStarted=e.noop,this.onReconnectSucceeded=e.noop,this.onReconnectFailed=e.noop,this.onDisconnected=e.noop}}class l extends c{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class h{constructor(){this.onSessionExpired=e.noop,this.onSessionTokenRequired=e=>e(null),this.onSessionError=e.noop,this.onSessionRefreshed=e.noop,this.onSessionClosed=e.noop}}class p extends h{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class _{constructor(){this.onFriendsDiscovered=e.noop,this.onTotalUnreadMessageCountChanged=e.noop,this.onTotalUnreadMessageCountUpdated=e.noop}}class f extends _{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class m extends e.APIRequestCommand{constructor({limit:t,token:s,userIdsFilter:n,metaDataKeyFilter:i,metaDataValuesFilter:r,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:i,metadatavalues_in:r,nickname_startswith:o})}}class g 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 v extends e.BaseListQuery{constructor(e,t){var s,n,i;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!==(i=t.metaDataValuesFilter)&&void 0!==i?i: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.nicknameStartsWithFilter,!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 m(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),n=yield t.send(s),{users:i,next:r}=n.as(g);return this._token=r,this._hasNext=!!r,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}class y extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n,userIdsFilter:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/block`,this.params=e.deundefined({limit:s,token:n,user_ids:i})}}class S 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 I 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 y(e.undefineNullProps(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token}))),i=yield s.send(n),{users:r,next:o}=i.as(S);return this._token=o,this._hasNext=!!o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}class P 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 C 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 E 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 P(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token})),i=yield s.send(n),{users:r,hasMore:o,next:a}=i.as(C);return this._token=a,this._hasNext=o,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}const b=2097152;class T extends n.BaseStore{constructor(t){var{AsyncStorage:s,itemSizeLimit:n=b}=t,i=e.__rest(t,["AsyncStorage","itemSizeLimit"]);super(Object.assign(Object.assign({},i),{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 n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){const t=Object.create(null,{clear:{get:()=>super.clear}});return e.__awaiter(this,void 0,void 0,(function*(){yield t.clear.call(this);const e=yield this.getAllKeys();yield this.removeMany(e)}))}}class A extends n.BaseStore{constructor(e){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:6291456})),this._mmkv=e.MMKV}_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._mmkv.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._mmkv.getString(this._getActualKey(t));return e?JSON.parse(e):null}))}_setRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t){const{key:t,data:s}=e;s.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(t),JSON.stringify(e))}}))}_removeRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of t)this._mmkv.delete(this._getActualKey(e))}))}checkAvailability(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._mmkv)throw n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){const t=Object.create(null,{clear:{get:()=>super.clear}});return e.__awaiter(this,void 0,void 0,(function*(){yield t.clear.call(this);const e=yield this.getAllKeys();yield this.removeMany(e)}))}}const k={profileImage:void 0,profileUrl:void 0,nickname:void 0},w=t=>(s,o)=>e.__awaiter(void 0,void 0,void 0,(function*(){switch(s){case 1:case 2:case 3:case 4:default:o();break;case 5:yield t.reset(),o();break;case 6:try{const{v2:s,v3:o,v4:a}=(t=>({v2:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_GROUPCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_GROUPCHANNEL_COLLECTION_KEY,index:[i.getGroupChannelIndexBy(i.GroupChannelListOrder.LATEST_LAST_MESSAGE),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHRONOLOGICAL),i.getGroupChannelIndexBy(i.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:n.NESTDB_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_POLL_COLLECTION_NAME,keyName:n.NESTDB_POLL_COLLECTION_KEY}])})),v3:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_FEEDCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_FEEDCHANNEL_COLLECTION_KEY,index:[r.getFeedChannelIndexBy("latest_last_message")]}])})),v4:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield t.commitSchema([{collectionName:n.NESTDB_NOTIFICATION_COLLECTION_NAME,keyName:n.NESTDB_NOTIFICATION_COLLECTION_KEY,index:[n.getNotificationMessageIndexBy()]}])}))}))(t);yield s(),yield o(),yield a();const d=t.collection(n.NESTDB_MESSAGE_COLLECTION_NAME);yield d.removeIf({where:{channelType:e.ChannelType.OPEN}})}catch(e){}o()}})),O=()=>"undefined"!=typeof document?document.visibilityState:"visible";class R extends e.EventDispatcher{constructor({getVisibilityState:e=O,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 U{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 D extends e.APIRequestCommand{constructor({userId:t,nickname:s,profileUrl:n,profileImage:i,preferredLanguages:r}){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:i,preferred_languages:r}))}}class M extends e.APIResponseCommand{constructor(t,s){super(t,s),this.user=new e.User(t,Object.assign({},s))}}class x extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`,this.params=e.deundefined({apns_device_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class N extends e.APIRequestCommand{constructor({userId:t,token:s,deviceOS:n,deviceManufacturer:i,systemPushEnabled:r}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`,this.params=e.deundefined({gcm_reg_token:s,always_push:!0,device_os:n,device_manufacturer:i,system_push_enabled:r})}}class L 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 q 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 V extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`}}class $ extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`}}class H extends e.APIRequestCommand{constructor({userId:t,type:s,token:n,ts:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/${encodeURIComponent(s)}/device_tokens`,this.params={created_ts:i,token:n}}}class F 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 j extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`}}class K extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class z 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 Q extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class B extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class G 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 W extends e.APIRequestCommand{constructor({userId:t,doNotDisturbOn:s,startHour:n,startMin:i,endHour:r,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:i,end_hour:r,end_min:o,timezone:a}}}class J 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 Y extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class X 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 Z extends e.APIRequestCommand{constructor({userId:t,snoozeOn:s,startTs:n,endTs:i}){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:i}}}class ee 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 te 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 se 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 ne extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class ie extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class re 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 oe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class ae extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`}}class de extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class ue 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 ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class le 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 he 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 pe 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 _e extends e.APIResponseCommand{constructor(e,t){super(e,t),this.friendDiscoveryRequestId=t.friend_discovery_request_id}}class fe 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 me 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 ge extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s)))}}class ve 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 ye 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 Se extends e.APIResponseCommand{constructor(e,t){super(e,t),this.allowFriendDiscovery=t.allow_friend_discovery}}class Ie 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 Pe extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_EMOJI_CATEGORIES}}class Ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiContainer=new u(t)}}class Ee extends e.APIRequestCommand{constructor({categoryId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJI_CATEGORIES}/${t}`}}class be extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiCategory=new d(t)}}class Te extends e.APIRequestCommand{constructor({key:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJIS}/${t}`}}class Ae extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emoji=new a(t)}}class ke extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_UIKIT_CONFIGURATION}`}}class we 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}}var Oe;!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(Oe||(Oe={}));class Re extends e.APIRequestCommand{constructor({deviceToken:t,pushTrackingId:s,messageId:n,allowedPushNotification:i,channelKey:r,templateKey:o,eventType:a,notificationEventDeadline:d}){super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_PUSH_DELIVERY,this.params=e.deundefined({device_token:t,push_tracking_id:s,message_id:n,allowed_push_notification:i,channel_key:r,template_key:o,event_type:a,notification_event_deadline:d})}}let Ue;class De{constructor(t,s,n){this._storeInitialized=!1,this._iid=t,this.options=s;const{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,userEventHandlers:h,appStateToggleEnabled:p}=e.Vault.of(t);this._onlineDetector=new U({logger:l,connectionDelegate:{reconnect:()=>e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,connectionManager:n,sessionManager:i}=e.Vault.of(t);if(i.session.hasSession){if("foreground"===s.appState)try{yield n.resetAndReconnect()}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("resetAndReconnect failed by reconnect event = ",t)}}else try{yield n.connect(i.session.authToken)}catch(t){if(e.isThrowingOutside(t))throw t;l.debug("connect failed by reconnect event = ",t)}d.dispatch(new r.NotificationCollectionRefreshCommand)})),disconnect:()=>{e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s}=e.Vault.of(t);yield s.disconnect()}))))}}});const _=new i.AutoResendManager(t,{localCacheEnabled:a.localCacheEnabled,enableAutoResend:a.localCacheConfig.enableAutoResend,dispatcher:d,sdkState:o,logger:l});n.forEach((e=>{e.init(t,{sdkState:o,cacheContext:a,dispatcher:d,sessionManager:u,requestQueue:c,logger:l,onlineDetector:this._onlineDetector}),this[e.name]=e})),this._appStateChangeDetector=new R({isEnabled:p}),this._appStateChangeDetector.on("resume",(()=>{l.debug("the page resumes from freeze"),this.setForegroundState()})).on("pause",(()=>{l.debug("the page freezes"),this.setBackgroundState()})),d.on((s=>{var n;if(s instanceof e.ConnectionStateChangeCommand){if(s.stateType===e.ConnectionStateType.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(s instanceof e.WebSocketEventCommand)switch(s.code){case"USEV":{const{event:n}=s.as(i.UserEventCommand);switch(n.category){case i.UserEventCategory.FRIEND_DISCOVERED:{const{friendDiscoveries:s}=i.UserEvent.getDataAsFriendDiscoveredEvent(t,n);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.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 i=s.ts;"number"==typeof i&&i>t.ts&&(t.all!==s.all&&(n=!0),t.all=s.all>=0?s.all:0,s.customTypes&&Object.keys(s.customTypes).forEach((e=>{t.customTypes[e]!==s.customTypes[e]&&(n=!0),t.customTypes[e]=s.customTypes[e]})),n=n&&t.ts>0,t.ts=i),n&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return h.forEach((e=>{e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:t.all,feedChannelCount:t.feed,customTypeUnreadCount:t.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(t.all,t.customTypes)}))}))))}else s instanceof e.UserProfileUpdateCommand?(a.preference.set(this._getUserProfileCacheKey(o.userId),e.UserProfile.payloadify(s.userProfile)),(null===(n=s.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&a.preference.set(e.createChangelogIncludeChatNotificationsCacheKey(this.appId),{value:!0})):s instanceof e.SessionExpiredCommand&&s.error&&s.error.isSessionInvalidatedError&&(l.debug("session revoked."),this._internalDisconnect(s.error))}))}static init(i){const{appId:r,appVersion:o,modules:a=[],options:d=new e.SendbirdChatOptions,debugMode:u=!1,customApiHost:c,customWebSocketHost:l,newInstance:h=!1,logLevel:p,localCacheEnabled:_=!1,localCacheConfig:f=new e.LocalCacheConfig,localCacheEncryption:m,useAsyncStorageStore:g=null,useMMKVStorageStore:v=null,appStateToggleEnabled:y=!0}=i;if(!Ue||h){const i=`su-${e.uuid()}`,h=null!=m?m:{encrypt:e=>e,decrypt:e=>e},S=new n.Logger;S.level=null!=p?p:n.LogLevel.WARN;let I=new n.MemoryStore({encryption:h});u||(e.isReactNative()?v?I=new A({MMKV:v,encryption:h}):g&&(I=new T({AsyncStorage:g,encryption:h}),S.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):I=new n.IndexedDbStore({encryption:h})),new e.Vault(i,{appId:r,appVersion:o,options:d,apiHost:null!=c?c:`https://api-${r}.sendbird.com`,websocketHost:null!=l?l:`wss://ws-${r}.sendbird.com`,store:I,encryption:h,logger:S,localCacheEnabled:_,localCacheConfig:f,debugMode:u,appStateToggleEnabled:y});const P=[new t.MessageModule,new s.PollModule],C=new De(i,d,[...a,...P]);return Ue||(Ue=C),C}return Ue}static get instance(){return Ue}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}_getNestDBVersion(){return 7}_getPreferenceCacheKey(e){return`sendbird@${this.appId}/${e}.pref`}_getUserProfileCacheKey(e){return`sendbird@${this.appId}/${e}.profile`}_internalDisconnect(t){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),yield s.logout(t),yield this.clearCachedData(),n.appState="foreground"}))}getMemoryStoreForDebugging(){const{debugMode:t,cacheContext:s}=e.Vault.of(this._iid);if(t)return s.store instanceof n.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)}addSendbirdExtensions(t,s,n){const{logger:i,sdkState:r}=e.Vault.of(this._iid),o=new RegExp(e.SEMVER_REGEX_STRING);if(0===t.length)return i.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(t.find((e=>!o.test(e.version))))return i.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(const[e,t]of Object.entries(n))if(/&|=/.test(e)||/&|=/.test(t))return i.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1;return r.sendbirdRuntimeEnvironment={sendbirdExtensions:t,deviceOS:s,customData:n},!0}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 n.MemoryStore),yield this._safeInitializeStore(t)}}))}setLocaleForChatbot(t){const{sdkState:s}=e.Vault.of(this._iid),n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(t.trim());n&&(s.localeForChatbot=n)}initializeCache(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:r,dispatcher:o,logger:a}=e.Vault.of(this._iid);if(!s.userId||s.userId!==t){const d=`sendbird@${s.appId}/${t}.db`;try{if(r.localCacheEnabled){if(r.nestdb&&r.nestdb.state!==n.NestDBState.CLOSED&&r.nestdb.name===d)yield this._safeInitializeStore(d);else{const e=`sendbird@${s.appId}/${t}.db`,a=r.nestdb=new n.NestDB({name:e,version:this._getNestDBVersion(),store:r.store,config:new n.Config({dbname:e,itemSizeLimit:61440})});a.on("upgrade",w(a)),a.on("storeReplaced",(e=>{r.replaceStore(e),r.localCacheEnabled=!1,a.on("upgrade",w(a))})),yield a.open(),this._storeInitialized=!0,o.dispatch(new i.DatabaseOpenCommand(this._iid,{userId:t}))}s.userId=t}else yield this._safeInitializeStore(d),s.userId=t}catch(i){throw a.warn("Nest DB Open Failed. ",i),r.store instanceof n.MemoryStore||(r.replaceStore(new n.MemoryStore),r.localCacheEnabled=!1),yield this._safeInitializeStore(d),s.userId=t,e.SendbirdError.databaseError}finally{yield this._setupPreference(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=n.MessageCache.of(this._iid),i=n.UnsentMessageCache.of(this._iid);s&&i&&(yield Promise.all(t.map((t=>e.__awaiter(this,void 0,void 0,(function*(){yield s.removeMessagesOfChannel(t),yield i.removeMessagesOfChannel(t)}))))))}))}_setupPreference(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:n,statManager:i}=e.Vault.of(this._iid);yield n.preference.init(this._getPreferenceCacheKey(t),this._getNestDBVersion());const r=yield n.preference.get(this._getUserProfileCacheKey(t));if(r){new e.UserProfile(this._iid,r).apply()}yield i.init(`sendbird@${s.appId}/${t}.statlog`)}))}_ready(t,s,n={}){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:r,cacheContext:o,connectionManager:a}=e.Vault.of(this._iid),{errorForOtherUser:d}=n;if(r.userId&&r.userId!==t){if(d)throw d;yield a.logout()}try{yield this.initializeCache(t);const{dispatcher:s}=e.Vault.of(this._iid);s.dispatch(new i.ReduceDBSizeEventCommand)}catch(t){const{logger:s}=e.Vault.of(this._iid);o.localCacheEnabled=!1,s.warn("Cache initialization failed - cache is not available.")}}))}authenticateFeed(t,s){return e.__awaiter(this,void 0,void 0,(function*(){return yield this.authenticate(t,s)}))}authenticate(t,s){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{sessionManager:i,connectionManager:r}=e.Vault.of(this._iid);return yield this._ready(t,s,{errorForOtherUser:r.isConnected?e.SendbirdError.alreadyConnectedAsAnotherUser:void 0}),(null===(n=i.session.services)||void 0===n?void 0:n.includes(e.SessionService.CHAT))||(s||i.handler||this.setSessionHandler(new p),yield i.authenticate(t,s)),this.currentUser}))}connect(t,s){return e.__awaiter(this,void 0,void 0,(function*(){yield this._ready(t,s);try{const{connectionManager:t}=e.Vault.of(this._iid);yield t.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),i=n.session.hasSession;return i&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((()=>{s.appState="foreground"})).catch((()=>{}))),i}disconnect(){return e.__awaiter(this,void 0,void 0,(function*(){yield this._internalDisconnect()}))}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(!0)}))}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().catch((e=>{n.debug("setBackgroundState error = ",e)})))}setForegroundState(){const{connectionManager:t,sdkState:s,dispatcher:n,logger:i}=e.Vault.of(this._iid);"background"===s.appState&&(s.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((e=>{i.debug("setForgroundState error = ",e)})),n.dispatch(new r.NotificationCollectionRefreshCommand))}setSessionHandler(t){e.unless(t instanceof p).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 f).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 l).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 v(this._iid,e)}createBlockedUserListQuery(e={}){return new I(this._iid,e)}createFriendListQuery(e={}){return new E(this._iid,e)}createMessageSearchQuery(e){return new n.MessageSearchQuery(this._iid,e)}createPollListQuery(t){return new e.PollListQuery(this._iid,Object.assign({},t))}createPollVoterListQuery(t){return new e.PollVoterListQuery(this._iid,Object.assign({},t))}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({},k),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),i=new D(Object.assign({userId:t.userId},s)),r=yield n.send(i),{user:o}=r.as(M);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),i=new D({userId:s.userId,preferredLanguages:t}),r=yield n.send(i),{user:o}=r.as(M);return this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),o}throw e.SendbirdError.connectionRequired}))}registerFCMPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.ANDROID}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.FCM,t))return e.PushTokenRegistrationState.SUCCESS;const o=new N({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.FCM,t,r),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:i}=e.Vault.of(this._iid),r=new q({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new $({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.FCM),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}registerAPNSPushTokenForCurrentUser(t,s){var n,i;return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",null==s?void 0:s.deviceManufacturer,!0)).throw(e.SendbirdError.invalidParameters),(null==s?void 0:s.deviceOS)&&e.unless(e.isEnumOf(e.DeviceOsPlatform,s.deviceOS.platform,!0)&&e.isTypeOf("string",s.deviceOS.version,!0)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;{const r={deviceOS:`${(null===(n=null==s?void 0:s.deviceOS)||void 0===n?void 0:n.platform)||e.DeviceOsPlatform.IOS}-${(null===(i=null==s?void 0:s.deviceOS)||void 0===i?void 0:i.version)||"unknown"}`,deviceManufacturer:null==s?void 0:s.deviceManufacturer,systemPushEnabled:null==s?void 0:s.systemPushEnabled};try{const{sessionManager:s,sdkState:n,requestQueue:i}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.APNS,t))return e.PushTokenRegistrationState.SUCCESS;const o=new x({userId:n.userId,token:t,deviceOS:r.deviceOS,deviceManufacturer:r.deviceManufacturer,systemPushEnabled:r.systemPushEnabled});return yield i.send(o),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.APNS,t,r),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:i}=e.Vault.of(this._iid),r=new L({userId:n.userId,token:t}),{lastDeletedAt:o}=yield i.send(r);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),i=new V({userId:s.userId}),{lastDeletedAt:r}=yield n.send(i);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.APNS),t.setDeviceTokenDeletedAt(r),yield t.saveDeviceToken()}))))}}))}markPushNotificationAsDelivered(t,s=!0){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:i,sessionManager:r,requestQueue:o,pushNotificationAckManager:a}=e.Vault.of(this._iid);i.debug("markPushNotificationAsDelivered:",t);const d=Oe.DELIVERED,{pushTrackingId:u,sessionTopics:c,sessionKey:l,messageId:h,channelKey:p,templateKey:_,notificationEventDeadline:f}=a.parseData(t);if(!l)throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(!c.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),e.SendbirdError.malformedDataError;if(a.isAcked(u,d))return void i.info("already delivered push notification:",u);const m=Boolean(p),g=s&&m,v=null===(n=r.deviceTokens[0])||void 0===n?void 0:n.token,y=new Re({deviceToken:null!=v?v:"",pushTrackingId:u,eventType:d,messageId:h,channelKey:p,templateKey:_,notificationEventDeadline:f,allowedPushNotification:g});l&&(y.headers["Session-Key"]=l);try{yield o.send(y),a.markAsAcked(u,d)}catch(e){throw i.debug(`failed to mark push notification as delivered. push tracking id: ${u}. error: ${e}`),e}}))}markPushNotificationAsClicked(t){var s;return e.__awaiter(this,void 0,void 0,(function*(){const{logger:n,sessionManager:i,requestQueue:r,pushNotificationAckManager:o}=e.Vault.of(this._iid);n.debug("markPushNotificationAsClicked:",t);const a=Oe.CLICKED,{pushTrackingId:d,sessionTopics:u,sessionKey:c,messageId:l,channelKey:h,templateKey:p,notificationEventDeadline:_}=o.parseData(t);if(!c)throw n.info("Can't use markPushNotificationAsClicked() feature."),e.SendbirdError.malformedDataError;if(!u.includes(e.PushSessionKeyTopic.PUSH_ACKNOWLEDGEMENT))throw n.info("Can't use markPushNotificationAsClicked() feature."),e.SendbirdError.malformedDataError;if(o.isAcked(d,a))return void n.info("already clicked push notification:",d);const f=null===(s=i.deviceTokens[0])||void 0===s?void 0:s.token,m=new Re({deviceToken:null!=f?f:"",pushTrackingId:d,eventType:a,messageId:l,channelKey:h,templateKey:p,notificationEventDeadline:_});c&&(m.headers["Session-Key"]=c);try{yield r.send(m),o.markAsAcked(d,a)}catch(e){throw n.debug(`failed to mark push notification as clicked. push tracking id: ${d}. error: ${e}`),e}}))}getChannelInvitationPreference(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new j({userId:t.userId}),i=yield s.send(n),{autoAccept:r}=i.as(K);return{autoAccept:r}}))}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),i=new z({userId:s.userId,willAutoAccept:t}),r=yield n.send(i),{autoAccept:o}=r.as(Q);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 B({userId:t.userId}),i=yield s.send(n),{preference:r}=i.as(G);return r}))}setDoNotDisturb(t,s=0,n=0,i=0,r=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",i)&&e.isTypeOf("number",r)&&e.isTypeOf("string",o)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:d}=e.Vault.of(this._iid),u=new W({userId:a.userId,doNotDisturbOn:t,startHour:s,startMin:n,endHour:i,endMin:r,timezone:o}),c=yield d.send(u),{preference:l}=c.as(J);return l}))}getSnoozePeriod(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new Y({userId:t.userId}),i=yield s.send(n),{snoozePeriod:r}=i.as(X);return r}))}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:i,requestQueue:r}=e.Vault.of(this._iid),o=new Z({userId:i.userId,snoozeOn:t,startTs:s,endTs:n}),a=yield r.send(o),{snoozePeriod:d}=a.as(ee);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:i,sessionManager:r}=e.Vault.of(this._iid),o=new H({userId:n.userId,type:s,token:t}),a=yield i.send(o),{pushTokens:d}=a.as(F);for(const e of d.deviceTokens)r.setDeviceToken(d.type,e);return yield r.saveDeviceToken(),d}))}getPushTriggerOption(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ne({userId:t.userId});return(yield s.send(n)).as(ie).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),i=new re({userId:s.userId,pushTriggerOption:t});return(yield n.send(i)).as(oe).pushTriggerOption}))}getPushTemplate(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ae({userId:t.userId});return(yield s.send(n)).as(de).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),i=new ue({userId:s.userId,templateName:t});return(yield n.send(i)).as(ce).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),i=new te({userId:s.userId,blockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new se({userId:s.userId,unblockedUserId:t instanceof e.User?t.userId:t});yield n.send(i)}))}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),i=new le({userId:s.userId,token:t}),r=yield n.send(i),{changelogs:o}=r.as(he);return o}))}getAllowFriendDiscovery(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ye({userId:t.userId}),i=yield s.send(n),{allowFriendDiscovery:r}=i.as(Se);return r}))}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),i=new Ie({userId:s.userId,allowFriendDiscovery:t});return yield n.send(i),t}))}uploadFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),i=new pe({userId:s.userId,discoveries:t}),r=yield n.send(i),{friendDiscoveryRequestId:o}=r.as(_e);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),i=new fe({userId:s.userId,discoveryKeys:t});yield n.send(i)}))}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),i=new me({userId:s.userId,userIds:t}),r=yield n.send(i),{users:o}=r.as(ge);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),i=new ve({userId:s.userId,userIds:t});yield n.send(i)}))}getAllEmoji(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),s=new Pe,n=yield t.send(s),{emojiContainer:i}=n.as(Ce);return i}))}getEmojiCategory(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Ee({categoryId:t}),i=yield s.send(n),{emojiCategory:r}=i.as(be);return r}))}getEmoji(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Te({key:t}),i=yield s.send(n),{emoji:r}=i.as(Ae);return r}))}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 ke,i=yield s.send(n),{uikitConfiguration:r}=i.as(we);return r}))}}exports.AppInfo=e.AppInfo,exports.CachedChannelInfo=e.CachedChannelInfo,Object.defineProperty(exports,"CachedDataClearOrder",{enumerable:!0,get:function(){return e.CachedDataClearOrder}}),Object.defineProperty(exports,"ChannelType",{enumerable:!0,get:function(){return e.ChannelType}}),Object.defineProperty(exports,"CollectionEventSource",{enumerable:!0,get:function(){return e.CollectionEventSource}}),Object.defineProperty(exports,"ConnectionState",{enumerable:!0,get:function(){return e.ConnectionState}}),Object.defineProperty(exports,"DeviceOsPlatform",{enumerable:!0,get:function(){return e.DeviceOsPlatform}}),Object.defineProperty(exports,"LastMessageThreadingPolicy",{enumerable:!0,get:function(){return e.LastMessageThreadingPolicy}}),exports.LocalCacheConfig=e.LocalCacheConfig,exports.NotificationInfo=e.NotificationInfo,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,Object.defineProperty(exports,"SendbirdErrorCode",{enumerable:!0,get:function(){return e.SendbirdErrorCode}}),Object.defineProperty(exports,"SendbirdPlatform",{enumerable:!0,get:function(){return e.SendbirdPlatform}}),Object.defineProperty(exports,"SendbirdProduct",{enumerable:!0,get:function(){return e.SendbirdProduct}}),exports.UIKitConfigInfo=e.UIKitConfigInfo,Object.defineProperty(exports,"UnreadCountThreadingPolicy",{enumerable:!0,get:function(){return e.UnreadCountThreadingPolicy}}),exports.User=e.User,Object.defineProperty(exports,"UserOnlineState",{enumerable:!0,get:function(){return e.UserOnlineState}}),exports.BannedUserListQuery=n.BannedUserListQuery,exports.BaseChannel=n.BaseChannel,Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return n.LogLevel}}),exports.MemoryStore=n.MemoryStore,exports.MutedUserListQuery=n.MutedUserListQuery,exports.OperatorListQuery=n.OperatorListQuery,exports.Plugin=n.Plugin,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.Participant=o.Participant,exports.ApplicationUserListQuery=v,exports.BlockedUserListQuery=I,exports.ConnectionHandler=l,exports.Emoji=a,exports.EmojiCategory=d,exports.EmojiContainer=u,exports.FriendListQuery=E,exports.SessionHandler=p,exports.UserEventHandler=f,exports.default=De; diff --git a/cjs/lib/__bundle-947cb619.cjs b/cjs/lib/__bundle-0a504be4.cjs similarity index 91% rename from cjs/lib/__bundle-947cb619.cjs rename to cjs/lib/__bundle-0a504be4.cjs index a7962f3..4c1efef 100644 --- a/cjs/lib/__bundle-947cb619.cjs +++ b/cjs/lib/__bundle-0a504be4.cjs @@ -1 +1 @@ -var o=require("./__bundle-0486c467.cjs");exports.BaseChannelHandlerParams=class{constructor(){this.onUserMuted=o.noop,this.onUserUnmuted=o.noop,this.onUserBanned=o.noop,this.onUserUnbanned=o.noop,this.onChannelChanged=o.noop,this.onChannelDeleted=o.noop,this.onChannelFrozen=o.noop,this.onChannelUnfrozen=o.noop,this.onOperatorUpdated=o.noop,this.onChannelMemberCountChanged=o.noop,this.onMetaDataCreated=o.noop,this.onMetaDataUpdated=o.noop,this.onMetaDataDeleted=o.noop,this.onMetaCounterCreated=o.noop,this.onMetaCounterUpdated=o.noop,this.onMetaCounterDeleted=o.noop,this.onMessageReceived=o.noop,this.onMessageUpdated=o.noop,this.onMessageDeleted=o.noop,this.onMentionReceived=o.noop,this.onReactionUpdated=o.noop,this.onThreadInfoUpdated=o.noop}}; +var o=require("./__bundle-2d1d7d4f.cjs");exports.BaseChannelHandlerParams=class{constructor(){this.onUserMuted=o.noop,this.onUserUnmuted=o.noop,this.onUserBanned=o.noop,this.onUserUnbanned=o.noop,this.onChannelChanged=o.noop,this.onChannelDeleted=o.noop,this.onChannelFrozen=o.noop,this.onChannelUnfrozen=o.noop,this.onOperatorUpdated=o.noop,this.onChannelMemberCountChanged=o.noop,this.onMetaDataCreated=o.noop,this.onMetaDataUpdated=o.noop,this.onMetaDataDeleted=o.noop,this.onMetaCounterCreated=o.noop,this.onMetaCounterUpdated=o.noop,this.onMetaCounterDeleted=o.noop,this.onMessageReceived=o.noop,this.onMessageUpdated=o.noop,this.onMessageDeleted=o.noop,this.onMentionReceived=o.noop,this.onReactionUpdated=o.noop,this.onThreadInfoUpdated=o.noop}}; diff --git a/cjs/lib/__bundle-0486c467.cjs b/cjs/lib/__bundle-2d1d7d4f.cjs similarity index 67% rename from cjs/lib/__bundle-0486c467.cjs rename to cjs/lib/__bundle-2d1d7d4f.cjs index bbf88cd..ca61f83 100644 --- a/cjs/lib/__bundle-0486c467.cjs +++ b/cjs/lib/__bundle-2d1d7d4f.cjs @@ -1,2 +1,2 @@ -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.14.5";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.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.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",t[t.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",t[t.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",t[t.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",t[t.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",t[t.SESSION_REVOKED=400310]="SESSION_REVOKED",t[t.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",t[t.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",t[t.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",t[t.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",t[t.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",t[t.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",t[t.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",t[t.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",t[t.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",t[t.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",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.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",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.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_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",t[t.USER_DEACTIVATED=900021]="USER_DEACTIVATED",t[t.CHANNEL_IS_FROZEN=900050]="CHANNEL_IS_FROZEN",t[t.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";const n=e=>!(e instanceof o&&!e.shouldThrowOutside);class o extends Error{constructor({code:e=0,message:t=""}){super(t),this.shouldThrowOutside=!1,this._detail="",this.name="SendbirdError",this.code=e,Object.setPrototypeOf(this,o.prototype)}get detail(){return this._detail}setDetail(e){this._detail=e}get isInvalidTokenError(){return this.code===exports.SendbirdErrorCode.INVALID_TOKEN}get isSessionExpiredError(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}get isSessionTokenExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}get isSessionKeyExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}get isSessionInvalidatedError(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}get isSessionRevokedError(){return this.code===exports.SendbirdErrorCode.SESSION_REVOKED}get isUserAuthDeactivedError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED}get isUserAuthDeletedOrNotFoundError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}get isNetworkError(){return this.code===exports.SendbirdErrorCode.NETWORK_ERROR||this.code===exports.SendbirdErrorCode.NETWORK_ROUTING_ERROR}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 xmlHttpRequestNotSupported(){return new o({code:exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}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 channelTypeNotSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}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 tooManyRequests(){return new o({code:exports.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}static get alreadyConnectedAsAnotherUser(){return new o({code:exports.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}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."})}static get statLogUploadLimitExceededError(){return new o({code:exports.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}static get malformedDataError(){return new o({code:exports.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}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,exports.SendbirdErrorCode.USER_DEACTIVATED,exports.SendbirdErrorCode.CHANNEL_IS_FROZEN,exports.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],a=[exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.CONNECTION_REQUIRED,exports.SendbirdErrorCode.CHANNEL_IS_FROZEN],l=(e,t,s=!1)=>!(!s||!_(t))||("string"!=typeof e?"object"==typeof e?d(e,t):c(e,t):typeof t===e),d=(e,t,s=!1)=>!(!s||!_(t))||Object.values(e).includes(t),c=(e,t)=>t instanceof e,h=(e,t,s=!1)=>!(!s||!_(t))||Array.isArray(t)&&t.every((t=>l(e,t))),u=(e,t=!1)=>{if(t&&_(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},_=e=>null==e;class p{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 E={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=exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=i}get maxSize(){return this._maxSize}get clearOrder(){return this._clearOrder}get clearOrderComparator(){var e;return this._clearOrder===exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}get enableAutoResend(){return this._enableAutoResend}}var A;exports.SessionService=void 0,(A=exports.SessionService||(exports.SessionService={})).FEED="feed",A.CHAT="chat",A.CHAT_API="chat_api";class N{constructor(){this.isRefreshing=!1}get hasSession(){return!!this.sessionKey}get hasChatServicePermission(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(exports.SessionService.CHAT))}clear(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}const w=()=>{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 b{constructor({container:e}){this._container={},this._container=e,this.key=w()}_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(){Object.keys(this._container).forEach((e=>{var t;null===(t=this._container[e])||void 0===t||t.delete(this.key)}))}}class I{constructor(){this._container={}}on(e,t){return new b({container:this._container}).on(e,t)}once(e,t){return new b({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 I}on(e){return this._dispatcher.on("event",e)}once(e){return this._dispatcher.once("event",e)}dispatch(e){this._dispatcher.dispatch("event",e)}}class R{}const O=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},k=e=>{if(null!=e){if("object"==typeof e){if(Array.isArray(e)){const t=[...e];for(let e=0;e{null===e[t]&&delete e[t]})),e}return e}};var D,L,P,U,M,q,F,H,V,z,G,K,B;exports.ChannelType=void 0,(D=exports.ChannelType||(exports.ChannelType={})).BASE="base",D.GROUP="group",D.OPEN="open",D.FEED="feed",exports.Role=void 0,(L=exports.Role||(exports.Role={})).OPERATOR="operator",L.NONE="none",exports.MutedState=void 0,(P=exports.MutedState||(exports.MutedState={})).MUTED="muted",P.UNMUTED="unmuted",exports.MessageType=void 0,(U=exports.MessageType||(exports.MessageType={})).BASE="base",U.USER="user",U.FILE="file",U.ADMIN="admin",exports.MessageTypeFilter=void 0,(M=exports.MessageTypeFilter||(exports.MessageTypeFilter={})).ALL="",M.USER="MESG",M.FILE="FILE",M.ADMIN="ADMM",exports.ServerSideMessageType=void 0,(q=exports.ServerSideMessageType||(exports.ServerSideMessageType={})).USER="MESG",q.FILE="FILE",q.ADMIN="ADMM",exports.MentionType=void 0,(F=exports.MentionType||(exports.MentionType={})).USERS="users",F.CHANNEL="channel",exports.ReplyType=void 0,(H=exports.ReplyType||(exports.ReplyType={})).ALL="all",H.NONE="none",H.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",exports.PushNotificationDeliveryOption=void 0,(V=exports.PushNotificationDeliveryOption||(exports.PushNotificationDeliveryOption={})).DEFAULT="default",V.SUPPRESS="suppress",exports.SendingStatus=void 0,(z=exports.SendingStatus||(exports.SendingStatus={})).PENDING="pending",z.SCHEDULED="scheduled",z.SUCCEEDED="succeeded",z.FAILED="failed",z.CANCELED="canceled",exports.MessageReviewStatus=void 0,(G=exports.MessageReviewStatus||(exports.MessageReviewStatus={})).INREVIEW="InReview",G.APPROVED="Approved",exports.NotificationPriority=void 0,(K=exports.NotificationPriority||(exports.NotificationPriority={})).HIGH="high",K.NORMAL="normal",K.LOW="low",exports.MessageTemplateListOrder=void 0,(B=exports.MessageTemplateListOrder||(exports.MessageTemplateListOrder={})).CREATED_AT="created_at",B.UPDATED_AT="updated_at";const Q="v3",W=`/${Q}/users`,j=`/${Q}/sdk/users`,$=`/${Q}/storage/file`,Z=`/${Q}/group_channels`,Y=`/${Q}/sdk/group_channels`,X=`/${Q}/open_channels`,J=`/${Q}/sdk/open_channels`,ee=`/${Q}/search`,te=`/${Q}/report`,se=`/${Q}/emojis`,ie=`/${Q}/emoji_categories`,ne=`/${Q}/polls`,oe=`/${Q}/scheduled_messages`,re=`/${Q}/sdk/ui_kit/configuration`,ae=`/${Q}/sdk/statistics`,le=`/${Q}/sdk/statistics/notification_statistics`,de=`/${Q}/notifications`,ce=`/${Q}/notifications/users`,he=`/${Q}/message_templates`,ue=`/${Q}/sdk/push_delivery`,_e=`/${Q}/forms`,pe=e=>{switch(e){case exports.ChannelType.FEED:case exports.ChannelType.GROUP:return Z;case exports.ChannelType.OPEN:return X;default:return null}},Ee=(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},ge=(e,t,s)=>{var i;let n=t||new FormData;for(const t in e){if(!e.hasOwnProperty(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=ge(o,n,r)}return n};var fe;exports.APIRequestMethod=void 0,(fe=exports.APIRequestMethod||(exports.APIRequestMethod={})).GET="GET",fe.POST="POST",fe.PUT="PUT",fe.DELETE="DELETE";class ve extends R{constructor(){super(...arguments),this.params={},this.requireAuth=!0,this.headers={},this.requestId=w()}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=O(this.params);return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${this.encodeParams(e[t])}`)).join("&")}`}get payload(){const e=O(this.params);return Object.keys(e).some((t=>u(e[t])))?ge(e):JSON.stringify(e)}get hasSessionKey(){return void 0!==this.headers["Session-Key"]}}class Se extends R{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 me extends R{constructor(e){super(),this.requestId=e}}class Ce extends R{constructor({expires_in:e,reason:t=exports.SendbirdErrorCode.SESSION_KEY_EXPIRED,message:s=""}){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:case exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED:case exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND:this.error=new o({code:t,message:s})}}get invalidateSessionToken(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}class Te extends R{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 Te(e,s,i)}}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}as(e){return new e(this._iid,this.code,this.payload)}}class ye extends R{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:w(),this.ackRequired=t,this.payload.req_id=this.requestId}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}}class Ae extends ve{constructor({userId:e,authToken:t,services:s,expiringSession:i=!0}){super(),this.path=`${W}/${e}/session_key`,this.method=exports.APIRequestMethod.POST,this.params=O({token:t,services:s,expiring_session:!!i}),this.requireAuth=!1}}class Ne extends ye{constructor({authToken:e,expiringSession:t=!0,requestId:s}){super({code:"LOGI",payload:O({token:e,expiring_session:t?1:0,req_id:s}),ackRequired:!0})}}class we extends Se{constructor(e,t){super(e,t);const{key:s,expires_at:i,services:n}=t;this.key=s,this.expiresAt=i,this.services=n}}class be extends Te{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):null}}class Ie extends R{constructor(e){super(),this.statLog=e}}class xe extends R{constructor({request:e,deferred:t,error:s=o.requestFailed}){super(),this.request=e,this.deferred=t,this.error=s}}var Re;exports.StatType=void 0,(Re=exports.StatType||(exports.StatType={})).FEATURE_LOCALCACHE="feature:local_cache",Re.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",Re.NOTIFICATION="noti:stats",Re.WEBSOCKET_CONNECT="ws:connect",Re.API_RESULT="api:result";class Oe{constructor({type:e,data:t,ts:s=Date.now()}){this.type=e,this.createdAt=s,this.data=t}static payloadify(e){return O({stat_type:e.type,ts:e.createdAt,data:O(e.data)})}}const ke=()=>"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product,De=()=>!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent));var Le,Pe,Ue;exports.SendbirdProduct=void 0,(Le=exports.SendbirdProduct||(exports.SendbirdProduct={})).CHAT="chat",Le.CALLS="calls",Le.DESK="desk",Le.LIVE="live",Le.UIKIT_CHAT="uikit-chat",Le.UIKIT_LIVE="uikit-live",exports.SendbirdPlatform=void 0,(Pe=exports.SendbirdPlatform||(exports.SendbirdPlatform={})).ANDROID="android",Pe.IOS="ios",Pe.JS="js",Pe.UNREAL="unreal",Pe.UNITY="unity",Pe.REACT_NATIVE="react-native",Pe.FLUTTER="flutter",exports.DeviceOsPlatform=void 0,(Ue=exports.DeviceOsPlatform||(exports.DeviceOsPlatform={})).ANDROID="android",Ue.IOS="ios",Ue.WEB="web",Ue.MOBILE_WEB="mobile_web",Ue.WINDOWS="windows";class Me{}Me.sendbirdSdkUserAgentWithExtension=e=>{let t={main_sdk_info:`chat/${ke()?exports.SendbirdPlatform.REACT_NATIVE:exports.SendbirdPlatform.JS}/${i.SDK_VERSION}`,device_os_platform:De()?"mobile-web":"web",os_version:i.OS_VERSION};if(e){const{sendbirdExtensions:s,deviceOS:i,customData:n={}}=e;i.version&&(t.os_version=i.version),i.platform&&(t.device_os_platform=i.platform),s.length>0&&(t.extension_sdk_info=s.map((({product:e,platform:t,version:s})=>`${e}/${t}/${s}`)).join(",")),Object.keys(t).forEach((e=>delete n[e])),Object.keys(n).length>0&&(t=Object.assign(Object.assign({},t),n))}return Object.entries(t).map((([e,t])=>`${e}=${t}`)).join("&")},Me.userAgentWithExtension=e=>{const t=ke()?"reactnative":"JS",s=e.sb_syncmanager?`s${e.sb_syncmanager}`:"",n=e.sb_uikit?`u${e.sb_uikit}`:"",o=e["device-os-platform"]?`o${e["device-os-platform"]}`:De()?"omobile-web":"oweb";return`${t}/c${i.SDK_VERSION}/${s}/${n}/${o}`};class qe{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=e=>{t(e)}}))}}class Fe extends R{constructor(e){super(),this.requestId=e.requestId}}class He extends ve{constructor(e){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${pe(e.channelType)}/${e.channelUrl}/messages/${e.messageId}`,e.messageToken&&(this.params=O({mesg_token:e.messageToken}))}}class Ve{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:o=!1}){this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=t,this._sdkState=s,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof me&&this.cancel(e.requestId)})),this._logger=n,this._shouldImportFetchCompat=o}_createHeader(e,t){const{appId:s,appVersion:n,sendbirdRuntimeEnvironment:o}=this._sdkState,r=Object.assign(Object.assign({},e.headers),{SendBird:`JS,${i.OS_VERSION},${i.SDK_VERSION},${s}${n?`,${n}`:""}`,"SB-User-Agent":Me.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":Me.sendbirdSdkUserAgentWithExtension(o)});return t||(r["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(r["Session-Key"]=this._session.sessionKey),r["App-Id"]=s,this._session&&this._session.authToken&&(r["Access-Token"]=this._session.authToken),r}_statLogApiResult(e,t,s){e.path.includes("/sdk/statistics")||this._dispatcher.dispatch(new Ie(new Oe({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}})))}_isBodyRequired(e){const{method:t}=e;return t!==exports.APIRequestMethod.GET&&(t!==exports.APIRequestMethod.DELETE||e instanceof He)}send(t){return e(this,void 0,void 0,(function*(){const{path:e,method:s,uploadProgressHandler:i}=t,n=this._isBodyRequired(t),{api:r}=this._sdkState,a=`${r.host}${e}${n?"":t.query}`,l=n?t.payload:null,d=this._createHeader(t,l instanceof FormData?l:void 0),c=new AbortController,{signal:h}=c;this._abortControl.set(t.requestId,c);const u=Date.now();try{if(i){const{xmlHttpRequest:e}=yield Promise.resolve().then((function(){return require("./__bundle-2e006691.cjs")}));try{const s=yield e(this._iid,{requestId:t.requestId,method:t.method,url:a,headers:d,data:null!=l?l:void 0,uploadProgressHandler:i});return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),s}catch(e){if(!(e instanceof o&&e.code===exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED))throw e;this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored.")}}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-6301b3ce.cjs")}))),"function"!=typeof fetch&&(yield Promise.resolve().then((function(){return require("./__bundle-38c66c0d.cjs")})));const e=yield fetch(a,{method:s,body:l,headers:d,signal:h}),n=yield e.json();if(e.ok||e.redirected)return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),new Se(this._iid,n);if(n){const e=new o(n);if(e.isSessionExpiredError){if(this._dispatcher.dispatch(new Ce({reason:e.code,message:e.message})),!(t instanceof Ae)){const s=new qe;return this._dispatcher.dispatch(new xe({request:t,deferred:s,error:e})),s.promise}throw e}throw e.isSessionInvalidatedError?(this._dispatcher.dispatch(new Ce({reason:e.code,message:e.message})),e):e}throw o.requestFailed}catch(e){throw this._statLogApiResult(t,u,e),e instanceof o?(this._logger.debug("fail api request",e),e):"AbortError"===(null==e?void 0:e.name)?o.requestCanceled:(this._logger.debug("fail api request",e),o.networkError)}}))}cancel(e){if(this._abortControl.has(e)){this._abortControl.get(e).abort(),this._abortControl.delete(e)}this._dispatcher.dispatch(new Fe({requestId:e}))}cancelAll(){for(const e of this._abortControl.values())e.abort();this._abortControl.clear(),this._dispatcher.dispatch(new Fe({}))}}const ze=()=>{}; -/*! 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 Ke=256,Be=286,Qe=30,We=15,je=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]),$e=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]),Ye=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xe=new Array(576);Ge(Xe);const Je=new Array(60);Ge(Je);const et=new Array(512);Ge(et);const tt=new Array(256);Ge(tt);const st=new Array(29);Ge(st);const it=new Array(Qe);function nt(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 ot,rt,at;function lt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ge(it);const dt=e=>e<256?et[e]:et[256+(e>>>7)],ct=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ht=(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<{ht(e,s[2*t],s[2*t+1])},_t=(e,t)=>{let s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1},pt=(e,t,s)=>{const i=new Array(16);let n,o,r=0;for(n=1;n<=We;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]=_t(i[t]++,t))}},Et=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},ft=(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?ut(e,n,t):(o=tt[n],ut(e,o+Ke+1,t),r=je[o],0!==r&&(n-=st[o],ht(e,n,r)),i--,o=dt(i),ut(e,o,s),r=$e[o],0!==r&&(i-=it[o],ht(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--)vt(e,s,r);l=o;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],vt(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++,vt(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,E=0;for(u=0;u<=We;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,E++),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!==E){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]--,E-=2}while(E>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),pt(s,d,e.bl_count)},Ct=(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{ht(e,0+(i?1:0),3),gt(e),ct(e,s),ct(e,~s),s&&e.pending_buf.set(e.window.subarray(t,t+s),e.pending),e.pending+=s};var Nt=(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(Ct(e,e.dyn_ltree,e.l_desc.max_code),Ct(e,e.dyn_dtree,e.d_desc.max_code),mt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Ye[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),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?At(e,t,s,i):4===e.strategy||o===n?(ht(e,2+(i?1:0),3),St(e,Xe,Je)):(ht(e,4+(i?1:0),3),((e,t,s,i)=>{let n;for(ht(e,t-257,5),ht(e,s-1,5),ht(e,i-4,4),n=0;n{yt||((()=>{let e,t,s,i,n;const o=new Array(16);for(s=0,i=0;i<28;i++)for(st[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*(tt[s]+Ke+1)]++,e.dyn_dtree[2*dt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ht(e,2,3),ut(e,256,Xe),(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 bt=(e,t,s,i)=>{let n=65535&e,o=e>>>16&65535,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};const It=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 xt=(e,t,s,i)=>{const n=It,o=i+s;e^=-1;for(let s=i;s>>8^n[255&(e^t[s])];return~e},Rt={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"},Ot={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:kt,_tr_stored_block:Dt,_tr_flush_block:Lt,_tr_tally:Pt,_tr_align:Ut}=wt,{Z_NO_FLUSH:Mt,Z_PARTIAL_FLUSH:qt,Z_FULL_FLUSH:Ft,Z_FINISH:Ht,Z_BLOCK:Vt,Z_OK:zt,Z_STREAM_END:Gt,Z_STREAM_ERROR:Kt,Z_DATA_ERROR:Bt,Z_BUF_ERROR:Qt,Z_DEFAULT_COMPRESSION:Wt,Z_FILTERED:jt,Z_HUFFMAN_ONLY:$t,Z_RLE:Zt,Z_FIXED:Yt,Z_DEFAULT_STRATEGY:Xt,Z_UNKNOWN:Jt,Z_DEFLATED:es}=Ot,ts=258,ss=262,is=42,ns=113,os=666,rs=(e,t)=>(e.msg=Rt[t],t),as=e=>2*e-(e>4?9:0),ls=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ds=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 cs=(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))},us=(e,t)=>{Lt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,hs(e.strm)},_s=(e,t)=>{e.pending_buf[e.pending++]=t},ps=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Es=(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=bt(e.adler,t,n,s):2===e.state.wrap&&(e.adler=xt(e.adler,t,n,s)),e.next_in+=n,e.total_in+=n,n)},gs=(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-ss?e.strstart-(e.w_size-ss):0,d=e.window,c=e.w_mask,h=e.prev,u=e.strstart+ts;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},fs=e=>{const t=e.w_size;let s,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ss)&&(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),ds(e),i+=t),0===e.strm.avail_in)break;if(s=Es(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=cs(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=cs(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,hs(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&&(Es(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&&(Es(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===Ht)&&t!==Mt&&0===e.strm.avail_in&&i<=n)&&(s=i>n?n:i,r=t===Ht&&0===e.strm.avail_in&&s===i?1:0,Dt(e,e.block_start,s,r),e.block_start+=s,hs(e.strm)),r?3:1)},Ss=(e,t)=>{let s,i;for(;;){if(e.lookahead=3&&(e.ins_h=cs(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-ss&&(e.match_length=gs(e,s)),e.match_length>=3)if(i=Pt(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=cs(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=cs(e,e.ins_h,e.window[e.strstart+1]);else i=Pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(us(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2},ms=(e,t)=>{let s,i,n;for(;;){if(e.lookahead=3&&(e.ins_h=cs(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=Pt(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=cs(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&&(us(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Pt(e,0,e.window[e.strstart-1]),i&&us(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=Pt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2};function Cs(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 Ts=[new Cs(0,0,0,0,vs),new Cs(4,4,8,4,Ss),new Cs(4,5,16,8,Ss),new Cs(4,6,32,32,Ss),new Cs(4,4,16,16,ms),new Cs(8,16,32,32,ms),new Cs(8,16,128,128,ms),new Cs(8,32,128,256,ms),new Cs(32,128,258,1024,ms),new Cs(32,258,258,4096,ms)];function ys(){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=es,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),ls(this.dyn_ltree),ls(this.dyn_dtree),ls(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),ls(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ls(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 As=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==is&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==ns&&t.status!==os?1:0},Ns=e=>{if(As(e))return rs(e,Kt);e.total_in=e.total_out=0,e.data_type=Jt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?is:ns,e.adler=2===t.wrap?0:1,t.last_flush=-2,kt(t),zt},ws=e=>{const t=Ns(e);var s;return t===zt&&((s=e.state).window_size=2*s.w_size,ls(s.head),s.max_lazy_match=Ts[s.level].max_lazy,s.good_match=Ts[s.level].good_length,s.nice_match=Ts[s.level].nice_length,s.max_chain_length=Ts[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},bs=(e,t,s,i,n,o)=>{if(!e)return Kt;let r=1;if(t===Wt&&(t=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||s!==es||i<8||i>15||t<0||t>9||o<0||o>Yt||8===i&&1!==r)return rs(e,Kt);8===i&&(i=9);const a=new ys;return e.state=a,a.strm=e,a.status=is,a.wrap=r,a.gzhead=null,a.w_bits=i,a.w_size=1<bs(e,t,es,15,8,Xt),deflateInit2:bs,deflateReset:ws,deflateResetKeep:Ns,deflateSetHeader:(e,t)=>As(e)||2!==e.state.wrap?Kt:(e.state.gzhead=t,zt),deflate:(e,t)=>{if(As(e)||t>Vt||t<0)return e?rs(e,Kt):Kt;const s=e.state;if(!e.output||0!==e.avail_in&&!e.input||s.status===os&&t!==Ht)return rs(e,0===e.avail_out?Qt:Kt);const i=s.last_flush;if(s.last_flush=t,0!==s.pending){if(hs(e),0===e.avail_out)return s.last_flush=-1,zt}else if(0===e.avail_in&&as(t)<=as(i)&&t!==Ht)return rs(e,Qt);if(s.status===os&&0!==e.avail_in)return rs(e,Qt);if(s.status===is&&0===s.wrap&&(s.status=ns),s.status===is){let t=es+(s.w_bits-8<<4)<<8,i=-1;if(i=s.strategy>=$t||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,ps(s,t),0!==s.strstart&&(ps(s,e.adler>>>16),ps(s,65535&e.adler)),e.adler=1,s.status=ns,hs(e),0!==s.pending)return s.last_flush=-1,zt}if(57===s.status)if(e.adler=0,_s(s,31),_s(s,139),_s(s,8),s.gzhead)_s(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)),_s(s,255&s.gzhead.time),_s(s,s.gzhead.time>>8&255),_s(s,s.gzhead.time>>16&255),_s(s,s.gzhead.time>>24&255),_s(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),_s(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(_s(s,255&s.gzhead.extra.length),_s(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=xt(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69;else if(_s(s,0),_s(s,0),_s(s,0),_s(s,0),_s(s,0),_s(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),_s(s,3),s.status=ns,hs(e),0!==s.pending)return s.last_flush=-1,zt;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=xt(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex+=n,hs(e),0!==s.pending)return s.last_flush=-1,zt;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=xt(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=xt(e.adler,s.pending_buf,s.pending-i,i)),hs(e),0!==s.pending)return s.last_flush=-1,zt;i=0}t=s.gzindexi&&(e.adler=xt(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=xt(e.adler,s.pending_buf,s.pending-i,i)),hs(e),0!==s.pending)return s.last_flush=-1,zt;i=0}t=s.gzindexi&&(e.adler=xt(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&&(hs(e),0!==s.pending))return s.last_flush=-1,zt;_s(s,255&e.adler),_s(s,e.adler>>8&255),e.adler=0}if(s.status=ns,hs(e),0!==s.pending)return s.last_flush=-1,zt}if(0!==e.avail_in||0!==s.lookahead||t!==Mt&&s.status!==os){let i=0===s.level?vs(s,t):s.strategy===$t?((e,t)=>{let s;for(;;){if(0===e.lookahead&&(fs(e),0===e.lookahead)){if(t===Mt)return 1;break}if(e.match_length=0,s=Pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(us(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2})(s,t):s.strategy===Zt?((e,t)=>{let s,i,n,o;const r=e.window;for(;;){if(e.lookahead<=ts){if(fs(e),e.lookahead<=ts&&t===Mt)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+ts;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=Pt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=Pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(us(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2})(s,t):Ts[s.level].func(s,t);if(3!==i&&4!==i||(s.status=os),1===i||3===i)return 0===e.avail_out&&(s.last_flush=-1),zt;if(2===i&&(t===qt?Ut(s):t!==Vt&&(Dt(s,0,0,!1),t===Ft&&(ls(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),hs(e),0===e.avail_out))return s.last_flush=-1,zt}return t!==Ht?zt:s.wrap<=0?Gt:(2===s.wrap?(_s(s,255&e.adler),_s(s,e.adler>>8&255),_s(s,e.adler>>16&255),_s(s,e.adler>>24&255),_s(s,255&e.total_in),_s(s,e.total_in>>8&255),_s(s,e.total_in>>16&255),_s(s,e.total_in>>24&255)):(ps(s,e.adler>>>16),ps(s,65535&e.adler)),hs(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?zt:Gt)},deflateEnd:e=>{if(As(e))return Kt;const t=e.state.status;return e.state=null,t===ns?rs(e,Bt):zt},deflateSetDictionary:(e,t)=>{let s=t.length;if(As(e))return Kt;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==is||i.lookahead)return Kt;if(1===n&&(e.adler=bt(e.adler,t,s,0)),i.wrap=0,s>=i.w_size){0===n&&(ls(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,fs(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=cs(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,fs(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,zt},deflateInfo:"pako deflate (from Nodeca project)"};const xs=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Rs=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)xs(s,t)&&(e[t]=s[t])}}return e},Os=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;Ds[254]=Ds[254]=1;var Ls=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},Ps=(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&&ks)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+Ds[e[s]]>t?s:t};var Ms=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 qs=Object.prototype.toString,{Z_NO_FLUSH:Fs,Z_SYNC_FLUSH:Hs,Z_FULL_FLUSH:Vs,Z_FINISH:zs,Z_OK:Gs,Z_STREAM_END:Ks,Z_DEFAULT_COMPRESSION:Bs,Z_DEFAULT_STRATEGY:Qs,Z_DEFLATED:Ws}=Ot;function js(e){this.options=Rs({level:Bs,method:Ws,chunkSize:16384,windowBits:15,memLevel:8,strategy:Qs},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 Ms,this.strm.avail_out=0;let s=Is.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(s!==Gs)throw new Error(Rt[s]);if(t.header&&Is.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Ls(t.dictionary):"[object ArrayBuffer]"===qs.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,s=Is.deflateSetDictionary(this.strm,e),s!==Gs)throw new Error(Rt[s]);this._dict_set=!0}}function $s(e,t){const s=new js(t);if(s.push(e,!0),s.err)throw s.msg||Rt[s.err];return s.result}js.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?zs:Fs,"string"==typeof e?s.input=Ls(e):"[object ArrayBuffer]"===qs.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===Hs||o===Vs)&&s.avail_out<=6)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else{if(n=Is.deflate(s,o),n===Ks)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),n=Is.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Gs;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},js.prototype.onData=function(e){this.chunks.push(e)},js.prototype.onEnd=function(e){e===Gs&&(this.result=Os(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Zs={Deflate:js,deflate:$s,deflateRaw:function(e,t){return(t=t||{}).raw=!0,$s(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,$s(e,t)},constants:Ot};const Ys=16209;var Xs=function(e,t){let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A,N;const w=e.state;s=e.next_in,A=e.input,i=s+(e.avail_in-5),n=e.next_out,N=e.output,o=n-(t-e.avail_out),r=n+(e.avail_out-257),a=w.dmax,l=w.wsize,d=w.whave,c=w.wnext,h=w.window,u=w.hold,_=w.bits,p=w.lencode,E=w.distcode,g=(1<>>24,u>>>=S,_-=S,S=v>>>16&255,0===S)N[n++]=65535&v;else{if(!(16&S)){if(64&S){if(32&S){w.mode=16191;break e}e.msg="invalid literal/length code",w.mode=Ys;break e}v=p[(65535&v)+(u&(1<>>=S,_-=S),_<15&&(u+=A[s++]<<_,_+=8,u+=A[s++]<<_,_+=8),v=E[u&f];;){if(S=v>>>24,u>>>=S,_-=S,S=v>>>16&255,16&S){if(C=65535&v,S&=15,_a){e.msg="invalid distance too far back",w.mode=Ys;break e}if(u>>>=S,_-=S,S=n-o,C>S){if(S=C-S,S>d&&w.sane){e.msg="invalid distance too far back",w.mode=Ys;break e}if(T=0,y=h,0===c){if(T+=l-S,S2;)N[n++]=y[T++],N[n++]=y[T++],N[n++]=y[T++],m-=3;m&&(N[n++]=y[T++],m>1&&(N[n++]=y[T++]))}else{T=n-C;do{N[n++]=N[T++],N[n++]=N[T++],N[n++]=N[T++],m-=3}while(m>2);m&&(N[n++]=N[T++],m>1&&(N[n++]=N[T++]))}break}if(64&S){e.msg="invalid distance code",w.mode=Ys;break e}v=E[(65535&v)+(u&(1<>3,s-=m,_-=m<<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,E=0,g=0,f=0,v=0,S=0,m=0,C=0,T=0,y=0,A=0,N=null;const w=new Uint16Array(16),b=new Uint16Array(16);let I,x,R,O=null;for(E=0;E<=Js;E++)w[E]=0;for(g=0;g=1&&0===w[v];v--);if(S>v&&(S=v),0===v)return n[o++]=20971520,n[o++]=20971520,a.bits=1,0;for(f=1;f0&&(0===e||1!==v))return-1;for(b[1]=0,E=1;E852||2===e&&y>592)return 1;for(;;){I=E-C,r[g]+1=p?(x=O[r[g]-p],R=N[r[g]-p]):(x=96,R=0),d=1<>C)+c]=I<<24|x<<16|R}while(0!==c);for(d=1<>=1;if(0!==d?(A&=d-1,A+=d):A=0,g++,0==--w[E]){if(E===v)break;E=t[s+r[g]]}if(E>S&&(A&u)!==h){for(0===C&&(C=S),_+=f,m=E-C,T=1<852||2===e&&y>592)return 1;h=A&u,n[h]=S<<24|m<<16|_-o}}return 0!==A&&(n[_+A]=E-C<<24|64<<16),a.bits=S,0};const{Z_FINISH:oi,Z_BLOCK:ri,Z_TREES:ai,Z_OK:li,Z_STREAM_END:di,Z_NEED_DICT:ci,Z_STREAM_ERROR:hi,Z_DATA_ERROR:ui,Z_MEM_ERROR:_i,Z_BUF_ERROR:pi,Z_DEFLATED:Ei}=Ot,gi=16180,fi=16190,vi=16191,Si=16192,mi=16194,Ci=16199,Ti=16200,yi=16206,Ai=16209,Ni=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function wi(){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 bi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Ii=e=>{if(bi(e))return hi;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=gi,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,li},xi=e=>{if(bi(e))return hi;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ii(e)},Ri=(e,t)=>{let s;if(bi(e))return hi;const i=e.state;return t<0?(s=0,t=-t):(s=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?hi:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=s,i.wbits=t,xi(e))},Oi=(e,t)=>{if(!e)return hi;const s=new wi;e.state=s,s.strm=e,s.window=null,s.mode=gi;const i=Ri(e,t);return i!==li&&(e.state=null),i};let ki,Di,Li=!0;const Pi=e=>{if(Li){ki=new Int32Array(512),Di=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(ni(1,e.lens,0,288,ki,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ni(2,e.lens,0,32,Di,0,e.work,{bits:5}),Li=!1}e.lencode=ki,e.lenbits=9,e.distcode=Di,e.distbits=5},Ui=(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.whaveOi(e,15),inflateInit2:Oi,inflate:(e,t)=>{let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A=0;const N=new Uint8Array(4);let w,b;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(bi(e)||!e.output||!e.input&&0!==e.avail_in)return hi;s=e.state,s.mode===vi&&(s.mode=Si),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,y=li;e:for(;;)switch(s.mode){case gi:if(0===s.wrap){s.mode=Si;break}for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>>8&255,s.check=xt(s.check,N,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=Ai;break}if((15&d)!==Ei){e.msg="unknown compression method",s.mode=Ai;break}if(d>>>=4,c-=4,T=8+(15&d),0===s.wbits&&(s.wbits=T),T>15||T>s.wbits){e.msg="invalid window size",s.mode=Ai;break}s.dmax=1<>8&1),512&s.flags&&4&s.wrap&&(N[0]=255&d,N[1]=d>>>8&255,s.check=xt(s.check,N,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,N[2]=d>>>16&255,N[3]=d>>>24&255,s.check=xt(s.check,N,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&&(N[0]=255&d,N[1]=d>>>8&255,s.check=xt(s.check,N,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=xt(s.check,N,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&&(T=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+_),T)),512&s.flags&&4&s.wrap&&(s.check=xt(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{T=i[o+_++],s.head&&T&&s.length<65536&&(s.head.name+=String.fromCharCode(T))}while(T&&_>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=vi;break;case 16189:for(;c<32;){if(0===a)break e;a--,d+=i[o++]<>>=7&c,c-=7&c,s.mode=yi;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(Pi(s),s.mode=Ci,t===ai){d>>>=2,c-=2;break e}break;case 2:s.mode=16196;break;case 3:e.msg="invalid block type",s.mode=Ai}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=Ai;break}if(s.length=65535&d,d=0,c=0,s.mode=mi,t===ai)break e;case mi: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=vi;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=Ai;break}s.have=0,s.mode=16197;case 16197:for(;s.have>>=3,c-=3}for(;s.have<19;)s.lens[I[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,w={bits:s.lenbits},y=ni(0,s.lens,0,19,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid code lengths set",s.mode=Ai;break}s.have=0,s.mode=16198;case 16198:for(;s.have>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=g,c-=g,s.lens[s.have++]=v;else{if(16===v){for(b=g+2;c>>=g,c-=g,0===s.have){e.msg="invalid bit length repeat",s.mode=Ai;break}T=s.lens[s.have-1],_=3+(3&d),d>>>=2,c-=2}else if(17===v){for(b=g+3;c>>=g,c-=g,T=0,_=3+(7&d),d>>>=3,c-=3}else{for(b=g+7;c>>=g,c-=g,T=0,_=11+(127&d),d>>>=7,c-=7}if(s.have+_>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=Ai;break}for(;_--;)s.lens[s.have++]=T}}if(s.mode===Ai)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=Ai;break}if(s.lenbits=9,w={bits:s.lenbits},y=ni(1,s.lens,0,s.nlen,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid literal/lengths set",s.mode=Ai;break}if(s.distbits=6,s.distcode=s.distdyn,w={bits:s.distbits},y=ni(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,w),s.distbits=w.bits,y){e.msg="invalid distances set",s.mode=Ai;break}if(s.mode=Ci,t===ai)break e;case Ci:s.mode=Ti;case Ti: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,Xs(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===vi&&(s.back=-1);break}for(s.back=0;A=s.lencode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,s.length=v,0===f){s.mode=16205;break}if(32&f){s.back=-1,s.mode=vi;break}if(64&f){e.msg="invalid literal/length code",s.mode=Ai;break}s.extra=15&f,s.mode=16201;case 16201:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=16202;case 16202:for(;A=s.distcode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,64&f){e.msg="invalid distance code",s.mode=Ai;break}s.offset=v,s.extra=15&f,s.mode=16203;case 16203:if(s.extra){for(b=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=Ai;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=Ai;break}_>s.wnext?(_-=s.wnext,p=s.wsize-_):p=s.wnext-_,_>s.length&&(_=s.length),E=s.window}else E=n,p=r-s.offset,_=s.length;_>l&&(_=l),l-=_,s.length-=_;do{n[r++]=E[p++]}while(--_);0===s.length&&(s.mode=Ti);break;case 16205:if(0===l)break e;n[r++]=s.length,l--,s.mode=Ti;break;case yi:if(s.wrap){for(;c<32;){if(0===a)break e;a--,d|=i[o++]<{if(bi(e))return hi;let t=e.state;return t.window&&(t.window=null),e.state=null,li},inflateGetHeader:(e,t)=>{if(bi(e))return hi;const s=e.state;return 2&s.wrap?(s.head=t,t.done=!1,li):hi},inflateSetDictionary:(e,t)=>{const s=t.length;let i,n,o;return bi(e)?hi:(i=e.state,0!==i.wrap&&i.mode!==fi?hi:i.mode===fi&&(n=1,n=bt(n,t,s,0),n!==i.check)?ui:(o=Ui(e,t,s,s),o?(i.mode=16210,_i):(i.havedict=1,li)))},inflateInfo:"pako inflate (from Nodeca project)"};var qi=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 Fi=Object.prototype.toString,{Z_NO_FLUSH:Hi,Z_FINISH:Vi,Z_OK:zi,Z_STREAM_END:Gi,Z_NEED_DICT:Ki,Z_STREAM_ERROR:Bi,Z_DATA_ERROR:Qi,Z_MEM_ERROR:Wi}=Ot;function ji(e){this.options=Rs({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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ms,this.strm.avail_out=0;let s=Mi.inflateInit2(this.strm,t.windowBits);if(s!==zi)throw new Error(Rt[s]);if(this.header=new qi,Mi.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Ls(t.dictionary):"[object ArrayBuffer]"===Fi.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=Mi.inflateSetDictionary(this.strm,t.dictionary),s!==zi)))throw new Error(Rt[s])}function $i(e,t){const s=new ji(t);if(s.push(e),s.err)throw s.msg||Rt[s.err];return s.result}ji.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?Vi:Hi,"[object ArrayBuffer]"===Fi.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=Mi.inflate(s,r),o===Ki&&n&&(o=Mi.inflateSetDictionary(s,n),o===zi?o=Mi.inflate(s,r):o===Qi&&(o=Ki));s.avail_in>0&&o===Gi&&s.state.wrap>0&&0!==e[s.next_in];)Mi.inflateReset(s),o=Mi.inflate(s,r);switch(o){case Bi:case Qi:case Ki:case Wi:return this.onEnd(o),this.ended=!0,!1}if(a=s.avail_out,s.next_out&&(0===s.avail_out||o===Gi))if("string"===this.options.to){let e=Us(s.output,s.next_out),t=s.next_out-e,n=Ps(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!==zi||0!==a){if(o===Gi)return o=Mi.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},ji.prototype.onData=function(e){this.chunks.push(e)},ji.prototype.onEnd=function(e){e===zi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Os(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Zi={Inflate:ji,inflate:$i,inflateRaw:function(e,t){return(t=t||{}).raw=!0,$i(e,t)},ungzip:$i,constants:Ot};const{Deflate:Yi,deflate:Xi,deflateRaw:Ji,gzip:en}=Zs,{Inflate:tn,inflate:sn,inflateRaw:nn,ungzip:on}=Zi;var rn={Deflate:Yi,deflate:Xi,deflateRaw:Ji,gzip:en,Inflate:tn,inflate:sn,inflateRaw:nn,ungzip:on,constants:Ot};const an=t=>e(void 0,void 0,void 0,(function*(){const e=rn.ungzip(t);return String.fromCharCode.apply(null,e)}));var ln,dn;exports.ConnectionState=void 0,(ln=exports.ConnectionState||(exports.ConnectionState={})).CONNECTING="CONNECTING",ln.OPEN="OPEN",ln.CLOSED="CLOSED";class cn extends I{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}get ws(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}_handleMessage(e){e.split("\n").forEach((e=>{if(e){const t=Te.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 Ce(t.payload);e.expiresIn>=0&&this._dispatcher.dispatch(e)}}else"NOOP"===t.code||this.dispatch("message",t)}}))}connect(t,s=""){return e(this,void 0,void 0,(function*(){this._ws=new WebSocket(t,encodeURIComponent(s)),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*(){try{const e=yield an(s.result);this._handleMessage(e)}catch(e){this.error(e)}}))}else if(t.data instanceof ArrayBuffer)try{const e=yield an(new Uint8Array(t.data));this._handleMessage(e)}catch(e){this.error(e)}else if("undefined"!=typeof Buffer&&t.data instanceof Buffer)try{const e=t.data,s=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),i=yield an(s);this._handleMessage(i)}catch(e){this.error(e)}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._ws.onopen=ze,this._ws.onmessage=ze,this._ws.onerror=ze,this.connectionState!==exports.ConnectionState.CLOSED?(this._ws.onclose=()=>{this.dispatch("close"),e()},this._ws.close(),this._ws=void 0):e()):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 hn extends R{constructor({all:e,feed:t,custom_types:s,ts:i}){super(),this.all=e,this.feed=t,this.customTypes=s,this.ts=i}}class un{constructor(e,{session: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 Ve(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this.websocketClient=new cn(e,{sdkState:s,dispatcher:i,logger:n}),this.websocketClient.on("message",(e=>{if(e.payload.unread_cnt&&this._dispatcher.dispatch(new hn(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 qe;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",t.requestId,i),e.reject(i)):(this._logger.debug("receive websocket ack",t.requestId,t),this._logger.debug("receive websocket ack",n),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 ve)return yield this._sendApiRequest(t);if(t instanceof ye)return yield this._sendWebsocketRequest(t);throw o.invalidParameters}))}cancel(e){this.apiClient.cancel(e)}cancelAll(){this.apiClient.cancelAll()}}exports.ConnectionStateType=void 0,(dn=exports.ConnectionStateType||(exports.ConnectionStateType={}))[dn.NONE=0]="NONE",dn[dn.INITIALIZED=1]="INITIALIZED",dn[dn.CONNECTING=2]="CONNECTING",dn[dn.CONNECTED=3]="CONNECTED",dn[dn.RECONNECTING=4]="RECONNECTING",dn[dn.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",dn[dn.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",dn[dn.LOGOUT=7]="LOGOUT";class _n extends R{constructor({stateType:e}){super(),this.stateType=e}}class pn extends R{}class En extends R{}class gn extends R{}class fn{constructor(e){var t,s,i,n;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(s=e.feed_channels)&&void 0!==s?s:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(n=e.settings_updated_at)&&void 0!==n?n:0}static payloadify(e){return O(k({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}class vn{constructor(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}static payloadify(e){return O(k({last_updated_at:e.lastUpdatedAt}))}}class Sn{constructor(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}static payloadify(e){return O(k({template_list_token:e.token}))}}class mn{constructor(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}){this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}static payloadify(e){return O(k({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}class Cn{constructor(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}){this.default=new mn(e.default),this.realTime=new mn(e.realtime)}static payloadify(e){return O(k({default:mn.payloadify(e.default),realtime:mn.payloadify(e.realTime)}))}}const Tn=1048576;var yn,An;exports.UnreadCountThreadingPolicy=void 0,(yn=exports.UnreadCountThreadingPolicy||(exports.UnreadCountThreadingPolicy={}))[yn.NONE=0]="NONE",yn[yn.INCLUDE_REPLY=1]="INCLUDE_REPLY",yn[yn.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",yn[yn.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",exports.LastMessageThreadingPolicy=void 0,(An=exports.LastMessageThreadingPolicy||(exports.LastMessageThreadingPolicy={}))[An.NONE=0]="NONE",An[An.INCLUDE_REPLY=1]="INCLUDE_REPLY",An[An.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",An[An.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";class Nn{constructor(e={}){var t,s,i,n,o,r,a;this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Tn: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.unreadCountThreadingPolicy=null!==(o=e.unread_cnt_threading_policy)&&void 0!==o?o:exports.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(r=e.last_msg_threading_policy)&&void 0!==r?r:exports.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new vn(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new fn(e.notifications):null,this.messageTemplateInfo=e.message_template?new Sn(e.message_template):null,this.statConfigInfo=e.log_publish_config?new Cn(e.log_publish_config):new Cn}static payloadify(e){return O(k({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Tn,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?vn.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?fn.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Sn.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Cn.payloadify(e.statConfigInfo):null}))}}class wn{constructor(e){this._iid="",this._iid=e}static payloadify(e){return{}}}class bn extends ve{constructor({userId:e,metadata:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${W}/${e}/metadata`,this.params={metadata:t}}}class In extends Se{constructor(e,t){super(e,t),this.metaData=t}}class xn extends ve{constructor({userId:e,metadata:t,upsert:s}){super(),this.method=exports.APIRequestMethod.PUT,this.path=`${W}/${e}/metadata`,this.params={metadata:t,upsert:s}}}class Rn extends Se{constructor(e,t){super(e,t),this.metadata=t}}class On extends ve{constructor({userId:e,metadataKey:t}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${W}/${e}/metadata/${t}`}}class kn extends ve{constructor({userId:e}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${W}/${e}/metadata`}}const Dn=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return s._iid&&delete s._iid,t&&t(s),s},Ln=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return t&&t(s),s},Pn=e=>({do:t=>{e||t()},throw:t=>{if(!e)throw t}});var Un;exports.UserOnlineState=void 0,(Un=exports.UserOnlineState||(exports.UserOnlineState={})).ONLINE="online",Un.OFFLINE="offline",Un.NON_AVAILABLE="nonavailable";class Mn extends wn{constructor(e,t){var s,i,n,o,r,a,c,h,u,_,p,E;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!==(E=t.friend_name)&&void 0!==E?E:null}static payloadify(e){return O(k(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}=Lo.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainProfileUrl}?auth=${e.ekey}`:this.plainProfileUrl}serialize(){return Dn(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*(){Pn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Lo.of(this._iid),i=new bn({userId:e.userId,metadata:t}),n=yield s.send(i),{metaData:r}=n.as(In);return this._applyMetaData(r),this.metaData}))}updateMetaData(t,s=!1){return e(this,void 0,void 0,(function*(){Pn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:i}=Lo.of(this._iid),n=new xn({userId:e.userId,metadata:t,upsert:s}),r=yield i.send(n),{metadata:a}=r.as(Rn);return this._applyMetaData(a),this.metaData}))}deleteMetaData(t){return e(this,void 0,void 0,(function*(){Pn(l("string",t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Lo.of(this._iid),i=new On({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}=Lo.of(this._iid),s=new kn({userId:e.userId});yield t.send(s),this.metaData={}}))}}class qn extends R{constructor({userProfile:e}){super(),this.userProfile=e}}class Fn{constructor(e,t){var s,i,n,o,r,a,l,d,c,h,u,_,p,E;this._iid=e,this.appInfo=new Nn(t),this.user=new Mn(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!==(E=t.back_off_delay)&&void 0!==E?E:100}static payloadify(e){return O(k(Object.assign(Object.assign(Object.assign({},Mn.payloadify(e.user)),Nn.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=Lo.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 qn({userProfile:this}))}}class Hn extends R{constructor({request:e=!0,features:t={},options:s={},statConfigInfo:i}){super(),this.request=e,this.features=Object.assign({localCache:!0,notification:!0},t),this.options=Object.assign({ingestion:!0},s),this.statConfigInfo=i}}class Vn extends Te{constructor(e,t,s){var i,n,r,a;super(e,t,s),this.error=null,this.services=[],this.userProfile=new Fn(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,this.services=null!==(a=s.services)&&void 0!==a?a:[]}static asError(e){return new Vn("","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=Lo.of(t);if(!e)throw o.lostInstance;{const{sessionManager:t,dispatcher:s}=e;yield t.login(this),this.userProfile.apply(),s.dispatch(new Hn({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo}))}}}))}}class zn{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,cause:n=null}){return e(this,void 0,void 0,(function*(){}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){}))}}const Gn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){if(!(e instanceof o))throw e;e.throwOutside()}})),Kn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){}}));class Bn extends zn{constructor(e={}){var t;super(),this.type=exports.ConnectionStateType.LOGOUT,this.name="logout",this._wasPreviouslyConnected=null===(t=e.wasPreviouslyConnected)||void 0===t||t}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 io,s),this._wasPreviouslyConnected&&Gn((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onDisconnected&&e.onDisconnected(i)}))}))))}))}}class Qn extends zn{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 to({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Yn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn,e)}))}}class Wn extends zn{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 Yn,e))}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new to({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Yn,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Qn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn,e)}))}}const jn=t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}));class $n{calcTimeout(){return 0}}const Zn=(t,s,i=new $n)=>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||et(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=new qe;this._callbacks.push((e=>e?i.reject(e):i.resolve())),Gn((()=>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 Zn(((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){if(e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);if(e.isSessionExpiredError||e.isSessionInvalidatedError)return void s(e)}throw e}}))),i,n),yield t.changeState(new Xn,s),this._flushCallbacks(),Gn((()=>e(this,void 0,void 0,(function*(){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 Wn({autoReconnect:!1}),s)),this._flushCallbacks(i),Gn((()=>e(this,void 0,void 0,(function*(){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 qe;return this._halt(o.connectionCanceled),t.cancelConnectForRetry(),this._callbacks.push((()=>{const i=Date.now();t.changeState(new to({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 qe;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 Wn({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 Qn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Bn,e)}))}}class Xn extends zn{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 Yn,e)}))}onDisconnect(t,{autoReconnect:s}){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Wn({autoReconnect:s}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Qn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn,e)}))}}var Jn;!function(e){e.ExternalSetBackground="ExternalSetBackground",e.ExternalDisconnectWebSocket="ExternalDisconnectWebSocket"}(Jn||(Jn={}));class eo{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:o,dispatcher:r,logger:a,disableWebSocketCloseEventHandling:l=!1}){this._disableWebSocketCloseEventHandling=!1,this._webSocketClosedCause=null,this._logger=a,this._disableWebSocketCloseEventHandling=l,this._context=new ao(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",(()=>{this.isConnecting||this.isConnected||(this._logger.debug("try reconnect by session key refresh"),Kn((()=>e(this,void 0,void 0,(function*(){yield this.reconnect()})))))})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(()=>{"foreground"!==this._sdkState.appState||this._webSocketClosedCause||Kn((()=>e(this,void 0,void 0,(function*(){this._sessionManager.isSessionKeyRefreshing?yield this.disconnectWebSocket():(this._logger.debug("try reconnect by websocket connection closed"),yield 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}get websocketClient(){return this._websocketClient}connect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onConnect(this._context,t),this._registerEventDispatcher()}))}reconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{})}))}resetAndReconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{resetReconnectCount:!0})}))}background(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=Jn.ExternalSetBackground,yield e.onDisconnect(this._context,{autoReconnect:!1,cause:this._webSocketClosedCause})}))}disconnect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;yield e.onDisconnect(this._context,{error:t,autoReconnect:!0,cause:this._webSocketClosedCause})}))}disconnectWebSocket(t=!1){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;t&&(this._webSocketClosedCause=Jn.ExternalDisconnectWebSocket),yield e.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause})}))}logout(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._clearEventDispatcher(),yield e.onLogout(this._context,t)}))}}class to extends zn{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 qe;this._callbacks.push((e=>e?i.reject(e):i.resolve()));try{yield Zn((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 Xn,s),Gn((()=>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 io,s)),Gn((()=>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 qe;return this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:i=!1,cause:n=null}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:so(n)),t.hasSession?yield t.changeState(new Wn({autoReconnect:i}),e):yield t.changeState(new Bn,e)}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){this._halt(so((null==s?void 0:s.cause)||null));const e=Date.now();t.hasSession?yield t.changeState(new Qn,e):yield t.changeState(new Bn,e)}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:o.connectionCanceled),yield t.changeState(new Bn,e)}))}}function so(e){const t=o.connectionCanceled;if(e){let s=null;switch(e){case Jn.ExternalSetBackground:s="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case Jn.ExternalDisconnectWebSocket:s="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}s&&t.setDetail(s)}return t}class io extends zn{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 to({authToken:s}),e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn({wasPreviouslyConnected:!1}),e)}))}}class no extends ye{constructor(){super({code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}}class oo{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 no;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)}}const ro=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"];class ao extends I{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:r,dispatcher:a,logger:l,entryState:d=new io}){var c;super(),this._stateUpdatedAt=0,this._connectingAt=0,this._connectedAt=0,this._logiReceivedAt=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 oo({pingDelegate:{send:e=>this._websocketClient.send(e),error:e=>this._websocketClient.error(e)},sdkState:this.sdkState,logger:l})),this._websocketClient.on("open",(()=>{this._connectedAt=Date.now(),this._tryResolveConnectionRequest()})).on("message",(e=>{if("LOGI"===e.code)this.clearLoginTimer(),this._dispatcher.dispatch(e.as(Vn))})).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 Vn&&(this._unresolvedLogi=e,this._tryResolveConnectionRequest())}))}get currentState(){return this._currentState}get hasSession(){return this._sessionManager.session.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 _n({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;this._websocketClient.isOpen&&e&&(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),e.error?(this._sessionManager.session.authToken=void 0,e.error.isSessionExpiredError||e.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Ce({reason:e.error.code,message:e.error.message})):this._logger.warn(`login failed: ${e.error}`),this._rejectConnectionRequest(e.error)):(yield e.applyTo(this._iid),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(){var e;const{appId:t,appVersion:s,userId:n,extensions:o,sendbirdRuntimeEnvironment:r}=this.sdkState,{localCacheEnabled:a}=this.cacheContext,{session:l}=this._sessionManager,d=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,c=!!(null!=o?o:{}).sb_uikit,h=Me.userAgentWithExtension(o);return`${this.sdkState.websocket.host}/?p=JS&pv=${encodeURIComponent(i.OS_VERSION)}&sv=${encodeURIComponent(i.SDK_VERSION)}&ai=${t}${s?`&av=${s}`:""}${l.hasSession?"":`&user_id=${encodeURIComponent(n)}`}&pmce=${d?1:0}&active=1&device_token_types=${encodeURIComponent(["gcm","huawei","apns"].join(","))}&SB-User-Agent=${h}&SB-SDK-User-Agent=${encodeURIComponent(Me.sendbirdSdkUserAgentWithExtension(r))}&Request-Sent-Timestamp=${Date.now().toString()}&include_extra_data=${encodeURIComponent(String(ro))}${this._sessionManager.handler?"&expiring_session=1":""}&use_local_cache=${a?1:0}&include_poll_details=1${c?"&uikit_config=1":""}`}_statLogConnection(e){var t;this._dispatcher.dispatch(new Ie(new Oe({type:exports.StatType.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:this._connectedAt>0?this._connectedAt-this._connectingAt:0,logi_latency:this._logiReceivedAt>0?this._logiReceivedAt-this._connectedAt:void 0,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=new qe;if(this._connectionRequestQueue.push(e),1===this._connectionRequestQueue.length){this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout((()=>{this._loginTimer=void 0,this._rejectConnectionRequest(o.loginTimeout)}),null===(s=this.sdkState.websocket)||void 0===s?void 0:s.responseTimeout);const{session:e}=this._sessionManager;t&&(e.authToken=t,e.sessionKey=void 0);const i=this._url();e.sessionKey||e.authToken?this._websocketClient.connect(i,JSON.stringify(e.hasSession?{auth:e.sessionKey}:{token:e.authToken})):this._websocketClient.connect(i,JSON.stringify({}))}return e.promise}))}cancelConnectForRetry(){this._dispatcher.dispatch(Vn.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.disconnect(),yield this._sessionManager.clear()}))}clearLoginTimer(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}class lo extends ve{constructor({appId:e,userId:t,includeUIKitConfig:s=!1,localCacheEnabled:i=!0,expiringSession:n=!0}){super(),this.path=`${j}/${t}/authentication`,this.method=exports.APIRequestMethod.POST,this.params=O({expiring_session:!!n,include_logi:!0,include_extra_data:String(ro),uikit_config:s,use_local_cache:i,app_id:e}),this.requireAuth=!1}}class co extends Se{constructor(e,t){super(e,t),this.logi=new Vn(e,"LOGI",t)}}var ho;!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(ho||(ho={}));const uo=[Ae,lo];class _o{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r=!1}){this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new un(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this._session=t,this._logger=n,this._dispatcher=i,this._dispatcher.on((e=>{var t;if(e instanceof _n){const{stateType:s}=e;switch(this._currentConnectionStateType=s,s){case exports.ConnectionStateType.CONNECTED:this._resolveLazyCallQueue();break;case exports.ConnectionStateType.INITIALIZED:case exports.ConnectionStateType.INTERNAL_DISCONNECTED:case exports.ConnectionStateType.EXTERNAL_DISCONNECTED:case exports.ConnectionStateType.LOGOUT:this._rejectLazyCallQueue((null===(t=this._session)||void 0===t?void 0:t.hasSession)?o.connectionClosed:o.connectionRequired)}}else if(e instanceof pn)this._session.hasChatServicePermission||this._resolveLazyCallQueue(ho.API);else if(e instanceof En||e instanceof gn)this._rejectLazyCallQueue(o.connectionClosed);else if(e instanceof xe){const{request:t,deferred:s,error:i}=e;for(const e of uo)if(t instanceof e)return void s.reject(i);this._lazyCallQueue.push({command:t,deferred:s})}}))}get isReady(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED}get isLazyCallActivated(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING||this._currentConnectionStateType===exports.ConnectionStateType.RECONNECTING||this._session.isRefreshing}_classifyLazyCallQueueByScope(e){const t=[],s=[];let i;switch(e){case ho.ALL:i=null;break;case ho.WEBSOCKET:i=ye;break;case ho.API:i=ve}let n=!1;return this._lazyCallQueue.forEach((e=>{!i||e.command instanceof i||(n=!0),n?s.push(e):t.push(e)})),[t,s]}_resolveLazyCallQueue(t=ho.ALL){const[s,i]=this._classifyLazyCallQueueByScope(t);this._lazyCallQueue=i,s.forEach((t=>e(this,void 0,void 0,(function*(){const{command:e,deferred:s,timeout:i}=t;i&&clearTimeout(i);try{const t=yield this.send(e);s.resolve(t)}catch(e){s.reject(e)}}))))}_rejectLazyCallQueue(t,s=ho.ALL){const[i,n]=this._classifyLazyCallQueueByScope(s);this._lazyCallQueue=n,i.forEach((s=>e(this,void 0,void 0,(function*(){const{deferred:e,timeout:i}=s;clearTimeout(i),e.reject(t)}))))}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof ye){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 qe;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 ve){if(this._session.hasSession)return this._logger.debug("send api request",t),yield this.commandRouter.send(t);if(t.hasSessionKey)return this._logger.debug("send api request with tmp session key",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait api request",t);const e=new qe;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*(){if(this._logger.debug("send forced request",t),t instanceof ye||t instanceof ve)return yield this.commandRouter.send(t);throw o.invalidCommand}))}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 po="sendbird@devicetokens";class Eo{constructor({type:e,token:t,device_os:s,device_manufacturer:i,system_push_enabled:n}){this.type=e,this.token=t,this.deviceOS=s,this.deviceManufacturer=i,this.systemPushEnabled=n}static payloadify(e){return O(k({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}const go=new WeakMap;class fo extends I{constructor({_iid:e,session:t,cacheContext:s,sdkState:i,dispatcher:o,requestQueue:r,logger:a,pushNotificationAckManager:l}){super(),this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._isRefreshingAuthToken=!1,this.currentUser=null,this.session=t,this._iid=e,this._cacheContext=s,this._sdkState=i,this._dispatcher=o,this._requestQueue=r,this._logger=a,this._pushNotificationAckManager=l,this._deviceTokens=[],this._dispatcher.on((e=>{var t,s,i;if(e instanceof _n){const{stateType:t}=e;this._currentConnectionStateType=t}else if(e instanceof Ce&&this.handler&&!this.isSessionKeyRefreshing){if(this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?this.close():((null===(s=e.error)||void 0===s?void 0:s.isSessionTokenExpiredError)&&this.refreshAuthToken().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(this._logger.debug("session expired"),this.handler.onSessionExpired&&this.handler.onSessionExpired(),this.refreshSessionKey().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e}))))}}))}get ekey(){return go.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 Ne({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(be);if(n)throw n;this.session.sessionKey=null!=i?i:this.session.sessionKey}))}_refreshSessionKeyByApi(t){return e(this,void 0,void 0,(function*(){const s=new Ae({userId:this._sdkState.userId,authToken:t,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0});yield Zn((t=>e(this,void 0,void 0,(function*(){try{const e=yield this._requestQueue.forceSend(s),{key:t,services:i}=e.as(we);this.session.sessionKey=t,this.session.services=i}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){try{return void(yield this._handleSessionRefreshError(e,s))}catch(e){}}try{yield this._refreshSessionKeyByApi(t),this.complete()}catch(e){yield this._handleSessionRefreshError(e,s)}}))}_receiveNewAuthToken(){var t;const s=new qe;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired){let t=null;const i=()=>{t&&(clearTimeout(t),t=null)},n=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.resolve(e))},o=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.reject(e))};t=setTimeout((()=>o()),1e3*this._sdkState.sessionTokenRefreshTimeout),Gn((()=>e(this,void 0,void 0,(function*(){var e;(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(n,o)}))))}else s.resolve(null);return s.promise}_handleSessionRefreshError(t,s=!1){return e(this,void 0,void 0,(function*(){if(!(t instanceof o&&(t.isSessionTokenExpiredError||t.code===exports.SendbirdErrorCode.APPLICATION_NOT_FOUND)&&(this.session.authToken=void 0,s)))throw t;{const e=yield this._receiveNewAuthToken();e?(this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken,!1)):yield this.clear()}}))}_isSessionRelatedError(e){return e instanceof o&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}get isSessionKeyRefreshing(){return this.session.isRefreshing}get isRefreshingAuthToken(){return this._isRefreshingAuthToken}get isSessionExpiring(){return!!this.handler}authenticate(t,s){var i;return e(this,void 0,void 0,(function*(){this.session.authToken=s;const e=new lo({appId:this._sdkState.appId,userId:t,includeUIKitConfig:!!(null!==(i=this._sdkState.extensions)&&void 0!==i?i:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!s||this.isSessionExpiring}),n=yield this._requestQueue.commandRouter.send(e),{logi:o}=n.as(co);if(o.error)throw o.error;this.session.hasChatServicePermission||(yield o.applyTo(this._iid))}))}login(t){var s;return e(this,void 0,void 0,(function*(){const{key:e,ekey:i,services:n,userProfile:o,deviceTokenLastDeletedAt:r=0}=t;this.session.sessionKey=e,this.session.services=n,go.set(this,i),this._deviceTokenCacheEnabled=null===(s=null==o?void 0:o.appInfo)||void 0===s?void 0:s.deviceTokenCache;const{preference:a}=this._cacheContext;if(this._deviceTokenCacheEnabled){const e=yield a.get(po);!e||e.lastDeletedAtnew Eo(Eo.payloadify(e)))),this._deviceTokenLastDeletedAt=e.lastDeletedAt)}else yield a.remove(po)}))}complete(){this.dispatch("refresh"),this._dispatcher.dispatch(new pn),Gn((()=>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){Gn((()=>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"),this._dispatcher.dispatch(new gn),Gn((()=>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()}))))}refreshAuthToken(){return e(this,void 0,void 0,(function*(){let e=null;if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{e=yield this._receiveNewAuthToken(),e?(this._logger.debug("session refreshing.."),this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken)):yield this.clear()}catch(t){const s=e?o.sessionTokenRefreshFailed:o.sessionTokenRequestFailed;throw this._dispatcher.dispatch(new En),this.error(s),this._logger.debug("refresh auth token error = ",s),s}finally{this.session.isRefreshing=!1}}}))}refreshSessionKey(){return e(this,void 0,void 0,(function*(){if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{yield this._refreshSessionKey(this.session.authToken)}catch(e){const t=o.sessionTokenRefreshFailed;throw this._dispatcher.dispatch(new En),this.error(t),t}finally{this.session.isRefreshing=!1}}}))}setDeviceToken(e,t,s){if(this._deviceTokenCacheEnabled){if(this.indexOfDeviceToken(e,t)<0){const i=new Eo({type:e,token:t,device_os:null==s?void 0:s.deviceOS,device_manufacturer:null==s?void 0:s.deviceManufacturer,system_push_enabled:null==s?void 0:s.systemPushEnabled});return this._deviceTokens.push(i),!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(po,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})}}))}clear(){return e(this,void 0,void 0,(function*(){this.currentUser=null,this.session.clear(),this.close(),go.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,yield this.saveDeviceToken(),this._pushNotificationAckManager.clear()}))}}const vo=(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]=vo(e[s],t[s]):o[s]=t[s]}return o}return t};var So,mo;!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(So||(So={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(mo||(mo={}));const Co=100;class To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){this.queue=[],this.flushWaitQueue=[],this.enabledState=So.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=e,this.cacheContext=t,this.requestQueue=s,this.logInfo={deviceId:e,statLogs:[],generation:1,lastFlushedAt:0},this.limit=Co}get isEnabled(){return this.enabledState===So.ENABLED}init(t){return e(this,void 0,void 0,(function*(){this.key=t;const e=yield this.cacheContext.preference.get(this.key);e&&(this.logInfo=e)}))}_mergeQueue(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}_isDuplicateStat(e){const t=this._sentLogStats.find((t=>{var s;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(s=e.data.notificationId)&&void 0!==s?s:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}_save(){return e(this,void 0,void 0,(function*(){const e=[...this.queue,...this.flushWaitQueue];yield this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((e=>Oe.payloadify(e))),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})}))}clear(){return e(this,void 0,void 0,(function*(){this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save()}))}}class yo extends Oe{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 Ao extends ve{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${ae}`,this.params={device_id:e,log_entries:t.map((e=>Oe.payloadify(e)))}}}class No extends To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".daily"),this.queue=this.logInfo.statLogs.map((e=>new Oe({type:e.stat_type,ts:e.ts,data:e.data})))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this.statConfig.minInterval=864e5,this._mergeQueue(),s.localCacheStat?this.enabledState=s.enabledStat?So.ENABLED:So.COLLECT_ONLY:(this.enabledState=So.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=yield this._getUploadStats(),t=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);for(let s=0;se instanceof yo&&e.key===t.key));if(s?s.data=vo(s.data,t.data):e.push(t),this.enabledState!==So.PENDING&&(yield this._save()),this.isEnabled&&(this._mergeQueue(),this._isSendable)){const e=yield this._getUploadStats();return yield this._flush(e)}return!0}))}_getUploadStats(){return e(this,void 0,void 0,(function*(){return this.queue.filter((e=>{if(e instanceof yo){const t=new Date,[s,i]=[e.date.getFullYear(),t.getFullYear()];if(s0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new Ao({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Co,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=So.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=So.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}}class wo extends To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}_isSendable(e=!1){if(this.queue.lengthe.type!==exports.StatType.FEATURE_LOCALCACHE_EVENT)):t.filter((e=>e.type===exports.StatType.FEATURE_LOCALCACHE_EVENT))}))}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".default"),this.queue=this.logInfo.statLogs.map((e=>(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data),new Oe({type:e.stat_type,ts:e.ts,data:e.data}))))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.requestStat||s.localCacheStat){let e;this.enabledState=s.enabledStat?So.ENABLED:So.COLLECT_ONLY,s.requestStat||(e=!1),s.localCacheStat||(e=!0),void 0!==e&&(this.queue=yield this._filterQueueByType(this.queue,e),this.flushWaitQueue=yield this._filterQueueByType(this.flushWaitQueue,e),this._save())}else this.enabledState=So.DISABLED,yield this.clear();if(this.isEnabled&&this._isSendable(!0)){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield jn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===So.DISABLED)return!0;const e=this.enabledState===So.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return e.push(t),this.enabledState!==So.PENDING&&(yield this._save()),!this.isEnabled||(this._mergeQueue(),!this._isSendable())||(yield this._flush(e))}))}_flush(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t.length>0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new Ao({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Co,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=So.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=So.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}}class bo extends ve{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${le}`,this.params={device_id:e,log_entries:t.map((e=>Oe.payloadify(e)))}}}class Io extends To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".realtime"),this.queue=this.logInfo.statLogs.map((e=>{var t;return e.data=O(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Oe({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((e=>{var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.notificationStat?this.enabledState=s.enabledStat?So.ENABLED:So.COLLECT_ONLY:(this.enabledState=So.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield jn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===So.DISABLED)return!0;const e=this.enabledState===So.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return!!this._isDuplicateStat(t)||(e.push(t),this.enabledState!==So.PENDING&&(yield this._save()),!(this.isEnabled&&(this._mergeQueue(),this.isEnabled&&this._isSendable))||(yield this._flush(e)))}))}_flush(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t.length>0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new bo({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Co,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=So.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=So.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}}class xo{constructor({cacheContext:e,requestQueue:t,dispatcher:s,logger:i}){this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=w(),this.cacheContext=e,this.requestQueue=t,this.dispatcher=s,this.logger=i,this._dailyStatCollector=new No({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new wo({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new Io({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}_migration(){return e(this,void 0,void 0,(function*(){const e=yield this.cacheContext.preference.get(this.key);if(e){const t=[];e.statLogs.forEach((e=>{e.stat_type===exports.StatType.FEATURE_LOCALCACHE&&t.push(new Oe({type:e.stat_type,ts:e.ts,data:e.data}))})),yield this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((e=>Oe.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const s=[];e.statLogs.forEach((e=>{e.stat_type!==exports.StatType.FEATURE_LOCALCACHE&&e.stat_type!==exports.StatType.NOTIFICATION&&(e.stat_type===exports.StatType.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),s.push(new Oe({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:s.map((e=>Oe.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const i=[];e.statLogs.forEach((e=>{var t;e.stat_type===exports.StatType.NOTIFICATION&&(e.data=O(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),i.push(new Oe({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:i.map((e=>Oe.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt}),yield this.cacheContext.preference.remove(this.key)}}))}init(t){return e(this,void 0,void 0,(function*(){this.key=t,yield this._migration(),yield this._dailyStatCollector.init(this.key),yield this._defaultStatCollector.init(this.key),yield this._notificationStatCollector.init(this.key),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((t=>e(this,void 0,void 0,(function*(){var e;if(t instanceof Ie){const{statLog:e}=t;this.put(e)}else if(t instanceof Hn){const{request:s,features:i,options:n,statConfigInfo:o}=t;this._retryCount=0,this._collectRequestStat=s,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._notificationStatCollector.setConfig(null!==(e=this._statConfig.realTime)&&void 0!==e?e:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:n.ingestion})}})))))}))}put(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t instanceof yo)this._collectFeatureLocalCacheStat&&(e=yield this._dailyStatCollector.put(t));else switch(t.type){case exports.StatType.API_RESULT:case exports.StatType.WEBSOCKET_CONNECT:this._collectRequestStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.FEATURE_LOCALCACHE:case exports.StatType.FEATURE_LOCALCACHE_EVENT:this._collectFeatureLocalCacheStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.NOTIFICATION:this._collectionNotificationStat&&(e=yield this._notificationStatCollector.put(t))}e?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=So.COLLECT_ONLY,this._defaultStatCollector.enabledState=So.COLLECT_ONLY,this._notificationStatCollector.enabledState=So.COLLECT_ONLY,this.logger.debug(o.statLogUploadLimitExceededError)))}))}close(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}class Ro{constructor({limit:e=5}){this.workersByKey={},this.limit=e}run(t,s){return e(this,void 0,void 0,(function*(){if(this.workersByKey[t]||(this.workersByKey[t]=[]),this.workersByKey[t].length{switch(e){case"open":return exports.PollStatus.OPEN;case"closed":return exports.PollStatus.CLOSED;default:return null}},Ho=e=>!e||!!e.text&&l("string",e.text);class Vo extends wn{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 O(k(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})))}}class zo extends wn{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=Fo(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 Vo(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=Fo(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 Vo(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 O(k(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=>Vo.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 Dn(this)}}class Go{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}}class Ko extends Go{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)}}class Bo extends ve{constructor({title:e,optionTexts:t,data:s,allowUserSuggestion:i,allowMultipleVotes:n,closeAt:o}){super(),this.method=exports.APIRequestMethod.POST,this.path=ne,this.params={title:e,options:t,data:s,allow_user_suggestion:i,allow_multiple_votes:n,close_at:o}}}class Qo extends Se{constructor(e,t){super(e,t),this.poll=new zo(e,t)}}class Wo extends ve{constructor({channelUrl:e,channelType:t,pollId:s}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}`,this.params={channel_url:e,channel_type:t}}}class jo extends Se{constructor(e,t){super(e,t),this.poll=new zo(e,t)}}class $o extends ve{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}`,this.params={channel_url:e,channel_type:t}}}class Zo extends Se{constructor(e,t){super(e,t),this.pollOption=new Vo(e,t)}}class Yo extends ve{constructor({channelType:e,channelUrl:t,timestamp:s,token:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${pe(e)}/${encodeURIComponent(t)}/polls/changelogs`,this.params=O({change_ts:s,token:i})}}class Xo extends Se{constructor(e,t){super(e,t),this.updatedPolls=t.updated.map((t=>((e,t)=>new zo(e,t))(e,t))),this.deletedPollIds=t.deleted.map((e=>e)),this.hasMore=t.has_more,this.nextToken=t.next}}const Jo={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},er=e=>{return l("string",e.title)&&(t=e.optionTexts,h("string",t)&&t.every((e=>""!==e.trim())))&&Ho(e.data)&&l("boolean",e.allowUserSuggestion,!0)&&l("boolean",e.allowMultipleVotes,!0)&&l("number",e.closeAt,!0);var t},tr={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0,pollOptionId:0},sr=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId)&&e.pollId>0&&l("number",e.pollOptionId)&&e.pollOptionId>0,ir={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0},nr=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId),or={};class rr extends ve{constructor({channelUrl:e,channelType:t,token:s,limit:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=ne,this.params={channel_url:e,channel_type:t,token:s,limit:i}}}class ar extends Se{constructor(e,t){var s;super(e,t),this.polls=(null!==(s=t.polls)&&void 0!==s?s:[]).map((t=>new zo(e,t))),this.token=t.next}}class lr extends ve{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i,token:n,limit:o}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}/voters`,this.params={channel_url:e,channel_type:t,token:n,limit:o}}}class dr extends Se{constructor(e,t){var s;super(e,t),this.voters=(null!==(s=t.voters)&&void 0!==s?s:[]).map((t=>new Mn(e,t))),this.token=t.next}}exports.APIRequestCommand=ve,exports.APIResponseCommand=Se,exports.API_PATH_EMOJIS=se,exports.API_PATH_EMOJI_CATEGORIES=ie,exports.API_PATH_FORMS=_e,exports.API_PATH_GROUP_CHANNELS=Z,exports.API_PATH_GROUP_CHANNELS_INTERNAL=Y,exports.API_PATH_MESSAGE_TEMPLATE=he,exports.API_PATH_NOTIFICATIONS=de,exports.API_PATH_NOTIFICATIONS_USERS=ce,exports.API_PATH_OPEN_CHANNELS=X,exports.API_PATH_OPEN_CHANNELS_INTERNAL=J,exports.API_PATH_POLLS=ne,exports.API_PATH_PUSH_DELIVERY=ue,exports.API_PATH_REPORT=te,exports.API_PATH_SCHEDULED_MESSAGES=oe,exports.API_PATH_SEARCH=ee,exports.API_PATH_UIKIT_CONFIGURATION=re,exports.API_PATH_UPLOAD=$,exports.API_PATH_USERS=W,exports.AppInfo=Nn,exports.BaseCommand=R,exports.BaseListQuery=Go,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.CancelXMLHttpRequestCommand=Fe,exports.ChannelDataListQuery=Ko,exports.ConnectionStateChangeCommand=_n,exports.DEFAULT_ENCRYPTION=E,exports.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT=5,exports.DailyRecordStatLog=yo,exports.Deferred=qe,exports.DeleteMessageEventCommand=class extends Te{constructor(e,t,s){var i;super(e,"DELM",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.messageId=Number(s.msg_id),this.silent=s.silent,this.messageCreatedAt=s.message_created_at?Number(s.message_created_at):-1,this.senderId=null!==(i=s.sender_id)&&void 0!==i?i:void 0}},exports.DeleteMessageRequestCommand=He,exports.EventDispatcher=I,exports.InstancedObject=wn,exports.LocalCacheConfig=y,exports.MessageEventSource=Uo,exports.MessageRemoveEventCommand=class extends R{constructor({messageIds:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messageIds=e,this.source=t,this.isWebSocketEventComing=s}},exports.MessageUpdateEventCommand=class extends R{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.NotificationInfo=fn,exports.POLL_REMOVED_STATUS="removed",exports.Poll=zo,exports.PollChangeLogEventCommand=Mo,exports.PollCreateParamsDefault=Jo,exports.PollListQuery=class extends Ko{constructor(e,t){super(e,t.channelUrl,t.channelType,t)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Lo.of(this._iid),t=new rr(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{polls:i,token:n}=s.as(ar);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.PollManager=class{constructor(e,{sdkState:t,dispatcher:s,sessionManager:i,requestQueue:n,logger:o}){this._iid=e,this._sdkState=t,this._sessionManager=i,this._requestQueue=n,this._dispatcher=s,this._logger=o,or[e]=this}static of(e){return or[e]}buildPollFromSerializedData(e){const t=Ln(e);return new zo(this._iid,zo.payloadify(t))}get(t){return e(this,void 0,void 0,(function*(){Pn(nr(t)).throw(o.invalidParameters);const e=new Wo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(jo);return i}))}create(t){return e(this,void 0,void 0,(function*(){Pn(er(t)).throw(o.invalidParameters);const e=new Bo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(Qo);return i}))}getOption(t){return e(this,void 0,void 0,(function*(){Pn(sr(t)).throw(o.invalidParameters);const e=new $o(Object.assign({},t)),s=yield this._requestQueue.send(e),{pollOption:i}=s.as(Zo);return i}))}getPollChangeLogs(t,s,i,n=exports.CollectionEventSource.SYNC_POLL_CHANGELOGS){return e(this,void 0,void 0,(function*(){const e=new Yo(k({channelType:s,channelUrl:t,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null})),o=yield this._requestQueue.send(e),{updatedPolls:r,deletedPollIds:a,hasMore:l,nextToken:d}=o.as(Xo);return r.length>0&&this._dispatcher.dispatch(new Mo({polls:r,source:n})),{updatedPolls:r,deletedPollIds:a,hasMore:l,token:d}}))}},exports.PollOption=Vo,exports.PollOptionRetrievalParamsDefault=tr,exports.PollRetrievalParamsDefault=ir,exports.PollUpdateInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=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.PollVoteInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoterListQuery=class extends Ko{constructor(e,t){super(e,t.channelUrl,t.channelType,t),this.pollId=t.pollId,this.pollOptionId=t.pollOptionId}_validate(){return super._validate()&&l("number",this.pollId)&&l("number",this.pollOptionId)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Lo.of(this._iid),t=new lr(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),s=yield e.send(t),{voters:i,token:n}=s.as(dr);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.ReactionUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.RequestResendCommand=xe,exports.SEMVER_REGEX_STRING="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",exports.SendbirdChatOptions=p,exports.SendbirdError=o,exports.SessionExpiredCommand=Ce,exports.SessionRefreshAPICommand=Ae,exports.StatLog=Oe,exports.SubscribedUnreadMessageCountUpdateCommand=hn,exports.ThreadUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.UIKitConfigInfo=vn,exports.UnsentMessageRemoveEventCommand=class extends R{constructor({reqId:e,source:t}){super(),this.reqId=e,this.source=t}},exports.User=Mn,exports.UserProfile=Fn,exports.UserProfileUpdateCommand=qn,exports.Vault=Lo,exports.WebSocketEventCommand=Te,exports.WebSocketRequestCommand=ye,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=Ee(null!==(i=e.mentionType)&&void 0!==i?i:null,null!==(n=e.mentionedUserIds)&&void 0!==n?n:[],s),l=Ee(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=Ee,exports.createChangelogIncludeChatNotificationsCacheKey=e=>`sendbird@${e}/changelog_include_chat_notifications`,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=Ln,exports.deundefined=O,exports.getChannelApiPathByType=pe,exports.getReportApiPathByType=e=>{switch(e){case exports.ChannelType.GROUP:return`${te}/group_channels`;case exports.ChannelType.OPEN:return`${te}/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.isMilliSecondOf=(e,t=!1)=>!(!t||!_(e))||"number"==typeof e&&13===e.toString().length,exports.isReactNative=ke,exports.isResendableError=e=>e>0&&r.indexOf(e)>=0,exports.isThrowingOutside=n,exports.isTypeOf=l,exports.noop=ze,exports.parsePollStatusPayload=Fo,exports.runAsCallback=Gn,exports.runOrNothing=Kn,exports.serialize=Dn,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===exports.CollectionEventSource.SYNC_MESSAGE_FILL||e===exports.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||e===exports.CollectionEventSource.SYNC_POLL_CHANGELOGS,exports.sleep=jn,exports.undefineNullProps=k,exports.unless=Pn,exports.uuid=w,exports.validatePollCreateParams=er,exports.validatePollData=Ho,exports.validatePollOptionRetrievalParams=sr,exports.validatePollRetrievalParams=nr,exports.version=s; +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.14.6";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.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.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",t[t.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",t[t.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",t[t.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",t[t.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",t[t.SESSION_REVOKED=400310]="SESSION_REVOKED",t[t.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",t[t.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",t[t.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",t[t.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",t[t.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",t[t.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",t[t.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",t[t.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",t[t.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",t[t.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",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.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",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.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_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",t[t.USER_DEACTIVATED=900021]="USER_DEACTIVATED",t[t.CHANNEL_IS_FROZEN=900050]="CHANNEL_IS_FROZEN",t[t.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";const n=e=>!(e instanceof o&&!e.shouldThrowOutside);class o extends Error{constructor({code:e=0,message:t=""}){super(t),this.shouldThrowOutside=!1,this._detail="",this.name="SendbirdError",this.code=e,Object.setPrototypeOf(this,o.prototype)}get detail(){return this._detail}setDetail(e){this._detail=e}get isInvalidTokenError(){return this.code===exports.SendbirdErrorCode.INVALID_TOKEN}get isSessionExpiredError(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}get isSessionTokenExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}get isSessionKeyExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}get isSessionInvalidatedError(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}get isSessionRevokedError(){return this.code===exports.SendbirdErrorCode.SESSION_REVOKED}get isUserAuthDeactivedError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED}get isUserAuthDeletedOrNotFoundError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}get isNetworkError(){return this.code===exports.SendbirdErrorCode.NETWORK_ERROR||this.code===exports.SendbirdErrorCode.NETWORK_ROUTING_ERROR}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 xmlHttpRequestNotSupported(){return new o({code:exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}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 channelTypeNotSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}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 tooManyRequests(){return new o({code:exports.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}static get alreadyConnectedAsAnotherUser(){return new o({code:exports.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}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."})}static get statLogUploadLimitExceededError(){return new o({code:exports.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}static get malformedDataError(){return new o({code:exports.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}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,exports.SendbirdErrorCode.USER_DEACTIVATED,exports.SendbirdErrorCode.CHANNEL_IS_FROZEN,exports.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],a=[exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.CONNECTION_REQUIRED,exports.SendbirdErrorCode.CHANNEL_IS_FROZEN],l=(e,t,s=!1)=>!(!s||!_(t))||("string"!=typeof e?"object"==typeof e?d(e,t):c(e,t):typeof t===e),d=(e,t,s=!1)=>!(!s||!_(t))||Object.values(e).includes(t),c=(e,t)=>t instanceof e,h=(e,t,s=!1)=>!(!s||!_(t))||Array.isArray(t)&&t.every((t=>l(e,t))),u=(e,t=!1)=>{if(t&&_(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},_=e=>null==e;class p{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 E={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=exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=i}get maxSize(){return this._maxSize}get clearOrder(){return this._clearOrder}get clearOrderComparator(){var e;return this._clearOrder===exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}get enableAutoResend(){return this._enableAutoResend}}var A;exports.SessionService=void 0,(A=exports.SessionService||(exports.SessionService={})).FEED="feed",A.CHAT="chat",A.CHAT_API="chat_api";class N{constructor(){this.isRefreshing=!1}get hasSession(){return!!this.sessionKey}get hasChatServicePermission(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(exports.SessionService.CHAT))}clear(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}const w=()=>{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 b{constructor({container:e}){this._container={},this._container=e,this.key=w()}_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(){Object.keys(this._container).forEach((e=>{var t;null===(t=this._container[e])||void 0===t||t.delete(this.key)}))}}class I{constructor(){this._container={}}on(e,t){return new b({container:this._container}).on(e,t)}once(e,t){return new b({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 I}on(e){return this._dispatcher.on("event",e)}once(e){return this._dispatcher.once("event",e)}dispatch(e){this._dispatcher.dispatch("event",e)}}class R{}const O=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},k=e=>{if(null!=e){if("object"==typeof e){if(Array.isArray(e)){const t=[...e];for(let e=0;e{null===e[t]&&delete e[t]})),e}return e}};var D,L,P,U,M,q,F,H,V,z,G,K,B;exports.ChannelType=void 0,(D=exports.ChannelType||(exports.ChannelType={})).BASE="base",D.GROUP="group",D.OPEN="open",D.FEED="feed",exports.Role=void 0,(L=exports.Role||(exports.Role={})).OPERATOR="operator",L.NONE="none",exports.MutedState=void 0,(P=exports.MutedState||(exports.MutedState={})).MUTED="muted",P.UNMUTED="unmuted",exports.MessageType=void 0,(U=exports.MessageType||(exports.MessageType={})).BASE="base",U.USER="user",U.FILE="file",U.ADMIN="admin",exports.MessageTypeFilter=void 0,(M=exports.MessageTypeFilter||(exports.MessageTypeFilter={})).ALL="",M.USER="MESG",M.FILE="FILE",M.ADMIN="ADMM",exports.ServerSideMessageType=void 0,(q=exports.ServerSideMessageType||(exports.ServerSideMessageType={})).USER="MESG",q.FILE="FILE",q.ADMIN="ADMM",exports.MentionType=void 0,(F=exports.MentionType||(exports.MentionType={})).USERS="users",F.CHANNEL="channel",exports.ReplyType=void 0,(H=exports.ReplyType||(exports.ReplyType={})).ALL="all",H.NONE="none",H.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",exports.PushNotificationDeliveryOption=void 0,(V=exports.PushNotificationDeliveryOption||(exports.PushNotificationDeliveryOption={})).DEFAULT="default",V.SUPPRESS="suppress",exports.SendingStatus=void 0,(z=exports.SendingStatus||(exports.SendingStatus={})).PENDING="pending",z.SCHEDULED="scheduled",z.SUCCEEDED="succeeded",z.FAILED="failed",z.CANCELED="canceled",exports.MessageReviewStatus=void 0,(G=exports.MessageReviewStatus||(exports.MessageReviewStatus={})).INREVIEW="InReview",G.APPROVED="Approved",exports.NotificationPriority=void 0,(K=exports.NotificationPriority||(exports.NotificationPriority={})).HIGH="high",K.NORMAL="normal",K.LOW="low",exports.MessageTemplateListOrder=void 0,(B=exports.MessageTemplateListOrder||(exports.MessageTemplateListOrder={})).CREATED_AT="created_at",B.UPDATED_AT="updated_at";const Q="v3",W=`/${Q}/users`,j=`/${Q}/sdk/users`,$=`/${Q}/storage/file`,Z=`/${Q}/group_channels`,Y=`/${Q}/sdk/group_channels`,X=`/${Q}/open_channels`,J=`/${Q}/sdk/open_channels`,ee=`/${Q}/search`,te=`/${Q}/report`,se=`/${Q}/emojis`,ie=`/${Q}/emoji_categories`,ne=`/${Q}/polls`,oe=`/${Q}/scheduled_messages`,re=`/${Q}/sdk/ui_kit/configuration`,ae=`/${Q}/sdk/statistics`,le=`/${Q}/sdk/statistics/notification_statistics`,de=`/${Q}/notifications`,ce=`/${Q}/notifications/users`,he=`/${Q}/message_templates`,ue=`/${Q}/sdk/push_delivery`,_e=`/${Q}/forms`,pe=e=>{switch(e){case exports.ChannelType.FEED:case exports.ChannelType.GROUP:return Z;case exports.ChannelType.OPEN:return X;default:return null}},Ee=(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},ge=(e,t,s)=>{var i;let n=t||new FormData;for(const t in e){if(!e.hasOwnProperty(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=ge(o,n,r)}return n};var fe;exports.APIRequestMethod=void 0,(fe=exports.APIRequestMethod||(exports.APIRequestMethod={})).GET="GET",fe.POST="POST",fe.PUT="PUT",fe.DELETE="DELETE";class ve extends R{constructor(){super(...arguments),this.params={},this.requireAuth=!0,this.headers={},this.requestId=w()}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=O(this.params);return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${this.encodeParams(e[t])}`)).join("&")}`}get payload(){const e=O(this.params);return Object.keys(e).some((t=>u(e[t])))?ge(e):JSON.stringify(e)}get hasSessionKey(){return void 0!==this.headers["Session-Key"]}}class Se extends R{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 me extends R{constructor(e){super(),this.requestId=e}}class Ce extends R{constructor({expires_in:e,reason:t=exports.SendbirdErrorCode.SESSION_KEY_EXPIRED,message:s=""}){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:case exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED:case exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND:this.error=new o({code:t,message:s})}}get invalidateSessionToken(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}class Te extends R{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 Te(e,s,i)}}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}as(e){return new e(this._iid,this.code,this.payload)}}class ye extends R{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:w(),this.ackRequired=t,this.payload.req_id=this.requestId}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}}class Ae extends ve{constructor({userId:e,authToken:t,services:s,expiringSession:i=!0}){super(),this.path=`${W}/${e}/session_key`,this.method=exports.APIRequestMethod.POST,this.params=O({token:t,services:s,expiring_session:!!i}),this.requireAuth=!1}}class Ne extends ye{constructor({authToken:e,expiringSession:t=!0,requestId:s}){super({code:"LOGI",payload:O({token:e,expiring_session:t?1:0,req_id:s}),ackRequired:!0})}}class we extends Se{constructor(e,t){super(e,t);const{key:s,expires_at:i,services:n}=t;this.key=s,this.expiresAt=i,this.services=n}}class be extends Te{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):null}}class Ie extends R{constructor(e){super(),this.statLog=e}}class xe extends R{constructor({request:e,deferred:t,error:s=o.requestFailed}){super(),this.request=e,this.deferred=t,this.error=s}}var Re;exports.StatType=void 0,(Re=exports.StatType||(exports.StatType={})).FEATURE_LOCALCACHE="feature:local_cache",Re.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",Re.NOTIFICATION="noti:stats",Re.WEBSOCKET_CONNECT="ws:connect",Re.API_RESULT="api:result";class Oe{constructor({type:e,data:t,ts:s=Date.now()}){this.type=e,this.createdAt=s,this.data=t}static payloadify(e){return O({stat_type:e.type,ts:e.createdAt,data:O(e.data)})}}const ke=()=>"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product,De=()=>!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent));var Le,Pe,Ue;exports.SendbirdProduct=void 0,(Le=exports.SendbirdProduct||(exports.SendbirdProduct={})).CHAT="chat",Le.CALLS="calls",Le.DESK="desk",Le.LIVE="live",Le.UIKIT_CHAT="uikit-chat",Le.UIKIT_LIVE="uikit-live",exports.SendbirdPlatform=void 0,(Pe=exports.SendbirdPlatform||(exports.SendbirdPlatform={})).ANDROID="android",Pe.IOS="ios",Pe.JS="js",Pe.UNREAL="unreal",Pe.UNITY="unity",Pe.REACT_NATIVE="react-native",Pe.FLUTTER="flutter",exports.DeviceOsPlatform=void 0,(Ue=exports.DeviceOsPlatform||(exports.DeviceOsPlatform={})).ANDROID="android",Ue.IOS="ios",Ue.WEB="web",Ue.MOBILE_WEB="mobile_web",Ue.WINDOWS="windows";class Me{}Me.sendbirdSdkUserAgentWithExtension=e=>{let t={main_sdk_info:`chat/${ke()?exports.SendbirdPlatform.REACT_NATIVE:exports.SendbirdPlatform.JS}/${i.SDK_VERSION}`,device_os_platform:De()?"mobile-web":"web",os_version:i.OS_VERSION};if(e){const{sendbirdExtensions:s,deviceOS:i,customData:n={}}=e;i.version&&(t.os_version=i.version),i.platform&&(t.device_os_platform=i.platform),s.length>0&&(t.extension_sdk_info=s.map((({product:e,platform:t,version:s})=>`${e}/${t}/${s}`)).join(",")),Object.keys(t).forEach((e=>delete n[e])),Object.keys(n).length>0&&(t=Object.assign(Object.assign({},t),n))}return Object.entries(t).map((([e,t])=>`${e}=${t}`)).join("&")},Me.userAgentWithExtension=e=>{const t=ke()?"reactnative":"JS",s=e.sb_syncmanager?`s${e.sb_syncmanager}`:"",n=e.sb_uikit?`u${e.sb_uikit}`:"",o=e["device-os-platform"]?`o${e["device-os-platform"]}`:De()?"omobile-web":"oweb";return`${t}/c${i.SDK_VERSION}/${s}/${n}/${o}`};class qe{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=e=>{t(e)}}))}}class Fe extends R{constructor(e){super(),this.requestId=e.requestId}}class He extends ve{constructor(e){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${pe(e.channelType)}/${e.channelUrl}/messages/${e.messageId}`,e.messageToken&&(this.params=O({mesg_token:e.messageToken}))}}class Ve{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:o=!1}){this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=t,this._sdkState=s,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof me&&this.cancel(e.requestId)})),this._logger=n,this._shouldImportFetchCompat=o}_createHeader(e,t){const{appId:s,appVersion:n,sendbirdRuntimeEnvironment:o}=this._sdkState,r=Object.assign(Object.assign({},e.headers),{SendBird:`JS,${i.OS_VERSION},${i.SDK_VERSION},${s}${n?`,${n}`:""}`,"SB-User-Agent":Me.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":Me.sendbirdSdkUserAgentWithExtension(o)});return t||(r["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(r["Session-Key"]=this._session.sessionKey),r["App-Id"]=s,this._session&&this._session.authToken&&(r["Access-Token"]=this._session.authToken),r}_statLogApiResult(e,t,s){e.path.includes("/sdk/statistics")||this._dispatcher.dispatch(new Ie(new Oe({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}})))}_isBodyRequired(e){const{method:t}=e;return t!==exports.APIRequestMethod.GET&&(t!==exports.APIRequestMethod.DELETE||e instanceof He)}send(t){return e(this,void 0,void 0,(function*(){const{path:e,method:s,uploadProgressHandler:i}=t,n=this._isBodyRequired(t),{api:r}=this._sdkState,a=`${r.host}${e}${n?"":t.query}`,l=n?t.payload:null,d=this._createHeader(t,l instanceof FormData?l:void 0),c=new AbortController,{signal:h}=c;this._abortControl.set(t.requestId,c);const u=Date.now();try{if(i){const{xmlHttpRequest:e}=yield Promise.resolve().then((function(){return require("./__bundle-4455b70a.cjs")}));try{const s=yield e(this._iid,{requestId:t.requestId,method:t.method,url:a,headers:d,data:null!=l?l:void 0,uploadProgressHandler:i});return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),s}catch(e){if(!(e instanceof o&&e.code===exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED))throw e;this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored.")}}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-6301b3ce.cjs")}))),"function"!=typeof fetch&&(yield Promise.resolve().then((function(){return require("./__bundle-38c66c0d.cjs")})));const e=yield fetch(a,{method:s,body:l,headers:d,signal:h}),n=yield e.json();if(e.ok||e.redirected)return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),new Se(this._iid,n);if(n){const e=new o(n);if(e.isSessionExpiredError){if(this._dispatcher.dispatch(new Ce({reason:e.code,message:e.message})),!(t instanceof Ae)){const s=new qe;return this._dispatcher.dispatch(new xe({request:t,deferred:s,error:e})),s.promise}throw e}throw e.isSessionInvalidatedError?(this._dispatcher.dispatch(new Ce({reason:e.code,message:e.message})),e):e}throw o.requestFailed}catch(e){throw this._statLogApiResult(t,u,e),e instanceof o?(this._logger.debug("fail api request",e),e):"AbortError"===(null==e?void 0:e.name)?o.requestCanceled:(this._logger.debug("fail api request",e),o.networkError)}}))}cancel(e){if(this._abortControl.has(e)){this._abortControl.get(e).abort(),this._abortControl.delete(e)}this._dispatcher.dispatch(new Fe({requestId:e}))}cancelAll(){for(const e of this._abortControl.values())e.abort();this._abortControl.clear(),this._dispatcher.dispatch(new Fe({}))}}const ze=()=>{}; +/*! 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 Ke=256,Be=286,Qe=30,We=15,je=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]),$e=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]),Ye=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xe=new Array(576);Ge(Xe);const Je=new Array(60);Ge(Je);const et=new Array(512);Ge(et);const tt=new Array(256);Ge(tt);const st=new Array(29);Ge(st);const it=new Array(Qe);function nt(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 ot,rt,at;function lt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ge(it);const dt=e=>e<256?et[e]:et[256+(e>>>7)],ct=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ht=(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<{ht(e,s[2*t],s[2*t+1])},_t=(e,t)=>{let s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1},pt=(e,t,s)=>{const i=new Array(16);let n,o,r=0;for(n=1;n<=We;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]=_t(i[t]++,t))}},Et=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},ft=(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?ut(e,n,t):(o=tt[n],ut(e,o+Ke+1,t),r=je[o],0!==r&&(n-=st[o],ht(e,n,r)),i--,o=dt(i),ut(e,o,s),r=$e[o],0!==r&&(i-=it[o],ht(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--)vt(e,s,r);l=o;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],vt(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++,vt(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,E=0;for(u=0;u<=We;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,E++),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!==E){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]--,E-=2}while(E>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),pt(s,d,e.bl_count)},Ct=(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{ht(e,0+(i?1:0),3),gt(e),ct(e,s),ct(e,~s),s&&e.pending_buf.set(e.window.subarray(t,t+s),e.pending),e.pending+=s};var Nt=(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(Ct(e,e.dyn_ltree,e.l_desc.max_code),Ct(e,e.dyn_dtree,e.d_desc.max_code),mt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Ye[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),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?At(e,t,s,i):4===e.strategy||o===n?(ht(e,2+(i?1:0),3),St(e,Xe,Je)):(ht(e,4+(i?1:0),3),((e,t,s,i)=>{let n;for(ht(e,t-257,5),ht(e,s-1,5),ht(e,i-4,4),n=0;n{yt||((()=>{let e,t,s,i,n;const o=new Array(16);for(s=0,i=0;i<28;i++)for(st[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*(tt[s]+Ke+1)]++,e.dyn_dtree[2*dt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ht(e,2,3),ut(e,256,Xe),(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 bt=(e,t,s,i)=>{let n=65535&e,o=e>>>16&65535,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};const It=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 xt=(e,t,s,i)=>{const n=It,o=i+s;e^=-1;for(let s=i;s>>8^n[255&(e^t[s])];return~e},Rt={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"},Ot={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:kt,_tr_stored_block:Dt,_tr_flush_block:Lt,_tr_tally:Pt,_tr_align:Ut}=wt,{Z_NO_FLUSH:Mt,Z_PARTIAL_FLUSH:qt,Z_FULL_FLUSH:Ft,Z_FINISH:Ht,Z_BLOCK:Vt,Z_OK:zt,Z_STREAM_END:Gt,Z_STREAM_ERROR:Kt,Z_DATA_ERROR:Bt,Z_BUF_ERROR:Qt,Z_DEFAULT_COMPRESSION:Wt,Z_FILTERED:jt,Z_HUFFMAN_ONLY:$t,Z_RLE:Zt,Z_FIXED:Yt,Z_DEFAULT_STRATEGY:Xt,Z_UNKNOWN:Jt,Z_DEFLATED:es}=Ot,ts=258,ss=262,is=42,ns=113,os=666,rs=(e,t)=>(e.msg=Rt[t],t),as=e=>2*e-(e>4?9:0),ls=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ds=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 cs=(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))},us=(e,t)=>{Lt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,hs(e.strm)},_s=(e,t)=>{e.pending_buf[e.pending++]=t},ps=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Es=(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=bt(e.adler,t,n,s):2===e.state.wrap&&(e.adler=xt(e.adler,t,n,s)),e.next_in+=n,e.total_in+=n,n)},gs=(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-ss?e.strstart-(e.w_size-ss):0,d=e.window,c=e.w_mask,h=e.prev,u=e.strstart+ts;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},fs=e=>{const t=e.w_size;let s,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ss)&&(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),ds(e),i+=t),0===e.strm.avail_in)break;if(s=Es(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=cs(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=cs(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,hs(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&&(Es(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&&(Es(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===Ht)&&t!==Mt&&0===e.strm.avail_in&&i<=n)&&(s=i>n?n:i,r=t===Ht&&0===e.strm.avail_in&&s===i?1:0,Dt(e,e.block_start,s,r),e.block_start+=s,hs(e.strm)),r?3:1)},Ss=(e,t)=>{let s,i;for(;;){if(e.lookahead=3&&(e.ins_h=cs(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-ss&&(e.match_length=gs(e,s)),e.match_length>=3)if(i=Pt(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=cs(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=cs(e,e.ins_h,e.window[e.strstart+1]);else i=Pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(us(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2},ms=(e,t)=>{let s,i,n;for(;;){if(e.lookahead=3&&(e.ins_h=cs(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=Pt(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=cs(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&&(us(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Pt(e,0,e.window[e.strstart-1]),i&&us(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=Pt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2};function Cs(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 Ts=[new Cs(0,0,0,0,vs),new Cs(4,4,8,4,Ss),new Cs(4,5,16,8,Ss),new Cs(4,6,32,32,Ss),new Cs(4,4,16,16,ms),new Cs(8,16,32,32,ms),new Cs(8,16,128,128,ms),new Cs(8,32,128,256,ms),new Cs(32,128,258,1024,ms),new Cs(32,258,258,4096,ms)];function ys(){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=es,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),ls(this.dyn_ltree),ls(this.dyn_dtree),ls(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),ls(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ls(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 As=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==is&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==ns&&t.status!==os?1:0},Ns=e=>{if(As(e))return rs(e,Kt);e.total_in=e.total_out=0,e.data_type=Jt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?is:ns,e.adler=2===t.wrap?0:1,t.last_flush=-2,kt(t),zt},ws=e=>{const t=Ns(e);var s;return t===zt&&((s=e.state).window_size=2*s.w_size,ls(s.head),s.max_lazy_match=Ts[s.level].max_lazy,s.good_match=Ts[s.level].good_length,s.nice_match=Ts[s.level].nice_length,s.max_chain_length=Ts[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},bs=(e,t,s,i,n,o)=>{if(!e)return Kt;let r=1;if(t===Wt&&(t=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||s!==es||i<8||i>15||t<0||t>9||o<0||o>Yt||8===i&&1!==r)return rs(e,Kt);8===i&&(i=9);const a=new ys;return e.state=a,a.strm=e,a.status=is,a.wrap=r,a.gzhead=null,a.w_bits=i,a.w_size=1<bs(e,t,es,15,8,Xt),deflateInit2:bs,deflateReset:ws,deflateResetKeep:Ns,deflateSetHeader:(e,t)=>As(e)||2!==e.state.wrap?Kt:(e.state.gzhead=t,zt),deflate:(e,t)=>{if(As(e)||t>Vt||t<0)return e?rs(e,Kt):Kt;const s=e.state;if(!e.output||0!==e.avail_in&&!e.input||s.status===os&&t!==Ht)return rs(e,0===e.avail_out?Qt:Kt);const i=s.last_flush;if(s.last_flush=t,0!==s.pending){if(hs(e),0===e.avail_out)return s.last_flush=-1,zt}else if(0===e.avail_in&&as(t)<=as(i)&&t!==Ht)return rs(e,Qt);if(s.status===os&&0!==e.avail_in)return rs(e,Qt);if(s.status===is&&0===s.wrap&&(s.status=ns),s.status===is){let t=es+(s.w_bits-8<<4)<<8,i=-1;if(i=s.strategy>=$t||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,ps(s,t),0!==s.strstart&&(ps(s,e.adler>>>16),ps(s,65535&e.adler)),e.adler=1,s.status=ns,hs(e),0!==s.pending)return s.last_flush=-1,zt}if(57===s.status)if(e.adler=0,_s(s,31),_s(s,139),_s(s,8),s.gzhead)_s(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)),_s(s,255&s.gzhead.time),_s(s,s.gzhead.time>>8&255),_s(s,s.gzhead.time>>16&255),_s(s,s.gzhead.time>>24&255),_s(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),_s(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(_s(s,255&s.gzhead.extra.length),_s(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=xt(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69;else if(_s(s,0),_s(s,0),_s(s,0),_s(s,0),_s(s,0),_s(s,9===s.level?2:s.strategy>=$t||s.level<2?4:0),_s(s,3),s.status=ns,hs(e),0!==s.pending)return s.last_flush=-1,zt;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=xt(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex+=n,hs(e),0!==s.pending)return s.last_flush=-1,zt;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=xt(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=xt(e.adler,s.pending_buf,s.pending-i,i)),hs(e),0!==s.pending)return s.last_flush=-1,zt;i=0}t=s.gzindexi&&(e.adler=xt(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=xt(e.adler,s.pending_buf,s.pending-i,i)),hs(e),0!==s.pending)return s.last_flush=-1,zt;i=0}t=s.gzindexi&&(e.adler=xt(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&&(hs(e),0!==s.pending))return s.last_flush=-1,zt;_s(s,255&e.adler),_s(s,e.adler>>8&255),e.adler=0}if(s.status=ns,hs(e),0!==s.pending)return s.last_flush=-1,zt}if(0!==e.avail_in||0!==s.lookahead||t!==Mt&&s.status!==os){let i=0===s.level?vs(s,t):s.strategy===$t?((e,t)=>{let s;for(;;){if(0===e.lookahead&&(fs(e),0===e.lookahead)){if(t===Mt)return 1;break}if(e.match_length=0,s=Pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(us(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2})(s,t):s.strategy===Zt?((e,t)=>{let s,i,n,o;const r=e.window;for(;;){if(e.lookahead<=ts){if(fs(e),e.lookahead<=ts&&t===Mt)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+ts;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=Pt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=Pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(us(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ht?(us(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(us(e,!1),0===e.strm.avail_out)?1:2})(s,t):Ts[s.level].func(s,t);if(3!==i&&4!==i||(s.status=os),1===i||3===i)return 0===e.avail_out&&(s.last_flush=-1),zt;if(2===i&&(t===qt?Ut(s):t!==Vt&&(Dt(s,0,0,!1),t===Ft&&(ls(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),hs(e),0===e.avail_out))return s.last_flush=-1,zt}return t!==Ht?zt:s.wrap<=0?Gt:(2===s.wrap?(_s(s,255&e.adler),_s(s,e.adler>>8&255),_s(s,e.adler>>16&255),_s(s,e.adler>>24&255),_s(s,255&e.total_in),_s(s,e.total_in>>8&255),_s(s,e.total_in>>16&255),_s(s,e.total_in>>24&255)):(ps(s,e.adler>>>16),ps(s,65535&e.adler)),hs(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?zt:Gt)},deflateEnd:e=>{if(As(e))return Kt;const t=e.state.status;return e.state=null,t===ns?rs(e,Bt):zt},deflateSetDictionary:(e,t)=>{let s=t.length;if(As(e))return Kt;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==is||i.lookahead)return Kt;if(1===n&&(e.adler=bt(e.adler,t,s,0)),i.wrap=0,s>=i.w_size){0===n&&(ls(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,fs(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=cs(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,fs(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,zt},deflateInfo:"pako deflate (from Nodeca project)"};const xs=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Rs=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)xs(s,t)&&(e[t]=s[t])}}return e},Os=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;Ds[254]=Ds[254]=1;var Ls=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},Ps=(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&&ks)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+Ds[e[s]]>t?s:t};var Ms=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 qs=Object.prototype.toString,{Z_NO_FLUSH:Fs,Z_SYNC_FLUSH:Hs,Z_FULL_FLUSH:Vs,Z_FINISH:zs,Z_OK:Gs,Z_STREAM_END:Ks,Z_DEFAULT_COMPRESSION:Bs,Z_DEFAULT_STRATEGY:Qs,Z_DEFLATED:Ws}=Ot;function js(e){this.options=Rs({level:Bs,method:Ws,chunkSize:16384,windowBits:15,memLevel:8,strategy:Qs},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 Ms,this.strm.avail_out=0;let s=Is.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(s!==Gs)throw new Error(Rt[s]);if(t.header&&Is.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Ls(t.dictionary):"[object ArrayBuffer]"===qs.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,s=Is.deflateSetDictionary(this.strm,e),s!==Gs)throw new Error(Rt[s]);this._dict_set=!0}}function $s(e,t){const s=new js(t);if(s.push(e,!0),s.err)throw s.msg||Rt[s.err];return s.result}js.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?zs:Fs,"string"==typeof e?s.input=Ls(e):"[object ArrayBuffer]"===qs.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===Hs||o===Vs)&&s.avail_out<=6)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else{if(n=Is.deflate(s,o),n===Ks)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),n=Is.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Gs;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},js.prototype.onData=function(e){this.chunks.push(e)},js.prototype.onEnd=function(e){e===Gs&&(this.result=Os(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Zs={Deflate:js,deflate:$s,deflateRaw:function(e,t){return(t=t||{}).raw=!0,$s(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,$s(e,t)},constants:Ot};const Ys=16209;var Xs=function(e,t){let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A,N;const w=e.state;s=e.next_in,A=e.input,i=s+(e.avail_in-5),n=e.next_out,N=e.output,o=n-(t-e.avail_out),r=n+(e.avail_out-257),a=w.dmax,l=w.wsize,d=w.whave,c=w.wnext,h=w.window,u=w.hold,_=w.bits,p=w.lencode,E=w.distcode,g=(1<>>24,u>>>=S,_-=S,S=v>>>16&255,0===S)N[n++]=65535&v;else{if(!(16&S)){if(64&S){if(32&S){w.mode=16191;break e}e.msg="invalid literal/length code",w.mode=Ys;break e}v=p[(65535&v)+(u&(1<>>=S,_-=S),_<15&&(u+=A[s++]<<_,_+=8,u+=A[s++]<<_,_+=8),v=E[u&f];;){if(S=v>>>24,u>>>=S,_-=S,S=v>>>16&255,16&S){if(C=65535&v,S&=15,_a){e.msg="invalid distance too far back",w.mode=Ys;break e}if(u>>>=S,_-=S,S=n-o,C>S){if(S=C-S,S>d&&w.sane){e.msg="invalid distance too far back",w.mode=Ys;break e}if(T=0,y=h,0===c){if(T+=l-S,S2;)N[n++]=y[T++],N[n++]=y[T++],N[n++]=y[T++],m-=3;m&&(N[n++]=y[T++],m>1&&(N[n++]=y[T++]))}else{T=n-C;do{N[n++]=N[T++],N[n++]=N[T++],N[n++]=N[T++],m-=3}while(m>2);m&&(N[n++]=N[T++],m>1&&(N[n++]=N[T++]))}break}if(64&S){e.msg="invalid distance code",w.mode=Ys;break e}v=E[(65535&v)+(u&(1<>3,s-=m,_-=m<<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,E=0,g=0,f=0,v=0,S=0,m=0,C=0,T=0,y=0,A=0,N=null;const w=new Uint16Array(16),b=new Uint16Array(16);let I,x,R,O=null;for(E=0;E<=Js;E++)w[E]=0;for(g=0;g=1&&0===w[v];v--);if(S>v&&(S=v),0===v)return n[o++]=20971520,n[o++]=20971520,a.bits=1,0;for(f=1;f0&&(0===e||1!==v))return-1;for(b[1]=0,E=1;E852||2===e&&y>592)return 1;for(;;){I=E-C,r[g]+1=p?(x=O[r[g]-p],R=N[r[g]-p]):(x=96,R=0),d=1<>C)+c]=I<<24|x<<16|R}while(0!==c);for(d=1<>=1;if(0!==d?(A&=d-1,A+=d):A=0,g++,0==--w[E]){if(E===v)break;E=t[s+r[g]]}if(E>S&&(A&u)!==h){for(0===C&&(C=S),_+=f,m=E-C,T=1<852||2===e&&y>592)return 1;h=A&u,n[h]=S<<24|m<<16|_-o}}return 0!==A&&(n[_+A]=E-C<<24|64<<16),a.bits=S,0};const{Z_FINISH:oi,Z_BLOCK:ri,Z_TREES:ai,Z_OK:li,Z_STREAM_END:di,Z_NEED_DICT:ci,Z_STREAM_ERROR:hi,Z_DATA_ERROR:ui,Z_MEM_ERROR:_i,Z_BUF_ERROR:pi,Z_DEFLATED:Ei}=Ot,gi=16180,fi=16190,vi=16191,Si=16192,mi=16194,Ci=16199,Ti=16200,yi=16206,Ai=16209,Ni=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function wi(){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 bi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Ii=e=>{if(bi(e))return hi;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=gi,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,li},xi=e=>{if(bi(e))return hi;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ii(e)},Ri=(e,t)=>{let s;if(bi(e))return hi;const i=e.state;return t<0?(s=0,t=-t):(s=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?hi:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=s,i.wbits=t,xi(e))},Oi=(e,t)=>{if(!e)return hi;const s=new wi;e.state=s,s.strm=e,s.window=null,s.mode=gi;const i=Ri(e,t);return i!==li&&(e.state=null),i};let ki,Di,Li=!0;const Pi=e=>{if(Li){ki=new Int32Array(512),Di=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(ni(1,e.lens,0,288,ki,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ni(2,e.lens,0,32,Di,0,e.work,{bits:5}),Li=!1}e.lencode=ki,e.lenbits=9,e.distcode=Di,e.distbits=5},Ui=(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.whaveOi(e,15),inflateInit2:Oi,inflate:(e,t)=>{let s,i,n,o,r,a,l,d,c,h,u,_,p,E,g,f,v,S,m,C,T,y,A=0;const N=new Uint8Array(4);let w,b;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(bi(e)||!e.output||!e.input&&0!==e.avail_in)return hi;s=e.state,s.mode===vi&&(s.mode=Si),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,y=li;e:for(;;)switch(s.mode){case gi:if(0===s.wrap){s.mode=Si;break}for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>>8&255,s.check=xt(s.check,N,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=Ai;break}if((15&d)!==Ei){e.msg="unknown compression method",s.mode=Ai;break}if(d>>>=4,c-=4,T=8+(15&d),0===s.wbits&&(s.wbits=T),T>15||T>s.wbits){e.msg="invalid window size",s.mode=Ai;break}s.dmax=1<>8&1),512&s.flags&&4&s.wrap&&(N[0]=255&d,N[1]=d>>>8&255,s.check=xt(s.check,N,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,N[2]=d>>>16&255,N[3]=d>>>24&255,s.check=xt(s.check,N,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&&(N[0]=255&d,N[1]=d>>>8&255,s.check=xt(s.check,N,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=xt(s.check,N,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&&(T=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+_),T)),512&s.flags&&4&s.wrap&&(s.check=xt(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{T=i[o+_++],s.head&&T&&s.length<65536&&(s.head.name+=String.fromCharCode(T))}while(T&&_>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=vi;break;case 16189:for(;c<32;){if(0===a)break e;a--,d+=i[o++]<>>=7&c,c-=7&c,s.mode=yi;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(Pi(s),s.mode=Ci,t===ai){d>>>=2,c-=2;break e}break;case 2:s.mode=16196;break;case 3:e.msg="invalid block type",s.mode=Ai}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=Ai;break}if(s.length=65535&d,d=0,c=0,s.mode=mi,t===ai)break e;case mi: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=vi;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=Ai;break}s.have=0,s.mode=16197;case 16197:for(;s.have>>=3,c-=3}for(;s.have<19;)s.lens[I[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,w={bits:s.lenbits},y=ni(0,s.lens,0,19,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid code lengths set",s.mode=Ai;break}s.have=0,s.mode=16198;case 16198:for(;s.have>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=g,c-=g,s.lens[s.have++]=v;else{if(16===v){for(b=g+2;c>>=g,c-=g,0===s.have){e.msg="invalid bit length repeat",s.mode=Ai;break}T=s.lens[s.have-1],_=3+(3&d),d>>>=2,c-=2}else if(17===v){for(b=g+3;c>>=g,c-=g,T=0,_=3+(7&d),d>>>=3,c-=3}else{for(b=g+7;c>>=g,c-=g,T=0,_=11+(127&d),d>>>=7,c-=7}if(s.have+_>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=Ai;break}for(;_--;)s.lens[s.have++]=T}}if(s.mode===Ai)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=Ai;break}if(s.lenbits=9,w={bits:s.lenbits},y=ni(1,s.lens,0,s.nlen,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid literal/lengths set",s.mode=Ai;break}if(s.distbits=6,s.distcode=s.distdyn,w={bits:s.distbits},y=ni(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,w),s.distbits=w.bits,y){e.msg="invalid distances set",s.mode=Ai;break}if(s.mode=Ci,t===ai)break e;case Ci:s.mode=Ti;case Ti: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,Xs(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===vi&&(s.back=-1);break}for(s.back=0;A=s.lencode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,s.length=v,0===f){s.mode=16205;break}if(32&f){s.back=-1,s.mode=vi;break}if(64&f){e.msg="invalid literal/length code",s.mode=Ai;break}s.extra=15&f,s.mode=16201;case 16201:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=16202;case 16202:for(;A=s.distcode[d&(1<>>24,f=A>>>16&255,v=65535&A,!(g<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],g=A>>>24,f=A>>>16&255,v=65535&A,!(S+g<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=g,c-=g,s.back+=g,64&f){e.msg="invalid distance code",s.mode=Ai;break}s.offset=v,s.extra=15&f,s.mode=16203;case 16203:if(s.extra){for(b=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=Ai;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=Ai;break}_>s.wnext?(_-=s.wnext,p=s.wsize-_):p=s.wnext-_,_>s.length&&(_=s.length),E=s.window}else E=n,p=r-s.offset,_=s.length;_>l&&(_=l),l-=_,s.length-=_;do{n[r++]=E[p++]}while(--_);0===s.length&&(s.mode=Ti);break;case 16205:if(0===l)break e;n[r++]=s.length,l--,s.mode=Ti;break;case yi:if(s.wrap){for(;c<32;){if(0===a)break e;a--,d|=i[o++]<{if(bi(e))return hi;let t=e.state;return t.window&&(t.window=null),e.state=null,li},inflateGetHeader:(e,t)=>{if(bi(e))return hi;const s=e.state;return 2&s.wrap?(s.head=t,t.done=!1,li):hi},inflateSetDictionary:(e,t)=>{const s=t.length;let i,n,o;return bi(e)?hi:(i=e.state,0!==i.wrap&&i.mode!==fi?hi:i.mode===fi&&(n=1,n=bt(n,t,s,0),n!==i.check)?ui:(o=Ui(e,t,s,s),o?(i.mode=16210,_i):(i.havedict=1,li)))},inflateInfo:"pako inflate (from Nodeca project)"};var qi=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 Fi=Object.prototype.toString,{Z_NO_FLUSH:Hi,Z_FINISH:Vi,Z_OK:zi,Z_STREAM_END:Gi,Z_NEED_DICT:Ki,Z_STREAM_ERROR:Bi,Z_DATA_ERROR:Qi,Z_MEM_ERROR:Wi}=Ot;function ji(e){this.options=Rs({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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ms,this.strm.avail_out=0;let s=Mi.inflateInit2(this.strm,t.windowBits);if(s!==zi)throw new Error(Rt[s]);if(this.header=new qi,Mi.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Ls(t.dictionary):"[object ArrayBuffer]"===Fi.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=Mi.inflateSetDictionary(this.strm,t.dictionary),s!==zi)))throw new Error(Rt[s])}function $i(e,t){const s=new ji(t);if(s.push(e),s.err)throw s.msg||Rt[s.err];return s.result}ji.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?Vi:Hi,"[object ArrayBuffer]"===Fi.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=Mi.inflate(s,r),o===Ki&&n&&(o=Mi.inflateSetDictionary(s,n),o===zi?o=Mi.inflate(s,r):o===Qi&&(o=Ki));s.avail_in>0&&o===Gi&&s.state.wrap>0&&0!==e[s.next_in];)Mi.inflateReset(s),o=Mi.inflate(s,r);switch(o){case Bi:case Qi:case Ki:case Wi:return this.onEnd(o),this.ended=!0,!1}if(a=s.avail_out,s.next_out&&(0===s.avail_out||o===Gi))if("string"===this.options.to){let e=Us(s.output,s.next_out),t=s.next_out-e,n=Ps(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!==zi||0!==a){if(o===Gi)return o=Mi.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},ji.prototype.onData=function(e){this.chunks.push(e)},ji.prototype.onEnd=function(e){e===zi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Os(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Zi={Inflate:ji,inflate:$i,inflateRaw:function(e,t){return(t=t||{}).raw=!0,$i(e,t)},ungzip:$i,constants:Ot};const{Deflate:Yi,deflate:Xi,deflateRaw:Ji,gzip:en}=Zs,{Inflate:tn,inflate:sn,inflateRaw:nn,ungzip:on}=Zi;var rn={Deflate:Yi,deflate:Xi,deflateRaw:Ji,gzip:en,Inflate:tn,inflate:sn,inflateRaw:nn,ungzip:on,constants:Ot};const an=t=>e(void 0,void 0,void 0,(function*(){const e=rn.ungzip(t);return String.fromCharCode.apply(null,e)}));var ln,dn;exports.ConnectionState=void 0,(ln=exports.ConnectionState||(exports.ConnectionState={})).CONNECTING="CONNECTING",ln.OPEN="OPEN",ln.CLOSED="CLOSED";class cn extends I{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}get ws(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}_handleMessage(e){e.split("\n").forEach((e=>{if(e){const t=Te.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 Ce(t.payload);e.expiresIn>=0&&this._dispatcher.dispatch(e)}}else"NOOP"===t.code||this.dispatch("message",t)}}))}connect(t,s=""){return e(this,void 0,void 0,(function*(){this._ws=new WebSocket(t,encodeURIComponent(s)),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*(){try{const e=yield an(s.result);this._handleMessage(e)}catch(e){this.error(e)}}))}else if(t.data instanceof ArrayBuffer)try{const e=yield an(new Uint8Array(t.data));this._handleMessage(e)}catch(e){this.error(e)}else if("undefined"!=typeof Buffer&&t.data instanceof Buffer)try{const e=t.data,s=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),i=yield an(s);this._handleMessage(i)}catch(e){this.error(e)}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._ws.onopen=ze,this._ws.onmessage=ze,this._ws.onerror=ze,this.connectionState!==exports.ConnectionState.CLOSED?(this._ws.onclose=()=>{this.dispatch("close"),e()},this._ws.close(),this._ws=void 0):e()):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 hn extends R{constructor({all:e,feed:t,custom_types:s,ts:i}){super(),this.all=e,this.feed=t,this.customTypes=s,this.ts=i}}class un{constructor(e,{session: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 Ve(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this.websocketClient=new cn(e,{sdkState:s,dispatcher:i,logger:n}),this.websocketClient.on("message",(e=>{if(e.payload.unread_cnt&&this._dispatcher.dispatch(new hn(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 qe;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",t.requestId,i),e.reject(i)):(this._logger.debug("receive websocket ack",t.requestId,t),this._logger.debug("receive websocket ack",n),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 ve)return yield this._sendApiRequest(t);if(t instanceof ye)return yield this._sendWebsocketRequest(t);throw o.invalidParameters}))}cancel(e){this.apiClient.cancel(e)}cancelAll(){this.apiClient.cancelAll()}}exports.ConnectionStateType=void 0,(dn=exports.ConnectionStateType||(exports.ConnectionStateType={}))[dn.NONE=0]="NONE",dn[dn.INITIALIZED=1]="INITIALIZED",dn[dn.CONNECTING=2]="CONNECTING",dn[dn.CONNECTED=3]="CONNECTED",dn[dn.RECONNECTING=4]="RECONNECTING",dn[dn.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",dn[dn.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",dn[dn.LOGOUT=7]="LOGOUT";class _n extends R{constructor({stateType:e}){super(),this.stateType=e}}class pn extends R{}class En extends R{}class gn extends R{}class fn{constructor(e){var t,s,i,n;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(s=e.feed_channels)&&void 0!==s?s:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(n=e.settings_updated_at)&&void 0!==n?n:0}static payloadify(e){return O(k({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}class vn{constructor(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}static payloadify(e){return O(k({last_updated_at:e.lastUpdatedAt}))}}class Sn{constructor(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}static payloadify(e){return O(k({template_list_token:e.token}))}}class mn{constructor(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}){this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}static payloadify(e){return O(k({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}class Cn{constructor(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}){this.default=new mn(e.default),this.realTime=new mn(e.realtime)}static payloadify(e){return O(k({default:mn.payloadify(e.default),realtime:mn.payloadify(e.realTime)}))}}const Tn=1048576;var yn,An;exports.UnreadCountThreadingPolicy=void 0,(yn=exports.UnreadCountThreadingPolicy||(exports.UnreadCountThreadingPolicy={}))[yn.NONE=0]="NONE",yn[yn.INCLUDE_REPLY=1]="INCLUDE_REPLY",yn[yn.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",yn[yn.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",exports.LastMessageThreadingPolicy=void 0,(An=exports.LastMessageThreadingPolicy||(exports.LastMessageThreadingPolicy={}))[An.NONE=0]="NONE",An[An.INCLUDE_REPLY=1]="INCLUDE_REPLY",An[An.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",An[An.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";class Nn{constructor(e={}){var t,s,i,n,o,r,a;this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Tn: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.unreadCountThreadingPolicy=null!==(o=e.unread_cnt_threading_policy)&&void 0!==o?o:exports.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(r=e.last_msg_threading_policy)&&void 0!==r?r:exports.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new vn(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new fn(e.notifications):null,this.messageTemplateInfo=e.message_template?new Sn(e.message_template):null,this.statConfigInfo=e.log_publish_config?new Cn(e.log_publish_config):new Cn}static payloadify(e){return O(k({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Tn,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?vn.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?fn.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Sn.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Cn.payloadify(e.statConfigInfo):null}))}}class wn{constructor(e){this._iid="",this._iid=e}static payloadify(e){return{}}}class bn extends ve{constructor({userId:e,metadata:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${W}/${e}/metadata`,this.params={metadata:t}}}class In extends Se{constructor(e,t){super(e,t),this.metaData=t}}class xn extends ve{constructor({userId:e,metadata:t,upsert:s}){super(),this.method=exports.APIRequestMethod.PUT,this.path=`${W}/${e}/metadata`,this.params={metadata:t,upsert:s}}}class Rn extends Se{constructor(e,t){super(e,t),this.metadata=t}}class On extends ve{constructor({userId:e,metadataKey:t}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${W}/${e}/metadata/${t}`}}class kn extends ve{constructor({userId:e}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${W}/${e}/metadata`}}const Dn=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return s._iid&&delete s._iid,t&&t(s),s},Ln=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return t&&t(s),s},Pn=e=>({do:t=>{e||t()},throw:t=>{if(!e)throw t}});var Un;exports.UserOnlineState=void 0,(Un=exports.UserOnlineState||(exports.UserOnlineState={})).ONLINE="online",Un.OFFLINE="offline",Un.NON_AVAILABLE="nonavailable";class Mn extends wn{constructor(e,t){var s,i,n,o,r,a,c,h,u,_,p,E;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!==(E=t.friend_name)&&void 0!==E?E:null}static payloadify(e){return O(k(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}=Lo.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainProfileUrl}?auth=${e.ekey}`:this.plainProfileUrl}serialize(){return Dn(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*(){Pn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Lo.of(this._iid),i=new bn({userId:e.userId,metadata:t}),n=yield s.send(i),{metaData:r}=n.as(In);return this._applyMetaData(r),this.metaData}))}updateMetaData(t,s=!1){return e(this,void 0,void 0,(function*(){Pn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:i}=Lo.of(this._iid),n=new xn({userId:e.userId,metadata:t,upsert:s}),r=yield i.send(n),{metadata:a}=r.as(Rn);return this._applyMetaData(a),this.metaData}))}deleteMetaData(t){return e(this,void 0,void 0,(function*(){Pn(l("string",t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Lo.of(this._iid),i=new On({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}=Lo.of(this._iid),s=new kn({userId:e.userId});yield t.send(s),this.metaData={}}))}}class qn extends R{constructor({userProfile:e}){super(),this.userProfile=e}}class Fn{constructor(e,t){var s,i,n,o,r,a,l,d,c,h,u,_,p,E;this._iid=e,this.appInfo=new Nn(t),this.user=new Mn(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!==(E=t.back_off_delay)&&void 0!==E?E:100}static payloadify(e){return O(k(Object.assign(Object.assign(Object.assign({},Mn.payloadify(e.user)),Nn.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=Lo.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 qn({userProfile:this}))}}class Hn extends R{constructor({request:e=!0,features:t={},options:s={},statConfigInfo:i}){super(),this.request=e,this.features=Object.assign({localCache:!0,notification:!0},t),this.options=Object.assign({ingestion:!0},s),this.statConfigInfo=i}}class Vn extends Te{constructor(e,t,s){var i,n,r,a;super(e,t,s),this.error=null,this.services=[],this.userProfile=new Fn(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,this.services=null!==(a=s.services)&&void 0!==a?a:[]}static asError(e){return new Vn("","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=Lo.of(t);if(!e)throw o.lostInstance;{const{sessionManager:t,dispatcher:s}=e;yield t.login(this),this.userProfile.apply(),s.dispatch(new Hn({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo}))}}}))}}class zn{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,cause:n=null}){return e(this,void 0,void 0,(function*(){}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){}))}}const Gn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){if(!(e instanceof o))throw e;e.throwOutside()}})),Kn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){}}));class Bn extends zn{constructor(e={}){var t;super(),this.type=exports.ConnectionStateType.LOGOUT,this.name="logout",this._wasPreviouslyConnected=null===(t=e.wasPreviouslyConnected)||void 0===t||t}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 io,s),this._wasPreviouslyConnected&&Gn((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onDisconnected&&e.onDisconnected(i)}))}))))}))}}class Qn extends zn{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 to({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Yn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn,e)}))}}class Wn extends zn{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 Yn,e))}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new to({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Yn,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Qn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn,e)}))}}const jn=t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}));class $n{calcTimeout(){return 0}}const Zn=(t,s,i=new $n)=>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||et(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=new qe;this._callbacks.push((e=>e?i.reject(e):i.resolve())),Gn((()=>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 Zn(((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){if(e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);if(e.isSessionExpiredError||e.isSessionInvalidatedError)return void s(e)}throw e}}))),i,n),yield t.changeState(new Xn,s),this._flushCallbacks(),Gn((()=>e(this,void 0,void 0,(function*(){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 Wn({autoReconnect:!1}),s)),this._flushCallbacks(i),Gn((()=>e(this,void 0,void 0,(function*(){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 qe;return this._halt(o.connectionCanceled),t.cancelConnectForRetry(),this._callbacks.push((()=>{const i=Date.now();t.changeState(new to({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 qe;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 Wn({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 Qn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Bn,e)}))}}class Xn extends zn{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 Yn,e)}))}onDisconnect(t,{autoReconnect:s}){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Wn({autoReconnect:s}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Qn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn,e)}))}}var Jn;!function(e){e.ExternalSetBackground="ExternalSetBackground",e.ExternalDisconnectWebSocket="ExternalDisconnectWebSocket"}(Jn||(Jn={}));class eo{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:o,dispatcher:r,logger:a,disableWebSocketCloseEventHandling:l=!1}){this._disableWebSocketCloseEventHandling=!1,this._webSocketClosedCause=null,this._logger=a,this._disableWebSocketCloseEventHandling=l,this._context=new ao(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",(()=>{this.isConnecting||this.isConnected||(this._logger.debug("try reconnect by session key refresh"),Kn((()=>e(this,void 0,void 0,(function*(){yield this.reconnect()})))))})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(()=>{"foreground"!==this._sdkState.appState||this._webSocketClosedCause||Kn((()=>e(this,void 0,void 0,(function*(){this._sessionManager.isSessionKeyRefreshing?yield this.disconnectWebSocket():(this._logger.debug("try reconnect by websocket connection closed"),yield 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}get websocketClient(){return this._websocketClient}connect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onConnect(this._context,t),this._registerEventDispatcher()}))}reconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{})}))}resetAndReconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=null,yield e.onReconnect(this._context,{resetReconnectCount:!0})}))}background(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._webSocketClosedCause=Jn.ExternalSetBackground,yield e.onDisconnect(this._context,{autoReconnect:!1,cause:this._webSocketClosedCause})}))}disconnect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;yield e.onDisconnect(this._context,{error:t,autoReconnect:!0,cause:this._webSocketClosedCause})}))}disconnectWebSocket(t=!1){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;t&&(this._webSocketClosedCause=Jn.ExternalDisconnectWebSocket),yield e.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause})}))}logout(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._clearEventDispatcher(),yield e.onLogout(this._context,t)}))}}class to extends zn{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 qe;this._callbacks.push((e=>e?i.reject(e):i.resolve()));try{yield Zn((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 Xn,s),Gn((()=>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 io,s)),Gn((()=>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 qe;return this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:i=!1,cause:n=null}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:so(n)),t.hasSession?yield t.changeState(new Wn({autoReconnect:i}),e):yield t.changeState(new Bn,e)}))}onDisconnectWebSocket(t,s){return e(this,void 0,void 0,(function*(){this._halt(so((null==s?void 0:s.cause)||null));const e=Date.now();t.hasSession?yield t.changeState(new Qn,e):yield t.changeState(new Bn,e)}))}onLogout(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:o.connectionCanceled),yield t.changeState(new Bn,e)}))}}function so(e){const t=o.connectionCanceled;if(e){let s=null;switch(e){case Jn.ExternalSetBackground:s="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case Jn.ExternalDisconnectWebSocket:s="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}s&&t.setDetail(s)}return t}class io extends zn{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 to({authToken:s}),e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Bn({wasPreviouslyConnected:!1}),e)}))}}class no extends ye{constructor(){super({code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}}class oo{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 no;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)}}const ro=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"];class ao extends I{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:r,dispatcher:a,logger:l,entryState:d=new io}){var c;super(),this._stateUpdatedAt=0,this._connectingAt=0,this._connectedAt=0,this._logiReceivedAt=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 oo({pingDelegate:{send:e=>this._websocketClient.send(e),error:e=>this._websocketClient.error(e)},sdkState:this.sdkState,logger:l})),this._websocketClient.on("open",(()=>{this._connectedAt=Date.now(),this._tryResolveConnectionRequest()})).on("message",(e=>{if("LOGI"===e.code)this.clearLoginTimer(),this._dispatcher.dispatch(e.as(Vn))})).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 Vn&&(this._unresolvedLogi=e,this._tryResolveConnectionRequest())}))}get currentState(){return this._currentState}get hasSession(){return this._sessionManager.session.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 _n({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;this._websocketClient.isOpen&&e&&(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),e.error?(this._sessionManager.session.authToken=void 0,e.error.isSessionExpiredError||e.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Ce({reason:e.error.code,message:e.error.message})):this._logger.warn(`login failed: ${e.error}`),this._rejectConnectionRequest(e.error)):(yield e.applyTo(this._iid),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(){var e;const{appId:t,appVersion:s,userId:n,extensions:o,sendbirdRuntimeEnvironment:r}=this.sdkState,{localCacheEnabled:a}=this.cacheContext,{session:l}=this._sessionManager,d=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,c=!!(null!=o?o:{}).sb_uikit,h=Me.userAgentWithExtension(o);return`${this.sdkState.websocket.host}/?p=JS&pv=${encodeURIComponent(i.OS_VERSION)}&sv=${encodeURIComponent(i.SDK_VERSION)}&ai=${t}${s?`&av=${s}`:""}${l.hasSession?"":`&user_id=${encodeURIComponent(n)}`}&pmce=${d?1:0}&active=1&device_token_types=${encodeURIComponent(["gcm","huawei","apns"].join(","))}&SB-User-Agent=${h}&SB-SDK-User-Agent=${encodeURIComponent(Me.sendbirdSdkUserAgentWithExtension(r))}&Request-Sent-Timestamp=${Date.now().toString()}&include_extra_data=${encodeURIComponent(String(ro))}${this._sessionManager.handler?"&expiring_session=1":""}&use_local_cache=${a?1:0}&include_poll_details=1${c?"&uikit_config=1":""}`}_statLogConnection(e){var t;this._dispatcher.dispatch(new Ie(new Oe({type:exports.StatType.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:this._connectedAt>0?this._connectedAt-this._connectingAt:Date.now()-this._connectingAt,logi_latency:this._logiReceivedAt>0?this._logiReceivedAt-this._connectingAt:void 0,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=new qe;if(this._connectionRequestQueue.push(e),1===this._connectionRequestQueue.length){this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout((()=>{this._loginTimer=void 0,this._rejectConnectionRequest(o.loginTimeout)}),null===(s=this.sdkState.websocket)||void 0===s?void 0:s.responseTimeout);const{session:e}=this._sessionManager;t&&(e.authToken=t,e.sessionKey=void 0);const i=this._url();e.sessionKey||e.authToken?this._websocketClient.connect(i,JSON.stringify(e.hasSession?{auth:e.sessionKey}:{token:e.authToken})):this._websocketClient.connect(i,JSON.stringify({}))}return e.promise}))}cancelConnectForRetry(){this._dispatcher.dispatch(Vn.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.disconnect(),yield this._sessionManager.clear()}))}clearLoginTimer(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}class lo extends ve{constructor({appId:e,userId:t,includeUIKitConfig:s=!1,localCacheEnabled:i=!0,expiringSession:n=!0}){super(),this.path=`${j}/${t}/authentication`,this.method=exports.APIRequestMethod.POST,this.params=O({expiring_session:!!n,include_logi:!0,include_extra_data:String(ro),uikit_config:s,use_local_cache:i,app_id:e}),this.requireAuth=!1}}class co extends Se{constructor(e,t){super(e,t),this.logi=new Vn(e,"LOGI",t)}}var ho;!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(ho||(ho={}));const uo=[Ae,lo];class _o{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r=!1}){this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new un(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this._session=t,this._logger=n,this._dispatcher=i,this._dispatcher.on((e=>{var t;if(e instanceof _n){const{stateType:s}=e;switch(this._currentConnectionStateType=s,s){case exports.ConnectionStateType.CONNECTED:this._resolveLazyCallQueue();break;case exports.ConnectionStateType.INITIALIZED:case exports.ConnectionStateType.INTERNAL_DISCONNECTED:case exports.ConnectionStateType.EXTERNAL_DISCONNECTED:case exports.ConnectionStateType.LOGOUT:this._rejectLazyCallQueue((null===(t=this._session)||void 0===t?void 0:t.hasSession)?o.connectionClosed:o.connectionRequired)}}else if(e instanceof pn)this._session.hasChatServicePermission||this._resolveLazyCallQueue(ho.API);else if(e instanceof En||e instanceof gn)this._rejectLazyCallQueue(o.connectionClosed);else if(e instanceof xe){const{request:t,deferred:s,error:i}=e;for(const e of uo)if(t instanceof e)return void s.reject(i);this._lazyCallQueue.push({command:t,deferred:s})}}))}get isReady(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED}get isLazyCallActivated(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING||this._currentConnectionStateType===exports.ConnectionStateType.RECONNECTING||this._session.isRefreshing}_classifyLazyCallQueueByScope(e){const t=[],s=[];let i;switch(e){case ho.ALL:i=null;break;case ho.WEBSOCKET:i=ye;break;case ho.API:i=ve}let n=!1;return this._lazyCallQueue.forEach((e=>{!i||e.command instanceof i||(n=!0),n?s.push(e):t.push(e)})),[t,s]}_resolveLazyCallQueue(t=ho.ALL){const[s,i]=this._classifyLazyCallQueueByScope(t);this._lazyCallQueue=i,s.forEach((t=>e(this,void 0,void 0,(function*(){const{command:e,deferred:s,timeout:i}=t;i&&clearTimeout(i);try{const t=yield this.send(e);s.resolve(t)}catch(e){s.reject(e)}}))))}_rejectLazyCallQueue(t,s=ho.ALL){const[i,n]=this._classifyLazyCallQueueByScope(s);this._lazyCallQueue=n,i.forEach((s=>e(this,void 0,void 0,(function*(){const{deferred:e,timeout:i}=s;clearTimeout(i),e.reject(t)}))))}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof ye){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 qe;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 ve){if(this._session.hasSession)return this._logger.debug("send api request",t),yield this.commandRouter.send(t);if(t.hasSessionKey)return this._logger.debug("send api request with tmp session key",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait api request",t);const e=new qe;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*(){if(this._logger.debug("send forced request",t),t instanceof ye||t instanceof ve)return yield this.commandRouter.send(t);throw o.invalidCommand}))}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 po="sendbird@devicetokens";class Eo{constructor({type:e,token:t,device_os:s,device_manufacturer:i,system_push_enabled:n}){this.type=e,this.token=t,this.deviceOS=s,this.deviceManufacturer=i,this.systemPushEnabled=n}static payloadify(e){return O(k({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}const go=new WeakMap;class fo extends I{constructor({_iid:e,session:t,cacheContext:s,sdkState:i,dispatcher:o,requestQueue:r,logger:a,pushNotificationAckManager:l}){super(),this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._isRefreshingAuthToken=!1,this.currentUser=null,this.session=t,this._iid=e,this._cacheContext=s,this._sdkState=i,this._dispatcher=o,this._requestQueue=r,this._logger=a,this._pushNotificationAckManager=l,this._deviceTokens=[],this._dispatcher.on((e=>{var t,s,i;if(e instanceof _n){const{stateType:t}=e;this._currentConnectionStateType=t}else if(e instanceof Ce&&this.handler&&!this.isSessionKeyRefreshing){if(this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?this.close():((null===(s=e.error)||void 0===s?void 0:s.isSessionTokenExpiredError)&&this.refreshAuthToken().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(this._logger.debug("session expired"),this.handler.onSessionExpired&&this.handler.onSessionExpired(),this.refreshSessionKey().catch((e=>{if(n(e)&&"foreground"===this._sdkState.appState)throw e}))))}}))}get ekey(){return go.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 Ne({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(be);if(n)throw n;this.session.sessionKey=null!=i?i:this.session.sessionKey}))}_refreshSessionKeyByApi(t){return e(this,void 0,void 0,(function*(){const s=new Ae({userId:this._sdkState.userId,authToken:t,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0});yield Zn((t=>e(this,void 0,void 0,(function*(){try{const e=yield this._requestQueue.forceSend(s),{key:t,services:i}=e.as(we);this.session.sessionKey=t,this.session.services=i}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){try{return void(yield this._handleSessionRefreshError(e,s))}catch(e){}}try{yield this._refreshSessionKeyByApi(t),this.complete()}catch(e){yield this._handleSessionRefreshError(e,s)}}))}_receiveNewAuthToken(){var t;const s=new qe;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired){let t=null;const i=()=>{t&&(clearTimeout(t),t=null)},n=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.resolve(e))},o=e=>{i(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,s.reject(e))};t=setTimeout((()=>o()),1e3*this._sdkState.sessionTokenRefreshTimeout),Gn((()=>e(this,void 0,void 0,(function*(){var e;(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(n,o)}))))}else s.resolve(null);return s.promise}_handleSessionRefreshError(t,s=!1){return e(this,void 0,void 0,(function*(){if(!(t instanceof o&&(t.isSessionTokenExpiredError||t.code===exports.SendbirdErrorCode.APPLICATION_NOT_FOUND)&&(this.session.authToken=void 0,s)))throw t;{const e=yield this._receiveNewAuthToken();e?(this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken,!1)):yield this.clear()}}))}_isSessionRelatedError(e){return e instanceof o&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}get isSessionKeyRefreshing(){return this.session.isRefreshing}get isRefreshingAuthToken(){return this._isRefreshingAuthToken}get isSessionExpiring(){return!!this.handler}authenticate(t,s){var i;return e(this,void 0,void 0,(function*(){this.session.authToken=s;const e=new lo({appId:this._sdkState.appId,userId:t,includeUIKitConfig:!!(null!==(i=this._sdkState.extensions)&&void 0!==i?i:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:this.isSessionExpiring}),n=yield this._requestQueue.commandRouter.send(e),{logi:o}=n.as(co);if(o.error)throw o.error;this.session.hasChatServicePermission||(yield o.applyTo(this._iid))}))}login(t){var s;return e(this,void 0,void 0,(function*(){const{key:e,ekey:i,services:n,userProfile:o,deviceTokenLastDeletedAt:r=0}=t;this.session.sessionKey=e,this.session.services=n,go.set(this,i),this._deviceTokenCacheEnabled=null===(s=null==o?void 0:o.appInfo)||void 0===s?void 0:s.deviceTokenCache;const{preference:a}=this._cacheContext;if(this._deviceTokenCacheEnabled){const e=yield a.get(po);!e||e.lastDeletedAtnew Eo(Eo.payloadify(e)))),this._deviceTokenLastDeletedAt=e.lastDeletedAt)}else yield a.remove(po)}))}complete(){this.dispatch("refresh"),this._dispatcher.dispatch(new pn),Gn((()=>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){Gn((()=>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"),this._dispatcher.dispatch(new gn),Gn((()=>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()}))))}refreshAuthToken(){return e(this,void 0,void 0,(function*(){let e=null;if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{e=yield this._receiveNewAuthToken(),e?(this._logger.debug("session refreshing.."),this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken)):yield this.clear()}catch(t){const s=e?o.sessionTokenRefreshFailed:o.sessionTokenRequestFailed;throw this._dispatcher.dispatch(new En),this.error(s),this._logger.debug("refresh auth token error = ",s),s}finally{this.session.isRefreshing=!1}}}))}refreshSessionKey(){return e(this,void 0,void 0,(function*(){if(this.isSessionExpiring&&!this.session.isRefreshing){this.session.isRefreshing=!0;try{yield this._refreshSessionKey(this.session.authToken)}catch(e){const t=o.sessionTokenRefreshFailed;throw this._dispatcher.dispatch(new En),this.error(t),t}finally{this.session.isRefreshing=!1}}}))}setDeviceToken(e,t,s){if(this._deviceTokenCacheEnabled){if(this.indexOfDeviceToken(e,t)<0){const i=new Eo({type:e,token:t,device_os:null==s?void 0:s.deviceOS,device_manufacturer:null==s?void 0:s.deviceManufacturer,system_push_enabled:null==s?void 0:s.systemPushEnabled});return this._deviceTokens.push(i),!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(po,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})}}))}clear(){return e(this,void 0,void 0,(function*(){this.currentUser=null,this.session.clear(),this.close(),go.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,yield this.saveDeviceToken(),this._pushNotificationAckManager.clear()}))}}const vo=(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]=vo(e[s],t[s]):o[s]=t[s]}return o}return t};var So,mo;!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(So||(So={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(mo||(mo={}));const Co=100;class To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){this.queue=[],this.flushWaitQueue=[],this.enabledState=So.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=e,this.cacheContext=t,this.requestQueue=s,this.logInfo={deviceId:e,statLogs:[],generation:1,lastFlushedAt:0},this.limit=Co}get isEnabled(){return this.enabledState===So.ENABLED}init(t){return e(this,void 0,void 0,(function*(){this.key=t;const e=yield this.cacheContext.preference.get(this.key);e&&(this.logInfo=e)}))}_mergeQueue(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}_isDuplicateStat(e){const t=this._sentLogStats.find((t=>{var s;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(s=e.data.notificationId)&&void 0!==s?s:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}_save(){return e(this,void 0,void 0,(function*(){const e=[...this.queue,...this.flushWaitQueue];yield this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((e=>Oe.payloadify(e))),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})}))}clear(){return e(this,void 0,void 0,(function*(){this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save()}))}}class yo extends Oe{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 Ao extends ve{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${ae}`,this.params={device_id:e,log_entries:t.map((e=>Oe.payloadify(e)))}}}class No extends To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".daily"),this.queue=this.logInfo.statLogs.map((e=>new Oe({type:e.stat_type,ts:e.ts,data:e.data})))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this.statConfig.minInterval=864e5,this._mergeQueue(),s.localCacheStat?this.enabledState=s.enabledStat?So.ENABLED:So.COLLECT_ONLY:(this.enabledState=So.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=yield this._getUploadStats(),t=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);for(let s=0;se instanceof yo&&e.key===t.key));if(s?s.data=vo(s.data,t.data):e.push(t),this.enabledState!==So.PENDING&&(yield this._save()),this.isEnabled&&(this._mergeQueue(),this._isSendable)){const e=yield this._getUploadStats();return yield this._flush(e)}return!0}))}_getUploadStats(){return e(this,void 0,void 0,(function*(){return this.queue.filter((e=>{if(e instanceof yo){const t=new Date,[s,i]=[e.date.getFullYear(),t.getFullYear()];if(s0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new Ao({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Co,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=So.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=So.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}}class wo extends To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}_isSendable(e=!1){if(this.queue.lengthe.type!==exports.StatType.FEATURE_LOCALCACHE_EVENT)):t.filter((e=>e.type===exports.StatType.FEATURE_LOCALCACHE_EVENT))}))}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".default"),this.queue=this.logInfo.statLogs.map((e=>(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data),new Oe({type:e.stat_type,ts:e.ts,data:e.data}))))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.requestStat||s.localCacheStat){let e;this.enabledState=s.enabledStat?So.ENABLED:So.COLLECT_ONLY,s.requestStat||(e=!1),s.localCacheStat||(e=!0),void 0!==e&&(this.queue=yield this._filterQueueByType(this.queue,e),this.flushWaitQueue=yield this._filterQueueByType(this.flushWaitQueue,e),this._save())}else this.enabledState=So.DISABLED,yield this.clear();if(this.isEnabled&&this._isSendable(!0)){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield jn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===So.DISABLED)return!0;const e=this.enabledState===So.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return e.push(t),this.enabledState!==So.PENDING&&(yield this._save()),!this.isEnabled||(this._mergeQueue(),!this._isSendable())||(yield this._flush(e))}))}_flush(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t.length>0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new Ao({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Co,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=So.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=So.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}}class bo extends ve{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${le}`,this.params={device_id:e,log_entries:t.map((e=>Oe.payloadify(e)))}}}class Io extends To{constructor({deviceId:e,cacheContext:t,requestQueue:s}){super({deviceId:e,cacheContext:t,requestQueue:s})}get _isSendable(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}init(t){const s=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){yield s.init.call(this,t+".realtime"),this.queue=this.logInfo.statLogs.map((e=>{var t;return e.data=O(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Oe({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((e=>{var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}))}))}setConfig(t,s){return e(this,void 0,void 0,(function*(){if(this.statConfig=t,this._mergeQueue(),s.notificationStat?this.enabledState=s.enabledStat?So.ENABLED:So.COLLECT_ONLY:(this.enabledState=So.DISABLED,yield this.clear()),this.isEnabled&&this._isSendable){const e=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100);yield jn(e),yield this._flush(this.queue)}}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState===So.DISABLED)return!0;const e=this.enabledState===So.PENDING||this.isFlushing?this.flushWaitQueue:this.queue;return!!this._isDuplicateStat(t)||(e.push(t),this.enabledState!==So.PENDING&&(yield this._save()),!(this.isEnabled&&(this._mergeQueue(),this.isEnabled&&this._isSendable))||(yield this._flush(e)))}))}_flush(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t.length>0){if(!this.isFlushing){this.isFlushing=!0;try{const e=[...t].slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new bo({deviceId:this.deviceId,statLogs:e});yield this.requestQueue.send(s),this.queue=[...t].slice(e.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Co,this.logInfo.lastFlushedAt=Date.now(),yield this._save()}catch(t){t instanceof o&&(t.code===exports.SendbirdErrorCode.NON_AUTHORIZED?(yield this.clear(),this.enabledState=So.DISABLED):t.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=So.COLLECT_ONLY)),this.limit=this.limit+20,e=!1}finally{this.isFlushing=!1}}}else this.isFlushing=!1;return e}))}}class xo{constructor({cacheContext:e,requestQueue:t,dispatcher:s,logger:i}){this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=w(),this.cacheContext=e,this.requestQueue=t,this.dispatcher=s,this.logger=i,this._dailyStatCollector=new No({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new wo({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new Io({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}_migration(){return e(this,void 0,void 0,(function*(){const e=yield this.cacheContext.preference.get(this.key);if(e){const t=[];e.statLogs.forEach((e=>{e.stat_type===exports.StatType.FEATURE_LOCALCACHE&&t.push(new Oe({type:e.stat_type,ts:e.ts,data:e.data}))})),yield this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((e=>Oe.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const s=[];e.statLogs.forEach((e=>{e.stat_type!==exports.StatType.FEATURE_LOCALCACHE&&e.stat_type!==exports.StatType.NOTIFICATION&&(e.stat_type===exports.StatType.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),s.push(new Oe({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:s.map((e=>Oe.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt});const i=[];e.statLogs.forEach((e=>{var t;e.stat_type===exports.StatType.NOTIFICATION&&(e.data=O(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),i.push(new Oe({type:e.stat_type,ts:e.ts,data:e.data})))})),yield this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:i.map((e=>Oe.payloadify(e))),generation:e.generation,lastFlushedAt:e.lastFlushedAt}),yield this.cacheContext.preference.remove(this.key)}}))}init(t){return e(this,void 0,void 0,(function*(){this.key=t,yield this._migration(),yield this._dailyStatCollector.init(this.key),yield this._defaultStatCollector.init(this.key),yield this._notificationStatCollector.init(this.key),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((t=>e(this,void 0,void 0,(function*(){var e;if(t instanceof Ie){const{statLog:e}=t;this.put(e)}else if(t instanceof Hn){const{request:s,features:i,options:n,statConfigInfo:o}=t;this._retryCount=0,this._collectRequestStat=s,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:n.ingestion}),this._notificationStatCollector.setConfig(null!==(e=this._statConfig.realTime)&&void 0!==e?e:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:n.ingestion})}})))))}))}put(t){return e(this,void 0,void 0,(function*(){let e=!0;if(t instanceof yo)this._collectFeatureLocalCacheStat&&(e=yield this._dailyStatCollector.put(t));else switch(t.type){case exports.StatType.API_RESULT:case exports.StatType.WEBSOCKET_CONNECT:this._collectRequestStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.FEATURE_LOCALCACHE:case exports.StatType.FEATURE_LOCALCACHE_EVENT:this._collectFeatureLocalCacheStat&&(e=yield this._defaultStatCollector.put(t));break;case exports.StatType.NOTIFICATION:this._collectionNotificationStat&&(e=yield this._notificationStatCollector.put(t))}e?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=So.COLLECT_ONLY,this._defaultStatCollector.enabledState=So.COLLECT_ONLY,this._notificationStatCollector.enabledState=So.COLLECT_ONLY,this.logger.debug(o.statLogUploadLimitExceededError)))}))}close(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}class Ro{constructor({limit:e=5}){this.workersByKey={},this.limit=e}run(t,s){return e(this,void 0,void 0,(function*(){if(this.workersByKey[t]||(this.workersByKey[t]=[]),this.workersByKey[t].length{switch(e){case"open":return exports.PollStatus.OPEN;case"closed":return exports.PollStatus.CLOSED;default:return null}},Ho=e=>!e||!!e.text&&l("string",e.text);class Vo extends wn{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 O(k(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})))}}class zo extends wn{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=Fo(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 Vo(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=Fo(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 Vo(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 O(k(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=>Vo.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 Dn(this)}}class Go{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}}class Ko extends Go{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)}}class Bo extends ve{constructor({title:e,optionTexts:t,data:s,allowUserSuggestion:i,allowMultipleVotes:n,closeAt:o}){super(),this.method=exports.APIRequestMethod.POST,this.path=ne,this.params={title:e,options:t,data:s,allow_user_suggestion:i,allow_multiple_votes:n,close_at:o}}}class Qo extends Se{constructor(e,t){super(e,t),this.poll=new zo(e,t)}}class Wo extends ve{constructor({channelUrl:e,channelType:t,pollId:s}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}`,this.params={channel_url:e,channel_type:t}}}class jo extends Se{constructor(e,t){super(e,t),this.poll=new zo(e,t)}}class $o extends ve{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}`,this.params={channel_url:e,channel_type:t}}}class Zo extends Se{constructor(e,t){super(e,t),this.pollOption=new Vo(e,t)}}class Yo extends ve{constructor({channelType:e,channelUrl:t,timestamp:s,token:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${pe(e)}/${encodeURIComponent(t)}/polls/changelogs`,this.params=O({change_ts:s,token:i})}}class Xo extends Se{constructor(e,t){super(e,t),this.updatedPolls=t.updated.map((t=>((e,t)=>new zo(e,t))(e,t))),this.deletedPollIds=t.deleted.map((e=>e)),this.hasMore=t.has_more,this.nextToken=t.next}}const Jo={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},er=e=>{return l("string",e.title)&&(t=e.optionTexts,h("string",t)&&t.every((e=>""!==e.trim())))&&Ho(e.data)&&l("boolean",e.allowUserSuggestion,!0)&&l("boolean",e.allowMultipleVotes,!0)&&l("number",e.closeAt,!0);var t},tr={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0,pollOptionId:0},sr=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId)&&e.pollId>0&&l("number",e.pollOptionId)&&e.pollOptionId>0,ir={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0},nr=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId),or={};class rr extends ve{constructor({channelUrl:e,channelType:t,token:s,limit:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=ne,this.params={channel_url:e,channel_type:t,token:s,limit:i}}}class ar extends Se{constructor(e,t){var s;super(e,t),this.polls=(null!==(s=t.polls)&&void 0!==s?s:[]).map((t=>new zo(e,t))),this.token=t.next}}class lr extends ve{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i,token:n,limit:o}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}/voters`,this.params={channel_url:e,channel_type:t,token:n,limit:o}}}class dr extends Se{constructor(e,t){var s;super(e,t),this.voters=(null!==(s=t.voters)&&void 0!==s?s:[]).map((t=>new Mn(e,t))),this.token=t.next}}exports.APIRequestCommand=ve,exports.APIResponseCommand=Se,exports.API_PATH_EMOJIS=se,exports.API_PATH_EMOJI_CATEGORIES=ie,exports.API_PATH_FORMS=_e,exports.API_PATH_GROUP_CHANNELS=Z,exports.API_PATH_GROUP_CHANNELS_INTERNAL=Y,exports.API_PATH_MESSAGE_TEMPLATE=he,exports.API_PATH_NOTIFICATIONS=de,exports.API_PATH_NOTIFICATIONS_USERS=ce,exports.API_PATH_OPEN_CHANNELS=X,exports.API_PATH_OPEN_CHANNELS_INTERNAL=J,exports.API_PATH_POLLS=ne,exports.API_PATH_PUSH_DELIVERY=ue,exports.API_PATH_REPORT=te,exports.API_PATH_SCHEDULED_MESSAGES=oe,exports.API_PATH_SEARCH=ee,exports.API_PATH_UIKIT_CONFIGURATION=re,exports.API_PATH_UPLOAD=$,exports.API_PATH_USERS=W,exports.AppInfo=Nn,exports.BaseCommand=R,exports.BaseListQuery=Go,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.CancelXMLHttpRequestCommand=Fe,exports.ChannelDataListQuery=Ko,exports.ConnectionStateChangeCommand=_n,exports.DEFAULT_ENCRYPTION=E,exports.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT=5,exports.DailyRecordStatLog=yo,exports.Deferred=qe,exports.DeleteMessageEventCommand=class extends Te{constructor(e,t,s){var i;super(e,"DELM",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.messageId=Number(s.msg_id),this.silent=s.silent,this.messageCreatedAt=s.message_created_at?Number(s.message_created_at):-1,this.senderId=null!==(i=s.sender_id)&&void 0!==i?i:void 0}},exports.DeleteMessageRequestCommand=He,exports.EventDispatcher=I,exports.InstancedObject=wn,exports.LocalCacheConfig=y,exports.MessageEventSource=Uo,exports.MessageRemoveEventCommand=class extends R{constructor({messageIds:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messageIds=e,this.source=t,this.isWebSocketEventComing=s}},exports.MessageUpdateEventCommand=class extends R{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.NotificationInfo=fn,exports.POLL_REMOVED_STATUS="removed",exports.Poll=zo,exports.PollChangeLogEventCommand=Mo,exports.PollCreateParamsDefault=Jo,exports.PollListQuery=class extends Ko{constructor(e,t){super(e,t.channelUrl,t.channelType,t)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Lo.of(this._iid),t=new rr(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{polls:i,token:n}=s.as(ar);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.PollManager=class{constructor(e,{sdkState:t,dispatcher:s,sessionManager:i,requestQueue:n,logger:o}){this._iid=e,this._sdkState=t,this._sessionManager=i,this._requestQueue=n,this._dispatcher=s,this._logger=o,or[e]=this}static of(e){return or[e]}buildPollFromSerializedData(e){const t=Ln(e);return new zo(this._iid,zo.payloadify(t))}get(t){return e(this,void 0,void 0,(function*(){Pn(nr(t)).throw(o.invalidParameters);const e=new Wo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(jo);return i}))}create(t){return e(this,void 0,void 0,(function*(){Pn(er(t)).throw(o.invalidParameters);const e=new Bo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(Qo);return i}))}getOption(t){return e(this,void 0,void 0,(function*(){Pn(sr(t)).throw(o.invalidParameters);const e=new $o(Object.assign({},t)),s=yield this._requestQueue.send(e),{pollOption:i}=s.as(Zo);return i}))}getPollChangeLogs(t,s,i,n=exports.CollectionEventSource.SYNC_POLL_CHANGELOGS){return e(this,void 0,void 0,(function*(){const e=new Yo(k({channelType:s,channelUrl:t,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null})),o=yield this._requestQueue.send(e),{updatedPolls:r,deletedPollIds:a,hasMore:l,nextToken:d}=o.as(Xo);return r.length>0&&this._dispatcher.dispatch(new Mo({polls:r,source:n})),{updatedPolls:r,deletedPollIds:a,hasMore:l,token:d}}))}},exports.PollOption=Vo,exports.PollOptionRetrievalParamsDefault=tr,exports.PollRetrievalParamsDefault=ir,exports.PollUpdateInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=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.PollVoteInternalEventCommand=class extends R{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoterListQuery=class extends Ko{constructor(e,t){super(e,t.channelUrl,t.channelType,t),this.pollId=t.pollId,this.pollOptionId=t.pollOptionId}_validate(){return super._validate()&&l("number",this.pollId)&&l("number",this.pollOptionId)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=Lo.of(this._iid),t=new lr(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),s=yield e.send(t),{voters:i,token:n}=s.as(dr);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.ReactionUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.RequestResendCommand=xe,exports.SEMVER_REGEX_STRING="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",exports.SendbirdChatOptions=p,exports.SendbirdError=o,exports.SessionExpiredCommand=Ce,exports.SessionRefreshAPICommand=Ae,exports.StatLog=Oe,exports.SubscribedUnreadMessageCountUpdateCommand=hn,exports.ThreadUpdateEventCommand=class extends R{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}},exports.UIKitConfigInfo=vn,exports.UnsentMessageRemoveEventCommand=class extends R{constructor({reqId:e,source:t}){super(),this.reqId=e,this.source=t}},exports.User=Mn,exports.UserProfile=Fn,exports.UserProfileUpdateCommand=qn,exports.Vault=Lo,exports.WebSocketEventCommand=Te,exports.WebSocketRequestCommand=ye,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=Ee(null!==(i=e.mentionType)&&void 0!==i?i:null,null!==(n=e.mentionedUserIds)&&void 0!==n?n:[],s),l=Ee(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=Ee,exports.createChangelogIncludeChatNotificationsCacheKey=e=>`sendbird@${e}/changelog_include_chat_notifications`,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=Ln,exports.deundefined=O,exports.getChannelApiPathByType=pe,exports.getReportApiPathByType=e=>{switch(e){case exports.ChannelType.GROUP:return`${te}/group_channels`;case exports.ChannelType.OPEN:return`${te}/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.isMilliSecondOf=(e,t=!1)=>!(!t||!_(e))||"number"==typeof e&&13===e.toString().length,exports.isReactNative=ke,exports.isResendableError=e=>e>0&&r.indexOf(e)>=0,exports.isThrowingOutside=n,exports.isTypeOf=l,exports.noop=ze,exports.parsePollStatusPayload=Fo,exports.runAsCallback=Gn,exports.runOrNothing=Kn,exports.serialize=Dn,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===exports.CollectionEventSource.SYNC_MESSAGE_FILL||e===exports.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||e===exports.CollectionEventSource.SYNC_POLL_CHANGELOGS,exports.sleep=jn,exports.undefineNullProps=k,exports.unless=Pn,exports.uuid=w,exports.validatePollCreateParams=er,exports.validatePollData=Ho,exports.validatePollOptionRetrievalParams=sr,exports.validatePollRetrievalParams=nr,exports.version=s; diff --git a/cjs/lib/__bundle-05f697db.cjs b/cjs/lib/__bundle-3d28c10f.cjs similarity index 65% rename from cjs/lib/__bundle-05f697db.cjs rename to cjs/lib/__bundle-3d28c10f.cjs index e71801b..b8f1b9e 100644 --- a/cjs/lib/__bundle-05f697db.cjs +++ b/cjs/lib/__bundle-3d28c10f.cjs @@ -1 +1 @@ -var s=require("./__bundle-0486c467.cjs");class e extends s.User{constructor(s,e){var t;super(s,e),this.isMuted=!1,this.isMuted=null!==(t=e.is_muted)&&void 0!==t&&t}}exports.Participant=e; +var s=require("./__bundle-2d1d7d4f.cjs");class e extends s.User{constructor(s,e){var t;super(s,e),this.isMuted=!1,this.isMuted=null!==(t=e.is_muted)&&void 0!==t&&t}}exports.Participant=e; diff --git a/cjs/lib/__bundle-2e006691.cjs b/cjs/lib/__bundle-4455b70a.cjs similarity index 54% rename from cjs/lib/__bundle-2e006691.cjs rename to cjs/lib/__bundle-4455b70a.cjs index 46d5e38..8c61571 100644 --- a/cjs/lib/__bundle-2e006691.cjs +++ b/cjs/lib/__bundle-4455b70a.cjs @@ -1 +1 @@ -var e=require("./__bundle-0486c467.cjs");exports.xmlHttpRequest=(r,s)=>new Promise(((t,o)=>{if("undefined"!=typeof XMLHttpRequest){const{dispatcher:n,logger:d}=e.Vault.of(r),{requestId:a,method:i,url:u,headers:p={},data:c="",uploadProgressHandler:l}=s;let m=!1;const E=new XMLHttpRequest;E.open(i,u),Object.keys(p).forEach((e=>{E.setRequestHeader(e,p[e])})),l&&E.upload.addEventListener("progress",(e=>{e.lengthComputable?l(a,e.loaded,e.total):d.debug("Progress computing failed: `Content-Length` header is not given.")})),E.onabort=()=>{o(e.SendbirdError.requestCanceled)},E.onerror=r=>{o(e.SendbirdError.networkError)},E.onreadystatechange=()=>{if(E.readyState===XMLHttpRequest.DONE&&!m)if(0===E.status||E.status>=200&&E.status<400)try{const s=JSON.parse(E.responseText);t(new e.APIResponseCommand(r,s))}catch(r){o(e.SendbirdError.networkError)}else try{const r=JSON.parse(E.responseText);if(r){const s=new e.SendbirdError(r);if(s.isSessionExpiredError){if(n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message})),!(E instanceof e.SessionRefreshAPICommand)){const r=new e.Deferred;return n.dispatch(new e.RequestResendCommand({request:E,deferred:r,error:s})),r.promise}}else s.isSessionInvalidatedError&&n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message}));o(s)}else o(e.SendbirdError.requestFailed)}catch(r){o(e.SendbirdError.requestFailed)}},n.on((r=>{r instanceof e.CancelXMLHttpRequestCommand&&(r.requestId&&r.requestId!==a||(m=!0,E.abort()))})),E.send(c)}else o(e.SendbirdError.xmlHttpRequestNotSupported)})); +var e=require("./__bundle-2d1d7d4f.cjs");exports.xmlHttpRequest=(r,s)=>new Promise(((t,o)=>{if("undefined"!=typeof XMLHttpRequest){const{dispatcher:n,logger:d}=e.Vault.of(r),{requestId:a,method:i,url:u,headers:p={},data:c="",uploadProgressHandler:l}=s;let m=!1;const f=new XMLHttpRequest;f.open(i,u),Object.keys(p).forEach((e=>{f.setRequestHeader(e,p[e])})),l&&f.upload.addEventListener("progress",(e=>{e.lengthComputable?l(a,e.loaded,e.total):d.debug("Progress computing failed: `Content-Length` header is not given.")})),f.onabort=()=>{o(e.SendbirdError.requestCanceled)},f.onerror=r=>{o(e.SendbirdError.networkError)},f.onreadystatechange=()=>{if(f.readyState===XMLHttpRequest.DONE&&!m)if(0===f.status||f.status>=200&&f.status<400)try{const s=JSON.parse(f.responseText);t(new e.APIResponseCommand(r,s))}catch(r){o(e.SendbirdError.networkError)}else try{const r=JSON.parse(f.responseText);if(r){const s=new e.SendbirdError(r);if(s.isSessionExpiredError){if(n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message})),!(f instanceof e.SessionRefreshAPICommand)){const r=new e.Deferred;return n.dispatch(new e.RequestResendCommand({request:f,deferred:r,error:s})),r.promise}}else s.isSessionInvalidatedError&&n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message}));o(s)}else o(e.SendbirdError.requestFailed)}catch(r){o(e.SendbirdError.requestFailed)}},n.on((r=>{r instanceof e.CancelXMLHttpRequestCommand&&(r.requestId&&r.requestId!==a||(m=!0,f.abort()))})),f.send(c)}else o(e.SendbirdError.xmlHttpRequestNotSupported)})); diff --git a/cjs/lib/__bundle-12c1cdf9.cjs b/cjs/lib/__bundle-73351257.cjs similarity index 97% rename from cjs/lib/__bundle-12c1cdf9.cjs rename to cjs/lib/__bundle-73351257.cjs index a8ea61b..c6e22ee 100644 --- a/cjs/lib/__bundle-12c1cdf9.cjs +++ b/cjs/lib/__bundle-73351257.cjs @@ -1 +1 @@ -var e,t=require("./__bundle-0486c467.cjs"),s=require("./__bundle-4bcf4070.cjs"),n=require("./__bundle-dae7bdf2.cjs");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 a{constructor(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===t.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===t.ChannelType.OPEN}}class o extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.event=new a(s)}}class r extends t.WebSocketEventCommand{constructor(e,t,n){var a;super(e,"SYEV",n),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,n.data&&(this.pinnedMessageIds=null!==(a=n.data.pinned_message_ids)&&void 0!==a?a:[],this.latestPinnedMessage=n.data.latest_pinned_message?s.parseMessagePayload(e,Object.assign({},n.data.latest_pinned_message)):null),this.ts=n.ts}}class i extends t.InstancedObject{get _messageBroadcast(){return s.MessageBroadcast.of(this._iid)}constructor(e,t){super(e),this._logger=t.logger,this._sdkState=t.sdkState,this._sessionManager=t.sessionManager,this._requestQueue=t.requestQueue,this._dispatcher=t.dispatcher,this._cacheContext=t.cacheContext,this._channelType=t.channelType}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}getMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){return null}))}getExactlyMatchingMessagesForTokenFromCache(e,s,n){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getMessagesFromCache(e,s,n,a,o,r){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getPollMessagesFromCache(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getCachedMessageCountBetween(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return 0}))}getUnsentMessagesFromCache(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}removeFailedMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){}))}}class E extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E;super(e,"ADMM",a),this.message=new s.AdminMessage(e,a);const{sdkState:d}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(i=null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(r=this.message.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)))&&void 0!==i?i:[],d.userId),this.forceUpdateLastMessage=null!==(E=a.force_update_last_message)&&void 0!==E&&E}}class d extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E,d;super(e,"AEDI",a),this.message=new s.AdminMessage(e,a);const{sdkState:_}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(o=a.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(i=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==i?i:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(E=this.message.mentionedUserIds)&&void 0!==E?E:null===(d=this.message.mentionedUsers)||void 0===d?void 0:d.map((e=>e.userId))}),_.userId)}}class _ extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MRCT",n),this.channelUrl=n.channel_url,this.channelType=n.channel_type,this.event=new s.ReactionEvent(n)}}class N extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MTHD",n),this.event=new s.ThreadInfoUpdateEvent(e,n)}}class c extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MCNT",s),this.groupChannelMemberCounts=s.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=s.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class l extends t.WebSocketEventCommand{constructor(e,s,a){super(e,"PEDI",a),this.event=new n.PollUpdateEvent(e,a),this.status=t.parsePollStatusPayload(a.poll.status)||a.poll.status,this.channelUrl=a.channel_url,this.channelType=a.channel_type}}exports.AdminMessageEventCommand=E,exports.BaseChannelManager=i,exports.ChannelEventCommand=o,exports.MemberCountUpdateEventCommand=c,exports.OperatorUpdateEventCommand=class extends o{constructor(e,s,n){super(e,s,n);const{operators:a=[]}=n.data;this.operators=a.map((e=>new t.User(this._iid,e)))}},exports.PollUpdateEventCommand=l,exports.ReactionEventCommand=_,exports.ThreadInfoUpdateEventCommand=N,exports.UpdateAdminMessageEventCommand=d,exports.UpdatePinnedMessageEventCommand=r; +var e,t=require("./__bundle-2d1d7d4f.cjs"),s=require("./__bundle-ccb8334d.cjs"),n=require("./__bundle-dae7bdf2.cjs");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 a{constructor(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===t.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===t.ChannelType.OPEN}}class o extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.event=new a(s)}}class r extends t.WebSocketEventCommand{constructor(e,t,n){var a;super(e,"SYEV",n),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,n.data&&(this.pinnedMessageIds=null!==(a=n.data.pinned_message_ids)&&void 0!==a?a:[],this.latestPinnedMessage=n.data.latest_pinned_message?s.parseMessagePayload(e,Object.assign({},n.data.latest_pinned_message)):null),this.ts=n.ts}}class i extends t.InstancedObject{get _messageBroadcast(){return s.MessageBroadcast.of(this._iid)}constructor(e,t){super(e),this._logger=t.logger,this._sdkState=t.sdkState,this._sessionManager=t.sessionManager,this._requestQueue=t.requestQueue,this._dispatcher=t.dispatcher,this._cacheContext=t.cacheContext,this._channelType=t.channelType}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}getMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){return null}))}getExactlyMatchingMessagesForTokenFromCache(e,s,n){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getMessagesFromCache(e,s,n,a,o,r){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getPollMessagesFromCache(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getCachedMessageCountBetween(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return 0}))}getUnsentMessagesFromCache(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}removeFailedMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){}))}}class E extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E;super(e,"ADMM",a),this.message=new s.AdminMessage(e,a);const{sdkState:d}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(i=null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(r=this.message.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)))&&void 0!==i?i:[],d.userId),this.forceUpdateLastMessage=null!==(E=a.force_update_last_message)&&void 0!==E&&E}}class d extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E,d;super(e,"AEDI",a),this.message=new s.AdminMessage(e,a);const{sdkState:_}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(o=a.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(i=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==i?i:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(E=this.message.mentionedUserIds)&&void 0!==E?E:null===(d=this.message.mentionedUsers)||void 0===d?void 0:d.map((e=>e.userId))}),_.userId)}}class _ extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MRCT",n),this.channelUrl=n.channel_url,this.channelType=n.channel_type,this.event=new s.ReactionEvent(n)}}class N extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MTHD",n),this.event=new s.ThreadInfoUpdateEvent(e,n)}}class c extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MCNT",s),this.groupChannelMemberCounts=s.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=s.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class l extends t.WebSocketEventCommand{constructor(e,s,a){super(e,"PEDI",a),this.event=new n.PollUpdateEvent(e,a),this.status=t.parsePollStatusPayload(a.poll.status)||a.poll.status,this.channelUrl=a.channel_url,this.channelType=a.channel_type}}exports.AdminMessageEventCommand=E,exports.BaseChannelManager=i,exports.ChannelEventCommand=o,exports.MemberCountUpdateEventCommand=c,exports.OperatorUpdateEventCommand=class extends o{constructor(e,s,n){super(e,s,n);const{operators:a=[]}=n.data;this.operators=a.map((e=>new t.User(this._iid,e)))}},exports.PollUpdateEventCommand=l,exports.ReactionEventCommand=_,exports.ThreadInfoUpdateEventCommand=N,exports.UpdateAdminMessageEventCommand=d,exports.UpdatePinnedMessageEventCommand=r; diff --git a/cjs/lib/__bundle-785dde28.cjs b/cjs/lib/__bundle-785dde28.cjs new file mode 100644 index 0000000..dae4ed3 --- /dev/null +++ b/cjs/lib/__bundle-785dde28.cjs @@ -0,0 +1 @@ +var e=require("./__bundle-2d1d7d4f.cjs");class d extends e.BaseCommand{}exports.NotificationCollectionRefreshCommand=d,exports.getFeedChannelIndexBy=e=>["-lastMessageUpdatedAt","-createdAt","syncIndex"]; diff --git a/cjs/lib/__bundle-0fbd5934.cjs b/cjs/lib/__bundle-90430bee.cjs similarity index 99% rename from cjs/lib/__bundle-0fbd5934.cjs rename to cjs/lib/__bundle-90430bee.cjs index 5446c07..11a49fd 100644 --- a/cjs/lib/__bundle-0fbd5934.cjs +++ b/cjs/lib/__bundle-90430bee.cjs @@ -1 +1 @@ -var e,t,s,n,i,a,r,o,l,d=require("./__bundle-0486c467.cjs"),h=require("./__bundle-4bcf4070.cjs"),c=require("./__bundle-0f6b8ff3.cjs"),u=require("./__bundle-12c1cdf9.cjs"),_=require("./__bundle-d349e14c.cjs");exports.MemberState=void 0,(e=exports.MemberState||(exports.MemberState={})).NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left";class p 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 m 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.member=new d.User(this._iid,t.user),this.deliveryAt=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 g{constructor(e){var t,s,n,i,a,r,o,l,d,h,c,u,_,p,m;this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(t=null==e?void 0:e.includeEmpty)&&void 0!==t&&t,this.nicknameContainsFilter=null!==(s=null==e?void 0:e.nicknameContainsFilter)&&void 0!==s?s:null,this.nicknameStartsWithFilter=null!==(n=null==e?void 0:e.nicknameStartsWithFilter)&&void 0!==n?n:null,this.nicknameExactMatchFilter=null!==(i=null==e?void 0:e.nicknameExactMatchFilter)&&void 0!==i?i:null,this.channelNameContainsFilter=null!==(a=null==e?void 0:e.channelNameContainsFilter)&&void 0!==a?a:"",this.myMemberStateFilter=null!==(r=null==e?void 0:e.myMemberStateFilter)&&void 0!==r?r:exports.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(o=null==e?void 0:e.customTypesFilter)&&void 0!==o?o:null,this.channelUrlsFilter=null!==(l=null==e?void 0:e.channelUrlsFilter)&&void 0!==l?l:null,this.superChannelFilter=null!==(d=null==e?void 0:e.superChannelFilter)&&void 0!==d?d:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(h=null==e?void 0:e.publicChannelFilter)&&void 0!==h?h:exports.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(c=null==e?void 0:e.customTypeStartsWithFilter)&&void 0!==c?c:null,this.unreadChannelFilter=null!==(u=null==e?void 0:e.unreadChannelFilter)&&void 0!==u?u:exports.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==e?void 0:e.hiddenChannelFilter)&&void 0!==_?_:exports.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(p=null==e?void 0:e.includeFrozen)||void 0===p||p,(null==e?void 0:e.createdAfter)&&(this.createdAfter=e.createdAfter),(null==e?void 0:e.createdBefore)&&(this.createdBefore=e.createdBefore),this.includeMetaData=null===(m=null==e?void 0:e.includeMetaData)||void 0===m||m}_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 g;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("*")&&!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.ALL:if("none"===e.myMemberState)return!1;break;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!(this.createdAfter&&e.createdAtthis.createdBefore)}}class C 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 be.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 c.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!s&&t.name.localeCompare(e)<0||s&&t.name.localeCompare(e)>0)return!1;break;case c.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>e||s&&t.createdAte||s&&t.lastMessageUpdatedAtthis._deserialize(e)));return d.forEach((e=>{!n.includeMetaData&&e.cachedMetaData&&e._clearCachedMetaData(),this._channels.has(e.url)||this._channels.set(e.url,e)})),d}return[]}))}upsert(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];if(e.forEach((e=>{if(this._channels.has(e.url)){const n=this._channels.get(e.url);if(n._pinnedMessagesUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t){const{isUpdated:s}=n._updateCachedMetaData(e.cachedMetaData,t);s||Object.assign(e,{_cachedMetaData:void 0})}n._update(e),s.push(n)}else this._channels.set(e.url,e),s.push(e)})),this.localCacheEnabled){const e=[];for(let t=0;t0&&(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},v=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),f={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},M=e=>d.isArrayOf("string",e.customTypes,!0)&&d.isTypeOf("boolean",e.includeEmpty,!0)&&d.isTypeOf("boolean",e.includeFrozen,!0)&&d.isTypeOf("boolean",e.includeMetaData,!0)&&d.isTypeOf("boolean",e.includeChatNotification,!0),y={myMemberStateFilter:exports.MyMemberStateFilter.ALL},S=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 b={keys:[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,exports.UnreadItemKey.NONSUPER_INVITATION_COUNT,exports.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},N={channelCustomTypesFilter:void 0,superChannelFilter:exports.SuperChannelFilter.ALL},T=e=>d.isArrayOf("string",e.channelCustomTypesFilter,!0)&&d.isEnumOf(exports.SuperChannelFilter,e.superChannelFilter),U={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:d.MessageTypeFilter.ALL},I=Object.assign({},d.CollectionEventSource),x=e=>e.startsWith("EVENT_")||e===d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||e===d.CollectionEventSource.REFRESH_CHANNEL;class P extends d.BaseCommand{constructor({channels:e,context:t,isWebSocketEventComing:s=!1,ts:n}){super(),this.channels=e,this.context=t,this.isWebSocketEventComing=s,this.ts=n}}class R extends d.BaseCommand{constructor({channelUrls:e,context:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.context=t,this.isWebSocketEventComing=s}}class O{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 P){const{channels:s,context:i,isWebSocketEventComing:a}=n,r=s.filter((e=>e instanceof vt));if(i.source===d.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY||i.source===d.CollectionEventSource.EVENT_CHANNEL_HIDDEN)for(const e of r)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp);else{const s=e.filterOffsetChanged(r);for(const e of s)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp)}const o=yield e.upsert(r,n.ts);a||this._broadcastUpdateEvent(o,i)}else if(n instanceof R){const{channelUrls:i,context: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 c.DatabaseOpenCommand&&(yield e.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,t)}_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 w extends d.APIRequestCommand{constructor({userId:e,ts:t,token:s,filter:n,includeChatNotification:i=!1}){super();const{customTypes:a,includeEmpty:r,includeFrozen:o}=Object.assign(Object.assign({},f),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:a,show_empty:r,show_frozen:o,include_chat_notification:i}))}}class L extends d.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((s=>new vt(e,Object.assign(s,{ts:t.ts})))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next,this.ts=t.ts}}class F extends d.APIRequestCommand{constructor({channelUrl:e,isInternalCall:t,showLatestMessage:s}){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,show_latest_message:null!=s&&s}}}class D extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}const k={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0};class H 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:c,nicknameStartsWithFilter:u,nicknameExactMatchFilter:_,channelNameContainsFilter:p,channelUrlsFilter:m,customTypesFilter:g,customTypeStartsWithFilter:C,hiddenChannelFilter:E,metadataOrderKeyFilter:v,metadataKey:f,metadataValues:M,metadataValueStartsWith:y,includeFrozen:S,includeMetaData:A,searchFilter:b,userIdsFilter:N,includeChatNotification:T=!1,includeLeftChannel:U=!1,createdAfter:I,createdBefore:x}=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:k.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=a?a:k.includeEmpty,member_state_filter:null!=r?r:k.myMemberStateFilter,super_mode:null!=o?o:k.superChannelFilter,public_mode:null!=l?l:k.publicChannelFilter,unread_filter:null!=h?h:k.unreadChannelFilter,members_nickname_contains:c,members_nickname_startswith:u,members_nickname:_,name_contains:p,channel_urls:m,custom_types:g,custom_type_startswith:C,hidden_mode:E,metadata_order_key:v,metadata_key:f,metadata_values:M,metadata_value_startswith:y,show_frozen:S,show_metadata:A,include_chat_notification:T,include_left_channel:U,created_after:I,created_before:x}),b&&b.query&&b.fields&&(this.params.search_query=b.query,this.params.search_fields=b.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(this.params.members_include_in=N.userIds,this.params.query_type=N.queryType.toUpperCase()):this.params.members_exactly_in=N.userIds)}}class V 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 vt(e,t))))),this.ts=null!=i?i:0}}class G 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 q extends d.APIResponseCommand{constructor(e,t){super(e,t),this.groupChannelCount=t.group_channel_count}}class B extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{keys:s,customTypeFilters:n,customTypesFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_item_count`,this.params=d.deundefined({item_keys:s,custom_types:null!=i?i:n})}}class j 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 z extends d.APIRequestCommand{constructor({userId:e}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_channel_count`}}class W extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class $ extends d.APIRequestCommand{constructor({userId:e,filter:t,includeFeedChannel:s=!1}){super();const{channelCustomTypesFilter:n,superChannelFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_message_count`,this.params={super_mode:null!=i?i:exports.SuperChannelFilter.ALL,custom_types:n,include_feed_channel:s}}}class K extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count,this.unreadFeedCount=t.unread_feed_count}}class Q 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:J(t)},s&&(this.params.message_type=s)}}class Y extends d.APIResponseCommand{constructor(e,t){super(e,t),this.count=t.count}}const J=e=>{if(!e)return[];const t=[];return e.forEach((e=>{switch(e){case h.ScheduledStatus.PENDING:t.push(h.InternalScheduledStatus.PENDING);break;case h.ScheduledStatus.SENT:t.push(h.InternalScheduledStatus.IN_QUEUE),t.push(h.InternalScheduledStatus.SENT);break;case h.ScheduledStatus.CANCELED:t.push(h.InternalScheduledStatus.CANCELED);break;case h.ScheduledStatus.FAILED:t.push(h.InternalScheduledStatus.FAILED)}})),t};class X 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:c,isStrict:u,isEphemeral:_,accessCode:p,name:m,data:g,customType:C,messageSurvivalSeconds:E,invitedUserIds:v,operatorUserIds:f}=e;super(),this.method=d.APIRequestMethod.POST,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined({user_ids:[t,...null!=v?v:[]].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:c,strict:u,is_ephemeral:_,access_code:p,name:m,data:g,custom_type:C,operator_ids:f,message_survival_seconds:E})}}class Z extends d.APIResponseCommand{constructor(e,t){var s;super(e,t),this.channel=new vt(e,t),this.isCreated=null===(s=t.is_created)||void 0===s||s}}class ee 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 te 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 se extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class ne extends u.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 p(e,t))):[new p(e,s.data)]}}class ie 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 ae extends u.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 p(this._iid,s.data)}}class re 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 oe extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class le extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s),this.inviter=null;const{member_count:n=0,joined_member_count:i=0,inviter:a,invitees:r=[]}=s.data;this.memberCount=n,this.joinedMemberCount=i,a&&Object.keys(a).length>0&&(this.inviter=new d.User(e,a)),this.invitees=r.map((t=>new p(e,t)))}}class de 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 he extends u.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 p(e,r)}}const ce={hidePreviousMessages:!1,allowAutoUnhide:!0};class ue 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 _e extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}class pe 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 me extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPST",ackRequired:!1,payload:{channel_url:e,time:t}})}}class ge extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class Ce 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 ve extends d.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"MACK",ackRequired:!1,payload:{channel_url:e,msg_id:t}})}}class fe extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,u,_,p,m,g,C,E,v,f,M,y,S,A,b;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.includeChatNotification=!1,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=c.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.includeChatNotification=null!==(a=t.includeChatNotification)&&void 0!==a&&a,this.channelUrlsFilter=null!==(r=t.channelUrlsFilter)&&void 0!==r?r:null,this.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,this.customTypeStartsWithFilter=null!==(l=t.customTypeStartsWithFilter)&&void 0!==l?l:"",this.nicknameContainsFilter=null!==(d=t.nicknameContainsFilter)&&void 0!==d?d:null,this.nicknameStartsWithFilter=null!==(h=t.nicknameStartsWithFilter)&&void 0!==h?h:null,this.nicknameExactMatchFilter=null!==(u=t.nicknameExactMatchFilter)&&void 0!==u?u:null,this.channelNameContainsFilter=null!==(_=t.channelNameContainsFilter)&&void 0!==_?_:"",this.myMemberStateFilter=null!==(p=t.myMemberStateFilter)&&void 0!==p?p:exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=null!==(m=t.unreadChannelFilter)&&void 0!==m?m:exports.UnreadChannelFilter.ALL,this.superChannelFilter=null!==(g=t.superChannelFilter)&&void 0!==g?g:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(C=t.publicChannelFilter)&&void 0!==C?C:exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=null!==(E=t.hiddenChannelFilter)&&void 0!==E?E:exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter=null!==(v=t.searchFilter)&&void 0!==v?v:{fields:[],query:null},this.userIdsFilter=null!==(f=t.userIdsFilter)&&void 0!==f?f:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null!==(M=t.metadataKey)&&void 0!==M?M:null,this.metadataValues=null!==(y=t.metadataValues)&&void 0!==y?y:null,this.metadataOrderKeyFilter=null!==(S=t.metadataOrderKeyFilter)&&void 0!==S?S:null,this.metadataValueStartsWith=null!==(A=t.metadataValueStartsWith)&&void 0!==A?A:null,this.order=null!==(b=t.order)&&void 0!==b?b:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,t.createdAfter&&(this.createdAfter=t.createdAfter),t.createdBefore&&(this.createdBefore=t.createdBefore)}_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(c.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)&&d.isMilliSecondOf(this.createdAfter,!0)&&d.isMilliSecondOf(this.createdBefore,!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=be.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign({},this)),this.limit,d.CollectionEventSource.REQUEST_CHANNEL,!0);return this._token=s,this._hasNext=!!s,this._isLoading=!1,t}return[]}throw d.SendbirdError.invalidParameters}))}}class Me extends d.APIRequestCommand{constructor({channelUrl:e,userId:t}){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 ye extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"DLVR",s),this.channelUrl=s.channel_url,this.deliveredStateUpdate=s.updated}}class Se{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)}}const Ae={};class be extends u.BaseChannelManager{get _messageCache(){return h.MessageCache.of(this._iid)}get _unsentMessageCache(){return h.UnsentMessageCache.of(this._iid)}constructor(e,t){var s;super(e,Object.assign(Object.assign({},t),{channelType:d.ChannelType.GROUP})),this._leftChannels=new Map,this._disableMack=!1,this._markAsReadAllLastSentAt=0,this._disableMack=null!==(s=t.disableMack)&&void 0!==s&&s,this._groupChannelHandlers=new Map,this._groupChannelCache=new C(this._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),this._groupChannelBroadcast=new O({dispatcher:t.dispatcher,groupChannelCache:this._groupChannelCache,messageCache:h.MessageCache.of(this._iid),unsentMessageCache:h.UnsentMessageCache.of(this._iid)}),setInterval((()=>{for(const e of this._groupChannelCache.channels)e.invalidateTypingStatus()&&(this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.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).catch((e=>{if(d.isThrowingOutside(e)&&"foreground"===this._sdkState.appState)throw e})):e instanceof c.AutoResendRequestCommand?(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{message:t}=e,s=yield this.getChannel(t.channelUrl,!0);s.isFrozen||(t instanceof h.UserMessage?s._autoResendUserMessage(t):t instanceof h.FileMessage&&s._autoResendFileMessage(t))}))})():e instanceof c.ReduceDBSizeEventCommand?this.reduceDBSize():e instanceof h.MessageThreadInfoUpdatedEventCommand&&(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{channelUrl:t,channelType:s,parentMessage:n}=e,i=new h.ThreadInfoUpdateEvent(this._iid,{channel_type:d.ChannelType.GROUP,channel_url:t,parent_message_id:n.messageId,thread_info:h.ThreadInfo.payloadify(n.threadInfo)});if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onThreadInfoUpdated&&t.onThreadInfoUpdated(e,i)}))))}}))})()})),Ae[e]||(Ae[e]=this)}static of(e){return Ae[e]||(Ae[e]=new be(e,d.Vault.of(e))),Ae[e]}static clear(e){Ae[e]&&delete Ae[e]}get handlers(){return[...this._groupChannelHandlers.values()]}buildGroupChannelFromSerializedData(e){const t=d.deserialize(e);return new vt(this._iid,vt.payloadify(t))}buildGroupChannelListQueryFromSerializedData(e){const t=d.deserialize(e);return new fe(this._iid,t)}buildMemberFromSerializedData(e){const t=d.deserialize(e);return new p(this._iid,p.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 e=h.MessageCache.of(this._iid),{cacheContext:t}=d.Vault.of(this._iid),{localCacheConfig:s,nestdb:n}=t;if(!t.localCacheEnabled||!n||n.state!=h.NestDBState.OPENED)return;const i=1024*s.maxSize*1024;let a=yield n.estimateUsage();if(ad.__awaiter(this,void 0,void 0,(function*(){const t=new ve(e);this._requestQueue.send(t)}))));const s=this._groupChannelCache.isCachedInMemory(e.channelUrl),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId,r=yield this.getChannel(e.channelUrl,!0),{useMemberInfoInMessage:o}=d.Vault.of(this._iid);if(e instanceof h.SendableMessage){for(const t of r.members)if(t.userId===e.sender.userId){o||(e.sender.nickname=t.nickname,e.sender.plainProfileUrl=t.plainProfileUrl,e.sender.metaData=t.metaData,e.sender.isBlockedByMe=t.isBlockedByMe);break}if(!o&&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._updateLastMessage(e),a||r._shouldUpdateUnreadCountWith(e)&&r._updateUnreadCount(r.unreadMessageCount+1,r.unreadMentionCount+(n?1:0))),i&&r._updateLastMessage(e),this._dispatcher.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),e.silent&&!a||d.runAsCallback((()=>d.__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.CollectionEventSource.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(u.UpdateAdminMessageEventCommand)),t){const{message:e,mentionCountChange:n}=t;if(e.threadInfo&&(e.threadInfo.unreadReplyCount=void 0),e.channelType===d.ChannelType.GROUP){const t=this._groupChannelCache.isCachedInMemory(e.channelUrl),i=yield this.getChannel(e.channelUrl,!0),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId;let r=!1;if(a){const t=e.sender,{currentUser:s}=this._sessionManager;s&&(s.nickname=t.nickname,s.plainProfileUrl=t.plainProfileUrl,s.metaData=t.metaData)}else i.isReadMessage(e)||0!==n&&!e.silent&&t&&(i._updateUnreadCount(i.unreadMessageCount,i.unreadMentionCount+n),r=!0);i._updateLastMessage(e)?r=!0:(null===(s=i.lastMessage)||void 0===s?void 0:s.isIdentical(e))&&(t?i._updateLastMessage(e)&&(r=!0):r=!0);let o=!1;i.lastPinnedMessage&&i.lastPinnedMessage.messageId===e.messageId&&(i.lastPinnedMessage=e,r=!0,o=!0),r&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:o?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}})),e.silent&&!a||d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)})))),o&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)}))))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageUpdated&&t.onMessageUpdated(i,e),n>0&&t.onMentionReceived&&t.onMentionReceived(i,e)}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:n,silent:i,messageCreatedAt:a,senderId:r}=e.as(d.DeleteMessageEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=r===this._sdkState.userId;i||s||a>0&&e.myLastRead0&&e._updateUnreadCount(e.unreadMessageCount-1,0),this._dispatcher.dispatch(new d.MessageRemoveEventCommand({messageIds:[n],source:d.CollectionEventSource.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(h.ReadEventCommand);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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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(ye),n=this._groupChannelCache.isCachedInMemory(t),i=yield this.getChannel(t,!0);n&&Object.keys(s).forEach((e=>{i._updateUndeliveredMemberState(e,s[e])})),Object.keys(s).some((e=>e!==this._sdkState.userId))&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:d.CollectionEventSource.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(u.ReactionEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=yield this.getMessageFromCache(n.messageId);s?s instanceof h.BaseMessage&&(s.applyReactionEvent(n),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new d.ReactionUpdateEventCommand({event:n,source:d.CollectionEventSource.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(u.ThreadInfoUpdateEventCommand);if(t.channelType===d.ChannelType.GROUP){const e=yield this.getChannel(t.channelUrl,!0),s=yield this.getMessageFromCache(t.targetMessageId);s?s instanceof h.BaseMessage&&(s.applyThreadInfoUpdateEvent(t),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new d.ThreadUpdateEventCommand({event:t,source:d.CollectionEventSource.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(u.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 P({channels:s,context:{source:d.CollectionEventSource.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(u.PollUpdateEventCommand);if(n&&i===d.ChannelType.GROUP){const e=yield this.getChannel(n,!0);this._dispatcher.dispatch(new d.PollUpdateInternalEventCommand({event:t,source:d.CollectionEventSource.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.CollectionEventSource.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(u.ChannelEventCommand);if(t.isGroupChannelEvent)switch(t.category){case u.ChannelEventCategory.CHANNEL_JOIN:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,members:a}=e.as(ne);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:a}})),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 u.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(ae);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((e=>e.userId===r.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 P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})):(this._markAsLeave(n),this._dispatcher.dispatch(new R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})))):this._dispatcher.dispatch(new P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})),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 u.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const s=yield this.getChannel(t.channelUrl,!0),{operators:n}=e.as(u.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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitees:r}=e.as(le);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:a,invitees:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserReceivedInvitation&&e.onUserReceivedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitee:r}=e.as(he);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})):this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}}))):this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.TYPING_START:case u.ChannelEventCategory.TYPING_END:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.TYPING_START,{user:i}=e.as(n?ge:Ee);s._updateTypingStatus(i,n?t.ts:0),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.USER_CHANNEL_MUTE:case u.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.USER_CHANNEL_MUTE,{user:i}=e.as(n?h.MuteUserEventCommand:h.UnmuteUserEventCommand);i.userId===this._sdkState.userId&&(s.myMutedState=n?d.MutedState.MUTED:d.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 P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_MUTED:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i}})),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 u.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 R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_BANNED,user:i}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserBanned&&e.onUserBanned(n,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_UNBAN:{const s=yield this.getChannel(t.channelUrl,!0),{user:n}=e.as(h.UnbanUserEventCommand);n.userId===this._sdkState.userId&&this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserUnbanned&&e.onUserUnbanned(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_FREEZE:case u.ChannelEventCategory.CHANNEL_UNFREEZE:{const s=yield this.getChannel(t.channelUrl,!0),{freeze:n}=e.as(h.FreezeEventCommand);s.isFrozen=n,this._dispatcher.dispatch(new P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_FROZEN:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_HIDE:{const s=yield this.getChannel(t.channelUrl,!0),{allowAutoUnhide:n,hidePreviousMessages:i,messageOffsetTimestamp:a}=e.as(pe);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onChannelHidden&&e.onChannelHidden(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_UNHIDE:{const e=yield this.getChannel(t.channelUrl,!0);e.hiddenState=exports.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_DELETED:{const e=yield this.getChannel(t.channelUrl,!0);this._dispatcher.dispatch(new R({channelUrls:[t.channelUrl],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const e=yield this.getChannelWithoutCache(t.channelUrl,!0);this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.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),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:n},ts:t.ts}))),i&&(s._upsertCachedMetaData(i,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:i},ts:t.ts}))),a&&(s._removeFromCachedMetaData(a,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:a},ts: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 u.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaCounterEventCommand);n&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:n}})),i&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:i}})),a&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:a}})),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 u.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:n,latestPinnedMessage:i,ts:a}=e.as(u.UpdatePinnedMessageEventCommand);a>s._pinnedMessagesUpdatedAt&&(s.pinnedMessageIds=null!=n?n:[],s.lastPinnedMessage=i,s._pinnedMessagesUpdatedAt=a,this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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(c.UserEventCommand);switch(t.category){case c.UserEventCategory.USER_BLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.block(e.userId,s.userId);break}case c.UserEventCategory.USER_UNBLOCK:{const{blocker:e,blockee:s}=c.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()}subscribeChannelEvent(e,t){this._groupChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._groupChannelBroadcast.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 F({channelUrl:e,isInternalCall:t}),n=yield this._requestQueue.send(s),{channel:i}=n.as(D);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=d.CollectionEventSource.REFRESH_CHANNEL,n=!1){return d.__awaiter(this,void 0,void 0,(function*(){try{const i=new F({channelUrl:e,isInternalCall:t,showLatestMessage:n}),a=yield this._requestQueue.send(i),{channel:r}=a.as(D);if(r.myMemberState===exports.MemberState.NONE)this._dispatcher.dispatch(new R({channelUrls:[r.url],context:{source:s}}));else{const e=yield this.upsertChannelsToCache([r]);this._dispatcher.dispatch(new P({channels:e,context:{source:s}}))}}catch(t){t.code!==d.SendbirdErrorCode.NON_AUTHORIZED&&t.code!==d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new R({channelUrls:[e],context:{source:s}}))}}))}getMyGroupChannels(e,t,s,n=d.CollectionEventSource.REQUEST_CHANNEL,i=!1){return d.__awaiter(this,void 0,void 0,(function*(){t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3));let a=!1;if(i){const{appInfo:e,cacheContext:t}=d.Vault.of(this._iid);t&&!t.localCacheEnabled&&(null==e?void 0:e.enabledChannelMemberShipHistory)&&(null==e?void 0:e.applicationAttributes.includes("left_user_view_support"))&&(a=!0)}const r=new H(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:e,limit:s,includeLeftChannel:i&&a})),o=yield this._requestQueue.send(r),{channels:l,token:h}=o.as(V);return this._dispatcher.dispatch(new P({channels:l,context:{source:n}})),{channels:l,token:h}}))}getMyGroupChannelChangeLogs(e,t,s=d.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return d.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},f),t);d.unless((d.isTypeOf("string",e)||d.isTypeOf("number",e))&&M(n)).throw(d.SendbirdError.invalidParameters);const i=new w(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(L),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,ts:h}=a;return r.length>0&&this._dispatcher.dispatch(new P({channels:r,context:{source:s},ts:h})),o.length>0&&this._dispatcher.dispatch(new R({channelUrls:o,context:{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({},y),e);d.unless(S(t)).throw(d.SendbirdError.invalidParameters);const s=new G({userId:this._sdkState.userId,filter:t}),n=yield this._requestQueue.send(s),{groupChannelCount:i}=n.as(q);return i}))}getUnreadItemCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},b),e);d.unless((e=>d.isArrayOf(exports.UnreadItemKey,e.keys)&&d.isArrayOf("string",e.customTypeFilters,!0)&&d.isArrayOf("string",e.customTypesFilter,!0))(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),{groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m}=a.as(j);return d.deundefined({groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,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 z({userId:e.userId}),n=yield t.send(s),{unreadCount:i}=n.as(W);return i}))}getTotalUnreadMessageCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},N),e);d.unless(T(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new $({userId:s.userId,filter:t}),a=yield n.send(i),{unreadCount:r}=a.as(K);return r}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},U),e);d.unless((e=>d.isTypeOf("string",e.channelUrl,!0)&&d.isArrayOf(h.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 Q(t),i=yield s.send(n),{count:a}=i.as(Y);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);return Object.keys(t.customTypes).forEach((s=>{e+=t.customTypes[s]})),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(v(t)).throw(d.SendbirdError.invalidParameters),t.isPublic||(t.accessCode=void 0);const s=new X(Object.assign({userId:this._sdkState.userId},t)),n=yield this._requestQueue.send(s),{channel:i}=n.as(Z);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 ee({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 ee({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()}))}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){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})}))}getCachedMessageCountBetween(e,t,s,n){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.countBetween(e,t,new Se({top:s,bottom:n}))}))}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])}))}}const Ne=(e,t)=>t instanceof h.SendableMessage?e.findIndex((e=>e instanceof h.SendableMessage&&t.isIdentical(e))):e.findIndex((e=>e.isIdentical(t))),Te=(e,t)=>e.findIndex((e=>e instanceof h.BaseMessage?e.messageId===t:e instanceof h.NotificationMessage?e.notificationId===t:void 0)),Ue=(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};var Ie;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Ie||(Ie={}));class xe extends d.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=Ie.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===Ie.IDLE}get isRunning(){return this._state===Ie.RUNNING}get isDone(){return this._state===Ie.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 xe(_,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u,_;const p={hasNext:!0,nextToken:0};if(this._prevSyncLoopCount++,yield this.loadMetadata(),r.debug("message background prev sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.top),null===(n=this._metadata)||void 0===n?void 0:n.previousComplete)p.hasNext=!1;else try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(l=null===(a=this._metadata)||void 0===a?void 0:a.range)||void 0===l?void 0:l.top)?this._metadata.range.top:e,{prevResultSize:this._limit,nextResultSize:0,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(c=this._metadata)||void 0===c?void 0:c.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}p.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(p.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.lengthd.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u;const _={hasNext:!0,nextToken:0};yield this.loadMetadata(),r.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom);try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(a=null===(n=this._metadata)||void 0===n?void 0:n.range)||void 0===a?void 0:a.bottom)?this._metadata.range.bottom:e,{prevResultSize:0,nextResultSize:this._limit,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(l=this._metadata)||void 0===l?void 0:l.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}_.hasNext=s.length>=this._limit,this._metadata&&(_.nextToken=this._metadata.range.bottom),r.debug("message background next sync progress",_),yield this.saveMetadata()}catch(e){throw r.debug("message background next sync error",e),e}finally{o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:t.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(u=null===(c=i.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==u?u:0,use_local_cache:i.localCacheEnabled,starting_point:0,message_init_policy:""}}))}return _}))))})))),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){return Pe[e]||(Pe[e]={}),Pe[e][t.url]||(Pe[e][t.url]=new Re({_iid:e,channel:t})),Pe[e][t.url].ref++,Pe[e][t.url]}static clear(e,t){Pe[e]&&Pe[e][t]&&(Pe[e][t].close(),delete Pe[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 Se({})}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(){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?{range:new Se(t.range),previousComplete:t.previousComplete}:{range:new Se({}),previousComplete:!1}}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(e=Date.now()){var t,s,n,i;const{logger:a,sessionManager:r,cacheContext:o}=d.Vault.of(this._iid);o.localCacheEnabled&&r.session.hasSession&&(a.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(s=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==s?s:e),this._nextSync.start(null!==(i=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==i?i:e))}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid][this._channel.url])}}const Oe={};class we{constructor({_iid:e,channel:t,includeParams:s}){this.ref=0,this._iid=e,this._channel=t,this._includeParams=s;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}/message/changelogs.meta`);const l=((e,t)=>`sendbird:${e}@groupchannel/${t}/message/changelogs`)(i.userId,this._channel.url);this._sync=new xe(l,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};yield this.loadMetadata(),n.debug("message changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=h.MessageManager.of(this._iid),{updatedMessages:s,deletedMessageIds:i,hasMore:a,token:r}=yield e.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:d.ReplyType.ALL},this._includeParams),d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);t.hasNext=a,t.nextToken=r,(s.length>0||i.length>0)&&this._metadata&&(this._metadata.token=r),n.debug("message changelog sync progress",t),yield this.saveMetadata()}catch(e){throw n.debug("message 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 Oe[e]||(Oe[e]={}),Oe[e][t.url]||(Oe[e][t.url]=new we({_iid:e,channel:t,includeParams:s})),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])}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,sessionManager:t}=d.Vault.of(this._iid);t.session.hasSession&&(e.debug("message changelog sync resume()"),this._sync.start(0))}pause(){const{logger:e}=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 Oe[this._iid][this._channel.url])}}const Le={};class Fe{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 xe(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=d.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 Le[e]||(Le[e]={}),Le[e][t.url]||(Le[e][t.url]=new Fe({_iid:e,channel:t,hasPollMessage:s})),Le[e][t.url].ref++,Le[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 Le[this._iid][this._channel.url])}}class De extends d.APIRequestCommand{constructor(e){var t,s,n,i,a,r,o,l,h,c;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_reply_type:null!==(i=e.replyType)&&void 0!==i?i:d.ReplyType.NONE,include_reactions:null===(a=e.includeReactions)||void 0===a||a,include_meta_array:null===(r=e.includeMetaArray)||void 0===r||r,include_thread_info:null===(o=e.includeThreadInfo)||void 0===o||o,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(c=e.showSubchannelMessagesOnly)&&void 0!==c&&c,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=>h.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=>h.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 He={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};exports.MessageCollectionInitPolicy=void 0,(exports.MessageCollectionInitPolicy||(exports.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";class Ve{constructor(){this._onCacheResult=d.noop,this._onApiResult=d.noop}_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 Ge{keyOf(e){return 0}get changelogIncludeParams(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}_postprocessChannelUpdateEvent(e,t){}_postprocessChannelRemoveEvent(e){}_postprocessMessageUpdateEvent(e,t){}_postprocessMessageRemoveEvent(e){}constructor(e,{filter:t,startingPoint:s,limit:n,prevResultLimit:i,nextResultLimit:a,channel:r,channelManager:o,disableBackgroundSync:l=!1}){this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key=`mc-${d.uuid()}`,this._isDisposed=!1,this.filter=null!=t?t:new h.MessageFilter,this._channel=r,this._syncRange=new Se({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=n||h.DEFAULT_MESSAGE_LIMIT,this._prevResultLimit=null!=i?i:Math.floor(this._limit/2),this._nextResultLimit=null!=a?a:Math.floor(this._limit/2),this._channelManager=o;const{statManager:c}=d.Vault.of(this._iid);this._channelManager.subscribeChannelEvent(this._key,{onUpdate:(e,t)=>{const{source:s}=t,n=e.findIndex((e=>e.isIdentical(this.channel)));n>=0&&(this._replaceChannelOfCollection(e[n]),this.channel._runIfHandleableWithGroupChannel((e=>{switch(s){case d.CollectionEventSource.EVENT_CHANNEL_UPDATED:{let t=!1;for(let s=0;s=e.messageOffsetTimestamp){t=!0;const e=s;if(e>0){const t=this._messages.splice(0,e);this._removeMessagesFromView(t.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!t&&this._messages.length>0&&this._removeMessagesFromView(this._messages.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break}case d.CollectionEventSource.EVENT_CHANNEL_UNMUTED:{const{sdkState:e}=d.Vault.of(this._iid),{user:s}=t;e.userId===s.userId&&this._clearCheckMyMutedTimer();break}case d.CollectionEventSource.EVENT_CHANNEL_MUTED:{const{sdkState:s}=d.Vault.of(this._iid),{user:n}=t;s.userId===n.userId&&-1!==e._myMutedRemainingTime&&this._startCheckMyMutedTimer(e._myMutedRemainingTime);break}case d.CollectionEventSource.EVENT_CHANNEL_LEFT:e.isPublic&&this._clearCheckMyMutedTimer()}d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;x(s)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel)}))))})),this._postprocessChannelUpdateEvent(e[n],s))},onRemove:(e,t)=>{const s=e.indexOf(this.channel.url);s>=0&&(this._clearCheckMyMutedTimer(),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url)})))),this._postprocessChannelRemoveEvent(e[s]))}}),this._channelManager.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(this.keyOf(t)));if(d.shouldGiveEvent(t)){if(s.length>0)switch(t){case d.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case d.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case d.CollectionEventSource.EVENT_MESSAGE_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:this._updateMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:this._addMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_RECEIVED:this.hasNext||this._addMessagesToView(s,t);break;case d.CollectionEventSource.SYNC_MESSAGE_FILL:this._addMessagesToView(s,t)}n.length>0&&this._removeMessagesFromView(n,t)}this._postprocessMessageUpdateEvent(e,t)},onRemove:(e,t)=>{this._removeMessagesFromView(e,t),this._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:(e,t)=>{this._applyReactionEventToView(e,t)},onThreadInfoUpdate:(e,t)=>{this._applyThreadInfoEventToView(e,t)}});const{cacheContext:u,dispatcher:_,messageBackgroundSyncThrottleController:p}=d.Vault.of(this._iid);this._channel._updateMessageCollectionLastAccessedAt(),_.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Re.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=we.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Fe.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new xe(this._key,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.min(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:i.length>=this._prevResultLimit&&this.viewTopd.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.max(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:!(i.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>e,nextToken:this._syncRange.bottom}}return u.localCacheEnabled&&c.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(s=u.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==n?n:0,use_local_cache:u.localCacheEnabled,starting_point:0,message_init_policy:""}})),{hasNext:!1,nextToken:0}}))))})))),this._connectionEventContext=_.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)switch(e.stateType){case d.ConnectionStateType.CONNECTED:d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){this._activate()}))));break;case d.ConnectionStateType.LOGOUT:this.dispose();break;default:this._clearCheckMyMutedTimer(),this._prevFill.stop(),this._nextFill.stop()}}))}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)}_activate(){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:e}=d.Vault.of(this._iid);e.debug("check huge gap"),this._checkHugeGap(),yield this._refreshChannel(d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS)}))}_replaceChannelOfCollection(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}_shouldStartBackgroundSync(){const{cacheContext:e}=d.Vault.of(this._iid);return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}_setBaseMessageCollectionHandler(e){this._handler=e}_filterUnderOffsetMessage(e){return e}_updateChildMessagesInView(e){const t=[];return this._messages.forEach((s=>{s instanceof h.BaseMessage&&s.parentMessageId===e.messageId&&s.applyParentMessage(e)&&t.push(s)})),t}_updatePollsToView(e,t){const s=[];for(const t of e){const e=Te(this._messages,t.messageId);if(e>=0){const n=this._messages[e];n.isUserMessage()&&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,n;const i={source:t};s.length>0&&(null===(n=(e=this._handler).onMessagesUpdated)||void 0===n||n.call(e,i,this.channel,s))})))),s}_applyPollUpdateEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyPollVoteEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyReactionEventToView(e,t){const s=Te(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyReactionEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_applyThreadInfoEventToView(e,t){const s=Te(this._messages,e.targetMessageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyThreadInfoUpdateEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_removeMessagesFromView(e,t){const s=[],n=[];for(const t of e){const e=this._messages.findIndex((e=>this.keyOf(e)===t));if(e>=0){const t=this._messages[e];s.push(this.keyOf(t)),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,i;const a={source:t};null===(i=null===(e=this._handler)||void 0===e?void 0:e.onMessagesDeleted)||void 0===i||i.call(e,a,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*(){let i=[];n&&(i=yield this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter));const a=t>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,t,!1):[],r=s>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1):[];return{messages:[...i,...a,...r].sort(((e,t)=>t.createdAt-e.createdAt)),prevMessagesCount:a.length,nextMessagesCount:r.length}}))}_getRemoteMessages(e,{prevLimit:t=0,nextLimit:s=0,source:n=d.CollectionEventSource.REQUEST_MESSAGE,reverse:i=!1,checkingHasNext:a=!1,checkingContinuousMessages:r=!1}){return d.__awaiter(this,void 0,void 0,(function*(){const o=h.MessageManager.of(this._iid);return t>0||s>0?yield o._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,d.undefineNullProps(Object.assign(Object.assign(Object.assign({},this.filter),He),{isInclusive:!0,reverse:i,prevResultSize:t,nextResultSize:s})),n,a,r):{messages:[],isContinuousMessages:!1}}))}_checkHugeGap(){var e,t,s,n,i;return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r,cacheContext:o,statManager:l,logger:h}=d.Vault.of(this._iid);if(this._messages.length>0){const s=this._syncRange.top,n=this.viewTop,i=this._syncRange.bottom,c=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,n,s),_=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,i,c);try{yield d.asyncRetry((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t=new De(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:s,prevCount:u,nextStart:i,nextEnd:c,nextCount:_,checkingContinuousMessages:o.localCacheEnabled},this.filter),He)),l=yield r.send(t),{isHugeGap:h,prevMessages:p=[],prevHasMore:m,isContinuousPrevMessages:g,nextMessages:C=[],nextHasmore:E,isContinuousNextMessages:v}=l.as(ke);if(h)d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected()}))));else{const t=this.viewTop,s=this.viewBottom,n=Math.min(Number.MAX_SAFE_INTEGER,t,...p.map((e=>e.createdAt))),i=Math.max(0,s,...C.map((e=>e.createdAt)));a.dispatch(new d.MessageUpdateEventCommand({messages:p,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),a.dispatch(new d.MessageUpdateEventCommand({messages:C,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(n,i),(g||v)&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(n,i)),m&&this._prevFill.start(n),E&&this._nextFill.start(i)}}))),1)}catch(e){h.debug("Failed HugeGap Check ",e)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}else{const e=Date.now();try{const{messages:t,isContinuousMessages:n,hasNext:i}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:o.localCacheEnabled});if(t.length>0){const a=t.map((e=>e.createdAt));let r=0,o=0;for(let t=0;t=e&&o++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=i?i:o>=this._nextResultLimit,this._syncRange.extends(...a),n&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(t,d.CollectionEventSource.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)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(n=o.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==i?i:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}}))}_loadUnsentMessages(){return d.__awaiter(this,void 0,void 0,(function*(){this._unsentMessages=yield this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)}))}_hasPollMessage(){return d.__awaiter(this,void 0,void 0,(function*(){return(yield this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)).length>0}))}_refreshChannel(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:s}=d.Vault.of(this._iid);try{yield this._channelManager.refreshChannel(this.channel.url,!0,e,t)}catch(e){s.warn("Failed to refresh channel",e)}}))}_startCheckMyMutedTimer(e){this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((()=>d.__awaiter(this,void 0,void 0,(function*(){this._checkMyMutedStateTimer=void 0;let e=!0;try{e=!(yield this._channel.getMyMutedInfo()).isMuted}catch(t){e=!0}finally{if(e){const{sessionManager:e}=d.Vault.of(this._iid);this.channel._runIfHandleableWithGroupChannel((t=>{var s,n;t.myMutedState=d.MutedState.UNMUTED;const i={source:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:e.currentUser};null===(n=null===(s=this._handler)||void 0===s?void 0:s.onChannelUpdated)||void 0===n||n.call(s,i,this.channel)}))}}}))),e+1e3)}_clearCheckMyMutedTimer(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}_setHasNextAndHasPrevious(e,t){const s=e.map((e=>e.createdAt));let n=0,i=0;for(let e=0;ethis._startingPoint&&i++}this._hasPrevious=n>=this._prevResultLimit,this._hasNext=null!=t?t:i>=this._nextResultLimit}initialize(e){const t=new Ve;this._messages=[],this._unsentMessages=[],this._syncRange=new Se({}),this._hasNext=!0,this._hasPrevious=!0;let s=[],n={messages:[],prevMessagesCount:0,nextMessagesCount:0};return d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var i;const a=yield null===(i=this._backgroundSync)||void 0===i?void 0:i.loadMetadata(),{cacheContext:r,statManager:o}=d.Vault.of(this._iid);if(e===exports.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((e=>d.__awaiter(this,void 0,void 0,(function*(){n=e,s=this._filterUnderOffsetMessage(n.messages),this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE),yield this._loadUnsentMessages(),t._invokeResponse("local",null,s)})))).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("local",e,null)})).finally((()=>d.__awaiter(this,void 0,void 0,(function*(){var i,r;const{cacheContext:l}=d.Vault.of(this._iid);let h=!0,c=!0,u=!1;l.localCacheEnabled&&s.length>0&&a.range.includes(...s.map((e=>e.createdAt)))&&(!a.previousComplete&&n.prevMessagesCounta.range.bottom||n.nextMessagesCount{const t=Math.max(...s.map((e=>e.createdAt)));e._latestMessageInfo&&t>=e._latestMessageInfo.createdAt&&(c=!1)})),c?(h=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled}).then((({messages:e,isContinuousMessages:s,hasNext:n})=>{var i,a;const r=this._filterUnderOffsetMessage(e);this._messages=[],r.length>0?(this._setHasNextAndHasPrevious(r,n),this._syncRange.extends(...r.map((e=>e.createdAt))),s&&(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(r,d.CollectionEventSource.REQUEST_MESSAGE)):(this._hasPrevious=!1,this._hasNext=!1),t._invokeResponse("remote",null,r)})).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(s),t._invokeResponse("remote",null,s)),l.localCacheEnabled&&o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:h?"cache_hit":"cache_miss",max_db_size:null!==(r=null===(i=l.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==r?r:0,message_init_policy:e,use_local_cache:l.localCacheEnabled,collection_id:this._key}}))}))));o.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}}))})))),t}loadPrevious(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasPrevious)return[];if(this._isLoadingPrevious)return a.warn("Messages are already fetching."),[];this._isLoadingPrevious=!0;const r=this.viewTop;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{prevLimit:this._prevResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._prevResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasPrevious=o.length>=this._prevResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a;const{cacheContext:l}=d.Vault.of(this._iid),h=yield this._getRemoteMessages(r,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:l.localCacheEnabled});o=this._filterUnderOffsetMessage(h.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasPrevious=o.length>=this._prevResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(n=l.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==a?a:0,use_local_cache:l.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingPrevious=!1,o}))}loadNext(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasNext)return[];if(this._isLoadingNext)return a.warn("Messages are already fetching."),[];this._isLoadingNext=!0;const r=this.viewBottom;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{nextLimit:this._nextResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._nextResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasNext=o.length>=this._nextResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a,l;const{cacheContext:h}=d.Vault.of(this._iid),c=yield this._getRemoteMessages(r,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled});o=this._filterUnderOffsetMessage(c.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&c.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.bottom))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasNext=null!==(n=c.hasNext)&&void 0!==n?n:o.length>=this._nextResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(l=null===(a=h.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==l?l:0,use_local_cache:h.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingNext=!1,o}))}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."});yield this._channelManager.removeFailedMessageFromCache(e);const t=this._unsentMessages.findIndex((t=>t.reqId===e));t>-1&&this._unsentMessages.splice(t,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._runIfHandleableWithGroupChannel((e=>{e.myMemberState!==exports.MemberState.NONE&&(this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}class qe extends Ge{keyOf(e){return e.messageId}constructor(e,t){super(e,Object.assign(Object.assign({},t),{channelManager:be.of(e)}))}initialize(e){return 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)})))),super.initialize(e)}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_activate(){const e=Object.create(null,{_activate:{get:()=>super._activate}});return d.__awaiter(this,void 0,void 0,(function*(){yield e._activate.call(this),yield 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)}))))}))}_addMessagesToView(e,t){const s=this._filterUnderOffsetMessage(e),n=[],i=[];for(const e of s)if(t===d.CollectionEventSource.SYNC_MESSAGE_FILL){if(e.messageId>0){if(Ne(this._messages,e)<0){Ne(this._unsentMessages,e)<0&&n.push(e);const t=Ue(this._messages,e);this._messages.splice(t,0,e)}}else if(e instanceof h.SendableMessage){Ne(this._unsentMessages,e)<0&&Ne(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e))}}else if(e.messageId>0){const t=Ne(this._messages,e);if(t<0){const t=Ne(this._unsentMessages,e);t<0?n.push(e):(this._unsentMessages.splice(t,1),i.push(e));const s=Ue(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 h.SendableMessage){const t=Ne(this._unsentMessages,e);t<0?Ne(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,a,r;const o={source:t};n.length>0&&(null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===s||s.call(e,o,this.channel,n)),i.length>0&&(null===(r=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===r||r.call(a,o,this.channel,i))}))))}_updateMessagesToView(e,t){const s=[],n=[],i=[];for(const t of e)if(t.messageId>0){const e=Ne(this._messages,t);if(e>=0)n.push(t),this._messages[e]=t;else{const e=Ne(this._unsentMessages,t);if(e>=0){const[s]=this._unsentMessages.splice(e,1);if(this.hasNext&&s)i.push(s);else{n.push(t);const e=Ue(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 h.SendableMessage){const e=Ne(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,r,o;const l={source:t};n.length>0?null===(a=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===a||a.call(e,l,this.channel,n):i.length>0?null===(o=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===o||o.call(r,l,this.channel,[],i):s.length>0&&this._addMessagesToView(s,t)})))),n}}const Be={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 je 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 ze 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 p(e,t))))}}var We,$e,Ke;exports.MutedMemberFilter=void 0,(We=exports.MutedMemberFilter||(exports.MutedMemberFilter={})).ALL="all",We.MUTED="muted",We.UNMUTED="unmuted",exports.MemberListOrder=void 0,($e=exports.MemberListOrder||(exports.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",$e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",exports.MemberStateFilter=void 0,(Ke=exports.MemberStateFilter||(exports.MemberStateFilter={})).ALL="all",Ke.JOINED="joined_only",Ke.INVITED="invited_only",Ke.INVITED_BY_FRIEND="invited_by_friend",Ke.INVITED_BY_NON_FRIEND="invited_by_non_friend";class Qe 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 je(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{members:n,token:i}=s.as(ze);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class Ye 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 Je extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t),this.channel.myMemberState=exports.MemberState.JOINED}}class Xe 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:c,operatorUserIds:u,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:c,cover_url:a,cover_file:r,access_code:o,operator_ids:u,message_survival_seconds:_})}}class Ze extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class et 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 tt 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 st 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 nt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.countPreference=t.count_preference}}class it extends d.APIRequestCommand{constructor(e){const{channelUrl:t,locale:s}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/reset_user_history`,this.params=d.deundefined({locale:s})}}class at extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}const rt=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}),ot=Object.assign(Object.assign({},h.UserMessageUpdateParamsDefault),{scheduledAt:void 0});class lt extends d.APIRequestCommand{constructor(e){var t,s;super();let n=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((e=>e.userId))));const{channelType:i,channelUrl:a,scheduledMessageId:r}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(i)}/${encodeURIComponent(a)}/scheduled_messages/${encodeURIComponent(r)}`,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:null===(t=e._thumbnails)||void 0===t?void 0:t.map((e=>h.Thumbnail.payloadify(e))),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:n,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}))}}class dt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.message=new h.FileMessage(e,t)}}class ht 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=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class ct 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 ut 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 _t 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 pt 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({userId:e,channelUrl:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`}}class gt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}var Ct,Et;exports.CountPreference=void 0,(Ct=exports.CountPreference||(exports.CountPreference={})).ALL="all",Ct.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Ct.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Ct.OFF="off",exports.HiddenState=void 0,(Et=exports.HiddenState||(exports.HiddenState={})).UNHIDDEN="unhidden",Et.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Et.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";class vt extends h.BaseChannel{constructor(e,t){var s,n,i,a,r,o,l,c,u,_,m,g,C,E,v,f,M,y,S;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._hasBotInfo={general:!1,ai:!1},this.isDistinct=!1,this.isSuper=!1,this.isBroadcast=!1,this.isExclusive=!1,this.isPublic=!1,this.isDiscoverable=!0,this.isChatNotification=!1,this.isAccessCodeRequired=!1,this.isPushEnabled=!1,this.unreadMessageCount=0,this.unreadMentionCount=0,this.totalUnreadReplyCount=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=d.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.lastPinnedMessage=null,this._latestMessageInfo=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.isChatNotification=null!==(l=t.is_chat_notification)&&void 0!==l&&l,this.isAccessCodeRequired=null!==(c=t.is_access_code_required)&&void 0!==c&&c,this.isPushEnabled=null!==(u=t.is_push_enabled)&&void 0!==u&&u,Array.isArray(t.members)&&this.members.push(...t.members.map((e=>new p(this._iid,e)))),this.memberCount=null!==(_=t.member_count)&&void 0!==_?_:0,this.joinedMemberCount=null!==(m=t.joined_member_count)&&void 0!==m?m:0,this.hiddenState=d.isEnumOf(exports.HiddenState,t.hidden_state)?t.hidden_state:exports.HiddenState.UNHIDDEN,this.messageOffsetTimestamp=null!==(g=t.ts_message_offset)&&void 0!==g?g:0,this.messageSurvivalSeconds=null!==(C=t.message_survival_seconds)&&void 0!==C?C:-1,this.lastMessage=t.last_message?h.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(d.MutedState,t.is_muted)?this.myMutedState=t.is_muted:d.isTypeOf("boolean",t.is_muted)?this.myMutedState=t.is_muted?d.MutedState.MUTED:d.MutedState.UNMUTED:this.myMutedState=d.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!==(E=t.user_last_read)&&void 0!==E?E: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!==(f=t.joined_ts)&&void 0!==f?f:0,this._updateUnreadCount(null!==(M=t.unread_message_count)&&void 0!==M?M:0,null!==(y=t.unread_mention_count)&&void 0!==y?y:0),this.totalUnreadReplyCount=null!==(S=t.total_unread_thread_message_count)&&void 0!==S?S:0,this.lastPinnedMessage=t.latest_pinned_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.latest_pinned_message)):null,t.latest_message&&(this._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),this._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot}}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}get hasBot(){return this._hasBotInfo.general}get hasAiBot(){return this._hasBotInfo.ai}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,total_unread_thread_message_count:e.totalUnreadReplyCount,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=>p.payloadify(e))),last_message:e.lastMessage?h.payloadifyMessage(e.lastMessage):null,inviter:e.inviter?d.User.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?h.payloadifyMessage(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))}_shouldUpdateLastMessageWith(e){if(e.silent)return!1;const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.lastMessageThreadingPolicy){case d.LastMessageThreadingPolicy.NONE:case d.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case d.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt{t.onChannelChanged&&t.onChannelChanged(e)})),s.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}}))}_shouldUpdateUnreadCountWith(e){const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.unreadCountThreadingPolicy){case d.UnreadCountThreadingPolicy.NONE:case d.UnreadCountThreadingPolicy.INCLUDE_REPLY:break;case d.UnreadCountThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}_updateLastMessage(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}_updateUnreadCount(e,t){if("number"==typeof e&&e>=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,Object.assign(e,this._serializeCachedMetaData())}))}createMessageCollection(e={}){return new qe(this._iid,Object.assign(Object.assign({},e),{channel:this}))}createMemberListQuery(e={}){return new Qe(this._iid,this.url,e)}createThreadedParentMessageListQuery(e={}){return new _.ThreadedParentMessageListQuery(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 p?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 h.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 h.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 h.ReadStatus(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.payloadify(n),ts:null!=e?e:0})}})),s}getDeliveryStatus(e=!0){const{sdkState:t}=d.Vault.of(this._iid);if(!t.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;const s={};return this.members.forEach((n=>{if(e||n.userId!==t.userId){const e=this._undeliveredMemberStateMap.get(n.userId);s[n.userId]=new m(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.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*(){return this._refresh()}))}_refresh(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t,dispatcher:s}=d.Vault.of(this._iid),n=new F({channelUrl:this.url}),i=yield t.send(n),{channel:a}=i.as(D);return this._update(a),e||s.dispatch(new P({channels:[a],context:{source:d.CollectionEventSource.REFRESH_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 P({channels:[this],context:{source:d.CollectionEventSource.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 P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}))}))}updateChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},Be),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 Xe(Object.assign({channelUrl:this.url},t)),a=yield n.send(i),{channel:r}=a.as(Ze);return this._update(r),s.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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,sessionManager:n}=d.Vault.of(this._iid),i=new re({channelUrl:this.url,userIds:e}),a=yield s.send(i),{channel:r}=a.as(oe);return this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:n.currentUser,invitees:[]},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 te({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(se);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},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 ie({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 Ye({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(Je);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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 de({channelUrl:this.url,userId:e.userId});return yield t.send(s),this.myMemberState=exports.MemberState.NONE,this}))}sendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=>{n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendMultipleFilesMessage(e){const t=new h.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=be.of(this._iid);this._updateLastMessage(e),n.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 h.SendableMessage){const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new d.UnsentMessageRemoveEventCommand({reqId:e.reqId,source:d.CollectionEventSource.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 ue(Object.assign({channelUrl:this.url,userId:n.userId},t)),r=yield i.send(a),{messageOffsetTimestamp:o}=r.as(_e);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 P({channels:[this],context:{source:d.CollectionEventSource.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 tt({channelUrl:this.url});return yield t.send(s),this.hiddenState=exports.HiddenState.UNHIDDEN,e.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 et({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 h.ReadRequestCommand({channelUrl:this.url}),i=yield s.send(n),{readStatus:a}=i.as(h.ReadEventCommand);if(this._updateUnreadMemberState(e.userId,a.readAt),this.unreadMessageCount>0||this.unreadMentionCount>0){this._updateUnreadCount(0,0);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 Me({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 me({channelUrl:this.url,time:this._typingStarted});yield 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 Ce({channelUrl:this.url,time:this._typingStarted});yield e.send(t)}}))}createScheduledUserMessage(e){e=Object.assign(Object.assign({},h.ScheduledUserMessageCreateParamsDefault),e),d.unless(h.validateScheduledUserMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=new h.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({},ot),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 ht(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({},h.ScheduledFileMessageCreateParamsDefault),e),d.unless(h.validateScheduledFileMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=Date.now(),s=this._generateRequestId(),n=new h.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({},rt),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 lt(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(dt);return r}))}cancelScheduledMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new ct({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 ut({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 mt({userId:e.userId,channelUrl:this.url}),n=yield t.send(s),{pushTriggerOption:i}=n.as(gt);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 _t({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),a=yield n.send(i),{pushTriggerOption:r}=a.as(pt);return this.myPushTriggerOption=r,t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 st({channelUrl:this.url,userId:s.userId,countPreference:e}),a=yield n.send(i),{countPreference:r}=a.as(nt);return this.myCountPreference=r,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),r}))}resetMyHistory(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t,sdkState:s}=d.Vault.of(this._iid),n=new it({channelUrl:this.url,locale:s.localeForChatbot}),i=yield t.send(n),{messageOffsetTimestamp:a}=i.as(at);return this.messageOffsetTimestamp=a,this.lastMessage&&this.lastMessage.createdAt{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),n._trigger(e)})),n}if(e.isFileMessage()){const s=this._validateFailedFileMessageHasFile(e,t);d.unless(s).throw(d.SendbirdError.invalidParameters);const n=h.createFileMessageCreateParamsFromFailedFileMessage(e,t),i=new h.MessageRequestHandler;return this._sendFileMessage(n,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{i._trigger(e)})).onFailed(((e,t)=>{i._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),i._trigger(e)})),i}if(e.isMultipleFilesMessage()){const t=e.messageParams,s=new h.MultipleFilesMessageRequestHandler;return this._sendMultipleFilesMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{s._trigger(e)})).onFailed(((e,t)=>{s._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),s._trigger(e)})).onFileUploaded(((e,t,n,i)=>{s._triggerOnFileUploaded(e,t,n,i)})),s}}copyMessage(e,t){if(d.unless(e instanceof h.BaseChannel&&t instanceof h.SendableMessage&&t.sendingStatus===d.SendingStatus.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(d.SendbirdError.invalidParameters),t.isUserMessage()){d.unless(!t.poll).throw(d.SendbirdError.notSupportedError);const s=h.createUserMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendUserMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isFileMessage()){const s=h.createFileMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendFileMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isMultipleFilesMessage()){if(e.isGroupChannel()){const s=h.createMultipleFilesMessageCreateParams(t),n=new h.MultipleFilesMessageRequestHandler;return e._sendMultipleFilesMessage(s,h.SendMessageRequestType.COPY).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})).onFileUploaded(((e,t,s,i)=>{n._triggerOnFileUploaded(e,t,s,i)})),n}throw d.SendbirdError.channelTypeNotSupportedError}}}exports.BaseMessageCollection=Ge,exports.DeliveryStatus=m,exports.GetTotalUnreadMessageCountRequestCommand=$,exports.GetTotalUnreadMessageCountResponseCommand=K,exports.GroupChannel=vt,exports.GroupChannelChangeLogsParamsDefault=f,exports.GroupChannelCountParamsDefault=y,exports.GroupChannelCreateParamsDefault=E,exports.GroupChannelEventSource=I,exports.GroupChannelFilter=g,exports.GroupChannelListQuery=fe,exports.GroupChannelManager=be,exports.Member=p,exports.MemberListQuery=Qe,exports.MessageCollection=qe,exports.MessageCollectionInitHandler=Ve,exports.Sync=xe,exports.TimeRange=Se,exports.TotalUnreadMessageCountParamsDefault=N,exports.indexOfMessage=Ne,exports.placeOfMessage=Ue,exports.shouldGiveEvent=x,exports.validateGroupChannelChangeLogsParams=M,exports.validateGroupChannelCountParams=S,exports.validateGroupChannelCreateParams=v,exports.validateTotalUnreadMessageCountParams=T; +var e,t,s,n,i,a,r,o,l,d=require("./__bundle-2d1d7d4f.cjs"),h=require("./__bundle-ccb8334d.cjs"),c=require("./__bundle-f1e6fb74.cjs"),u=require("./__bundle-73351257.cjs"),_=require("./__bundle-fdee1c40.cjs");exports.MemberState=void 0,(e=exports.MemberState||(exports.MemberState={})).NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left";class p 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 m 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.member=new d.User(this._iid,t.user),this.deliveryAt=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 g{constructor(e){var t,s,n,i,a,r,o,l,d,h,c,u,_,p,m;this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(t=null==e?void 0:e.includeEmpty)&&void 0!==t&&t,this.nicknameContainsFilter=null!==(s=null==e?void 0:e.nicknameContainsFilter)&&void 0!==s?s:null,this.nicknameStartsWithFilter=null!==(n=null==e?void 0:e.nicknameStartsWithFilter)&&void 0!==n?n:null,this.nicknameExactMatchFilter=null!==(i=null==e?void 0:e.nicknameExactMatchFilter)&&void 0!==i?i:null,this.channelNameContainsFilter=null!==(a=null==e?void 0:e.channelNameContainsFilter)&&void 0!==a?a:"",this.myMemberStateFilter=null!==(r=null==e?void 0:e.myMemberStateFilter)&&void 0!==r?r:exports.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(o=null==e?void 0:e.customTypesFilter)&&void 0!==o?o:null,this.channelUrlsFilter=null!==(l=null==e?void 0:e.channelUrlsFilter)&&void 0!==l?l:null,this.superChannelFilter=null!==(d=null==e?void 0:e.superChannelFilter)&&void 0!==d?d:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(h=null==e?void 0:e.publicChannelFilter)&&void 0!==h?h:exports.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(c=null==e?void 0:e.customTypeStartsWithFilter)&&void 0!==c?c:null,this.unreadChannelFilter=null!==(u=null==e?void 0:e.unreadChannelFilter)&&void 0!==u?u:exports.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==e?void 0:e.hiddenChannelFilter)&&void 0!==_?_:exports.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(p=null==e?void 0:e.includeFrozen)||void 0===p||p,(null==e?void 0:e.createdAfter)&&(this.createdAfter=e.createdAfter),(null==e?void 0:e.createdBefore)&&(this.createdBefore=e.createdBefore),this.includeMetaData=null===(m=null==e?void 0:e.includeMetaData)||void 0===m||m}_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 g;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("*")&&!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.ALL:if("none"===e.myMemberState)return!1;break;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!(this.createdAfter&&e.createdAtthis.createdBefore)}}class C 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 be.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 c.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!s&&t.name.localeCompare(e)<0||s&&t.name.localeCompare(e)>0)return!1;break;case c.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>e||s&&t.createdAte||s&&t.lastMessageUpdatedAtthis._deserialize(e)));return d.forEach((e=>{!n.includeMetaData&&e.cachedMetaData&&e._clearCachedMetaData(),this._channels.has(e.url)||this._channels.set(e.url,e)})),d}return[]}))}upsert(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];if(e.forEach((e=>{if(this._channels.has(e.url)){const n=this._channels.get(e.url);if(n._pinnedMessagesUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t){const{isUpdated:s}=n._updateCachedMetaData(e.cachedMetaData,t);s||Object.assign(e,{_cachedMetaData:void 0})}n._update(e),s.push(n)}else this._channels.set(e.url,e),s.push(e)})),this.localCacheEnabled){const e=[];for(let t=0;t0&&(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},v=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),f={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},M=e=>d.isArrayOf("string",e.customTypes,!0)&&d.isTypeOf("boolean",e.includeEmpty,!0)&&d.isTypeOf("boolean",e.includeFrozen,!0)&&d.isTypeOf("boolean",e.includeMetaData,!0)&&d.isTypeOf("boolean",e.includeChatNotification,!0),y={myMemberStateFilter:exports.MyMemberStateFilter.ALL},S=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 b={keys:[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,exports.UnreadItemKey.NONSUPER_INVITATION_COUNT,exports.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},N={channelCustomTypesFilter:void 0,superChannelFilter:exports.SuperChannelFilter.ALL},T=e=>d.isArrayOf("string",e.channelCustomTypesFilter,!0)&&d.isEnumOf(exports.SuperChannelFilter,e.superChannelFilter),U={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:d.MessageTypeFilter.ALL},I=Object.assign({},d.CollectionEventSource),x=e=>e.startsWith("EVENT_")||e===d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||e===d.CollectionEventSource.REFRESH_CHANNEL;class P extends d.BaseCommand{constructor({channels:e,context:t,isWebSocketEventComing:s=!1,ts:n}){super(),this.channels=e,this.context=t,this.isWebSocketEventComing=s,this.ts=n}}class R extends d.BaseCommand{constructor({channelUrls:e,context:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.context=t,this.isWebSocketEventComing=s}}class O{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 P){const{channels:s,context:i,isWebSocketEventComing:a}=n,r=s.filter((e=>e instanceof vt));if(i.source===d.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY||i.source===d.CollectionEventSource.EVENT_CHANNEL_HIDDEN)for(const e of r)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp);else{const s=e.filterOffsetChanged(r);for(const e of s)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp)}const o=yield e.upsert(r,n.ts);a||this._broadcastUpdateEvent(o,i)}else if(n instanceof R){const{channelUrls:i,context: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 c.DatabaseOpenCommand&&(yield e.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,t)}_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 w extends d.APIRequestCommand{constructor({userId:e,ts:t,token:s,filter:n,includeChatNotification:i=!1}){super();const{customTypes:a,includeEmpty:r,includeFrozen:o}=Object.assign(Object.assign({},f),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:a,show_empty:r,show_frozen:o,include_chat_notification:i}))}}class L extends d.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((s=>new vt(e,Object.assign(s,{ts:t.ts})))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next,this.ts=t.ts}}class F extends d.APIRequestCommand{constructor({channelUrl:e,isInternalCall:t,showLatestMessage:s}){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,show_latest_message:null!=s&&s}}}class D extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}const k={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0};class H 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:c,nicknameStartsWithFilter:u,nicknameExactMatchFilter:_,channelNameContainsFilter:p,channelUrlsFilter:m,customTypesFilter:g,customTypeStartsWithFilter:C,hiddenChannelFilter:E,metadataOrderKeyFilter:v,metadataKey:f,metadataValues:M,metadataValueStartsWith:y,includeFrozen:S,includeMetaData:A,searchFilter:b,userIdsFilter:N,includeChatNotification:T=!1,includeLeftChannel:U=!1,createdAfter:I,createdBefore:x}=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:k.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=a?a:k.includeEmpty,member_state_filter:null!=r?r:k.myMemberStateFilter,super_mode:null!=o?o:k.superChannelFilter,public_mode:null!=l?l:k.publicChannelFilter,unread_filter:null!=h?h:k.unreadChannelFilter,members_nickname_contains:c,members_nickname_startswith:u,members_nickname:_,name_contains:p,channel_urls:m,custom_types:g,custom_type_startswith:C,hidden_mode:E,metadata_order_key:v,metadata_key:f,metadata_values:M,metadata_value_startswith:y,show_frozen:S,show_metadata:A,include_chat_notification:T,include_left_channel:U,created_after:I,created_before:x}),b&&b.query&&b.fields&&(this.params.search_query=b.query,this.params.search_fields=b.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(this.params.members_include_in=N.userIds,this.params.query_type=N.queryType.toUpperCase()):this.params.members_exactly_in=N.userIds)}}class V 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 vt(e,t))))),this.ts=null!=i?i:0}}class G 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 q extends d.APIResponseCommand{constructor(e,t){super(e,t),this.groupChannelCount=t.group_channel_count}}class B extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{keys:s,customTypeFilters:n,customTypesFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_item_count`,this.params=d.deundefined({item_keys:s,custom_types:null!=i?i:n})}}class j 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 z extends d.APIRequestCommand{constructor({userId:e}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_channel_count`}}class W extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class $ extends d.APIRequestCommand{constructor({userId:e,filter:t,includeFeedChannel:s=!1}){super();const{channelCustomTypesFilter:n,superChannelFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_message_count`,this.params={super_mode:null!=i?i:exports.SuperChannelFilter.ALL,custom_types:n,include_feed_channel:s}}}class K extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count,this.unreadFeedCount=t.unread_feed_count}}class Q 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:J(t)},s&&(this.params.message_type=s)}}class Y extends d.APIResponseCommand{constructor(e,t){super(e,t),this.count=t.count}}const J=e=>{if(!e)return[];const t=[];return e.forEach((e=>{switch(e){case h.ScheduledStatus.PENDING:t.push(h.InternalScheduledStatus.PENDING);break;case h.ScheduledStatus.SENT:t.push(h.InternalScheduledStatus.IN_QUEUE),t.push(h.InternalScheduledStatus.SENT);break;case h.ScheduledStatus.CANCELED:t.push(h.InternalScheduledStatus.CANCELED);break;case h.ScheduledStatus.FAILED:t.push(h.InternalScheduledStatus.FAILED)}})),t};class X 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:c,isStrict:u,isEphemeral:_,accessCode:p,name:m,data:g,customType:C,messageSurvivalSeconds:E,invitedUserIds:v,operatorUserIds:f}=e;super(),this.method=d.APIRequestMethod.POST,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined({user_ids:[t,...null!=v?v:[]].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:c,strict:u,is_ephemeral:_,access_code:p,name:m,data:g,custom_type:C,operator_ids:f,message_survival_seconds:E})}}class Z extends d.APIResponseCommand{constructor(e,t){var s;super(e,t),this.channel=new vt(e,t),this.isCreated=null===(s=t.is_created)||void 0===s||s}}class ee 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 te 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 se extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class ne extends u.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 p(e,t))):[new p(e,s.data)]}}class ie 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 ae extends u.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 p(this._iid,s.data)}}class re 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 oe extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class le extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s),this.inviter=null;const{member_count:n=0,joined_member_count:i=0,inviter:a,invitees:r=[]}=s.data;this.memberCount=n,this.joinedMemberCount=i,a&&Object.keys(a).length>0&&(this.inviter=new d.User(e,a)),this.invitees=r.map((t=>new p(e,t)))}}class de 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 he extends u.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 p(e,r)}}const ce={hidePreviousMessages:!1,allowAutoUnhide:!0};class ue 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 _e extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}class pe 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 me extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPST",ackRequired:!1,payload:{channel_url:e,time:t}})}}class ge extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class Ce 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 ve extends d.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"MACK",ackRequired:!1,payload:{channel_url:e,msg_id:t}})}}class fe extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,u,_,p,m,g,C,E,v,f,M,y,S,A,b;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.includeChatNotification=!1,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=c.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.includeChatNotification=null!==(a=t.includeChatNotification)&&void 0!==a&&a,this.channelUrlsFilter=null!==(r=t.channelUrlsFilter)&&void 0!==r?r:null,this.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,this.customTypeStartsWithFilter=null!==(l=t.customTypeStartsWithFilter)&&void 0!==l?l:"",this.nicknameContainsFilter=null!==(d=t.nicknameContainsFilter)&&void 0!==d?d:null,this.nicknameStartsWithFilter=null!==(h=t.nicknameStartsWithFilter)&&void 0!==h?h:null,this.nicknameExactMatchFilter=null!==(u=t.nicknameExactMatchFilter)&&void 0!==u?u:null,this.channelNameContainsFilter=null!==(_=t.channelNameContainsFilter)&&void 0!==_?_:"",this.myMemberStateFilter=null!==(p=t.myMemberStateFilter)&&void 0!==p?p:exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=null!==(m=t.unreadChannelFilter)&&void 0!==m?m:exports.UnreadChannelFilter.ALL,this.superChannelFilter=null!==(g=t.superChannelFilter)&&void 0!==g?g:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(C=t.publicChannelFilter)&&void 0!==C?C:exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=null!==(E=t.hiddenChannelFilter)&&void 0!==E?E:exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter=null!==(v=t.searchFilter)&&void 0!==v?v:{fields:[],query:null},this.userIdsFilter=null!==(f=t.userIdsFilter)&&void 0!==f?f:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null!==(M=t.metadataKey)&&void 0!==M?M:null,this.metadataValues=null!==(y=t.metadataValues)&&void 0!==y?y:null,this.metadataOrderKeyFilter=null!==(S=t.metadataOrderKeyFilter)&&void 0!==S?S:null,this.metadataValueStartsWith=null!==(A=t.metadataValueStartsWith)&&void 0!==A?A:null,this.order=null!==(b=t.order)&&void 0!==b?b:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,t.createdAfter&&(this.createdAfter=t.createdAfter),t.createdBefore&&(this.createdBefore=t.createdBefore)}_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(c.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)&&d.isMilliSecondOf(this.createdAfter,!0)&&d.isMilliSecondOf(this.createdBefore,!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=be.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign({},this)),this.limit,d.CollectionEventSource.REQUEST_CHANNEL,!0);return this._token=s,this._hasNext=!!s,this._isLoading=!1,t}return[]}throw d.SendbirdError.invalidParameters}))}}class Me extends d.APIRequestCommand{constructor({channelUrl:e,userId:t}){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 ye extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"DLVR",s),this.channelUrl=s.channel_url,this.deliveredStateUpdate=s.updated}}class Se{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)}}const Ae={};class be extends u.BaseChannelManager{get _messageCache(){return h.MessageCache.of(this._iid)}get _unsentMessageCache(){return h.UnsentMessageCache.of(this._iid)}constructor(e,t){var s;super(e,Object.assign(Object.assign({},t),{channelType:d.ChannelType.GROUP})),this._leftChannels=new Map,this._disableMack=!1,this._markAsReadAllLastSentAt=0,this._disableMack=null!==(s=t.disableMack)&&void 0!==s&&s,this._groupChannelHandlers=new Map,this._groupChannelCache=new C(this._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),this._groupChannelBroadcast=new O({dispatcher:t.dispatcher,groupChannelCache:this._groupChannelCache,messageCache:h.MessageCache.of(this._iid),unsentMessageCache:h.UnsentMessageCache.of(this._iid)}),setInterval((()=>{for(const e of this._groupChannelCache.channels)e.invalidateTypingStatus()&&(this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.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).catch((e=>{if(d.isThrowingOutside(e)&&"foreground"===this._sdkState.appState)throw e})):e instanceof c.AutoResendRequestCommand?(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{message:t}=e,s=yield this.getChannel(t.channelUrl,!0);s.isFrozen||(t instanceof h.UserMessage?s._autoResendUserMessage(t):t instanceof h.FileMessage&&s._autoResendFileMessage(t))}))})():e instanceof c.ReduceDBSizeEventCommand?this.reduceDBSize():e instanceof h.MessageThreadInfoUpdatedEventCommand&&(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{channelUrl:t,channelType:s,parentMessage:n}=e,i=new h.ThreadInfoUpdateEvent(this._iid,{channel_type:d.ChannelType.GROUP,channel_url:t,parent_message_id:n.messageId,thread_info:h.ThreadInfo.payloadify(n.threadInfo)});if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onThreadInfoUpdated&&t.onThreadInfoUpdated(e,i)}))))}}))})()})),Ae[e]||(Ae[e]=this)}static of(e){return Ae[e]||(Ae[e]=new be(e,d.Vault.of(e))),Ae[e]}static clear(e){Ae[e]&&delete Ae[e]}get handlers(){return[...this._groupChannelHandlers.values()]}buildGroupChannelFromSerializedData(e){const t=d.deserialize(e);return new vt(this._iid,vt.payloadify(t))}buildGroupChannelListQueryFromSerializedData(e){const t=d.deserialize(e);return new fe(this._iid,t)}buildMemberFromSerializedData(e){const t=d.deserialize(e);return new p(this._iid,p.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 e=h.MessageCache.of(this._iid),{cacheContext:t}=d.Vault.of(this._iid),{localCacheConfig:s,nestdb:n}=t;if(!t.localCacheEnabled||!n||n.state!=h.NestDBState.OPENED)return;const i=1024*s.maxSize*1024;let a=yield n.estimateUsage();if(ad.__awaiter(this,void 0,void 0,(function*(){const t=new ve(e);this._requestQueue.send(t)}))));const s=this._groupChannelCache.isCachedInMemory(e.channelUrl),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId,r=yield this.getChannel(e.channelUrl,!0),{useMemberInfoInMessage:o}=d.Vault.of(this._iid);if(e instanceof h.SendableMessage){for(const t of r.members)if(t.userId===e.sender.userId){o||(e.sender.nickname=t.nickname,e.sender.plainProfileUrl=t.plainProfileUrl,e.sender.metaData=t.metaData,e.sender.isBlockedByMe=t.isBlockedByMe);break}if(!o&&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._updateLastMessage(e),a||r._shouldUpdateUnreadCountWith(e)&&r._updateUnreadCount(r.unreadMessageCount+1,r.unreadMentionCount+(n?1:0))),i&&r._updateLastMessage(e),this._dispatcher.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_MESSAGE_RECEIVED}})),e.silent&&!a||d.runAsCallback((()=>d.__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.CollectionEventSource.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(u.UpdateAdminMessageEventCommand)),t){const{message:e,mentionCountChange:n}=t;if(e.threadInfo&&(e.threadInfo.unreadReplyCount=void 0),e.channelType===d.ChannelType.GROUP){const t=this._groupChannelCache.isCachedInMemory(e.channelUrl),i=yield this.getChannel(e.channelUrl,!0),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId;let r=!1;if(a){const t=e.sender,{currentUser:s}=this._sessionManager;s&&(s.nickname=t.nickname,s.plainProfileUrl=t.plainProfileUrl,s.metaData=t.metaData)}else i.isReadMessage(e)||0!==n&&!e.silent&&t&&(i._updateUnreadCount(i.unreadMessageCount,i.unreadMentionCount+n),r=!0);i._updateLastMessage(e)?r=!0:(null===(s=i.lastMessage)||void 0===s?void 0:s.isIdentical(e))&&(t?i._updateLastMessage(e)&&(r=!0):r=!0);let o=!1;i.lastPinnedMessage&&i.lastPinnedMessage.messageId===e.messageId&&(i.lastPinnedMessage=e,r=!0,o=!0),r&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:o?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}})),e.silent&&!a||d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)})))),o&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)}))))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageUpdated&&t.onMessageUpdated(i,e),n>0&&t.onMentionReceived&&t.onMentionReceived(i,e)}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:n,silent:i,messageCreatedAt:a,senderId:r}=e.as(d.DeleteMessageEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=r===this._sdkState.userId;i||s||a>0&&e.myLastRead0&&e._updateUnreadCount(e.unreadMessageCount-1,0),this._dispatcher.dispatch(new d.MessageRemoveEventCommand({messageIds:[n],source:d.CollectionEventSource.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(h.ReadEventCommand);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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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 P({channels:[s],context:{source:d.CollectionEventSource.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(ye),n=this._groupChannelCache.isCachedInMemory(t),i=yield this.getChannel(t,!0);n&&Object.keys(s).forEach((e=>{i._updateUndeliveredMemberState(e,s[e])})),Object.keys(s).some((e=>e!==this._sdkState.userId))&&(this._dispatcher.dispatch(new P({channels:[i],context:{source:d.CollectionEventSource.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(u.ReactionEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=yield this.getMessageFromCache(n.messageId);s?s instanceof h.BaseMessage&&(s.applyReactionEvent(n),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new d.ReactionUpdateEventCommand({event:n,source:d.CollectionEventSource.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(u.ThreadInfoUpdateEventCommand);if(t.channelType===d.ChannelType.GROUP){const e=yield this.getChannel(t.channelUrl,!0),s=yield this.getMessageFromCache(t.targetMessageId);s?s instanceof h.BaseMessage&&(s.applyThreadInfoUpdateEvent(t),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new d.ThreadUpdateEventCommand({event:t,source:d.CollectionEventSource.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(u.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 P({channels:s,context:{source:d.CollectionEventSource.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(u.PollUpdateEventCommand);if(n&&i===d.ChannelType.GROUP){const e=yield this.getChannel(n,!0);this._dispatcher.dispatch(new d.PollUpdateInternalEventCommand({event:t,source:d.CollectionEventSource.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.CollectionEventSource.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(u.ChannelEventCommand);if(t.isGroupChannelEvent)switch(t.category){case u.ChannelEventCategory.CHANNEL_JOIN:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,members:a}=e.as(ne);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:a}})),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 u.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(ae);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((e=>e.userId===r.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 P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})):(this._markAsLeave(n),this._dispatcher.dispatch(new R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})))):this._dispatcher.dispatch(new P({channels:[n],context:{source:d.CollectionEventSource.EVENT_CHANNEL_LEFT,user:r}})),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 u.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const s=yield this.getChannel(t.channelUrl,!0),{operators:n}=e.as(u.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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitees:r}=e.as(le);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:a,invitees:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserReceivedInvitation&&e.onUserReceivedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitee:r}=e.as(he);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})):this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}}))):this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:a,invitee:r}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.TYPING_START:case u.ChannelEventCategory.TYPING_END:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.TYPING_START,{user:i}=e.as(n?ge:Ee);s._updateTypingStatus(i,n?t.ts:0),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.USER_CHANNEL_MUTE:case u.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.USER_CHANNEL_MUTE,{user:i}=e.as(n?h.MuteUserEventCommand:h.UnmuteUserEventCommand);i.userId===this._sdkState.userId&&(s.myMutedState=n?d.MutedState.MUTED:d.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 P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_MUTED:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i}})),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 u.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 R({channelUrls:[n.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_BANNED,user:i}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserBanned&&e.onUserBanned(n,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_UNBAN:{const s=yield this.getChannel(t.channelUrl,!0),{user:n}=e.as(h.UnbanUserEventCommand);n.userId===this._sdkState.userId&&this._dispatcher.dispatch(new R({channelUrls:[s.url],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:n}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserUnbanned&&e.onUserUnbanned(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_FREEZE:case u.ChannelEventCategory.CHANNEL_UNFREEZE:{const s=yield this.getChannel(t.channelUrl,!0),{freeze:n}=e.as(h.FreezeEventCommand);s.isFrozen=n,this._dispatcher.dispatch(new P({channels:[s],context:{source:n?d.CollectionEventSource.EVENT_CHANNEL_FROZEN:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_HIDE:{const s=yield this.getChannel(t.channelUrl,!0),{allowAutoUnhide:n,hidePreviousMessages:i,messageOffsetTimestamp:a}=e.as(pe);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 P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onChannelHidden&&e.onChannelHidden(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_UNHIDE:{const e=yield this.getChannel(t.channelUrl,!0);e.hiddenState=exports.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_DELETED:{const e=yield this.getChannel(t.channelUrl,!0);this._dispatcher.dispatch(new R({channelUrls:[t.channelUrl],context:{source:d.CollectionEventSource.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 u.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const e=yield this.getChannelWithoutCache(t.channelUrl,!0);this._dispatcher.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.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),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:n},ts:t.ts}))),i&&(s._upsertCachedMetaData(i,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:i},ts:t.ts}))),a&&(s._removeFromCachedMetaData(a,t.ts),this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:a},ts: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 u.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaCounterEventCommand);n&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:n}})),i&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:i}})),a&&this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:a}})),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 u.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:n,latestPinnedMessage:i,ts:a}=e.as(u.UpdatePinnedMessageEventCommand);a>s._pinnedMessagesUpdatedAt&&(s.pinnedMessageIds=null!=n?n:[],s.lastPinnedMessage=i,s._pinnedMessagesUpdatedAt=a,this._dispatcher.dispatch(new P({channels:[s],context:{source:d.CollectionEventSource.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(c.UserEventCommand);switch(t.category){case c.UserEventCategory.USER_BLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.block(e.userId,s.userId);break}case c.UserEventCategory.USER_UNBLOCK:{const{blocker:e,blockee:s}=c.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()}subscribeChannelEvent(e,t){this._groupChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._groupChannelBroadcast.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 F({channelUrl:e,isInternalCall:t}),n=yield this._requestQueue.send(s),{channel:i}=n.as(D);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=d.CollectionEventSource.REFRESH_CHANNEL,n=!1){return d.__awaiter(this,void 0,void 0,(function*(){try{const i=new F({channelUrl:e,isInternalCall:t,showLatestMessage:n}),a=yield this._requestQueue.send(i),{channel:r}=a.as(D);if(r.myMemberState===exports.MemberState.NONE)this._dispatcher.dispatch(new R({channelUrls:[r.url],context:{source:s}}));else{const e=yield this.upsertChannelsToCache([r]);this._dispatcher.dispatch(new P({channels:e,context:{source:s}}))}}catch(t){t.code!==d.SendbirdErrorCode.NON_AUTHORIZED&&t.code!==d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new R({channelUrls:[e],context:{source:s}}))}}))}getMyGroupChannels(e,t,s,n=d.CollectionEventSource.REQUEST_CHANNEL,i=!1){return d.__awaiter(this,void 0,void 0,(function*(){t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3));let a=!1;if(i){const{appInfo:e,cacheContext:t}=d.Vault.of(this._iid);t&&!t.localCacheEnabled&&(null==e?void 0:e.enabledChannelMemberShipHistory)&&(null==e?void 0:e.applicationAttributes.includes("left_user_view_support"))&&(a=!0)}const r=new H(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:e,limit:s,includeLeftChannel:i&&a})),o=yield this._requestQueue.send(r),{channels:l,token:h}=o.as(V);return this._dispatcher.dispatch(new P({channels:l,context:{source:n}})),{channels:l,token:h}}))}getMyGroupChannelChangeLogs(e,t,s=d.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return d.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},f),t);d.unless((d.isTypeOf("string",e)||d.isTypeOf("number",e))&&M(n)).throw(d.SendbirdError.invalidParameters);const i=new w(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(L),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,ts:h}=a;return r.length>0&&this._dispatcher.dispatch(new P({channels:r,context:{source:s},ts:h})),o.length>0&&this._dispatcher.dispatch(new R({channelUrls:o,context:{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({},y),e);d.unless(S(t)).throw(d.SendbirdError.invalidParameters);const s=new G({userId:this._sdkState.userId,filter:t}),n=yield this._requestQueue.send(s),{groupChannelCount:i}=n.as(q);return i}))}getUnreadItemCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},b),e);d.unless((e=>d.isArrayOf(exports.UnreadItemKey,e.keys)&&d.isArrayOf("string",e.customTypeFilters,!0)&&d.isArrayOf("string",e.customTypesFilter,!0))(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),{groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m}=a.as(j);return d.deundefined({groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,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 z({userId:e.userId}),n=yield t.send(s),{unreadCount:i}=n.as(W);return i}))}getTotalUnreadMessageCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},N),e);d.unless(T(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new $({userId:s.userId,filter:t}),a=yield n.send(i),{unreadCount:r}=a.as(K);return r}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},U),e);d.unless((e=>d.isTypeOf("string",e.channelUrl,!0)&&d.isArrayOf(h.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 Q(t),i=yield s.send(n),{count:a}=i.as(Y);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);return Object.keys(t.customTypes).forEach((s=>{e+=t.customTypes[s]})),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(v(t)).throw(d.SendbirdError.invalidParameters),t.isPublic||(t.accessCode=void 0);const s=new X(Object.assign({userId:this._sdkState.userId},t)),n=yield this._requestQueue.send(s),{channel:i}=n.as(Z);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 ee({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 ee({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()}))}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){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})}))}getCachedMessageCountBetween(e,t,s,n){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.countBetween(e,t,new Se({top:s,bottom:n}))}))}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])}))}}const Ne=(e,t)=>t instanceof h.SendableMessage?e.findIndex((e=>e instanceof h.SendableMessage&&t.isIdentical(e))):e.findIndex((e=>e.isIdentical(t))),Te=(e,t)=>e.findIndex((e=>e instanceof h.BaseMessage?e.messageId===t:e instanceof h.NotificationMessage?e.notificationId===t:void 0)),Ue=(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};var Ie;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Ie||(Ie={}));class xe extends d.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=Ie.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===Ie.IDLE}get isRunning(){return this._state===Ie.RUNNING}get isDone(){return this._state===Ie.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 xe(_,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u,_;const p={hasNext:!0,nextToken:0};if(this._prevSyncLoopCount++,yield this.loadMetadata(),r.debug("message background prev sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.top),null===(n=this._metadata)||void 0===n?void 0:n.previousComplete)p.hasNext=!1;else try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(l=null===(a=this._metadata)||void 0===a?void 0:a.range)||void 0===l?void 0:l.top)?this._metadata.range.top:e,{prevResultSize:this._limit,nextResultSize:0,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(c=this._metadata)||void 0===c?void 0:c.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}p.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(p.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.lengthd.__awaiter(this,void 0,void 0,(function*(){return yield l.run(`message-background-sync-${t.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u;const _={hasNext:!0,nextToken:0};yield this.loadMetadata(),r.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom);try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(a=null===(n=this._metadata)||void 0===n?void 0:n.range)||void 0===a?void 0:a.bottom)?this._metadata.range.bottom:e,{prevResultSize:0,nextResultSize:this._limit,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0,isInclusive:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(l=this._metadata)||void 0===l?void 0:l.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Se({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}_.hasNext=s.length>=this._limit,this._metadata&&(_.nextToken=this._metadata.range.bottom),r.debug("message background next sync progress",_),yield this.saveMetadata()}catch(e){throw r.debug("message background next sync error",e),e}finally{o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:t.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(u=null===(c=i.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==u?u:0,use_local_cache:i.localCacheEnabled,starting_point:0,message_init_policy:""}}))}return _}))))})))),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){return Pe[e]||(Pe[e]={}),Pe[e][t.url]||(Pe[e][t.url]=new Re({_iid:e,channel:t})),Pe[e][t.url].ref++,Pe[e][t.url]}static clear(e,t){Pe[e]&&Pe[e][t]&&(Pe[e][t].close(),delete Pe[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 Se({})}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(){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?{range:new Se(t.range),previousComplete:t.previousComplete}:{range:new Se({}),previousComplete:!1}}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(e=Date.now()){var t,s,n,i;const{logger:a,sessionManager:r,cacheContext:o}=d.Vault.of(this._iid);o.localCacheEnabled&&r.session.hasSession&&(a.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(s=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==s?s:e),this._nextSync.start(null!==(i=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==i?i:e))}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid][this._channel.url])}}const Oe={};class we{constructor({_iid:e,channel:t,includeParams:s}){this.ref=0,this._iid=e,this._channel=t,this._includeParams=s;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}/message/changelogs.meta`);const l=((e,t)=>`sendbird:${e}@groupchannel/${t}/message/changelogs`)(i.userId,this._channel.url);this._sync=new xe(l,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};yield this.loadMetadata(),n.debug("message changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=h.MessageManager.of(this._iid),{updatedMessages:s,deletedMessageIds:i,hasMore:a,token:r}=yield e.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:d.ReplyType.ALL},this._includeParams),d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);t.hasNext=a,t.nextToken=r,(s.length>0||i.length>0)&&this._metadata&&(this._metadata.token=r),n.debug("message changelog sync progress",t),yield this.saveMetadata()}catch(e){throw n.debug("message 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 Oe[e]||(Oe[e]={}),Oe[e][t.url]||(Oe[e][t.url]=new we({_iid:e,channel:t,includeParams:s})),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])}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,sessionManager:t}=d.Vault.of(this._iid);t.session.hasSession&&(e.debug("message changelog sync resume()"),this._sync.start(0))}pause(){const{logger:e}=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 Oe[this._iid][this._channel.url])}}const Le={};class Fe{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 xe(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=d.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 Le[e]||(Le[e]={}),Le[e][t.url]||(Le[e][t.url]=new Fe({_iid:e,channel:t,hasPollMessage:s})),Le[e][t.url].ref++,Le[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 Le[this._iid][this._channel.url])}}class De extends d.APIRequestCommand{constructor(e){var t,s,n,i,a,r,o,l,h,c;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_reply_type:null!==(i=e.replyType)&&void 0!==i?i:d.ReplyType.NONE,include_reactions:null===(a=e.includeReactions)||void 0===a||a,include_meta_array:null===(r=e.includeMetaArray)||void 0===r||r,include_thread_info:null===(o=e.includeThreadInfo)||void 0===o||o,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(c=e.showSubchannelMessagesOnly)&&void 0!==c&&c,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=>h.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=>h.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 He={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};exports.MessageCollectionInitPolicy=void 0,(exports.MessageCollectionInitPolicy||(exports.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";class Ve{constructor(){this._onCacheResult=d.noop,this._onApiResult=d.noop}_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 Ge{keyOf(e){return 0}get changelogIncludeParams(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}_postprocessChannelUpdateEvent(e,t){}_postprocessChannelRemoveEvent(e){}_postprocessMessageUpdateEvent(e,t){}_postprocessMessageRemoveEvent(e){}constructor(e,{filter:t,startingPoint:s,limit:n,prevResultLimit:i,nextResultLimit:a,channel:r,channelManager:o,disableBackgroundSync:l=!1}){this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key=`mc-${d.uuid()}`,this._isDisposed=!1,this.filter=null!=t?t:new h.MessageFilter,this._channel=r,this._syncRange=new Se({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=n||h.DEFAULT_MESSAGE_LIMIT,this._prevResultLimit=null!=i?i:Math.floor(this._limit/2),this._nextResultLimit=null!=a?a:Math.floor(this._limit/2),this._channelManager=o;const{statManager:c}=d.Vault.of(this._iid);this._channelManager.subscribeChannelEvent(this._key,{onUpdate:(e,t)=>{const{source:s}=t,n=e.findIndex((e=>e.isIdentical(this.channel)));n>=0&&(this._replaceChannelOfCollection(e[n]),this.channel._runIfHandleableWithGroupChannel((e=>{switch(s){case d.CollectionEventSource.EVENT_CHANNEL_UPDATED:{let t=!1;for(let s=0;s=e.messageOffsetTimestamp){t=!0;const e=s;if(e>0){const t=this._messages.splice(0,e);this._removeMessagesFromView(t.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!t&&this._messages.length>0&&this._removeMessagesFromView(this._messages.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break}case d.CollectionEventSource.EVENT_CHANNEL_UNMUTED:{const{sdkState:e}=d.Vault.of(this._iid),{user:s}=t;e.userId===s.userId&&this._clearCheckMyMutedTimer();break}case d.CollectionEventSource.EVENT_CHANNEL_MUTED:{const{sdkState:s}=d.Vault.of(this._iid),{user:n}=t;s.userId===n.userId&&-1!==e._myMutedRemainingTime&&this._startCheckMyMutedTimer(e._myMutedRemainingTime);break}case d.CollectionEventSource.EVENT_CHANNEL_LEFT:e.isPublic&&this._clearCheckMyMutedTimer()}d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;x(s)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel)}))))})),this._postprocessChannelUpdateEvent(e[n],s))},onRemove:(e,t)=>{const s=e.indexOf(this.channel.url);s>=0&&(this._clearCheckMyMutedTimer(),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url)})))),this._postprocessChannelRemoveEvent(e[s]))}}),this._channelManager.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(this.keyOf(t)));if(d.shouldGiveEvent(t)){if(s.length>0)switch(t){case d.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case d.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case d.CollectionEventSource.EVENT_MESSAGE_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:this._updateMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:this._addMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_RECEIVED:this.hasNext||this._addMessagesToView(s,t);break;case d.CollectionEventSource.SYNC_MESSAGE_FILL:this._addMessagesToView(s,t)}n.length>0&&this._removeMessagesFromView(n,t)}this._postprocessMessageUpdateEvent(e,t)},onRemove:(e,t)=>{this._removeMessagesFromView(e,t),this._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:(e,t)=>{this._applyReactionEventToView(e,t)},onThreadInfoUpdate:(e,t)=>{this._applyThreadInfoEventToView(e,t)}});const{cacheContext:u,dispatcher:_,messageBackgroundSyncThrottleController:p}=d.Vault.of(this._iid);this._channel._updateMessageCollectionLastAccessedAt(),_.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Re.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=we.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Fe.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new xe(this._key,(e=>d.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-prev`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.min(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:i.length>=this._prevResultLimit&&this.viewTopd.__awaiter(this,void 0,void 0,(function*(){return yield p.run(`message-fill-sync-${r.url}-next`,(()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled});if(i.length>0){const e=Math.max(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:!(i.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>e,nextToken:this._syncRange.bottom}}return u.localCacheEnabled&&c.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(s=u.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==n?n:0,use_local_cache:u.localCacheEnabled,starting_point:0,message_init_policy:""}})),{hasNext:!1,nextToken:0}}))))})))),this._connectionEventContext=_.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)switch(e.stateType){case d.ConnectionStateType.CONNECTED:d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){this._activate()}))));break;case d.ConnectionStateType.LOGOUT:this.dispose();break;default:this._clearCheckMyMutedTimer(),this._prevFill.stop(),this._nextFill.stop()}}))}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)}_activate(){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:e}=d.Vault.of(this._iid);e.debug("check huge gap"),this._checkHugeGap(),yield this._refreshChannel(d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS)}))}_replaceChannelOfCollection(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}_shouldStartBackgroundSync(){const{cacheContext:e}=d.Vault.of(this._iid);return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}_setBaseMessageCollectionHandler(e){this._handler=e}_filterUnderOffsetMessage(e){return e}_updateChildMessagesInView(e){const t=[];return this._messages.forEach((s=>{s instanceof h.BaseMessage&&s.parentMessageId===e.messageId&&s.applyParentMessage(e)&&t.push(s)})),t}_updatePollsToView(e,t){const s=[];for(const t of e){const e=Te(this._messages,t.messageId);if(e>=0){const n=this._messages[e];n.isUserMessage()&&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,n;const i={source:t};s.length>0&&(null===(n=(e=this._handler).onMessagesUpdated)||void 0===n||n.call(e,i,this.channel,s))})))),s}_applyPollUpdateEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyPollVoteEventToView(e,t){const s=Te(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,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyReactionEventToView(e,t){const s=Te(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyReactionEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_applyThreadInfoEventToView(e,t){const s=Te(this._messages,e.targetMessageId);if(s>=0){const n=this._messages[s];n&&(n.isUserMessage()||n.isFileMessage()||n.isMultipleFilesMessage())&&d.shouldGiveEvent(t)&&(n.applyThreadInfoUpdateEvent(e),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i={source:t};null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])})))))}}_removeMessagesFromView(e,t){const s=[],n=[];for(const t of e){const e=this._messages.findIndex((e=>this.keyOf(e)===t));if(e>=0){const t=this._messages[e];s.push(this.keyOf(t)),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,i;const a={source:t};null===(i=null===(e=this._handler)||void 0===e?void 0:e.onMessagesDeleted)||void 0===i||i.call(e,a,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*(){let i=[];n&&(i=yield this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter));const a=t>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,t,!1):[],r=s>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1):[];return{messages:[...i,...a,...r].sort(((e,t)=>t.createdAt-e.createdAt)),prevMessagesCount:a.length,nextMessagesCount:r.length}}))}_getRemoteMessages(e,{prevLimit:t=0,nextLimit:s=0,source:n=d.CollectionEventSource.REQUEST_MESSAGE,reverse:i=!1,checkingHasNext:a=!1,checkingContinuousMessages:r=!1}){return d.__awaiter(this,void 0,void 0,(function*(){const o=h.MessageManager.of(this._iid);return t>0||s>0?yield o._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,d.undefineNullProps(Object.assign(Object.assign(Object.assign({},this.filter),He),{isInclusive:!0,reverse:i,prevResultSize:t,nextResultSize:s})),n,a,r):{messages:[],isContinuousMessages:!1}}))}_checkHugeGap(){var e,t,s,n,i;return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r,cacheContext:o,statManager:l,logger:h}=d.Vault.of(this._iid);if(this._messages.length>0){const s=this._syncRange.top,n=this.viewTop,i=this._syncRange.bottom,c=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,n,s),_=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,i,c);try{yield d.asyncRetry((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t=new De(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:s,prevCount:u,nextStart:i,nextEnd:c,nextCount:_,checkingContinuousMessages:o.localCacheEnabled},this.filter),He)),l=yield r.send(t),{isHugeGap:h,prevMessages:p=[],prevHasMore:m,isContinuousPrevMessages:g,nextMessages:C=[],nextHasmore:E,isContinuousNextMessages:v}=l.as(ke);if(h)d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected()}))));else{const t=this.viewTop,s=this.viewBottom,n=Math.min(Number.MAX_SAFE_INTEGER,t,...p.map((e=>e.createdAt))),i=Math.max(0,s,...C.map((e=>e.createdAt)));a.dispatch(new d.MessageUpdateEventCommand({messages:p,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),a.dispatch(new d.MessageUpdateEventCommand({messages:C,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(n,i),(g||v)&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(n,i)),m&&this._prevFill.start(n),E&&this._nextFill.start(i)}}))),1)}catch(e){h.debug("Failed HugeGap Check ",e)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}else{const e=Date.now();try{const{messages:t,isContinuousMessages:n,hasNext:i}=yield this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:o.localCacheEnabled});if(t.length>0){const a=t.map((e=>e.createdAt));let r=0,o=0;for(let t=0;t=e&&o++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=i?i:o>=this._nextResultLimit,this._syncRange.extends(...a),n&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(t,d.CollectionEventSource.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)}finally{o.localCacheEnabled&&l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(n=o.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==i?i:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}}))}_loadUnsentMessages(){return d.__awaiter(this,void 0,void 0,(function*(){this._unsentMessages=yield this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)}))}_hasPollMessage(){return d.__awaiter(this,void 0,void 0,(function*(){return(yield this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)).length>0}))}_refreshChannel(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:s}=d.Vault.of(this._iid);try{yield this._channelManager.refreshChannel(this.channel.url,!0,e,t)}catch(e){s.warn("Failed to refresh channel",e)}}))}_startCheckMyMutedTimer(e){this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((()=>d.__awaiter(this,void 0,void 0,(function*(){this._checkMyMutedStateTimer=void 0;let e=!0;try{e=!(yield this._channel.getMyMutedInfo()).isMuted}catch(t){e=!0}finally{if(e){const{sessionManager:e}=d.Vault.of(this._iid);this.channel._runIfHandleableWithGroupChannel((t=>{var s,n;t.myMutedState=d.MutedState.UNMUTED;const i={source:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:e.currentUser};null===(n=null===(s=this._handler)||void 0===s?void 0:s.onChannelUpdated)||void 0===n||n.call(s,i,this.channel)}))}}}))),e+1e3)}_clearCheckMyMutedTimer(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}_setHasNextAndHasPrevious(e,t){const s=e.map((e=>e.createdAt));let n=0,i=0;for(let e=0;ethis._startingPoint&&i++}this._hasPrevious=n>=this._prevResultLimit,this._hasNext=null!=t?t:i>=this._nextResultLimit}initialize(e){const t=new Ve;this._messages=[],this._unsentMessages=[],this._syncRange=new Se({}),this._hasNext=!0,this._hasPrevious=!0;let s=[],n={messages:[],prevMessagesCount:0,nextMessagesCount:0};return d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var i;const a=yield null===(i=this._backgroundSync)||void 0===i?void 0:i.loadMetadata(),{cacheContext:r,statManager:o}=d.Vault.of(this._iid);if(e===exports.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((e=>d.__awaiter(this,void 0,void 0,(function*(){n=e,s=this._filterUnderOffsetMessage(n.messages),this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE),yield this._loadUnsentMessages(),t._invokeResponse("local",null,s)})))).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("local",e,null)})).finally((()=>d.__awaiter(this,void 0,void 0,(function*(){var i,r;const{cacheContext:l}=d.Vault.of(this._iid);let h=!0,c=!0,u=!1;l.localCacheEnabled&&s.length>0&&a.range.includes(...s.map((e=>e.createdAt)))&&(!a.previousComplete&&n.prevMessagesCounta.range.bottom||n.nextMessagesCount{const t=Math.max(...s.map((e=>e.createdAt)));e._latestMessageInfo&&t>=e._latestMessageInfo.createdAt&&(c=!1)})),c?(h=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled}).then((({messages:e,isContinuousMessages:s,hasNext:n})=>{var i,a;const r=this._filterUnderOffsetMessage(e);this._messages=[],r.length>0?(this._setHasNextAndHasPrevious(r,n),this._syncRange.extends(...r.map((e=>e.createdAt))),s&&(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(r,d.CollectionEventSource.REQUEST_MESSAGE)):(this._hasPrevious=!1,this._hasNext=!1),t._invokeResponse("remote",null,r)})).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(s),t._invokeResponse("remote",null,s)),l.localCacheEnabled&&o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:h?"cache_hit":"cache_miss",max_db_size:null!==(r=null===(i=l.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==r?r:0,message_init_policy:e,use_local_cache:l.localCacheEnabled,collection_id:this._key}}))}))));o.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}}))})))),t}loadPrevious(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasPrevious)return[];if(this._isLoadingPrevious)return a.warn("Messages are already fetching."),[];this._isLoadingPrevious=!0;const r=this.viewTop;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{prevLimit:this._prevResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._prevResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasPrevious=o.length>=this._prevResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a;const{cacheContext:l}=d.Vault.of(this._iid),h=yield this._getRemoteMessages(r,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:l.localCacheEnabled});o=this._filterUnderOffsetMessage(h.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasPrevious=o.length>=this._prevResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(n=l.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==a?a:0,use_local_cache:l.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingPrevious=!1,o}))}loadNext(){var e,t,s;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{cacheContext:n,statManager:i,logger:a}=d.Vault.of(this._iid);if(!this._hasNext)return[];if(this._isLoadingNext)return a.warn("Messages are already fetching."),[];this._isLoadingNext=!0;const r=this.viewBottom;let o=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getLocalMessages(r,{nextLimit:this._nextResultLimit,inclusive:!1});o=this._filterUnderOffsetMessage(e.messages)}))));const l=o.length>=this._nextResultLimit;if(n.localCacheEnabled&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:l?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=n.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:n.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(o)))this._hasNext=o.length>=this._nextResultLimit,o.length>0&&this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE);else{let e=!1;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,a,l;const{cacheContext:h}=d.Vault.of(this._iid),c=yield this._getRemoteMessages(r,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled});o=this._filterUnderOffsetMessage(c.messages),o.length>0&&(this._syncRange.extends(...o.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&c.isContinuousMessages&&(e=!0,null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.bottom))),o=o.filter((e=>Ne(this._messages,e)<0)),this._hasNext=null!==(n=c.hasNext)&&void 0!==n?n:o.length>=this._nextResultLimit,e&&i.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(l=null===(a=h.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==l?l:0,use_local_cache:h.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(o,d.CollectionEventSource.REQUEST_MESSAGE)}return this._isLoadingNext=!1,o}))}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."});yield this._channelManager.removeFailedMessageFromCache(e);const t=this._unsentMessages.findIndex((t=>t.reqId===e));t>-1&&this._unsentMessages.splice(t,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._runIfHandleableWithGroupChannel((e=>{e.myMemberState!==exports.MemberState.NONE&&(this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new P({channels:[this._channel],context:{source:d.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}class qe extends Ge{keyOf(e){return e.messageId}constructor(e,t){super(e,Object.assign(Object.assign({},t),{channelManager:be.of(e)}))}initialize(e){return 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)})))),super.initialize(e)}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_activate(){const e=Object.create(null,{_activate:{get:()=>super._activate}});return d.__awaiter(this,void 0,void 0,(function*(){yield e._activate.call(this),yield 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)}))))}))}_addMessagesToView(e,t){const s=this._filterUnderOffsetMessage(e),n=[],i=[];for(const e of s)if(t===d.CollectionEventSource.SYNC_MESSAGE_FILL){if(e.messageId>0){if(Ne(this._messages,e)<0){Ne(this._unsentMessages,e)<0&&n.push(e);const t=Ue(this._messages,e);this._messages.splice(t,0,e)}}else if(e instanceof h.SendableMessage){Ne(this._unsentMessages,e)<0&&Ne(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e))}}else if(e.messageId>0){const t=Ne(this._messages,e);if(t<0){const t=Ne(this._unsentMessages,e);t<0?n.push(e):(this._unsentMessages.splice(t,1),i.push(e));const s=Ue(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 h.SendableMessage){const t=Ne(this._unsentMessages,e);t<0?Ne(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,a,r;const o={source:t};n.length>0&&(null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===s||s.call(e,o,this.channel,n)),i.length>0&&(null===(r=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===r||r.call(a,o,this.channel,i))}))))}_updateMessagesToView(e,t){const s=[],n=[],i=[];for(const t of e)if(t.messageId>0){const e=Ne(this._messages,t);if(e>=0)n.push(t),this._messages[e]=t;else{const e=Ne(this._unsentMessages,t);if(e>=0){const[s]=this._unsentMessages.splice(e,1);if(this.hasNext&&s)i.push(s);else{n.push(t);const e=Ue(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 h.SendableMessage){const e=Ne(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,r,o;const l={source:t};n.length>0?null===(a=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===a||a.call(e,l,this.channel,n):i.length>0?null===(o=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===o||o.call(r,l,this.channel,[],i):s.length>0&&this._addMessagesToView(s,t)})))),n}}const Be={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 je 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 ze 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 p(e,t))))}}var We,$e,Ke;exports.MutedMemberFilter=void 0,(We=exports.MutedMemberFilter||(exports.MutedMemberFilter={})).ALL="all",We.MUTED="muted",We.UNMUTED="unmuted",exports.MemberListOrder=void 0,($e=exports.MemberListOrder||(exports.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",$e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",exports.MemberStateFilter=void 0,(Ke=exports.MemberStateFilter||(exports.MemberStateFilter={})).ALL="all",Ke.JOINED="joined_only",Ke.INVITED="invited_only",Ke.INVITED_BY_FRIEND="invited_by_friend",Ke.INVITED_BY_NON_FRIEND="invited_by_non_friend";class Qe 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 je(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{members:n,token:i}=s.as(ze);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class Ye 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 Je extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t),this.channel.myMemberState=exports.MemberState.JOINED}}class Xe 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:c,operatorUserIds:u,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:c,cover_url:a,cover_file:r,access_code:o,operator_ids:u,message_survival_seconds:_})}}class Ze extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new vt(e,t)}}class et 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 tt 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 st 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 nt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.countPreference=t.count_preference}}class it extends d.APIRequestCommand{constructor(e){const{channelUrl:t,locale:s}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/reset_user_history`,this.params=d.deundefined({locale:s})}}class at extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}const rt=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}),ot=Object.assign(Object.assign({},h.UserMessageUpdateParamsDefault),{scheduledAt:void 0});class lt extends d.APIRequestCommand{constructor(e){var t,s;super();let n=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((e=>e.userId))));const{channelType:i,channelUrl:a,scheduledMessageId:r}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(i)}/${encodeURIComponent(a)}/scheduled_messages/${encodeURIComponent(r)}`,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:null===(t=e._thumbnails)||void 0===t?void 0:t.map((e=>h.Thumbnail.payloadify(e))),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:n,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}))}}class dt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.message=new h.FileMessage(e,t)}}class ht 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=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class ct 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 ut 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 _t 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 pt 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({userId:e,channelUrl:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`}}class gt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}var Ct,Et;exports.CountPreference=void 0,(Ct=exports.CountPreference||(exports.CountPreference={})).ALL="all",Ct.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Ct.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Ct.OFF="off",exports.HiddenState=void 0,(Et=exports.HiddenState||(exports.HiddenState={})).UNHIDDEN="unhidden",Et.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Et.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";class vt extends h.BaseChannel{constructor(e,t){var s,n,i,a,r,o,l,c,u,_,m,g,C,E,v,f,M,y,S;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._hasBotInfo={general:!1,ai:!1},this.isDistinct=!1,this.isSuper=!1,this.isBroadcast=!1,this.isExclusive=!1,this.isPublic=!1,this.isDiscoverable=!0,this.isChatNotification=!1,this.isAccessCodeRequired=!1,this.isPushEnabled=!1,this.unreadMessageCount=0,this.unreadMentionCount=0,this.totalUnreadReplyCount=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=d.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.lastPinnedMessage=null,this._latestMessageInfo=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.isChatNotification=null!==(l=t.is_chat_notification)&&void 0!==l&&l,this.isAccessCodeRequired=null!==(c=t.is_access_code_required)&&void 0!==c&&c,this.isPushEnabled=null!==(u=t.is_push_enabled)&&void 0!==u&&u,Array.isArray(t.members)&&this.members.push(...t.members.map((e=>new p(this._iid,e)))),this.memberCount=null!==(_=t.member_count)&&void 0!==_?_:0,this.joinedMemberCount=null!==(m=t.joined_member_count)&&void 0!==m?m:0,this.hiddenState=d.isEnumOf(exports.HiddenState,t.hidden_state)?t.hidden_state:exports.HiddenState.UNHIDDEN,this.messageOffsetTimestamp=null!==(g=t.ts_message_offset)&&void 0!==g?g:0,this.messageSurvivalSeconds=null!==(C=t.message_survival_seconds)&&void 0!==C?C:-1,this.lastMessage=t.last_message?h.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(d.MutedState,t.is_muted)?this.myMutedState=t.is_muted:d.isTypeOf("boolean",t.is_muted)?this.myMutedState=t.is_muted?d.MutedState.MUTED:d.MutedState.UNMUTED:this.myMutedState=d.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!==(E=t.user_last_read)&&void 0!==E?E: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!==(f=t.joined_ts)&&void 0!==f?f:0,this._updateUnreadCount(null!==(M=t.unread_message_count)&&void 0!==M?M:0,null!==(y=t.unread_mention_count)&&void 0!==y?y:0),this.totalUnreadReplyCount=null!==(S=t.total_unread_thread_message_count)&&void 0!==S?S:0,this.lastPinnedMessage=t.latest_pinned_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.latest_pinned_message)):null,t.latest_message&&(this._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),this._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot}}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}get hasBot(){return this._hasBotInfo.general}get hasAiBot(){return this._hasBotInfo.ai}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,total_unread_thread_message_count:e.totalUnreadReplyCount,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=>p.payloadify(e))),last_message:e.lastMessage?h.payloadifyMessage(e.lastMessage):null,inviter:e.inviter?d.User.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?h.payloadifyMessage(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))}_shouldUpdateLastMessageWith(e){if(e.silent)return!1;const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.lastMessageThreadingPolicy){case d.LastMessageThreadingPolicy.NONE:case d.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case d.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt{t.onChannelChanged&&t.onChannelChanged(e)})),s.dispatch(new P({channels:[e],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}}))}_shouldUpdateUnreadCountWith(e){const{appInfo:t}=d.Vault.of(this._iid);switch(null==t?void 0:t.unreadCountThreadingPolicy){case d.UnreadCountThreadingPolicy.NONE:case d.UnreadCountThreadingPolicy.INCLUDE_REPLY:break;case d.UnreadCountThreadingPolicy.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case d.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}_updateLastMessage(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}_updateUnreadCount(e,t){if("number"==typeof e&&e>=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,Object.assign(e,this._serializeCachedMetaData())}))}createMessageCollection(e={}){return new qe(this._iid,Object.assign(Object.assign({},e),{channel:this}))}createMemberListQuery(e={}){return new Qe(this._iid,this.url,e)}createThreadedParentMessageListQuery(e={}){return new _.ThreadedParentMessageListQuery(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 p?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 h.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 h.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 h.ReadStatus(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.payloadify(n),ts:null!=e?e:0})}})),s}getDeliveryStatus(e=!0){const{sdkState:t}=d.Vault.of(this._iid);if(!t.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;const s={};return this.members.forEach((n=>{if(e||n.userId!==t.userId){const e=this._undeliveredMemberStateMap.get(n.userId);s[n.userId]=new m(this._iid,{channel_url:this.url,channel_type:this.channelType,user:p.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*(){return this._refresh()}))}_refresh(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t,dispatcher:s}=d.Vault.of(this._iid),n=new F({channelUrl:this.url}),i=yield t.send(n),{channel:a}=i.as(D);return this._update(a),e||s.dispatch(new P({channels:[a],context:{source:d.CollectionEventSource.REFRESH_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 P({channels:[this],context:{source:d.CollectionEventSource.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 P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}))}))}updateChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},Be),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 Xe(Object.assign({channelUrl:this.url},t)),a=yield n.send(i),{channel:r}=a.as(Ze);return this._update(r),s.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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,sessionManager:n}=d.Vault.of(this._iid),i=new re({channelUrl:this.url,userIds:e}),a=yield s.send(i),{channel:r}=a.as(oe);return this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:n.currentUser,invitees:[]},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 te({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(se);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},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 ie({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 Ye({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(Je);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],context:{source:d.CollectionEventSource.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 de({channelUrl:this.url,userId:e.userId});return yield t.send(s),this.myMemberState=exports.MemberState.NONE,this}))}sendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=>{n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_MESSAGE_SENT}})),t._trigger(e)})),t}sendMultipleFilesMessage(e){const t=new h.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=be.of(this._iid);this._updateLastMessage(e),n.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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=this._updateLastMessage(i),r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],context:{source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))}if(r){be.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.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=be.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._updateLastMessage(e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 h.SendableMessage){const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new d.UnsentMessageRemoveEventCommand({reqId:e.reqId,source:d.CollectionEventSource.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 ue(Object.assign({channelUrl:this.url,userId:n.userId},t)),r=yield i.send(a),{messageOffsetTimestamp:o}=r.as(_e);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 P({channels:[this],context:{source:d.CollectionEventSource.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 tt({channelUrl:this.url});return yield t.send(s),this.hiddenState=exports.HiddenState.UNHIDDEN,e.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 et({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 h.ReadRequestCommand({channelUrl:this.url}),i=yield s.send(n),{readStatus:a}=i.as(h.ReadEventCommand);if(this._updateUnreadMemberState(e.userId,a.readAt),this.unreadMessageCount>0||this.unreadMentionCount>0){this._updateUnreadCount(0,0);be.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 Me({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 me({channelUrl:this.url,time:this._typingStarted});yield 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 Ce({channelUrl:this.url,time:this._typingStarted});yield e.send(t)}}))}createScheduledUserMessage(e){e=Object.assign(Object.assign({},h.ScheduledUserMessageCreateParamsDefault),e),d.unless(h.validateScheduledUserMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=new h.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({},ot),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 ht(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({},h.ScheduledFileMessageCreateParamsDefault),e),d.unless(h.validateScheduledFileMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=Date.now(),s=this._generateRequestId(),n=new h.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({},rt),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 lt(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(dt);return r}))}cancelScheduledMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new ct({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 ut({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 mt({userId:e.userId,channelUrl:this.url}),n=yield t.send(s),{pushTriggerOption:i}=n.as(gt);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 _t({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),a=yield n.send(i),{pushTriggerOption:r}=a.as(pt);return this.myPushTriggerOption=r,t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.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 st({channelUrl:this.url,userId:s.userId,countPreference:e}),a=yield n.send(i),{countPreference:r}=a.as(nt);return this.myCountPreference=r,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),t.dispatch(new P({channels:[this],context:{source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),r}))}resetMyHistory(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t,sdkState:s}=d.Vault.of(this._iid),n=new it({channelUrl:this.url,locale:s.localeForChatbot}),i=yield t.send(n),{messageOffsetTimestamp:a}=i.as(at);return this.messageOffsetTimestamp=a,this.lastMessage&&this.lastMessage.createdAt{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),n._trigger(e)})),n}if(e.isFileMessage()){const s=this._validateFailedFileMessageHasFile(e,t);d.unless(s).throw(d.SendbirdError.invalidParameters);const n=h.createFileMessageCreateParamsFromFailedFileMessage(e,t),i=new h.MessageRequestHandler;return this._sendFileMessage(n,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{i._trigger(e)})).onFailed(((e,t)=>{i._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),i._trigger(e)})),i}if(e.isMultipleFilesMessage()){const t=e.messageParams,s=new h.MultipleFilesMessageRequestHandler;return this._sendMultipleFilesMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{s._trigger(e)})).onFailed(((e,t)=>{s._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),s._trigger(e)})).onFileUploaded(((e,t,n,i)=>{s._triggerOnFileUploaded(e,t,n,i)})),s}}copyMessage(e,t){if(d.unless(e instanceof h.BaseChannel&&t instanceof h.SendableMessage&&t.sendingStatus===d.SendingStatus.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(d.SendbirdError.invalidParameters),t.isUserMessage()){d.unless(!t.poll).throw(d.SendbirdError.notSupportedError);const s=h.createUserMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendUserMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isFileMessage()){const s=h.createFileMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendFileMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isMultipleFilesMessage()){if(e.isGroupChannel()){const s=h.createMultipleFilesMessageCreateParams(t),n=new h.MultipleFilesMessageRequestHandler;return e._sendMultipleFilesMessage(s,h.SendMessageRequestType.COPY).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})).onFileUploaded(((e,t,s,i)=>{n._triggerOnFileUploaded(e,t,s,i)})),n}throw d.SendbirdError.channelTypeNotSupportedError}}}exports.BaseMessageCollection=Ge,exports.DeliveryStatus=m,exports.GetTotalUnreadMessageCountRequestCommand=$,exports.GetTotalUnreadMessageCountResponseCommand=K,exports.GroupChannel=vt,exports.GroupChannelChangeLogsParamsDefault=f,exports.GroupChannelCountParamsDefault=y,exports.GroupChannelCreateParamsDefault=E,exports.GroupChannelEventSource=I,exports.GroupChannelFilter=g,exports.GroupChannelListQuery=fe,exports.GroupChannelManager=be,exports.Member=p,exports.MemberListQuery=Qe,exports.MessageCollection=qe,exports.MessageCollectionInitHandler=Ve,exports.Sync=xe,exports.TimeRange=Se,exports.TotalUnreadMessageCountParamsDefault=N,exports.indexOfMessage=Ne,exports.placeOfMessage=Ue,exports.shouldGiveEvent=x,exports.validateGroupChannelChangeLogsParams=M,exports.validateGroupChannelCountParams=S,exports.validateGroupChannelCreateParams=v,exports.validateTotalUnreadMessageCountParams=T; diff --git a/cjs/lib/__bundle-4bcf4070.cjs b/cjs/lib/__bundle-ccb8334d.cjs similarity index 99% rename from cjs/lib/__bundle-4bcf4070.cjs rename to cjs/lib/__bundle-ccb8334d.cjs index fc7ad26..5d9a01b 100644 --- a/cjs/lib/__bundle-4bcf4070.cjs +++ b/cjs/lib/__bundle-ccb8334d.cjs @@ -1 +1 @@ -var e,t=require("./__bundle-0486c467.cjs");class s{constructor(e,t,s){var i,n;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(i=t.real_width)&&void 0!==i?i:t.width,this.realHeight=null!==(n=t.real_height)&&void 0!==n?n:t.height,this._requireAuth=s}static payloadify(e){return e instanceof s?t.deundefined(t.undefineNullProps({url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight})):t.deundefined(t.undefineNullProps({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class i extends t.APIRequestCommand{constructor(e){if(super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_UPLOAD}`,this.params=t.deundefined({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(let t=0;tnew s(e,t,!1))))&&void 0!==a?a:[],this.requireAuth=null!==(r=t.require_auth)&&void 0!==r&&r}}class a extends t.InstancedObject{constructor(e,s){var i,n,a,r,o;super(e),this.replyCount=0,this.memberCount=0,this.lastRepliedAt=0,this.updatedAt=0,this.replyCount=null!==(i=s.reply_count)&&void 0!==i?i:0,this.memberCount=null!==(n=s.member_count)&&void 0!==n?n:0,this.mostRepliedUsers=s.most_replies&&t.isArrayOf("object",s.most_replies)?s.most_replies.map((e=>new t.User(this._iid,e))):[],this.unreadReplyCount=null!==(a=s.unread_message_count)&&void 0!==a?a:0,this.isPushNotificationEnabled="number"==typeof s.push_enabled?s.push_enabled>0:void 0,this.lastRepliedAt=null!==(r=s.last_replied_at)&&void 0!==r?r:0,this.updatedAt=null!==(o=s.updated_at)&&void 0!==o?o:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((e=>t.User.payloadify(e))):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}get _isUpdateRequired(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}_updateFrom(e){var t,s;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(s=e.isPushNotificationEnabled)&&void 0!==s?s:this.isPushNotificationEnabled}}exports.ReactionEventOperation=void 0,(e=exports.ReactionEventOperation||(exports.ReactionEventOperation={})).ADD="add",e.DELETE="delete";class r{constructor(e){this.messageId=0,this.operation=null,this.updatedAt=0;const s=t.isTypeOf("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,n=e.operation?e.operation.toLowerCase():null,a=e.reaction,r=e.updated_at;s&&t.isTypeOf("string",i)&&t.isTypeOf("string",n)&&t.isEnumOf(exports.ReactionEventOperation,n)&&t.isTypeOf("string",a)&&a&&t.isTypeOf("number",r)&&(this.messageId=s,this.userId=i,this.key=a,this.operation=n,this.updatedAt=r)}}class o{constructor(e){var s;const i=e.key,n=null!==(s=[...e.user_ids])&&void 0!==s?s:[],a=e.updated_at;t.isTypeOf("string",i)&&i&&t.isArrayOf("string",n)&&n.length>0&&t.isTypeOf("number",a)&&(this.key=i,this.userIds=n,this.updatedAt=a);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 t.deundefined(t.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 t=this.userIds.indexOf(e.userId);switch(e.operation){case exports.ReactionEventOperation.ADD:t<0&&this.userIds.push(e.userId);break;case exports.ReactionEventOperation.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}}}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 s,i;return t.deundefined(t.undefineNullProps({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(s=e.width)&&void 0!==s?s: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 t.deundefined(t.undefineNullProps({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?l.payloadify(e.defaultImage):null}))}}class u{constructor(e){var t,s;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(s=e.volume)&&void 0!==s?s:1}serialize(){return{name:this.name,volume:this.volume}}static payloadify(e){return t.deundefined(t.undefineNullProps({name:e.name,volume:e.volume}))}}var c;exports.FeedbackRating=void 0,(c=exports.FeedbackRating||(exports.FeedbackRating={})).GOOD="good",c.BAD="bad";class h{constructor(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}static _getStatus(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}static _isSubmitted(e){return"SUBMITTED"===h._getStatus(e)}static _getPayloadByStatus(e){return"NO_FEEDBACK"===e?{}:null}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,rating:e.rating,comment:e.comment}))}}class p extends t.User{constructor(e,s){var i;super(e,s),this.isBlockedByMe=!1,this.role=t.isEnumOf(t.Role,s.role)?s.role:t.Role.NONE,this.isBlockedByMe=null!==(i=s.is_blocked_by_me)&&void 0!==i&&i}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}class m{constructor(e){this.key=e.key,this.value=t.isArrayOf("string",e.value)?[...e.value]:[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:e.key,value:null!==(s=e.value)&&void 0!==s?s:[]}))}}const _=e=>{switch(e){case t.MessageType.BASE:return"";case t.MessageType.USER:return"MESG";case t.MessageType.FILE:return"FILE";case t.MessageType.ADMIN:return"ADMM"}};class g extends t.InstancedObject{constructor(e,s){var i,n,a,r,o,l,d,u,c;super(e),this.channelType=t.ChannelType.BASE,this.messageType=t.MessageType.BASE,this.mentionType=null,this.mentionedUsers=null,this.mentionedUserIds=null,this.mentionedMessageTemplate=void 0,this.metaArrays=[],this.extendedMessage={},this.createdAt=0,this.updatedAt=0,this.channelUrl=s.channel_url,this.channelType=t.isEnumOf(t.ChannelType,s.channel_type)?s.channel_type:t.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(this.channelUrl=s.channel.channel_url),s.channel.channel_type&&(this.channelType=s.channel.channel_type)),this.data=null!==(i=s.data)&&void 0!==i?i:"",this.customType=null!==(n=s.custom_type)&&void 0!==n?n:"",this.mentionType=t.isEnumOf(t.MentionType,s.mention_type)?s.mention_type:null,this.mentionedUsers=s.mentioned_users?s.mentioned_users.map((e=>new t.User(this._iid,e))):null,this.mentionedUserIds=null!==(a=s.mentioned_user_ids)&&void 0!==a?a:null,this.mentionedUsers&&!this.mentionedUserIds&&(this.mentionedUserIds=this.mentionedUsers.map((e=>e.userId))),this.mentionedMessageTemplate=s.mentioned_message_template;const h=null!==(r=s.metaarray)&&void 0!==r?r:{},p=null!==(o=s.metaarray_key_order)&&void 0!==o?o:Object.keys(h).sort(((e,t)=>e.localeCompare(t)));this.metaArrays=[];for(let e=0;enew m(e)))),this.extendedMessage=null!==(l=s.extended_message)&&void 0!==l?l:{},this.extendedMessagePayload=s.extended_message_payload,this.createdAt=null!==(u=null!==(d=s.created_at)&&void 0!==d?d:s.ts)&&void 0!==u?u:0,this.updatedAt=null!==(c=s.updated_at)&&void 0!==c?c:0}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.channelUrl,channel_type:e.channelType,type:_(e.messageType),data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(s=e.mentionedUsers)||void 0===s?void 0:s.map((e=>t.User.payloadify(e))),mentioned_message_template:e.mentionedMessageTemplate,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>m.payloadify(e))),extended_message:e.extendedMessage,extended_message_payload:e.extendedMessagePayload,created_at:e.createdAt,updated_at:e.updatedAt})))}isIdentical(e){return!0}isEqual(e){return t.deepEqual(this,e)}isUserMessage(){return this.messageType===t.MessageType.USER}isFileMessage(){return this.messageType===t.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isMultipleFilesMessage(){return this.messageType===t.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isAdminMessage(){return this.messageType===t.MessageType.ADMIN}serialize(){return t.serialize(this)}getMetaArraysByKeys(e){return this.metaArrays.filter((t=>e.includes(t.key)))}}class y extends t.InstancedObject{constructor(e,s){var i,n;super(e),this.channelUrl=null!==(i=s.channel_url)&&void 0!==i?i:"",this.channelType=null!==(n=s.channel_type)&&void 0!==n?n:t.ChannelType.GROUP,this.reader=new t.User(this._iid,s.user),this.readAt=s.ts}}class f extends t.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class v extends t.APIRequestCommand{constructor(e){super();const{channelUrl:s,channelType:i,userId:n,notificationIds:a}=e;this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/messages/mark_as_read`,this.params=t.deundefined(t.undefineNullProps({user_id:n,message_ids:a}))}}class I extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new y(e,s)}}class E extends t.APIResponseCommand{constructor(e,t){super(e,t),this.readAt=t.ts,this.unreadMessageCount=t.unread_message_count}}class T extends t.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"READ",ackRequired:!0,payload:{channel_url:e,parent_message_id:t}})}}class b extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,pushEnabled:n}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/thread_push`,this.params={push_enabled:n}}}class M extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,rating:n,comment:a}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks`,this.params={rating:n,comment:a}}}class S extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class O extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n,rating:a,comment:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`,this.params={rating:a,comment:r}}}class A extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class C extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`}}class w extends t.InstancedObject{constructor(e,t){var i,n,a,r,o;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!==(n=t.file_name)&&void 0!==n?n:null,this.mimeType=null!==(a=t.file_type)&&void 0!==a?a:null,this.fileSize=null!==(r=t.file_size)&&void 0!==r?r:0,this._requireAuth=null!==(o=t.require_auth)&&void 0!==o&&o,this.thumbnails=t.thumbnails?t.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this._requireAuth)})):[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>{var t;return{url:(null!==(t=e.plainUrl)&&void 0!==t?t:"").split("auth=")[0],width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class N{constructor({channelUrl:e,channelType:t,parentMessage:s}){this.channelUrl=e,this.channelType=t,this.parentMessage=s}}var P,U,R,x;!function(e){e.NUMBER="number",e.ENUM="enum",e.TEXT="text",e.REGEX="regex",e.DECIMAL_PLACE="decimal_place"}(P||(P={})),exports.MessageFormItemLayout=void 0,(U=exports.MessageFormItemLayout||(exports.MessageFormItemLayout={})).TEXT="text",U.TEXTAREA="textarea",U.NUMBER="number",U.PHONE="phone",U.EMAIL="email",U.CHIP="chip";class k{constructor(e,t){const{id:s,name:i,items:n,version:a,is_submitted:r}=t;this.messageId=e,this.id=s,this.name=i,this.items=n.map((e=>new L(e))).sort(((e,t)=>e.sortOrder-t.sortOrder)),this.version=null!=a?a:1,this._isSubmitted=r}get isSubmitted(){var e;return null!==(e=this._isSubmitted)&&void 0!==e?e:this.items.some((e=>Array.isArray(e.submittedValues)))}get isSubmittable(){return this.items.every((e=>e.required?!!(Array.isArray(e.draftValues)&&e.draftValues.length>0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,items:e.items.map((e=>L.payloadify(e))),version:e.version,is_submitted:e._isSubmitted}))}static isMessageFormPayload(e){return Boolean(null==e?void 0:e.message_form)}}class L{constructor(e){const{id:s,name:i,required:n,sort_order:a,placeholder:r,style:o,item_type:l,validators:d,value:u,values:c}=e;this.id=s,this.name=i,this.required=n,this.sortOrder=a,this.placeholder=r,0===Object.keys(o).length?this.style={layout:l}:this.style=t.deundefined({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),c?this.submittedValues=c:u&&(this.submittedValues=[u]),this._validators=d}isValid(e){return e.every((e=>{const t=function(e,t){return t.every((t=>{switch(t.key){case P.NUMBER:{const s=Number(e);return!(isNaN(s)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&st.max)}case P.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case P.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case P.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case P.DECIMAL_PLACE:{if(0===e.length)return!1;const s=Number(e);return!(isNaN(s)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){const s=e.toString(),i=s.indexOf(".");return-1===i||s.slice(i+1).length<=t}(s,t.max_decimal_place))}default:return!0}}))}(e,this._validators);return t}))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:t.deundefined({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}class D extends t.APIRequestCommand{constructor(e){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_FORMS}/${e.formId}/submit`,this.params=t.deundefined({message_id:e.messageId,items:e.items})}}exports.ScheduledStatus=void 0,(R=exports.ScheduledStatus||(exports.ScheduledStatus={})).PENDING="pending",R.SENT="sent",R.FAILED="failed",R.CANCELED="canceled",exports.InternalScheduledStatus=void 0,(x=exports.InternalScheduledStatus||(exports.InternalScheduledStatus={})).PENDING="pending",x.IN_QUEUE="in_queue",x.SENT="sent",x.FAILED="failed",x.CANCELED="canceled",x.REMOVED="removed";class q extends g{constructor(e,t){var s,i,n,r,l,c,p,m,_;super(e,t),this.parentMessage=null,this.silent=!1,this.isOperatorMessage=!1,this.threadInfo=null,this.reactions=[],this.appleCriticalAlertOptions=null,this.scheduledInfo=null,this.suggestedReplies=null,this.myFeedback=null,this.myFeedbackStatus="NOT_APPLICABLE",this.messageForm=null,this._isContinuousMessages=!1,this._scheduledStatus=null,this.messageId=null!==(i=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==i?i:0,this.parentMessageId=null!==(n="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==n?n:0,this.threadInfo=t.thread_info?new a(this._iid,t.thread_info):null,this.reactions=t.reactions?t.reactions.map((e=>new o(e))):[],this.ogMetaData=t.og_tag?new d(t.og_tag):null,this.silent=null!==(r=t.silent)&&void 0!==r&&r,this.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,this.appleCriticalAlertOptions=t.apple_critical_alert_options?new u(t.apple_critical_alert_options):null,"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._isContinuousMessages=null!==(c=t.is_continuous_messages)&&void 0!==c&&c,this.myFeedback=h._isSubmitted(t.feedback)?new h(t.feedback):null,this.myFeedbackStatus=h._getStatus(t.feedback),this.suggestedReplies=null!==(m=null===(p=t.extended_message_payload)||void 0===p?void 0:p.suggested_replies)&&void 0!==m?m:null,this.messageForm=k.isMessageFormPayload(t.extended_message_payload)?new k(this.messageId,t.extended_message_payload.message_form):null,this.message=null!==(_=t.message)&&void 0!==_?_:""}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?a.payloadify(e.threadInfo):null,reactions:e.reactions.map((e=>o.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?u.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledMessageId,scheduled_at:null===(i=e.scheduledInfo)||void 0===i?void 0:i.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?h.payloadify(e.myFeedback):h._getPayloadByStatus(e.myFeedbackStatus),message:e.message})))}static _getParentMessageInfoPayload(e){return t.deundefined(t.undefineNullProps({type:_(e.messageType),ts:e.createdAt,user:e.sender?p.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null}))}isIdentical(e){return this.messageId===e.messageId}applyThreadInfoUpdateEvent(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}applyReactionEvent(e){if(this.messageId===e.messageId){let t=!1;for(let s=0;s=t)return this.parentMessage=e,!0}return!1}_triggerThreadInfoUpdatedEvent(){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e}=t.Vault.of(this._iid);e.dispatch(new N({channelType:t.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))}))}markThreadAsRead(){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=t.Vault.of(this._iid),s=new T({channelUrl:this.channelUrl,messageId:this.messageId});yield e.send(s),this.threadInfo&&0!==this.threadInfo.unreadReplyCount&&(this.threadInfo.unreadReplyCount=0,yield this._triggerThreadInfoUpdatedEvent())}))}setPushNotificationEnabled(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),i=new b({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e});yield s.send(i),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e)}))}submitMessageForm(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid);let i=null,n=null;const a=this.messageForm;if(!e&&a){if(!a.isSubmittable)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(a.isSubmitted)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});i=a.id,n=a.items.reduce(((e,t)=>(e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e)),[])}else e&&(i=e.formId,n=Object.entries(e.answers).reduce(((e,[s,i])=>{const n=Number(s);if(Number.isNaN(n))throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:n,value:i}),e}),[]));if(!i||!n)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});const r=new D({messageId:this.messageId,formId:i,items:n});yield s.send(r)}))}submitFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new M({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(S);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}))}))}updateFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new O({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(A);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}))}))}deleteFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new C({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e});yield s.send(n),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}))}))}}class F extends q{constructor(e,s){var i,n,a,r;if(super(e,s),this.reqId="",this.replyToChannel=!1,this.errorCode=0,this.sender=s.user?new p(this._iid,s.user):s.sender_id,this.reqId=null!==(n=null!==(i=s.req_id)&&void 0!==i?i:s.request_id)&&void 0!==n?n:"",this.replyToChannel=null!==(a=s.is_reply_to_channel)&&void 0!==a&&a,s.request_state&&t.isEnumOf(t.SendingStatus,s.request_state)&&(this.sendingStatus=s.request_state),!this.sendingStatus)if(this.messageId>0)this.sendingStatus=t.SendingStatus.SUCCEEDED;else if(this.scheduledInfo)switch(s.scheduled_status&&(this._scheduledStatus=s.scheduled_status),s.scheduled_status){case exports.InternalScheduledStatus.SENT:case exports.InternalScheduledStatus.IN_QUEUE:this.sendingStatus=t.SendingStatus.SUCCEEDED;break;case exports.InternalScheduledStatus.PENDING:this.sendingStatus=t.SendingStatus.SCHEDULED;break;case exports.InternalScheduledStatus.FAILED:case exports.InternalScheduledStatus.REMOVED:this.sendingStatus=t.SendingStatus.FAILED;break;case exports.InternalScheduledStatus.CANCELED:this.sendingStatus=t.SendingStatus.CANCELED}else this.sendingStatus=t.SendingStatus.PENDING;this.errorCode=null!==(r=s.error_code)&&void 0!==r?r:0,this._messageToken=s.mesg_token}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{user:p.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}get isResendable(){return(this.sendingStatus===t.SendingStatus.FAILED||this.sendingStatus===t.SendingStatus.CANCELED)&&t.isResendableError(this.errorCode)}isIdentical(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}const B={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},j=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo);class V extends q{constructor(e,s){var i,n,a;if(super(e,s),this.translations={},this.messageType=t.MessageType.ADMIN,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(a=i.file)||void 0===a?void 0:a.require_auth}))))}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{translations:e.translations,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class z{constructor(e){var s,i;this.detail={},this.type=null!==(s=e.type)&&void 0!==s?s:"",this.vendor=null!==(i=e.vendor)&&void 0!==i?i:"",e.detail&&t.isTypeOf("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}static payloadify(e){return t.deundefined(t.undefineNullProps({type:e.type,vendor:e.vendor,detail:e.detail}))}}class ${constructor(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}static payloadify(e){return t.deundefined({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}class Q extends F{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.messageParams=null,this.translations={},this.translationTargetLanguages=[],this.messageSurvivalSeconds=-1,this.plugins=[],this._poll=null,this.messageType=t.MessageType.USER,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},this.translationTargetLanguages=null!==(n=s.target_langs)&&void 0!==n?n:[],0===Object.keys(this.translations).length&&this.translationTargetLanguages.length>0)for(const e of this.translationTargetLanguages)this.translations[e]="";if(this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,this.plugins=s.plugins?s.plugins.map((e=>new z(e))):[],this._poll=s.poll?new t.Poll(this._iid,s.poll):null,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(o=i.file)||void 0===o?void 0:o.require_auth}))))}s.review_info&&(this.messageReviewInfo=new $(s.review_info))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((e=>z.payloadify(e))),poll:e._poll?t.Poll.payloadify(e._poll):null,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null,review_info:e.messageReviewInfo?$.payloadify(e.messageReviewInfo):void 0})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.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 G extends F{constructor(e,s){var i,n,a,r,o,l,d,u;if(super(e,s),this.messageParams=null,this.fileInfoList=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE,this.data=null!==(a=null!==(n=null===(i=s.file)||void 0===i?void 0:i.data)&&void 0!==n?n:s.custom)&&void 0!==a?a:"",this.fileInfoList=null!==(o=null===(r=s.files)||void 0===r?void 0:r.map((t=>new w(e,t))))&&void 0!==o?o:[],this.messageSurvivalSeconds=null!==(l=s.message_survival_seconds)&&void 0!==l?l:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(d=i.file)||void 0===d?void 0:d.url,require_auth:null===(u=i.file)||void 0===u?void 0:u.require_auth}))))}}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}static payloadify(e){var s,i,n,a,r,o;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{file:{name:null!==(i=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.fileName)&&void 0!==i?i:"",size:null!==(a=null===(n=e.fileInfoList[0])||void 0===n?void 0:n.fileSize)&&void 0!==a?a:0,type:null!==(o=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}static _isMultipleFilesMessagePayload(e){const t=e.files;return Array.isArray(t)&&t.length>=2}static _isMultipleFilesMessageSerializedData(e){const t=e.fileInfoList;return Array.isArray(t)}}var K;exports.NotificationMessageStatus=void 0,(K=exports.NotificationMessageStatus||(exports.NotificationMessageStatus={})).SENT="SENT",K.READ="READ";class H extends g{constructor(e,s){var i,n;if(super(e,s),this.notificationData=null,this.notificationId=s.notification_message_id,this.messageType=t.MessageType.ADMIN,this.messageStatus=null!==(i=s.message_status)&&void 0!==i?i:exports.NotificationMessageStatus.SENT,this.priority=null!==(n=s.priority)&&void 0!==n?n:t.NotificationPriority.NORMAL,this.notificationEventDeadline=s.notification_event_deadline,0===this.extendedMessage.sub_type)try{const{label:e,tags:t=[],template_key:s,template_variables:i}=JSON.parse(this.extendedMessage.sub_data);this.notificationData={label:e,tags:t,templateKey:s,templateVariables:i}}catch(e){}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}isIdentical(e){return this.notificationId===e.notificationId}}const W=(e,t)=>{if(t.notification_message_id)return new H(e,t);switch(t.type){case"MESG":return new Q(e,t);case"FILE":return G._isMultipleFilesMessagePayload(t)?new G(e,t):new Y(e,t);case"ADMM":case"BRDM":return new V(e,t);default:return null}};class Y extends F{constructor(e,i){var n,a,r,o,l,d,u,c,h,p,m,_,g,y;super(e,i),this.messageParams=null,this.plainUrl="",this.requireAuth=!1,this.thumbnails=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE;const f=i.file;if(this.plainUrl=(null!==(a=null!==(n=null==f?void 0:f.url)&&void 0!==n?n:i.url)&&void 0!==a?a:"").split("?auth=")[0],this.name=null!==(o=null!==(r=null==f?void 0:f.name)&&void 0!==r?r:i.name)&&void 0!==o?o:"File",this.size=null!==(d=null!==(l=null==f?void 0:f.size)&&void 0!==l?l:i.size)&&void 0!==d?d:0,this.data=null!==(c=null!==(u=null==f?void 0:f.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",this.type=f?null!==(h=f.type)&&void 0!==h?h:"":null!==(p=i.type)&&void 0!==p?p:"",this.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,this.thumbnails=i.thumbnails?i.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this.requireAuth)})):[],this.messageSurvivalSeconds=null!==(_=i.message_survival_seconds)&&void 0!==_?_:-1,i.parent_message_info){const s=i.parent_message_info;this.parentMessage=W(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},s),{created_at:s.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:s.file,url:null===(g=s.file)||void 0===g?void 0:g.url,require_auth:null===(y=s.file)||void 0===y?void 0:y.require_auth}))))}}static payloadify(e){var s;return t.deundefined(t.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===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.plainUrl,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}=t.Vault.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class J extends t.InstancedObject{static getPlainUrl(e){return e instanceof J?e._plainUrl:e.fileUrl}constructor(e,{file:t,fileUrl:s,fileName:i,fileSize:n,mimeType:a,thumbnailSizes:r,_uploadedMetaData:o,_thumbnails:l}){super(e),this._plainUrl=s,this.file=t,this.fileName=i,this.fileSize=n,this.mimeType=a,this.thumbnailSizes=r,this._uploadedMetaData=o,this._thumbnails=l}get fileUrl(){var e;const{sessionManager:s}=t.Vault.of(this._iid);return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&s.ekey?`${this._plainUrl}?auth=${s.ekey}`:this._plainUrl}set fileUrl(e){this._plainUrl=e}toJSON(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}class X extends t.WebSocketRequestCommand{constructor(e){var i,n,a,r;let o=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((e=>e.userId)))),super({code:"FILE",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,files:e.files?se(e.files):null,url:e.url,name:null!==(i=e.fileName)&&void 0!==i?i:"",type:null!==(n=e.mimeType)&&void 0!==n?n:"",size:null!==(a=e.fileSize)&&void 0!==a?a:0,custom:e.data,custom_type:e.customType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((e=>s.payloadify(e))),require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:o,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?u.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,message:e.message}))})}}class Z extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId)))),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e.channelType)}/${encodeURIComponent(e.channelUrl)}/messages`,this.params=t.deundefined(t.undefineNullProps({message_type:t.MessageType.FILE,user_id:e.userId,files:e.files?se(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===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:e.requireAuth,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((e=>m.payloadify(e))),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}))}}class ee extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"FILE",i),this.message=i.files&&i.files.length>=2?new G(e,i):new Y(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class te extends t.APIResponseCommand{constructor(e,s){var i,n,a,r;super(e,s),this.message=s.files&&s.files.length>=2?new G(e,s):new Y(e,s);const{sdkState:o}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(a=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(n=this.message.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)))&&void 0!==a?a:[],o.userId),this.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r}}function se(e){return e.map((e=>{var i,n;return t.deundefined(t.undefineNullProps({url:J.getPlainUrl(e),file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var ie;!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"}(ie||(ie={}));class ne{constructor(e,{sdkState:s,dispatcher:i,requestQueue:n,onlineDetector:a,cacheContext:r}){this._queueMap=new Map,this._iid=e,this._sdkState=s,this._requestQueue=n,this._cacheContext=r,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof t.ConnectionStateChangeCommand&&(this._connectionState=e.stateType)})),this._onlineDetector=a}get _shouldSendThroughWebSocket(){return this._connectionState===t.ConnectionStateType.CONNECTED||this._connectionState===t.ConnectionStateType.CONNECTING||this._connectionState===t.ConnectionStateType.RECONNECTING}_sendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._createSendFileMessageRequestParams(e,s);if(this._shouldSendThroughWebSocket){const e=new X(t),s=yield this._requestQueue.send(e),{message:i}=s.as(ee);return i}{const e=new Z(Object.assign(Object.assign({},t),{userId:this._sdkState.userId})),s=yield this._requestQueue.send(e),{message:i}=s.as(te);return i}}))}_createSendFileMessageRequestParams(e,t){const s=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){const e=t.params;s.files=e.fileInfoList}else{const e=t.params;s.url=e.fileUrl,s.requireAuth=e.requireAuth}return s}_resolveMessageQueue(e){var s;return t.__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 n=[];let a=!0;for(const r of i.messageQueue)switch(r.state){case ie.PENDING:case ie.UPLOADING:a=!1,n.push(r);break;case ie.UPLOADED:if(a)try{r.state=ie.SENDING;const s=yield this._sendFileMessage(e,r);r.deferred.resolve(s),yield t.sleep(100)}catch(e){r.deferred.reject(e)}else n.push(r);break;case ie.FAILED:{const e=null!==(s=r.error)&&void 0!==s?s:t.SendbirdError.unknown;r.deferred.reject(e.code===t.SendbirdErrorCode.REQUEST_CANCELED?t.SendbirdError.fileUploadCanceled:e);break}}const r=i.isResolveRequestPending;i.messageQueue=n,i.isResolving=!1,i.isResolveRequestPending=!1,r&&(yield this._resolveMessageQueue(e))}}))}_uploadNextPendingItem(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i){const n=i.messageQueue.find((e=>e.state===ie.PENDING));if(n){if(n.multipleFileUploadInfo){const{uploadIndex:a,uploadCount:r,requestHandler:o}=n.multipleFileUploadInfo,l=n.params,d=l.fileInfoList[a];t.isFile(d.file)&&!(null===(s=d._uploadedMetaData)||void 0===s?void 0:s.isUploaded)?yield this._tryUploadNextItemAndUpdateItemState(e,i,n):n.state=ae.requestId===t.requestId));s>=0&&e.uploadQueue.splice(s,1)}_uploadNextFileForSingleFileItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const t=new i({file:a.file,channelUrl:e.url,thumbnailSizes:a.thumbnailSizes,requestId:s.requestId}),d=yield this._requestQueue.send(t),{url:u,fileSize:c=a.fileSize,thumbnails:h=[],requireAuth:p=!1}=d.as(n);a.fileName=null!==(r=a.fileName)&&void 0!==r?r:a.file.name,a.mimeType=null!==(o=a.mimeType)&&void 0!==o?o:a.file.type,a.fileSize=null!==(l=a.fileSize)&&void 0!==l?l:a.file.size,a.fileUrl=u,a.fileSize=c,a.requireAuth=p,a._thumbnails=h}))}_uploadNextFileForMultipleFilesItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const{uploadIndex:t}=s.multipleFileUploadInfo,d=a.fileInfoList[t],u=new i({file:d.file,channelUrl:e.url,thumbnailSizes:d.thumbnailSizes,requestId:s.requestId}),c=yield this._requestQueue.send(u),{url:h,fileSize:p=d.fileSize,thumbnails:m,requireAuth:_=!1}=c.as(n);d.fileName=null!==(r=d.fileName)&&void 0!==r?r:d.file.name,d.mimeType=null!==(o=d.mimeType)&&void 0!==o?o:d.file.type,d.fileSize=null!==(l=d.fileSize)&&void 0!==l?l:d.file.size,d.file=void 0,d.fileUrl=h,d.fileSize=p,d._thumbnails=m,d._uploadedMetaData=Object.assign(Object.assign({},d._uploadedMetaData),{requireAuth:_,isUploaded:!0}),d instanceof J||(a.fileInfoList[t]=new J(this._iid,d))}))}request(e,s,i,n={}){return t.__awaiter(this,void 0,void 0,(function*(){if(!this._queueMap.has(e.url)){const t={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1};this._queueMap.set(e.url,t)}const a=this._queueMap.get(e.url),r=new t.Deferred,o={requestId:s,params:i,state:ie.PENDING,deferred:r};if(function(e){return"fileInfoList"in e}(i)){const e=i,t=Object.assign({uploadIndex:0,uploadCount:e.fileInfoList.length},n);o.multipleFileUploadInfo=t}return a.messageQueue.push(o),this._uploadNextPendingItem(e),r.promise}))}cancel(e,s){const i=this._queueMap.get(e.url);if(i){const n=s?[i.messageQueue.find((e=>e.requestId===s))]:[...i.messageQueue];for(const s of n)if(s)switch(s.state){case ie.PENDING:if(s.state=ie.FAILED,s.error=t.SendbirdError.requestCanceled,s.multipleFileUploadInfo&&!s.multipleFileUploadInfo.isCopy){const{uploadIndex:e,requestHandler:i}=s.multipleFileUploadInfo,n=s.params.fileInfoList[e];null==i||i._triggerOnFileUploaded(s.requestId,e,n,t.SendbirdError.fileUploadCanceled)}this._resolveMessageQueue(e);break;case ie.UPLOADING:this._requestQueue.cancel(s.requestId),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s.requestId}))}}else s&&(this._requestQueue.cancel(s),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s})))}}const ae={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:t.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},re=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo)&&t.isTypeOf("boolean",e.showSubchannelMessagesOnly),oe={replyType:t.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},le=e=>t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo);class de extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,includeMetaArray:n,includeReactions:a,includeThreadInfo:r,includeParentMessageInfo:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}`,this.params={is_sdk:!0,with_sorted_meta_array:n,include_reactions:a,include_thread_info:r,include_parent_message_info:o,include_poll_details:!0}}}class ue extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}class ce extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,prevResultSize:a,nextResultSize:r,isInclusive:o,reverse:l,messageTypeFilter:d,customTypesFilter:u,senderUserIdsFilter:c,replyType:h,includeMetaArray:p,includeReactions:m,parentMessageId:_,includeThreadInfo:g,includeParentMessageInfo:y,showSubchannelMessagesOnly:f,checkingHasNext:v,checkingContinuousMessages:I}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages`,this.params=t.deundefined(t.undefineNullProps({is_sdk:!0,prev_limit:a,next_limit:r,include:o,reverse:l,message_ts:i,message_id:n,message_type:null!=d?d:null,custom_types:u,sender_ids:c,include_reply_type:h,with_sorted_meta_array:p,include_reactions:m,parent_message_id:_,include_thread_info:g,include_parent_message_info:y,show_subchannel_message_only:f,include_poll_details:!0,checking_has_next:v,checking_continuous_messages:I}))}}class he extends t.APIResponseCommand{constructor(e,t){super(e,t),void 0!==t.is_continuous_messages&&(this.isContinuousMessages=t.is_continuous_messages),void 0!==t.has_next&&(this.hasNext=t.has_next),this.messages=t.messages.map((t=>W(e,t)))}}class pe extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,replyType:a,includeMetaArray:r,includeReactions:o,includeThreadInfo:l,includeParentMessageInfo:d}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/changelogs`,this.params={change_ts:i,token:n,with_sorted_meta_array:r,include_reactions:o,include_thread_info:l,include_reply_type:a,include_parent_message_info:d,include_poll_details:!0}}}class me extends t.APIResponseCommand{constructor(e,t){super(e,t),this.updatedMessages=t.updated.map((t=>W(e,t))),this.deletedMessagesInfo=t.deleted.map((e=>({messageId:e.message_id,deletedAt:e.deleted_at}))),this.hasMore=t.has_more,this.nextToken=t.next}}class _e extends t.APIRequestCommand{constructor({channelUrl:e,scheduledMessageId:s}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/scheduled_messages/${encodeURIComponent(s)}`,this.params={}}}class ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}var ye;exports.RestrictionType=void 0,(ye=exports.RestrictionType||(exports.RestrictionType={})).MUTED="muted",ye.BANNED="banned";class fe{constructor(e){var s,i,n,a;this.restrictionType=null,t.isEnumOf(exports.RestrictionType,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(s=e.description)&&void 0!==s?s:null,this.endAt=null!==(n=null!==(i=e.end_at)&&void 0!==i?i:e.muted_end_at)&&void 0!==n?n:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}static payloadify(e){return t.deundefined(t.undefineNullProps({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}class ve extends t.User{constructor(e,t){super(e,t),this.restrictionInfo=new fe(t)}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),fe.payloadify(e.restrictionInfo))))}}class Ie{constructor(){this._onPending=t.noop,this._onFailed=t.noop,this._onSucceeded=t.noop}_trigger(e){switch(null==e?void 0:e.sendingStatus){case t.SendingStatus.PENDING:0===e.errorCode&&this._onPending(e);break;case t.SendingStatus.SCHEDULED:case t.SendingStatus.SUCCEEDED:this._onSucceeded(e)}}_triggerFailed(e,s){switch(null==s?void 0:s.sendingStatus){case t.SendingStatus.FAILED:case t.SendingStatus.CANCELED:this._onFailed(e,s.scheduledInfo?null:s)}}onPending(e){return this._onPending=e,this}onFailed(e){return this._onFailed=e,this}onSucceeded(e){return this._onSucceeded=e,this}}const Ee={data:void 0,customType:void 0,mentionType:t.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},Te=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isTypeOf("number",e.parentMessageId,!0)&&t.isTypeOf("boolean",e.isReplyToChannel)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0)&&t.isTypeOf("boolean",e.isPinnedMessage,!0),be=e=>({isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}),Me=Object.assign(Object.assign({},Ee),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function Se(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}const Oe=e=>{var s;return t.deundefined(t.undefineNullProps({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(s=e.poll)||void 0===s?void 0:s.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations),extendedMessagePayload:e.extendedMessagePayload}))},Ae=e=>Te(e)&&t.isTypeOf("string",e.message)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0)&&t.isTypeOf("object",e.extendedMessagePayload,!0);var Ce;!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Ce||(Ce={}));const we=e=>"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob,Ne=e=>e===Ce.BLOB||e===Ce.FILE,Pe=e=>({file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}),Ue=Object.assign(Object.assign({},Ee),{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,message:void 0});function Re(e){var s,i,n,a;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=e.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails,message:e.message}))}const xe=(e,s)=>{var i;return e.messageParams?(!e.url&&t.isFile(s)&&(e.messageParams.file=s),e.messageParams):t.deundefined(t.undefineNullProps({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:s,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),message:e.message}))},ke=e=>Te(e)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&t.isTypeOf("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),Le={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},De=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0),qe=Object.assign(Object.assign({},Le),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Fe=e=>De(e)&&t.isTypeOf("string",e.message,!0)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0),Be=Object.assign({},Le);class je extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,token:i,limit:n}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(e)}/operators`,this.params={token:i,limit:n}}}class Ve extends t.APIResponseCommand{constructor(e,s){super(e,s),this.operators=s.operators.map((s=>new t.User(e,s))),this.token=s.next}}class ze extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;{const e=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new je(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),i=yield e.send(s),{operators:n,token:a}=i.as(Ve);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return e}}throw t.SendbirdError.invalidParameters}))}}class $e extends t.ChannelDataListQuery{constructor(e,s,i,n){var a,r,o,l,d,u,c,h,p,m;super(e,s,i,n),this.reverse=!1,this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.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!==(a=n.reverse)&&void 0!==a&&a,this.messageTypeFilter=null!==(r=n.messageTypeFilter)&&void 0!==r?r:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,this.senderUserIdsFilter=null!==(l=n.senderUserIdsFilter)&&void 0!==l?l:null,this.replyType=null!==(d=n.replyType)&&void 0!==d?d:t.ReplyType.NONE,this.includeMetaArray=null!==(u=n.includeMetaArray)&&void 0!==u&&u,this.includeReactions=null!==(c=n.includeReactions)&&void 0!==c&&c,this.includeParentMessageInfo=null!==(h=n.includeParentMessageInfo)&&void 0!==h&&h,this.includeThreadInfo=null!==(p=n.includeThreadInfo)&&void 0!==p&&p,this.showSubchannelMessagesOnly=null!==(m=n.showSubchannelMessagesOnly)&&void 0!==m&&m}_validate(){return super._validate()&&t.isTypeOf("boolean",this.reverse)&&t.isEnumOf(t.MessageTypeFilter,this.messageTypeFilter)&&t.isEnumOf(t.ReplyType,this.replyType)&&t.isArrayOf("string",this.customTypesFilter,!0)&&t.isArrayOf("string",this.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",this.includeMetaArray)&&t.isTypeOf("boolean",this.includeReactions)&&t.isTypeOf("boolean",this.includeParentMessageInfo)&&t.isTypeOf("boolean",this.includeThreadInfo)&&t.isTypeOf("boolean",this.showSubchannelMessagesOnly)}load(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=zi.of(this._iid),s=yield e.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t.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,...s.map((e=>e.createdAt))),this._hasNext=s.length>=this.limit,this._isLoading=!1,s}return[]}throw t.SendbirdError.invalidParameters}))}}class Qe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={limit:n,token:a}}}class Ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.mutedUsers=[];const{next:s,muted_list:i}=t;this.token=s,i&&i.length>0&&(this.mutedUsers=i.map((t=>new ve(e,t))))}}class Ke extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Qe(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{mutedUsers:n,token:a}=i.as(Ge);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class He extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({limit:n,token:a})}}class We extends t.APIResponseCommand{constructor(e,t){super(e,t),this.bannedUsers=[];const{next:s,banned_list:i}=t;this.token=s,i&&i.length>0&&(this.bannedUsers=i.map((t=>new ve(e,t.user))))}}class Ye extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new He(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{bannedUsers:n,token:a}=i.as(We);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}var Je;exports.ReportCategory=void 0,(Je=exports.ReportCategory||(exports.ReportCategory={})).SPAM="spam",Je.HARASSING="harassing",Je.SUSPICIOUS="suspicious",Je.INAPPROPRIATE="inappropriate";class Xe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class Ze extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${n}`}}class tt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.isMuted=!1,this.startAt=0,this.endAt=0;const{is_muted:s,start_at:i,end_at:n,remaining_duration:a,description:r}=t;this.isMuted=s,this.startAt=i,this.endAt=n,this.remainingDuration=a,this.description=r}}class st extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={keys:n,include_ts:!0}}}class it extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0}}}class at extends t.APIResponseCommand{constructor(e,t){var s,i;super(e,t),this.metaData=null!==(s=t.metadata)&&void 0!==s?s:{},this.ts=null!==(i=t.ts)&&void 0!==i?i:null}}class rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n,upsert:a}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0,upsert:null!=a&&a}}}class ot extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class lt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class dt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata/${n}`,this.params={include_ts:!0}}}class ut extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={include_ts:!0}}}class ht extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class pt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={keys:n}}}class mt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class _t extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n}}}class gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class yt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n,upsert:a=!1,mode:r="set"}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n,upsert:a,mode:r}}}class ft extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class vt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class It extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter/${n}`,this.params={}}}class Et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={}}}class Tt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={user_id:n,seconds:a,description:r}}}class bt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Mt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${encodeURIComponent(n)}`}}class St extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Ot extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({user_id:n,seconds:a,description:r})}}class At extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data),s.data.member_count&&(this.memberCount=s.data.member_count),s.data.joined_member_count&&(this.joinedMemberCount=s.data.joined_member_count)}}class Ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban/${encodeURIComponent(n)}`}}class wt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,freezing:n}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/freeze`,this.params={freeze:n}}}class Pt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.freeze=s.data.freeze}}class Ut extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}`,this.params={report_category:n,reporting_user_id:a,report_description:r}}}class Rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,description:o}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_REPORT}/users/${r}`,this.params={channel_url:s,channel_type:i===t.ChannelType.OPEN?"open_channels":"group_channels",report_category:n,reporting_user_id:a,report_description:o}}}class xt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,messageId:o,description:l,messageToken:d}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}/messages/${o}`,this.params=t.deundefined({report_category:n,reporting_user_id:a,report_description:l,offending_user_id:r,mesg_token:d})}}class kt extends t.WebSocketRequestCommand{constructor(e){let s=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MESG",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage,extended_message_payload:e.extendedMessagePayload}))})}}class Lt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"MESG",i),this.message=new Q(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class Dt extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,poll_id:e.pollId}))})}}class qt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"MEDI",i),this.message=new Q(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class Ft extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"FEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,apple_critical_alert_options:e.appleCriticalAlertOptions}))})}}class Bt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"FEDI",i),this.message=new Y(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class jt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class Vt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(t)}}class zt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class $t extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(Object.assign({},t))}}class Qt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,translationTargetLanguages:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}/translation`,this.params={target_langs:n}}}class Gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Kt extends t.APIRequestCommand{constructor(e){var s;super();let i=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:a}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(n)}/${encodeURIComponent(a)}/scheduled_messages`,this.params=t.deundefined(t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class Ht extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Wt extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId))));const{channelType:r,channelUrl:o}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(r)}/${encodeURIComponent(o)}/scheduled_messages`,this.params=t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.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((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})}}class Yt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Y(e,t)}}class Jt extends t.APIRequestCommand{constructor({pollId:e,title:s,data:i,allowUserSuggestion:n,allowMultipleVotes:a,closeAt:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`,this.params={title:s,data:i,allow_user_suggestion:n,allow_multiple_votes:a,close_at:r}}}class Xt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Zt extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`}}class es extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/close`}}class ts extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ss extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,pollId:i,optionText:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(i)}/options`,this.params={channel_url:e,channel_type:s,text:n}}}class is extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ns extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s,optionText:i}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`,this.params={text:i}}}class as extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class rs extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`}}class os extends t.WebSocketRequestCommand{constructor({reqId:e,channelType:s,channelUrl:i,pollId:n,pollOptionIds:a}){super({code:"VOTE",ackRequired:!0,payload:t.deundefined({req_id:e,channel_type:s===t.ChannelType.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:n,option_ids:a})})}}class ls extends t.WebSocketEventCommand{constructor(e,s,i){super(e,"VOTE",i),this.event=new t.PollVoteEvent(i),this.channelUrl=i.channel_url,this.channelType=i.channel_type}}const ds="Message",us="NotificationMessage";const cs=Object.assign(Object.assign({},Ee),{fileInfoList:[],message:""}),hs=e=>(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>e.maxWidth>0&&e.maxHeight>0)));class ps extends Ie{constructor(){super(...arguments),this._onFileUploaded=t.noop}_triggerOnFileUploaded(e,t,s,i){this._onFileUploaded(e,t,s,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}}class ms extends t.InstancedObject{constructor(e,t){super(e),this.message=null,this.message=W(e,t.message)}}class _s extends t.APIRequestCommand{constructor(e){const{channelType:s,channelUrl:i,limit:n,token:a,includeReactions:r,includeMetaArray:o,includeParentMessageInfo:l,includeThreadInfo:d,includePollDetails:u}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(i)}/pinned_messages`,this.params=t.deundefined({limit:n,token:a,include_reactions:r,with_sorted_meta_array:o,include_thread_info:d,include_parent_message_info:l,include_poll_details:u})}}class gs extends t.APIResponseCommand{constructor(e,t){super(e,t);const{pinned_messages:s,has_more:i,next:n}=t;this.pinnedMessages=s.map((t=>new ms(e,t))),this.hasMore=i,this.token=n}}class ys extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i),this.includeMetaArray=i.includeMetaArray,this.includeReactions=i.includeReactions,this.includeParentMessageInfo=i.includeParentMessageInfo,this.includeThreadInfo=i.includeThreadInfo,this.includePollDetails=i.includePollDetails}_validate(){return super._validate()&&t.isTypeOf("boolean",this.includeMetaArray,!0)&&t.isTypeOf("boolean",this.includeReactions,!0)&&t.isTypeOf("boolean",this.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",this.includeThreadInfo,!0)&&t.isTypeOf("boolean",this.includePollDetails,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new _s(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{pinnedMessages:n,hasMore:a,token:r}=i.as(gs);return this._token=r,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class fs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}class vs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}var Is;exports.SendMessageRequestType=void 0,(Is=exports.SendMessageRequestType||(exports.SendMessageRequestType={})).SEND="send",Is.RESEND="resend",Is.COPY="copy";class Es extends t.InstancedObject{get url(){return this._url}get name(){return this._name}set name(e){this._name=e}get createdAt(){return this._createdAt}toJSON(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}constructor(e,s){var i,n,a,r,o,l,d;super(e),this._name="",this._createdAt=0,this.pinnedMessageIds=[],this.channelType=t.ChannelType.BASE,this.coverUrl="",this.customType="",this.data="",this.isFrozen=!1,this.isEphemeral=!1,this.creator=null,this._messageCollectionLastAccessedAt=0,this._url=s.channel_url,this._name=null!==(i=s.name)&&void 0!==i?i:"",this._createdAt=1e3*s.created_at,this.coverUrl=null!==(n=s.cover_url)&&void 0!==n?n:"",this.customType=null!==(a=s.custom_type)&&void 0!==a?a:"",this.data=null!==(r=s.data)&&void 0!==r?r:"",this.isFrozen=null!==(o=s.freeze)&&void 0!==o&&o,this.isEphemeral=null!==(l=s.is_ephemeral)&&void 0!==l&&l,this.creator=s.created_by?new t.User(this._iid,s.created_by):null,s.metadata&&Object.keys(s.metadata).length>0&&s.ts?(this._cachedMetaData=new Map,Object.keys(s.metadata).forEach((e=>{this._cachedMetaData.set(e,{value:s.metadata[e],isRemoved:!1,updatedAt:s.ts})}))):"string"==typeof s.metadata&&(this._cachedMetaData=new Map(Object.entries(JSON.parse(s.metadata)))),this.pinnedMessageIds=null!==(d=s.pinned_message_ids)&&void 0!==d?d:[]}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(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?t.User.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}isGroupChannel(){return this.channelType===t.ChannelType.GROUP}isOpenChannel(){return this.channelType===t.ChannelType.OPEN}isFeedChannel(){return this.channelType===t.ChannelType.FEED}get cachedMetaData(){const e={};return this._cachedMetaData?(this._cachedMetaData.forEach(((t,s)=>{t.isRemoved||(e[s]=t.value)})),e):e}get messageCollectionLastAccessedAt(){return this._messageCollectionLastAccessedAt}_serializeCachedMetaData(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}_updateMessageCollectionLastAccessedAt(){this._messageCollectionLastAccessedAt=Date.now()}_update(e){const s=t.deundefined(e);Object.assign(this,s)}_upsertCachedMetaData(e,t){Object.keys(e).forEach((s=>{this._cachedMetaData||(this._cachedMetaData=new Map);const i=this._cachedMetaData.get(s);(!i||i.updatedAt<=t)&&this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})}))}_updateCachedMetaData(e,t){let s=!1;return this._cachedMetaData?this._cachedMetaData.forEach(((i,n)=>{var a;i.updatedAt<=t&&(this._cachedMetaData.set(n,{value:null!==(a=e[n])&&void 0!==a?a:i.value,isRemoved:!e[n],updatedAt:t}),s=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((s=>{this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})})),s=!0),{isUpdated:s}}_removeFromCachedMetaData(e,t){this._cachedMetaData&&e.forEach((e=>{const s=this._cachedMetaData.get(e);s&&s.updatedAtm.payloadify(e))):null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,created_at:i,user:a.currentUser?p.payloadify(a.currentUser):null,req_id:s,request_state:t.SendingStatus.PENDING,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>t.User.payloadify(e)))}))}_createPendingUserMessage(e,s,i){const n={};if(e.translationTargetLanguages)for(const t of e.translationTargetLanguages)n[t]="";const a=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.USER,message:e.message,translations:n,extended_message_payload:e.extendedMessagePayload})),r=new Q(this._iid,a);return r.messageParams=e,r}_createPendingScheduledUserMessage(e,t,s){const i=this._createPendingUserMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_createPendingFileMessage(e,i,n){var a,r,o,l,d,u,c;const h=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,i,n)),{type:t.MessageType.FILE,url:e.fileUrl,file:{name:null!==(a=e.fileName)&&void 0!==a?a:null===(r=e.file)||void 0===r?void 0:r.name,size:null!==(o=e.fileSize)&&void 0!==o?o:null===(l=e.file)||void 0===l?void 0:l.size,type:null!==(d=e.mimeType)&&void 0!==d?d:null===(u=e.file)||void 0===u?void 0:u.type,data:e.data},thumbnails:null===(c=e._thumbnails)||void 0===c?void 0:c.map((e=>s.payloadify(e))),message:e.message})),p=new Y(this._iid,h);return p.messageParams=e,p}_createPendingMultipleFilesMessage(e,s,i){const n=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.FILE,file:e.fileInfoList.length>0?{name:e.fileInfoList[0].fileName,size:e.fileInfoList[0].fileSize,type:e.fileInfoList[0].mimeType,data:e.data}:void 0,message:e.message})),a=new G(this._iid,n);return a.messageParams=e,a}_validateFailedFileMessageHasFile(e,s){var i;return Boolean(e.url)||t.isFile(s)||t.isFile(null===(i=e.messageParams)||void 0===i?void 0:i.file)}_createPendingScheduledFileMessage(e,t,s){const i=this._createPendingFileMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_markMessageAsFailed(e,s,i=!1){e.errorCode=s.code,s.code===t.SendbirdErrorCode.REQUEST_CANCELED||s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=t.SendingStatus.CANCELED:i||(e.sendingStatus=t.SendingStatus.FAILED)}sendUserMessage(e){const s=Object.assign(Object.assign({},Me),e);return t.unless(Ae(s)).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(s)}_sendUserMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n,requestQueue:a}=t.Vault.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)}))));const d=new kt(Object.assign(Object.assign({},e),{channelUrl:this.url,channelType:this.channelType,reqId:r}));a.send(d).then((e=>{const{message:s}=e.as(Lt);n.dispatch(new t.MessageUpdateEventCommand({messages:[s],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(s)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendUserMessage(e){return t.unless(e instanceof Q&&!!e.messageParams).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId)}resendUserMessage(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=new t.Deferred,n=null!==(s=e.messageParams)&&void 0!==s?s:Oe(e);return this._sendUserMessage(n,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>i.reject(e))).onSucceeded((e=>i.resolve(e))),i.promise}))}updateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},qe),s);t.unless(t.isTypeOf("number",e)&&Fe(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Dt(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(qt);return o}))}copyUserMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Q&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters),t.unless(!s.poll).throw(t.SendbirdError.notSupportedError);const r=new t.Deferred,o=null!==(i=s.messageParams)&&void 0!==i?i:t.undefineNullProps(Object.assign(Object.assign({},s),{mentionType:s.mentionType,mentionedUserIds:null!==(n=s.mentionedUserIds)&&void 0!==n?n:null===(a=s.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)),translationTargetLanguages:Object.keys(s.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}));return e._sendUserMessage(o).onSucceeded((e=>{r.resolve(e)})).onFailed((e=>r.reject(e))),r.promise}))}translateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Qt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:s}),a=yield i.send(n),{message:r}=a.as(Gt);return r}))}_createScheduledUserMessage(e,s){const{requestQueue:i}=t.Vault.of(this._iid),n=Date.now(),a=this._generateRequestId();t.sleep(2).then((()=>{const i=this._createPendingScheduledUserMessage(e,a,n);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))}));const r=new Kt(Object.assign({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(r).then((e=>{const{message:i}=e.as(Ht);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((i=>{if(t.isThrowingOutside(i))throw i;t.sleep(2).then((()=>{const r=this._createPendingScheduledUserMessage(e,a,n);this._markMessageAsFailed(r,i),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(i,r)}))))}))}))}sendFileMessage(e){const s=Object.assign(Object.assign({},Ue),e);return t.unless(ke(s)).throw(t.SendbirdError.invalidParameters),this._sendFileMessage(s)}sendMultipleFilesMessage(e){var s;const i=Object.assign(Object.assign({},cs),e),n=t.Vault.of(this._iid);t.unless(((e,s=t.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT)=>Te(e)&&t.isTypeOf("string",e.message,!0)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=s&&e.fileInfoList.every((e=>hs(e))))(i,null===(s=n.appInfo)||void 0===s?void 0:s.multipleFilesMessageFileCountLimit)).throw(t.SendbirdError.invalidParameters);const a=!!e.fileInfoList.find((e=>{const t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return t.unless(!a).throw(t.SendbirdError.fileSizeLimitExceededError),this._sendMultipleFilesMessage(i)}_sendFileMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=zi.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?t.CollectionEventSource.LOCAL_MESSAGE_CANCELED:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendFileMessage(e){t.unless(e instanceof Y&&!!e.messageParams).throw(t.SendbirdError.invalidParameters);const{logger:s}=t.Vault.of(this._iid);return s.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId).onFailed((e=>{s.debug("autoResendFileMessage failed",e)})).onSucceeded((e=>{s.debug("autoResendFileMessage success",e)}))}_sendMultipleFilesMessage(e,s,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=zi.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new ps;return t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e,{requestHandler:l,isCopy:s===exports.SendMessageRequestType.COPY}).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);this._markMessageAsFailed(i,s),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_createScheduledFileMessage(e,s,i,n){const{requestQueue:a}=t.Vault.of(this._iid),r=new Wt(Object.assign(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(r).then((e=>{const{message:i}=e.as(Yt);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((a=>{if(t.isThrowingOutside(a))throw a;t.sleep(2).then((()=>{const r=this._createPendingScheduledFileMessage(e,i,n);this._markMessageAsFailed(r,a),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(a,r)}))))}))}))}sendFileMessages(e){t.unless(e.every((e=>ke(Object.assign(Object.assign({},Ue),e))))).throw(t.SendbirdError.invalidParameters);const s=new Ie;for(const t of e)this.sendFileMessage(t).onPending((e=>s._trigger(e))).onFailed(((e,t)=>s._triggerFailed(e,t))).onSucceeded((e=>s._trigger(e)));return s}resendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(e instanceof Y&&i&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const n=new t.Deferred,a=xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>n.reject(e))).onSucceeded((e=>n.resolve(e))),n.promise}))}resendMessage(e,s){var i,n;if(t.unless(e instanceof F&&!e.scheduledInfo&&e.isResendable).throw(t.SendbirdError.invalidParameters),e.isUserMessage()){const t=null!==(i=e.messageParams)&&void 0!==i?i:Oe(e);return this._sendUserMessage(t,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isFileMessage()){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(i).throw(t.SendbirdError.invalidParameters);const a=null!==(n=e.messageParams)&&void 0!==n?n:xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}updateFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},Be),s);t.unless(t.isTypeOf("number",e)&&(e=>De(e))(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Ft(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(Bt);return o}))}uploadFile(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),a=t.uuid(),r=new i({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a});r.uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a);const o=yield s.send(r),{url:l,thumbnails:d}=o.as(n);return{requestId:a,url:l,thumbnails:d}}))}cancelUploadingFileMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e)).throw(t.SendbirdError.invalidParameters);const{fileMessageQueue:s}=zi.of(this._iid);return s.cancel(this,e),!0}))}copyFileMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Y&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const r=new t.Deferred,o=t.undefineNullProps(Object.assign(Object.assign({},s),{fileUrl:s.url,fileName:s.name,fileSize:s.size,mimeType:s.type,mentionType:s.mentionType,mentionedUserIds:null!==(i=s.mentionedUserIds)&&void 0!==i?i:null===(n=s.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=s.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:s.requireAuth,isPinnedMessage:!1}));return e._sendFileMessage(o).onSucceeded((e=>r.resolve(e))).onFailed((e=>r.reject(e))),r.promise}))}copyMessage(e,s){t.unless(e instanceof Es&&s instanceof F&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=s,n=e;if(i.isUserMessage()){t.unless(!i.poll).throw(t.SendbirdError.notSupportedError);const e=Se(i);return n._sendUserMessage(e)}if(i.isFileMessage()){const e=Re(i);return n._sendFileMessage(e)}if(s.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}deleteMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){if(t.unless(e instanceof q).throw(t.SendbirdError.invalidParameters),e.messageId>0){const{requestQueue:s}=t.Vault.of(this._iid),i=new t.DeleteMessageRequestCommand({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof F?e._messageToken:void 0});yield s.send(i)}}))}addReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new jt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as(Vt);return r}))}deleteReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new zt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as($t);return r}))}_updateUserMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Dt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(qt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}_updateFileMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Ft({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(Bt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}createMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"add",!0):this._updateUserMessageMetaArray(e.messageId,i,"add",!0)}))}deleteMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"remove",!0):this._updateUserMessageMetaArray(e.messageId,i,"remove",!0)}))}addMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"add",!0):this._updateUserMessageMetaArray(e.messageId,s,"add",!0)}))}removeMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"remove",!0):this._updateUserMessageMetaArray(e.messageId,s,"remove",!0)}))}report(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isEnumOf(exports.ReportCategory,e)&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:n}=t.Vault.of(this._iid),a=new Ut({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:s});yield n.send(a)}))}reportUser(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof t.User&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new Rt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.userId,category:s,description:i});yield a.send(r)}))}reportMessage(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof F&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new xt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:s,description:i,messageToken:e._messageToken});yield a.send(r)}))}updatePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&(e=>t.isTypeOf("string",e.title,!0)&&t.validatePollData(e.data)&&t.isTypeOf("boolean",e.allowUserSuggestion,!0)&&t.isTypeOf("boolean",e.allowMultipleVotes,!0)&&t.isTypeOf("number",e.closeAt,!0))(s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Jt(Object.assign({pollId:e},s)),a=yield i.send(n),{poll:r}=a.as(Xt);return r}))}deletePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Zt({pollId:e});yield i.send(n)}))}closePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new es({pollId:e}),a=yield i.send(n),{poll:r}=a.as(ts);return r}))}addPollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("string",s)&&""!==s.trim();t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new ss({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:s}),r=yield n.send(a),{poll:o}=r.as(is);return o}))}updatePollOption(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const n=t.isTypeOf("number",e)&&t.isTypeOf("number",s)&&t.isTypeOf("string",i)&&""!==i.trim();t.unless(n).throw(t.SendbirdError.invalidParameters);const{requestQueue:a}=t.Vault.of(this._iid),r=new ns({pollId:e,pollOptionId:s,optionText:i}),o=yield a.send(r),{poll:l}=o.as(as);return l}))}deletePollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new rs({pollId:e,pollOptionId:s});yield n.send(a)}))}votePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isArrayOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n,dispatcher:a}=t.Vault.of(this._iid),r=new os({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:s}),o=yield n.send(r),{event:l}=o.as(ls);return a.dispatch(new t.PollVoteInternalEventCommand({event:l,source:t.CollectionEventSource.EVENT_POLL_VOTED})),l}))}getPollChangeLogsSinceTimestamp(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)).throw(t.SendbirdError.invalidParameters);const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}getPollChangeLogsSinceToken(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e,!0));const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}createPollListQuery(e=10){return new t.PollListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}createPollVoterListQuery(e,s,i=20){return new t.PollVoterListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:s,limit:i})}pinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new fs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}unpinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new vs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}}const Ts={};class bs{constructor({dbname:e,itemSizeLimit:t=1048576,cacheLimit:s=256,blockHashBase:i=2,blockHashMultiplier:n=10,blockHashConstant:a=11,transactionApplyDelay:r=200,disableLogger:o=!1}){return Ts[e]||(this.itemSizeLimit=t,this.cacheLimit=s,this.blockHashBase=i,this.blockHashMultiplier=n,this.blockHashConstant=a,this.transactionApplyDelay=r,this.disableLogger=o,Ts[e]=this),Ts[e]}static get(e){return Ts[e]}}var Ms,Ss;!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"}(Ms||(Ms={}));class Os extends Error{constructor({code:e=Ms.UNKNOWN_ERROR,message:t="Unknown error occurred."}){super(t),this.code=e,Object.setPrototypeOf(this,Os.prototype)}static get storeNotDefined(){return new Os({code:Ms.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}static get storeNotAvailable(){return new Os({code:Ms.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}static get storeNotAvailableInPrivateBrowsing(){return new Os({code:Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}static get storeIsFull(){return new Os({code:Ms.STORE_IS_FULL,message:"Store is full."})}static get storeNotInitialized(){return new Os({code:Ms.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}static get storeKeyTypeIsInvalid(){return new Os({code:Ms.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}static get storeBrokenIntegrity(){return new Os({code:Ms.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}static get storeBrokenBlob(){return new Os({code:Ms.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}static get storeEncryptionInvalid(){return new Os({code:Ms.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}static get storeItemSizeExceeded(){return new Os({code:Ms.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}static get storeReadFailed(){return new Os({code:Ms.STORE_READ_FAILED,message:"Failed to read from store."})}static get storeWriteFailed(){return new Os({code:Ms.STORE_WRITE_FAILED,message:"Failed to write to store."})}static get databaseSchemaNotOnUpgrade(){return new Os({code:Ms.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}static get collectionNotReady(){return new Os({code:Ms.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}static get collectionKeyNotMatch(){return new Os({code:Ms.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}static get collectionQueryNotValid(){return new Os({code:Ms.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}static get collectionInsertDuplicate(){return new Os({code:Ms.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}static get collectionKeyNotFound(){return new Os({code:Ms.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}static get collectionKeyNotGiven(){return new Os({code:Ms.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}static get collectionWriteFailed(){return new Os({code:Ms.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}static get collectionItemSizeExceeded(){return new Os({code:Ms.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}static get indexTableIsRequired(){return new Os({code:Ms.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}static get indexTypesNotMatch(){return new Os({code:Ms.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}static get compareTypesNotMatch(){return new Os({code:Ms.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}static get circularReferenceFound(){return new Os({code:Ms.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ss||(Ss={}));const As=(e,t=new WeakMap)=>{if("object"==typeof e&&null!==e){if(t.has(e))throw Os.circularReferenceFound;{let s;return t.set(e,!0),Array.isArray(e)?s=e.map((e=>As(e,t))):e instanceof RegExp||e instanceof Date?s=e:(s={},Object.keys(e).forEach((i=>{s[i]=As(e[i],t)}))),t.delete(e),s}}return e},Cs=(e,t)=>{if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Os.compareTypesNotMatch;let s=0;switch(typeof e){case"boolean":case"number":s=e-t;break;case"string":s=e.localeCompare(t)}return s},ws=(e,t)=>{let s=0;for(let t=0;t>>0)%t},Ns=e=>new Promise((t=>{setTimeout((()=>t()),e)})),Ps=(e,t)=>{if(!t)return!1;if("function"!=typeof e){for(const s in e)if(["/and","&&"].includes(s)){if(e[s].some((e=>!Ps(e,t))))return!1}else if(["/or","||"].includes(s)){if(e[s].every((e=>!Ps(e,t))))return!1}else if("/where"===s){if(!(0,e[s])(t))return!1}else{const i=s;if("object"==typeof e[i]){const s=e[i];for(const e in s)switch(e){case"/eq":case"=":if(t[i]!==s[e])return!1;break;case"/neq":case"!=":if(t[i]===s[e])return!1;break;case"/gt":case">":{const n=t[i],a=s[e];if(!(Cs(n,a)>0))return!1;break}case"/gte":case">=":{const n=t[i],a=s[e];if(!(Cs(n,a)>=0))return!1;break}case"/lt":case"<":{const n=t[i],a=s[e];if(!(Cs(n,a)<0))return!1;break}case"/lte":case"<=":{const n=t[i],a=s[e];if(!(Cs(n,a)<=0))return!1;break}case"/in":{const n=t[i];if(!s[e].includes(n))return!1;break}case"/nin":{const n=t[i];if(s[e].includes(n))return!1;break}case"/contain":{const n=t[i],a=s[e];if(!n.includes(a))return!1;break}case"/regex":{const n=t[i];if(!s[e].test(n))return!1;break}case"/where":{const n=t[i];if(!(0,s[e])(n))return!1;break}}}else if("function"==typeof e[i]){if(!e[i](t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}return e(t)},Us=()=>{},Rs=()=>Promise.resolve(),xs=e=>e,ks=(e,t)=>{t()};var Ls;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Ls||(Ls={}));class Ds{constructor({initialPrevValue:e=null,initialNextValue:t=null,iterator:s,map:i=xs,backward:n=Rs,forward:a=Rs,complete:r=Us}){this._prevValue=e,this._nextValue=t,this._error=null,this._map=i,this._backward=n,this._forward=a,this._iterator=s,this._complete=r}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 t.__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 t.__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 qs{constructor({condition:e={},backward:t=!1,blockManager:s,indexer:i}){this.condition=e,this.backward=t,this._blockManager=s,this._indexer=i}findOptimizedStartPosition(){const e=["=","/eq",">",">=","/gt","/gte"],t=["=","/eq","<","<=","/lt","/lte"];if(this.backward){let s=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(let i=0;i0?t:e;for(const e in this.condition[n])if(r.includes(e))for(let t=s;t>=0;t--)if(a*Cs(this._indexer.origin[t].columnValues[i],this.condition[n][e])<=0){s=t;break}}else for(let e=s;e>=0;e--)if(a*Cs(this._indexer.origin[e].columnValues[i],this.condition[n])<=0){s=e;break}}return Math.min(s+1,this._indexer.origin.length-1)}{let s=0;if("function"!=typeof this.condition)for(let i=0;i{if((a>0?e:t).includes(r))for(let e=s;e=0){s=e;break}}));else for(let e=s;e=0){s=e;break}}return Math.max(s-1,0)}}each(e){return t.__awaiter(this,void 0,void 0,(function*(){let s=this.findOptimizedStartPosition(),i=0;this.backward&&this._indexer.origin[s]&&(i=this._indexer.origin[s].keys.length-1);const n=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[++i]){if(!this._indexer.origin[++s])return!1;i=0}return!0}return!1},a=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[--i]){if(!this._indexer.origin[--s])return!1;i=this._indexer.origin[s].keys.length-1}return!0}return!1};let r=null;if(this._indexer.origin[s]){const e=this.backward?a:n;do{const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e)){r=e;break}}while(e())}return yield new Promise((o=>{const l=new Ds({initialNextValue:As(r),iterator:e,forward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?a:n;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return As(e)}return null})),backward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?n:a;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return As(e)}return null})),complete:o});e(l)}))}))}}class Fs{constructor({condition:e={},backward:t=!1,mutex:s,blockManager:i,indexer:n}){this._mutex=s,this._iterator=new qs({condition:e,backward:t,blockManager:i,indexer:n})}fetch(e={}){return t.__awaiter(this,void 0,void 0,(function*(){let s=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 Os.collectionQueryNotValid;try{const e=[];return yield this._mutex.lock(),yield this._iterator.each((n=>t.__awaiter(this,void 0,void 0,(function*(){n.error?n.stop():n.hasNext?0===s?(e.push(n.nextValue),0t.__awaiter(this,void 0,void 0,(function*(){s.error?s.stop():s.hasNext?(e++,s.next()):s.stop()})))),this._mutex.unlock(),e}catch(e){throw this._mutex.unlock(),e}}))}}const Bs=e=>`nest@${e}`,js=(e,t)=>`${Bs(e)}/${t}`,Vs=(e,t)=>`${js(e,t)}.metadata`,zs=(e,t)=>`${js(e,t)}/block.`,$s=(e,t)=>`${js(e,t)}/blob.`;class Qs{constructor({dbname:e,collectionName:t,store:s}){this.dbname=e,this.collectionName=t,this.store=s}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.store.get(e);if(t){const{data:e,type:s}=t;if("undefined"!=typeof fetch){const t=yield fetch(e);return yield t.blob()}{const t=512,i=[],n=atob(e.split(",")[1]);for(let e=0;e{const i=((e,t,s,i=0)=>`${$s(e,t)}${s}.${i}`)(this.dbname,this.collectionName,s),n=new FileReader;n.onload=()=>{t({blobId:i,data:n.result,type:e.type})},n.readAsDataURL(e)}));return yield this.store.set({key:t,value:{data:i,type:n}}),t}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this.store.remove(e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=$s(this.dbname,this.collectionName),s=yield this.store.getAllKeys();yield Promise.all(s.filter((t=>t.startsWith(e))).map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this.store.remove(e)})))))}))}}var Gs,Ks,Hs;!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Gs||(Gs={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Ks||(Ks={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Hs||(Hs={}));const Ws=[Ks.PENDING,Ks.VOLATILE],Ys={};class Js{constructor({dbname:e,limit:t=256}){return Ys[e]||(this.dbname=e,this._items=[],this._limit=t,Ys[e]=this),Ys[e]}static get(e){return Ys[e]}get items(){return this._items}find(e,s,i=Hs.DEFAULT){return t.__awaiter(this,void 0,void 0,(function*(){let t=this.get(s);if(t)i===Hs.PERSISTENT&&(t.state=Ks.PERSISTENT);else{const n=yield e.get(s);n&&(t={key:s,value:n,state:i===Hs.PERSISTENT?Ks.PERSISTENT:Ks.VOLATILE},this.put(t))}return t}))}get(e,t=Hs.DEFAULT){const s=this._items.map((e=>e.key)).indexOf(e);if(s>-1){const e=this._items[s];return t===Hs.PERSISTENT&&(e.state=Ks.PERSISTENT),t!==Hs.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)Ws.includes(this._items[t].state)&&Ws.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===Ks.VOLATILE));let s=t.length-this._limit;if(s>0){const e=[];for(const t of this._items)t.state===Ks.VOLATILE&&s>0?s--: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)))}clearForDatabase(e){this.clearByCondition((t=>t.key.startsWith(Bs(e))))}clear(e=!1){this._items=e?[]:this._items.filter((e=>e.state!==Ks.VOLATILE))}}class Xs{constructor({dbname:e,collectionName:t,store:s}){this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=e,this.collectionName=t,this.metadataKey=((e,t)=>`${js(e,t)}/trans.metadata`)(e,t),this.recordsetKey=((e,t)=>`${js(e,t)}/trans.recordset`)(e,t),this._store=s}get generation(){return this._metadata?this._metadata.generation:0}get requestCount(){return this._requests.length}_getReducedRecordset(e=[]){return t.__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=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=[];for(let e=n.requests.length-1;e>=0;e--){const t=n.requests[e],i=t.data;s[i.key]||(a.unshift(t),s[i.key]=!0)}a.length>0&&(n.requests=a,t.unshift(n))}return t}_applyRecord(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname),{generation:i,requests:n}=s;let a=null;try{const e=yield this._store.setMany(n.map((e=>Object.assign(Object.assign({},e.data),{generation:i}))));for(let s=0;s{a&&e(a)}));else{const t=e.filter((e=>e.generation!==i));yield this._store.set({key:this.recordsetKey,value:t}),this._onWrite.forEach((e=>{e(n.map((e=>e.data)))}))}}))}init(){return t.__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,s){switch(e){case Gs.COMMIT:this._onCommit.set(t,s);break;case Gs.WRITE:this._onWrite.set(t,s);break;case Gs.ERROR:this._onError.set(t,s)}}requestWrite(e,t){this._requests.push({data:e,options:t});Js.get(this.dbname).put(Object.assign({state:Ks.PENDING},e))}requestMultipleWrite(e,t){const s=Js.get(this.dbname);for(const i of e)this._requests.push({data:i,options:t}),s.put(Object.assign({state:Ks.PENDING},i))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).clearByCondition((e=>e.state===Ks.PENDING)),this._requests=[]}))}commit(){return t.__awaiter(this,void 0,void 0,(function*(){const e=this._requests;if(e.length>0){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=n.data;s[a.key]||(s[a.key]=!0,t.unshift(n))}const i={generation:this.generation,requests:t},n=yield this._getReducedRecordset([i]);yield this._store.set({key:this.recordsetKey,value:n}),this._metadata.generation++,yield this._store.set({key:this.metadataKey,value:this._metadata});const a=Js.get(this.dbname);for(let e=0;e{t(e.map((e=>e.data)))}));const r=bs.get(this.dbname);setTimeout((()=>{try{this._applyRecord(n,i)}catch(e){this._onError.forEach((t=>t(e)))}}),r.transactionApplyDelay)}}))}}class Zs{constructor({blockId:e,keyName:t,items:s=[],limit:i}){this.blockId=e,this.keyName=t,this.limit=i,this._items=[...s]}static createFromCacheItem(e){return e?new Zs(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 s=t[this.keyName];return e===s}));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 i=s.base*Math.pow(s.multiplier,t)+s.constant;return(s.hashFunction||ws)(e,i)})(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})}`,`${zs(s,i)}${n}.${a}`;var s,i,n,a}_findBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname);for(let s=this.metadata.blockLevel;s>0;s--){const i=this.createBlockId(e,s),n=yield t.find(this._store,i);if(n){const t=Zs.createFromCacheItem(n);if(null==t?void 0:t.getItemByKey(e))return t}}return null}))}getFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return t?t.getItemByKey(e):null}))}putToBlock(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=bs.get(this.dbname),i=this.createBlockId(e),n=Math.floor(this._store.itemSizeLimit/t.itemSizeLimit),a=Js.get(this.dbname),r=yield a.find(this._store,i),o=r?Zs.createFromCacheItem(r):new Zs({blockId:i,keyName:this.keyName,items:[],limit:n});return!!(null==o?void 0:o.add(s))&&(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),!0)}))}removeFromBlock(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const e=zs(this.dbname,this.collectionName),t=(yield this._store.getAllKeys()).filter((t=>t.startsWith(e)));yield this._store.removeMany(t),yield this._transaction.clear();Js.get(this.dbname).clearByCondition((t=>t.key.startsWith(e)))}))}}const ti=e=>{const t=typeof e;return null===e||"undefined"===t||"boolean"===t||"number"===t||"string"===t};class si{constructor({dbname:e,collectionName:t,keyName:s,fields:i,transaction:n,store:a}){this._origin=[],this._table=[];const r=((e,t,s)=>`${js(e,t)}/index.${s}`)(e,t,i.join(">"));this.dbname=e,this.collectionName=t,this.keyName=s,this.fields=i,this.indexerKey=r,this._store=a,this._transaction=n,this._transaction.on(Gs.COMMIT,this.indexerKey,(()=>this.commit())),this._transaction.on(Gs.ERROR,this.indexerKey,(()=>this.abort()))}static createKey(e){return e.join(">")}static parseKey(e){return e.split(">")}_addItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);return n?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:s,keys:[t]}),!0)}_removeItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);if(n){const e=this._table[i].keys.indexOf(t);if(e>-1)return this._table[i].keys.splice(e,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1}get origin(){return this._origin}get table(){return this._table}getColumnValues(e){const t=[];for(let s of this.fields){if("-"===s[0]&&(s=s.slice(1)),!ti(e[s]))throw Os.indexTypesNotMatch;t.push(e[s])}return t}diff(e,t){for(const s in this.fields){const i="-"===this.fields[s][0]?-1:1,n=Cs(e[s],t[s]);if(0!==n)return i*n}return 0}indexOf(e){if(this._table.length>0){let t=0,s=this._table.length-1;for(;t<=s;){const i=Math.floor((t+s)/2),n=this.diff(e,this._table[i].columnValues);if(n>0)t=i+1;else{if(!(n<0))return[i,!0];s=i-1}}return[t,!1]}return[0,!1]}ensure(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.dbname),t=yield e.find(this._store,this.indexerKey,Hs.PERSISTENT);if(t)this._origin=t.value,this._table=As(this._origin);else{const t=zs(this.dbname,this.collectionName),s=yield this._store.getAllKeys();for(const i of s)if(i.startsWith(t)){const t=yield e.find(this._store,i,Hs.NO_CACHE),s=Zs.createFromCacheItem(t);if(s)for(const e of s.items)this._addItem(e)}this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}}))}drop(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).remove(this.indexerKey),yield this._store.remove(this.indexerKey)}))}addItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}removeItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}clear(){return t.__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=As(this._origin)}abort(){this._table=As(this._origin)}}const ii=()=>"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product,ni=()=>{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)}))};var ai,ri;!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(ai||(ai={})),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"}(ri||(ri={}));const oi={};class li{constructor(e,t={}){return this._state=ai.PROCESSING,this._queue=[],this._activationQueue=[],oi[e]&&!t.forceCreate||(this.nodeId=ni(),this.key=e,ii()&&(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;if(!(null==t?void 0:t.isNestDbMessage))return;const{nodeId:s,requestId:i,key:n,op:a,data:r}=t;if(s!==this.nodeId&&n===this.key)switch(a){case ri.NEWNODE:this._sendSync();break;case ri.CLAIM_HOST:this._sendSync(),this._hostId=s;break;case ri.SYNC_HOST:if(!this.isInSync){this._activationTimeout&&clearTimeout(this._activationTimeout);const{currentItemRequestId:e,queue:t}=r;for(const e of t){this._queue.findIndex((t=>t.requestId===e.requestId))<0&&this._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:this.key,op:ri.REQUEST_LOCK,ts:e.ts})}this._currentItem=this._queue.find((t=>t.requestId===e)),this._completeSync()}break;case ri.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 ri.REQUEST_LOCK:this._requestLock(t);break;case ri.ACQUIRE_LOCK:{const e=this._queue.find((e=>e.requestId===i));this._acquire(e);break}case ri.RELEASE_LOCK:this._release(i)}})),window.addEventListener("beforeunload",(()=>{this._send(ri.REMOVENODE)}))),oi[e]=this),oi[e]}get locked(){return!!this._currentItem}get isHost(){return this._hostId===this.nodeId}get isInSync(){return this._state==ai.DONE}_send(e,t={}){var s;const i={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(s=null==t?void 0:t.requestId)&&void 0!==s?s:ni(),key:this.key,op:e,data:t.data,ts:Date.now()};return ii()&&window.postMessage(i,"*"),i}_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(ri.RELEASE_LOCK,{requestId:t.requestId});const s=this._queue.findIndex((t=>t.requestId===e));s>-1&&this._queue.splice(s,1),t.onReleased&&t.onReleased(e)}}_requestLock(e){return new Promise((t=>{const s={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:e=>{this.isHost&&this._send(ri.ACQUIRE_LOCK,{requestId:e}),t()},onReleased:()=>{this._acquire(this._queue[0])}};let i=!1;for(let e=0;es.ts){this._queue.splice(e,0,s),i=!0;break}i||this._queue.push(s),this._currentItem||this._acquire(this._queue[0])}))}_sendSync(){var e;this.isHost&&this._send(ri.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 t.__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=ai.DONE,this._activationQueue.forEach((e=>e())),this._activationQueue=[])}registerNode(){this._send(ri.NEWNODE),this._waitSync()}claimHost(){this._hostId=this.nodeId,this._send(ri.CLAIM_HOST),this._waitSync()}lock(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._waitUntilSyncCompleted();const e=this._send(ri.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)}}class di{constructor({dbname:e,collectionName:t,keyName:s,keyHash:i,indexes:n,store:a}){this._state=Ss.INIT,this._indexers=[],this.dbname=e,this.name=t,this.keyName=s,this.indexes=[[s],...n.filter((e=>si.createKey(e)!==this.keyName))],this._keyHash=i,this._store=a,this._mutex=new li(((e,t)=>`${js(e,t)}.lock`)(e,t)),this._blobContainer=new Qs({dbname:e,collectionName:t,store:a}),this._transaction=new Xs({dbname:e,collectionName:t,store:a})}static metadataOf(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const t=Vs(e,s);return yield i.get(t)}))}get state(){return this._state}get isReady(){return this._state===Ss.READY}init(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._mutex.lock();try{const e=bs.get(this.dbname),t=yield di.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 ei({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store});const s=[...this.indexes],i=[],n=s.map((e=>si.createKey(e))),a=t?t.indexes.map((e=>si.createKey(e))):[];for(const e of a)n.includes(e)||i.push(si.parseKey(e));const r=[];if(r.push(...s.map((e=>{const t=new si({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store});return this._indexers.push(t),t.ensure()}))),r.push(...i.map((e=>new si({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store}).drop()))),yield Promise.all(r),yield this._transaction.commit(),n.sort().join(",")!==a.sort().join(",")){const e=Vs(this.dbname,this.name);this._metadata.indexes=s,yield this._store.set({key:e,value:this._metadata})}this._state=Ss.READY,this._mutex.unlock()}catch(e){throw this._mutex.unlock(),e}}))}close(){this._state=Ss.CLOSED}_hasPropertyOfKeyName(e){const t=e[this.keyName];return"string"==typeof t&&!!t}_getIndexerBy(e=null){e||(e=[this.keyName]);const t=si.createKey(e);for(const e of this._indexers)if(t===si.createKey(e.fields))return e;throw Os.indexTableIsRequired}_upgradeBlockLevel(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Vs(this.dbname,this.name);this._metadata.blockLevel++,yield this._store.set({key:e,value:this._metadata})}))}_requestInsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName];if(yield this._blockManager.getFromBlock(t))throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}}))}_requestRemove(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){yield this._blockManager.clearAllBlocks();for(const e of this._indexers)yield e.clear()}))}getByKey(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{const t=yield this._blockManager.getFromBlock(e);return this._mutex.unlock(),As(t)}catch(e){throw this._mutex.unlock(),e}}))}query(e={}){if(this.isReady)return new Fs({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Os.collectionNotReady}insertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestInsert(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}insertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Os.collectionKeyNotGiven;for(const t of e)yield this._requestInsert(As(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestUpsert(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Os.collectionKeyNotGiven;for(const t of e)yield this._requestUpsert(As(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}update(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestUpdate(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}updateIf(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Os.collectionNotReady;yield this._mutex.lock();try{const{where:i={},index:n=null,backward:a=!1}=e,r=[],o=new qs({condition:i,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(n)});yield o.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;Ps(i,t)&&s.set&&("function"!=typeof s.set?Object.keys(s.set).forEach((e=>{var i;t[e]=null===(i=s.set)||void 0===i?void 0:i[e]})):s.set(t),r.push(t)),e.next()}else e.stop()}))));for(const e of r)yield this._requestUpdate(As(e));return yield this._transaction.commit(),this._mutex.unlock(),r}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Os.collectionNotReady;yield this._mutex.lock();try{const{where:s={},index:i=null,backward:n=!1}=e,a=[],r=new qs({condition:s,blockManager:this._blockManager,backward:n,indexer:this._getIndexerBy(i)});yield r.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(Ps(s,t)){const e=t[this.keyName];a.push(e)}e.next()}else e.stop()}))));for(const e of a)yield this._requestRemove(e);return yield this._transaction.commit(),this._mutex.unlock(),a}catch(e){throw this._mutex.unlock(),e}}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.get(e)}))}saveBlob(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.save(e,s)}))}removeBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.remove(e)}))}removeAllBlobs(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.clear()}))}}const ui="[NESTDB]";let ci=!0;class hi{static off(){ci=!1}static log(...e){ci&&console.log(`${ui}[LOG]`,...e)}static warning(...e){ci&&console.warn(`${ui}[WARNING]`,...e)}static error(...e){ci&&console.error(`${ui}[ERROR]`,...e)}}const pi=[{},{a:700400,n:"error"}];class mi{constructor(e){var s,i,n;this.encryption=null!==(s=e.encryption)&&void 0!==s?s:t.DEFAULT_ENCRYPTION,this.itemSizeLimit=null!==(i=e.itemSizeLimit)&&void 0!==i?i:4194304,this.metadataBuffer=null!==(n=e.metadataBuffer)&&void 0!==n?n:256}get _encryptionCheckKey(){return`${this.dbname}.encrypt`}get _reservedKeys(){return[this._encryptionCheckKey]}_getRawKey(e,t=""){return`${e}${t}`}_generateShardPostfixArray(e=1){return[...Array(e).keys()]}_shardify(e){const{key:t,value:s}=e,i=JSON.stringify(this.encryption.encrypt(s)),n=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(n).map((e=>{const s={key:this._getRawKey(t,`.${e}`),data:i.substring(e*this.adjustedItemSizeLimit,(e+1)*this.adjustedItemSizeLimit)};return 0===e&&(s.metadata={shards:n}),s}))}_resetIfEncryptionChanged(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.get(this._encryptionCheckKey),t={encrypted:pi.map((e=>{var t;return null===(t=this.encryption)||void 0===t?void 0:t.encrypt(e)}))};if(e)if(e.encrypted&&Array.isArray(e.encrypted))for(const s in e.encrypted){if(JSON.stringify(e.encrypted[s])!==JSON.stringify(t.encrypted[s])){hi.warning("Encryption algorithm has changed. Stored data would be cleared."),yield this.clear();break}}else yield this.clear();yield this.set({key:this._encryptionCheckKey,value:t})}))}get adjustedItemSizeLimit(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}usage(){return t.__awaiter(this,void 0,void 0,(function*(){let e=0;const t=yield this._getAllRawKeys();for(const s of t){const t=yield this._getRaw(s);t&&(e+=JSON.stringify(t).length)}return e}))}getAllKeys(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this._getAllRawKeys()).filter((e=>e.endsWith(".0"))).map((e=>e.replace(/\.0$/,""))).filter((e=>!this._reservedKeys.includes(e)))}))}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=this._getRawKey(e,".0"),i=yield this._getRaw(s);if(i)try{const{data:s,metadata:n}=i,a=(null==n?void 0:n.shards)&&n.shards>1?yield Promise.all(this._generateShardPostfixArray(null==n?void 0:n.shards).map((i=>t.__awaiter(this,void 0,void 0,(function*(){if(i>0){const t=this._getRawKey(e,`.${i}`),s=yield this._getRaw(t);if(!s)throw Os.storeBrokenIntegrity;return s.data}return s}))))):[s];return this.encryption.decrypt(JSON.parse(a.join("")))}catch(e){return null}return null}))}set(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._shardify(e);return yield this._setRaw(t),Object.assign({},e.value)}))}setMany(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const t=this._getRawKey(e,".0"),s=yield this._getRaw(t);if(s){const{metadata:t}=s,i=this._generateShardPostfixArray(null==t?void 0:t.shards).map((t=>this._getRawKey(e,`.${t}`)));yield this._removeRaw(i);const n=Js.get(this.dbname);return null==n||n.remove(e),!0}return!1}))}removeMany(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname),s=[];for(const i of e){const e=this._getRawKey(i,".0"),n=yield this._getRaw(e);if(n){const{metadata:e}=n;s.push(...this._generateShardPostfixArray(null==e?void 0:e.shards).map((e=>this._getRawKey(i,`.${e}`))))}null==t||t.remove(i)}return s.length>0&&(yield this._removeRaw(s)),e}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.dbname);null==e||e.clearForDatabase(this.dbname)}))}}const _i=1,gi={};class yi extends mi{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:4194304}));const{delay:s=_i}=e;this.delay=s,this.observer={}}get rawData(){return gi[this.dbname]}set rawData(e){gi[this.dbname]=e}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){if(gi[this.dbname])return Object.keys(gi[this.dbname]);throw Os.storeNotAvailable}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(gi[this.dbname])return yield Ns(this.delay),gi[this.dbname][e]?Object.assign({key:e},gi[this.dbname][e]):null;throw Os.storeNotAvailable}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!gi[this.dbname])throw Os.storeNotAvailable;yield Ns(this.delay);for(const t of e){const{key:e,data:s,metadata:i}=t;gi[this.dbname][e]=Object.freeze({data:s,metadata:i})}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!gi[this.dbname])throw Os.storeNotAvailable;yield Ns(this.delay);for(const t of e)gi[this.dbname][t]&&delete gi[this.dbname][t]}))}observe(e,t,s){this.observer[e]||(this.observer[e]={}),t.forEach((t=>this.observer[e][t]=s))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,gi[this.dbname]||(gi[this.dbname]={}),yield this._resetIfEncryptionChanged()}))}set(e){const s=Object.create(null,{set:{get:()=>super.set}});return t.__awaiter(this,void 0,void 0,(function*(){const t=this.observer[e.key];if(t&&"function"==typeof t.set){const e=t.set();if(e)throw e}return s.set.call(this,e)}))}setMany(e){const s=Object.create(null,{setMany:{get:()=>super.setMany}});return t.__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 s.setMany.call(this,e)}))}clear(){const e=Object.create(null,{clear:{get:()=>super.clear}});return t.__awaiter(this,void 0,void 0,(function*(){yield e.clear.call(this),yield Ns(this.delay),gi[this.dbname]={}}))}}const fi="NestDBStore";var vi;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(vi||(vi={}));var Ii,Ei,Ti;exports.NestDBState=void 0,(Ii=exports.NestDBState||(exports.NestDBState={})).INIT="INIT",Ii.OPENING="OPENING",Ii.OPENED="OPENED",Ii.CLOSED="CLOSED";exports.LogLevel=void 0,(Ei=exports.LogLevel||(exports.LogLevel={}))[Ei.VERBOSE=0]="VERBOSE",Ei[Ei.DEBUG=1]="DEBUG",Ei[Ei.INFO=2]="INFO",Ei[Ei.WARN=3]="WARN",Ei[Ei.ERROR=4]="ERROR",Ei[Ei.NONE=5]="NONE";class bi{constructor(e){var s,i,n,a;this.messageTypeFilter=null!==(s=null==e?void 0:e.messageTypeFilter)&&void 0!==s?s:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(i=null==e?void 0:e.customTypesFilter)&&void 0!==i?i:null,this.senderUserIdsFilter=null!==(n=null==e?void 0:e.senderUserIdsFilter)&&void 0!==n?n:null,this.replyType=null!==(a=null==e?void 0:e.replyType)&&void 0!==a?a:t.ReplyType.NONE}clone(){const e=new bi,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((s=>{e[s]=t[s]})),e}match(e){switch(this.messageTypeFilter){case t.MessageTypeFilter.USER:if(e.messageType!==t.MessageType.USER)return!1;break;case t.MessageTypeFilter.FILE:if(e.messageType!==t.MessageType.FILE)return!1;break;case t.MessageTypeFilter.ADMIN:if(e.messageType!==t.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof F))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof q)switch(this.replyType){case t.ReplyType.NONE:if(e.parentMessageId>0)return!1;break;case t.ReplyType.ONLY_REPLY_TO_CHANNEL:if(e instanceof F&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}}exports.MessageListOrder=void 0,(Ti=exports.MessageListOrder||(exports.MessageListOrder={})).CHANNEL_LATEST="channel_latest",Ti.NEWEST_CHILD_MESSAGE="newest_child_message";const Mi=e=>{switch(e){case exports.MessageListOrder.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Si=()=>["channelUrl","-createdAt","-notificationId"],Oi=Object.assign(Object.assign({},Me),{scheduledAt:void 0}),Ai=Object.assign(Object.assign({},Ee),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ci="UnsentMessage",wi={};class Ni extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),this._mutex=new li("unsendmessagecache.lock"),wi[e]=this}static of(e,t=!1){return wi[e]&&!t||(wi[e]=new Ni(e)),wi[e]}get collection(){const{nestdb:e}=this._cacheContext,s=null==e?void 0:e.collection(Ci);if(!s)throw t.SendbirdError.databaseError;return s}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){if(e.messageId>0)throw t.SendbirdError.invalidParameters;const s=Object.assign({},e.serialize());var i;return e instanceof Q?(e.messageParams&&(s.messageParams=be(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(i=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},be(i)),{scheduledAt:i.scheduledAt})))):e instanceof Y?(e.messageParams&&(s.messageParams=Pe(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(e=>Object.assign(Object.assign({},Pe(e)),{scheduledAt:e.scheduledAt}))(e.scheduledInfo.scheduledMessageParams))):e instanceof G&&e.messageParams&&(s.messageParams=(e=>t.deundefined({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}))(e.messageParams)),s}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return zi.of(this._iid).buildMessageFromSerializedData(e)}_deserializeWithMessageCreateParams(e){var s,i,n;return t.__awaiter(this,void 0,void 0,(function*(){const a=zi.of(this._iid),r=this._deserialize(e);if(e.messageParams)if(r instanceof Q){const t=e.messageParams;r.messageParams=a.buildUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.messageParams;t.fileKey&&"string"==typeof t.fileKey&&Ne(null!==(s=t.fileType)&&void 0!==s?s:"")&&(t.file=null!==(i=yield this.collection.getBlob(t.fileKey))&&void 0!==i?i:void 0),r.messageParams=a.buildFileMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof G){const s=e.messageParams;s&&s.fileInfoList&&(r.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(s,r),yield Promise.all(r.messageParams.fileInfoList.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t,s,i,n;"string"==typeof(null===(t=e._uploadedMetaData)||void 0===t?void 0:t.fileKey)&&Ne(null!==(i=null===(s=e._uploadedMetaData)||void 0===s?void 0:s.fileType)&&void 0!==i?i:"")&&(e.file=null!==(n=yield this.collection.getBlob(e._uploadedMetaData.fileKey))&&void 0!==n?n:void 0)}))))))}if(r.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)if(r instanceof Q){const t=e.scheduledInfo.scheduledMessageParams;r.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.scheduledInfo.scheduledMessageParams;t.fileKey&&"string"==typeof t.fileKey&&"string"==typeof t.fileType&&Ne(t.fileType)&&(t.file=null!==(n=yield this.collection.getBlob(t.fileKey))&&void 0!==n?n:void 0),r.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(t,r)}return r}))}_getFileInfoBlobKey(e,t){return`${e}.${t}`}get(e){return t.__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:s=new bi,order:i=exports.MessageListOrder.CHANNEL_LATEST,sendingStatus:n,backward:a=!1,parentMessageId:r}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const o=Mi(i),l={"/where":e=>!!(i!==exports.MessageListOrder.NEWEST_CHILD_MESSAGE||r&&0!==e.parentMessageId&&e.parentMessageId===r)&&s.match(this._deserialize(e))};e&&(l.channelUrl=e),n&&(l.sendingStatus=n);const d={where:l,index:o,backward:a},u=yield this.collection.query(d),c=yield u.fetch({});return Promise.all(c.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._deserializeWithMessageCreateParams(e)})))))}return[]}))}getAllChildMessages(e,s=new bi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){(e instanceof Y||e instanceof G)&&(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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__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 t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e}}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}saveBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y){if(e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}if(e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams){const t=e.scheduledInfo.scheduledMessageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}}else if(e instanceof G){const s=e.messageParams;s&&s.fileInfoList&&Array.isArray(s.fileInfoList)&&(yield Promise.all(s.fileInfoList.map(((s,i)=>t.__awaiter(this,void 0,void 0,(function*(){if(s.file&&we(s.file)){const t=yield this.collection.saveBlob(s.file,this._getFileInfoBlobKey(e.reqId,i));s._uploadedMetaData||(s._uploadedMetaData={}),s._uploadedMetaData.fileKey=t,s._uploadedMetaData.fileType=Ce.BLOB}}))))))}}))}}const Pi={};class Ui extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _unsentMessageCache(){return Ni.of(this._iid)}constructor(e){super(e),Pi[e]=this}static of(e,t=!1){return Pi[e]&&!t||(Pi[e]=new Ui(e)),Pi[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(ds)}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 zi.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new bi,order:a=exports.MessageListOrder.CHANNEL_LATEST,backward:r=!1,parentMessageId:o,isPollOnly:l=!1,exactMatch:d=!1,inclusive:u=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const c=Mi(a),h={where:{channelUrl:e,"/where":e=>{if(null!=s&&""!==s)switch(a){case exports.MessageListOrder.CHANNEL_LATEST:if(d&&e.createdAt!==s)return!1;if(r){if(u&&e.createdAts||!u&&e.createdAt>=s)return!1;break;case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:if(!o||0===e.parentMessageId||e.parentMessageId!==o)return!1}return!(l&&!e._poll)&&n.match(this._deserialize(e))}},index:c,backward:r},p=yield this.collection.query(h),m=yield p.fetch({limit:null!=i?i:void 0});return Promise.all(m.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return this._deserialize(e)})))))}return[]}))}getAllChildMessages(e,s=new bi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})}))}upsert(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.saveBlobs(e);for(const t of e)if(null===(s=t.threadInfo)||void 0===s?void 0:s._isUpdateRequired){const e=yield this.get(t.messageId);(null==e?void 0:e.threadInfo)&&t.threadInfo._updateFrom(e.threadInfo)}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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t;let s=[];(null===(t=e.threadInfo)||void 0===t?void 0:t.replyCount)&&e.threadInfo.replyCount>0&&(s=yield this.getAllChildMessages(e)),s.length>0&&(s.forEach((t=>t.applyParentMessage(e))),yield this.upsert(s))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(`${t}`)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:Mi(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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Mi(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=Mi(exports.MessageListOrder.CHANNEL_LATEST),n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}saveBlobs(e){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y&&e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s}}})))))}))}_getGroupChannelPreferenceSize(e){return t.__awaiter(this,void 0,void 0,(function*(){let t=0;const{preference:s}=this._cacheContext,i=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),n=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),a=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),r=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`);return i&&(t+=JSON.stringify(i).length),n&&(t+=JSON.stringify(n).length),a&&(t+=JSON.stringify(a).length),r&&(t+=JSON.stringify(r).length),t}))}}const Ri={};class xi extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),Ri[e]=this}static of(e,t=!1){return Ri[e]&&!t||(Ri[e]=new xi(e)),Ri[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(us)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){return Object.assign({},e.serialize())}_deserialize(e){return zi.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new bi,backward:a=!1,exactMatch:r=!1,inclusive:o=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t={where:{channelUrl:e,"/where":e=>{if(s){if(r&&e.createdAt!==s)return!1;if(a){if(o&&e.createdAts||!o&&e.createdAt>=s)return!1}return n.match(this._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:a},l=yield this.collection.query(t);return(yield l.fetch({limit:null!=i?i:void 0})).map((e=>this._deserialize(e)))}return[]}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=e.map((e=>this._serialize(e)));yield this.collection.upsertMany(t)}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}markAsReadByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.updateIf({where:{channelUrl:e,messageStatus:exports.NotificationMessageStatus.SENT,createdAt:{"<":s}}},{set:{messageStatus:exports.NotificationMessageStatus.READ}}))}))}markAsReadByMessageIds(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){return(yield this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":s},messageStatus:exports.NotificationMessageStatus.SENT}},{set:{messageStatus:exports.NotificationMessageStatus.READ}})).length}return 0}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]});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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Mi(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=["channelUrl","-createdAt","-notificationId"],n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}}const ki={};class Li extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _dispatcher(){return t.Vault.of(this._iid).dispatcher}get _messageCache(){return Ui.of(this._iid)}get _unsentMessageCache(){return Ni.of(this._iid)}get _notificationCache(){return xi.of(this._iid)}constructor(e){super(e),this._observers=new Map,this._dispatcherContext=this._dispatcher.on((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof t.MessageUpdateEventCommand){const{messages:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&e.messageId>0)),r=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&0===e.messageId)),o=s.filter((e=>e instanceof H));a.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.upsert(a),yield this._unsentMessageCache.remove(a.map((e=>e instanceof F?e.reqId:null)).filter((e=>null!==e)))})))),n||this._broadcastUpdateEvent(a,i)),r.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.upsert(r)})))),n||this._broadcastUpdateEvent(r,i)),o.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._notificationCache.upsert(o)})))),n||this._broadcastUpdateEvent(o,i))}else if(e instanceof t.MessageRemoveEventCommand){const{messageIds:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>"number"==typeof e)),r=s.filter((e=>"string"==typeof e));yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){a.length>0&&(yield this._messageCache.remove(a)),r.length>0&&(yield this._notificationCache.remove(r))})))),n||this._broadcastRemoveEvent(s,i)}else if(e instanceof t.UnsentMessageRemoveEventCommand){const{reqId:s,source:i}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([s])})))),this._broadcastRemoveUnsentEvent(s,i)}else if(e instanceof t.PollChangeLogEventCommand){const{polls:s,source:i}=e;if(this._cacheContext.localCacheEnabled){const e=s.map((e=>e.messageId)),i=(yield Promise.all(e.map((e=>this._messageCache.get(e))))).filter((e=>e));i.length>0&&s.forEach((e=>{const t=i.find((t=>t.messageId===e.messageId));t&&t.applyPoll(e)})),yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert(i)}))))}this._broadcastPollChangeLogEvent(s,i)}else if(e instanceof t.PollUpdateInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollUpdateEvent(s,i)}else if(e instanceof t.PollVoteInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollVoteEvent(s,i)}else if(e instanceof t.ReactionUpdateEventCommand){const{event:t,source:s}=e;t.messageId>0&&this._broadcastReactionUpdateEvent(t,s)}else if(e instanceof t.ThreadUpdateEventCommand){const{event:t,source:s}=e;this._broadcastThreadUpdateEvent(t,s)}}))))}static of(e,t=!1){var s;return ki[e]&&!t||(ki[e]&&(null===(s=ki[e]._dispatcherContext)||void 0===s||s.close()),ki[e]=new Li(e)),ki[e]}_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)}_broadcastReactionUpdateEvent(e,t){for(const s of this._observers.values())s.onReactionUpdate&&s.onReactionUpdate(e,t)}_broadcastThreadUpdateEvent(e,t){for(const s of this._observers.values())s.onThreadInfoUpdate&&s.onThreadInfoUpdate(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const Di=20;class qi extends t.APIRequestCommand{constructor(e){const{reverse:s=!1,limit:i=Di,keys:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}`,this.params=t.deundefined({token:a,limit:i,reverse:s,order:t.MessageTemplateListOrder.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:n})}}class Fi extends t.APIResponseCommand{constructor(e,t){super(e,t);const{next:s,has_more:i=!1,templates:n}=t;this.nextToken=s,this.hasMore=i,this.templates=n.map((e=>({template:JSON.stringify(e)})))}}class Bi extends t.APIRequestCommand{constructor(e){const{key:s}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}/${s}`}}class ji extends t.APIResponseCommand{constructor(e,t){super(e,t),this.template=JSON.stringify(t)}}const Vi={};class zi{constructor(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}){this._iid=e,this._sdkState=t,this._requestQueue=i,this._dispatcher=s,this._cacheContext=a,Ui.of(e),Ni.of(e),Li.of(e),this.fileMessageQueue=new ne(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}),Vi[e]=this}static of(e){return Vi[e]}buildMessageFromSerializedData(e){const s=t.deserialize(e);if(s.notificationId)return new H(this._iid,H.payloadify(s));switch(s.messageType){case t.MessageType.USER:return new Q(this._iid,Q.payloadify(s));case t.MessageType.FILE:return G._isMultipleFilesMessageSerializedData(s)?new G(this._iid,G.payloadify(s)):new Y(this._iid,Y.payloadify(s));case t.MessageType.ADMIN:return new V(this._iid,V.payloadify(s))}throw t.SendbirdError.invalidParameters}buildUserMessageCreateParamsFromSerializedData(e,s){return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,message:s.message,translationTargetLanguages:Object.keys(s.translations),pollId:e.pollId}))}buildFileMessageCreateParamsFromSerializedData(e,s){var i;return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,file:e.file,fileKey:e.fileKey,fileUrl:s.plainUrl,fileName:s.name,fileSize:s.size,mimeType:s.type,thumbnailSizes:null===(i=s.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),fileType:e.fileType,requireAuth:s.requireAuth}))}buildMultipleFilesMessageCreateParamsFromSerializedData(e,s){return t.deundefined({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,fileInfoList:e.fileInfoList.map((e=>new J(this._iid,e)))})}buildScheduledUserMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildScheduledFileMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildSenderFromSerializedData(e){const s=t.deserialize(e);return new p(this._iid,p.payloadify(s))}getMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new de(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ue);return i}))}getScheduledMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new _e(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ge);return i}))}getMessagesByMessageId(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,token:String(i)},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}getMessagesByTimestamp(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}_getMessagesByTimestampForCollection(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE,r,o){return t.__awaiter(this,void 0,void 0,(function*(){const l=new ce(Object.assign(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n),{checkingHasNext:r,checkingContinuousMessages:o})),d=yield this._requestQueue.send(l),{messages:u,isContinuousMessages:c,hasNext:h}=d.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:u,source:a})),{messages:u,isContinuousMessages:c,hasNext:h}}))}getThreadedMessagesByTimestamp(e,s,i,n=t.CollectionEventSource.REQUEST_THREADED_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const a=new ce(Object.assign(Object.assign(Object.assign({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:s},B),i),{replyType:t.ReplyType.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),r=yield this._requestQueue.send(a),{messages:o}=r.as(he),l=o.slice(1);return l.forEach((t=>{t.parentMessage=e})),this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:n})),{parentMessage:o[0],threadedMessages:l}}))}getMessageTemplatesByToken(e,s={}){return t.__awaiter(this,void 0,void 0,(function*(){const t=new qi(Object.assign({token:e},s)),i=yield this._requestQueue.send(t),{hasMore:n,nextToken:a,templates:r}=i.as(Fi);return{hasMore:n,token:a,templates:r}}))}getMessageTemplate(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new Bi({key:e}),s=yield this._requestQueue.send(t),{template:i}=s.as(ji);return{template:i}}))}getMessageChangelogs(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS){return t.__awaiter(this,void 0,void 0,(function*(){const r=new pe(t.deundefined(t.undefineNullProps(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},oe),n)))),o=yield this._requestQueue.send(r),{updatedMessages:l,deletedMessagesInfo:d,hasMore:u,nextToken:c}=o.as(me),h=d.map((e=>e.messageId));return l.length>0&&this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),h.length>0&&this._dispatcher.dispatch(new t.MessageRemoveEventCommand({messageIds:h,source:a})),{updatedMessages:l,deletedMessageIds:h,hasMore:u,token:c}}))}}class $i extends t.InstancedObject{constructor(e,s){super(e),this.targetMessageId=0;const i=s.thread_info,n=s.parent_message_id,r=s.channel_url,o=s.channel_type;i&&t.isTypeOf("object",i)&&t.isTypeOf("number",n)&&t.isTypeOf("string",r)&&t.isTypeOf("string",o)&&(this.threadInfo=new a(e,i),this.targetMessageId=n,this.channelUrl=r,this.channelType=o)}}const Qi={channelUrl:"",channelType:t.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1};class Gi extends t.APIRequestCommand{constructor({channelCustomType:e,keyword:s,limit:i,reverse:n,exactMatch:a,channelUrl:r,order:o,messageTimestampFrom:l,messageTimestampTo:d,advancedQuery:u,targetFields:c,nextToken:h}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_SEARCH}/messages`,this.params={custom_type:e,query:s,limit:i,reverse:n,exact_match:a,channel_url:r,message_ts_from:l,message_ts_to:d,sort_field:o,advanced_query:u,target_fields:c,after:h}}}class Ki extends t.APIResponseCommand{constructor(e,t){super(e,t),this.messages=t.results.map((t=>W(e,t))),this.hasNext=t.has_next,this.nextToken=t.end_cursor,this.totalCount=t.total_count}}var Hi;exports.MessageSearchOrder=void 0,(Hi=exports.MessageSearchOrder||(exports.MessageSearchOrder={})).SCORE="score",Hi.TIMESTAMP="ts";class Wi extends t.BaseListQuery{constructor(e,t){var s,i,n,a,r,o,l,d,u;super(e,t),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=t.keyword,this.reverse=null!==(s=t.reverse)&&void 0!==s&&s,this.exactMatch=null!==(i=t.exactMatch)&&void 0!==i&&i,this.channelUrl=null!==(n=t.channelUrl)&&void 0!==n?n:"",this.channelCustomType=null!==(a=t.channelCustomType)&&void 0!==a?a:"",this.messageTimestampFrom=null!==(r=t.messageTimestampFrom)&&void 0!==r?r:null,this.messageTimestampTo=null!==(o=t.messageTimestampTo)&&void 0!==o?o:null,this.order=null!==(l=t.order)&&void 0!==l?l:exports.MessageSearchOrder.SCORE,this.advancedQuery=null!==(d=t.advancedQuery)&&void 0!==d&&d,this.targetFields=null!==(u=t.targetFields)&&void 0!==u?u:null}_validate(){return super._validate()&&t.isTypeOf("string",this.keyword)&&this.keyword.length>0&&t.isTypeOf("boolean",this.reverse)&&t.isTypeOf("boolean",this.exactMatch)&&t.isTypeOf("string",this.channelUrl)&&t.isTypeOf("string",this.channelCustomType)&&(t.isTypeOf("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(t.isTypeOf("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&t.isEnumOf(exports.MessageSearchOrder,this.order)&&t.isTypeOf("boolean",this.advancedQuery)&&t.isArrayOf("string",this.targetFields,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Gi(t.undefineNullProps(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),i=yield e.send(s),{messages:n,hasNext:a,nextToken:r,totalCount:o}=i.as(Ki);return this._nextToken=r,this._hasNext=a,this._isLoading=!1,this.totalCount=o,n}return[]}throw t.SendbirdError.invalidParameters}))}}exports.AdminMessage=V,exports.AppleCriticalAlertOptions=u,exports.BanUserEventCommand=At,exports.BannedUserListQuery=Ye,exports.BaseChannel=Es,exports.BaseMessage=q,exports.BaseMessageUpdateParamsDefault=Le,exports.BaseStore=mi,exports.Config=bs,exports.CreateScheduledUserMessageResponseCommand=Ht,exports.DEFAULT_FEED_LIMIT=100,exports.DEFAULT_GROUPCHANNEL_LIMIT=100,exports.DEFAULT_MESSAGE_LIMIT=100,exports.DEFAULT_NOTIFICATION_LIMIT=100,exports.Feedback=h,exports.FileMessage=Y,exports.FileMessageEventCommand=ee,exports.FreezeEventCommand=Pt,exports.IndexedDbStore=class extends mi{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:104857600})),this._storeName=fi,this._state=vi.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}isTransactionInactiveError(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}_putToObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.put(s);n.addEventListener("success",(e=>{t(e.target.result)})),n.addEventListener("error",(()=>{i("Failed to write.")}))}))}))}_deleteFromObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.delete(s);n.addEventListener("success",(()=>t(s))),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_openDatabase(e){return new Promise(((t,s)=>{if(this._indexedDb){this._state=vi.OPENING;const i=this._indexedDb.open(e);i.addEventListener("upgradeneeded",(e=>{e.target.result.createObjectStore(fi,{keyPath:"key"})})),i.addEventListener("success",(s=>{this._state=vi.OPEN,this._database=s.target.result,this._openJobQueue.forEach((e=>e())),this._openJobQueue=[],this._database.onclose=()=>{this._database=void 0,this._state=vi.OPENING,setTimeout((()=>{this._openDatabase(e)}),5)},t(this._database)})),i.addEventListener("error",(e=>{this._state=vi.UNINITIALIZED,s(e.target.error)}))}else s(Os.storeNotAvailable)}))}_getObjectStore(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);switch(this._state){case vi.UNINITIALIZED:case vi.OPEN:throw Os.storeNotInitialized;case vi.OPENING:case vi.CLOSED:return new Promise((t=>{this._openJobQueue.push((()=>t(this._getObjectStore(e))))}));default:return yield this._getObjectStore(e)}}))}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readonly");return yield new Promise(((t,s)=>{const i=e.getAllKeys();i.addEventListener("success",(e=>{t(e.target.result)})),i.addEventListener("error",(e=>s(e.target.error)))}))}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readonly");return yield new Promise(((s,i)=>{const n=t.get(e);n.addEventListener("success",(e=>{var t;s(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._putToObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._putToObjectStore(t,s)}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._deleteFromObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._deleteFromObjectStore(t,s)}}))}_triggerDatabaseClose(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}checkAvailability(){return t.__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 Os.storeNotAvailable;if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!ii())throw Os.storeNotAvailable;if(ii()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")){if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Os.storeNotAvailableInPrivateBrowsing}else yield new Promise(((e,t)=>{if(this._indexedDb)try{const s=this._indexedDb.open("_testMozilla");s.onerror=()=>t(Os.storeNotAvailableInPrivateBrowsing),s.onsuccess=s=>{if(s.target.result.close(),this._indexedDb){const t=this._indexedDb.deleteDatabase("_testMozilla");t.onerror=()=>e(),t.onsuccess=()=>e()}else t(Os.storeNotAvailable)}}catch(e){t(Os.storeNotAvailableInPrivateBrowsing)}else t(Os.storeNotAvailable)}))}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yield this.checkAvailability(),yield this._openDatabase(e),yield this._resetIfEncryptionChanged()}))}clear(){const e=Object.create(null,{clear:{get:()=>super.clear}});return t.__awaiter(this,void 0,void 0,(function*(){yield e.clear.call(this);const t=yield this._getObjectStore("readwrite");return yield new Promise(((e,s)=>{const i=t.clear();i.addEventListener("success",(()=>e())),i.addEventListener("error",(e=>s(e.target.error)))}))}))}},exports.Logger=class{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)}},exports.MemoryStore=yi,exports.MessageBroadcast=Li,exports.MessageCache=Ui,exports.MessageFilter=bi,exports.MessageForm=k,exports.MessageFormItem=L,exports.MessageManager=zi,exports.MessageMetaArray=m,exports.MessageRequestHandler=Ie,exports.MessageRetrievalParamsDefault=Qi,exports.MessageReviewInfo=$,exports.MessageSearchQuery=Wi,exports.MessageThreadInfoUpdatedEventCommand=N,exports.MultipleFilesMessage=G,exports.MultipleFilesMessageRequestHandler=ps,exports.MuteUserEventCommand=bt,exports.MutedUserListQuery=Ke,exports.NESTDB_FEEDCHANNEL_COLLECTION_KEY="url",exports.NESTDB_FEEDCHANNEL_COLLECTION_NAME="FeedChannel",exports.NESTDB_GROUPCHANNEL_COLLECTION_KEY="url",exports.NESTDB_GROUPCHANNEL_COLLECTION_NAME="GroupChannel",exports.NESTDB_MESSAGE_COLLECTION_KEY="messageId",exports.NESTDB_MESSAGE_COLLECTION_NAME=ds,exports.NESTDB_NOTIFICATION_COLLECTION_KEY="notificationId",exports.NESTDB_NOTIFICATION_COLLECTION_NAME=us,exports.NESTDB_POLL_COLLECTION_KEY="pollId",exports.NESTDB_POLL_COLLECTION_NAME="Poll",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY="reqId",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME=Ci,exports.NestDB=class{constructor({name:e,version:t,store:s,config:i}){this.name=e,this._version=t,this._state=exports.NestDBState.INIT,this._config=i||new bs({dbname:e}),this._store=s,this._event={success:Us,error:Us,storeReplaced:Us,upgrade:ks},this._collections=new Map,this._globalMutex=new li(`${this.name}.lock`),this._config.disableLogger&&hi.off(),new Js({dbname:e,limit:this._config.cacheLimit})}get version(){return this._version}get state(){return this._state}get store(){return this._store}estimateUsage(){return t.__awaiter(this,void 0,void 0,(function*(){return yield(e=this._store,t.__awaiter(void 0,void 0,void 0,(function*(){return yield e.usage()})));var e}))}commitSchema(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._state!==exports.NestDBState.OPENING)throw Os.databaseSchemaNotOnUpgrade;yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){const{collectionName:t,keyName:s,index:i=[]}=e;this._collections.has(t)||this._collections.set(t,new di({dbname:this.name,collectionName:t,keyName:s,indexes:i,store:this._store}));const n=this._collections.get(t);n&&(yield n.init())})))))}))}open(){var e;return t.__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=(s=this.name,`${Bs(s)}.metadata`),n={version:0,collectionNames:[]},a=null!==(e=yield this._store.get(i))&&void 0!==e?e:n;return new Promise(((e,s)=>{const n=e=>{a.versiont.__awaiter(this,void 0,void 0,(function*(){if(s)e({continued:!1,err:s});else{a.version++,a.collectionNames=Array.from(this._collections.keys());try{yield this._store.set({key:i,value:a}),e({continued:!0})}catch(t){e({continued:!1,err:t})}}})))):e({continued:!1})},r=i=>{const{continued:o=!1,err:l=null}=i;if(o)setTimeout((()=>n(r)),10);else if(l)hi.error(l.message),this._globalMutex.unlock(),this._event.error(l),s(l);else{const i=[];a.collectionNames.forEach((e=>{const s=this._collections.get(e);s&&s.state===Ss.READY||i.push((()=>t.__awaiter(this,void 0,void 0,(function*(){const t=yield di.metadataOf(this.name,e,this._store);if(t){const s=new di({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:t.indexes,store:this._store});this._collections.set(e,s),yield s.init()}})))())})),Promise.all(i).then((()=>{this._state=exports.NestDBState.OPENED,this._globalMutex.unlock(),this._event.success(),e()})).catch((e=>{hi.error(e.message),this._globalMutex.unlock(),this._event.error(e),s(e)}))}};n(r)}))}catch(e){switch(e.code){case Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:hi.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new yi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;case Ms.STORE_NOT_AVAILABLE:hi.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 yi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;default:throw hi.error(e.message),this._globalMutex.unlock(),this._event.error(e),e}}}var s}))}close(){this._collections.forEach((e=>e.close())),this._state=exports.NestDBState.CLOSED}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this._collections.values()).map((e=>e.clear())))}))}reset(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.name);e&&e.clearForDatabase(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]=ks;else this._event[e]=Us}collection(e){const t=this._collections.get(e);if(t)return t;throw Os.collectionNotReady}},exports.NestDBError=Os,exports.NotificationMessage=H,exports.NotificationMessageCache=xi,exports.OGImage=l,exports.OGMetaData=d,exports.OperatorListQuery=ze,exports.PENDING_MESSAGE_DELAY=2,exports.PinnedMessage=ms,exports.PinnedMessageListQuery=ys,exports.Plugin=z,exports.PollVoteEventCommand=ls,exports.PreviousMessageListQuery=$e,exports.Reaction=o,exports.ReactionEvent=r,exports.ReadAPIRequestCommand=v,exports.ReadAPIResponseCommand=E,exports.ReadEventCommand=I,exports.ReadRequestCommand=f,exports.ReadStatus=y,exports.RestrictedUser=ve,exports.RestrictionInfo=fe,exports.ScheduledFileMessageCreateParamsDefault=Ai,exports.ScheduledUserMessageCreateParamsDefault=Oi,exports.SendableMessage=F,exports.Sender=p,exports.ThreadInfo=a,exports.ThreadInfoUpdateEvent=$i,exports.Thumbnail=s,exports.UnbanUserEventCommand=wt,exports.UnmuteUserEventCommand=St,exports.UnsentMessageCache=Ni,exports.UpdateFileMessageEventCommand=Bt,exports.UpdateMetaCounterEventCommand=vt,exports.UpdateMetaDataEventCommand=lt,exports.UpdateUserMessageEventCommand=qt,exports.UploadFileRequestCommand=i,exports.UploadFileResponseCommand=n,exports.UploadedFileInfo=w,exports.UserMessage=Q,exports.UserMessageEventCommand=Lt,exports.UserMessageUpdateParamsDefault=qe,exports.createFileMessageCreateParams=Re,exports.createFileMessageCreateParamsFromFailedFileMessage=xe,exports.createMultipleFilesMessageCreateParams=function(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((e=>{var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((e=>({maxWidth:e.width,maxHeight:e.height}))),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))},exports.createUserMessageCreateParams=Se,exports.createUserMessageCreateParamsFromFailedUserMessage=Oe,exports.getMessageIndexBy=Mi,exports.getNotificationMessageIndexBy=Si,exports.parseMessagePayload=W,exports.payloadifyMessage=e=>{if(e.notificationId)return H.payloadify(e);switch(e.messageType){case t.MessageType.USER:return Q.payloadify(e);case t.MessageType.FILE:return e.fileInfoList?G.payloadify(e):Y.payloadify(e);case t.MessageType.ADMIN:return V.payloadify(e);default:throw t.SendbirdError.unknown}},exports.validateBaseMessageUpdateParams=De,exports.validateMessageRetrievalParams=e=>t.isTypeOf("string",e.channelUrl)&&t.isEnumOf(t.ChannelType,e.channelType)&&t.isTypeOf("number",e.messageId)&&t.isTypeOf("boolean",e.includeReactions,!0)&&t.isTypeOf("boolean",e.includeMetaArray,!0)&&t.isTypeOf("boolean",e.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",e.includeThreadInfo,!0),exports.validateScheduledFileMessageCreateParams=e=>Te(e)&&t.isTypeOf("number",e.scheduledAt)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),exports.validateScheduledUserMessageCreateParams=e=>Ae(e)&&t.isTypeOf("number",e.scheduledAt,!0),exports.validateUserMessageUpdateParams=Fe; +var e,t=require("./__bundle-2d1d7d4f.cjs");class s{constructor(e,t,s){var i,n;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(i=t.real_width)&&void 0!==i?i:t.width,this.realHeight=null!==(n=t.real_height)&&void 0!==n?n:t.height,this._requireAuth=s}static payloadify(e){return e instanceof s?t.deundefined(t.undefineNullProps({url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight})):t.deundefined(t.undefineNullProps({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class i extends t.APIRequestCommand{constructor(e){if(super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_UPLOAD}`,this.params=t.deundefined({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(let t=0;tnew s(e,t,!1))))&&void 0!==a?a:[],this.requireAuth=null!==(r=t.require_auth)&&void 0!==r&&r}}class a extends t.InstancedObject{constructor(e,s){var i,n,a,r,o;super(e),this.replyCount=0,this.memberCount=0,this.lastRepliedAt=0,this.updatedAt=0,this.replyCount=null!==(i=s.reply_count)&&void 0!==i?i:0,this.memberCount=null!==(n=s.member_count)&&void 0!==n?n:0,this.mostRepliedUsers=s.most_replies&&t.isArrayOf("object",s.most_replies)?s.most_replies.map((e=>new t.User(this._iid,e))):[],this.unreadReplyCount=null!==(a=s.unread_message_count)&&void 0!==a?a:0,this.isPushNotificationEnabled="number"==typeof s.push_enabled?s.push_enabled>0:void 0,this.lastRepliedAt=null!==(r=s.last_replied_at)&&void 0!==r?r:0,this.updatedAt=null!==(o=s.updated_at)&&void 0!==o?o:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((e=>t.User.payloadify(e))):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}get _isUpdateRequired(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}_updateFrom(e){var t,s;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(s=e.isPushNotificationEnabled)&&void 0!==s?s:this.isPushNotificationEnabled}}exports.ReactionEventOperation=void 0,(e=exports.ReactionEventOperation||(exports.ReactionEventOperation={})).ADD="add",e.DELETE="delete";class r{constructor(e){this.messageId=0,this.operation=null,this.updatedAt=0;const s=t.isTypeOf("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,n=e.operation?e.operation.toLowerCase():null,a=e.reaction,r=e.updated_at;s&&t.isTypeOf("string",i)&&t.isTypeOf("string",n)&&t.isEnumOf(exports.ReactionEventOperation,n)&&t.isTypeOf("string",a)&&a&&t.isTypeOf("number",r)&&(this.messageId=s,this.userId=i,this.key=a,this.operation=n,this.updatedAt=r)}}class o{constructor(e){var s;const i=e.key,n=null!==(s=[...e.user_ids])&&void 0!==s?s:[],a=e.updated_at;t.isTypeOf("string",i)&&i&&t.isArrayOf("string",n)&&n.length>0&&t.isTypeOf("number",a)&&(this.key=i,this.userIds=n,this.updatedAt=a);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 t.deundefined(t.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 t=this.userIds.indexOf(e.userId);switch(e.operation){case exports.ReactionEventOperation.ADD:t<0&&this.userIds.push(e.userId);break;case exports.ReactionEventOperation.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}}}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 s,i;return t.deundefined(t.undefineNullProps({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(s=e.width)&&void 0!==s?s: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 t.deundefined(t.undefineNullProps({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?l.payloadify(e.defaultImage):null}))}}class u{constructor(e){var t,s;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(s=e.volume)&&void 0!==s?s:1}serialize(){return{name:this.name,volume:this.volume}}static payloadify(e){return t.deundefined(t.undefineNullProps({name:e.name,volume:e.volume}))}}var c;exports.FeedbackRating=void 0,(c=exports.FeedbackRating||(exports.FeedbackRating={})).GOOD="good",c.BAD="bad";class h{constructor(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}static _getStatus(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}static _isSubmitted(e){return"SUBMITTED"===h._getStatus(e)}static _getPayloadByStatus(e){return"NO_FEEDBACK"===e?{}:null}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,rating:e.rating,comment:e.comment}))}}class p extends t.User{constructor(e,s){var i;super(e,s),this.isBlockedByMe=!1,this.role=t.isEnumOf(t.Role,s.role)?s.role:t.Role.NONE,this.isBlockedByMe=null!==(i=s.is_blocked_by_me)&&void 0!==i&&i}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}class m{constructor(e){this.key=e.key,this.value=t.isArrayOf("string",e.value)?[...e.value]:[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:e.key,value:null!==(s=e.value)&&void 0!==s?s:[]}))}}const _=e=>{switch(e){case t.MessageType.BASE:return"";case t.MessageType.USER:return"MESG";case t.MessageType.FILE:return"FILE";case t.MessageType.ADMIN:return"ADMM"}};class g extends t.InstancedObject{constructor(e,s){var i,n,a,r,o,l,d,u,c;super(e),this.channelType=t.ChannelType.BASE,this.messageType=t.MessageType.BASE,this.mentionType=null,this.mentionedUsers=null,this.mentionedUserIds=null,this.mentionedMessageTemplate=void 0,this.metaArrays=[],this.extendedMessage={},this.createdAt=0,this.updatedAt=0,this.channelUrl=s.channel_url,this.channelType=t.isEnumOf(t.ChannelType,s.channel_type)?s.channel_type:t.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(this.channelUrl=s.channel.channel_url),s.channel.channel_type&&(this.channelType=s.channel.channel_type)),this.data=null!==(i=s.data)&&void 0!==i?i:"",this.customType=null!==(n=s.custom_type)&&void 0!==n?n:"",this.mentionType=t.isEnumOf(t.MentionType,s.mention_type)?s.mention_type:null,this.mentionedUsers=s.mentioned_users?s.mentioned_users.map((e=>new t.User(this._iid,e))):null,this.mentionedUserIds=null!==(a=s.mentioned_user_ids)&&void 0!==a?a:null,this.mentionedUsers&&!this.mentionedUserIds&&(this.mentionedUserIds=this.mentionedUsers.map((e=>e.userId))),this.mentionedMessageTemplate=s.mentioned_message_template;const h=null!==(r=s.metaarray)&&void 0!==r?r:{},p=null!==(o=s.metaarray_key_order)&&void 0!==o?o:Object.keys(h).sort(((e,t)=>e.localeCompare(t)));this.metaArrays=[];for(let e=0;enew m(e)))),this.extendedMessage=null!==(l=s.extended_message)&&void 0!==l?l:{},this.extendedMessagePayload=s.extended_message_payload,this.createdAt=null!==(u=null!==(d=s.created_at)&&void 0!==d?d:s.ts)&&void 0!==u?u:0,this.updatedAt=null!==(c=s.updated_at)&&void 0!==c?c:0}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.channelUrl,channel_type:e.channelType,type:_(e.messageType),data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(s=e.mentionedUsers)||void 0===s?void 0:s.map((e=>t.User.payloadify(e))),mentioned_message_template:e.mentionedMessageTemplate,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>m.payloadify(e))),extended_message:e.extendedMessage,extended_message_payload:e.extendedMessagePayload,created_at:e.createdAt,updated_at:e.updatedAt})))}isIdentical(e){return!0}isEqual(e){return t.deepEqual(this,e)}isUserMessage(){return this.messageType===t.MessageType.USER}isFileMessage(){return this.messageType===t.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isMultipleFilesMessage(){return this.messageType===t.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isAdminMessage(){return this.messageType===t.MessageType.ADMIN}serialize(){return t.serialize(this)}getMetaArraysByKeys(e){return this.metaArrays.filter((t=>e.includes(t.key)))}}class y extends t.InstancedObject{constructor(e,s){var i,n;super(e),this.channelUrl=null!==(i=s.channel_url)&&void 0!==i?i:"",this.channelType=null!==(n=s.channel_type)&&void 0!==n?n:t.ChannelType.GROUP,this.reader=new t.User(this._iid,s.user),this.readAt=s.ts}}class f extends t.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class v extends t.APIRequestCommand{constructor(e){super();const{channelUrl:s,channelType:i,userId:n,notificationIds:a}=e;this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/messages/mark_as_read`,this.params=t.deundefined(t.undefineNullProps({user_id:n,message_ids:a}))}}class I extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new y(e,s)}}class E extends t.APIResponseCommand{constructor(e,t){super(e,t),this.readAt=t.ts,this.unreadMessageCount=t.unread_message_count}}class T extends t.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"READ",ackRequired:!0,payload:{channel_url:e,parent_message_id:t}})}}class b extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,pushEnabled:n}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/thread_push`,this.params={push_enabled:n}}}class M extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,rating:n,comment:a}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks`,this.params={rating:n,comment:a}}}class S extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class O extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n,rating:a,comment:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`,this.params={rating:a,comment:r}}}class A extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class C extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`}}class w extends t.InstancedObject{constructor(e,t){var i,n,a,r,o;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!==(n=t.file_name)&&void 0!==n?n:null,this.mimeType=null!==(a=t.file_type)&&void 0!==a?a:null,this.fileSize=null!==(r=t.file_size)&&void 0!==r?r:0,this._requireAuth=null!==(o=t.require_auth)&&void 0!==o&&o,this.thumbnails=t.thumbnails?t.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this._requireAuth)})):[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>{var t;return{url:(null!==(t=e.plainUrl)&&void 0!==t?t:"").split("auth=")[0],width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class N{constructor({channelUrl:e,channelType:t,parentMessage:s}){this.channelUrl=e,this.channelType=t,this.parentMessage=s}}var P,U,R,x;!function(e){e.NUMBER="number",e.ENUM="enum",e.TEXT="text",e.REGEX="regex",e.DECIMAL_PLACE="decimal_place"}(P||(P={})),exports.MessageFormItemLayout=void 0,(U=exports.MessageFormItemLayout||(exports.MessageFormItemLayout={})).TEXT="text",U.TEXTAREA="textarea",U.NUMBER="number",U.PHONE="phone",U.EMAIL="email",U.CHIP="chip";class k{constructor(e,t){const{id:s,name:i,items:n,version:a,is_submitted:r}=t;this.messageId=e,this.id=s,this.name=i,this.items=n.map((e=>new L(e))).sort(((e,t)=>e.sortOrder-t.sortOrder)),this.version=null!=a?a:1,this._isSubmitted=r}get isSubmitted(){var e;return null!==(e=this._isSubmitted)&&void 0!==e?e:this.items.some((e=>Array.isArray(e.submittedValues)))}get isSubmittable(){return this.items.every((e=>e.required?!!(Array.isArray(e.draftValues)&&e.draftValues.length>0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,items:e.items.map((e=>L.payloadify(e))),version:e.version,is_submitted:e._isSubmitted}))}static isMessageFormPayload(e){return Boolean(null==e?void 0:e.message_form)}}class L{constructor(e){const{id:s,name:i,required:n,sort_order:a,placeholder:r,style:o,item_type:l,validators:d,value:u,values:c}=e;this.id=s,this.name=i,this.required=n,this.sortOrder=a,this.placeholder=r,0===Object.keys(o).length?this.style={layout:l}:this.style=t.deundefined({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),c?this.submittedValues=c:u&&(this.submittedValues=[u]),this._validators=d}isValid(e){return e.every((e=>{const t=function(e,t){return t.every((t=>{switch(t.key){case P.NUMBER:{const s=Number(e);return!(isNaN(s)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&st.max)}case P.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case P.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case P.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case P.DECIMAL_PLACE:{if(0===e.length)return!1;const s=Number(e);return!(isNaN(s)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){const s=e.toString(),i=s.indexOf(".");return-1===i||s.slice(i+1).length<=t}(s,t.max_decimal_place))}default:return!0}}))}(e,this._validators);return t}))}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:t.deundefined({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}class D extends t.APIRequestCommand{constructor(e){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_FORMS}/${e.formId}/submit`,this.params=t.deundefined({message_id:e.messageId,items:e.items})}}exports.ScheduledStatus=void 0,(R=exports.ScheduledStatus||(exports.ScheduledStatus={})).PENDING="pending",R.SENT="sent",R.FAILED="failed",R.CANCELED="canceled",exports.InternalScheduledStatus=void 0,(x=exports.InternalScheduledStatus||(exports.InternalScheduledStatus={})).PENDING="pending",x.IN_QUEUE="in_queue",x.SENT="sent",x.FAILED="failed",x.CANCELED="canceled",x.REMOVED="removed";class q extends g{constructor(e,t){var s,i,n,r,l,c,p,m,_;super(e,t),this.parentMessage=null,this.silent=!1,this.isOperatorMessage=!1,this.threadInfo=null,this.reactions=[],this.appleCriticalAlertOptions=null,this.scheduledInfo=null,this.suggestedReplies=null,this.myFeedback=null,this.myFeedbackStatus="NOT_APPLICABLE",this.messageForm=null,this._isContinuousMessages=!1,this._scheduledStatus=null,this.messageId=null!==(i=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==i?i:0,this.parentMessageId=null!==(n="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==n?n:0,this.threadInfo=t.thread_info?new a(this._iid,t.thread_info):null,this.reactions=t.reactions?t.reactions.map((e=>new o(e))):[],this.ogMetaData=t.og_tag?new d(t.og_tag):null,this.silent=null!==(r=t.silent)&&void 0!==r&&r,this.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,this.appleCriticalAlertOptions=t.apple_critical_alert_options?new u(t.apple_critical_alert_options):null,"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._isContinuousMessages=null!==(c=t.is_continuous_messages)&&void 0!==c&&c,this.myFeedback=h._isSubmitted(t.feedback)?new h(t.feedback):null,this.myFeedbackStatus=h._getStatus(t.feedback),this.suggestedReplies=null!==(m=null===(p=t.extended_message_payload)||void 0===p?void 0:p.suggested_replies)&&void 0!==m?m:null,this.messageForm=k.isMessageFormPayload(t.extended_message_payload)?new k(this.messageId,t.extended_message_payload.message_form):null,this.message=null!==(_=t.message)&&void 0!==_?_:""}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?a.payloadify(e.threadInfo):null,reactions:e.reactions.map((e=>o.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?u.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledMessageId,scheduled_at:null===(i=e.scheduledInfo)||void 0===i?void 0:i.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?h.payloadify(e.myFeedback):h._getPayloadByStatus(e.myFeedbackStatus),message:e.message})))}static _getParentMessageInfoPayload(e){return t.deundefined(t.undefineNullProps({type:_(e.messageType),ts:e.createdAt,user:e.sender?p.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null}))}isIdentical(e){return this.messageId===e.messageId}applyThreadInfoUpdateEvent(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}applyReactionEvent(e){if(this.messageId===e.messageId){let t=!1;for(let s=0;s=t)return this.parentMessage=e,!0}return!1}_triggerThreadInfoUpdatedEvent(){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e}=t.Vault.of(this._iid);e.dispatch(new N({channelType:t.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))}))}markThreadAsRead(){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=t.Vault.of(this._iid),s=new T({channelUrl:this.channelUrl,messageId:this.messageId});yield e.send(s),this.threadInfo&&0!==this.threadInfo.unreadReplyCount&&(this.threadInfo.unreadReplyCount=0,yield this._triggerThreadInfoUpdatedEvent())}))}setPushNotificationEnabled(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),i=new b({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e});yield s.send(i),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e)}))}submitMessageForm(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid);let i=null,n=null;const a=this.messageForm;if(!e&&a){if(!a.isSubmittable)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(a.isSubmitted)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});i=a.id,n=a.items.reduce(((e,t)=>(e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e)),[])}else e&&(i=e.formId,n=Object.entries(e.answers).reduce(((e,[s,i])=>{const n=Number(s);if(Number.isNaN(n))throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:n,value:i}),e}),[]));if(!i||!n)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});const r=new D({messageId:this.messageId,formId:i,items:n});yield s.send(r)}))}submitFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new M({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(S);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}))}))}updateFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new O({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(A);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}))}))}deleteFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new C({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e});yield s.send(n),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}))}))}}class F extends q{constructor(e,s){var i,n,a,r;if(super(e,s),this.reqId="",this.replyToChannel=!1,this.errorCode=0,this.sender=s.user?new p(this._iid,s.user):s.sender_id,this.reqId=null!==(n=null!==(i=s.req_id)&&void 0!==i?i:s.request_id)&&void 0!==n?n:"",this.replyToChannel=null!==(a=s.is_reply_to_channel)&&void 0!==a&&a,s.request_state&&t.isEnumOf(t.SendingStatus,s.request_state)&&(this.sendingStatus=s.request_state),!this.sendingStatus)if(this.messageId>0)this.sendingStatus=t.SendingStatus.SUCCEEDED;else if(this.scheduledInfo)switch(s.scheduled_status&&(this._scheduledStatus=s.scheduled_status),s.scheduled_status){case exports.InternalScheduledStatus.SENT:case exports.InternalScheduledStatus.IN_QUEUE:this.sendingStatus=t.SendingStatus.SUCCEEDED;break;case exports.InternalScheduledStatus.PENDING:this.sendingStatus=t.SendingStatus.SCHEDULED;break;case exports.InternalScheduledStatus.FAILED:case exports.InternalScheduledStatus.REMOVED:this.sendingStatus=t.SendingStatus.FAILED;break;case exports.InternalScheduledStatus.CANCELED:this.sendingStatus=t.SendingStatus.CANCELED}else this.sendingStatus=t.SendingStatus.PENDING;this.errorCode=null!==(r=s.error_code)&&void 0!==r?r:0,this._messageToken=s.mesg_token}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{user:p.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}get isResendable(){return(this.sendingStatus===t.SendingStatus.FAILED||this.sendingStatus===t.SendingStatus.CANCELED)&&t.isResendableError(this.errorCode)}isIdentical(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}const B={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},j=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo);class V extends q{constructor(e,s){var i,n,a;if(super(e,s),this.translations={},this.messageType=t.MessageType.ADMIN,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(a=i.file)||void 0===a?void 0:a.require_auth}))))}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{translations:e.translations,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class z{constructor(e){var s,i;this.detail={},this.type=null!==(s=e.type)&&void 0!==s?s:"",this.vendor=null!==(i=e.vendor)&&void 0!==i?i:"",e.detail&&t.isTypeOf("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}static payloadify(e){return t.deundefined(t.undefineNullProps({type:e.type,vendor:e.vendor,detail:e.detail}))}}class ${constructor(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}static payloadify(e){return t.deundefined({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}class Q extends F{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.messageParams=null,this.translations={},this.translationTargetLanguages=[],this.messageSurvivalSeconds=-1,this.plugins=[],this._poll=null,this.messageType=t.MessageType.USER,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},this.translationTargetLanguages=null!==(n=s.target_langs)&&void 0!==n?n:[],0===Object.keys(this.translations).length&&this.translationTargetLanguages.length>0)for(const e of this.translationTargetLanguages)this.translations[e]="";if(this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,this.plugins=s.plugins?s.plugins.map((e=>new z(e))):[],this._poll=s.poll?new t.Poll(this._iid,s.poll):null,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(o=i.file)||void 0===o?void 0:o.require_auth}))))}s.review_info&&(this.messageReviewInfo=new $(s.review_info))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((e=>z.payloadify(e))),poll:e._poll?t.Poll.payloadify(e._poll):null,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null,review_info:e.messageReviewInfo?$.payloadify(e.messageReviewInfo):void 0})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.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 G extends F{constructor(e,s){var i,n,a,r,o,l,d,u;if(super(e,s),this.messageParams=null,this.fileInfoList=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE,this.data=null!==(a=null!==(n=null===(i=s.file)||void 0===i?void 0:i.data)&&void 0!==n?n:s.custom)&&void 0!==a?a:"",this.fileInfoList=null!==(o=null===(r=s.files)||void 0===r?void 0:r.map((t=>new w(e,t))))&&void 0!==o?o:[],this.messageSurvivalSeconds=null!==(l=s.message_survival_seconds)&&void 0!==l?l:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=W(e,t.deundefined(t.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===(d=i.file)||void 0===d?void 0:d.url,require_auth:null===(u=i.file)||void 0===u?void 0:u.require_auth}))))}}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}static payloadify(e){var s,i,n,a,r,o;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{file:{name:null!==(i=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.fileName)&&void 0!==i?i:"",size:null!==(a=null===(n=e.fileInfoList[0])||void 0===n?void 0:n.fileSize)&&void 0!==a?a:0,type:null!==(o=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>w.payloadify(e))):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}static _isMultipleFilesMessagePayload(e){const t=e.files;return Array.isArray(t)&&t.length>=2}static _isMultipleFilesMessageSerializedData(e){const t=e.fileInfoList;return Array.isArray(t)}}var K;exports.NotificationMessageStatus=void 0,(K=exports.NotificationMessageStatus||(exports.NotificationMessageStatus={})).SENT="SENT",K.READ="READ";class H extends g{constructor(e,s){var i,n;if(super(e,s),this.notificationData=null,this.notificationId=s.notification_message_id,this.messageType=t.MessageType.ADMIN,this.messageStatus=null!==(i=s.message_status)&&void 0!==i?i:exports.NotificationMessageStatus.SENT,this.priority=null!==(n=s.priority)&&void 0!==n?n:t.NotificationPriority.NORMAL,this.notificationEventDeadline=s.notification_event_deadline,0===this.extendedMessage.sub_type)try{const{label:e,tags:t=[],template_key:s,template_variables:i}=JSON.parse(this.extendedMessage.sub_data);this.notificationData={label:e,tags:t,templateKey:s,templateVariables:i}}catch(e){}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}isIdentical(e){return this.notificationId===e.notificationId}}const W=(e,t)=>{if(t.notification_message_id)return new H(e,t);switch(t.type){case"MESG":return new Q(e,t);case"FILE":return G._isMultipleFilesMessagePayload(t)?new G(e,t):new Y(e,t);case"ADMM":case"BRDM":return new V(e,t);default:return null}};class Y extends F{constructor(e,i){var n,a,r,o,l,d,u,c,h,p,m,_,g,y;super(e,i),this.messageParams=null,this.plainUrl="",this.requireAuth=!1,this.thumbnails=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE;const f=i.file;if(this.plainUrl=(null!==(a=null!==(n=null==f?void 0:f.url)&&void 0!==n?n:i.url)&&void 0!==a?a:"").split("?auth=")[0],this.name=null!==(o=null!==(r=null==f?void 0:f.name)&&void 0!==r?r:i.name)&&void 0!==o?o:"File",this.size=null!==(d=null!==(l=null==f?void 0:f.size)&&void 0!==l?l:i.size)&&void 0!==d?d:0,this.data=null!==(c=null!==(u=null==f?void 0:f.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",this.type=f?null!==(h=f.type)&&void 0!==h?h:"":null!==(p=i.type)&&void 0!==p?p:"",this.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,this.thumbnails=i.thumbnails?i.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this.requireAuth)})):[],this.messageSurvivalSeconds=null!==(_=i.message_survival_seconds)&&void 0!==_?_:-1,i.parent_message_info){const s=i.parent_message_info;this.parentMessage=W(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},s),{created_at:s.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:s.file,url:null===(g=s.file)||void 0===g?void 0:g.url,require_auth:null===(y=s.file)||void 0===y?void 0:y.require_auth}))))}}static payloadify(e){var s;return t.deundefined(t.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===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.plainUrl,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}=t.Vault.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},B),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&j(i)).throw(t.SendbirdError.invalidParameters);const n=zi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class J extends t.InstancedObject{static getPlainUrl(e){return e instanceof J?e._plainUrl:e.fileUrl}constructor(e,{file:t,fileUrl:s,fileName:i,fileSize:n,mimeType:a,thumbnailSizes:r,_uploadedMetaData:o,_thumbnails:l}){super(e),this._plainUrl=s,this.file=t,this.fileName=i,this.fileSize=n,this.mimeType=a,this.thumbnailSizes=r,this._uploadedMetaData=o,this._thumbnails=l}get fileUrl(){var e;const{sessionManager:s}=t.Vault.of(this._iid);return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&s.ekey?`${this._plainUrl}?auth=${s.ekey}`:this._plainUrl}set fileUrl(e){this._plainUrl=e}toJSON(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}class X extends t.WebSocketRequestCommand{constructor(e){var i,n,a,r;let o=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((e=>e.userId)))),super({code:"FILE",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,files:e.files?se(e.files):null,url:e.url,name:null!==(i=e.fileName)&&void 0!==i?i:"",type:null!==(n=e.mimeType)&&void 0!==n?n:"",size:null!==(a=e.fileSize)&&void 0!==a?a:0,custom:e.data,custom_type:e.customType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((e=>s.payloadify(e))),require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:o,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?u.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,message:e.message}))})}}class Z extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId)))),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e.channelType)}/${encodeURIComponent(e.channelUrl)}/messages`,this.params=t.deundefined(t.undefineNullProps({message_type:t.MessageType.FILE,user_id:e.userId,files:e.files?se(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===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:e.requireAuth,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((e=>m.payloadify(e))),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}))}}class ee extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"FILE",i),this.message=i.files&&i.files.length>=2?new G(e,i):new Y(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class te extends t.APIResponseCommand{constructor(e,s){var i,n,a,r;super(e,s),this.message=s.files&&s.files.length>=2?new G(e,s):new Y(e,s);const{sdkState:o}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(a=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(n=this.message.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)))&&void 0!==a?a:[],o.userId),this.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r}}function se(e){return e.map((e=>{var i,n;return t.deundefined(t.undefineNullProps({url:J.getPlainUrl(e),file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var ie;!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"}(ie||(ie={}));class ne{constructor(e,{sdkState:s,dispatcher:i,requestQueue:n,onlineDetector:a,cacheContext:r}){this._queueMap=new Map,this._iid=e,this._sdkState=s,this._requestQueue=n,this._cacheContext=r,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof t.ConnectionStateChangeCommand&&(this._connectionState=e.stateType)})),this._onlineDetector=a}get _shouldSendThroughWebSocket(){return this._connectionState===t.ConnectionStateType.CONNECTED||this._connectionState===t.ConnectionStateType.CONNECTING||this._connectionState===t.ConnectionStateType.RECONNECTING}_sendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._createSendFileMessageRequestParams(e,s);if(this._shouldSendThroughWebSocket){const e=new X(t),s=yield this._requestQueue.send(e),{message:i}=s.as(ee);return i}{const e=new Z(Object.assign(Object.assign({},t),{userId:this._sdkState.userId})),s=yield this._requestQueue.send(e),{message:i}=s.as(te);return i}}))}_createSendFileMessageRequestParams(e,t){const s=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){const e=t.params;s.files=e.fileInfoList}else{const e=t.params;s.url=e.fileUrl,s.requireAuth=e.requireAuth}return s}_resolveMessageQueue(e){var s;return t.__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 n=[];let a=!0;for(const r of i.messageQueue)switch(r.state){case ie.PENDING:case ie.UPLOADING:a=!1,n.push(r);break;case ie.UPLOADED:if(a)try{r.state=ie.SENDING;const s=yield this._sendFileMessage(e,r);r.deferred.resolve(s),yield t.sleep(100)}catch(e){r.deferred.reject(e)}else n.push(r);break;case ie.FAILED:{const e=null!==(s=r.error)&&void 0!==s?s:t.SendbirdError.unknown;r.deferred.reject(e.code===t.SendbirdErrorCode.REQUEST_CANCELED?t.SendbirdError.fileUploadCanceled:e);break}}const r=i.isResolveRequestPending;i.messageQueue=n,i.isResolving=!1,i.isResolveRequestPending=!1,r&&(yield this._resolveMessageQueue(e))}}))}_uploadNextPendingItem(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i){const n=i.messageQueue.find((e=>e.state===ie.PENDING));if(n){if(n.multipleFileUploadInfo){const{uploadIndex:a,uploadCount:r,requestHandler:o}=n.multipleFileUploadInfo,l=n.params,d=l.fileInfoList[a];t.isFile(d.file)&&!(null===(s=d._uploadedMetaData)||void 0===s?void 0:s.isUploaded)?yield this._tryUploadNextItemAndUpdateItemState(e,i,n):n.state=ae.requestId===t.requestId));s>=0&&e.uploadQueue.splice(s,1)}_uploadNextFileForSingleFileItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const t=new i({file:a.file,channelUrl:e.url,thumbnailSizes:a.thumbnailSizes,requestId:s.requestId}),d=yield this._requestQueue.send(t),{url:u,fileSize:c=a.fileSize,thumbnails:h=[],requireAuth:p=!1}=d.as(n);a.fileName=null!==(r=a.fileName)&&void 0!==r?r:a.file.name,a.mimeType=null!==(o=a.mimeType)&&void 0!==o?o:a.file.type,a.fileSize=null!==(l=a.fileSize)&&void 0!==l?l:a.file.size,a.fileUrl=u,a.fileSize=c,a.requireAuth=p,a._thumbnails=h}))}_uploadNextFileForMultipleFilesItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const{uploadIndex:t}=s.multipleFileUploadInfo,d=a.fileInfoList[t],u=new i({file:d.file,channelUrl:e.url,thumbnailSizes:d.thumbnailSizes,requestId:s.requestId}),c=yield this._requestQueue.send(u),{url:h,fileSize:p=d.fileSize,thumbnails:m,requireAuth:_=!1}=c.as(n);d.fileName=null!==(r=d.fileName)&&void 0!==r?r:d.file.name,d.mimeType=null!==(o=d.mimeType)&&void 0!==o?o:d.file.type,d.fileSize=null!==(l=d.fileSize)&&void 0!==l?l:d.file.size,d.file=void 0,d.fileUrl=h,d.fileSize=p,d._thumbnails=m,d._uploadedMetaData=Object.assign(Object.assign({},d._uploadedMetaData),{requireAuth:_,isUploaded:!0}),d instanceof J||(a.fileInfoList[t]=new J(this._iid,d))}))}request(e,s,i,n={}){return t.__awaiter(this,void 0,void 0,(function*(){if(!this._queueMap.has(e.url)){const t={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1};this._queueMap.set(e.url,t)}const a=this._queueMap.get(e.url),r=new t.Deferred,o={requestId:s,params:i,state:ie.PENDING,deferred:r};if(function(e){return"fileInfoList"in e}(i)){const e=i,t=Object.assign({uploadIndex:0,uploadCount:e.fileInfoList.length},n);o.multipleFileUploadInfo=t}return a.messageQueue.push(o),this._uploadNextPendingItem(e),r.promise}))}cancel(e,s){const i=this._queueMap.get(e.url);if(i){const n=s?[i.messageQueue.find((e=>e.requestId===s))]:[...i.messageQueue];for(const s of n)if(s)switch(s.state){case ie.PENDING:if(s.state=ie.FAILED,s.error=t.SendbirdError.requestCanceled,s.multipleFileUploadInfo&&!s.multipleFileUploadInfo.isCopy){const{uploadIndex:e,requestHandler:i}=s.multipleFileUploadInfo,n=s.params.fileInfoList[e];null==i||i._triggerOnFileUploaded(s.requestId,e,n,t.SendbirdError.fileUploadCanceled)}this._resolveMessageQueue(e);break;case ie.UPLOADING:this._requestQueue.cancel(s.requestId),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s.requestId}))}}else s&&(this._requestQueue.cancel(s),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s})))}}const ae={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:t.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},re=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo)&&t.isTypeOf("boolean",e.showSubchannelMessagesOnly),oe={replyType:t.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},le=e=>t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo);class de extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,includeMetaArray:n,includeReactions:a,includeThreadInfo:r,includeParentMessageInfo:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}`,this.params={is_sdk:!0,with_sorted_meta_array:n,include_reactions:a,include_thread_info:r,include_parent_message_info:o,include_poll_details:!0}}}class ue extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}class ce extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,prevResultSize:a,nextResultSize:r,isInclusive:o,reverse:l,messageTypeFilter:d,customTypesFilter:u,senderUserIdsFilter:c,replyType:h,includeMetaArray:p,includeReactions:m,parentMessageId:_,includeThreadInfo:g,includeParentMessageInfo:y,showSubchannelMessagesOnly:f,checkingHasNext:v,checkingContinuousMessages:I}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages`,this.params=t.deundefined(t.undefineNullProps({is_sdk:!0,prev_limit:a,next_limit:r,include:o,reverse:l,message_ts:i,message_id:n,message_type:null!=d?d:null,custom_types:u,sender_ids:c,include_reply_type:h,with_sorted_meta_array:p,include_reactions:m,parent_message_id:_,include_thread_info:g,include_parent_message_info:y,show_subchannel_message_only:f,include_poll_details:!0,checking_has_next:v,checking_continuous_messages:I}))}}class he extends t.APIResponseCommand{constructor(e,t){super(e,t),void 0!==t.is_continuous_messages&&(this.isContinuousMessages=t.is_continuous_messages),void 0!==t.has_next&&(this.hasNext=t.has_next),this.messages=t.messages.map((t=>W(e,t)))}}class pe extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,replyType:a,includeMetaArray:r,includeReactions:o,includeThreadInfo:l,includeParentMessageInfo:d}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/changelogs`,this.params={change_ts:i,token:n,with_sorted_meta_array:r,include_reactions:o,include_thread_info:l,include_reply_type:a,include_parent_message_info:d,include_poll_details:!0}}}class me extends t.APIResponseCommand{constructor(e,t){super(e,t),this.updatedMessages=t.updated.map((t=>W(e,t))),this.deletedMessagesInfo=t.deleted.map((e=>({messageId:e.message_id,deletedAt:e.deleted_at}))),this.hasMore=t.has_more,this.nextToken=t.next}}class _e extends t.APIRequestCommand{constructor({channelUrl:e,scheduledMessageId:s}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/scheduled_messages/${encodeURIComponent(s)}`,this.params={}}}class ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?W(e,Object.assign({},t)):null}}var ye;exports.RestrictionType=void 0,(ye=exports.RestrictionType||(exports.RestrictionType={})).MUTED="muted",ye.BANNED="banned";class fe{constructor(e){var s,i,n,a;this.restrictionType=null,t.isEnumOf(exports.RestrictionType,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(s=e.description)&&void 0!==s?s:null,this.endAt=null!==(n=null!==(i=e.end_at)&&void 0!==i?i:e.muted_end_at)&&void 0!==n?n:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}static payloadify(e){return t.deundefined(t.undefineNullProps({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}class ve extends t.User{constructor(e,t){super(e,t),this.restrictionInfo=new fe(t)}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),fe.payloadify(e.restrictionInfo))))}}class Ie{constructor(){this._onPending=t.noop,this._onFailed=t.noop,this._onSucceeded=t.noop}_trigger(e){switch(null==e?void 0:e.sendingStatus){case t.SendingStatus.PENDING:0===e.errorCode&&this._onPending(e);break;case t.SendingStatus.SCHEDULED:case t.SendingStatus.SUCCEEDED:this._onSucceeded(e)}}_triggerFailed(e,s){switch(null==s?void 0:s.sendingStatus){case t.SendingStatus.FAILED:case t.SendingStatus.CANCELED:this._onFailed(e,s.scheduledInfo?null:s)}}onPending(e){return this._onPending=e,this}onFailed(e){return this._onFailed=e,this}onSucceeded(e){return this._onSucceeded=e,this}}const Ee={data:void 0,customType:void 0,mentionType:t.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},Te=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isTypeOf("number",e.parentMessageId,!0)&&t.isTypeOf("boolean",e.isReplyToChannel)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0)&&t.isTypeOf("boolean",e.isPinnedMessage,!0),be=e=>({isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}),Me=Object.assign(Object.assign({},Ee),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function Se(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}const Oe=e=>{var s;return t.deundefined(t.undefineNullProps({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(s=e.poll)||void 0===s?void 0:s.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations),extendedMessagePayload:e.extendedMessagePayload}))},Ae=e=>Te(e)&&t.isTypeOf("string",e.message)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0)&&t.isTypeOf("object",e.extendedMessagePayload,!0);var Ce;!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Ce||(Ce={}));const we=e=>"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob,Ne=e=>e===Ce.BLOB||e===Ce.FILE,Pe=e=>({file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}),Ue=Object.assign(Object.assign({},Ee),{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,message:void 0});function Re(e){var s,i,n,a;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=e.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails,message:e.message}))}const xe=(e,s)=>{var i;return e.messageParams?(!e.url&&t.isFile(s)&&(e.messageParams.file=s),e.messageParams):t.deundefined(t.undefineNullProps({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:s,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),message:e.message}))},ke=e=>Te(e)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&t.isTypeOf("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),Le={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},De=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(m,e.metaArrays,!0)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0),qe=Object.assign(Object.assign({},Le),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Fe=e=>De(e)&&t.isTypeOf("string",e.message,!0)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0),Be=Object.assign({},Le);class je extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,token:i,limit:n}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(e)}/operators`,this.params={token:i,limit:n}}}class Ve extends t.APIResponseCommand{constructor(e,s){super(e,s),this.operators=s.operators.map((s=>new t.User(e,s))),this.token=s.next}}class ze extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;{const e=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new je(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),i=yield e.send(s),{operators:n,token:a}=i.as(Ve);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return e}}throw t.SendbirdError.invalidParameters}))}}class $e extends t.ChannelDataListQuery{constructor(e,s,i,n){var a,r,o,l,d,u,c,h,p,m;super(e,s,i,n),this.reverse=!1,this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.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!==(a=n.reverse)&&void 0!==a&&a,this.messageTypeFilter=null!==(r=n.messageTypeFilter)&&void 0!==r?r:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,this.senderUserIdsFilter=null!==(l=n.senderUserIdsFilter)&&void 0!==l?l:null,this.replyType=null!==(d=n.replyType)&&void 0!==d?d:t.ReplyType.NONE,this.includeMetaArray=null!==(u=n.includeMetaArray)&&void 0!==u&&u,this.includeReactions=null!==(c=n.includeReactions)&&void 0!==c&&c,this.includeParentMessageInfo=null!==(h=n.includeParentMessageInfo)&&void 0!==h&&h,this.includeThreadInfo=null!==(p=n.includeThreadInfo)&&void 0!==p&&p,this.showSubchannelMessagesOnly=null!==(m=n.showSubchannelMessagesOnly)&&void 0!==m&&m}_validate(){return super._validate()&&t.isTypeOf("boolean",this.reverse)&&t.isEnumOf(t.MessageTypeFilter,this.messageTypeFilter)&&t.isEnumOf(t.ReplyType,this.replyType)&&t.isArrayOf("string",this.customTypesFilter,!0)&&t.isArrayOf("string",this.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",this.includeMetaArray)&&t.isTypeOf("boolean",this.includeReactions)&&t.isTypeOf("boolean",this.includeParentMessageInfo)&&t.isTypeOf("boolean",this.includeThreadInfo)&&t.isTypeOf("boolean",this.showSubchannelMessagesOnly)}load(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=zi.of(this._iid),s=yield e.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t.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,...s.map((e=>e.createdAt))),this._hasNext=s.length>=this.limit,this._isLoading=!1,s}return[]}throw t.SendbirdError.invalidParameters}))}}class Qe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={limit:n,token:a}}}class Ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.mutedUsers=[];const{next:s,muted_list:i}=t;this.token=s,i&&i.length>0&&(this.mutedUsers=i.map((t=>new ve(e,t))))}}class Ke extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Qe(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{mutedUsers:n,token:a}=i.as(Ge);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class He extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({limit:n,token:a})}}class We extends t.APIResponseCommand{constructor(e,t){super(e,t),this.bannedUsers=[];const{next:s,banned_list:i}=t;this.token=s,i&&i.length>0&&(this.bannedUsers=i.map((t=>new ve(e,t.user))))}}class Ye extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new He(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{bannedUsers:n,token:a}=i.as(We);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}var Je;exports.ReportCategory=void 0,(Je=exports.ReportCategory||(exports.ReportCategory={})).SPAM="spam",Je.HARASSING="harassing",Je.SUSPICIOUS="suspicious",Je.INAPPROPRIATE="inappropriate";class Xe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class Ze extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${n}`}}class tt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.isMuted=!1,this.startAt=0,this.endAt=0;const{is_muted:s,start_at:i,end_at:n,remaining_duration:a,description:r}=t;this.isMuted=s,this.startAt=i,this.endAt=n,this.remainingDuration=a,this.description=r}}class st extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={keys:n,include_ts:!0}}}class it extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0}}}class at extends t.APIResponseCommand{constructor(e,t){var s,i;super(e,t),this.metaData=null!==(s=t.metadata)&&void 0!==s?s:{},this.ts=null!==(i=t.ts)&&void 0!==i?i:null}}class rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n,upsert:a}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0,upsert:null!=a&&a}}}class ot extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class lt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class dt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata/${n}`,this.params={include_ts:!0}}}class ut extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={include_ts:!0}}}class ht extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class pt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={keys:n}}}class mt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class _t extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n}}}class gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class yt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n,upsert:a=!1,mode:r="set"}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n,upsert:a,mode:r}}}class ft extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class vt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class It extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter/${n}`,this.params={}}}class Et extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={}}}class Tt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={user_id:n,seconds:a,description:r}}}class bt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Mt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${encodeURIComponent(n)}`}}class St extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Ot extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({user_id:n,seconds:a,description:r})}}class At extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data),s.data.member_count&&(this.memberCount=s.data.member_count),s.data.joined_member_count&&(this.joinedMemberCount=s.data.joined_member_count)}}class Ct extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban/${encodeURIComponent(n)}`}}class wt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new ve(e,s.data)}}class Nt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,freezing:n}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/freeze`,this.params={freeze:n}}}class Pt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.freeze=s.data.freeze}}class Ut extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}`,this.params={report_category:n,reporting_user_id:a,report_description:r}}}class Rt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,description:o}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_REPORT}/users/${r}`,this.params={channel_url:s,channel_type:i===t.ChannelType.OPEN?"open_channels":"group_channels",report_category:n,reporting_user_id:a,report_description:o}}}class xt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,messageId:o,description:l,messageToken:d}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}/messages/${o}`,this.params=t.deundefined({report_category:n,reporting_user_id:a,report_description:l,offending_user_id:r,mesg_token:d})}}class kt extends t.WebSocketRequestCommand{constructor(e){let s=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MESG",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage,extended_message_payload:e.extendedMessagePayload}))})}}class Lt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"MESG",i),this.message=new Q(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class Dt extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,poll_id:e.pollId}))})}}class qt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"MEDI",i),this.message=new Q(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class Ft extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"FEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,apple_critical_alert_options:e.appleCriticalAlertOptions}))})}}class Bt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"FEDI",i),this.message=new Y(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class jt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class Vt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(t)}}class zt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class $t extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new r(Object.assign({},t))}}class Qt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,translationTargetLanguages:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}/translation`,this.params={target_langs:n}}}class Gt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Kt extends t.APIRequestCommand{constructor(e){var s;super();let i=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:a}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(n)}/${encodeURIComponent(a)}/scheduled_messages`,this.params=t.deundefined(t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class Ht extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Q(e,t)}}class Wt extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId))));const{channelType:r,channelUrl:o}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(r)}/${encodeURIComponent(o)}/scheduled_messages`,this.params=t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.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((e=>m.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})}}class Yt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new Y(e,t)}}class Jt extends t.APIRequestCommand{constructor({pollId:e,title:s,data:i,allowUserSuggestion:n,allowMultipleVotes:a,closeAt:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`,this.params={title:s,data:i,allow_user_suggestion:n,allow_multiple_votes:a,close_at:r}}}class Xt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Zt extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`}}class es extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/close`}}class ts extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ss extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,pollId:i,optionText:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(i)}/options`,this.params={channel_url:e,channel_type:s,text:n}}}class is extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class ns extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s,optionText:i}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`,this.params={text:i}}}class as extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class rs extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`}}class os extends t.WebSocketRequestCommand{constructor({reqId:e,channelType:s,channelUrl:i,pollId:n,pollOptionIds:a}){super({code:"VOTE",ackRequired:!0,payload:t.deundefined({req_id:e,channel_type:s===t.ChannelType.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:n,option_ids:a})})}}class ls extends t.WebSocketEventCommand{constructor(e,s,i){super(e,"VOTE",i),this.event=new t.PollVoteEvent(i),this.channelUrl=i.channel_url,this.channelType=i.channel_type}}const ds="Message",us="NotificationMessage";const cs=Object.assign(Object.assign({},Ee),{fileInfoList:[],message:""}),hs=e=>(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>e.maxWidth>0&&e.maxHeight>0)));class ps extends Ie{constructor(){super(...arguments),this._onFileUploaded=t.noop}_triggerOnFileUploaded(e,t,s,i){this._onFileUploaded(e,t,s,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}}class ms extends t.InstancedObject{constructor(e,t){super(e),this.message=null,this.message=W(e,t.message)}}class _s extends t.APIRequestCommand{constructor(e){const{channelType:s,channelUrl:i,limit:n,token:a,includeReactions:r,includeMetaArray:o,includeParentMessageInfo:l,includeThreadInfo:d,includePollDetails:u}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(i)}/pinned_messages`,this.params=t.deundefined({limit:n,token:a,include_reactions:r,with_sorted_meta_array:o,include_thread_info:d,include_parent_message_info:l,include_poll_details:u})}}class gs extends t.APIResponseCommand{constructor(e,t){super(e,t);const{pinned_messages:s,has_more:i,next:n}=t;this.pinnedMessages=s.map((t=>new ms(e,t))),this.hasMore=i,this.token=n}}class ys extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i),this.includeMetaArray=i.includeMetaArray,this.includeReactions=i.includeReactions,this.includeParentMessageInfo=i.includeParentMessageInfo,this.includeThreadInfo=i.includeThreadInfo,this.includePollDetails=i.includePollDetails}_validate(){return super._validate()&&t.isTypeOf("boolean",this.includeMetaArray,!0)&&t.isTypeOf("boolean",this.includeReactions,!0)&&t.isTypeOf("boolean",this.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",this.includeThreadInfo,!0)&&t.isTypeOf("boolean",this.includePollDetails,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new _s(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{pinnedMessages:n,hasMore:a,token:r}=i.as(gs);return this._token=r,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class fs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}class vs extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/pin`}}var Is;exports.SendMessageRequestType=void 0,(Is=exports.SendMessageRequestType||(exports.SendMessageRequestType={})).SEND="send",Is.RESEND="resend",Is.COPY="copy";class Es extends t.InstancedObject{get url(){return this._url}get name(){return this._name}set name(e){this._name=e}get createdAt(){return this._createdAt}toJSON(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}constructor(e,s){var i,n,a,r,o,l,d;super(e),this._name="",this._createdAt=0,this.pinnedMessageIds=[],this.channelType=t.ChannelType.BASE,this.coverUrl="",this.customType="",this.data="",this.isFrozen=!1,this.isEphemeral=!1,this.creator=null,this._messageCollectionLastAccessedAt=0,this._url=s.channel_url,this._name=null!==(i=s.name)&&void 0!==i?i:"",this._createdAt=1e3*s.created_at,this.coverUrl=null!==(n=s.cover_url)&&void 0!==n?n:"",this.customType=null!==(a=s.custom_type)&&void 0!==a?a:"",this.data=null!==(r=s.data)&&void 0!==r?r:"",this.isFrozen=null!==(o=s.freeze)&&void 0!==o&&o,this.isEphemeral=null!==(l=s.is_ephemeral)&&void 0!==l&&l,this.creator=s.created_by?new t.User(this._iid,s.created_by):null,s.metadata&&Object.keys(s.metadata).length>0&&s.ts?(this._cachedMetaData=new Map,Object.keys(s.metadata).forEach((e=>{this._cachedMetaData.set(e,{value:s.metadata[e],isRemoved:!1,updatedAt:s.ts})}))):"string"==typeof s.metadata&&(this._cachedMetaData=new Map(Object.entries(JSON.parse(s.metadata)))),this.pinnedMessageIds=null!==(d=s.pinned_message_ids)&&void 0!==d?d:[]}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(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?t.User.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}isGroupChannel(){return this.channelType===t.ChannelType.GROUP}isOpenChannel(){return this.channelType===t.ChannelType.OPEN}isFeedChannel(){return this.channelType===t.ChannelType.FEED}get cachedMetaData(){const e={};return this._cachedMetaData?(this._cachedMetaData.forEach(((t,s)=>{t.isRemoved||(e[s]=t.value)})),e):e}get messageCollectionLastAccessedAt(){return this._messageCollectionLastAccessedAt}_serializeCachedMetaData(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}_updateMessageCollectionLastAccessedAt(){this._messageCollectionLastAccessedAt=Date.now()}_update(e){const s=t.deundefined(e);Object.assign(this,s)}_upsertCachedMetaData(e,t){Object.keys(e).forEach((s=>{this._cachedMetaData||(this._cachedMetaData=new Map);const i=this._cachedMetaData.get(s);(!i||i.updatedAt<=t)&&this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})}))}_updateCachedMetaData(e,t){let s=!1;return this._cachedMetaData?this._cachedMetaData.forEach(((i,n)=>{var a;i.updatedAt<=t&&(this._cachedMetaData.set(n,{value:null!==(a=e[n])&&void 0!==a?a:i.value,isRemoved:!e[n],updatedAt:t}),s=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((s=>{this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})})),s=!0),{isUpdated:s}}_removeFromCachedMetaData(e,t){this._cachedMetaData&&e.forEach((e=>{const s=this._cachedMetaData.get(e);s&&s.updatedAtm.payloadify(e))):null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,created_at:i,user:a.currentUser?p.payloadify(a.currentUser):null,req_id:s,request_state:t.SendingStatus.PENDING,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>t.User.payloadify(e)))}))}_createPendingUserMessage(e,s,i){const n={};if(e.translationTargetLanguages)for(const t of e.translationTargetLanguages)n[t]="";const a=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.USER,message:e.message,translations:n,extended_message_payload:e.extendedMessagePayload})),r=new Q(this._iid,a);return r.messageParams=e,r}_createPendingScheduledUserMessage(e,t,s){const i=this._createPendingUserMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_createPendingFileMessage(e,i,n){var a,r,o,l,d,u,c;const h=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,i,n)),{type:t.MessageType.FILE,url:e.fileUrl,file:{name:null!==(a=e.fileName)&&void 0!==a?a:null===(r=e.file)||void 0===r?void 0:r.name,size:null!==(o=e.fileSize)&&void 0!==o?o:null===(l=e.file)||void 0===l?void 0:l.size,type:null!==(d=e.mimeType)&&void 0!==d?d:null===(u=e.file)||void 0===u?void 0:u.type,data:e.data},thumbnails:null===(c=e._thumbnails)||void 0===c?void 0:c.map((e=>s.payloadify(e))),message:e.message})),p=new Y(this._iid,h);return p.messageParams=e,p}_createPendingMultipleFilesMessage(e,s,i){const n=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.FILE,file:e.fileInfoList.length>0?{name:e.fileInfoList[0].fileName,size:e.fileInfoList[0].fileSize,type:e.fileInfoList[0].mimeType,data:e.data}:void 0,message:e.message})),a=new G(this._iid,n);return a.messageParams=e,a}_validateFailedFileMessageHasFile(e,s){var i;return Boolean(e.url)||t.isFile(s)||t.isFile(null===(i=e.messageParams)||void 0===i?void 0:i.file)}_createPendingScheduledFileMessage(e,t,s){const i=this._createPendingFileMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_markMessageAsFailed(e,s,i=!1){e.errorCode=s.code,s.code===t.SendbirdErrorCode.REQUEST_CANCELED||s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=t.SendingStatus.CANCELED:i||(e.sendingStatus=t.SendingStatus.FAILED)}sendUserMessage(e){const s=Object.assign(Object.assign({},Me),e);return t.unless(Ae(s)).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(s)}_sendUserMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n,requestQueue:a}=t.Vault.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)}))));const d=new kt(Object.assign(Object.assign({},e),{channelUrl:this.url,channelType:this.channelType,reqId:r}));a.send(d).then((e=>{const{message:s}=e.as(Lt);n.dispatch(new t.MessageUpdateEventCommand({messages:[s],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(s)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendUserMessage(e){return t.unless(e instanceof Q&&!!e.messageParams).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId)}resendUserMessage(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=new t.Deferred,n=null!==(s=e.messageParams)&&void 0!==s?s:Oe(e);return this._sendUserMessage(n,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>i.reject(e))).onSucceeded((e=>i.resolve(e))),i.promise}))}updateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},qe),s);t.unless(t.isTypeOf("number",e)&&Fe(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Dt(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(qt);return o}))}copyUserMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Q&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters),t.unless(!s.poll).throw(t.SendbirdError.notSupportedError);const r=new t.Deferred,o=null!==(i=s.messageParams)&&void 0!==i?i:t.undefineNullProps(Object.assign(Object.assign({},s),{mentionType:s.mentionType,mentionedUserIds:null!==(n=s.mentionedUserIds)&&void 0!==n?n:null===(a=s.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)),translationTargetLanguages:Object.keys(s.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}));return e._sendUserMessage(o).onSucceeded((e=>{r.resolve(e)})).onFailed((e=>r.reject(e))),r.promise}))}translateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Qt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:s}),a=yield i.send(n),{message:r}=a.as(Gt);return r}))}_createScheduledUserMessage(e,s){const{requestQueue:i}=t.Vault.of(this._iid),n=Date.now(),a=this._generateRequestId();t.sleep(2).then((()=>{const i=this._createPendingScheduledUserMessage(e,a,n);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))}));const r=new Kt(Object.assign({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(r).then((e=>{const{message:i}=e.as(Ht);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((i=>{if(t.isThrowingOutside(i))throw i;t.sleep(2).then((()=>{const r=this._createPendingScheduledUserMessage(e,a,n);this._markMessageAsFailed(r,i),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(i,r)}))))}))}))}sendFileMessage(e){const s=Object.assign(Object.assign({},Ue),e);return t.unless(ke(s)).throw(t.SendbirdError.invalidParameters),this._sendFileMessage(s)}sendMultipleFilesMessage(e){var s;const i=Object.assign(Object.assign({},cs),e),n=t.Vault.of(this._iid);t.unless(((e,s=t.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT)=>Te(e)&&t.isTypeOf("string",e.message,!0)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=s&&e.fileInfoList.every((e=>hs(e))))(i,null===(s=n.appInfo)||void 0===s?void 0:s.multipleFilesMessageFileCountLimit)).throw(t.SendbirdError.invalidParameters);const a=!!e.fileInfoList.find((e=>{const t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return t.unless(!a).throw(t.SendbirdError.fileSizeLimitExceededError),this._sendMultipleFilesMessage(i)}_sendFileMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=zi.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Ie;return t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?t.CollectionEventSource.LOCAL_MESSAGE_CANCELED:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendFileMessage(e){t.unless(e instanceof Y&&!!e.messageParams).throw(t.SendbirdError.invalidParameters);const{logger:s}=t.Vault.of(this._iid);return s.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId).onFailed((e=>{s.debug("autoResendFileMessage failed",e)})).onSucceeded((e=>{s.debug("autoResendFileMessage success",e)}))}_sendMultipleFilesMessage(e,s,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=zi.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new ps;return t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e,{requestHandler:l,isCopy:s===exports.SendMessageRequestType.COPY}).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);this._markMessageAsFailed(i,s),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_createScheduledFileMessage(e,s,i,n){const{requestQueue:a}=t.Vault.of(this._iid),r=new Wt(Object.assign(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(r).then((e=>{const{message:i}=e.as(Yt);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((a=>{if(t.isThrowingOutside(a))throw a;t.sleep(2).then((()=>{const r=this._createPendingScheduledFileMessage(e,i,n);this._markMessageAsFailed(r,a),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(a,r)}))))}))}))}sendFileMessages(e){t.unless(e.every((e=>ke(Object.assign(Object.assign({},Ue),e))))).throw(t.SendbirdError.invalidParameters);const s=new Ie;for(const t of e)this.sendFileMessage(t).onPending((e=>s._trigger(e))).onFailed(((e,t)=>s._triggerFailed(e,t))).onSucceeded((e=>s._trigger(e)));return s}resendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(e instanceof Y&&i&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const n=new t.Deferred,a=xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>n.reject(e))).onSucceeded((e=>n.resolve(e))),n.promise}))}resendMessage(e,s){var i,n;if(t.unless(e instanceof F&&!e.scheduledInfo&&e.isResendable).throw(t.SendbirdError.invalidParameters),e.isUserMessage()){const t=null!==(i=e.messageParams)&&void 0!==i?i:Oe(e);return this._sendUserMessage(t,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isFileMessage()){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(i).throw(t.SendbirdError.invalidParameters);const a=null!==(n=e.messageParams)&&void 0!==n?n:xe(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}updateFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},Be),s);t.unless(t.isTypeOf("number",e)&&(e=>De(e))(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Ft(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),r=yield n.send(a),{message:o}=r.as(Bt);return o}))}uploadFile(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),a=t.uuid(),r=new i({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a});r.uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a);const o=yield s.send(r),{url:l,thumbnails:d}=o.as(n);return{requestId:a,url:l,thumbnails:d}}))}cancelUploadingFileMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e)).throw(t.SendbirdError.invalidParameters);const{fileMessageQueue:s}=zi.of(this._iid);return s.cancel(this,e),!0}))}copyFileMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Es&&s instanceof Y&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const r=new t.Deferred,o=t.undefineNullProps(Object.assign(Object.assign({},s),{fileUrl:s.url,fileName:s.name,fileSize:s.size,mimeType:s.type,mentionType:s.mentionType,mentionedUserIds:null!==(i=s.mentionedUserIds)&&void 0!==i?i:null===(n=s.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=s.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:s.requireAuth,isPinnedMessage:!1}));return e._sendFileMessage(o).onSucceeded((e=>r.resolve(e))).onFailed((e=>r.reject(e))),r.promise}))}copyMessage(e,s){t.unless(e instanceof Es&&s instanceof F&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=s,n=e;if(i.isUserMessage()){t.unless(!i.poll).throw(t.SendbirdError.notSupportedError);const e=Se(i);return n._sendUserMessage(e)}if(i.isFileMessage()){const e=Re(i);return n._sendFileMessage(e)}if(s.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}deleteMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){if(t.unless(e instanceof q).throw(t.SendbirdError.invalidParameters),e.messageId>0){const{requestQueue:s}=t.Vault.of(this._iid),i=new t.DeleteMessageRequestCommand({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof F?e._messageToken:void 0});yield s.send(i)}}))}addReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new jt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as(Vt);return r}))}deleteReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new zt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as($t);return r}))}_updateUserMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Dt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(qt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}_updateFileMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new Ft({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(Bt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}createMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"add",!0):this._updateUserMessageMetaArray(e.messageId,i,"add",!0)}))}deleteMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof q&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new m({key:e})));return e instanceof Y?this._updateFileMessageMetaArray(e.messageId,i,"remove",!0):this._updateUserMessageMetaArray(e.messageId,i,"remove",!0)}))}addMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"add",!0):this._updateUserMessageMetaArray(e.messageId,s,"add",!0)}))}removeMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof q&&e.messageId>0&&s.every((e=>e instanceof m))).throw(t.SendbirdError.invalidParameters),e instanceof Y?this._updateFileMessageMetaArray(e.messageId,s,"remove",!0):this._updateUserMessageMetaArray(e.messageId,s,"remove",!0)}))}report(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isEnumOf(exports.ReportCategory,e)&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:n}=t.Vault.of(this._iid),a=new Ut({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:s});yield n.send(a)}))}reportUser(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof t.User&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new Rt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.userId,category:s,description:i});yield a.send(r)}))}reportMessage(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof F&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new xt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:s,description:i,messageToken:e._messageToken});yield a.send(r)}))}updatePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&(e=>t.isTypeOf("string",e.title,!0)&&t.validatePollData(e.data)&&t.isTypeOf("boolean",e.allowUserSuggestion,!0)&&t.isTypeOf("boolean",e.allowMultipleVotes,!0)&&t.isTypeOf("number",e.closeAt,!0))(s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Jt(Object.assign({pollId:e},s)),a=yield i.send(n),{poll:r}=a.as(Xt);return r}))}deletePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Zt({pollId:e});yield i.send(n)}))}closePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new es({pollId:e}),a=yield i.send(n),{poll:r}=a.as(ts);return r}))}addPollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("string",s)&&""!==s.trim();t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new ss({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:s}),r=yield n.send(a),{poll:o}=r.as(is);return o}))}updatePollOption(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const n=t.isTypeOf("number",e)&&t.isTypeOf("number",s)&&t.isTypeOf("string",i)&&""!==i.trim();t.unless(n).throw(t.SendbirdError.invalidParameters);const{requestQueue:a}=t.Vault.of(this._iid),r=new ns({pollId:e,pollOptionId:s,optionText:i}),o=yield a.send(r),{poll:l}=o.as(as);return l}))}deletePollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new rs({pollId:e,pollOptionId:s});yield n.send(a)}))}votePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isArrayOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n,dispatcher:a}=t.Vault.of(this._iid),r=new os({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:s}),o=yield n.send(r),{event:l}=o.as(ls);return a.dispatch(new t.PollVoteInternalEventCommand({event:l,source:t.CollectionEventSource.EVENT_POLL_VOTED})),l}))}getPollChangeLogsSinceTimestamp(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)).throw(t.SendbirdError.invalidParameters);const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}getPollChangeLogsSinceToken(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e,!0));const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}createPollListQuery(e=10){return new t.PollListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}createPollVoterListQuery(e,s,i=20){return new t.PollVoterListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:s,limit:i})}pinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new fs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}unpinMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&e>0).throw(t.SendbirdError.invalidParameters);const{requestQueue:s}=t.Vault.of(this._iid),i=new vs({channelType:this.channelType,channelUrl:this.url,messageId:e});yield s.send(i)}))}}const Ts={};class bs{constructor({dbname:e,itemSizeLimit:t=1048576,cacheLimit:s=256,blockHashBase:i=2,blockHashMultiplier:n=10,blockHashConstant:a=11,transactionApplyDelay:r=200,disableLogger:o=!1}){return Ts[e]||(this.itemSizeLimit=t,this.cacheLimit=s,this.blockHashBase=i,this.blockHashMultiplier=n,this.blockHashConstant=a,this.transactionApplyDelay=r,this.disableLogger=o,Ts[e]=this),Ts[e]}static get(e){return Ts[e]}}var Ms,Ss;!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"}(Ms||(Ms={}));class Os extends Error{constructor({code:e=Ms.UNKNOWN_ERROR,message:t="Unknown error occurred."}){super(t),this.code=e,Object.setPrototypeOf(this,Os.prototype)}static get storeNotDefined(){return new Os({code:Ms.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}static get storeNotAvailable(){return new Os({code:Ms.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}static get storeNotAvailableInPrivateBrowsing(){return new Os({code:Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}static get storeIsFull(){return new Os({code:Ms.STORE_IS_FULL,message:"Store is full."})}static get storeNotInitialized(){return new Os({code:Ms.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}static get storeKeyTypeIsInvalid(){return new Os({code:Ms.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}static get storeBrokenIntegrity(){return new Os({code:Ms.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}static get storeBrokenBlob(){return new Os({code:Ms.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}static get storeEncryptionInvalid(){return new Os({code:Ms.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}static get storeItemSizeExceeded(){return new Os({code:Ms.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}static get storeReadFailed(){return new Os({code:Ms.STORE_READ_FAILED,message:"Failed to read from store."})}static get storeWriteFailed(){return new Os({code:Ms.STORE_WRITE_FAILED,message:"Failed to write to store."})}static get databaseSchemaNotOnUpgrade(){return new Os({code:Ms.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}static get collectionNotReady(){return new Os({code:Ms.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}static get collectionKeyNotMatch(){return new Os({code:Ms.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}static get collectionQueryNotValid(){return new Os({code:Ms.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}static get collectionInsertDuplicate(){return new Os({code:Ms.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}static get collectionKeyNotFound(){return new Os({code:Ms.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}static get collectionKeyNotGiven(){return new Os({code:Ms.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}static get collectionWriteFailed(){return new Os({code:Ms.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}static get collectionItemSizeExceeded(){return new Os({code:Ms.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}static get indexTableIsRequired(){return new Os({code:Ms.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}static get indexTypesNotMatch(){return new Os({code:Ms.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}static get compareTypesNotMatch(){return new Os({code:Ms.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}static get circularReferenceFound(){return new Os({code:Ms.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ss||(Ss={}));const As=(e,t=new WeakMap)=>{if("object"==typeof e&&null!==e){if(t.has(e))throw Os.circularReferenceFound;{let s;return t.set(e,!0),Array.isArray(e)?s=e.map((e=>As(e,t))):e instanceof RegExp||e instanceof Date?s=e:(s={},Object.keys(e).forEach((i=>{s[i]=As(e[i],t)}))),t.delete(e),s}}return e},Cs=(e,t)=>{if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Os.compareTypesNotMatch;let s=0;switch(typeof e){case"boolean":case"number":s=e-t;break;case"string":s=e.localeCompare(t)}return s},ws=(e,t)=>{let s=0;for(let t=0;t>>0)%t},Ns=e=>new Promise((t=>{setTimeout((()=>t()),e)})),Ps=(e,t)=>{if(!t)return!1;if("function"!=typeof e){for(const s in e)if(["/and","&&"].includes(s)){if(e[s].some((e=>!Ps(e,t))))return!1}else if(["/or","||"].includes(s)){if(e[s].every((e=>!Ps(e,t))))return!1}else if("/where"===s){if(!(0,e[s])(t))return!1}else{const i=s;if("object"==typeof e[i]){const s=e[i];for(const e in s)switch(e){case"/eq":case"=":if(t[i]!==s[e])return!1;break;case"/neq":case"!=":if(t[i]===s[e])return!1;break;case"/gt":case">":{const n=t[i],a=s[e];if(!(Cs(n,a)>0))return!1;break}case"/gte":case">=":{const n=t[i],a=s[e];if(!(Cs(n,a)>=0))return!1;break}case"/lt":case"<":{const n=t[i],a=s[e];if(!(Cs(n,a)<0))return!1;break}case"/lte":case"<=":{const n=t[i],a=s[e];if(!(Cs(n,a)<=0))return!1;break}case"/in":{const n=t[i];if(!s[e].includes(n))return!1;break}case"/nin":{const n=t[i];if(s[e].includes(n))return!1;break}case"/contain":{const n=t[i],a=s[e];if(!n.includes(a))return!1;break}case"/regex":{const n=t[i];if(!s[e].test(n))return!1;break}case"/where":{const n=t[i];if(!(0,s[e])(n))return!1;break}}}else if("function"==typeof e[i]){if(!e[i](t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}return e(t)},Us=()=>{},Rs=()=>Promise.resolve(),xs=e=>e,ks=(e,t)=>{t()};var Ls;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Ls||(Ls={}));class Ds{constructor({initialPrevValue:e=null,initialNextValue:t=null,iterator:s,map:i=xs,backward:n=Rs,forward:a=Rs,complete:r=Us}){this._prevValue=e,this._nextValue=t,this._error=null,this._map=i,this._backward=n,this._forward=a,this._iterator=s,this._complete=r}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 t.__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 t.__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 qs{constructor({condition:e={},backward:t=!1,blockManager:s,indexer:i}){this.condition=e,this.backward=t,this._blockManager=s,this._indexer=i}findOptimizedStartPosition(){const e=["=","/eq",">",">=","/gt","/gte"],t=["=","/eq","<","<=","/lt","/lte"];if(this.backward){let s=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(let i=0;i0?t:e;for(const e in this.condition[n])if(r.includes(e))for(let t=s;t>=0;t--)if(a*Cs(this._indexer.origin[t].columnValues[i],this.condition[n][e])<=0){s=t;break}}else for(let e=s;e>=0;e--)if(a*Cs(this._indexer.origin[e].columnValues[i],this.condition[n])<=0){s=e;break}}return Math.min(s+1,this._indexer.origin.length-1)}{let s=0;if("function"!=typeof this.condition)for(let i=0;i{if((a>0?e:t).includes(r))for(let e=s;e=0){s=e;break}}));else for(let e=s;e=0){s=e;break}}return Math.max(s-1,0)}}each(e){return t.__awaiter(this,void 0,void 0,(function*(){let s=this.findOptimizedStartPosition(),i=0;this.backward&&this._indexer.origin[s]&&(i=this._indexer.origin[s].keys.length-1);const n=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[++i]){if(!this._indexer.origin[++s])return!1;i=0}return!0}return!1},a=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[--i]){if(!this._indexer.origin[--s])return!1;i=this._indexer.origin[s].keys.length-1}return!0}return!1};let r=null;if(this._indexer.origin[s]){const e=this.backward?a:n;do{const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e)){r=e;break}}while(e())}return yield new Promise((o=>{const l=new Ds({initialNextValue:As(r),iterator:e,forward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?a:n;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return As(e)}return null})),backward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?n:a;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&Ps(this.condition,e))return As(e)}return null})),complete:o});e(l)}))}))}}class Fs{constructor({condition:e={},backward:t=!1,mutex:s,blockManager:i,indexer:n}){this._mutex=s,this._iterator=new qs({condition:e,backward:t,blockManager:i,indexer:n})}fetch(e={}){return t.__awaiter(this,void 0,void 0,(function*(){let s=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 Os.collectionQueryNotValid;try{const e=[];return yield this._mutex.lock(),yield this._iterator.each((n=>t.__awaiter(this,void 0,void 0,(function*(){n.error?n.stop():n.hasNext?0===s?(e.push(n.nextValue),0t.__awaiter(this,void 0,void 0,(function*(){s.error?s.stop():s.hasNext?(e++,s.next()):s.stop()})))),this._mutex.unlock(),e}catch(e){throw this._mutex.unlock(),e}}))}}const Bs=e=>`nest@${e}`,js=(e,t)=>`${Bs(e)}/${t}`,Vs=(e,t)=>`${js(e,t)}.metadata`,zs=(e,t)=>`${js(e,t)}/block.`,$s=(e,t)=>`${js(e,t)}/blob.`;class Qs{constructor({dbname:e,collectionName:t,store:s}){this.dbname=e,this.collectionName=t,this.store=s}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.store.get(e);if(t){const{data:e,type:s}=t;if("undefined"!=typeof fetch){const t=yield fetch(e);return yield t.blob()}{const t=512,i=[],n=atob(e.split(",")[1]);for(let e=0;e{const i=((e,t,s,i=0)=>`${$s(e,t)}${s}.${i}`)(this.dbname,this.collectionName,s),n=new FileReader;n.onload=()=>{t({blobId:i,data:n.result,type:e.type})},n.readAsDataURL(e)}));return yield this.store.set({key:t,value:{data:i,type:n}}),t}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this.store.remove(e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=$s(this.dbname,this.collectionName),s=yield this.store.getAllKeys();yield Promise.all(s.filter((t=>t.startsWith(e))).map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this.store.remove(e)})))))}))}}var Gs,Ks,Hs;!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Gs||(Gs={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Ks||(Ks={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Hs||(Hs={}));const Ws=[Ks.PENDING,Ks.VOLATILE],Ys={};class Js{constructor({dbname:e,limit:t=256}){return Ys[e]||(this.dbname=e,this._items=[],this._limit=t,Ys[e]=this),Ys[e]}static get(e){return Ys[e]}get items(){return this._items}find(e,s,i=Hs.DEFAULT){return t.__awaiter(this,void 0,void 0,(function*(){let t=this.get(s);if(t)i===Hs.PERSISTENT&&(t.state=Ks.PERSISTENT);else{const n=yield e.get(s);n&&(t={key:s,value:n,state:i===Hs.PERSISTENT?Ks.PERSISTENT:Ks.VOLATILE},this.put(t))}return t}))}get(e,t=Hs.DEFAULT){const s=this._items.map((e=>e.key)).indexOf(e);if(s>-1){const e=this._items[s];return t===Hs.PERSISTENT&&(e.state=Ks.PERSISTENT),t!==Hs.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)Ws.includes(this._items[t].state)&&Ws.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===Ks.VOLATILE));let s=t.length-this._limit;if(s>0){const e=[];for(const t of this._items)t.state===Ks.VOLATILE&&s>0?s--: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)))}clearForDatabase(e){this.clearByCondition((t=>t.key.startsWith(Bs(e))))}clear(e=!1){this._items=e?[]:this._items.filter((e=>e.state!==Ks.VOLATILE))}}class Xs{constructor({dbname:e,collectionName:t,store:s}){this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=e,this.collectionName=t,this.metadataKey=((e,t)=>`${js(e,t)}/trans.metadata`)(e,t),this.recordsetKey=((e,t)=>`${js(e,t)}/trans.recordset`)(e,t),this._store=s}get generation(){return this._metadata?this._metadata.generation:0}get requestCount(){return this._requests.length}_getReducedRecordset(e=[]){return t.__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=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=[];for(let e=n.requests.length-1;e>=0;e--){const t=n.requests[e],i=t.data;s[i.key]||(a.unshift(t),s[i.key]=!0)}a.length>0&&(n.requests=a,t.unshift(n))}return t}_applyRecord(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname),{generation:i,requests:n}=s;let a=null;try{const e=yield this._store.setMany(n.map((e=>Object.assign(Object.assign({},e.data),{generation:i}))));for(let s=0;s{a&&e(a)}));else{const t=e.filter((e=>e.generation!==i));yield this._store.set({key:this.recordsetKey,value:t}),this._onWrite.forEach((e=>{e(n.map((e=>e.data)))}))}}))}init(){return t.__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,s){switch(e){case Gs.COMMIT:this._onCommit.set(t,s);break;case Gs.WRITE:this._onWrite.set(t,s);break;case Gs.ERROR:this._onError.set(t,s)}}requestWrite(e,t){this._requests.push({data:e,options:t});Js.get(this.dbname).put(Object.assign({state:Ks.PENDING},e))}requestMultipleWrite(e,t){const s=Js.get(this.dbname);for(const i of e)this._requests.push({data:i,options:t}),s.put(Object.assign({state:Ks.PENDING},i))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).clearByCondition((e=>e.state===Ks.PENDING)),this._requests=[]}))}commit(){return t.__awaiter(this,void 0,void 0,(function*(){const e=this._requests;if(e.length>0){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=n.data;s[a.key]||(s[a.key]=!0,t.unshift(n))}const i={generation:this.generation,requests:t},n=yield this._getReducedRecordset([i]);yield this._store.set({key:this.recordsetKey,value:n}),this._metadata.generation++,yield this._store.set({key:this.metadataKey,value:this._metadata});const a=Js.get(this.dbname);for(let e=0;e{t(e.map((e=>e.data)))}));const r=bs.get(this.dbname);setTimeout((()=>{try{this._applyRecord(n,i)}catch(e){this._onError.forEach((t=>t(e)))}}),r.transactionApplyDelay)}}))}}class Zs{constructor({blockId:e,keyName:t,items:s=[],limit:i}){this.blockId=e,this.keyName=t,this.limit=i,this._items=[...s]}static createFromCacheItem(e){return e?new Zs(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 s=t[this.keyName];return e===s}));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 i=s.base*Math.pow(s.multiplier,t)+s.constant;return(s.hashFunction||ws)(e,i)})(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})}`,`${zs(s,i)}${n}.${a}`;var s,i,n,a}_findBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname);for(let s=this.metadata.blockLevel;s>0;s--){const i=this.createBlockId(e,s),n=yield t.find(this._store,i);if(n){const t=Zs.createFromCacheItem(n);if(null==t?void 0:t.getItemByKey(e))return t}}return null}))}getFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return t?t.getItemByKey(e):null}))}putToBlock(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=bs.get(this.dbname),i=this.createBlockId(e),n=Math.floor(this._store.itemSizeLimit/t.itemSizeLimit),a=Js.get(this.dbname),r=yield a.find(this._store,i),o=r?Zs.createFromCacheItem(r):new Zs({blockId:i,keyName:this.keyName,items:[],limit:n});return!!(null==o?void 0:o.add(s))&&(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),!0)}))}removeFromBlock(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const e=zs(this.dbname,this.collectionName),t=(yield this._store.getAllKeys()).filter((t=>t.startsWith(e)));yield this._store.removeMany(t),yield this._transaction.clear();Js.get(this.dbname).clearByCondition((t=>t.key.startsWith(e)))}))}}const ti=e=>{const t=typeof e;return null===e||"undefined"===t||"boolean"===t||"number"===t||"string"===t};class si{constructor({dbname:e,collectionName:t,keyName:s,fields:i,transaction:n,store:a}){this._origin=[],this._table=[];const r=((e,t,s)=>`${js(e,t)}/index.${s}`)(e,t,i.join(">"));this.dbname=e,this.collectionName=t,this.keyName=s,this.fields=i,this.indexerKey=r,this._store=a,this._transaction=n,this._transaction.on(Gs.COMMIT,this.indexerKey,(()=>this.commit())),this._transaction.on(Gs.ERROR,this.indexerKey,(()=>this.abort()))}static createKey(e){return e.join(">")}static parseKey(e){return e.split(">")}_addItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);return n?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:s,keys:[t]}),!0)}_removeItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);if(n){const e=this._table[i].keys.indexOf(t);if(e>-1)return this._table[i].keys.splice(e,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1}get origin(){return this._origin}get table(){return this._table}getColumnValues(e){const t=[];for(let s of this.fields){if("-"===s[0]&&(s=s.slice(1)),!ti(e[s]))throw Os.indexTypesNotMatch;t.push(e[s])}return t}diff(e,t){for(const s in this.fields){const i="-"===this.fields[s][0]?-1:1,n=Cs(e[s],t[s]);if(0!==n)return i*n}return 0}indexOf(e){if(this._table.length>0){let t=0,s=this._table.length-1;for(;t<=s;){const i=Math.floor((t+s)/2),n=this.diff(e,this._table[i].columnValues);if(n>0)t=i+1;else{if(!(n<0))return[i,!0];s=i-1}}return[t,!1]}return[0,!1]}ensure(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.dbname),t=yield e.find(this._store,this.indexerKey,Hs.PERSISTENT);if(t)this._origin=t.value,this._table=As(this._origin);else{const t=zs(this.dbname,this.collectionName),s=yield this._store.getAllKeys();for(const i of s)if(i.startsWith(t)){const t=yield e.find(this._store,i,Hs.NO_CACHE),s=Zs.createFromCacheItem(t);if(s)for(const e of s.items)this._addItem(e)}this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}}))}drop(){return t.__awaiter(this,void 0,void 0,(function*(){Js.get(this.dbname).remove(this.indexerKey),yield this._store.remove(this.indexerKey)}))}addItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}removeItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}clear(){return t.__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=As(this._origin)}abort(){this._table=As(this._origin)}}const ii=()=>"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product,ni=()=>{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)}))};var ai,ri;!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(ai||(ai={})),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"}(ri||(ri={}));const oi={};class li{constructor(e,t={}){return this._state=ai.PROCESSING,this._queue=[],this._activationQueue=[],oi[e]&&!t.forceCreate||(this.nodeId=ni(),this.key=e,ii()&&(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;if(!(null==t?void 0:t.isNestDbMessage))return;const{nodeId:s,requestId:i,key:n,op:a,data:r}=t;if(s!==this.nodeId&&n===this.key)switch(a){case ri.NEWNODE:this._sendSync();break;case ri.CLAIM_HOST:this._sendSync(),this._hostId=s;break;case ri.SYNC_HOST:if(!this.isInSync){this._activationTimeout&&clearTimeout(this._activationTimeout);const{currentItemRequestId:e,queue:t}=r;for(const e of t){this._queue.findIndex((t=>t.requestId===e.requestId))<0&&this._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:this.key,op:ri.REQUEST_LOCK,ts:e.ts})}this._currentItem=this._queue.find((t=>t.requestId===e)),this._completeSync()}break;case ri.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 ri.REQUEST_LOCK:this._requestLock(t);break;case ri.ACQUIRE_LOCK:{const e=this._queue.find((e=>e.requestId===i));this._acquire(e);break}case ri.RELEASE_LOCK:this._release(i)}})),window.addEventListener("beforeunload",(()=>{this._send(ri.REMOVENODE)}))),oi[e]=this),oi[e]}get locked(){return!!this._currentItem}get isHost(){return this._hostId===this.nodeId}get isInSync(){return this._state==ai.DONE}_send(e,t={}){var s;const i={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(s=null==t?void 0:t.requestId)&&void 0!==s?s:ni(),key:this.key,op:e,data:t.data,ts:Date.now()};return ii()&&window.postMessage(i,"*"),i}_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(ri.RELEASE_LOCK,{requestId:t.requestId});const s=this._queue.findIndex((t=>t.requestId===e));s>-1&&this._queue.splice(s,1),t.onReleased&&t.onReleased(e)}}_requestLock(e){return new Promise((t=>{const s={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:e=>{this.isHost&&this._send(ri.ACQUIRE_LOCK,{requestId:e}),t()},onReleased:()=>{this._acquire(this._queue[0])}};let i=!1;for(let e=0;es.ts){this._queue.splice(e,0,s),i=!0;break}i||this._queue.push(s),this._currentItem||this._acquire(this._queue[0])}))}_sendSync(){var e;this.isHost&&this._send(ri.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 t.__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=ai.DONE,this._activationQueue.forEach((e=>e())),this._activationQueue=[])}registerNode(){this._send(ri.NEWNODE),this._waitSync()}claimHost(){this._hostId=this.nodeId,this._send(ri.CLAIM_HOST),this._waitSync()}lock(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._waitUntilSyncCompleted();const e=this._send(ri.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)}}class di{constructor({dbname:e,collectionName:t,keyName:s,keyHash:i,indexes:n,store:a}){this._state=Ss.INIT,this._indexers=[],this.dbname=e,this.name=t,this.keyName=s,this.indexes=[[s],...n.filter((e=>si.createKey(e)!==this.keyName))],this._keyHash=i,this._store=a,this._mutex=new li(((e,t)=>`${js(e,t)}.lock`)(e,t)),this._blobContainer=new Qs({dbname:e,collectionName:t,store:a}),this._transaction=new Xs({dbname:e,collectionName:t,store:a})}static metadataOf(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const t=Vs(e,s);return yield i.get(t)}))}get state(){return this._state}get isReady(){return this._state===Ss.READY}init(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._mutex.lock();try{const e=bs.get(this.dbname),t=yield di.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 ei({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store});const s=[...this.indexes],i=[],n=s.map((e=>si.createKey(e))),a=t?t.indexes.map((e=>si.createKey(e))):[];for(const e of a)n.includes(e)||i.push(si.parseKey(e));const r=[];if(r.push(...s.map((e=>{const t=new si({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store});return this._indexers.push(t),t.ensure()}))),r.push(...i.map((e=>new si({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store}).drop()))),yield Promise.all(r),yield this._transaction.commit(),n.sort().join(",")!==a.sort().join(",")){const e=Vs(this.dbname,this.name);this._metadata.indexes=s,yield this._store.set({key:e,value:this._metadata})}this._state=Ss.READY,this._mutex.unlock()}catch(e){throw this._mutex.unlock(),e}}))}close(){this._state=Ss.CLOSED}_hasPropertyOfKeyName(e){const t=e[this.keyName];return"string"==typeof t&&!!t}_getIndexerBy(e=null){e||(e=[this.keyName]);const t=si.createKey(e);for(const e of this._indexers)if(t===si.createKey(e.fields))return e;throw Os.indexTableIsRequired}_upgradeBlockLevel(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Vs(this.dbname,this.name);this._metadata.blockLevel++,yield this._store.set({key:e,value:this._metadata})}))}_requestInsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName];if(yield this._blockManager.getFromBlock(t))throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),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 t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}}))}_requestRemove(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){yield this._blockManager.clearAllBlocks();for(const e of this._indexers)yield e.clear()}))}getByKey(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{const t=yield this._blockManager.getFromBlock(e);return this._mutex.unlock(),As(t)}catch(e){throw this._mutex.unlock(),e}}))}query(e={}){if(this.isReady)return new Fs({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Os.collectionNotReady}insertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestInsert(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}insertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Os.collectionKeyNotGiven;for(const t of e)yield this._requestInsert(As(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestUpsert(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Os.collectionKeyNotGiven;for(const t of e)yield this._requestUpsert(As(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}update(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Os.collectionKeyNotGiven;return yield this._requestUpdate(As(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}updateIf(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Os.collectionNotReady;yield this._mutex.lock();try{const{where:i={},index:n=null,backward:a=!1}=e,r=[],o=new qs({condition:i,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(n)});yield o.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;Ps(i,t)&&s.set&&("function"!=typeof s.set?Object.keys(s.set).forEach((e=>{var i;t[e]=null===(i=s.set)||void 0===i?void 0:i[e]})):s.set(t),r.push(t)),e.next()}else e.stop()}))));for(const e of r)yield this._requestUpdate(As(e));return yield this._transaction.commit(),this._mutex.unlock(),r}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Os.collectionNotReady;yield this._mutex.lock();try{const{where:s={},index:i=null,backward:n=!1}=e,a=[],r=new qs({condition:s,blockManager:this._blockManager,backward:n,indexer:this._getIndexerBy(i)});yield r.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(Ps(s,t)){const e=t[this.keyName];a.push(e)}e.next()}else e.stop()}))));for(const e of a)yield this._requestRemove(e);return yield this._transaction.commit(),this._mutex.unlock(),a}catch(e){throw this._mutex.unlock(),e}}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Os.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 t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.get(e)}))}saveBlob(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.save(e,s)}))}removeBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.remove(e)}))}removeAllBlobs(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.clear()}))}}const ui="[NESTDB]";let ci=!0;class hi{static off(){ci=!1}static log(...e){ci&&console.log(`${ui}[LOG]`,...e)}static warning(...e){ci&&console.warn(`${ui}[WARNING]`,...e)}static error(...e){ci&&console.error(`${ui}[ERROR]`,...e)}}const pi=[{},{a:700400,n:"error"}];class mi{constructor(e){var s,i,n;this.encryption=null!==(s=e.encryption)&&void 0!==s?s:t.DEFAULT_ENCRYPTION,this.itemSizeLimit=null!==(i=e.itemSizeLimit)&&void 0!==i?i:4194304,this.metadataBuffer=null!==(n=e.metadataBuffer)&&void 0!==n?n:256}get _encryptionCheckKey(){return`${this.dbname}.encrypt`}get _reservedKeys(){return[this._encryptionCheckKey]}_getRawKey(e,t=""){return`${e}${t}`}_generateShardPostfixArray(e=1){return[...Array(e).keys()]}_shardify(e){const{key:t,value:s}=e,i=JSON.stringify(this.encryption.encrypt(s)),n=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(n).map((e=>{const s={key:this._getRawKey(t,`.${e}`),data:i.substring(e*this.adjustedItemSizeLimit,(e+1)*this.adjustedItemSizeLimit)};return 0===e&&(s.metadata={shards:n}),s}))}_resetIfEncryptionChanged(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.get(this._encryptionCheckKey),t={encrypted:pi.map((e=>{var t;return null===(t=this.encryption)||void 0===t?void 0:t.encrypt(e)}))};if(e)if(e.encrypted&&Array.isArray(e.encrypted))for(const s in e.encrypted){if(JSON.stringify(e.encrypted[s])!==JSON.stringify(t.encrypted[s])){hi.warning("Encryption algorithm has changed. Stored data would be cleared."),yield this.clear();break}}else yield this.clear();yield this.set({key:this._encryptionCheckKey,value:t})}))}get adjustedItemSizeLimit(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}usage(){return t.__awaiter(this,void 0,void 0,(function*(){let e=0;const t=yield this._getAllRawKeys();for(const s of t){const t=yield this._getRaw(s);t&&(e+=JSON.stringify(t).length)}return e}))}getAllKeys(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this._getAllRawKeys()).filter((e=>e.endsWith(".0"))).map((e=>e.replace(/\.0$/,""))).filter((e=>!this._reservedKeys.includes(e)))}))}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=this._getRawKey(e,".0"),i=yield this._getRaw(s);if(i)try{const{data:s,metadata:n}=i,a=(null==n?void 0:n.shards)&&n.shards>1?yield Promise.all(this._generateShardPostfixArray(null==n?void 0:n.shards).map((i=>t.__awaiter(this,void 0,void 0,(function*(){if(i>0){const t=this._getRawKey(e,`.${i}`),s=yield this._getRaw(t);if(!s)throw Os.storeBrokenIntegrity;return s.data}return s}))))):[s];return this.encryption.decrypt(JSON.parse(a.join("")))}catch(e){return null}return null}))}set(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._shardify(e);return yield this._setRaw(t),Object.assign({},e.value)}))}setMany(e){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){const t=this._getRawKey(e,".0"),s=yield this._getRaw(t);if(s){const{metadata:t}=s,i=this._generateShardPostfixArray(null==t?void 0:t.shards).map((t=>this._getRawKey(e,`.${t}`)));yield this._removeRaw(i);const n=Js.get(this.dbname);return null==n||n.remove(e),!0}return!1}))}removeMany(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Js.get(this.dbname),s=[];for(const i of e){const e=this._getRawKey(i,".0"),n=yield this._getRaw(e);if(n){const{metadata:e}=n;s.push(...this._generateShardPostfixArray(null==e?void 0:e.shards).map((e=>this._getRawKey(i,`.${e}`))))}null==t||t.remove(i)}return s.length>0&&(yield this._removeRaw(s)),e}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.dbname);null==e||e.clearForDatabase(this.dbname)}))}}const _i=1,gi={};class yi extends mi{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:4194304}));const{delay:s=_i}=e;this.delay=s,this.observer={}}get rawData(){return gi[this.dbname]}set rawData(e){gi[this.dbname]=e}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){if(gi[this.dbname])return Object.keys(gi[this.dbname]);throw Os.storeNotAvailable}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(gi[this.dbname])return yield Ns(this.delay),gi[this.dbname][e]?Object.assign({key:e},gi[this.dbname][e]):null;throw Os.storeNotAvailable}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!gi[this.dbname])throw Os.storeNotAvailable;yield Ns(this.delay);for(const t of e){const{key:e,data:s,metadata:i}=t;gi[this.dbname][e]=Object.freeze({data:s,metadata:i})}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!gi[this.dbname])throw Os.storeNotAvailable;yield Ns(this.delay);for(const t of e)gi[this.dbname][t]&&delete gi[this.dbname][t]}))}observe(e,t,s){this.observer[e]||(this.observer[e]={}),t.forEach((t=>this.observer[e][t]=s))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,gi[this.dbname]||(gi[this.dbname]={}),yield this._resetIfEncryptionChanged()}))}set(e){const s=Object.create(null,{set:{get:()=>super.set}});return t.__awaiter(this,void 0,void 0,(function*(){const t=this.observer[e.key];if(t&&"function"==typeof t.set){const e=t.set();if(e)throw e}return s.set.call(this,e)}))}setMany(e){const s=Object.create(null,{setMany:{get:()=>super.setMany}});return t.__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 s.setMany.call(this,e)}))}clear(){const e=Object.create(null,{clear:{get:()=>super.clear}});return t.__awaiter(this,void 0,void 0,(function*(){yield e.clear.call(this),yield Ns(this.delay),gi[this.dbname]={}}))}}const fi="NestDBStore";var vi;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(vi||(vi={}));var Ii,Ei,Ti;exports.NestDBState=void 0,(Ii=exports.NestDBState||(exports.NestDBState={})).INIT="INIT",Ii.OPENING="OPENING",Ii.OPENED="OPENED",Ii.CLOSED="CLOSED";exports.LogLevel=void 0,(Ei=exports.LogLevel||(exports.LogLevel={}))[Ei.VERBOSE=0]="VERBOSE",Ei[Ei.DEBUG=1]="DEBUG",Ei[Ei.INFO=2]="INFO",Ei[Ei.WARN=3]="WARN",Ei[Ei.ERROR=4]="ERROR",Ei[Ei.NONE=5]="NONE";class bi{constructor(e){var s,i,n,a;this.messageTypeFilter=null!==(s=null==e?void 0:e.messageTypeFilter)&&void 0!==s?s:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(i=null==e?void 0:e.customTypesFilter)&&void 0!==i?i:null,this.senderUserIdsFilter=null!==(n=null==e?void 0:e.senderUserIdsFilter)&&void 0!==n?n:null,this.replyType=null!==(a=null==e?void 0:e.replyType)&&void 0!==a?a:t.ReplyType.NONE}clone(){const e=new bi,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((s=>{e[s]=t[s]})),e}match(e){switch(this.messageTypeFilter){case t.MessageTypeFilter.USER:if(e.messageType!==t.MessageType.USER)return!1;break;case t.MessageTypeFilter.FILE:if(e.messageType!==t.MessageType.FILE)return!1;break;case t.MessageTypeFilter.ADMIN:if(e.messageType!==t.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof F))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof q)switch(this.replyType){case t.ReplyType.NONE:if(e.parentMessageId>0)return!1;break;case t.ReplyType.ONLY_REPLY_TO_CHANNEL:if(e instanceof F&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}}exports.MessageListOrder=void 0,(Ti=exports.MessageListOrder||(exports.MessageListOrder={})).CHANNEL_LATEST="channel_latest",Ti.NEWEST_CHILD_MESSAGE="newest_child_message";const Mi=e=>{switch(e){case exports.MessageListOrder.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Si=()=>["channelUrl","-createdAt","-notificationId"],Oi=Object.assign(Object.assign({},Me),{scheduledAt:void 0}),Ai=Object.assign(Object.assign({},Ee),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ci="UnsentMessage",wi={};class Ni extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),this._mutex=new li("unsendmessagecache.lock"),wi[e]=this}static of(e,t=!1){return wi[e]&&!t||(wi[e]=new Ni(e)),wi[e]}get collection(){const{nestdb:e}=this._cacheContext,s=null==e?void 0:e.collection(Ci);if(!s)throw t.SendbirdError.databaseError;return s}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){if(e.messageId>0)throw t.SendbirdError.invalidParameters;const s=Object.assign({},e.serialize());var i;return e instanceof Q?(e.messageParams&&(s.messageParams=be(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(i=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},be(i)),{scheduledAt:i.scheduledAt})))):e instanceof Y?(e.messageParams&&(s.messageParams=Pe(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(e=>Object.assign(Object.assign({},Pe(e)),{scheduledAt:e.scheduledAt}))(e.scheduledInfo.scheduledMessageParams))):e instanceof G&&e.messageParams&&(s.messageParams=(e=>t.deundefined({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}))(e.messageParams)),s}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return zi.of(this._iid).buildMessageFromSerializedData(e)}_deserializeWithMessageCreateParams(e){var s,i,n;return t.__awaiter(this,void 0,void 0,(function*(){const a=zi.of(this._iid),r=this._deserialize(e);if(e.messageParams)if(r instanceof Q){const t=e.messageParams;r.messageParams=a.buildUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.messageParams;t.fileKey&&"string"==typeof t.fileKey&&Ne(null!==(s=t.fileType)&&void 0!==s?s:"")&&(t.file=null!==(i=yield this.collection.getBlob(t.fileKey))&&void 0!==i?i:void 0),r.messageParams=a.buildFileMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof G){const s=e.messageParams;s&&s.fileInfoList&&(r.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(s,r),yield Promise.all(r.messageParams.fileInfoList.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t,s,i,n;"string"==typeof(null===(t=e._uploadedMetaData)||void 0===t?void 0:t.fileKey)&&Ne(null!==(i=null===(s=e._uploadedMetaData)||void 0===s?void 0:s.fileType)&&void 0!==i?i:"")&&(e.file=null!==(n=yield this.collection.getBlob(e._uploadedMetaData.fileKey))&&void 0!==n?n:void 0)}))))))}if(r.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)if(r instanceof Q){const t=e.scheduledInfo.scheduledMessageParams;r.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof Y){const t=e.scheduledInfo.scheduledMessageParams;t.fileKey&&"string"==typeof t.fileKey&&"string"==typeof t.fileType&&Ne(t.fileType)&&(t.file=null!==(n=yield this.collection.getBlob(t.fileKey))&&void 0!==n?n:void 0),r.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(t,r)}return r}))}_getFileInfoBlobKey(e,t){return`${e}.${t}`}get(e){return t.__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:s=new bi,order:i=exports.MessageListOrder.CHANNEL_LATEST,sendingStatus:n,backward:a=!1,parentMessageId:r}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const o=Mi(i),l={"/where":e=>!!(i!==exports.MessageListOrder.NEWEST_CHILD_MESSAGE||r&&0!==e.parentMessageId&&e.parentMessageId===r)&&s.match(this._deserialize(e))};e&&(l.channelUrl=e),n&&(l.sendingStatus=n);const d={where:l,index:o,backward:a},u=yield this.collection.query(d),c=yield u.fetch({});return Promise.all(c.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._deserializeWithMessageCreateParams(e)})))))}return[]}))}getAllChildMessages(e,s=new bi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){(e instanceof Y||e instanceof G)&&(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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__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 t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e}}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}saveBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y){if(e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}if(e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams){const t=e.scheduledInfo.scheduledMessageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Ce.BLOB}}}else if(e instanceof G){const s=e.messageParams;s&&s.fileInfoList&&Array.isArray(s.fileInfoList)&&(yield Promise.all(s.fileInfoList.map(((s,i)=>t.__awaiter(this,void 0,void 0,(function*(){if(s.file&&we(s.file)){const t=yield this.collection.saveBlob(s.file,this._getFileInfoBlobKey(e.reqId,i));s._uploadedMetaData||(s._uploadedMetaData={}),s._uploadedMetaData.fileKey=t,s._uploadedMetaData.fileType=Ce.BLOB}}))))))}}))}}const Pi={};class Ui extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _unsentMessageCache(){return Ni.of(this._iid)}constructor(e){super(e),Pi[e]=this}static of(e,t=!1){return Pi[e]&&!t||(Pi[e]=new Ui(e)),Pi[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(ds)}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 zi.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new bi,order:a=exports.MessageListOrder.CHANNEL_LATEST,backward:r=!1,parentMessageId:o,isPollOnly:l=!1,exactMatch:d=!1,inclusive:u=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const c=Mi(a),h={where:{channelUrl:e,"/where":e=>{if(null!=s&&""!==s)switch(a){case exports.MessageListOrder.CHANNEL_LATEST:if(d&&e.createdAt!==s)return!1;if(r){if(u&&e.createdAts||!u&&e.createdAt>=s)return!1;break;case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:if(!o||0===e.parentMessageId||e.parentMessageId!==o)return!1}return!(l&&!e._poll)&&n.match(this._deserialize(e))}},index:c,backward:r},p=yield this.collection.query(h),m=yield p.fetch({limit:null!=i?i:void 0});return Promise.all(m.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return this._deserialize(e)})))))}return[]}))}getAllChildMessages(e,s=new bi){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})}))}upsert(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.saveBlobs(e);for(const t of e)if(null===(s=t.threadInfo)||void 0===s?void 0:s._isUpdateRequired){const e=yield this.get(t.messageId);(null==e?void 0:e.threadInfo)&&t.threadInfo._updateFrom(e.threadInfo)}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 t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t;let s=[];(null===(t=e.threadInfo)||void 0===t?void 0:t.replyCount)&&e.threadInfo.replyCount>0&&(s=yield this.getAllChildMessages(e)),s.length>0&&(s.forEach((t=>t.applyParentMessage(e))),yield this.upsert(s))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(`${t}`)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:Mi(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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Mi(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=Mi(exports.MessageListOrder.CHANNEL_LATEST),n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}saveBlobs(e){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof Y&&e.messageParams){const t=e.messageParams;if(t.file&&we(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s}}})))))}))}_getGroupChannelPreferenceSize(e){return t.__awaiter(this,void 0,void 0,(function*(){let t=0;const{preference:s}=this._cacheContext,i=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),n=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),a=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),r=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`);return i&&(t+=JSON.stringify(i).length),n&&(t+=JSON.stringify(n).length),a&&(t+=JSON.stringify(a).length),r&&(t+=JSON.stringify(r).length),t}))}}const Ri={};class xi extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),Ri[e]=this}static of(e,t=!1){return Ri[e]&&!t||(Ri[e]=new xi(e)),Ri[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(us)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){return Object.assign({},e.serialize())}_deserialize(e){return zi.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__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:s,limit:i=100,filter:n=new bi,backward:a=!1,exactMatch:r=!1,inclusive:o=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t={where:{channelUrl:e,"/where":e=>{if(s){if(r&&e.createdAt!==s)return!1;if(a){if(o&&e.createdAts||!o&&e.createdAt>=s)return!1}return n.match(this._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:a},l=yield this.collection.query(t);return(yield l.fetch({limit:null!=i?i:void 0})).map((e=>this._deserialize(e)))}return[]}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=e.map((e=>this._serialize(e)));yield this.collection.upsertMany(t)}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}markAsReadByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.updateIf({where:{channelUrl:e,messageStatus:exports.NotificationMessageStatus.SENT,createdAt:{"<":s}}},{set:{messageStatus:exports.NotificationMessageStatus.READ}}))}))}markAsReadByMessageIds(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){return(yield this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":s},messageStatus:exports.NotificationMessageStatus.SENT}},{set:{messageStatus:exports.NotificationMessageStatus.READ}})).length}return 0}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]});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,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Mi(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=["channelUrl","-createdAt","-notificationId"],n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}}const ki={};class Li extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _dispatcher(){return t.Vault.of(this._iid).dispatcher}get _messageCache(){return Ui.of(this._iid)}get _unsentMessageCache(){return Ni.of(this._iid)}get _notificationCache(){return xi.of(this._iid)}constructor(e){super(e),this._observers=new Map,this._dispatcherContext=this._dispatcher.on((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof t.MessageUpdateEventCommand){const{messages:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&e.messageId>0)),r=s.filter((e=>e instanceof q&&e.channelType!==t.ChannelType.OPEN&&0===e.messageId)),o=s.filter((e=>e instanceof H));a.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.upsert(a),yield this._unsentMessageCache.remove(a.map((e=>e instanceof F?e.reqId:null)).filter((e=>null!==e)))})))),n||this._broadcastUpdateEvent(a,i)),r.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.upsert(r)})))),n||this._broadcastUpdateEvent(r,i)),o.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._notificationCache.upsert(o)})))),n||this._broadcastUpdateEvent(o,i))}else if(e instanceof t.MessageRemoveEventCommand){const{messageIds:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>"number"==typeof e)),r=s.filter((e=>"string"==typeof e));yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){a.length>0&&(yield this._messageCache.remove(a)),r.length>0&&(yield this._notificationCache.remove(r))})))),n||this._broadcastRemoveEvent(s,i)}else if(e instanceof t.UnsentMessageRemoveEventCommand){const{reqId:s,source:i}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([s])})))),this._broadcastRemoveUnsentEvent(s,i)}else if(e instanceof t.PollChangeLogEventCommand){const{polls:s,source:i}=e;if(this._cacheContext.localCacheEnabled){const e=s.map((e=>e.messageId)),i=(yield Promise.all(e.map((e=>this._messageCache.get(e))))).filter((e=>e));i.length>0&&s.forEach((e=>{const t=i.find((t=>t.messageId===e.messageId));t&&t.applyPoll(e)})),yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert(i)}))))}this._broadcastPollChangeLogEvent(s,i)}else if(e instanceof t.PollUpdateInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollUpdateEvent(s,i)}else if(e instanceof t.PollVoteInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollVoteEvent(s,i)}else if(e instanceof t.ReactionUpdateEventCommand){const{event:t,source:s}=e;t.messageId>0&&this._broadcastReactionUpdateEvent(t,s)}else if(e instanceof t.ThreadUpdateEventCommand){const{event:t,source:s}=e;this._broadcastThreadUpdateEvent(t,s)}}))))}static of(e,t=!1){var s;return ki[e]&&!t||(ki[e]&&(null===(s=ki[e]._dispatcherContext)||void 0===s||s.close()),ki[e]=new Li(e)),ki[e]}_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)}_broadcastReactionUpdateEvent(e,t){for(const s of this._observers.values())s.onReactionUpdate&&s.onReactionUpdate(e,t)}_broadcastThreadUpdateEvent(e,t){for(const s of this._observers.values())s.onThreadInfoUpdate&&s.onThreadInfoUpdate(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const Di=20;class qi extends t.APIRequestCommand{constructor(e){const{reverse:s=!1,limit:i=Di,keys:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}`,this.params=t.deundefined({token:a,limit:i,reverse:s,order:t.MessageTemplateListOrder.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:n})}}class Fi extends t.APIResponseCommand{constructor(e,t){super(e,t);const{next:s,has_more:i=!1,templates:n}=t;this.nextToken=s,this.hasMore=i,this.templates=n.map((e=>({template:JSON.stringify(e)})))}}class Bi extends t.APIRequestCommand{constructor(e){const{key:s}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_MESSAGE_TEMPLATE}/${s}`}}class ji extends t.APIResponseCommand{constructor(e,t){super(e,t),this.template=JSON.stringify(t)}}const Vi={};class zi{constructor(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}){this._iid=e,this._sdkState=t,this._requestQueue=i,this._dispatcher=s,this._cacheContext=a,Ui.of(e),Ni.of(e),Li.of(e),this.fileMessageQueue=new ne(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}),Vi[e]=this}static of(e){return Vi[e]}buildMessageFromSerializedData(e){const s=t.deserialize(e);if(s.notificationId)return new H(this._iid,H.payloadify(s));switch(s.messageType){case t.MessageType.USER:return new Q(this._iid,Q.payloadify(s));case t.MessageType.FILE:return G._isMultipleFilesMessageSerializedData(s)?new G(this._iid,G.payloadify(s)):new Y(this._iid,Y.payloadify(s));case t.MessageType.ADMIN:return new V(this._iid,V.payloadify(s))}throw t.SendbirdError.invalidParameters}buildUserMessageCreateParamsFromSerializedData(e,s){return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,message:s.message,translationTargetLanguages:Object.keys(s.translations),pollId:e.pollId}))}buildFileMessageCreateParamsFromSerializedData(e,s){var i;return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,file:e.file,fileKey:e.fileKey,fileUrl:s.plainUrl,fileName:s.name,fileSize:s.size,mimeType:s.type,thumbnailSizes:null===(i=s.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),fileType:e.fileType,requireAuth:s.requireAuth}))}buildMultipleFilesMessageCreateParamsFromSerializedData(e,s){return t.deundefined({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,fileInfoList:e.fileInfoList.map((e=>new J(this._iid,e)))})}buildScheduledUserMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildScheduledFileMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildSenderFromSerializedData(e){const s=t.deserialize(e);return new p(this._iid,p.payloadify(s))}getMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new de(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ue);return i}))}getScheduledMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new _e(e),s=yield this._requestQueue.send(t),{message:i}=s.as(ge);return i}))}getMessagesByMessageId(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,token:String(i)},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}getMessagesByTimestamp(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new ce(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}_getMessagesByTimestampForCollection(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE,r,o){return t.__awaiter(this,void 0,void 0,(function*(){const l=new ce(Object.assign(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},ae),n),{checkingHasNext:r,checkingContinuousMessages:o})),d=yield this._requestQueue.send(l),{messages:u,isContinuousMessages:c,hasNext:h}=d.as(he);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:u,source:a})),{messages:u,isContinuousMessages:c,hasNext:h}}))}getThreadedMessagesByTimestamp(e,s,i,n=t.CollectionEventSource.REQUEST_THREADED_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const a=new ce(Object.assign(Object.assign(Object.assign({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:s},B),i),{replyType:t.ReplyType.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),r=yield this._requestQueue.send(a),{messages:o}=r.as(he),l=o.slice(1);return l.forEach((t=>{t.parentMessage=e})),this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:n})),{parentMessage:o[0],threadedMessages:l}}))}getMessageTemplatesByToken(e,s={}){return t.__awaiter(this,void 0,void 0,(function*(){const t=new qi(Object.assign({token:e},s)),i=yield this._requestQueue.send(t),{hasMore:n,nextToken:a,templates:r}=i.as(Fi);return{hasMore:n,token:a,templates:r}}))}getMessageTemplate(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new Bi({key:e}),s=yield this._requestQueue.send(t),{template:i}=s.as(ji);return{template:i}}))}getMessageChangelogs(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS){return t.__awaiter(this,void 0,void 0,(function*(){const r=new pe(t.deundefined(t.undefineNullProps(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},oe),n)))),o=yield this._requestQueue.send(r),{updatedMessages:l,deletedMessagesInfo:d,hasMore:u,nextToken:c}=o.as(me),h=d.map((e=>e.messageId));return l.length>0&&this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),h.length>0&&this._dispatcher.dispatch(new t.MessageRemoveEventCommand({messageIds:h,source:a})),{updatedMessages:l,deletedMessageIds:h,hasMore:u,token:c}}))}}class $i extends t.InstancedObject{constructor(e,s){super(e),this.targetMessageId=0;const i=s.thread_info,n=s.parent_message_id,r=s.channel_url,o=s.channel_type;i&&t.isTypeOf("object",i)&&t.isTypeOf("number",n)&&t.isTypeOf("string",r)&&t.isTypeOf("string",o)&&(this.threadInfo=new a(e,i),this.targetMessageId=n,this.channelUrl=r,this.channelType=o)}}const Qi={channelUrl:"",channelType:t.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1};class Gi extends t.APIRequestCommand{constructor({channelCustomType:e,keyword:s,limit:i,reverse:n,exactMatch:a,channelUrl:r,order:o,messageTimestampFrom:l,messageTimestampTo:d,advancedQuery:u,targetFields:c,nextToken:h}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_SEARCH}/messages`,this.params={custom_type:e,query:s,limit:i,reverse:n,exact_match:a,channel_url:r,message_ts_from:l,message_ts_to:d,sort_field:o,advanced_query:u,target_fields:c,after:h}}}class Ki extends t.APIResponseCommand{constructor(e,t){super(e,t),this.messages=t.results.map((t=>W(e,t))),this.hasNext=t.has_next,this.nextToken=t.end_cursor,this.totalCount=t.total_count}}var Hi;exports.MessageSearchOrder=void 0,(Hi=exports.MessageSearchOrder||(exports.MessageSearchOrder={})).SCORE="score",Hi.TIMESTAMP="ts";class Wi extends t.BaseListQuery{constructor(e,t){var s,i,n,a,r,o,l,d,u;super(e,t),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=t.keyword,this.reverse=null!==(s=t.reverse)&&void 0!==s&&s,this.exactMatch=null!==(i=t.exactMatch)&&void 0!==i&&i,this.channelUrl=null!==(n=t.channelUrl)&&void 0!==n?n:"",this.channelCustomType=null!==(a=t.channelCustomType)&&void 0!==a?a:"",this.messageTimestampFrom=null!==(r=t.messageTimestampFrom)&&void 0!==r?r:null,this.messageTimestampTo=null!==(o=t.messageTimestampTo)&&void 0!==o?o:null,this.order=null!==(l=t.order)&&void 0!==l?l:exports.MessageSearchOrder.SCORE,this.advancedQuery=null!==(d=t.advancedQuery)&&void 0!==d&&d,this.targetFields=null!==(u=t.targetFields)&&void 0!==u?u:null}_validate(){return super._validate()&&t.isTypeOf("string",this.keyword)&&this.keyword.length>0&&t.isTypeOf("boolean",this.reverse)&&t.isTypeOf("boolean",this.exactMatch)&&t.isTypeOf("string",this.channelUrl)&&t.isTypeOf("string",this.channelCustomType)&&(t.isTypeOf("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(t.isTypeOf("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&t.isEnumOf(exports.MessageSearchOrder,this.order)&&t.isTypeOf("boolean",this.advancedQuery)&&t.isArrayOf("string",this.targetFields,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Gi(t.undefineNullProps(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),i=yield e.send(s),{messages:n,hasNext:a,nextToken:r,totalCount:o}=i.as(Ki);return this._nextToken=r,this._hasNext=a,this._isLoading=!1,this.totalCount=o,n}return[]}throw t.SendbirdError.invalidParameters}))}}exports.AdminMessage=V,exports.AppleCriticalAlertOptions=u,exports.BanUserEventCommand=At,exports.BannedUserListQuery=Ye,exports.BaseChannel=Es,exports.BaseMessage=q,exports.BaseMessageUpdateParamsDefault=Le,exports.BaseStore=mi,exports.Config=bs,exports.CreateScheduledUserMessageResponseCommand=Ht,exports.DEFAULT_FEED_LIMIT=100,exports.DEFAULT_GROUPCHANNEL_LIMIT=100,exports.DEFAULT_MESSAGE_LIMIT=100,exports.DEFAULT_NOTIFICATION_LIMIT=100,exports.Feedback=h,exports.FileMessage=Y,exports.FileMessageEventCommand=ee,exports.FreezeEventCommand=Pt,exports.IndexedDbStore=class extends mi{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:104857600})),this._storeName=fi,this._state=vi.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}isTransactionInactiveError(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}_putToObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.put(s);n.addEventListener("success",(e=>{t(e.target.result)})),n.addEventListener("error",(()=>{i("Failed to write.")}))}))}))}_deleteFromObjectStore(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=e.delete(s);n.addEventListener("success",(()=>t(s))),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_openDatabase(e){return new Promise(((t,s)=>{if(this._indexedDb){this._state=vi.OPENING;const i=this._indexedDb.open(e);i.addEventListener("upgradeneeded",(e=>{e.target.result.createObjectStore(fi,{keyPath:"key"})})),i.addEventListener("success",(s=>{this._state=vi.OPEN,this._database=s.target.result,this._openJobQueue.forEach((e=>e())),this._openJobQueue=[],this._database.onclose=()=>{this._database=void 0,this._state=vi.OPENING,setTimeout((()=>{this._openDatabase(e)}),5)},t(this._database)})),i.addEventListener("error",(e=>{this._state=vi.UNINITIALIZED,s(e.target.error)}))}else s(Os.storeNotAvailable)}))}_getObjectStore(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);switch(this._state){case vi.UNINITIALIZED:case vi.OPEN:throw Os.storeNotInitialized;case vi.OPENING:case vi.CLOSED:return new Promise((t=>{this._openJobQueue.push((()=>t(this._getObjectStore(e))))}));default:return yield this._getObjectStore(e)}}))}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readonly");return yield new Promise(((t,s)=>{const i=e.getAllKeys();i.addEventListener("success",(e=>{t(e.target.result)})),i.addEventListener("error",(e=>s(e.target.error)))}))}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readonly");return yield new Promise(((s,i)=>{const n=t.get(e);n.addEventListener("success",(e=>{var t;s(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._putToObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._putToObjectStore(t,s)}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");try{yield Promise.all(e.map((e=>this._deleteFromObjectStore(t,e))))}catch(s){if(!this.isTransactionInactiveError(s))throw s;for(const s of e)yield this._deleteFromObjectStore(t,s)}}))}_triggerDatabaseClose(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}checkAvailability(){return t.__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 Os.storeNotAvailable;if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!ii())throw Os.storeNotAvailable;if(ii()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")){if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Os.storeNotAvailableInPrivateBrowsing}else yield new Promise(((e,t)=>{if(this._indexedDb)try{const s=this._indexedDb.open("_testMozilla");s.onerror=()=>t(Os.storeNotAvailableInPrivateBrowsing),s.onsuccess=s=>{if(s.target.result.close(),this._indexedDb){const t=this._indexedDb.deleteDatabase("_testMozilla");t.onerror=()=>e(),t.onsuccess=()=>e()}else t(Os.storeNotAvailable)}}catch(e){t(Os.storeNotAvailableInPrivateBrowsing)}else t(Os.storeNotAvailable)}))}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yield this.checkAvailability(),yield this._openDatabase(e),yield this._resetIfEncryptionChanged()}))}clear(){const e=Object.create(null,{clear:{get:()=>super.clear}});return t.__awaiter(this,void 0,void 0,(function*(){yield e.clear.call(this);const t=yield this._getObjectStore("readwrite");return yield new Promise(((e,s)=>{const i=t.clear();i.addEventListener("success",(()=>e())),i.addEventListener("error",(e=>s(e.target.error)))}))}))}},exports.Logger=class{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)}},exports.MemoryStore=yi,exports.MessageBroadcast=Li,exports.MessageCache=Ui,exports.MessageFilter=bi,exports.MessageForm=k,exports.MessageFormItem=L,exports.MessageManager=zi,exports.MessageMetaArray=m,exports.MessageRequestHandler=Ie,exports.MessageRetrievalParamsDefault=Qi,exports.MessageReviewInfo=$,exports.MessageSearchQuery=Wi,exports.MessageThreadInfoUpdatedEventCommand=N,exports.MultipleFilesMessage=G,exports.MultipleFilesMessageRequestHandler=ps,exports.MuteUserEventCommand=bt,exports.MutedUserListQuery=Ke,exports.NESTDB_FEEDCHANNEL_COLLECTION_KEY="url",exports.NESTDB_FEEDCHANNEL_COLLECTION_NAME="FeedChannel",exports.NESTDB_GROUPCHANNEL_COLLECTION_KEY="url",exports.NESTDB_GROUPCHANNEL_COLLECTION_NAME="GroupChannel",exports.NESTDB_MESSAGE_COLLECTION_KEY="messageId",exports.NESTDB_MESSAGE_COLLECTION_NAME=ds,exports.NESTDB_NOTIFICATION_COLLECTION_KEY="notificationId",exports.NESTDB_NOTIFICATION_COLLECTION_NAME=us,exports.NESTDB_POLL_COLLECTION_KEY="pollId",exports.NESTDB_POLL_COLLECTION_NAME="Poll",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY="reqId",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME=Ci,exports.NestDB=class{constructor({name:e,version:t,store:s,config:i}){this.name=e,this._version=t,this._state=exports.NestDBState.INIT,this._config=i||new bs({dbname:e}),this._store=s,this._event={success:Us,error:Us,storeReplaced:Us,upgrade:ks},this._collections=new Map,this._globalMutex=new li(`${this.name}.lock`),this._config.disableLogger&&hi.off(),new Js({dbname:e,limit:this._config.cacheLimit})}get version(){return this._version}get state(){return this._state}get store(){return this._store}estimateUsage(){return t.__awaiter(this,void 0,void 0,(function*(){return yield(e=this._store,t.__awaiter(void 0,void 0,void 0,(function*(){return yield e.usage()})));var e}))}commitSchema(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._state!==exports.NestDBState.OPENING)throw Os.databaseSchemaNotOnUpgrade;yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){const{collectionName:t,keyName:s,index:i=[]}=e;this._collections.has(t)||this._collections.set(t,new di({dbname:this.name,collectionName:t,keyName:s,indexes:i,store:this._store}));const n=this._collections.get(t);n&&(yield n.init())})))))}))}open(){var e;return t.__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=(s=this.name,`${Bs(s)}.metadata`),n={version:0,collectionNames:[]},a=null!==(e=yield this._store.get(i))&&void 0!==e?e:n;return new Promise(((e,s)=>{const n=e=>{a.versiont.__awaiter(this,void 0,void 0,(function*(){if(s)e({continued:!1,err:s});else{a.version++,a.collectionNames=Array.from(this._collections.keys());try{yield this._store.set({key:i,value:a}),e({continued:!0})}catch(t){e({continued:!1,err:t})}}})))):e({continued:!1})},r=i=>{const{continued:o=!1,err:l=null}=i;if(o)setTimeout((()=>n(r)),10);else if(l)hi.error(l.message),this._globalMutex.unlock(),this._event.error(l),s(l);else{const i=[];a.collectionNames.forEach((e=>{const s=this._collections.get(e);s&&s.state===Ss.READY||i.push((()=>t.__awaiter(this,void 0,void 0,(function*(){const t=yield di.metadataOf(this.name,e,this._store);if(t){const s=new di({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:t.indexes,store:this._store});this._collections.set(e,s),yield s.init()}})))())})),Promise.all(i).then((()=>{this._state=exports.NestDBState.OPENED,this._globalMutex.unlock(),this._event.success(),e()})).catch((e=>{hi.error(e.message),this._globalMutex.unlock(),this._event.error(e),s(e)}))}};n(r)}))}catch(e){switch(e.code){case Ms.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:hi.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new yi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;case Ms.STORE_NOT_AVAILABLE:hi.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 yi({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;default:throw hi.error(e.message),this._globalMutex.unlock(),this._event.error(e),e}}}var s}))}close(){this._collections.forEach((e=>e.close())),this._state=exports.NestDBState.CLOSED}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this._collections.values()).map((e=>e.clear())))}))}reset(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Js.get(this.name);e&&e.clearForDatabase(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]=ks;else this._event[e]=Us}collection(e){const t=this._collections.get(e);if(t)return t;throw Os.collectionNotReady}},exports.NestDBError=Os,exports.NotificationMessage=H,exports.NotificationMessageCache=xi,exports.OGImage=l,exports.OGMetaData=d,exports.OperatorListQuery=ze,exports.PENDING_MESSAGE_DELAY=2,exports.PinnedMessage=ms,exports.PinnedMessageListQuery=ys,exports.Plugin=z,exports.PollVoteEventCommand=ls,exports.PreviousMessageListQuery=$e,exports.Reaction=o,exports.ReactionEvent=r,exports.ReadAPIRequestCommand=v,exports.ReadAPIResponseCommand=E,exports.ReadEventCommand=I,exports.ReadRequestCommand=f,exports.ReadStatus=y,exports.RestrictedUser=ve,exports.RestrictionInfo=fe,exports.ScheduledFileMessageCreateParamsDefault=Ai,exports.ScheduledUserMessageCreateParamsDefault=Oi,exports.SendableMessage=F,exports.Sender=p,exports.ThreadInfo=a,exports.ThreadInfoUpdateEvent=$i,exports.Thumbnail=s,exports.UnbanUserEventCommand=wt,exports.UnmuteUserEventCommand=St,exports.UnsentMessageCache=Ni,exports.UpdateFileMessageEventCommand=Bt,exports.UpdateMetaCounterEventCommand=vt,exports.UpdateMetaDataEventCommand=lt,exports.UpdateUserMessageEventCommand=qt,exports.UploadFileRequestCommand=i,exports.UploadFileResponseCommand=n,exports.UploadedFileInfo=w,exports.UserMessage=Q,exports.UserMessageEventCommand=Lt,exports.UserMessageUpdateParamsDefault=qe,exports.createFileMessageCreateParams=Re,exports.createFileMessageCreateParamsFromFailedFileMessage=xe,exports.createMultipleFilesMessageCreateParams=function(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((e=>{var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((e=>({maxWidth:e.width,maxHeight:e.height}))),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))},exports.createUserMessageCreateParams=Se,exports.createUserMessageCreateParamsFromFailedUserMessage=Oe,exports.getMessageIndexBy=Mi,exports.getNotificationMessageIndexBy=Si,exports.parseMessagePayload=W,exports.payloadifyMessage=e=>{if(e.notificationId)return H.payloadify(e);switch(e.messageType){case t.MessageType.USER:return Q.payloadify(e);case t.MessageType.FILE:return e.fileInfoList?G.payloadify(e):Y.payloadify(e);case t.MessageType.ADMIN:return V.payloadify(e);default:throw t.SendbirdError.unknown}},exports.validateBaseMessageUpdateParams=De,exports.validateMessageRetrievalParams=e=>t.isTypeOf("string",e.channelUrl)&&t.isEnumOf(t.ChannelType,e.channelType)&&t.isTypeOf("number",e.messageId)&&t.isTypeOf("boolean",e.includeReactions,!0)&&t.isTypeOf("boolean",e.includeMetaArray,!0)&&t.isTypeOf("boolean",e.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",e.includeThreadInfo,!0),exports.validateScheduledFileMessageCreateParams=e=>Te(e)&&t.isTypeOf("number",e.scheduledAt)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),exports.validateScheduledUserMessageCreateParams=e=>Ae(e)&&t.isTypeOf("number",e.scheduledAt,!0),exports.validateUserMessageUpdateParams=Fe; diff --git a/cjs/lib/__bundle-d1419fd1.cjs b/cjs/lib/__bundle-d1419fd1.cjs deleted file mode 100644 index 9e4e842..0000000 --- a/cjs/lib/__bundle-d1419fd1.cjs +++ /dev/null @@ -1 +0,0 @@ -var e=require("./__bundle-0486c467.cjs");class s extends e.BaseCommand{}exports.NotificationCollectionRefreshCommand=s,exports.getFeedChannelIndexBy=e=>["-lastMessageUpdatedAt","-createdAt","syncIndex"]; diff --git a/cjs/lib/__bundle-0f6b8ff3.cjs b/cjs/lib/__bundle-f1e6fb74.cjs similarity index 88% rename from cjs/lib/__bundle-0f6b8ff3.cjs rename to cjs/lib/__bundle-f1e6fb74.cjs index b4b61a3..018d769 100644 --- a/cjs/lib/__bundle-0f6b8ff3.cjs +++ b/cjs/lib/__bundle-f1e6fb74.cjs @@ -1 +1 @@ -var e,s,t,n=require("./__bundle-0486c467.cjs"),r=require("./__bundle-4bcf4070.cjs");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,(s=exports.PublicGroupChannelListOrder||(exports.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",s.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",s.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.ScheduledMessageListOrder=void 0,(t=exports.ScheduledMessageListOrder||(exports.ScheduledMessageListOrder={})).CREATED_AT="created_at",t.SCHEDULED_AT="scheduled_at";class a extends n.BaseCommand{constructor({message:e}){super(),this.message=e}}const o={};var i;exports.UserEventCategory=void 0,(i=exports.UserEventCategory||(exports.UserEventCategory={}))[i.USER_BLOCK=20001]="USER_BLOCK",i[i.USER_UNBLOCK=2e4]="USER_UNBLOCK",i[i.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED";class d{constructor(e){this.category=e.cat,this.data=e.data}static getDataAsUserBlockEvent(e,s){const{blocker:t,blockee:r}=s.data;return{blocker:new n.User(e,t),blockee:new n.User(e,r)}}static getDataAsFriendDiscoveredEvent(e,s){const{friend_discoveries:t}=s.data;return{friendDiscoveries:Array.isArray(t)?t.map((s=>new n.User(e,s))):[]}}}class c extends n.BaseCommand{constructor(e,{userId:s}){super(),this._iid=e,this.userId=s}}class u extends n.BaseCommand{constructor(){super()}}class h extends n.WebSocketEventCommand{constructor(e,s,t){super(e,"USEV",t),this.event=new d(t)}}exports.AutoResendManager=class{constructor(e,{localCacheEnabled:s,enableAutoResend:t,dispatcher:r,sdkState:a,logger:i}){this._iid=e,o[e]=this,this._localCacheEnabled=s,this._enableAutoResend=t,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=i,this._sdkState=a,this._localCacheEnabled&&r.on((e=>{if(e instanceof n.ConnectionStateChangeCommand)switch(e.stateType){case n.ConnectionStateType.CONNECTED:this._isProcessingAutoResend||this.processAutoResendRegisteredPendingMessages().then((()=>this._processNextAutoResend()));break;case n.ConnectionStateType.INTERNAL_DISCONNECTED:case n.ConnectionStateType.EXTERNAL_DISCONNECTED:this._isProcessingAutoResend=!1}}))}static of(e){return o[e]}processNonAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){if(!this._enableAutoResend)return;const e=yield this._fetchAllCachedPendingMessages();for(const s of e)0===s.errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=n.SendingStatus.FAILED,s.errorCode=n.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}))}processAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const s of e)if(this._enableAutoResend&&s.errorCode&&n.isAutoResendableError(s.errorCode)){const e=(new Date).getTime(),t=s.createdAt+2592e5;this._enableAutoResend&&e<=t?this._autoResendQueue.map((e=>e.reqId)).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(t).toLocaleString()),s.sendingStatus=n.SendingStatus.FAILED,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}}))}completeCurrentAndProcessNextAutoResend(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===n.SendingStatus.SUCCEEDED||e.sendingStatus===n.SendingStatus.FAILED&&!n.isAutoResendableError(e.errorCode))){const s=this.indexOf(e);s>=0&&this._autoResendQueue.splice(s,1),0===s&&this._processNextAutoResend()}}_fetchAllCachedPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=r.UnsentMessageCache.of(this._iid),s=new r.MessageFilter;return s.replyType=n.ReplyType.ALL,yield e.fetch({sendingStatus:n.SendingStatus.PENDING,backward:!0,filter:s})}))}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 n.__awaiter(this,void 0,void 0,(function*(){if(this._localCacheEnabled&&this._enableAutoResend&&"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 a({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=a,exports.DatabaseOpenCommand=c,exports.ReduceDBSizeEventCommand=u,exports.UserEvent=d,exports.UserEventCommand=h,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"]}}; +var e,s,t,n=require("./__bundle-2d1d7d4f.cjs"),r=require("./__bundle-ccb8334d.cjs");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,(s=exports.PublicGroupChannelListOrder||(exports.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",s.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",s.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.ScheduledMessageListOrder=void 0,(t=exports.ScheduledMessageListOrder||(exports.ScheduledMessageListOrder={})).CREATED_AT="created_at",t.SCHEDULED_AT="scheduled_at";class a extends n.BaseCommand{constructor({message:e}){super(),this.message=e}}const o={};var d;exports.UserEventCategory=void 0,(d=exports.UserEventCategory||(exports.UserEventCategory={}))[d.USER_BLOCK=20001]="USER_BLOCK",d[d.USER_UNBLOCK=2e4]="USER_UNBLOCK",d[d.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED";class i{constructor(e){this.category=e.cat,this.data=e.data}static getDataAsUserBlockEvent(e,s){const{blocker:t,blockee:r}=s.data;return{blocker:new n.User(e,t),blockee:new n.User(e,r)}}static getDataAsFriendDiscoveredEvent(e,s){const{friend_discoveries:t}=s.data;return{friendDiscoveries:Array.isArray(t)?t.map((s=>new n.User(e,s))):[]}}}class c extends n.BaseCommand{constructor(e,{userId:s}){super(),this._iid=e,this.userId=s}}class u extends n.BaseCommand{constructor(){super()}}class h extends n.WebSocketEventCommand{constructor(e,s,t){super(e,"USEV",t),this.event=new i(t)}}exports.AutoResendManager=class{constructor(e,{localCacheEnabled:s,enableAutoResend:t,dispatcher:r,sdkState:a,logger:d}){this._iid=e,o[e]=this,this._localCacheEnabled=s,this._enableAutoResend=t,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=d,this._sdkState=a,this._localCacheEnabled&&r.on((e=>{if(e instanceof n.ConnectionStateChangeCommand)switch(e.stateType){case n.ConnectionStateType.CONNECTED:this._isProcessingAutoResend||this.processAutoResendRegisteredPendingMessages().then((()=>this._processNextAutoResend()));break;case n.ConnectionStateType.INTERNAL_DISCONNECTED:case n.ConnectionStateType.EXTERNAL_DISCONNECTED:this._isProcessingAutoResend=!1}}))}static of(e){return o[e]}processNonAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){if(!this._enableAutoResend)return;const e=yield this._fetchAllCachedPendingMessages();for(const s of e)0===s.errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=n.SendingStatus.FAILED,s.errorCode=n.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}))}processAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const s of e)if(this._enableAutoResend&&s.errorCode&&n.isAutoResendableError(s.errorCode)){const e=(new Date).getTime(),t=s.createdAt+2592e5;this._enableAutoResend&&e<=t?this._autoResendQueue.map((e=>e.reqId)).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(t).toLocaleString()),s.sendingStatus=n.SendingStatus.FAILED,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}}))}completeCurrentAndProcessNextAutoResend(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===n.SendingStatus.SUCCEEDED||e.sendingStatus===n.SendingStatus.FAILED&&!n.isAutoResendableError(e.errorCode))){const s=this.indexOf(e);s>=0&&this._autoResendQueue.splice(s,1),0===s&&this._processNextAutoResend()}}_fetchAllCachedPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=r.UnsentMessageCache.of(this._iid),s=new r.MessageFilter;return s.replyType=n.ReplyType.ALL,yield e.fetch({sendingStatus:n.SendingStatus.PENDING,backward:!0,filter:s})}))}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 n.__awaiter(this,void 0,void 0,(function*(){if(this._localCacheEnabled&&this._enableAutoResend&&"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 a({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=a,exports.DatabaseOpenCommand=c,exports.ReduceDBSizeEventCommand=u,exports.UserEvent=i,exports.UserEventCommand=h,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"]}}; diff --git a/cjs/lib/__bundle-d349e14c.cjs b/cjs/lib/__bundle-fdee1c40.cjs similarity index 89% rename from cjs/lib/__bundle-d349e14c.cjs rename to cjs/lib/__bundle-fdee1c40.cjs index 9d13de7..2a6132e 100644 --- a/cjs/lib/__bundle-d349e14c.cjs +++ b/cjs/lib/__bundle-fdee1c40.cjs @@ -1 +1 @@ -var e=require("./__bundle-0486c467.cjs"),s=require("./__bundle-4bcf4070.cjs");class t extends e.APIRequestCommand{constructor({channelType:s,channelUrl:t,limit:n,token:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(s)}/${encodeURIComponent(t)}/messages/parent_thread_message`,this.params=e.deundefined(e.undefineNullProps({limit:n,token:i}))}}class n extends e.APIResponseCommand{constructor(e,t){super(e,t),this.token=t.next,this.messages=t.messages.map((t=>s.parseMessagePayload(e,t)))}}class i extends e.ChannelDataListQuery{constructor(e,s,t,n){super(e,s,t,n),this._edge=""}_validate(){return super._validate()}load(){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),i=new t({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),a=yield s.send(i),{messages:r,token:d}=a.as(n);return this._edge=d,this._hasNext=!!d,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}exports.ThreadedParentMessageListQuery=i; +var e=require("./__bundle-2d1d7d4f.cjs"),s=require("./__bundle-ccb8334d.cjs");class t extends e.APIRequestCommand{constructor({channelType:s,channelUrl:t,limit:n,token:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(s)}/${encodeURIComponent(t)}/messages/parent_thread_message`,this.params=e.deundefined(e.undefineNullProps({limit:n,token:i}))}}class n extends e.APIResponseCommand{constructor(e,t){super(e,t),this.token=t.next,this.messages=t.messages.map((t=>s.parseMessagePayload(e,t)))}}class i extends e.ChannelDataListQuery{constructor(e,s,t,n){super(e,s,t,n),this._edge=""}_validate(){return super._validate()}load(){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),i=new t({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),a=yield s.send(i),{messages:r,token:d}=a.as(n);return this._edge=d,this._hasNext=!!d,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}exports.ThreadedParentMessageListQuery=i; diff --git a/cjs/message.cjs b/cjs/message.cjs index 335eea3..0af93d1 100644 --- a/cjs/message.cjs +++ b/cjs/message.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),s=require("./lib/__bundle-4bcf4070.cjs"),t=require("./lib/__bundle-d349e14c.cjs");const r={channelUrl:"",scheduledMessageId:0},a={reverse:!1,limit:20};class n extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}){super.init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}),this._manager=new s.MessageManager(e,{sdkState:t,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:u})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s.MessageRetrievalParamsDefault),t);e.unless(s.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters);const a=yield this._manager.getMessage(r);if(a instanceof s.BaseMessage||a instanceof s.NotificationMessage||null===a)return a;throw"Unknown message type is given."}))}getScheduledMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),s);return e.unless((s=>e.isTypeOf("string",s.channelUrl)&&""!==s.channelUrl&&e.isTypeOf("number",s.scheduledMessageId)&&s.scheduledMessageId>0)(t)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(t)}))}getMessageTemplatesByToken(s,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},a),t);return e.unless(e.isTypeOf("string",s,!0)&&(s=>e.isTypeOf("boolean",s.reverse,!0)&&e.isTypeOf("number",s.limit,!0)&&e.isArrayOf("string",s.keys,!0))(r)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplatesByToken(s,r)}))}getMessageTemplate(s){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",s)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplate(s)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageReviewStatus",{enumerable:!0,get:function(){return e.MessageReviewStatus}}),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=s.AdminMessage,exports.AppleCriticalAlertOptions=s.AppleCriticalAlertOptions,exports.BaseMessage=s.BaseMessage,exports.Feedback=s.Feedback,Object.defineProperty(exports,"FeedbackRating",{enumerable:!0,get:function(){return s.FeedbackRating}}),exports.FileMessage=s.FileMessage,exports.MessageForm=s.MessageForm,exports.MessageFormItem=s.MessageFormItem,Object.defineProperty(exports,"MessageFormItemLayout",{enumerable:!0,get:function(){return s.MessageFormItemLayout}}),exports.MessageMetaArray=s.MessageMetaArray,exports.MessageRequestHandler=s.MessageRequestHandler,exports.MessageReviewInfo=s.MessageReviewInfo,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return s.MessageSearchOrder}}),exports.MessageSearchQuery=s.MessageSearchQuery,exports.MultipleFilesMessage=s.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=s.MultipleFilesMessageRequestHandler,exports.OGImage=s.OGImage,exports.OGMetaData=s.OGMetaData,exports.PreviousMessageListQuery=s.PreviousMessageListQuery,exports.Reaction=s.Reaction,exports.ReactionEvent=s.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return s.ReactionEventOperation}}),exports.Sender=s.Sender,exports.ThreadInfo=s.ThreadInfo,exports.ThreadInfoUpdateEvent=s.ThreadInfoUpdateEvent,exports.Thumbnail=s.Thumbnail,exports.UploadedFileInfo=s.UploadedFileInfo,exports.UserMessage=s.UserMessage,exports.ThreadedParentMessageListQuery=t.ThreadedParentMessageListQuery,exports.MessageModule=n; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-2d1d7d4f.cjs"),s=require("./lib/__bundle-ccb8334d.cjs"),t=require("./lib/__bundle-fdee1c40.cjs");const r={channelUrl:"",scheduledMessageId:0},a={reverse:!1,limit:20};class n extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}){super.init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}),this._manager=new s.MessageManager(e,{sdkState:t,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:u})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s.MessageRetrievalParamsDefault),t);e.unless(s.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters);const a=yield this._manager.getMessage(r);if(a instanceof s.BaseMessage||a instanceof s.NotificationMessage||null===a)return a;throw"Unknown message type is given."}))}getScheduledMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),s);return e.unless((s=>e.isTypeOf("string",s.channelUrl)&&""!==s.channelUrl&&e.isTypeOf("number",s.scheduledMessageId)&&s.scheduledMessageId>0)(t)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(t)}))}getMessageTemplatesByToken(s,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},a),t);return e.unless(e.isTypeOf("string",s,!0)&&(s=>e.isTypeOf("boolean",s.reverse,!0)&&e.isTypeOf("number",s.limit,!0)&&e.isArrayOf("string",s.keys,!0))(r)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplatesByToken(s,r)}))}getMessageTemplate(s){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",s)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplate(s)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageReviewStatus",{enumerable:!0,get:function(){return e.MessageReviewStatus}}),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=s.AdminMessage,exports.AppleCriticalAlertOptions=s.AppleCriticalAlertOptions,exports.BaseMessage=s.BaseMessage,exports.Feedback=s.Feedback,Object.defineProperty(exports,"FeedbackRating",{enumerable:!0,get:function(){return s.FeedbackRating}}),exports.FileMessage=s.FileMessage,exports.MessageForm=s.MessageForm,exports.MessageFormItem=s.MessageFormItem,Object.defineProperty(exports,"MessageFormItemLayout",{enumerable:!0,get:function(){return s.MessageFormItemLayout}}),exports.MessageMetaArray=s.MessageMetaArray,exports.MessageRequestHandler=s.MessageRequestHandler,exports.MessageReviewInfo=s.MessageReviewInfo,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return s.MessageSearchOrder}}),exports.MessageSearchQuery=s.MessageSearchQuery,exports.MultipleFilesMessage=s.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=s.MultipleFilesMessageRequestHandler,exports.OGImage=s.OGImage,exports.OGMetaData=s.OGMetaData,exports.PreviousMessageListQuery=s.PreviousMessageListQuery,exports.Reaction=s.Reaction,exports.ReactionEvent=s.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return s.ReactionEventOperation}}),exports.Sender=s.Sender,exports.ThreadInfo=s.ThreadInfo,exports.ThreadInfoUpdateEvent=s.ThreadInfoUpdateEvent,exports.Thumbnail=s.Thumbnail,exports.UploadedFileInfo=s.UploadedFileInfo,exports.UserMessage=s.UserMessage,exports.ThreadedParentMessageListQuery=t.ThreadedParentMessageListQuery,exports.MessageModule=n; diff --git a/cjs/openChannel.cjs b/cjs/openChannel.cjs index 05214cc..ce79738 100644 --- a/cjs/openChannel.cjs +++ b/cjs/openChannel.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),n=require("./lib/__bundle-4bcf4070.cjs"),t=require("./lib/__bundle-12c1cdf9.cjs"),a=require("./lib/__bundle-05f697db.cjs"),s=require("./lib/__bundle-947cb619.cjs");require("./lib/__bundle-dae7bdf2.cjs");class i 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 r={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)}`,this.params={show_pinned_messages:!0}}}class l extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class d extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o,is_ephemeral:l}))}}class h extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class c extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}class u extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class C extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}const p={};class _ extends t.BaseChannelManager{constructor(n,t){super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.OPEN})),this.subscribeChannelEvent=e.noop,this.unsubscribeChannelEvent=e.noop,this.refreshChannel=()=>e.__awaiter(this,void 0,void 0,(function*(){return e.noop()})),this._openChannelCache=new i(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n).catch((n=>{if(e.isThrowingOutside(n)&&"foreground"===this._sdkState.appState)throw 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]||(p[n]=this)}static of(e){return p[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new P(this._iid,P.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)}get handlers(){return[...this._openChannelHandlers.values()]}_handleEvent(a){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(a.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let s=null;if("MESG"===a.code?s=a.as(n.UserMessageEventCommand):"FILE"===a.code?s=a.as(n.FileMessageEventCommand):"ADMM"!==a.code&&"BRDM"!=a.code||(s=a.as(t.AdminMessageEventCommand)),s){const{message:n,isMentioned:t}=s;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 s=null;if("MEDI"===a.code?s=a.as(n.UpdateUserMessageEventCommand):"FEDI"===a.code?s=a.as(n.UpdateFileMessageEventCommand):"AEDI"===a.code&&(s=a.as(t.UpdateAdminMessageEventCommand)),s){const{message:n,mentionCountChange:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);let s=!1;a.lastPinnedMessage&&a.lastPinnedMessage.messageId===n.messageId&&a.lastPinnedMessage.updatedAte.__awaiter(this,void 0,void 0,(function*(){var e,i;for(const r of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(s&&(null===(e=r.onPinnedMessageUpdated)||void 0===e||e.call(r,a),null===(i=r.onChannelChanged)||void 0===i||i.call(r,a)),r.onMessageUpdated&&r.onMessageUpdated(a,n),t>0&&r.onMentionReceived&&r.onMentionReceived(a,n))}))))}}break}case"DELM":{const{channelUrl:n,channelType:t,messageId:s}=a.as(e.DeleteMessageEventCommand);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.onMessageDeleted&&e.onMessageDeleted(t,s)}))))}break}case"MRCT":{const{channelUrl:n,channelType:s,event:i}=a.as(t.ReactionEventCommand);if(s===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,i)}))))}break}case"MTHD":{const{event:n}=a.as(t.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}=a.as(t.MemberCountUpdateEventCommand),s=[];for(const e of n){const{channelUrl:n,participantCount:t,updatedAt:a}=e,i=yield this.getChannelFromCache(n);i&&i._updateParticipantCount(t,a)&&s.push(i)}if(s.length>0){const n=yield this.upsertChannelsToCache(s);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:s,channelUrl:i,channelType:r}=a.as(t.PollUpdateEventCommand);if(i&&r===e.ChannelType.OPEN){const t=yield this.getChannel(i,!0);this._dispatcher.dispatch(new e.PollUpdateInternalEventCommand({event:n,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),s===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(t,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(t,n)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:i}=a.as(n.PollVoteEventCommand);if(s&&i===e.ChannelType.OPEN){const n=yield this.getChannel(s,!0);this._dispatcher.dispatch(new e.PollVoteInternalEventCommand({event:t,source:e.CollectionEventSource.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:s}=a.as(t.ChannelEventCommand);if(s.isOpenChannelEvent)switch(s.category){case t.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(c),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(C),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(s.channelUrl,!0),{operators:i}=a.as(t.OperatorUpdateEventCommand);n.operators=i,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,i)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_MUTE:case t.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=a.as(r?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserMuted&&e.onUserMuted(i,o):e.onUserUnmuted&&e.onUserUnmuted(i,o)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_BAN:case t.ChannelEventCategory.USER_CHANNEL_UNBAN:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=a.as(r?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserBanned&&e.onUserBanned(i,o):e.onUserUnbanned&&e.onUserUnbanned(i,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_FREEZE:case t.ChannelEventCategory.CHANNEL_UNFREEZE:{const t=yield this.getChannel(s.channelUrl,!0),{freeze:i}=a.as(n.FreezeEventCommand);t.isFrozen=i,this.upsertChannelsToCache([t]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onChannelFrozen&&e.onChannelFrozen(t):e.onChannelUnfrozen&&e.onChannelUnfrozen(t)}))}))));break}case t.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(s.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 t.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(s.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaDataEventCommand);i&&t._upsertCachedMetaData(i,s.ts),r&&t._upsertCachedMetaData(r,s.ts),o&&t._removeFromCachedMetaData(o,s.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaDataCreated&&e.onMetaDataCreated(t,i),r&&e.onMetaDataUpdated&&e.onMetaDataUpdated(t,r),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(t,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaCounterCreated&&e.onMetaCounterCreated(t,i),r&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(t,r),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(t,o)}))}))));break}case t.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const n=yield this.getChannel(s.channelUrl,!0),{pinnedMessageIds:i,latestPinnedMessage:r,ts:o}=a.as(t.UpdatePinnedMessageEventCommand);o>n._pinnedMessagesUpdatedAt&&(n.pinnedMessageIds=i,n.lastPinnedMessage=r,n._pinnedMessagesUpdatedAt=o,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))})))));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,t)}))}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:i}=s.as(l);return(yield this.upsertChannelsToCache([i]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),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 d(t),s=yield this._requestQueue.send(a),{channel:i}=s.as(l);return this.upsertChannelsToCache([i]),i}))}}const v={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class g 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 m extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:s}=n;this.token=t,this.participants=s.map((n=>new a.Participant(e,n)))}}class E 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 g(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:i}=a.as(m);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class f extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o}))}}class U extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class y 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 P extends n.BaseChannel{constructor(t,a){var s;super(t,a),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(s=a.participant_count)&&void 0!==s?s:0,this.operators=Array.isArray(a.operators)?a.operators.map((n=>new e.User(t,n))):[],this.lastPinnedMessage=a.latest_pinned_message?n.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},a.latest_pinned_message)):null}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))),latest_pinned_message:t.lastPinnedMessage?n.payloadifyMessage(t.lastPinnedMessage):null})))}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 E(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 h({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:i}=a.as(c);this._updateParticipantCount(s,i);_.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),a=new u({channelUrl:this.url}),s=yield t.send(a),{participantCount:i,ts:r}=s.as(C);this._updateParticipantCount(i,r);_.of(this._iid).setExitedToCache(this);n.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,!0)||e.isFile(n.coverUrlOrImage,!0))&&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 f(Object.assign({channelUrl:this.url},t)),i=yield a.send(s),{channel:r}=i.as(U);this._update(r);const o=_.of(this._iid);return yield o.upsertChannelsToCache([r]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,i){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:i});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new y({channelUrl:this.url});yield n.send(t);const a=_.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}updateUserMessage(n,t){const a=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateUserMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}updateFileMessage(n,t){const a=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateFileMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}}class M extends s.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,this.onPinnedMessageUpdated=e.noop}}class T extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:i,customTypes:r,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:i,custom_types:r,show_frozen:o,show_metadata:l,show_pinned_messages:!0})}}class b 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 P(e,n)))),this.ts="number"==typeof s?s:null}}class A extends e.BaseListQuery{constructor(e,n){var t,a,s,i,r;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!==(i=n.urlKeyword)&&void 0!==i?i:null,this.customTypes=null!==(r=n.customTypes)&&void 0!==r?r: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 T(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:i}=a.as(b);this._token=i,this._hasNext=!!i;const r=_.of(this._iid);return yield r.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class O extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}),this._manager=new _(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:i,cacheContext:o,sessionManager:a})}createOpenChannelListQuery(e={}){return new A(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,i){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},r);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=i,this._manager.createChannel(e)}))}}exports.OpenChannel=P,exports.OpenChannelHandler=class extends M{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=A,exports.OpenChannelModule=O,exports.ParticipantListQuery=E; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-2d1d7d4f.cjs"),n=require("./lib/__bundle-ccb8334d.cjs"),t=require("./lib/__bundle-73351257.cjs"),a=require("./lib/__bundle-3d28c10f.cjs"),s=require("./lib/__bundle-0a504be4.cjs");require("./lib/__bundle-dae7bdf2.cjs");class i 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 r={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)}`,this.params={show_pinned_messages:!0}}}class l extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class d extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o,is_ephemeral:l}))}}class h extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class c extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}class u extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class C extends t.ChannelEventCommand{constructor(n,t,a){var s,i;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!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}const p={};class _ extends t.BaseChannelManager{constructor(n,t){super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.OPEN})),this.subscribeChannelEvent=e.noop,this.unsubscribeChannelEvent=e.noop,this.refreshChannel=()=>e.__awaiter(this,void 0,void 0,(function*(){return e.noop()})),this._openChannelCache=new i(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n).catch((n=>{if(e.isThrowingOutside(n)&&"foreground"===this._sdkState.appState)throw 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]||(p[n]=this)}static of(e){return p[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new P(this._iid,P.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)}get handlers(){return[...this._openChannelHandlers.values()]}_handleEvent(a){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(a.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let s=null;if("MESG"===a.code?s=a.as(n.UserMessageEventCommand):"FILE"===a.code?s=a.as(n.FileMessageEventCommand):"ADMM"!==a.code&&"BRDM"!=a.code||(s=a.as(t.AdminMessageEventCommand)),s){const{message:n,isMentioned:t}=s;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 s=null;if("MEDI"===a.code?s=a.as(n.UpdateUserMessageEventCommand):"FEDI"===a.code?s=a.as(n.UpdateFileMessageEventCommand):"AEDI"===a.code&&(s=a.as(t.UpdateAdminMessageEventCommand)),s){const{message:n,mentionCountChange:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);let s=!1;a.lastPinnedMessage&&a.lastPinnedMessage.messageId===n.messageId&&a.lastPinnedMessage.updatedAte.__awaiter(this,void 0,void 0,(function*(){var e,i;for(const r of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(s&&(null===(e=r.onPinnedMessageUpdated)||void 0===e||e.call(r,a),null===(i=r.onChannelChanged)||void 0===i||i.call(r,a)),r.onMessageUpdated&&r.onMessageUpdated(a,n),t>0&&r.onMentionReceived&&r.onMentionReceived(a,n))}))))}}break}case"DELM":{const{channelUrl:n,channelType:t,messageId:s}=a.as(e.DeleteMessageEventCommand);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.onMessageDeleted&&e.onMessageDeleted(t,s)}))))}break}case"MRCT":{const{channelUrl:n,channelType:s,event:i}=a.as(t.ReactionEventCommand);if(s===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,i)}))))}break}case"MTHD":{const{event:n}=a.as(t.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}=a.as(t.MemberCountUpdateEventCommand),s=[];for(const e of n){const{channelUrl:n,participantCount:t,updatedAt:a}=e,i=yield this.getChannelFromCache(n);i&&i._updateParticipantCount(t,a)&&s.push(i)}if(s.length>0){const n=yield this.upsertChannelsToCache(s);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:s,channelUrl:i,channelType:r}=a.as(t.PollUpdateEventCommand);if(i&&r===e.ChannelType.OPEN){const t=yield this.getChannel(i,!0);this._dispatcher.dispatch(new e.PollUpdateInternalEventCommand({event:n,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),s===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(t,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(t,n)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:i}=a.as(n.PollVoteEventCommand);if(s&&i===e.ChannelType.OPEN){const n=yield this.getChannel(s,!0);this._dispatcher.dispatch(new e.PollVoteInternalEventCommand({event:t,source:e.CollectionEventSource.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:s}=a.as(t.ChannelEventCommand);if(s.isOpenChannelEvent)switch(s.category){case t.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(c),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:i}=a.as(C),r=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(s.channelUrl,!0),{operators:i}=a.as(t.OperatorUpdateEventCommand);n.operators=i,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,i)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_MUTE:case t.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=a.as(r?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserMuted&&e.onUserMuted(i,o):e.onUserUnmuted&&e.onUserUnmuted(i,o)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_BAN:case t.ChannelEventCategory.USER_CHANNEL_UNBAN:{const i=yield this.getChannel(s.channelUrl,!0),r=s.category===t.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=a.as(r?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserBanned&&e.onUserBanned(i,o):e.onUserUnbanned&&e.onUserUnbanned(i,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_FREEZE:case t.ChannelEventCategory.CHANNEL_UNFREEZE:{const t=yield this.getChannel(s.channelUrl,!0),{freeze:i}=a.as(n.FreezeEventCommand);t.isFrozen=i,this.upsertChannelsToCache([t]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onChannelFrozen&&e.onChannelFrozen(t):e.onChannelUnfrozen&&e.onChannelUnfrozen(t)}))}))));break}case t.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(s.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 t.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(s.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaDataEventCommand);i&&t._upsertCachedMetaData(i,s.ts),r&&t._upsertCachedMetaData(r,s.ts),o&&t._removeFromCachedMetaData(o,s.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaDataCreated&&e.onMetaDataCreated(t,i),r&&e.onMetaDataUpdated&&e.onMetaDataUpdated(t,r),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(t,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:i,updated:r,deleted:o}=a.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaCounterCreated&&e.onMetaCounterCreated(t,i),r&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(t,r),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(t,o)}))}))));break}case t.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const n=yield this.getChannel(s.channelUrl,!0),{pinnedMessageIds:i,latestPinnedMessage:r,ts:o}=a.as(t.UpdatePinnedMessageEventCommand);o>n._pinnedMessagesUpdatedAt&&(n.pinnedMessageIds=i,n.lastPinnedMessage=r,n._pinnedMessagesUpdatedAt=o,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))})))));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,t)}))}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:i}=s.as(l);return(yield this.upsertChannelsToCache([i]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),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 d(t),s=yield this._requestQueue.send(a),{channel:i}=s.as(l);return this.upsertChannelsToCache([i]),i}))}}const v={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class g 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 m extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:s}=n;this.token=t,this.participants=s.map((n=>new a.Participant(e,n)))}}class E 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 g(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:i}=a.as(m);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class f extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,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:i,custom_type:r,operators:o}))}}class U extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new P(e,n)}}class y 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 P extends n.BaseChannel{constructor(t,a){var s;super(t,a),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(s=a.participant_count)&&void 0!==s?s:0,this.operators=Array.isArray(a.operators)?a.operators.map((n=>new e.User(t,n))):[],this.lastPinnedMessage=a.latest_pinned_message?n.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},a.latest_pinned_message)):null}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))),latest_pinned_message:t.lastPinnedMessage?n.payloadifyMessage(t.lastPinnedMessage):null})))}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 E(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 h({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:i}=a.as(c);this._updateParticipantCount(s,i);_.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),a=new u({channelUrl:this.url}),s=yield t.send(a),{participantCount:i,ts:r}=s.as(C);this._updateParticipantCount(i,r);_.of(this._iid).setExitedToCache(this);n.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,!0)||e.isFile(n.coverUrlOrImage,!0))&&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 f(Object.assign({channelUrl:this.url},t)),i=yield a.send(s),{channel:r}=i.as(U);this._update(r);const o=_.of(this._iid);return yield o.upsertChannelsToCache([r]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,i){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:i});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new y({channelUrl:this.url});yield n.send(t);const a=_.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}updateUserMessage(n,t){const a=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateUserMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}updateFileMessage(n,t){const a=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateFileMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){_.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){_.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}}class M extends s.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,this.onPinnedMessageUpdated=e.noop}}class T extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:i,customTypes:r,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:i,custom_types:r,show_frozen:o,show_metadata:l,show_pinned_messages:!0})}}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 P(e,n)))),this.ts="number"==typeof s?s:null}}class b extends e.BaseListQuery{constructor(e,n){var t,a,s,i,r;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!==(i=n.urlKeyword)&&void 0!==i?i:null,this.customTypes=null!==(r=n.customTypes)&&void 0!==r?r: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 T(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:i}=a.as(A);this._token=i,this._hasNext=!!i;const r=_.of(this._iid);return yield r.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class O extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}),this._manager=new _(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:i,cacheContext:o,sessionManager:a})}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,i){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},r);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=i,this._manager.createChannel(e)}))}}exports.OpenChannel=P,exports.OpenChannelHandler=class extends M{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=b,exports.OpenChannelModule=O,exports.ParticipantListQuery=E; diff --git a/cjs/poll.cjs b/cjs/poll.cjs index e0bd740..bef8381 100644 --- a/cjs/poll.cjs +++ b/cjs/poll.cjs @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-0486c467.cjs"),t=require("./lib/__bundle-dae7bdf2.cjs");class r extends e.Module{constructor(){super(...arguments),this.name="poll"}init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}){super.init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new e.PollManager(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n})}create(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollCreateParamsDefault),t);return e.unless(e.validatePollCreateParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.create(r)}))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollRetrievalParamsDefault),t);return e.unless(e.validatePollRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.get(r)}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollOptionRetrievalParamsDefault),t);return e.unless(e.validatePollOptionRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(r)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=e.Poll,exports.PollListQuery=e.PollListQuery,exports.PollOption=e.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return e.PollStatus}}),exports.PollVoteEvent=e.PollVoteEvent,exports.PollVoterListQuery=e.PollVoterListQuery,exports.PollUpdateEvent=t.PollUpdateEvent,exports.PollModule=r; +Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-2d1d7d4f.cjs"),t=require("./lib/__bundle-dae7bdf2.cjs");class r extends e.Module{constructor(){super(...arguments),this.name="poll"}init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}){super.init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new e.PollManager(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n})}create(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollCreateParamsDefault),t);return e.unless(e.validatePollCreateParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.create(r)}))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollRetrievalParamsDefault),t);return e.unless(e.validatePollRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.get(r)}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollOptionRetrievalParamsDefault),t);return e.unless(e.validatePollOptionRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(r)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=e.Poll,exports.PollListQuery=e.PollListQuery,exports.PollOption=e.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return e.PollStatus}}),exports.PollVoteEvent=e.PollVoteEvent,exports.PollVoterListQuery=e.PollVoterListQuery,exports.PollUpdateEvent=t.PollUpdateEvent,exports.PollModule=r; diff --git a/feedChannel.js b/feedChannel.js index 2336b4b..94a11cb 100644 --- a/feedChannel.js +++ b/feedChannel.js @@ -1 +1 @@ -import{e,u as t,c as n,w as r,s as a,g as i,p as o,q as s,_ as c,b as u,af as l,t as h,b8 as d,B as f,A as p,d as v,f as _,h as g,bg as y,az as m,a as C,bp as b,aQ as w,Q as E,V as M,au as T,W as N,bq as k,z as x,a2 as I,C as S,O as A,a8 as U,G as D,an as F,bk as R,aw as O,ai as P,b9 as H,ba as L,aA as j,aO as G,a_ as V}from"./lib/__bundle-c03282ec.js";import{i as z,aO as B,aj as Q,aP as q,ac as W,aQ as K,aR as J,T as Y,z as X,aS as Z,aT as $}from"./lib/__bundle-45809bc9.js";export{aj as NotificationMessage,aR as NotificationMessageStatus}from"./lib/__bundle-45809bc9.js";import{y as ee,z as te,A as ne,B as re,o as ae,E as ie,F as oe,I as se,b as ce}from"./lib/__bundle-03052043.js";import{g as ue,N as le}from"./lib/__bundle-5f5bca4c.js";import{D as he}from"./lib/__bundle-1a7e946b.js";import{B as de,C as fe,a as pe}from"./lib/__bundle-5dbd9d35.js";import"./lib/__bundle-acd77193.js";var ve=function(){function n(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}return n.payloadify=function(n){return e(t({id:n.id,name:n.name,is_default:n.isDefault}))},Object.defineProperty(n.prototype,"customType",{get:function(){return this.isDefault?"*":String(this.id)},enumerable:!1,configurable:!0}),n}(),_e=function(t){function l(e,n){var r=n.sdkState,a=n.cacheContext,i=n.channelManager,o=t.call(this,e)||this;return o._channels=new Map,o._sdkState=r,o._cacheContext=a,o._channelManager=i,o}return n(l,t),Object.defineProperty(l.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return r(!!e).throw(a.databaseError),e.collection(z)},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),l.prototype._serialize=function(e,t){return void 0===t&&(t=0),i(i({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},l.prototype._deserialize=function(e){return this._channelManager.buildFeedChannelFromSerializedData(e)},Object.defineProperty(l.prototype,"channels",{get:function(){return o([],s(this._channels.values()),!1)},enumerable:!1,configurable:!0}),l.prototype.isCachedInMemory=function(e){return this._channels.has(e)},l.prototype.get=function(e){return c(this,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=n.sent())return this._channels.set(e,this._deserialize(t)),[2,this._channels.get(e)];n.label=2;case 2:return[2,void 0];case 3:return[2,this._channels.get(e)]}}))}))},l.prototype.fetch=function(e){var t=e.token,n=e.limit,r=void 0===n?B:n,a=e.backward,i=void 0!==a&&a,o=e.order,s=void 0===o?"latest_last_message":o,l=e.borderlineChannelUrl;return c(this,void 0,void 0,(function(){var e,n,a,o,c=this;return u(this,(function(u){switch(u.label){case 0:return this.localCacheEnabled?(e=ue(s),n={where:function(e){if(t&&"latest_last_message"===s)if(!i&&e.lastMessageUpdatedAt>t||i&&e.lastMessageUpdatedAt0&&this._dispatcher.dispatch(new ge({channels:d,context:{source:o}})),f.length>0&&this._dispatcher.dispatch(new ye({channelUrls:f,context:{source:o}})),[2,{updatedChannels:d,deletedChannelUrls:f,hasMore:p,token:v}]}}))}))},l.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){var t,n,o,s,c,l,h;return u(this,(function(u){switch(u.label){case 0:return t=i(i({},te),e),r(ne(t)).throw(a.invalidParameters),n=M.of(this._iid),o=n.sdkState,s=n.requestQueue,c=new re({userId:o.userId,filter:t,includeFeedChannel:!0}),[4,s.send(c)];case 1:return l=u.sent(),h=l.as(ee).unreadFeedCount,[2,void 0===h?0:h]}}))}))},l.prototype.getTotalUnreadNotificationCount=function(){return c(this,void 0,void 0,(function(){var e,t,n,r,a,i;return u(this,(function(o){switch(o.label){case 0:return e=M.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pe({userId:t.userId}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(ee).unreadFeedCount,[2,void 0===i?0:i]}}))}))},l.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){var e,t;return u(this,(function(n){switch(n.label){case 0:return e=new Ie,[4,this._requestQueue.send(e)];case 1:return t=n.sent(),[2,{jsonString:t.as(Se).jsonString}]}}))}))},l.prototype.getNotificationTemplateListByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n,o,s,c,l,h,d;return u(this,(function(u){switch(u.label){case 0:return n=i(i({},De),t),r(C("string",e)&&function(e){return C("boolean",e.reverse,!0)&&E("string",e.keys,!0)&&C("number",e.limit,!0)}(n)).throw(a.invalidParameters),o=new Ae({token:e,keys:n.keys,reverse:n.reverse,limit:n.limit}),[4,this._requestQueue.send(o)];case 1:return s=u.sent(),c=s.as(Ue),l=c.hasMore,h=c.nextToken,d=c.notificationTemplateList,[2,{hasMore:l,token:h,notificationTemplateList:d}]}}))}))},l.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){var t,n;return u(this,(function(i){switch(i.label){case 0:return r(C("string",e)).throw(a.invalidParameters),t=new Fe({key:e}),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,{jsonString:n.as(Re).jsonString}]}}))}))},l.prototype.upsertChannelsToCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.removeChannelsFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return t.sent(),[2]}}))}))},l.prototype.getNotificationMessageFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=I.REFRESH_CHANNEL),c(this,void 0,void 0,(function(){var r,a,i,o,s;return u(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Ee({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Me).channel).myMemberState!==ae.NONE?[3,2]:(this._dispatcher.dispatch(new ye({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new ge({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(s=c.sent()).code!==U.NON_AUTHORIZED&&s.code!==U.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new ye({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},l.prototype.refreshNotificationCollections=function(){this._dispatcher.dispatch(new le)},l.prototype.subscribeChannelEvent=function(e,t){this._feedChannelBroadcast.subscribe(e,t)},l.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},l.prototype._handleEvent=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,l,d,f,p=this;return u(this,(function(v){switch(v.label){case 0:switch(e.code){case"ADMM":case"BRDM":return[3,1];case"READ":return[3,4];case"SYEV":return[3,7]}return[3,13];case 1:return(s="ADMM"===e.code||"BRDM"===e.code?e.as(Oe):null)&&s.message.channelType===this._channelType?(t=s.message,n=s.isMentioned,[4,this.getChannel(t.channelUrl,!0)]):[3,3];case 2:(r=v.sent())._runIfHandleableWithGroupChannel((function(e){var a;t instanceof Q&&n&&(null===(a=t.mentionedUsers)||void 0===a||a.forEach((function(t){var n,r;try{for(var a=h(e.members),i=a.next();!i.done;i=a.next()){var o=i.value;if(t.userId===o.userId){t.nickname=o.nickname,t.plainProfileUrl=o.plainProfileUrl,t.metaData=o.metaData;break}}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}))),p._dispatcher.dispatch(new ge({channels:[r],context:{source:I.EVENT_MESSAGE_RECEIVED}})),p._dispatcher.dispatch(new F({messages:[t],source:I.EVENT_MESSAGE_RECEIVED})),D((function(){return c(p,void 0,void 0,(function(){var e,a,i,o,s;return u(this,(function(c){try{for(e=h(this._feedChannelHandlers.values()),a=e.next();!a.done;a=e.next())(i=a.value).onMessageReceived&&i.onMessageReceived(r,t),n&&i.onMentionReceived&&i.onMentionReceived(r,t)}catch(e){o={error:e}}finally{try{a&&!a.done&&(s=e.return)&&s.call(e)}finally{if(o)throw o.error}}return[2]}))}))}))})),v.label=3;case 3:return[3,13];case 4:return(s="READ"===e.code?e.as(W):null)&&s.readStatus.channelType===this._channelType?(a=s.readStatus,i=this._feedChannelCache.isCachedInMemory(a.channelUrl),[4,this.getChannel(a.channelUrl,!0)]):[3,6];case 5:(o=v.sent())._runIfHandleableWithGroupChannel((function(e){i&&e._updateUnreadMemberState(a.reader.userId,a.readAt),a.reader.userId===p._sdkState.userId&&(i?(e.unreadMessageCount>0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))))})),v.label=6;case 6:return[3,13];case 7:if(!(s="SYEV"===e.code?e.as(fe):null)||s.event.channelType!==this._channelType)return[3,12];switch(l=s.event,l.category){case pe.CHANNEL_DELETED:return[3,8];case pe.CHANNEL_PROP_CHANGED:return[3,10]}return[3,12];case 8:return[4,this.getChannel(l.channelUrl,!0)];case 9:return d=v.sent(),this._dispatcher.dispatch(new ye({channelUrls:[l.channelUrl],context:{source:I.EVENT_CHANNEL_DELETED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(d.url,d.channelType)})),[2]}))}))})),[3,12];case 10:return[4,this.getChannelWithoutCache(l.channelUrl,!0)];case 11:return f=v.sent(),this._dispatcher.dispatch(new ge({channels:[f],context:{source:I.EVENT_CHANNEL_UPDATED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(f)})),[2]}))}))})),[3,12];case 12:return[3,13];case 13:return[2]}}))}))},l.prototype.getMessageFromCache=function(e){var t;return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},l.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return c(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,r.sent()]}}))}))},l.prototype.getMessagesFromCache=function(e,t,n,r,a,i){return void 0===a&&(a=K),void 0===i&&(i=!0),c(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i})];case 1:return[2,o.sent()]}}))}))},l}(de),je=function(e){function t(t,n){var r=e.call(this,t,i(i({},n),{channelManager:Le.of(t)}))||this,a=M.of(r._iid),o=a.connectionManager,s=a.dispatcher;return r._notificationCollectionEventContext=s.on((function(e){e instanceof le&&O(10).then((function(){o.isConnected||o.isConnecting||r.refresh()}))})),r}return n(t,e),t.prototype.keyOf=function(e){return e.notificationId},Object.defineProperty(t.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._notificationCollectionEventContext.close()},t.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},t.prototype._postprocessChannelUpdateEvent=function(e,t){var n,r,a=this._messages.filter((function(t){return t.messageStatus===J.SENT&&t.createdAt<=e.myLastRead}));if(a.length>0){try{for(var i=h(a),o=i.next();!o.done;o=i.next()){o.value.messageStatus=J.READ}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}this._updateMessagesToView(a,t)}},t.prototype._postprocessMessageUpdateEvent=function(e,t){var n,r;if(t===I.EVENT_CHANNEL_READ){var a=[],i=this._messages.map((function(e){return e.notificationId}));try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var c=s.value.notificationId,u=i.indexOf(c);u>=0&&(this._messages[u].messageStatus=J.READ,a.push(this._messages[u]))}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a.length>0&&this._updateMessagesToView(a,t)}},t.prototype._addMessagesToView=function(e,t){var n,r,a=this,i=this._filterUnderOffsetMessage(e),o=[],s=[];try{for(var l=h(i),d=l.next();!d.done;d=l.next()){var f,p=d.value;if(t===I.SYNC_MESSAGE_FILL){if((f=ie(this._messages,p))<0){var v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}}else if((f=ie(this._messages,p))<0){v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}else this._messages[f]=p,s.push(p)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r,a,i;return u(this,(function(c){return e={source:t},o.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===r||r.call(n,e,this.channel,o)),s.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,e,this.channel,s)),[2]}))}))}))},t.prototype._updateMessagesToView=function(e,t){var n,r,a=this,i=[];try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var l=s.value,d=ie(this._messages,l);d>=0&&(i.push(l),this._messages[d]=l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r;return u(this,(function(a){return e={source:t},i.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,i)),[2]}))}))})),i},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._activate()];case 1:return e.sent(),[2]}}))}))},t}(se),Ge=function(e){function t(t,n){var r,a,o=this;return(o=e.call(this,t,n)||this).channelType=S.FEED,o._groupChannel=new ce(t,n),o.isCategoryFilterEnabled=null!==(r=n.is_category_filter_enabled)&&void 0!==r&&r,o.isTemplateLabelEnabled=null===(a=n.is_template_label_enabled)||void 0===a||a,o.notificationCategories=n.categories?n.categories.map((function(e){return new ve(e)})):[],o.lastMessage=n.last_message?Y(o._iid,i({channel_type:o.channelType},n.last_message)):null,o}return n(t,e),t.payloadify=function(e){var t;return i(i({},ce.payloadify(null!==(t=e._groupChannel)&&void 0!==t?t:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((function(e){return ve.payloadify(e)})),last_message:e.lastMessage?Q.payloadify(e.lastMessage):null})},Object.defineProperty(t.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var e,t;return i(i({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((function(e){return P(e)})),lastMessage:null!==(t=null===(e=this.lastMessage)||void 0===e?void 0:e.serialize())&&void 0!==t?t:null})},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},t.prototype.markAsRead=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,c,l,h,d=this;return u(this,(function(u){switch(u.label){case 0:return t=M.of(this._iid),n=t.sdkState,r=t.dispatcher,a=t.requestQueue,!(i=null==e?void 0:e.filter((function(e){return!e||e.messageStatus===J.SENT})).map((function(e){return e.notificationId})))||i.length>0?(o=new $({userId:n.userId,channelUrl:this.url,channelType:S.FEED,notificationIds:i}),[4,a.send(o)]):[3,2];case 1:s=u.sent(),c=s.as(Z),l=c.unreadMessageCount,h=c.readAt,e?("number"==typeof l&&(this._groupChannel._updateUnreadCount(l,this._groupChannel.unreadMentionCount),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)}))),e.forEach((function(e){e.messageStatus=J.READ})),r.dispatch(new F({messages:e,source:I.EVENT_CHANNEL_READ}))):(this._groupChannel._updateUnreadMemberState(n.userId,h),this._groupChannel.unreadMessageCount!==l&&(this._groupChannel._updateUnreadCount(l,0),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})))),r.dispatch(new ge({channels:[this],context:{source:I.EVENT_CHANNEL_READ}})),u.label=2;case 2:return[2]}}))}))},t.prototype.markAsClicked=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.logClicked(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.logClicked=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30)try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.logImpression=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return[2,this.logViewed(e)]}))}))},t.prototype.logViewed=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30){try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2,!0]}return[2,!1]}))}))},t.prototype.logCustom=function(e,t){return c(this,void 0,void 0,(function(){var n,r,a,i,o,s;return u(this,(function(c){if(n=M.of(this._iid).statManager,0t||i&&e.lastMessageUpdatedAt0&&this._dispatcher.dispatch(new ge({channels:d,context:{source:o}})),f.length>0&&this._dispatcher.dispatch(new ye({channelUrls:f,context:{source:o}})),[2,{updatedChannels:d,deletedChannelUrls:f,hasMore:p,token:v}]}}))}))},l.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){var t,n,o,s,c,l,h;return u(this,(function(u){switch(u.label){case 0:return t=i(i({},te),e),r(ne(t)).throw(a.invalidParameters),n=M.of(this._iid),o=n.sdkState,s=n.requestQueue,c=new re({userId:o.userId,filter:t,includeFeedChannel:!0}),[4,s.send(c)];case 1:return l=u.sent(),h=l.as(ee).unreadFeedCount,[2,void 0===h?0:h]}}))}))},l.prototype.getTotalUnreadNotificationCount=function(){return c(this,void 0,void 0,(function(){var e,t,n,r,a,i;return u(this,(function(o){switch(o.label){case 0:return e=M.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pe({userId:t.userId}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(ee).unreadFeedCount,[2,void 0===i?0:i]}}))}))},l.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){var e,t;return u(this,(function(n){switch(n.label){case 0:return e=new Ie,[4,this._requestQueue.send(e)];case 1:return t=n.sent(),[2,{jsonString:t.as(Se).jsonString}]}}))}))},l.prototype.getNotificationTemplateListByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n,o,s,c,l,h,d;return u(this,(function(u){switch(u.label){case 0:return n=i(i({},De),t),r(C("string",e)&&function(e){return C("boolean",e.reverse,!0)&&E("string",e.keys,!0)&&C("number",e.limit,!0)}(n)).throw(a.invalidParameters),o=new Ae({token:e,keys:n.keys,reverse:n.reverse,limit:n.limit}),[4,this._requestQueue.send(o)];case 1:return s=u.sent(),c=s.as(Ue),l=c.hasMore,h=c.nextToken,d=c.notificationTemplateList,[2,{hasMore:l,token:h,notificationTemplateList:d}]}}))}))},l.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){var t,n;return u(this,(function(i){switch(i.label){case 0:return r(C("string",e)).throw(a.invalidParameters),t=new Fe({key:e}),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,{jsonString:n.as(Re).jsonString}]}}))}))},l.prototype.upsertChannelsToCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.removeChannelsFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return t.sent(),[2]}}))}))},l.prototype.getNotificationMessageFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=I.REFRESH_CHANNEL),c(this,void 0,void 0,(function(){var r,a,i,o,s;return u(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Ee({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Me).channel).myMemberState!==ae.NONE?[3,2]:(this._dispatcher.dispatch(new ye({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new ge({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(s=c.sent()).code!==U.NON_AUTHORIZED&&s.code!==U.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new ye({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},l.prototype.refreshNotificationCollections=function(){this._dispatcher.dispatch(new le)},l.prototype.subscribeChannelEvent=function(e,t){this._feedChannelBroadcast.subscribe(e,t)},l.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},l.prototype._handleEvent=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,l,d,f,p=this;return u(this,(function(v){switch(v.label){case 0:switch(e.code){case"ADMM":case"BRDM":return[3,1];case"READ":return[3,4];case"SYEV":return[3,7]}return[3,13];case 1:return(s="ADMM"===e.code||"BRDM"===e.code?e.as(Oe):null)&&s.message.channelType===this._channelType?(t=s.message,n=s.isMentioned,[4,this.getChannel(t.channelUrl,!0)]):[3,3];case 2:(r=v.sent())._runIfHandleableWithGroupChannel((function(e){var a;t instanceof Q&&n&&(null===(a=t.mentionedUsers)||void 0===a||a.forEach((function(t){var n,r;try{for(var a=h(e.members),i=a.next();!i.done;i=a.next()){var o=i.value;if(t.userId===o.userId){t.nickname=o.nickname,t.plainProfileUrl=o.plainProfileUrl,t.metaData=o.metaData;break}}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}))),p._dispatcher.dispatch(new ge({channels:[r],context:{source:I.EVENT_MESSAGE_RECEIVED}})),p._dispatcher.dispatch(new F({messages:[t],source:I.EVENT_MESSAGE_RECEIVED})),D((function(){return c(p,void 0,void 0,(function(){var e,a,i,o,s;return u(this,(function(c){try{for(e=h(this._feedChannelHandlers.values()),a=e.next();!a.done;a=e.next())(i=a.value).onMessageReceived&&i.onMessageReceived(r,t),n&&i.onMentionReceived&&i.onMentionReceived(r,t)}catch(e){o={error:e}}finally{try{a&&!a.done&&(s=e.return)&&s.call(e)}finally{if(o)throw o.error}}return[2]}))}))}))})),v.label=3;case 3:return[3,13];case 4:return(s="READ"===e.code?e.as(W):null)&&s.readStatus.channelType===this._channelType?(a=s.readStatus,i=this._feedChannelCache.isCachedInMemory(a.channelUrl),[4,this.getChannel(a.channelUrl,!0)]):[3,6];case 5:(o=v.sent())._runIfHandleableWithGroupChannel((function(e){i&&e._updateUnreadMemberState(a.reader.userId,a.readAt),a.reader.userId===p._sdkState.userId&&(i?(e.unreadMessageCount>0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))))})),v.label=6;case 6:return[3,13];case 7:if(!(s="SYEV"===e.code?e.as(fe):null)||s.event.channelType!==this._channelType)return[3,12];switch(l=s.event,l.category){case pe.CHANNEL_DELETED:return[3,8];case pe.CHANNEL_PROP_CHANGED:return[3,10]}return[3,12];case 8:return[4,this.getChannel(l.channelUrl,!0)];case 9:return d=v.sent(),this._dispatcher.dispatch(new ye({channelUrls:[l.channelUrl],context:{source:I.EVENT_CHANNEL_DELETED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(d.url,d.channelType)})),[2]}))}))})),[3,12];case 10:return[4,this.getChannelWithoutCache(l.channelUrl,!0)];case 11:return f=v.sent(),this._dispatcher.dispatch(new ge({channels:[f],context:{source:I.EVENT_CHANNEL_UPDATED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(f)})),[2]}))}))})),[3,12];case 12:return[3,13];case 13:return[2]}}))}))},l.prototype.getMessageFromCache=function(e){var t;return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},l.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return c(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,r.sent()]}}))}))},l.prototype.getMessagesFromCache=function(e,t,n,r,a,i){return void 0===a&&(a=K),void 0===i&&(i=!0),c(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i})];case 1:return[2,o.sent()]}}))}))},l}(de),je=function(e){function t(t,n){var r=e.call(this,t,i(i({},n),{channelManager:Le.of(t)}))||this,a=M.of(r._iid),o=a.connectionManager,s=a.dispatcher;return r._notificationCollectionEventContext=s.on((function(e){e instanceof le&&O(10).then((function(){o.isConnected||o.isConnecting||r.refresh()}))})),r}return n(t,e),t.prototype.keyOf=function(e){return e.notificationId},Object.defineProperty(t.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._notificationCollectionEventContext.close()},t.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},t.prototype._postprocessChannelUpdateEvent=function(e,t){var n,r,a=this._messages.filter((function(t){return t.messageStatus===J.SENT&&t.createdAt<=e.myLastRead}));if(a.length>0){try{for(var i=h(a),o=i.next();!o.done;o=i.next()){o.value.messageStatus=J.READ}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}this._updateMessagesToView(a,t)}},t.prototype._postprocessMessageUpdateEvent=function(e,t){var n,r;if(t===I.EVENT_CHANNEL_READ){var a=[],i=this._messages.map((function(e){return e.notificationId}));try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var c=s.value.notificationId,u=i.indexOf(c);u>=0&&(this._messages[u].messageStatus=J.READ,a.push(this._messages[u]))}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a.length>0&&this._updateMessagesToView(a,t)}},t.prototype._addMessagesToView=function(e,t){var n,r,a=this,i=this._filterUnderOffsetMessage(e),o=[],s=[];try{for(var l=h(i),d=l.next();!d.done;d=l.next()){var f,p=d.value;if(t===I.SYNC_MESSAGE_FILL){if((f=ie(this._messages,p))<0){var v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}}else if((f=ie(this._messages,p))<0){v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}else this._messages[f]=p,s.push(p)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r,a,i;return u(this,(function(c){return e={source:t},o.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===r||r.call(n,e,this.channel,o)),s.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,e,this.channel,s)),[2]}))}))}))},t.prototype._updateMessagesToView=function(e,t){var n,r,a=this,i=[];try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var l=s.value,d=ie(this._messages,l);d>=0&&(i.push(l),this._messages[d]=l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r;return u(this,(function(a){return e={source:t},i.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,i)),[2]}))}))})),i},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._activate()];case 1:return e.sent(),[2]}}))}))},t}(se),Ge=function(e){function t(t,n){var r,a,o=this;return(o=e.call(this,t,n)||this).channelType=S.FEED,o._groupChannel=new ce(t,n),o.isCategoryFilterEnabled=null!==(r=n.is_category_filter_enabled)&&void 0!==r&&r,o.isTemplateLabelEnabled=null===(a=n.is_template_label_enabled)||void 0===a||a,o.notificationCategories=n.categories?n.categories.map((function(e){return new ve(e)})):[],o.lastMessage=n.last_message?Y(o._iid,i({channel_type:o.channelType},n.last_message)):null,o}return n(t,e),t.payloadify=function(e){var t;return i(i({},ce.payloadify(null!==(t=e._groupChannel)&&void 0!==t?t:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((function(e){return ve.payloadify(e)})),last_message:e.lastMessage?Q.payloadify(e.lastMessage):null})},Object.defineProperty(t.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var e,t;return i(i({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((function(e){return P(e)})),lastMessage:null!==(t=null===(e=this.lastMessage)||void 0===e?void 0:e.serialize())&&void 0!==t?t:null})},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},t.prototype.markAsRead=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,c,l,h,d=this;return u(this,(function(u){switch(u.label){case 0:return t=M.of(this._iid),n=t.sdkState,r=t.dispatcher,a=t.requestQueue,!(i=null==e?void 0:e.filter((function(e){return!e||e.messageStatus===J.SENT})).map((function(e){return e.notificationId})))||i.length>0?(o=new $({userId:n.userId,channelUrl:this.url,channelType:S.FEED,notificationIds:i}),[4,a.send(o)]):[3,2];case 1:s=u.sent(),c=s.as(Z),l=c.unreadMessageCount,h=c.readAt,e?("number"==typeof l&&(this._groupChannel._updateUnreadCount(l,this._groupChannel.unreadMentionCount),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)}))),e.forEach((function(e){e.messageStatus=J.READ})),r.dispatch(new F({messages:e,source:I.EVENT_CHANNEL_READ}))):(this._groupChannel._updateUnreadMemberState(n.userId,h),this._groupChannel.unreadMessageCount!==l&&(this._groupChannel._updateUnreadCount(l,0),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})))),r.dispatch(new ge({channels:[this],context:{source:I.EVENT_CHANNEL_READ}})),u.label=2;case 2:return[2]}}))}))},t.prototype.markAsClicked=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.logClicked(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.logClicked=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30)try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.logImpression=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return[2,this.logViewed(e)]}))}))},t.prototype.logViewed=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30){try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2,!0]}return[2,!1]}))}))},t.prototype.logCustom=function(e,t){return c(this,void 0,void 0,(function(){var n,r,a,i,o,s;return u(this,(function(c){if(n=M.of(this._iid).statManager,0=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(l=this._metadata.range).extends.apply(l,y([],E(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),p.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),[3,13];case 9:return o=s.sent(),p.debug("channel background sync error",o),o instanceof g&&o.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw o;case 12:return C.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(S=null===(b=m.localCacheConfig)||void 0===b?void 0:b.maxSize)&&void 0!==S?S:0,use_local_cache:m.localCacheEnabled,starting_point:0,message_init_policy:null!==(w=null===(M=t.order)||void 0===M?void 0:M.toString())&&void 0!==w?w:"",collection_id:c.userId}})),[7];case 13:return[3,15];case 14:e.hasNext=!1,e.nextToken="",s.label=15;case 15:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)o.resume();else o.pause()}))}return t.of=function(e){return Pe[e]||(Pe[e]=new t({_iid:e})),Pe[e].ref++,Pe[e]},t.clear=function(e){Pe[e]&&(Pe[e].close(),delete Pe[e])},Object.defineProperty(t.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 _e({})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,i.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new _e(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.resume=function(){var e,t,n=i.of(this._iid),a=n.logger;n.sessionManager.session.hasSession&&(a.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:""))},t.prototype.pause=function(){i.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid])},t}(),Re={},Ve=function(){function t(t){var n=t._iid,a=this;this.ref=0,this._iid=n;var r,o=i.of(this._iid),l=o.logger,u=o.sdkState,c=o.dispatcher,d=o.cacheContext,p=o.statManager;this._metadataKey=(r=u.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta")),this._subscribers=new T;var m=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new fe(m,(function(){return e(a,void 0,void 0,(function(){var e,t,n,a,r,i,o,c,h,f,m,y;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),l.debug("channel changelog sync from",null===(f=this._metadata)||void 0===f?void 0:f.token),s.label=2;case 2:s.trys.push([2,9,,12]),t={includeEmpty:!0,includeMetaData:!0},s.label=3;case 3:return s.trys.push([3,5,,6]),[4,d.preference.get(L(u.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannelChangeLogs(null!==(y=null===(m=this._metadata)||void 0===m?void 0:m.token)&&void 0!==y?y:"",t,A.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=s.sent(),r=a.updatedChannels,i=a.deletedChannelUrls,o=a.hasMore,c=a.token,this._subscribers.dispatch("progress",{updatedChannels:r,deletedChannelUrls:i,hasMore:o,token:c}),e.hasNext=o,e.nextToken=c,this._metadata&&(this._metadata.token=c),l.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),d.localCacheEnabled&&p.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:r.length>0||i.length>0?"cache_miss":"cache_hit",max_db_size:r.length,use_local_cache:d.localCacheEnabled,starting_point:0,message_init_policy:i.length.toString(),collection_id:u.userId}})),[3,12];case 9:return h=s.sent(),l.debug("channel changelog sync error",h),h instanceof g&&h.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw h;case 12:return[2,e]}}))}))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=c.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)a.resume();else a.pause()}))}return t.of=function(e){return Re[e]||(Re[e]=new t({_iid:e})),Re[e].ref++,Re[e]},t.clear=function(e){Re[e]&&(Re[e].close(),delete Re[e])},Object.defineProperty(t.prototype,"isRunning",{get:function(){return this._sync.isRunning},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e,t,n,a;return s(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=i.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.on=function(e,t){return this._subscribers.on(e,t)},t.prototype.resume=function(){i.of(this._iid).sessionManager.session.hasSession&&this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid])},t}(),Ke=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},ze=function(e,t,n){if(e.length>0){for(var a=Ke(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(o<0))return{place:s,oldPosition:a};r=s+1,s=Math.floor((r+i)/2)}}return{place:Qe(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Qe=function(e,t,n){switch(n){case Ge.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?0===(a=t.lastMessage.createdAt-e.lastMessage.createdAt)?t.createdAt-e.createdAt:a:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var a;return 0===(a=e.name.localeCompare(t.name))?e.createdAt-t.createdAt:a;default:return 0}},je=function(){function t(t,n){var a=n.filter,r=void 0===a?new ge:a,o=n.order,l=void 0===o?Ge.LATEST_LAST_MESSAGE:o,u=n.limit,c=void 0===u?ke:u,d=n.includeChangesOnInitialLoad,p=void 0!==d&&d,_=this;this.channels=[],this._isInitialized=!1,this._iid=t,this._key="gcc-".concat(I()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=r,this.order=l,this._hasMore=!0,this._token="",this._limit=c;var v=i.of(this._iid),m=v.sdkState,g=v.cacheContext,y=v.dispatcher;g.localCacheEnabled&&(this._backgroundSync=He.of(t),this._backgroundSync.resume()),this._changelogSync=Ve.of(t),this._changelogSync.resume(),ve.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(me(n)){var a=e.filter((function(e){return _.filter.match(e,m.userId)})),r=e.filter((function(e){return!_.filter.match(e,m.userId)})).map((function(e){return e.url}));a.length>0&&_._addChannelsToView(a,t),r.length>0&&_._removeChannelsFromView(r,t)}},onRemove:function(e,t){_._removeChannelsFromView(e,t)}}),y.on((function(t){t instanceof h&&(t.stateType===f.CONNECTED?_._isGetRemoteChannelsSucceeded||e(_,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):t.stateType===f.LOGOUT&&_.dispose())}))}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,n,a){var r,i,o,l,u=this;void 0===a&&(a=!1);var c=[],h=[],d=[];try{for(var p=F(t),f=p.next();!f.done;f=p.next()){var _=f.value,v=Ke(this.channels,_);v>=0&&this.channels.splice(v,1);var m=ze(this.channels,_,this.order).place;if(v<0)m===this.channels.length?!a&&this._hasMore||(c.push(_),this.channels.push(_)):(c.push(_),this.channels.splice(m,0,_));else switch(n.source){case A.EVENT_CHANNEL_UPDATED:case A.EVENT_MESSAGE_RECEIVED:case A.SYNC_CHANNEL_CHANGELOGS:case A.EVENT_MESSAGE_SENT:this.order===Ge.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&m===this.channels.length?d.push(_):(this.channels.splice(m,0,_),h.push(_));break;default:this.channels.splice(m,0,_),h.push(_)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}if(d.length>0)try{for(var g=F(d),y=g.next();!y.done;y=g.next()){_=y.value;var C=Ke(this.channels,_);-1!==C&&this.channels.splice(C,1)}}catch(e){o={error:e}}finally{try{y&&!y.done&&(l=g.return)&&l.call(g)}finally{if(o)throw o.error}}me(n.source)&&N((function(){return e(u,void 0,void 0,(function(){var e,t,a;return s(this,(function(r){return c.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(n,c),h.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,h),d.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,d.map((function(e){return e.url}))),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,n){var a,r,i=this,o=[],l=function(e){var t=u.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(u.channels[t].url),u.channels.splice(t,1))},u=this;try{for(var c=F(t),h=c.next();!h.done;h=c.next()){l(h.value)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(a)throw a.error}}return me(n.source)&&o.length>0&&N((function(){return e(i,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=ve.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.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()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(a){switch(a.label){case 0:return[4,ve.of(this._iid).getMyGroupChannels(this._token,R(z(z({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},t.prototype._revokeLoadMore=function(){return e(this,void 0,void 0,(function(){var e;return s(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,{source:A.REQUEST_CHANNEL},!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},t.prototype.loadMore=function(){var t;return e(this,void 0,void 0,(function(){var n,a,r,o,l,u,c,h,d,p,f,_,m,y,C,b,S,M,E,w=this;return s(this,(function(L){switch(L.label){case 0:if(this._isDisposed)throw new g({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return n=null,this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning?[4,new Promise((function(e){w._changelogSyncSubscriberContext=w._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}))]:[3,2];case 1:n=L.sent(),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close(),L.label=2;case 2:return a=i.of(this._iid),r=a.cacheContext,o=a.connectionManager,l=a.statManager,this._isInitialized?[3,5]:(this._isInitialized=!0,r.localCacheEnabled?[4,this._backgroundSync.loadMetadata()]:[3,4]);case 3:L.sent(),L.label=4;case 4:l.put(new B({type:v.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{group_channel:!0}}})),L.label=5;case 5:return u=[],this._hasMore?!r.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed?[3,7]:[4,Z((function(){return e(w,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return u=e.sent(),[2]}}))}))}))]:[3,11];case 6:return L.sent(),this._hasMore=u.length>=this._limit,[3,10];case 7:return L.trys.push([7,9,,10]),[4,this._getRemoteChannels()];case 8:return u=L.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,10];case 9:return L.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,10];case 10:this._addChannelsToView(u,{source:A.REQUEST_CHANNEL},!0),L.label=11;case 11:if(n){try{for(c=F(n.updatedChannels),h=c.next();!h.done;h=c.next())d=h.value,(C=Ke(u,d))>=0?u[C]=d:(p=ze(u,d,this.order).place,u.splice(p,0,d))}catch(e){b={error:e}}finally{try{h&&!h.done&&(S=c.return)&&S.call(c)}finally{if(b)throw b.error}}f=u.map((function(e){return e.url}));try{for(_=F(n.deletedChannelUrls),m=_.next();!m.done;m=_.next())y=m.value,(C=f.indexOf(y))>=0&&(u.splice(C,1),f.splice(C,1))}catch(e){M={error:e}}finally{try{m&&!m.done&&(E=_.return)&&E.call(_)}finally{if(M)throw M.error}}}return[2,u]}}))}))},t.prototype.dispose=function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),ve.of(this._iid).unsubscribeChannelEvent(this._key))},t}(),We=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,_=t.metadataValues,v=t.metadataValueStartsWith,m=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=ee.GET,n.path=te,n.params=ne(R({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:ye.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:_,metadata_value_startswith:v,show_frozen:m,show_metadata:g})),n}return $(t,e),t}(ae),Be=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new Ce(t,e)}))),a.ts="number"==typeof s?s:0,a}return $(t,e),t}(re);!function(e){e.ALL="all",e.JOINED="joined"}(De||(De={}));var qe=function(t){function n(e,n){var a,r,i,s,o,l,u,c,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=De.ALL,m.superChannelFilter=Se.ALL,m.metadataKey=null,m.metadataValues=null,m.metadataOrderKeyFilter=null,m.metadataValueStartsWith=null,m.order=Ue.CHRONOLOGICAL,m.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,m.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,m.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,m.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,m.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,m.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,m.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,m.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:De.ALL,m.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Se.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:Ue.CHRONOLOGICAL,m}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("boolean",this.includeEmpty)&&ie("boolean",this.includeFrozen)&&ie("boolean",this.includeMetaData)&&ie("string",this.channelNameContainsFilter,!0)&&se("string",this.channelUrlsFilter,!0)&&se("string",this.customTypesFilter,!0)&&ie("string",this.customTypeStartsWithFilter,!0)&&oe(De,this.membershipFilter)&&oe(Se,this.superChannelFilter)&&oe(Ue,this.order)&&ie("string",this.metadataOrderKeyFilter,!0)&&ie("string",this.metadataKey,!0)&&se("string",this.metadataValues,!0)&&ie("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o,l;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=i.of(this._iid).requestQueue,n=new We(R(z(z({},this),{token:this._token}))),[4,t.send(n)]):[3,2]):[3,5];case 1:return a=s.sent(),r=a.as(Be),o=r.channels,l=r.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),Ye=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 $(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=ue,t.onUserLeft=ue,t.onUserReceivedInvitation=ue,t.onUserDeclinedInvitation=ue,t.onChannelHidden=ue,t.onUnreadMemberStatusUpdated=ue,t.onUndeliveredMemberStatusUpdated=ue,t.onTypingStatusUpdated=ue,t.onPollUpdated=ue,t.onPollVoted=ue,t.onPollDeleted=ue,t.onPinnedMessageUpdated=ue,t}return $(t,e),t}(Ie)),Xe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=ee.GET,n.path="".concat(ce),n.params=ne(R({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return $(t,e),t}(ae),Je=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return Ne(t,e)})),a}return $(t,e),t}(re),Ze=function(t){function n(e,n){var a,r,i,s,o,l=this;return(l=t.call(this,e,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=he.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:he.ALL,l}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("string",this.channelUrl,!0)&&(oe(Oe,this.order)||null===this.order)&&ie("boolean",this.reverse)&&(se(xe,this.scheduledStatus)||null===this.scheduledStatus)&&oe(he,this.messageTypeFilter)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=i.of(this._iid).requestQueue,t=new Xe(R(z(z({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),a=n.as(Je),r=a.scheduledMessages,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),$e=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return $(n,t),n.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new ve(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new je(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Me(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ze(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){de(ie("string",e)&&t instanceof Ye).throw(g.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){de(ie("string",e)).throw(g.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(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannel(t)]}))}))},n.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("string",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("number",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},we),t),de(Le(e)).throw(g.invalidParameters),[2,this._manager.getGroupChannelCount(e)]}))}))},n.prototype.getUnreadItemCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getUnreadItemCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(t)];case 1:return[2,e.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(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),[2,this._manager.createChannel(e)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),e&&(e.isDistinct=!0),[2,this.createChannel(e)]}))}))},n.prototype.createChannelWithUserIds=function(t,n,a,r,i,o){return void 0===n&&(n=!1),void 0===i&&(i=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return s(this,(function(s){return e=z(z({},Te),{invitedUserIds:t,isDistinct:n,name:a,data:i,customType:o}),"string"==typeof r?e.coverUrl=r:e.coverImage=r,[2,this.createChannel(e)]}))}))},n.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(se("string",t)).throw(g.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},n.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return de(ie("string",t)).throw(g.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},n}(pe);export{je as GroupChannelCollection,Ye as GroupChannelHandler,$e as GroupChannelModule,De as MembershipFilter,qe as PublicGroupChannelListQuery,Ze as ScheduledMessageListQuery}; +import{_ as e,V as i,b as s,D as h,F as f,b9 as _,ba as v,s as g,p as y,q as E,a2 as A,K as L,E as T,t as F,G as N,n as I,u as R,g as z,bb as B,a8 as J,B as Z,c as $,A as ee,az as te,e as ne,f as ae,h as re,a as ie,Q as se,X as oe,aO as le,aA as ue,bc as ce,aq as he,w as de,a_ as pe}from"./lib/__bundle-0ca331b6.js";export{bd as MessageEventSource,be as MutedState}from"./lib/__bundle-0ca331b6.js";import{S as fe,T as _e,G as ve,s as me,a as ge,P as ye,b as Ce,c as Se,d as Me,e as Ee,v as Ae,f as we,g as Le,h as Te,i as Fe}from"./lib/__bundle-e06a35d9.js";export{C as CountPreference,D as DeliveryStatus,b as GroupChannel,j as GroupChannelEventSource,a as GroupChannelFilter,d as GroupChannelListQuery,k as GroupChannelSearchField,H as HiddenChannelFilter,l as HiddenState,M as Member,m as MemberListOrder,n as MemberListQuery,o as MemberState,p as MemberStateFilter,r as MessageCollection,t as MessageCollectionInitHandler,u as MessageCollectionInitPolicy,w as MutedMemberFilter,q as MyMemberStateFilter,O as OperatorFilter,P as PublicChannelFilter,Q as QueryType,c as SuperChannelFilter,U as UnreadChannelFilter,x as UnreadItemKey}from"./lib/__bundle-e06a35d9.js";import{Q as ke,T as Ne,V as xe}from"./lib/__bundle-af65b142.js";export{K as MessageFilter,W as PinnedMessage,X as PinnedMessageListQuery,Y as ReadStatus,V as ScheduledStatus}from"./lib/__bundle-af65b142.js";import{G as Ge,P as Ue,S as Oe}from"./lib/__bundle-735270df.js";export{G as GroupChannelListOrder,P as PublicGroupChannelListOrder,S as ScheduledMessageListOrder}from"./lib/__bundle-735270df.js";import{B as Ie}from"./lib/__bundle-e4c89c6a.js";import"./lib/__bundle-bfc18da1.js";import"./lib/__bundle-acd77193.js";var De,Pe={},He=function(){function t(t){var n=t._iid,a=t.limit,r=void 0===a?100:a,o=this;this.ref=0,this._iid=n,this._limit=r;var l,u=i.of(this._iid),c=u.sdkState,d=u.dispatcher,p=u.logger,m=u.cacheContext,C=u.statManager;this._metadataKey=(l=c.userId,"sendbird:".concat(l,"@groupchannel/sync.meta"));var b=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(c.userId);this._sync=new fe(b,(function(){return e(o,void 0,void 0,(function(){var e,t,n,a,r,i,o,l,u,h,d,f,b,S,M,w;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(s.sent(),p.debug("channel background sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),null===(h=this._metadata)||void 0===h?void 0:h.completed)return[3,14];t={includeEmpty:!0,includeMetaData:!0,order:Ge.CHRONOLOGICAL},s.label=2;case 2:if(s.trys.push([2,9,12,13]),t.order!==Ge.LATEST_LAST_MESSAGE)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,m.preference.get(L(c.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannels(null!==(f=null===(d=this._metadata)||void 0===d?void 0:d.token)&&void 0!==f?f:"",t,this._limit,A.SYNC_CHANNEL_BACKGROUND)];case 7:return a=s.sent(),r=a.channels,i=a.token,e.hasNext=r.length>=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(l=this._metadata.range).extends.apply(l,y([],E(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),p.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),[3,13];case 9:return o=s.sent(),p.debug("channel background sync error",o),o instanceof g&&o.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw o;case 12:return C.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(S=null===(b=m.localCacheConfig)||void 0===b?void 0:b.maxSize)&&void 0!==S?S:0,use_local_cache:m.localCacheEnabled,starting_point:0,message_init_policy:null!==(w=null===(M=t.order)||void 0===M?void 0:M.toString())&&void 0!==w?w:"",collection_id:c.userId}})),[7];case 13:return[3,15];case 14:e.hasNext=!1,e.nextToken="",s.label=15;case 15:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)o.resume();else o.pause()}))}return t.of=function(e){return Pe[e]||(Pe[e]=new t({_iid:e})),Pe[e].ref++,Pe[e]},t.clear=function(e){Pe[e]&&(Pe[e].close(),delete Pe[e])},Object.defineProperty(t.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 _e({})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,i.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new _e(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.resume=function(){var e,t,n=i.of(this._iid),a=n.logger;n.sessionManager.session.hasSession&&(a.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:""))},t.prototype.pause=function(){i.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid])},t}(),Re={},Ve=function(){function t(t){var n=t._iid,a=this;this.ref=0,this._iid=n;var r,o=i.of(this._iid),l=o.logger,u=o.sdkState,c=o.dispatcher,d=o.cacheContext,p=o.statManager;this._metadataKey=(r=u.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta")),this._subscribers=new T;var m=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new fe(m,(function(){return e(a,void 0,void 0,(function(){var e,t,n,a,r,i,o,c,h,f,m,y;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),l.debug("channel changelog sync from",null===(f=this._metadata)||void 0===f?void 0:f.token),s.label=2;case 2:s.trys.push([2,9,,12]),t={includeEmpty:!0,includeMetaData:!0},s.label=3;case 3:return s.trys.push([3,5,,6]),[4,d.preference.get(L(u.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannelChangeLogs(null!==(y=null===(m=this._metadata)||void 0===m?void 0:m.token)&&void 0!==y?y:"",t,A.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=s.sent(),r=a.updatedChannels,i=a.deletedChannelUrls,o=a.hasMore,c=a.token,this._subscribers.dispatch("progress",{updatedChannels:r,deletedChannelUrls:i,hasMore:o,token:c}),e.hasNext=o,e.nextToken=c,this._metadata&&(this._metadata.token=c),l.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),d.localCacheEnabled&&p.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:r.length>0||i.length>0?"cache_miss":"cache_hit",max_db_size:r.length,use_local_cache:d.localCacheEnabled,starting_point:0,message_init_policy:i.length.toString(),collection_id:u.userId}})),[3,12];case 9:return h=s.sent(),l.debug("channel changelog sync error",h),h instanceof g&&h.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw h;case 12:return[2,e]}}))}))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=c.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)a.resume();else a.pause()}))}return t.of=function(e){return Re[e]||(Re[e]=new t({_iid:e})),Re[e].ref++,Re[e]},t.clear=function(e){Re[e]&&(Re[e].close(),delete Re[e])},Object.defineProperty(t.prototype,"isRunning",{get:function(){return this._sync.isRunning},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e,t,n,a;return s(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=i.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.on=function(e,t){return this._subscribers.on(e,t)},t.prototype.resume=function(){i.of(this._iid).sessionManager.session.hasSession&&this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid])},t}(),Ke=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},ze=function(e,t,n){if(e.length>0){for(var a=Ke(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(o<0))return{place:s,oldPosition:a};r=s+1,s=Math.floor((r+i)/2)}}return{place:Qe(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Qe=function(e,t,n){switch(n){case Ge.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?0===(a=t.lastMessage.createdAt-e.lastMessage.createdAt)?t.createdAt-e.createdAt:a:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var a;return 0===(a=e.name.localeCompare(t.name))?e.createdAt-t.createdAt:a;default:return 0}},je=function(){function t(t,n){var a=n.filter,r=void 0===a?new ge:a,o=n.order,l=void 0===o?Ge.LATEST_LAST_MESSAGE:o,u=n.limit,c=void 0===u?ke:u,d=n.includeChangesOnInitialLoad,p=void 0!==d&&d,_=this;this.channels=[],this._isInitialized=!1,this._iid=t,this._key="gcc-".concat(I()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=r,this.order=l,this._hasMore=!0,this._token="",this._limit=c;var v=i.of(this._iid),m=v.sdkState,g=v.cacheContext,y=v.dispatcher;g.localCacheEnabled&&(this._backgroundSync=He.of(t),this._backgroundSync.resume()),this._changelogSync=Ve.of(t),this._changelogSync.resume(),ve.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(me(n)){var a=e.filter((function(e){return _.filter.match(e,m.userId)})),r=e.filter((function(e){return!_.filter.match(e,m.userId)})).map((function(e){return e.url}));a.length>0&&_._addChannelsToView(a,t),r.length>0&&_._removeChannelsFromView(r,t)}},onRemove:function(e,t){_._removeChannelsFromView(e,t)}}),y.on((function(t){t instanceof h&&(t.stateType===f.CONNECTED?_._isGetRemoteChannelsSucceeded||e(_,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):t.stateType===f.LOGOUT&&_.dispose())}))}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,n,a){var r,i,o,l,u=this;void 0===a&&(a=!1);var c=[],h=[],d=[];try{for(var p=F(t),f=p.next();!f.done;f=p.next()){var _=f.value,v=Ke(this.channels,_);v>=0&&this.channels.splice(v,1);var m=ze(this.channels,_,this.order).place;if(v<0)m===this.channels.length?!a&&this._hasMore||(c.push(_),this.channels.push(_)):(c.push(_),this.channels.splice(m,0,_));else switch(n.source){case A.EVENT_CHANNEL_UPDATED:case A.EVENT_MESSAGE_RECEIVED:case A.SYNC_CHANNEL_CHANGELOGS:case A.EVENT_MESSAGE_SENT:this.order===Ge.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&m===this.channels.length?d.push(_):(this.channels.splice(m,0,_),h.push(_));break;default:this.channels.splice(m,0,_),h.push(_)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}if(d.length>0)try{for(var g=F(d),y=g.next();!y.done;y=g.next()){_=y.value;var C=Ke(this.channels,_);-1!==C&&this.channels.splice(C,1)}}catch(e){o={error:e}}finally{try{y&&!y.done&&(l=g.return)&&l.call(g)}finally{if(o)throw o.error}}me(n.source)&&N((function(){return e(u,void 0,void 0,(function(){var e,t,a;return s(this,(function(r){return c.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(n,c),h.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,h),d.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,d.map((function(e){return e.url}))),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,n){var a,r,i=this,o=[],l=function(e){var t=u.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(u.channels[t].url),u.channels.splice(t,1))},u=this;try{for(var c=F(t),h=c.next();!h.done;h=c.next()){l(h.value)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(a)throw a.error}}return me(n.source)&&o.length>0&&N((function(){return e(i,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=ve.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.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()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(a){switch(a.label){case 0:return[4,ve.of(this._iid).getMyGroupChannels(this._token,R(z(z({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},t.prototype._revokeLoadMore=function(){return e(this,void 0,void 0,(function(){var e;return s(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,{source:A.REQUEST_CHANNEL},!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},t.prototype.loadMore=function(){var t;return e(this,void 0,void 0,(function(){var n,a,r,o,l,u,c,h,d,p,f,_,m,y,C,b,S,M,E,w=this;return s(this,(function(L){switch(L.label){case 0:if(this._isDisposed)throw new g({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return n=null,this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning?[4,new Promise((function(e){w._changelogSyncSubscriberContext=w._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}))]:[3,2];case 1:n=L.sent(),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close(),L.label=2;case 2:return a=i.of(this._iid),r=a.cacheContext,o=a.connectionManager,l=a.statManager,this._isInitialized?[3,5]:(this._isInitialized=!0,r.localCacheEnabled?[4,this._backgroundSync.loadMetadata()]:[3,4]);case 3:L.sent(),L.label=4;case 4:l.put(new B({type:v.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{group_channel:!0}}})),L.label=5;case 5:return u=[],this._hasMore?!r.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed?[3,7]:[4,Z((function(){return e(w,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return u=e.sent(),[2]}}))}))}))]:[3,11];case 6:return L.sent(),this._hasMore=u.length>=this._limit,[3,10];case 7:return L.trys.push([7,9,,10]),[4,this._getRemoteChannels()];case 8:return u=L.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,10];case 9:return L.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,10];case 10:this._addChannelsToView(u,{source:A.REQUEST_CHANNEL},!0),L.label=11;case 11:if(n){try{for(c=F(n.updatedChannels),h=c.next();!h.done;h=c.next())d=h.value,(C=Ke(u,d))>=0?u[C]=d:(p=ze(u,d,this.order).place,u.splice(p,0,d))}catch(e){b={error:e}}finally{try{h&&!h.done&&(S=c.return)&&S.call(c)}finally{if(b)throw b.error}}f=u.map((function(e){return e.url}));try{for(_=F(n.deletedChannelUrls),m=_.next();!m.done;m=_.next())y=m.value,(C=f.indexOf(y))>=0&&(u.splice(C,1),f.splice(C,1))}catch(e){M={error:e}}finally{try{m&&!m.done&&(E=_.return)&&E.call(_)}finally{if(M)throw M.error}}}return[2,u]}}))}))},t.prototype.dispose=function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),ve.of(this._iid).unsubscribeChannelEvent(this._key))},t}(),We=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,_=t.metadataValues,v=t.metadataValueStartsWith,m=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=ee.GET,n.path=te,n.params=ne(R({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:ye.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:_,metadata_value_startswith:v,show_frozen:m,show_metadata:g})),n}return $(t,e),t}(ae),Be=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new Ce(t,e)}))),a.ts="number"==typeof s?s:0,a}return $(t,e),t}(re);!function(e){e.ALL="all",e.JOINED="joined"}(De||(De={}));var qe=function(t){function n(e,n){var a,r,i,s,o,l,u,c,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=De.ALL,m.superChannelFilter=Se.ALL,m.metadataKey=null,m.metadataValues=null,m.metadataOrderKeyFilter=null,m.metadataValueStartsWith=null,m.order=Ue.CHRONOLOGICAL,m.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,m.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,m.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,m.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,m.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,m.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,m.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,m.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:De.ALL,m.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Se.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:Ue.CHRONOLOGICAL,m}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("boolean",this.includeEmpty)&&ie("boolean",this.includeFrozen)&&ie("boolean",this.includeMetaData)&&ie("string",this.channelNameContainsFilter,!0)&&se("string",this.channelUrlsFilter,!0)&&se("string",this.customTypesFilter,!0)&&ie("string",this.customTypeStartsWithFilter,!0)&&oe(De,this.membershipFilter)&&oe(Se,this.superChannelFilter)&&oe(Ue,this.order)&&ie("string",this.metadataOrderKeyFilter,!0)&&ie("string",this.metadataKey,!0)&&se("string",this.metadataValues,!0)&&ie("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o,l;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=i.of(this._iid).requestQueue,n=new We(R(z(z({},this),{token:this._token}))),[4,t.send(n)]):[3,2]):[3,5];case 1:return a=s.sent(),r=a.as(Be),o=r.channels,l=r.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),Ye=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 $(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=ue,t.onUserLeft=ue,t.onUserReceivedInvitation=ue,t.onUserDeclinedInvitation=ue,t.onChannelHidden=ue,t.onUnreadMemberStatusUpdated=ue,t.onUndeliveredMemberStatusUpdated=ue,t.onTypingStatusUpdated=ue,t.onPollUpdated=ue,t.onPollVoted=ue,t.onPollDeleted=ue,t.onPinnedMessageUpdated=ue,t}return $(t,e),t}(Ie)),Xe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=ee.GET,n.path="".concat(ce),n.params=ne(R({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return $(t,e),t}(ae),Je=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return Ne(t,e)})),a}return $(t,e),t}(re),Ze=function(t){function n(e,n){var a,r,i,s,o,l=this;return(l=t.call(this,e,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=he.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:he.ALL,l}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("string",this.channelUrl,!0)&&(oe(Oe,this.order)||null===this.order)&&ie("boolean",this.reverse)&&(se(xe,this.scheduledStatus)||null===this.scheduledStatus)&&oe(he,this.messageTypeFilter)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=i.of(this._iid).requestQueue,t=new Xe(R(z(z({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),a=n.as(Je),r=a.scheduledMessages,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),$e=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return $(n,t),n.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new ve(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new je(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Me(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ze(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){de(ie("string",e)&&t instanceof Ye).throw(g.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){de(ie("string",e)).throw(g.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(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannel(t)]}))}))},n.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("string",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("number",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},we),t),de(Le(e)).throw(g.invalidParameters),[2,this._manager.getGroupChannelCount(e)]}))}))},n.prototype.getUnreadItemCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getUnreadItemCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(t)];case 1:return[2,e.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(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),[2,this._manager.createChannel(e)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),e&&(e.isDistinct=!0),[2,this.createChannel(e)]}))}))},n.prototype.createChannelWithUserIds=function(t,n,a,r,i,o){return void 0===n&&(n=!1),void 0===i&&(i=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return s(this,(function(s){return e=z(z({},Te),{invitedUserIds:t,isDistinct:n,name:a,data:i,customType:o}),"string"==typeof r?e.coverUrl=r:e.coverImage=r,[2,this.createChannel(e)]}))}))},n.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(se("string",t)).throw(g.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},n.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return de(ie("string",t)).throw(g.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},n}(pe);export{je as GroupChannelCollection,Ye as GroupChannelHandler,$e as GroupChannelModule,De as MembershipFilter,qe as PublicGroupChannelListQuery,Ze as ScheduledMessageListQuery}; diff --git a/index.js b/index.js index e4d8443..04bcf41 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -import{i as e,a as t,_ as i,b as a,C as u,c,E as d,A as l,d as h,e as f,u as p,f as v,U as g,g as m,h as b,P as _,j as w,k,l as I,m as A,S as N,L as M,n as Q,o as j,V as q,p as x,q as K,v as W,r as V,s as Z,t as X,w as ee,x as te,y as ne,z as re,B as ie,D as se,F as oe,W as ae,G as ue,H as ce,I as de,J as le,K as he,M as fe,N as pe,O as ve,Q as ge,R as me,T as be,X as _e,Y as ye,Z as we,$ as ke,a0 as Se}from"./lib/__bundle-c03282ec.js";export{a1 as AppInfo,a3 as CachedChannelInfo,a4 as CachedDataClearOrder,C as ChannelType,a2 as CollectionEventSource,r as ConnectionState,Y as DeviceOsPlatform,a5 as LastMessageThreadingPolicy,L as LocalCacheConfig,a6 as NotificationInfo,a0 as PushTemplate,T as PushTokenRegistrationState,P as PushTokenType,$ as PushTriggerOption,a7 as Role,S as SendbirdChatOptions,s as SendbirdError,a8 as SendbirdErrorCode,ad as SendbirdPlatform,ac as SendbirdProduct,a9 as UIKitConfigInfo,aa as UnreadCountThreadingPolicy,U as User,ab as UserOnlineState}from"./lib/__bundle-c03282ec.js";import{N as Ie,a as Ce,b as Ee,c as Te,g as Pe,M as De,d as Ue,e as Oe,f as Ae,h as Ne,i as Me,j as Le,k as Re,l as ze,m as Qe,L as je,n as Fe,o as qe,p as He,A as xe,I as Ke,q as Ge,U as We,C as Ve,r as Be,B as Je,F as Ye,s as Ze,S as $e,t as Xe,u as et,v as tt,w as nt,x as rt}from"./lib/__bundle-45809bc9.js";export{r as ApplicationUserListQuery,y as BannedUserListQuery,z as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,n as LogLevel,o as MemoryStore,D as MutedUserListQuery,O as OperatorListQuery,P as Participant,E as Plugin,R as ReportCategory,G as RestrictedUser,H as RestrictionInfo,J as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-45809bc9.js";import{PollModule as it}from"./poll.js";import{g as st,G as ot,A as at,U as ut,a as ct,b as dt,D as lt,R as ht}from"./lib/__bundle-1a7e946b.js";import{g as ft,N as pt}from"./lib/__bundle-5f5bca4c.js";import"./lib/__bundle-acd77193.js";var vt=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 vt(e)})):[]},mt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new gt(e)})):[]},bt={profileImage:void 0,profileUrl:void 0,nickname:void 0},_t=function(e){return function(t,n){return i(void 0,void 0,void 0,(function(){var r,s,o,c;return a(this,(function(d){switch(d.label){case 0:switch(t){case 1:case 2:case 3:case 4:return[3,1];case 5:return[3,2];case 6:return[3,4]}return[3,11];case 1:return n(),[3,12];case 2:return[4,e.reset()];case 3:return d.sent(),n(),[3,12];case 4:return d.trys.push([4,9,,10]),r=function(e){return{v2:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Ce,keyName:Ee,index:[st(ot.LATEST_LAST_MESSAGE),st(ot.CHRONOLOGICAL),st(ot.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Ie,keyName:Te,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ue,keyName:Oe,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ae,keyName:Ne}])];case 1:return[2,t.sent()]}}))}))},v3:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Me,keyName:Le,index:[ft("latest_last_message")]}])];case 1:return[2,t.sent()]}}))}))},v4:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Re,keyName:ze,index:[Qe()]}])];case 1:return[2,t.sent()]}}))}))}}}(e),s=r.v2,o=r.v3,c=r.v4,[4,s()];case 5:return d.sent(),[4,o()];case 6:return d.sent(),[4,c()];case 7:return d.sent(),[4,e.collection(Ie).removeIf({where:{channelType:u.OPEN}})];case 8:case 9:return d.sent(),[3,10];case 10:return n(),[3,12];case 11:n(),d.label=12;case 12:return[2]}}))}))}},yt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},wt=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?yt: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 c(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}(d),kt=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 i(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:l.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),St=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=l.PUT,a.path="".concat(h,"/").concat(encodeURIComponent(n)),a.params=f(p({nickname:r,profile_url:i,profile_file:s,preferred_languages:o})),a}return c(t,e),t}(v),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,m({},n)),r}return c(t,e),t}(b),Ct=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),a.params=f({apns_device_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Et=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),a.params=f({gcm_reg_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Pt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Dt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ut=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ot=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=l.GET,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return c(t,e),t}(v),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?_[n.type.toLowerCase()]:_.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return c(t,e),t}(b),Nt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return c(t,e),t}(v),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(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=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return c(t,e),t}(v),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(t,e),t}(b),zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Qt=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 c(t,e),t}(b),jt=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=l.PUT,c.path="".concat(h,"/").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 c(t,e),t}(v),Ft=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 c(t,e),t}(b),qt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Ht=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 c(t,e),t}(b),xt=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=l.PUT,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return c(t,e),t}(v),Kt=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 c(t,e),t}(b),Gt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,n),r}c(t,e)}(b);var Wt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var Vt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Jt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return c(t,e),t}(v),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),r}return c(t,e),t}(v),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),Xt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return c(t,e),t}(v),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),tn=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.GET,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return c(t,e),t}(v),nn=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 g(t,e)})),updatedUsers:n.updated.map((function(e){return new g(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return c(t,e),t}(b),rn=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").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 c(t,e),t}(v),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return c(t,e),t}(b),on=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var an=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new g(t,e)})),r}return c(t,e),t}(b),cn=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var dn=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return c(t,e),t}(v),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return c(t,e),t}(b),hn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var fn,pn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path=w,t}return c(t,e),t}(v),vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new mt(n),r}return c(t,e),t}(b),gn=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(w,"/").concat(n),r}return c(t,e),t}(v),mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new gt(n),r}return c(t,e),t}(b),bn=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(k,"/").concat(n),r}return c(t,e),t}(v),_n=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new vt(n),r}return c(t,e),t}(b),yn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path="".concat(I),t}return c(t,e),t}(v),wn=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 c(t,e),t}(b);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(fn||(fn={}));var kn,Sn=function(e){function t(t){var n=t.deviceToken,r=t.pushTrackingId,i=t.messageId,s=t.allowedPushNotification,o=t.channelKey,a=t.templateKey,u=t.eventType,c=t.notificationEventDeadline,d=e.call(this)||this;return d.method=l.POST,d.path=A,d.params=f({device_token:n,push_tracking_id:r,message_id:i,allowed_push_notification:s,channel_key:o,template_key:a,event_type:u,notification_event_deadline:c}),d}return c(t,e),t}(v);var In=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var s=q.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,d=s.sessionManager,l=s.requestQueue,h=s.logger,f=s.userEventHandlers,p=s.appStateToggleEnabled;this._onlineDetector=new kt({logger:h,connectionDelegate:{reconnect:function(){return i(r,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:if(t=q.of(e),n=t.sdkState,r=t.connectionManager,(i=t.sessionManager).session.hasSession)return[3,5];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.connect(i.session.authToken)];case 2:return a.sent(),[3,4];case 3:if(s=a.sent(),ve(s))throw s;return h.debug("connect failed by reconnect event = ",s),[3,4];case 4:return[3,9];case 5:if("foreground"!==n.appState)return[3,9];a.label=6;case 6:return a.trys.push([6,8,,9]),[4,r.resetAndReconnect()];case 7:return a.sent(),[3,9];case 8:if(o=a.sent(),ve(o))throw o;return h.debug("resetAndReconnect failed by reconnect event = ",o),[3,9];case 9:return c.dispatch(new pt),[2]}}))}))},disconnect:function(){ie((function(){return i(r,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,q.of(e).connectionManager.disconnect()];case 1:return t.sent(),[2]}}))}))}))}}});var v=new at(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,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 wt({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){var n;if(t instanceof se){if(t.stateType===oe.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof ae){if("USEV"===t.code){var s=t.as(ut).event;if(s.category===ct.FRIEND_DISCOVERED){var c=dt.getDataAsFriendDiscoveredEvent(e,s).friendDiscoveries;ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ce){var d=q.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;"number"==typeof p&&p>d.ts&&(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){d.customTypes[e]!==t.customTypes[e]&&(l=!0),d.customTypes[e]=t.customTypes[e]})),l=l&&d.ts>0,d.ts=p),l&&ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof de?(u.preference.set(r._getUserProfileCacheKey(o.userId),le.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(he(r.appId),{value:!0})):t instanceof fe&&t.error&&t.error.isSessionInvalidatedError&&(h.debug("session revoked."),r._internalDisconnect(t.error))}))}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 N: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,g=void 0!==v&&v,m=e.localCacheConfig,b=void 0===m?new M:m,_=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,k=e.useMMKVStorageStore,S=void 0===k?null:k,I=e.appStateToggleEnabled,C=void 0===I||I;if(!kn||f){var E="su-".concat(Q()),T=null!=_?_:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new je;P.level=null!=p?p:Fe.WARN;var D=new qe({encryption:T});c||(j()?S?D=new He({MMKV:S,encryption:T}):w&&(D=new xe({AsyncStorage:w,encryption:T}),P.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):D=new Ke({encryption:T})),new q(E,{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:D,encryption:T,logger:P,localCacheEnabled:g,localCacheConfig:b,debugMode:c,appStateToggleEnabled:C});var U=[new Ge,new it],O=new n(E,a,x(x([],K(s),!1),K(U),!1));return kn||(kn=O),O}return kn},Object.defineProperty(n,"instance",{get:function(){return kn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return W},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?V.OPEN:e.isConnecting?V.CONNECTING:V.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._getNestDBVersion=function(){return 7},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._internalDisconnect=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return t=q.of(this._iid),n=t.connectionManager,r=t.sdkState,i=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),[4,n.logout(e)];case 1:return s.sent(),[4,this.clearCachedData()];case 2:return s.sent(),r.appState="foreground",[2]}}))}))},n.prototype.getMemoryStoreForDebugging=function(){var e=q.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof qe?n.store:null;throw Z.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.addSendbirdExtensions=function(e,t,n){var r,i,s=q.of(this._iid),o=s.logger,a=s.sdkState,u=new RegExp(pe);if(0===e.length)return o.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return o.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=X(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=K(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return o.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return i(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 qe),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.setLocaleForChatbot=function(e){var t=q.of(this._iid).sdkState,n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(e.trim());n&&(t.localeForChatbot=n)},n.prototype.initializeCache=function(e){return i(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:if(t=q.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.dispatcher,s=t.logger,n.userId&&n.userId===e)return[3,13];o="sendbird@".concat(n.appId,"/").concat(e,".db"),a.label=1;case 1:return a.trys.push([1,9,11,13]),r.localCacheEnabled?r.nestdb&&r.nestdb.state!==tt.CLOSED&&r.nestdb.name===o?[3,3]:(u="sendbird@".concat(n.appId,"/").concat(e,".db"),(c=r.nestdb=new nt({name:u,version:this._getNestDBVersion(),store:r.store,config:new rt({dbname:u,itemSizeLimit:61440})})).on("upgrade",_t(c)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",_t(c))})),[4,c.open()]):[3,6];case 2:return a.sent(),this._storeInitialized=!0,i.dispatch(new lt(this._iid,{userId:e})),[3,5];case 3:return[4,this._safeInitializeStore(o)];case 4:a.sent(),a.label=5;case 5:return n.userId=e,[3,8];case 6:return[4,this._safeInitializeStore(o)];case 7:a.sent(),n.userId=e,a.label=8;case 8:return[3,13];case 9:return d=a.sent(),s.warn("Nest DB Open Failed. ",d),r.store instanceof qe||(r.replaceStore(new qe),r.localCacheEnabled=!1),[4,this._safeInitializeStore(o)];case 10:throw a.sent(),n.userId=e,Z.databaseError;case 11:return[4,this._setupPreference(e)];case 12:return a.sent(),[7];case 13:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return i(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 i(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 i(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=Xe.of(this._iid),n=et.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return i(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:s.sent(),s.label=2;case 2:return[2]}}))}))},n.prototype._setupPreference=function(e){return i(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.cacheContext,i=t.statManager,[4,r.preference.init(this._getPreferenceCacheKey(e),this._getNestDBVersion())];case 1:return o.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 2:return(s=o.sent())&&new le(this._iid,s).apply(),[4,i.init("sendbird@".concat(n.appId,"/").concat(e,".statlog"))];case 3:return o.sent(),[2]}}))}))},n.prototype._ready=function(e,n,r){return void 0===r&&(r={}),i(this,void 0,void 0,(function(){var i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)&&t("string",n,!0)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.cacheContext,u=i.connectionManager,c=r.errorForOtherUser,s.userId&&s.userId!==e?c?[3,2]:[4,u.logout()]:[3,3];case 1:return a.sent(),[3,3];case 2:throw c;case 3:return a.trys.push([3,5,,6]),[4,this.initializeCache(e)];case 4:return a.sent(),q.of(this._iid).dispatcher.dispatch(new ht),[3,6];case 5:return a.sent(),d=q.of(this._iid).logger,o.localCacheEnabled=!1,d.warn("Cache initialization failed - cache is not available."),[3,6];case 6:return[2]}}))}))},n.prototype.authenticateFeed=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.authenticate(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.authenticate=function(e,t){var n;return i(this,void 0,void 0,(function(){var r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return r=q.of(this._iid),i=r.sessionManager,s=r.connectionManager,[4,this._ready(e,t,{errorForOtherUser:s.isConnected?Z.alreadyConnectedAsAnotherUser:void 0})];case 1:return a.sent(),(null===(n=i.session.services)||void 0===n?void 0:n.includes(me.CHAT))?[3,3]:(t||i.handler||(o=new $e,this.setSessionHandler(o)),[4,i.authenticate(e,t)]);case 2:a.sent(),a.label=3;case 3:return[2,this.currentUser]}}))}))},n.prototype.connect=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this._ready(e,t)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,,4,5]),[4,q.of(this._iid).connectionManager.connect(t)];case 3:return n.sent(),[3,5];case 4:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 5:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._internalDisconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return i(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(!0)];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().catch((function(e){r.debug("setBackgroundState error = ",e)})))},n.prototype.setForegroundState=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,i=e.logger;"background"===n.appState&&(n.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((function(e){i.debug("setForgroundState error = ",e)})),r.dispatch(new pt))},n.prototype.setSessionHandler=function(e){ee(e instanceof $e).throw(Z.invalidParameters),q.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){ee(t("string",e)&&n instanceof We).throw(Z.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){ee(t("string",e)&&n instanceof Ve).throw(Z.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 Be(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Je(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Ye(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new Ze(this._iid,e)},n.prototype.createPollListQuery=function(e){return new te(this._iid,m({},e))},n.prototype.createPollVoterListQuery=function(e){return new ne(this._iid,m({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=re(e);return new g(this._iid,g.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=m(m({},bt),n),ee(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(Z.invalidParameters),this.currentUser?(i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new St(m({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(It).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw Z.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),this.currentUser?(t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(It).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw Z.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.ANDROID,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.FCM,e)?[2,be.SUCCESS]:(h=new Et({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.FCM,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Pt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Ut({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.IOS,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.APNS,e)?[2,be.SUCCESS]:(h=new Ct({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.APNS,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Tt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Dt({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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.markPushNotificationAsDelivered=function(e,t){var n;return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_,y,w,k;return a(this,(function(a){switch(a.label){case 0:if(r=q.of(this._iid),i=r.logger,s=r.sessionManager,o=r.requestQueue,u=r.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=fn.DELIVERED,d=u.parseData(e),l=d.pushTrackingId,h=d.sessionTopics,f=d.sessionKey,p=d.messageId,v=d.channelKey,g=d.templateKey,m=d.notificationEventDeadline,!f)throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!h.includes(we.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(u.isAcked(l,c))return i.info("already delivered push notification:",l),[2];b=Boolean(v),_=t&&b,y=null===(n=s.deviceTokens[0])||void 0===n?void 0:n.token,w=new Sn({deviceToken:null!=y?y:"",pushTrackingId:l,eventType:c,messageId:p,channelKey:v,templateKey:g,notificationEventDeadline:m,allowedPushNotification:_}),f&&(w.headers["Session-Key"]=f),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,o.send(w)];case 2:return a.sent(),u.markAsAcked(l,c),[3,4];case 3:throw k=a.sent(),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(l,". error: ").concat(k)),k;case 4:return[2]}}))}))},n.prototype.markPushNotificationAsClicked=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_;return a(this,(function(a){switch(a.label){case 0:if(n=q.of(this._iid),r=n.logger,i=n.sessionManager,s=n.requestQueue,o=n.pushNotificationAckManager,r.debug("markPushNotificationAsClicked:",e),u=fn.CLICKED,c=o.parseData(e),d=c.pushTrackingId,l=c.sessionTopics,h=c.sessionKey,f=c.messageId,p=c.channelKey,v=c.templateKey,g=c.notificationEventDeadline,!h)throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!l.includes(we.PUSH_ACKNOWLEDGEMENT))throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(o.isAcked(d,u))return r.info("already clicked push notification:",d),[2];m=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,b=new Sn({deviceToken:null!=m?m:"",pushTrackingId:d,eventType:u,messageId:f,channelKey:p,templateKey:v,notificationEventDeadline:g}),h&&(b.headers["Session-Key"]=h),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,s.send(b)];case 2:return a.sent(),o.markAsAcked(d,u),[3,4];case 3:throw _=a.sent(),r.debug("failed to mark push notification as clicked. push tracking id: ".concat(d,". error: ").concat(_)),_;case 4:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return i(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 Nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Mt).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)).throw(Z.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(Rt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return i(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 zt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Qt).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,s,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===u&&(u=""),i(this,void 0,void 0,(function(){var i,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",s)&&t("number",o)&&t("string",u)).throw(Z.invalidParameters),i=q.of(this._iid),c=i.sdkState,d=i.requestQueue,l=new jt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:s,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(Ft).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return i(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(Ht).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),i(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new xt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(Kt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return i(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 ee(t("string",e)&&_e(_,n)).throw(Z.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new Ot({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(At).pushTokens;try{for(l=X(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 i(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 Vt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Bt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(ke,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Jt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Yt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return i(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 Zt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as($t).name]}}))}))},n.prototype.setPushTemplate=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(Se,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(en).name]}}))}))},n.prototype.blockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Gt({userId:r.userId,blockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Wt({userId:r.userId,unblockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new tn({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(nn).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return i(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 dn({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ln).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(t("boolean",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new hn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return i(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 rn({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(sn).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new on({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new an({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(un).users]}}))}))},n.prototype.deleteFriend=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new cn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return i(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 pn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(vn).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return i(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 gn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(mn).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return i(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 bn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(_n).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return i(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),ee(e.hasExtension("sb_uikit")).throw(Z.notSupportedError),t=e.requestQueue,n=new yn,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(wn).uikitConfiguration]}}))}))},n}();export{vt as Emoji,gt as EmojiCategory,mt as EmojiContainer,In as default}; +import{i as e,a as t,_ as i,b as a,C as u,c,E as d,A as l,d as h,e as f,u as p,f as v,U as g,g as m,h as b,P as _,j as w,k,l as I,m as A,S as N,L as M,n as Q,o as j,V as q,p as x,q as K,v as W,r as V,s as Z,t as X,w as ee,x as te,y as ne,z as re,B as ie,D as se,F as oe,W as ae,G as ue,H as ce,I as de,J as le,K as he,M as fe,N as pe,O as ve,Q as ge,R as me,T as be,X as _e,Y as ye,Z as we,$ as ke,a0 as Se}from"./lib/__bundle-0ca331b6.js";export{a1 as AppInfo,a3 as CachedChannelInfo,a4 as CachedDataClearOrder,C as ChannelType,a2 as CollectionEventSource,r as ConnectionState,Y as DeviceOsPlatform,a5 as LastMessageThreadingPolicy,L as LocalCacheConfig,a6 as NotificationInfo,a0 as PushTemplate,T as PushTokenRegistrationState,P as PushTokenType,$ as PushTriggerOption,a7 as Role,S as SendbirdChatOptions,s as SendbirdError,a8 as SendbirdErrorCode,ad as SendbirdPlatform,ac as SendbirdProduct,a9 as UIKitConfigInfo,aa as UnreadCountThreadingPolicy,U as User,ab as UserOnlineState}from"./lib/__bundle-0ca331b6.js";import{N as Ie,a as Ce,b as Ee,c as Te,g as Pe,M as De,d as Ue,e as Oe,f as Ae,h as Ne,i as Me,j as Le,k as Re,l as ze,m as Qe,L as je,n as Fe,o as qe,p as He,A as xe,I as Ke,q as Ge,U as We,C as Ve,r as Be,B as Je,F as Ye,s as Ze,S as $e,t as Xe,u as et,v as tt,w as nt,x as rt}from"./lib/__bundle-af65b142.js";export{r as ApplicationUserListQuery,y as BannedUserListQuery,z as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,n as LogLevel,o as MemoryStore,D as MutedUserListQuery,O as OperatorListQuery,P as Participant,E as Plugin,R as ReportCategory,G as RestrictedUser,H as RestrictionInfo,J as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-af65b142.js";import{PollModule as it}from"./poll.js";import{g as st,G as ot,A as at,U as ut,a as ct,b as dt,D as lt,R as ht}from"./lib/__bundle-735270df.js";import{g as ft,N as pt}from"./lib/__bundle-dfeaa7a2.js";import"./lib/__bundle-acd77193.js";var vt=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 vt(e)})):[]},mt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new gt(e)})):[]},bt={profileImage:void 0,profileUrl:void 0,nickname:void 0},_t=function(e){return function(t,n){return i(void 0,void 0,void 0,(function(){var r,s,o,c;return a(this,(function(d){switch(d.label){case 0:switch(t){case 1:case 2:case 3:case 4:return[3,1];case 5:return[3,2];case 6:return[3,4]}return[3,11];case 1:return n(),[3,12];case 2:return[4,e.reset()];case 3:return d.sent(),n(),[3,12];case 4:return d.trys.push([4,9,,10]),r=function(e){return{v2:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Ce,keyName:Ee,index:[st(ot.LATEST_LAST_MESSAGE),st(ot.CHRONOLOGICAL),st(ot.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Ie,keyName:Te,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ue,keyName:Oe,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ae,keyName:Ne}])];case 1:return[2,t.sent()]}}))}))},v3:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Me,keyName:Le,index:[ft("latest_last_message")]}])];case 1:return[2,t.sent()]}}))}))},v4:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Re,keyName:ze,index:[Qe()]}])];case 1:return[2,t.sent()]}}))}))}}}(e),s=r.v2,o=r.v3,c=r.v4,[4,s()];case 5:return d.sent(),[4,o()];case 6:return d.sent(),[4,c()];case 7:return d.sent(),[4,e.collection(Ie).removeIf({where:{channelType:u.OPEN}})];case 8:case 9:return d.sent(),[3,10];case 10:return n(),[3,12];case 11:n(),d.label=12;case 12:return[2]}}))}))}},yt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},wt=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?yt: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 c(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}(d),kt=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 i(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:l.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),St=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=l.PUT,a.path="".concat(h,"/").concat(encodeURIComponent(n)),a.params=f(p({nickname:r,profile_url:i,profile_file:s,preferred_languages:o})),a}return c(t,e),t}(v),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,m({},n)),r}return c(t,e),t}(b),Ct=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),a.params=f({apns_device_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Et=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),a.params=f({gcm_reg_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Pt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Dt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ut=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ot=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=l.GET,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return c(t,e),t}(v),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?_[n.type.toLowerCase()]:_.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return c(t,e),t}(b),Nt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return c(t,e),t}(v),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(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=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return c(t,e),t}(v),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(t,e),t}(b),zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Qt=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 c(t,e),t}(b),jt=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=l.PUT,c.path="".concat(h,"/").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 c(t,e),t}(v),Ft=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 c(t,e),t}(b),qt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Ht=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 c(t,e),t}(b),xt=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=l.PUT,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return c(t,e),t}(v),Kt=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 c(t,e),t}(b),Gt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,n),r}c(t,e)}(b);var Wt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var Vt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Jt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return c(t,e),t}(v),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),r}return c(t,e),t}(v),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),Xt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return c(t,e),t}(v),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),tn=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.GET,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return c(t,e),t}(v),nn=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 g(t,e)})),updatedUsers:n.updated.map((function(e){return new g(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return c(t,e),t}(b),rn=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").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 c(t,e),t}(v),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return c(t,e),t}(b),on=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var an=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new g(t,e)})),r}return c(t,e),t}(b),cn=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var dn=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return c(t,e),t}(v),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return c(t,e),t}(b),hn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var fn,pn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path=w,t}return c(t,e),t}(v),vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new mt(n),r}return c(t,e),t}(b),gn=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(w,"/").concat(n),r}return c(t,e),t}(v),mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new gt(n),r}return c(t,e),t}(b),bn=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(k,"/").concat(n),r}return c(t,e),t}(v),_n=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new vt(n),r}return c(t,e),t}(b),yn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path="".concat(I),t}return c(t,e),t}(v),wn=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 c(t,e),t}(b);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(fn||(fn={}));var kn,Sn=function(e){function t(t){var n=t.deviceToken,r=t.pushTrackingId,i=t.messageId,s=t.allowedPushNotification,o=t.channelKey,a=t.templateKey,u=t.eventType,c=t.notificationEventDeadline,d=e.call(this)||this;return d.method=l.POST,d.path=A,d.params=f({device_token:n,push_tracking_id:r,message_id:i,allowed_push_notification:s,channel_key:o,template_key:a,event_type:u,notification_event_deadline:c}),d}return c(t,e),t}(v);var In=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var s=q.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,d=s.sessionManager,l=s.requestQueue,h=s.logger,f=s.userEventHandlers,p=s.appStateToggleEnabled;this._onlineDetector=new kt({logger:h,connectionDelegate:{reconnect:function(){return i(r,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:if(t=q.of(e),n=t.sdkState,r=t.connectionManager,(i=t.sessionManager).session.hasSession)return[3,5];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.connect(i.session.authToken)];case 2:return a.sent(),[3,4];case 3:if(s=a.sent(),ve(s))throw s;return h.debug("connect failed by reconnect event = ",s),[3,4];case 4:return[3,9];case 5:if("foreground"!==n.appState)return[3,9];a.label=6;case 6:return a.trys.push([6,8,,9]),[4,r.resetAndReconnect()];case 7:return a.sent(),[3,9];case 8:if(o=a.sent(),ve(o))throw o;return h.debug("resetAndReconnect failed by reconnect event = ",o),[3,9];case 9:return c.dispatch(new pt),[2]}}))}))},disconnect:function(){ie((function(){return i(r,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,q.of(e).connectionManager.disconnect()];case 1:return t.sent(),[2]}}))}))}))}}});var v=new at(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,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 wt({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){var n;if(t instanceof se){if(t.stateType===oe.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof ae){if("USEV"===t.code){var s=t.as(ut).event;if(s.category===ct.FRIEND_DISCOVERED){var c=dt.getDataAsFriendDiscoveredEvent(e,s).friendDiscoveries;ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ce){var d=q.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;"number"==typeof p&&p>d.ts&&(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){d.customTypes[e]!==t.customTypes[e]&&(l=!0),d.customTypes[e]=t.customTypes[e]})),l=l&&d.ts>0,d.ts=p),l&&ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof de?(u.preference.set(r._getUserProfileCacheKey(o.userId),le.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(he(r.appId),{value:!0})):t instanceof fe&&t.error&&t.error.isSessionInvalidatedError&&(h.debug("session revoked."),r._internalDisconnect(t.error))}))}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 N: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,g=void 0!==v&&v,m=e.localCacheConfig,b=void 0===m?new M:m,_=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,k=e.useMMKVStorageStore,S=void 0===k?null:k,I=e.appStateToggleEnabled,C=void 0===I||I;if(!kn||f){var E="su-".concat(Q()),T=null!=_?_:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new je;P.level=null!=p?p:Fe.WARN;var D=new qe({encryption:T});c||(j()?S?D=new He({MMKV:S,encryption:T}):w&&(D=new xe({AsyncStorage:w,encryption:T}),P.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):D=new Ke({encryption:T})),new q(E,{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:D,encryption:T,logger:P,localCacheEnabled:g,localCacheConfig:b,debugMode:c,appStateToggleEnabled:C});var U=[new Ge,new it],O=new n(E,a,x(x([],K(s),!1),K(U),!1));return kn||(kn=O),O}return kn},Object.defineProperty(n,"instance",{get:function(){return kn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return W},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?V.OPEN:e.isConnecting?V.CONNECTING:V.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._getNestDBVersion=function(){return 7},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._internalDisconnect=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return t=q.of(this._iid),n=t.connectionManager,r=t.sdkState,i=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),[4,n.logout(e)];case 1:return s.sent(),[4,this.clearCachedData()];case 2:return s.sent(),r.appState="foreground",[2]}}))}))},n.prototype.getMemoryStoreForDebugging=function(){var e=q.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof qe?n.store:null;throw Z.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.addSendbirdExtensions=function(e,t,n){var r,i,s=q.of(this._iid),o=s.logger,a=s.sdkState,u=new RegExp(pe);if(0===e.length)return o.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return o.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=X(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=K(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return o.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return i(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 qe),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.setLocaleForChatbot=function(e){var t=q.of(this._iid).sdkState,n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(e.trim());n&&(t.localeForChatbot=n)},n.prototype.initializeCache=function(e){return i(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:if(t=q.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.dispatcher,s=t.logger,n.userId&&n.userId===e)return[3,13];o="sendbird@".concat(n.appId,"/").concat(e,".db"),a.label=1;case 1:return a.trys.push([1,9,11,13]),r.localCacheEnabled?r.nestdb&&r.nestdb.state!==tt.CLOSED&&r.nestdb.name===o?[3,3]:(u="sendbird@".concat(n.appId,"/").concat(e,".db"),(c=r.nestdb=new nt({name:u,version:this._getNestDBVersion(),store:r.store,config:new rt({dbname:u,itemSizeLimit:61440})})).on("upgrade",_t(c)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",_t(c))})),[4,c.open()]):[3,6];case 2:return a.sent(),this._storeInitialized=!0,i.dispatch(new lt(this._iid,{userId:e})),[3,5];case 3:return[4,this._safeInitializeStore(o)];case 4:a.sent(),a.label=5;case 5:return n.userId=e,[3,8];case 6:return[4,this._safeInitializeStore(o)];case 7:a.sent(),n.userId=e,a.label=8;case 8:return[3,13];case 9:return d=a.sent(),s.warn("Nest DB Open Failed. ",d),r.store instanceof qe||(r.replaceStore(new qe),r.localCacheEnabled=!1),[4,this._safeInitializeStore(o)];case 10:throw a.sent(),n.userId=e,Z.databaseError;case 11:return[4,this._setupPreference(e)];case 12:return a.sent(),[7];case 13:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return i(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 i(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 i(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=Xe.of(this._iid),n=et.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return i(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:s.sent(),s.label=2;case 2:return[2]}}))}))},n.prototype._setupPreference=function(e){return i(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.cacheContext,i=t.statManager,[4,r.preference.init(this._getPreferenceCacheKey(e),this._getNestDBVersion())];case 1:return o.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 2:return(s=o.sent())&&new le(this._iid,s).apply(),[4,i.init("sendbird@".concat(n.appId,"/").concat(e,".statlog"))];case 3:return o.sent(),[2]}}))}))},n.prototype._ready=function(e,n,r){return void 0===r&&(r={}),i(this,void 0,void 0,(function(){var i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)&&t("string",n,!0)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.cacheContext,u=i.connectionManager,c=r.errorForOtherUser,s.userId&&s.userId!==e?c?[3,2]:[4,u.logout()]:[3,3];case 1:return a.sent(),[3,3];case 2:throw c;case 3:return a.trys.push([3,5,,6]),[4,this.initializeCache(e)];case 4:return a.sent(),q.of(this._iid).dispatcher.dispatch(new ht),[3,6];case 5:return a.sent(),d=q.of(this._iid).logger,o.localCacheEnabled=!1,d.warn("Cache initialization failed - cache is not available."),[3,6];case 6:return[2]}}))}))},n.prototype.authenticateFeed=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.authenticate(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.authenticate=function(e,t){var n;return i(this,void 0,void 0,(function(){var r,i,s;return a(this,(function(o){switch(o.label){case 0:return r=q.of(this._iid),i=r.sessionManager,s=r.connectionManager,[4,this._ready(e,t,{errorForOtherUser:s.isConnected?Z.alreadyConnectedAsAnotherUser:void 0})];case 1:return o.sent(),(null===(n=i.session.services)||void 0===n?void 0:n.includes(me.CHAT))?[3,3]:(t||i.handler||this.setSessionHandler(new $e),[4,i.authenticate(e,t)]);case 2:o.sent(),o.label=3;case 3:return[2,this.currentUser]}}))}))},n.prototype.connect=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this._ready(e,t)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,,4,5]),[4,q.of(this._iid).connectionManager.connect(t)];case 3:return n.sent(),[3,5];case 4:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 5:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._internalDisconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return i(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(!0)];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().catch((function(e){r.debug("setBackgroundState error = ",e)})))},n.prototype.setForegroundState=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,i=e.logger;"background"===n.appState&&(n.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((function(e){i.debug("setForgroundState error = ",e)})),r.dispatch(new pt))},n.prototype.setSessionHandler=function(e){ee(e instanceof $e).throw(Z.invalidParameters),q.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){ee(t("string",e)&&n instanceof We).throw(Z.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){ee(t("string",e)&&n instanceof Ve).throw(Z.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 Be(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Je(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Ye(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new Ze(this._iid,e)},n.prototype.createPollListQuery=function(e){return new te(this._iid,m({},e))},n.prototype.createPollVoterListQuery=function(e){return new ne(this._iid,m({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=re(e);return new g(this._iid,g.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=m(m({},bt),n),ee(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(Z.invalidParameters),this.currentUser?(i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new St(m({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(It).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw Z.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),this.currentUser?(t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(It).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw Z.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.ANDROID,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.FCM,e)?[2,be.SUCCESS]:(h=new Et({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.FCM,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Pt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Ut({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.IOS,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.APNS,e)?[2,be.SUCCESS]:(h=new Ct({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.APNS,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.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,s=n.sdkState,o=n.requestQueue,u=new Tt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,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,s=new Dt({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.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.markPushNotificationAsDelivered=function(e,t){var n;return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_,y,w,k;return a(this,(function(a){switch(a.label){case 0:if(r=q.of(this._iid),i=r.logger,s=r.sessionManager,o=r.requestQueue,u=r.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=fn.DELIVERED,d=u.parseData(e),l=d.pushTrackingId,h=d.sessionTopics,f=d.sessionKey,p=d.messageId,v=d.channelKey,g=d.templateKey,m=d.notificationEventDeadline,!f)throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!h.includes(we.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(u.isAcked(l,c))return i.info("already delivered push notification:",l),[2];b=Boolean(v),_=t&&b,y=null===(n=s.deviceTokens[0])||void 0===n?void 0:n.token,w=new Sn({deviceToken:null!=y?y:"",pushTrackingId:l,eventType:c,messageId:p,channelKey:v,templateKey:g,notificationEventDeadline:m,allowedPushNotification:_}),f&&(w.headers["Session-Key"]=f),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,o.send(w)];case 2:return a.sent(),u.markAsAcked(l,c),[3,4];case 3:throw k=a.sent(),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(l,". error: ").concat(k)),k;case 4:return[2]}}))}))},n.prototype.markPushNotificationAsClicked=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_;return a(this,(function(a){switch(a.label){case 0:if(n=q.of(this._iid),r=n.logger,i=n.sessionManager,s=n.requestQueue,o=n.pushNotificationAckManager,r.debug("markPushNotificationAsClicked:",e),u=fn.CLICKED,c=o.parseData(e),d=c.pushTrackingId,l=c.sessionTopics,h=c.sessionKey,f=c.messageId,p=c.channelKey,v=c.templateKey,g=c.notificationEventDeadline,!h)throw r.info("Can't use markPushNotificationAsClicked() feature."),Z.malformedDataError;if(!l.includes(we.PUSH_ACKNOWLEDGEMENT))throw r.info("Can't use markPushNotificationAsClicked() feature."),Z.malformedDataError;if(o.isAcked(d,u))return r.info("already clicked push notification:",d),[2];m=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,b=new Sn({deviceToken:null!=m?m:"",pushTrackingId:d,eventType:u,messageId:f,channelKey:p,templateKey:v,notificationEventDeadline:g}),h&&(b.headers["Session-Key"]=h),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,s.send(b)];case 2:return a.sent(),o.markAsAcked(d,u),[3,4];case 3:throw _=a.sent(),r.debug("failed to mark push notification as clicked. push tracking id: ".concat(d,". error: ").concat(_)),_;case 4:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return i(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 Nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Mt).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)).throw(Z.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(Rt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return i(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 zt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Qt).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,s,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===u&&(u=""),i(this,void 0,void 0,(function(){var i,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",s)&&t("number",o)&&t("string",u)).throw(Z.invalidParameters),i=q.of(this._iid),c=i.sdkState,d=i.requestQueue,l=new jt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:s,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(Ft).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return i(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(Ht).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),i(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new xt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(Kt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return i(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 ee(t("string",e)&&_e(_,n)).throw(Z.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new Ot({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(At).pushTokens;try{for(l=X(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 i(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 Vt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Bt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(ke,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Jt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Yt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return i(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 Zt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as($t).name]}}))}))},n.prototype.setPushTemplate=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(Se,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(en).name]}}))}))},n.prototype.blockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Gt({userId:r.userId,blockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Wt({userId:r.userId,unblockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new tn({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(nn).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return i(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 dn({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ln).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(t("boolean",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new hn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return i(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 rn({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(sn).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new on({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new an({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(un).users]}}))}))},n.prototype.deleteFriend=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new cn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return i(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 pn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(vn).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return i(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 gn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(mn).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return i(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 bn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(_n).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return i(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),ee(e.hasExtension("sb_uikit")).throw(Z.notSupportedError),t=e.requestQueue,n=new yn,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(wn).uikitConfiguration]}}))}))},n}();export{vt as Emoji,gt as EmojiCategory,mt as EmojiContainer,In as default}; diff --git a/lib/__bundle-c03282ec.js b/lib/__bundle-0ca331b6.js similarity index 69% rename from lib/__bundle-c03282ec.js rename to lib/__bundle-0ca331b6.js index cf42a4a..5e8039b 100644 --- a/lib/__bundle-c03282ec.js +++ b/lib/__bundle-0ca331b6.js @@ -1 +1 @@ -var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[i++],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 i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function c(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r0&&b.indexOf(e)>=0},I=function(e){return e>0&&m.indexOf(e)>=0},O=function(e,t){if(void 0===t&&(t=!1),t&&D(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},k=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(),i=c([],a(t),!1).sort(),r=0;r=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}(),L={encrypt:function(e){return e},decrypt:function(e){return e}},x=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return r(this,void 0,void 0,(function(){return s(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),r(this,void 0,void 0,(function(){var i,r,a,c,u,l,h,d,_,f;return s(this,(function(s){switch(s.label){case 0:return this._version=t,this._keysAddress=e,i="".concat(e,".metadata.version"),[4,this._store.get(i)];case 1:return r=s.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=s.sent())&&void 0!==n?n:[],!r||r.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(i,64),o?(this._clearOrder=s,this._customClearOrderComparator=o):this._clearOrder=E.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=c}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===E.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableAutoResend",{get:function(){return this._enableAutoResend},enumerable:!1,configurable:!0}),e}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(P||(P={}));var q,H,V,z,G,j,K,B,Q,W,Z,Y,X,J=function(){function e(){this.isRefreshing=!1}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasChatServicePermission",{get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(P.CHAT))},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]},e}(),$=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)}))},ee=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=$()}return e.prototype._register=function(e,t,n){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: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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))},e}(),te=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new ee({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new ee({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,i,r=this._container[e];if(r){var s=[];try{for(var a=o(r.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=r.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&s.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}s.forEach((function(e){return r.delete(e)}))}},e}(),ne=function(){function e(){this._dispatcher=new te}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}(),ie=function(){},re=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},se=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){for(var t=c([],a(e),!1),n=0;n0&&(i.extension_sdk_info=r.map((function(e){var t=e.product,n=e.platform,i=e.version;return"".concat(t,"/").concat(n,"/").concat(i)})).join(",")),Object.keys(i).forEach((function(e){return delete c[e]})),Object.keys(c).length>0&&(i=n(n({},i),c))}return Object.entries(i).map((function(e){var t=a(e,2),n=t[0],i=t[1];return"".concat(n,"=").concat(i)})).join("&")},e.userAgentWithExtension=function(e){var t=Xe()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",i=e.sb_uikit?"u".concat(e.sb_uikit):"",r=e["device-os-platform"]?"o".concat(e["device-os-platform"]):Je()?"omobile-web":"oweb";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(i,"/").concat(r)},e}(),tt=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=function(e){n(e)}}))},nt=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t.requestId,n}return t(n,e),n}(ie),it=function(e){function n(t){var n=e.call(this)||this;return n.method=oe.DELETE,n.path="".concat(Oe(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),t.messageToken&&(n.params=re({mesg_token:t.messageToken})),n}return t(n,e),n}(Ue);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Pe);var rt=function(e){function n(t,n,i){var r,s=this;return(s=e.call(this,t,"DELM",i)||this).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(r=i.sender_id)&&void 0!==r?r:void 0,s}return t(n,e),n}(qe),st=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=n,this._sdkState=i,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof Me&&c.cancel(e.requestId)})),this._logger=s,this._shouldImportFetchCompat=a}return e.prototype._createHeader=function(e,t){var i=this._sdkState,r=i.appId,s=i.appVersion,o=i.sendbirdRuntimeEnvironment,a=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(r).concat(s?",".concat(s):""),"SB-User-Agent":et.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":et.sendbirdSdkUserAgentWithExtension(o)});return t||(a["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(a["Session-Key"]=this._session.sessionKey),a["App-Id"]=r,this._session&&this._session.authToken&&(a["Access-Token"]=this._session.authToken),a},e.prototype._statLogApiResult=function(e,t,n){e.path.includes("/sdk/statistics")||this._dispatcher.dispatch(new Ke(new Ye({type:xe.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._isBodyRequired=function(e){var t=e.method;return t!==oe.GET&&(t!==oe.DELETE||e instanceof it)},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a,c,l,h,d,_,f,p,E,g,b,m,y,w;return s(this,(function(s){switch(s.label){case 0:t=e.path,n=e.method,i=e.uploadProgressHandler,r=this._isBodyRequired(e),o=this._sdkState.api,a="".concat(o.host).concat(t).concat(r?"":e.query),c=r?e.payload:null,l=this._createHeader(e,c instanceof FormData?c:void 0),h=new AbortController,d=h.signal,this._abortControl.set(e.requestId,h),_=Date.now(),s.label=1;case 1:return s.trys.push([1,13,,14]),i?[4,import("./__bundle-b5ef7de4.js")]:[3,6];case 2:f=s.sent().xmlHttpRequest,s.label=3;case 3:return s.trys.push([3,5,,6]),[4,f(this._iid,{requestId:e.requestId,method:e.method,url:a,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i})];case 4:return p=s.sent(),this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,p];case 5:if(!((E=s.sent())instanceof v&&E.code===u.XMLHTTPREQUEST_NOT_SUPPORTED))throw E;return this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),[3,6];case 6:return 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,8]:[4,import("./__bundle-7c3d40f4.js")];case 7:s.sent(),s.label=8;case 8:return"function"==typeof fetch?[3,10]:[4,import("./__bundle-46d64517.js")];case 9:s.sent(),s.label=10;case 10:return[4,fetch(a,{method:n,body:c,headers:l,signal:d})];case 11:return[4,(g=s.sent()).json()];case 12:if(b=s.sent(),g.ok||g.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,new Pe(this._iid,b)];if(b){if((m=new v(b)).isSessionExpiredError){if(this._dispatcher.dispatch(new Fe({reason:m.code,message:m.message})),!(e instanceof Ve))return y=new tt,this._dispatcher.dispatch(new Be({request:e,deferred:y,error:m})),[2,y.promise];throw m}throw m.isSessionInvalidatedError?(this._dispatcher.dispatch(new Fe({reason:m.code,message:m.message})),m):m}throw v.requestFailed;case 13:throw w=s.sent(),this._statLogApiResult(e,_,w),w instanceof v?(this._logger.debug("fail api request",w),w):"AbortError"===(null==w?void 0:w.name)?v.requestCanceled:(this._logger.debug("fail api request",w),v.networkError);case 14:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new nt({requestId:e}))},e.prototype.cancelAll=function(){var e,t;try{for(var n=o(this._abortControl.values()),i=n.next();!i.done;i=n.next()){i.value.abort()}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear(),this._dispatcher.dispatch(new nt({}))},e}(),ot=function(){};function at(e){let t=e.length;for(;--t>=0;)e[t]=0}const ct=256,ut=286,lt=30,ht=15,dt=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]),_t=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]),ft=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),pt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Et=new Array(576);at(Et);const gt=new Array(60);at(gt);const vt=new Array(512);at(vt);const bt=new Array(256);at(bt);const mt=new Array(29);at(mt);const yt=new Array(lt);function wt(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}let St,Tt,Nt;function Ct(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}at(yt);const At=e=>e<256?vt[e]:vt[256+(e>>>7)],It=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Ot=(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<{Ot(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},Rt=(e,t,n)=>{const i=new Array(16);let r,s,o=0;for(r=1;r<=ht;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=Dt(i[t]++,t))}},Lt=e=>{let t;for(t=0;t{e.bi_valid>8?It(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ut=(e,t,n,i)=>{const r=2*t,s=2*n;return e[r]{const i=e.heap[n];let r=n<<1;for(;r<=e.heap_len&&(r{let i,r,s,o,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,r=e.pending_buf[e.sym_buf+a++],0===i?kt(e,r,t):(s=bt[r],kt(e,s+ct+1,t),o=dt[s],0!==o&&(r-=mt[s],Ot(e,r,o)),i--,s=At(i),kt(e,s,n),o=_t[s],0!==o&&(i-=yt[s],Ot(e,i,o)))}while(a{const n=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)Pt(e,n,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Pt(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,n[2*c]=n[2*o]+n[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,n[2*o+1]=n[2*a+1]=c,e.heap[1]=c++,Pt(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,i=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=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<=ht;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>i||(e.bl_count[d]++,_=0,l>=a&&(_=o[l-a]),f=n[2*l],e.opt_len+=f*(d+_),s&&(e.static_len+=f*(r[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>i||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),Rt(n,u,e.bl_count)},qt=(e,t,n)=>{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=t[2*(i+1)+1],++a{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),i=0;i<=n;i++)if(r=o,o=t[2*(i+1)+1],!(++a{Ot(e,0+(i?1:0),3),xt(e),It(e,n),It(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Gt=(e,t,n,i)=>{let r,s,o=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(qt(e,e.dyn_ltree,e.l_desc.max_code),qt(e,e.dyn_dtree,e.d_desc.max_code),Ft(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*pt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&-1!==t?zt(e,t,n,i):4===e.strategy||s===r?(Ot(e,2+(i?1:0),3),Mt(e,Et,gt)):(Ot(e,4+(i?1:0),3),((e,t,n,i)=>{let r;for(Ot(e,t-257,5),Ot(e,n-1,5),Ot(e,i-4,4),r=0;r{Vt||((()=>{let e,t,n,i,r;const s=new Array(16);for(n=0,i=0;i<28;i++)for(mt[i]=n,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++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(bt[n]+ct+1)]++,e.dyn_dtree[2*At(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Ot(e,2,3),kt(e,256,Et),(e=>{16===e.bi_valid?(It(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 Kt=(e,t,n,i)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+t[i++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Bt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Qt=(e,t,n,i)=>{const r=Bt,s=i+n;e^=-1;for(let n=i;n>>8^r[255&(e^t[n])];return~e},Wt={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"},Zt={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:Yt,_tr_stored_block:Xt,_tr_flush_block:Jt,_tr_tally:$t,_tr_align:en}=jt,{Z_NO_FLUSH:tn,Z_PARTIAL_FLUSH:nn,Z_FULL_FLUSH:rn,Z_FINISH:sn,Z_BLOCK:on,Z_OK:an,Z_STREAM_END:cn,Z_STREAM_ERROR:un,Z_DATA_ERROR:ln,Z_BUF_ERROR:hn,Z_DEFAULT_COMPRESSION:dn,Z_FILTERED:_n,Z_HUFFMAN_ONLY:fn,Z_RLE:pn,Z_FIXED:En,Z_DEFAULT_STRATEGY:gn,Z_UNKNOWN:vn,Z_DEFLATED:bn}=Zt,mn=258,yn=262,wn=42,Sn=113,Tn=666,Nn=(e,t)=>(e.msg=Wt[t],t),Cn=e=>2*e-(e>4?9:0),An=e=>{let t=e.length;for(;--t>=0;)e[t]=0},In=e=>{let t,n,i,r=e.w_size;t=e.hash_size,i=t;do{n=e.head[--i],e.head[i]=n>=r?n-r:0}while(--t);t=r,i=t;do{n=e.prev[--i],e.prev[i]=n>=r?n-r:0}while(--t)};let On=(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)=>{Jt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,kn(e.strm)},Rn=(e,t)=>{e.pending_buf[e.pending++]=t},Ln=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},xn=(e,t,n,i)=>{let r=e.avail_in;return r>i&&(r=i),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),n),1===e.state.wrap?e.adler=Kt(e.adler,t,r,n):2===e.state.wrap&&(e.adler=Qt(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)},Un=(e,t)=>{let n,i,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-yn?e.strstart-(e.w_size-yn):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+mn;let _=u[s+o-1],f=u[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+o]===f&&u[n+o-1]===_&&u[n]===u[s]&&u[++n]===u[s+1]){s+=2,n++;do{}while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&so){if(e.match_start=t,o=i,i>=a)break;_=u[s+o-1],f=u[s+o]}}}while((t=h[t&l])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead},Pn=e=>{const t=e.w_size;let n,i,r;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-yn)&&(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),In(e),i+=t),0===e.strm.avail_in)break;if(n=xn(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=n,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=On(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=On(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,i,r,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(n=65535,r=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(n=i+e.strm.avail_in),n>r&&(n=r),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,kn(e.strm),i&&(i>n&&(i=n),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,n-=i),n&&(xn(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===o);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_waterr&&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++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(xn(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,s=r>e.w_size?e.w_size:r,i=e.strstart-e.block_start,(i>=s||(i||t===sn)&&t!==tn&&0===e.strm.avail_in&&i<=r)&&(n=i>r?r:i,o=t===sn&&0===e.strm.avail_in&&n===i?1:0,Xt(e,e.block_start,n,o),e.block_start+=n,kn(e.strm)),o?3:1)},Fn=(e,t)=>{let n,i;for(;;){if(e.lookahead=3&&(e.ins_h=On(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-yn&&(e.match_length=Un(e,n)),e.match_length>=3)if(i=$t(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=On(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=On(e,e.ins_h,e.window[e.strstart+1]);else i=$t(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(Dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===sn?(Dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Dn(e,!1),0===e.strm.avail_out)?1:2},qn=(e,t)=>{let n,i,r;for(;;){if(e.lookahead=3&&(e.ins_h=On(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){r=e.strstart+e.lookahead-3,i=$t(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=On(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++,i&&(Dn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=$t(e,0,e.window[e.strstart-1]),i&&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&&(i=$t(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===sn?(Dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Dn(e,!1),0===e.strm.avail_out)?1:2};function Hn(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}const Vn=[new Hn(0,0,0,0,Mn),new Hn(4,4,8,4,Fn),new Hn(4,5,16,8,Fn),new Hn(4,6,32,32,Fn),new Hn(4,4,16,16,qn),new Hn(8,16,32,32,qn),new Hn(8,16,128,128,qn),new Hn(8,32,128,256,qn),new Hn(32,128,258,1024,qn),new Hn(32,258,258,4096,qn)];function zn(){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=bn,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),An(this.dyn_ltree),An(this.dyn_dtree),An(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),An(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),An(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 Gn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==wn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Sn&&t.status!==Tn?1:0},jn=e=>{if(Gn(e))return Nn(e,un);e.total_in=e.total_out=0,e.data_type=vn;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?wn:Sn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Yt(t),an},Kn=e=>{const t=jn(e);var n;return t===an&&((n=e.state).window_size=2*n.w_size,An(n.head),n.max_lazy_match=Vn[n.level].max_lazy,n.good_match=Vn[n.level].good_length,n.nice_match=Vn[n.level].nice_length,n.max_chain_length=Vn[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},Bn=(e,t,n,i,r,s)=>{if(!e)return un;let o=1;if(t===dn&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>9||n!==bn||i<8||i>15||t<0||t>9||s<0||s>En||8===i&&1!==o)return Nn(e,un);8===i&&(i=9);const a=new zn;return e.state=a,a.strm=e,a.status=wn,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<Bn(e,t,bn,15,8,gn),deflateInit2:Bn,deflateReset:Kn,deflateResetKeep:jn,deflateSetHeader:(e,t)=>Gn(e)||2!==e.state.wrap?un:(e.state.gzhead=t,an),deflate:(e,t)=>{if(Gn(e)||t>on||t<0)return e?Nn(e,un):un;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Tn&&t!==sn)return Nn(e,0===e.avail_out?hn:un);const i=n.last_flush;if(n.last_flush=t,0!==n.pending){if(kn(e),0===e.avail_out)return n.last_flush=-1,an}else if(0===e.avail_in&&Cn(t)<=Cn(i)&&t!==sn)return Nn(e,hn);if(n.status===Tn&&0!==e.avail_in)return Nn(e,hn);if(n.status===wn&&0===n.wrap&&(n.status=Sn),n.status===wn){let t=bn+(n.w_bits-8<<4)<<8,i=-1;if(i=n.strategy>=fn||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=i<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Ln(n,t),0!==n.strstart&&(Ln(n,e.adler>>>16),Ln(n,65535&e.adler)),e.adler=1,n.status=Sn,kn(e),0!==n.pending)return n.last_flush=-1,an}if(57===n.status)if(e.adler=0,Rn(n,31),Rn(n,139),Rn(n,8),n.gzhead)Rn(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)),Rn(n,255&n.gzhead.time),Rn(n,n.gzhead.time>>8&255),Rn(n,n.gzhead.time>>16&255),Rn(n,n.gzhead.time>>24&255),Rn(n,9===n.level?2:n.strategy>=fn||n.level<2?4:0),Rn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Rn(n,255&n.gzhead.extra.length),Rn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Qt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Rn(n,0),Rn(n,0),Rn(n,0),Rn(n,0),Rn(n,0),Rn(n,9===n.level?2:n.strategy>=fn||n.level<2?4:0),Rn(n,3),n.status=Sn,kn(e),0!==n.pending)return n.last_flush=-1,an;if(69===n.status){if(n.gzhead.extra){let t=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=r,kn(e),0!==n.pending)return n.last_flush=-1,an;t=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>t&&(e.adler=Qt(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,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,an;i=0}t=n.gzindexi&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,an;i=0}t=n.gzindexi&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(kn(e),0!==n.pending))return n.last_flush=-1,an;Rn(n,255&e.adler),Rn(n,e.adler>>8&255),e.adler=0}if(n.status=Sn,kn(e),0!==n.pending)return n.last_flush=-1,an}if(0!==e.avail_in||0!==n.lookahead||t!==tn&&n.status!==Tn){let i=0===n.level?Mn(n,t):n.strategy===fn?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Pn(e),0===e.lookahead)){if(t===tn)return 1;break}if(e.match_length=0,n=$t(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===sn?(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===pn?((e,t)=>{let n,i,r,s;const o=e.window;for(;;){if(e.lookahead<=mn){if(Pn(e),e.lookahead<=mn&&t===tn)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=e.strstart+mn;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=$t(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=$t(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===sn?(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):Vn[n.level].func(n,t);if(3!==i&&4!==i||(n.status=Tn),1===i||3===i)return 0===e.avail_out&&(n.last_flush=-1),an;if(2===i&&(t===nn?en(n):t!==on&&(Xt(n,0,0,!1),t===rn&&(An(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),kn(e),0===e.avail_out))return n.last_flush=-1,an}return t!==sn?an:n.wrap<=0?cn:(2===n.wrap?(Rn(n,255&e.adler),Rn(n,e.adler>>8&255),Rn(n,e.adler>>16&255),Rn(n,e.adler>>24&255),Rn(n,255&e.total_in),Rn(n,e.total_in>>8&255),Rn(n,e.total_in>>16&255),Rn(n,e.total_in>>24&255)):(Ln(n,e.adler>>>16),Ln(n,65535&e.adler)),kn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?an:cn)},deflateEnd:e=>{if(Gn(e))return un;const t=e.state.status;return e.state=null,t===Sn?Nn(e,ln):an},deflateSetDictionary:(e,t)=>{let n=t.length;if(Gn(e))return un;const i=e.state,r=i.wrap;if(2===r||1===r&&i.status!==wn||i.lookahead)return un;if(1===r&&(e.adler=Kt(e.adler,t,n,0)),i.wrap=0,n>=i.w_size){0===r&&(An(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(n-i.w_size,n),0),t=e,n=i.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Pn(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=On(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,Pn(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=o,e.input=a,e.avail_in=s,i.wrap=r,an},deflateInfo:"pako deflate (from Nodeca project)"};const Wn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Zn=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)Wn(n,t)&&(e[t]=n[t])}}return e},Yn=e=>{let t=0;for(let n=0,i=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Jn[254]=Jn[254]=1;var $n=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,i,r,s,o=e.length,a=0;for(r=0;r>>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},ei=(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let i,r;const s=new Array(2*n);for(r=0,i=0;i4)s[r++]=65533,i+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&i1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Xn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let i=0;i{(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+Jn[e[n]]>t?n:t};var ni=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 ii=Object.prototype.toString,{Z_NO_FLUSH:ri,Z_SYNC_FLUSH:si,Z_FULL_FLUSH:oi,Z_FINISH:ai,Z_OK:ci,Z_STREAM_END:ui,Z_DEFAULT_COMPRESSION:li,Z_DEFAULT_STRATEGY:hi,Z_DEFLATED:di}=Zt;function _i(e){this.options=Zn({level:li,method:di,chunkSize:16384,windowBits:15,memLevel:8,strategy:hi},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 ni,this.strm.avail_out=0;let n=Qn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ci)throw new Error(Wt[n]);if(t.header&&Qn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?$n(t.dictionary):"[object ArrayBuffer]"===ii.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Qn.deflateSetDictionary(this.strm,e),n!==ci)throw new Error(Wt[n]);this._dict_set=!0}}function fi(e,t){const n=new _i(t);if(n.push(e,!0),n.err)throw n.msg||Wt[n.err];return n.result}_i.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?ai:ri,"string"==typeof e?n.input=$n(e):"[object ArrayBuffer]"===ii.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(i),n.next_out=0,n.avail_out=i),(s===si||s===oi)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(r=Qn.deflate(n,s),r===ui)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),r=Qn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===ci;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},_i.prototype.onData=function(e){this.chunks.push(e)},_i.prototype.onEnd=function(e){e===ci&&(this.result=Yn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var pi={Deflate:_i,deflate:fi,deflateRaw:function(e,t){return(t=t||{}).raw=!0,fi(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,fi(e,t)},constants:Zt};const Ei=16209;var gi=function(e,t){let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T,N;const C=e.state;n=e.next_in,T=e.input,i=n+(e.avail_in-5),r=e.next_out,N=e.output,s=r-(t-e.avail_out),o=r+(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,E=(1<>>24,d>>>=b,_-=b,b=v>>>16&255,0===b)N[r++]=65535&v;else{if(!(16&b)){if(64&b){if(32&b){C.mode=16191;break e}e.msg="invalid literal/length code",C.mode=Ei;break e}v=f[(65535&v)+(d&(1<>>=b,_-=b),_<15&&(d+=T[n++]<<_,_+=8,d+=T[n++]<<_,_+=8),v=p[d&g];;){if(b=v>>>24,d>>>=b,_-=b,b=v>>>16&255,16&b){if(y=65535&v,b&=15,_a){e.msg="invalid distance too far back",C.mode=Ei;break e}if(d>>>=b,_-=b,b=r-s,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=Ei;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)N[r++]=S[w++],N[r++]=S[w++],N[r++]=S[w++],m-=3;m&&(N[r++]=S[w++],m>1&&(N[r++]=S[w++]))}else{w=r-y;do{N[r++]=N[w++],N[r++]=N[w++],N[r++]=N[w++],m-=3}while(m>2);m&&(N[r++]=N[w++],m>1&&(N[r++]=N[w++]))}break}if(64&b){e.msg="invalid distance code",C.mode=Ei;break e}v=p[(65535&v)+(d&(1<>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=r,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,E=0,g=0,v=0,b=0,m=0,y=0,w=0,S=0,T=0,N=null;const C=new Uint16Array(16),A=new Uint16Array(16);let I,O,k,D=null;for(p=0;p<=vi;p++)C[p]=0;for(E=0;E=1&&0===C[v];v--);if(b>v&&(b=v),0===v)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(A[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){I=p-y,o[E]+1=f?(O=D[o[E]-f],k=N[o[E]-f]):(O=96,k=0),u=1<>y)+l]=I<<24|O<<16|k}while(0!==l);for(u=1<>=1;if(0!==u?(T&=u-1,T+=u):T=0,E++,0==--C[p]){if(p===v)break;p=t[n+o[E]]}if(p>b&&(T&d)!==h){for(0===y&&(y=b),_+=g,m=p-y,w=1<852||2===e&&S>592)return 1;h=T&d,r[h]=b<<24|m<<16|_-s}}return 0!==T&&(r[_+T]=p-y<<24|64<<16),a.bits=b,0};const{Z_FINISH:Ti,Z_BLOCK:Ni,Z_TREES:Ci,Z_OK:Ai,Z_STREAM_END:Ii,Z_NEED_DICT:Oi,Z_STREAM_ERROR:ki,Z_DATA_ERROR:Di,Z_MEM_ERROR:Ri,Z_BUF_ERROR:Li,Z_DEFLATED:xi}=Zt,Ui=16180,Pi=16190,Mi=16191,Fi=16192,qi=16194,Hi=16199,Vi=16200,zi=16206,Gi=16209,ji=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ki(){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 Bi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Qi=e=>{if(Bi(e))return ki;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=Ui,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,Ai},Wi=e=>{if(Bi(e))return ki;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Qi(e)},Zi=(e,t)=>{let n;if(Bi(e))return ki;const i=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ki:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,Wi(e))},Yi=(e,t)=>{if(!e)return ki;const n=new Ki;e.state=n,n.strm=e,n.window=null,n.mode=Ui;const i=Zi(e,t);return i!==Ai&&(e.state=null),i};let Xi,Ji,$i=!0;const er=e=>{if($i){Xi=new Int32Array(512),Ji=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(Si(1,e.lens,0,288,Xi,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Si(2,e.lens,0,32,Ji,0,e.work,{bits:5}),$i=!1}e.lencode=Xi,e.lenbits=9,e.distcode=Ji,e.distbits=5},tr=(e,t,n,i)=>{let r;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):(r=s.wsize-s.wnext,r>i&&(r=i),s.window.set(t.subarray(n-i,n-i+r),s.wnext),(i-=r)?(s.window.set(t.subarray(n-i,n),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whaveYi(e,15),inflateInit2:Yi,inflate:(e,t)=>{let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T=0;const N=new Uint8Array(4);let C,A;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Bi(e)||!e.output||!e.input&&0!==e.avail_in)return ki;n=e.state,n.mode===Mi&&(n.mode=Fi),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=Ai;e:for(;;)switch(n.mode){case Ui:if(0===n.wrap){n.mode=Fi;break}for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>>8&255,n.check=Qt(n.check,N,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=Gi;break}if((15&u)!==xi){e.msg="unknown compression method",n.mode=Gi;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=Gi;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Qt(n.check,N,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>8&255,N[2]=u>>>16&255,N[3]=u>>>24&255,n.check=Qt(n.check,N,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>8),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Qt(n.check,N,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+=i[s++]<>>8&255,n.check=Qt(n.check,N,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(i.subarray(s,s+_),w)),512&n.flags&&4&n.wrap&&(n.check=Qt(n.check,i,_,s)),a-=_,s+=_,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=i[s+_++],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=Mi;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>=7&l,l-=7&l,n.mode=zi;break}for(;l<3;){if(0===a)break e;a--,u+=i[s++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(er(n),n.mode=Hi,t===Ci){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Gi}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=i[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Gi;break}if(n.length=65535&u,u=0,l=0,n.mode=qi,t===Ci)break e;case qi:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;r.set(i.subarray(s,s+_),o),a-=_,s+=_,c-=_,o+=_,n.length-=_;break}n.mode=Mi;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=i[s++]<>>=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=Gi;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,C={bits:n.lenbits},S=Si(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=Gi;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=E,l-=E,n.lens[n.have++]=v;else{if(16===v){for(A=E+2;l>>=E,l-=E,0===n.have){e.msg="invalid bit length repeat",n.mode=Gi;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===v){for(A=E+3;l>>=E,l-=E,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(A=E+7;l>>=E,l-=E,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Gi;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===Gi)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Gi;break}if(n.lenbits=9,C={bits:n.lenbits},S=Si(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=Gi;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=Si(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=Gi;break}if(n.mode=Hi,t===Ci)break e;case Hi:n.mode=Vi;case Vi:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,n.hold=u,n.bits=l,gi(e,d),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===Mi&&(n.back=-1);break}for(n.back=0;T=n.lencode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,n.length=v,0===g){n.mode=16205;break}if(32&g){n.back=-1,n.mode=Mi;break}if(64&g){e.msg="invalid literal/length code",n.mode=Gi;break}n.extra=15&g,n.mode=16201;case 16201:if(n.extra){for(A=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;T=n.distcode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,64&g){e.msg="invalid distance code",n.mode=Gi;break}n.offset=v,n.extra=15&g,n.mode=16203;case 16203:if(n.extra){for(A=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=Gi;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=Gi;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=r,f=o-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{r[o++]=p[f++]}while(--_);0===n.length&&(n.mode=Vi);break;case 16205:if(0===c)break e;r[o++]=n.length,c--,n.mode=Vi;break;case zi:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=i[s++]<{if(Bi(e))return ki;let t=e.state;return t.window&&(t.window=null),e.state=null,Ai},inflateGetHeader:(e,t)=>{if(Bi(e))return ki;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Ai):ki},inflateSetDictionary:(e,t)=>{const n=t.length;let i,r,s;return Bi(e)?ki:(i=e.state,0!==i.wrap&&i.mode!==Pi?ki:i.mode===Pi&&(r=1,r=Kt(r,t,n,0),r!==i.check)?Di:(s=tr(e,t,n,n),s?(i.mode=16210,Ri):(i.havedict=1,Ai)))},inflateInfo:"pako inflate (from Nodeca project)"};var ir=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 rr=Object.prototype.toString,{Z_NO_FLUSH:sr,Z_FINISH:or,Z_OK:ar,Z_STREAM_END:cr,Z_NEED_DICT:ur,Z_STREAM_ERROR:lr,Z_DATA_ERROR:hr,Z_MEM_ERROR:dr}=Zt;function _r(e){this.options=Zn({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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ni,this.strm.avail_out=0;let n=nr.inflateInit2(this.strm,t.windowBits);if(n!==ar)throw new Error(Wt[n]);if(this.header=new ir,nr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=$n(t.dictionary):"[object ArrayBuffer]"===rr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=nr.inflateSetDictionary(this.strm,t.dictionary),n!==ar)))throw new Error(Wt[n])}function fr(e,t){const n=new _r(t);if(n.push(e),n.err)throw n.msg||Wt[n.err];return n.result}_r.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?or:sr,"[object ArrayBuffer]"===rr.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(i),n.next_out=0,n.avail_out=i),s=nr.inflate(n,o),s===ur&&r&&(s=nr.inflateSetDictionary(n,r),s===ar?s=nr.inflate(n,o):s===hr&&(s=ur));n.avail_in>0&&s===cr&&n.state.wrap>0&&0!==e[n.next_in];)nr.inflateReset(n),s=nr.inflate(n,o);switch(s){case lr:case hr:case ur:case dr:return this.onEnd(s),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||s===cr))if("string"===this.options.to){let e=ti(n.output,n.next_out),t=n.next_out-e,r=ei(n.output,e);n.next_out=t,n.avail_out=i-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==ar||0!==a){if(s===cr)return s=nr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},_r.prototype.onData=function(e){this.chunks.push(e)},_r.prototype.onEnd=function(e){e===ar&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Yn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var pr={Inflate:_r,inflate:fr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,fr(e,t)},ungzip:fr,constants:Zt};const{Deflate:Er,deflate:gr,deflateRaw:vr,gzip:br}=pi,{Inflate:mr,inflate:yr,inflateRaw:wr,ungzip:Sr}=pr;var Tr,Nr={Deflate:Er,deflate:gr,deflateRaw:vr,gzip:br,Inflate:mr,inflate:yr,inflateRaw:wr,ungzip:Sr,constants:Zt},Cr=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){return t=Nr.ungzip(e),[2,String.fromCharCode.apply(null,t)]}))}))};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(Tr||(Tr={}));var Ar,Ir=function(e){function n(t,n){var i=n.sdkState,r=n.dispatcher,s=n.logger,o=e.call(this)||this;return o.lastActive=0,o._iid=t,o._sdkState=i,o._dispatcher=r,o._logger=s,o}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===Tr.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return Tr.CONNECTING;case 1:return Tr.OPEN}return Tr.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ws",{get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._handleMessage=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 i=new Fe(n.payload);i.expiresIn>=0&&t._dispatcher.dispatch(i)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e,t){return void 0===t&&(t=""),r(this,void 0,void 0,(function(){var n=this;return s(this,(function(i){return this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return r(n,void 0,void 0,(function(){var t,n,i,o,a,c,u,l=this;return s(this,(function(h){switch(h.label){case 0:return(null===(u=this._sdkState.websocket)||void 0===u?void 0:u.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return r(l,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,Cr(t.result)];case 1:return e=i.sent(),this._handleMessage(e),[3,3];case 2:return n=i.sent(),this.error(n),[3,3];case 3:return[2]}}))}))},[3,12]):[3,1]:[3,13];case 1:if(!(e.data instanceof ArrayBuffer))return[3,6];h.label=2;case 2:return h.trys.push([2,4,,5]),[4,Cr(new Uint8Array(e.data))];case 3:return a=h.sent(),this._handleMessage(a),[3,5];case 4:return n=h.sent(),this.error(n),[3,5];case 5:return[3,12];case 6:if(!("undefined"!=typeof Buffer&&e.data instanceof Buffer))return[3,11];h.label=7;case 7:return h.trys.push([7,9,,10]),i=e.data,o=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),[4,Cr(o)];case 8:return a=h.sent(),this._handleMessage(a),[3,10];case 9:return c=h.sent(),this.error(c),[3,10];case 10:return[3,12];case 11:"string"==typeof e.data&&this._handleMessage(e.data),h.label=12;case 12:return[3,14];case 13:this._handleMessage(e.data),h.label=14;case 14:return[2]}}))}))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",v.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now(),[2]}))}))},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws?(e._ws.onopen=ot,e._ws.onmessage=ot,e._ws.onerror=ot,e.connectionState!==Tr.CLOSED?(e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=void 0):t()):t()}))},n.prototype.send=function(e){if(!this._ws)throw v.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}(te),Or=function(e){function n(t){var n=t.all,i=t.feed,r=t.custom_types,s=t.ts,o=e.call(this)||this;return o.all=n,o.feed=i,o.customTypes=r,o.ts=s,o}return t(n,e),n}(ie),kr=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=r,this._logger=s,this.apiClient=new st(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:a}),this.websocketClient=new Ir(e,{sdkState:i,dispatcher:r,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new Or(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 v({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(v.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r=this;return s(this,(function(s){if(!this._sdkState.websocket)throw v.connectionRequired;if(t=new tt,e.ackRequired){i=function(i,s){r._ackStateMap.has(e.requestId)&&(r._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),i?(r._logger.debug("fail websocket request",e.requestId,i),t.reject(i)):(r._logger.debug("receive websocket ack",e.requestId,e),r._logger.debug("receive websocket ack",s),t.resolve(s)))};try{n=setTimeout((function(){return i(v.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return i(void 0,e)},reject:function(e){return i(e)}}),this.websocketClient.send(e)}catch(e){i(e)}}else try{this.websocketClient.send(e),t.resolve()}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return e instanceof Ue?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof He?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw v.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"}(Ar||(Ar={}));var Dr,Rr,Lr=function(e){function n(t){var n=t.stateType,i=e.call(this)||this;return i.stateType=n,i}return t(n,e),n}(ie),xr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Ur=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Pr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Mr=function(){function e(e){var t,n,i,r;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(n=e.feed_channels)&&void 0!==n?n:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(r=e.settings_updated_at)&&void 0!==r?r:0}return e.payloadify=function(e){return re(se({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))},e}(),Fr=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},qr=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 re(se({last_updated_at:e.lastUpdatedAt}))},e}(),Hr=function(){function e(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}return e.payloadify=function(e){return re(se({template_list_token:e.token}))},e}(),Vr=function(){function e(e){void 0===e&&(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}),this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}return e.payloadify=function(e){return re(se({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))},e}(),zr=function(){function e(e){void 0===e&&(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}),this.default=new Vr(e.default),this.realTime=new Vr(e.realtime)}return e.payloadify=function(e){return re(se({default:Vr.payloadify(e.default),realtime:Vr.payloadify(e.realTime)}))},e}(),Gr=1048576,jr=5;!function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Dr||(Dr={})),function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Rr||(Rr={}));var Kr=function(){function e(e){var t,n,i,r,s,o,a;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Gr: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!==(i=e.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(r=e.allow_sdk_log_ingestion)||void 0===r||r,this.unreadCountThreadingPolicy=null!==(s=e.unread_cnt_threading_policy)&&void 0!==s?s:Dr.NONE,this.lastMessageThreadingPolicy=null!==(o=e.last_msg_threading_policy)&&void 0!==o?o:Rr.NONE,this.uikitConfigInfo=new qr(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new Mr(e.notifications):null,this.messageTemplateInfo=e.message_template?new Hr(e.message_template):null,this.statConfigInfo=e.log_publish_config?new zr(e.log_publish_config):new zr}return e.payloadify=function(e){return re(se({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Gr,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?qr.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Mr.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Hr.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?zr.payloadify(e.statConfigInfo):null}))},e}(),Br=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return{}},e}(),Qr=function(e){function n(t){var n=t.userId,i=t.metadata,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(ce,"/").concat(n,"/metadata"),r.params={metadata:i},r}return t(n,e),n}(Ue),Wr=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metaData=n,i}return t(n,e),n}(Pe),Zr=function(e){function n(t){var n=t.userId,i=t.metadata,r=t.upsert,s=e.call(this)||this;return s.method=oe.PUT,s.path="".concat(ce,"/").concat(n,"/metadata"),s.params={metadata:i,upsert:r},s}return t(n,e),n}(Ue),Yr=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metadata=n,i}return t(n,e),n}(Pe),Xr=function(e){function n(t){var n=t.userId,i=t.metadataKey,r=e.call(this)||this;return r.method=oe.DELETE,r.path="".concat(ce,"/").concat(n,"/metadata/").concat(i),r}return t(n,e),n}(Ue);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Pe);var Jr=function(e){function n(t){var n=t.userId,i=e.call(this)||this;return i.method=oe.DELETE,i.path="".concat(ce,"/").concat(n,"/metadata"),i}return t(n,e),n}(Ue);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Pe);var $r,es=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},ts=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ns=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"}($r||($r={}));var is,rs=function(e){function i(t,n){var i,r,s,o,u,l,h,d,_,f,p,E,g=this;return(g=e.call(this,t)||this).userId=null!==(r=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==r?r:"",g.nickname=null!==(o=null!==(s=n.nickname)&&void 0!==s?s:n.name)&&void 0!==o?o:"",g.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",g.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,g.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},g.connectionStatus=$r.NON_AVAILABLE,S($r,n.is_online)?g.connectionStatus=n.is_online:w("boolean",n.is_online)&&(g.connectionStatus=n.is_online?$r.ONLINE:$r.OFFLINE),g.isActive=null===(_=n.is_active)||void 0===_||_,g.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,g.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,g.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,g.friendName=null!==(E=n.friend_name)&&void 0!==E?E:null,g}return t(i,e),i.payloadify=function(t){return re(se(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(i.prototype,"profileUrl",{get:function(){var e=eo.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),i.prototype.serialize=function(){return es(this)},i.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)}))},i.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(i){t?delete n.metaData[i]:n.metaData[i]=e[i]}))},i.prototype.createMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return ns(this._isValidMetaData(e)).throw(v.invalidParameters),t=eo.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Qr({userId:n.userId,metadata:e}),[4,i.send(r)];case 1:return o=s.sent(),a=o.as(Wr).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},i.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n,i,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:return ns(this._isValidMetaData(e)).throw(v.invalidParameters),n=eo.of(this._iid),i=n.sdkState,r=n.requestQueue,o=new Zr({userId:i.userId,metadata:e,upsert:t}),[4,r.send(o)];case 1:return a=s.sent(),c=a.as(Yr).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},i.prototype.deleteMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return ns(w("string",e)).throw(v.invalidParameters),t=eo.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Xr({userId:n.userId,metadataKey:e}),[4,i.send(r)];case 1:return s.sent(),this._applyMetaData(((o={})[e]=!0,o),!0),[2,this.metaData]}}))}))},i.prototype.deleteAllMetaData=function(){return r(this,void 0,void 0,(function(){var e,t,n,i;return s(this,(function(r){switch(r.label){case 0:return e=eo.of(this._iid),t=e.sdkState,n=e.requestQueue,i=new Jr({userId:t.userId}),[4,n.send(i)];case 1:return r.sent(),this.metaData={},[2]}}))}))},i}(Br),ss=function(e){function n(t){var n=t.userProfile,i=e.call(this)||this;return i.userProfile=n,i}return t(n,e),n}(ie),os=function(){function e(e,t){var n,i,r,s,o,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new Kr(t),this.user=new rs(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=t.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(r=t.pong_timeout)&&void 0!==r?r:5e3,this.reconnectInterval=null!==(o=null===(s=t.reconnect)||void 0===s?void 0:s.interval)&&void 0!==o?o: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 re(se(n(n(n({},rs.payloadify(e.user)),Kr.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,i=eo.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:function(i){return i>0?1e3*Math.min(e*Math.pow(n,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 ss({userProfile:this}))},e}(),as=function(e){function i(t){var i=t.request,r=void 0===i||i,s=t.features,o=void 0===s?{}:s,a=t.options,c=void 0===a?{}:a,u=t.statConfigInfo,l=e.call(this)||this;return l.request=r,l.features=n({localCache:!0,notification:!0},o),l.options=n({ingestion:!0},c),l.statConfigInfo=u,l}return t(i,e),i}(ie),cs=function(e){function i(t,n,i){var r,s,o,a,c=this;return(c=e.call(this,t,n,i)||this).error=null,c.services=[],c.userProfile=new os(t,i),c.deviceTokenLastDeletedAt=null!==(r=i.device_token_last_deleted_at)&&void 0!==r?r:0,c.key=null!==(s=i.key)&&void 0!==s?s:"",c.ekey=null!==(o=i.ekey)&&void 0!==o?o:"",c.error=i.error?new v(i):null,c.services=null!==(a=i.services)&&void 0!==a?a:[],c}return t(i,e),i.asError=function(e){return new i("","LOGI",n({user_id:"",error:!0},e))},i.prototype.applyTo=function(e){return r(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(r){switch(r.label){case 0:return this.error?[3,4]:(t=eo.of(e))?(n=t.sessionManager,i=t.dispatcher,[4,n.login(this)]):[3,2];case 1:return r.sent(),this.userProfile.apply(),i.dispatch(new as({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),[3,3];case 2:throw v.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},i}(qe),us=function(){function e(){this.type=Ar.NONE,this.name="none"}return e.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,t.cause,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e}(),ls=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e()];case 1:return n.sent(),[3,3];case 2:if(!((t=n.sent())instanceof v))throw t;return t.throwOutside(),[3,3];case 3:return[2]}}))}))},hs=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e()];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},ds=function(e){function n(t){void 0===t&&(t={});var n,i=this;return(i=e.call(this)||this).type=Ar.LOGOUT,i.name="logout",i._wasPreviouslyConnected=null===(n=t.wasPreviouslyConnected)||void 0===n||n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(o){switch(o.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return o.sent(),[4,e.changeState(new Ts,t)];case 2:return o.sent(),this._wasPreviouslyConnected&&ls((function(){return r(i,void 0,void 0,(function(){return s(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(us),_s=function(e){function n(){var t=e.call(this)||this;return t.type=Ar.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new ys({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new vs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ds,t)];case 1:return n.sent(),[2]}}))}))},n}(us),fs=function(e){function n(t){var n=t.autoReconnect,i=e.call(this)||this;return i.type=Ar.INTERNAL_DISCONNECTED,i.name="internaldisconnected",i._autoReconnect=!1,i._autoReconnect=n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new vs,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new ys({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new vs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new _s,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ds,t)];case 1:return n.sent(),[2]}}))}))},n}(us),ps=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},Es=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),gs=function(e,t,n){return void 0===n&&(n=new Es),r(void 0,void 0,void 0,(function(){var i,r,o,a,c,u;return s(this,(function(s){switch(s.label){case 0:i=0,r=null,o=function(e){return r=null!=e?e:new Error("Halted")},a=function(){i=0},s.label=1;case 1:if(!(-1===t||i=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Lr({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 r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return n.sent(),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.session.authToken=void 0,t.error.isSessionExpiredError||t.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Fe({reason:t.error.code,message:t.error.message})):this._logger.warn("login failed: ".concat(t.error)),this._rejectConnectionRequest(t.error),n.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(){var e,t=this.sdkState,n=t.appId,i=t.appVersion,r=t.userId,s=t.extensions,o=t.sendbirdRuntimeEnvironment,a=this.cacheContext.localCacheEnabled,c=this._sessionManager.session,u=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=s?s:{}).sb_uikit,d=et.userAgentWithExtension(s);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(n).concat(i?"&av=".concat(i):"").concat(c.hasSession?"":"&user_id=".concat(encodeURIComponent(r)),"&pmce=").concat(u?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent(et.sendbirdSdkUserAgentWithExtension(o)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(As))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(a?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")},n.prototype._statLogConnection=function(e){var t;this._dispatcher.dispatch(new Ke(new Ye({type:xe.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:this._connectedAt>0?this._connectedAt-this._connectingAt:0,logi_latency:this._logiReceivedAt>0?this._logiReceivedAt-this._connectedAt:void 0,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=""),r(this,void 0,void 0,(function(){var n,i,r,o=this;return s(this,(function(s){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(v.connectionCanceled)),n=new tt,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout((function(){o._loginTimer=void 0,o._rejectConnectionRequest(v.loginTimeout)}),null===(t=this.sdkState.websocket)||void 0===t?void 0:t.responseTimeout),i=this._sessionManager.session,e&&(i.authToken=e,i.sessionKey=void 0),r=this._url(),i.sessionKey||i.authToken?this._websocketClient.connect(r,JSON.stringify(i.hasSession?{auth:i.sessionKey}:{token:i.authToken})):this._websocketClient.connect(r,JSON.stringify({}))),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(cs.asError(v.connectionRenew))},n.prototype.disconnect=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,[4,this.disconnect()];case 1:return e.sent(),[4,this._sessionManager.clear()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)},n}(te),Os=function(e){function n(t){var n=t.appId,i=t.userId,r=t.includeUIKitConfig,s=void 0!==r&&r,o=t.localCacheEnabled,a=void 0===o||o,c=t.expiringSession,u=void 0===c||c,l=e.call(this)||this;return l.path="".concat(ue,"/").concat(i,"/authentication"),l.method=oe.POST,l.params=re({expiring_session:!!u,include_logi:!0,include_extra_data:String(As),uikit_config:s,use_local_cache:a,app_id:n}),l.requireAuth=!1,l}return t(n,e),n}(Ue),ks=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.logi=new cs(t,"LOGI",n),i}return t(n,e),n}(Pe);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(Ss||(Ss={}));var Ds,Rs,Ls=[Ve,Os],xs=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,a=t.useFetchCompat,c=void 0!==a&&a,u=this;this._currentConnectionStateType=Ar.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new kr(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:c}),this._session=n,this._logger=s,this._dispatcher=r,this._dispatcher.on((function(e){var t,n,i;if(e instanceof Lr){var r=e.stateType;switch(u._currentConnectionStateType=r,r){case Ar.CONNECTED:u._resolveLazyCallQueue();break;case Ar.INITIALIZED:case Ar.INTERNAL_DISCONNECTED:case Ar.EXTERNAL_DISCONNECTED:case Ar.LOGOUT:u._rejectLazyCallQueue((null===(i=u._session)||void 0===i?void 0:i.hasSession)?v.connectionClosed:v.connectionRequired)}}else if(e instanceof xr)u._session.hasChatServicePermission||u._resolveLazyCallQueue(Ss.API);else if(e instanceof Ur||e instanceof Pr)u._rejectLazyCallQueue(v.connectionClosed);else if(e instanceof Be){var s=e.request,a=e.deferred,c=e.error;try{for(var l=o(Ls),h=l.next();!h.done;h=l.next()){if(s instanceof h.value)return void a.reject(c)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}u._lazyCallQueue.push({command:s,deferred:a})}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===Ar.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Ar.CONNECTING||this._currentConnectionStateType===Ar.RECONNECTING||this._session.isRefreshing},enumerable:!1,configurable:!0}),e.prototype._classifyLazyCallQueueByScope=function(e){var t,n=[],i=[];switch(e){case Ss.ALL:t=null;break;case Ss.WEBSOCKET:t=He;break;case Ss.API:t=Ue}var r=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(r=!0),r?i.push(e):n.push(e)})),[n,i]},e.prototype._resolveLazyCallQueue=function(e){var t=this;void 0===e&&(e=Ss.ALL);var n=a(this._classifyLazyCallQueueByScope(e),2),i=n[0],o=n[1];this._lazyCallQueue=o,i.forEach((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:t=e.command,n=e.deferred,(i=e.timeout)&&clearTimeout(i),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.send(t)];case 2:return r=s.sent(),n.resolve(r),[3,4];case 3:return o=s.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}))},e.prototype._rejectLazyCallQueue=function(e,t){var n=this;void 0===t&&(t=Ss.ALL);var i=a(this._classifyLazyCallQueueByScope(t),2),o=i[0],c=i[1];this._lazyCallQueue=c,o.forEach((function(t){return r(n,void 0,void 0,(function(){var n,i;return s(this,(function(r){return n=t.deferred,i=t.timeout,clearTimeout(i),n.reject(e),[2]}))}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(r){switch(r.label){case 0:return e instanceof He?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:case 7:return[2,r.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new tt,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),v.connectionRequired;case 3:case 9:return[3,11];case 4:return e instanceof Ue?this._session.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,10];case 6:return e.hasSessionKey?(this._logger.debug("send api request with tmp session key",e),[4,this.commandRouter.send(e)]):[3,8];case 8:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new tt,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=v.connectionRequired,this._logger.debug("fail api request",n),n;case 10:throw v.invalidCommand;case 11:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),e instanceof He||e instanceof Ue?[4,this.commandRouter.send(e)]:[3,2];case 1:return[2,t.sent()];case 2:throw v.invalidCommand}}))}))},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(v.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}(),Us="sendbird@devicetokens",Ps=function(){function e(e){var t=e.type,n=e.token,i=e.device_os,r=e.device_manufacturer,s=e.system_push_enabled;this.type=t,this.token=n,this.deviceOS=i,this.deviceManufacturer=r,this.systemPushEnabled=s}return e.payloadify=function(e){return re(se({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))},e}(),Ms=new WeakMap,Fs=function(e){function n(t){var n=t._iid,i=t.session,r=t.cacheContext,s=t.sdkState,o=t.dispatcher,a=t.requestQueue,c=t.logger,u=t.pushNotificationAckManager,l=e.call(this)||this;return l._currentConnectionStateType=Ar.INITIALIZED,l._isRefreshingAuthToken=!1,l.currentUser=null,l.session=i,l._iid=n,l._cacheContext=r,l._sdkState=s,l._dispatcher=o,l._requestQueue=a,l._logger=c,l._pushNotificationAckManager=u,l._deviceTokens=[],l._dispatcher.on((function(e){var t,n,i;if(e instanceof Lr){var r=e.stateType;l._currentConnectionStateType=r}else if(e instanceof Fe&&l.handler&&!l.isSessionKeyRefreshing){if(l._currentConnectionStateType===Ar.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?l.close():((null===(n=e.error)||void 0===n?void 0:n.isSessionTokenExpiredError)&&l.refreshAuthToken().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(l._logger.debug("session expired"),l.handler.onSessionExpired&&l.handler.onSessionExpired(),l.refreshSessionKey().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e}))))}})),l}return t(n,e),Object.defineProperty(n.prototype,"ekey",{get:function(){return Ms.get(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokens",{get:function(){return this._deviceTokens},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokenLastDeletedAt",{get:function(){return this._deviceTokenLastDeletedAt},enumerable:!1,configurable:!0}),n.prototype.indexOfDeviceToken=function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))},n.prototype.hasDeviceToken=function(e,t){return this.indexOfDeviceToken(e,t)>=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return new ze({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=s.sent(),i=n.as(je),r=i.newKey,o=i.error)throw o;return this.session.sessionKey=null!=r?r:this.session.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(i){switch(i.label){case 0:return t=new Ve({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),[4,gs((function(e){return r(n,void 0,void 0,(function(){var n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=s.sent(),i=n.as(Ge),r=i.key,o=i.services,this.session.sessionKey=r,this.session.services=o,[3,3];case 2:if(a=s.sent(),!this._isSessionRelatedError(a))throw a;return e(a),[3,3];case 3:return[2]}}))}))}),3)];case 1:return i.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:if(this._currentConnectionStateType!==Ar.CONNECTED)return[3,8];r.label=1;case 1:return r.trys.push([1,3,,8]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return r.sent(),this.complete(),[2];case 3:n=r.sent(),r.label=4;case 4:return r.trys.push([4,6,,7]),[4,this._handleSessionRefreshError(n,t)];case 5:return r.sent(),[2];case 6:return r.sent(),[3,7];case 7:return[3,8];case 8:return r.trys.push([8,10,,12]),[4,this._refreshSessionKeyByApi(e)];case 9:return r.sent(),this.complete(),[3,12];case 10:return i=r.sent(),[4,this._handleSessionRefreshError(i,t)];case 11:return r.sent(),[3,12];case 12:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e,t=this,n=new tt;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var i=null,o=function(){i&&(clearTimeout(i),i=null)},a=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},c=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};i=setTimeout((function(){return c()}),1e3*this._sdkState.sessionTokenRefreshTimeout),ls((function(){return r(t,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(a,c),[2]}))}))}))}else n.resolve(null);return n.promise},n.prototype._handleSessionRefreshError=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return e instanceof v&&(e.isSessionTokenExpiredError||e.code===u.APPLICATION_NOT_FOUND)?(this.session.authToken=void 0,t?[4,this._receiveNewAuthToken()]:[3,6]):[3,6];case 1:return(n=i.sent())?(this.session.authToken=n,[4,this._refreshSessionKey(this.session.authToken,!1)]):[3,3];case 2:return i.sent(),[3,5];case 3:return[4,this.clear()];case 4:i.sent(),i.label=5;case 5:return[2];case 6:throw e}}))}))},n.prototype._isSessionRelatedError=function(e){return e instanceof v&&(e.isSessionExpiredError||e.isSessionInvalidatedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this.session.isRefreshing},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isSessionExpiring",{get:function(){return!!this.handler},enumerable:!1,configurable:!0}),n.prototype.authenticate=function(e,t){var n;return r(this,void 0,void 0,(function(){var i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.session.authToken=t,i=new Os({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!t||this.isSessionExpiring}),[4,this._requestQueue.commandRouter.send(i)];case 1:return r=s.sent(),(o=r.as(ks).logi).error?[3,4]:this.session.hasChatServicePermission?[3,3]:[4,o.applyTo(this._iid)];case 2:s.sent(),s.label=3;case 3:return[3,5];case 4:throw o.error;case 5:return[2]}}))}))},n.prototype.login=function(e){var t;return r(this,void 0,void 0,(function(){var n,i,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return n=e.key,i=e.ekey,r=e.services,o=e.userProfile,a=e.deviceTokenLastDeletedAt,c=void 0===a?0:a,this.session.sessionKey=n,this.session.services=r,Ms.set(this,i),this._deviceTokenCacheEnabled=null===(t=null==o?void 0:o.appInfo)||void 0===t?void 0:t.deviceTokenCache,u=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,u.get(Us)]:[3,5];case 1:return!(l=s.sent())||l.lastDeletedAt0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])},e.prototype._isDuplicateStat=function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t},e.prototype._save=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=c(c([],a(this.queue),!1),a(this.flushWaitQueue),!1),[4,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((function(e){return Ye.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})];case 1:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save(),[2]}))}))},e}(),Gs=function(e){function n(t){var n,i,r,s,o=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:o,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,i=n.getFullYear(),r=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0"),"".concat(i).concat(r).concat(s)),"_").concat(o),l}return t(n,e),n}(Ye),js=function(e){function n(t){var n=t.deviceId,i=t.statLogs,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(we),r.params={device_id:n,log_entries:i.map((function(e){return Ye.payloadify(e)}))},r}return t(n,e),n}(Ue),Ks=function(e){function n(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(n,e),Object.defineProperty(n.prototype,"_isSendable",{get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),n.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,e.prototype.init.call(this,t+".daily")];case 1:return n.sent(),this.queue=this.logInfo.statLogs.map((function(e){return new Ye({type:e.stat_type,ts:e.ts,data:e.data})})),[2]}}))}))},n.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),t.localCacheStat?(this.enabledState=t.enabledStat?Ds.ENABLED:Ds.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=Ds.DISABLED,[4,this.clear()];case 2:s.sent(),s.label=3;case 3:return this.isEnabled&&this._isSendable?[4,this._getUploadStats()]:[3,9];case 4:n=s.sent(),i=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),r=0,s.label=5;case 5:return r0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new js({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Vs,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=Ds.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ds.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},n}(zs),Bs=function(e){function i(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(i,e),i.prototype._isSendable=function(e){if(void 0===e&&(e=!1),this.queue.length0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new js({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Vs,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=Ds.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ds.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},i}(zs),Qs=function(e){function n(t){var n=t.deviceId,i=t.statLogs,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(Se),r.params={device_id:n,log_entries:i.map((function(e){return Ye.payloadify(e)}))},r}return t(n,e),n}(Ue),Ws=function(e){function i(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(i,e),Object.defineProperty(i.prototype,"_isSendable",{get:function(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),i.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,e.prototype.init.call(this,t+".realtime")];case 1:return i.sent(),this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Ye({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}})),[2]}}))}))},i.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.statConfig=e,this._mergeQueue(),t.notificationStat?(this.enabledState=t.enabledStat?Ds.ENABLED:Ds.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=Ds.DISABLED,[4,this.clear()];case 2:i.sent(),i.label=3;case 3:return this.isEnabled&&this._isSendable?(n=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),[4,ps(n)]):[3,6];case 4:return i.sent(),[4,this._flush(this.queue)];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},i.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.enabledState===Ds.DISABLED?[2,!0]:(t=this.enabledState===Ds.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,this._isDuplicateStat(e)?[2,!0]:(t.push(e),this.enabledState===Ds.PENDING?[3,2]:[4,this._save()]));case 1:n.sent(),n.label=2;case 2:return this.isEnabled?(this._mergeQueue(),this.isEnabled&&this._isSendable?[4,this._flush(t)]:[3,4]):[3,4];case 3:return[2,n.sent()];case 4:return[2,!0]}}))}))},i.prototype._flush=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r;return s(this,(function(s){switch(s.label){case 0:if(t=!0,!(e.length>0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Qs({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Vs,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=Ds.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ds.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},i}(zs),Zs=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,i=e.dispatcher,r=e.logger;this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=$(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=i,this.logger=r,this._dailyStatCollector=new Ks({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Bs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new Ws({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}return e.prototype._migration=function(){return r(this,void 0,void 0,(function(){var e,t,i,r;return s(this,(function(s){switch(s.label){case 0:return[4,this.cacheContext.preference.get(this.key)];case 1:return(e=s.sent())?(t=[],e.statLogs.forEach((function(e){e.stat_type===xe.FEATURE_LOCALCACHE&&t.push(new Ye({type:e.stat_type,ts:e.ts,data:e.data}))})),[4,this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((function(e){return Ye.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})]):[3,6];case 2:return s.sent(),i=[],e.statLogs.forEach((function(e){e.stat_type!==xe.FEATURE_LOCALCACHE&&e.stat_type!==xe.NOTIFICATION&&(e.stat_type===xe.FEATURE_LOCALCACHE_EVENT&&(e.data=n({message_init_policy:"",starting_point:0},e.data)),i.push(new Ye({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:i.map((function(e){return Ye.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 3:return s.sent(),r=[],e.statLogs.forEach((function(e){var t;e.stat_type===xe.NOTIFICATION&&(e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),r.push(new Ye({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:r.map((function(e){return Ye.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 4:return s.sent(),[4,this.cacheContext.preference.remove(this.key)];case 5:s.sent(),s.label=6;case 6:return[2]}}))}))},e.prototype.init=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.key=e,[4,this._migration()];case 1:return n.sent(),[4,this._dailyStatCollector.init(this.key)];case 2:return n.sent(),[4,this._defaultStatCollector.init(this.key)];case 3:return n.sent(),[4,this._notificationStatCollector.init(this.key)];case 4:return n.sent(),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){return e instanceof Ke?(t=e.statLog,this.put(t)):e instanceof as&&(n=e.request,i=e.features,r=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=n,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._notificationStatCollector.setConfig(null!==(a=this._statConfig.realTime)&&void 0!==a?a:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:r.ingestion})),[2]}))}))}))),[2]}}))}))},e.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=!0,e instanceof Gs?this._collectFeatureLocalCacheStat?[4,this._dailyStatCollector.put(e)]:[3,2]:[3,3];case 1:t=n.sent(),n.label=2;case 2:return[3,13];case 3:switch(e.type){case xe.API_RESULT:case xe.WEBSOCKET_CONNECT:return[3,4];case xe.FEATURE_LOCALCACHE:case xe.FEATURE_LOCALCACHE_EVENT:return[3,7];case xe.NOTIFICATION:return[3,10]}return[3,13];case 4:return this._collectRequestStat?[4,this._defaultStatCollector.put(e)]:[3,6];case 5:t=n.sent(),n.label=6;case 6:return[3,13];case 7:return this._collectFeatureLocalCacheStat?[4,this._defaultStatCollector.put(e)]:[3,9];case 8:t=n.sent(),n.label=9;case 9:return[3,13];case 10:return this._collectionNotificationStat?[4,this._notificationStatCollector.put(e)]:[3,12];case 11:t=n.sent(),n.label=12;case 12:return[3,13];case 13:return t?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Ds.COLLECT_ONLY,this._defaultStatCollector.enabledState=Ds.COLLECT_ONLY,this._notificationStatCollector.enabledState=Ds.COLLECT_ONLY,this.logger.debug(v.statLogUploadLimitExceededError))),[2]}}))}))},e.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)},e}(),Ys=function(){function e(e){var t=e.limit,n=void 0===t?5:t;this.workersByKey={},this.limit=n}return e.prototype.run=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.workersByKey[e]||(this.workersByKey[e]=[]),this.workersByKey[e].length0})).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},i.payloadify=function(t){return re(se(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 go.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})))},i.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[i];r>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=r)}})),i.req_id&&i.voted_option_ids&&(this.votedPollOptionIds=i.voted_option_ids),"number"==typeof i.voter_count&&(this.voterCount=i.voter_count),!0},i.prototype.serialize=function(){return es(this)},i}(Br),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,i,r){var s=e.call(this,t,r)||this;return s.channelUrl=n,s.channelType=i,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(q,this.channelType)},n}(bo),yo=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},wo=function(e){function n(t){var n=t.title,i=t.optionTexts,r=t.data,s=t.allowUserSuggestion,o=t.allowMultipleVotes,a=t.closeAt,c=e.call(this)||this;return c.method=oe.POST,c.path=be,c.params={title:n,options:i,data:r,allow_user_suggestion:s,allow_multiple_votes:o,close_at:a},c}return t(n,e),n}(Ue),So=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new vo(t,n),i}return t(n,e),n}(Pe),To=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=e.call(this)||this;return s.method=oe.GET,s.path="".concat(be,"/").concat(encodeURIComponent(r)),s.params={channel_url:n,channel_type:i},s}return t(n,e),n}(Ue),No=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new vo(t,n),i}return t(n,e),n}(Pe),Co=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s)),o.params={channel_url:n,channel_type:i},o}return t(n,e),n}(Ue),Ao=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.pollOption=new go(t,n),i}return t(n,e),n}(Pe),Io=function(e){function n(t){var n=t.channelType,i=t.channelUrl,r=t.timestamp,s=t.token,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(Oe(n),"/").concat(encodeURIComponent(i),"/polls/changelogs"),o.params=re({change_ts:r,token:s}),o}return t(n,e),n}(Ue),Oo=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.updatedPolls=n.updated.map((function(e){return function(e,t){return new vo(e,t)}(t,e)})),i.deletedPollIds=n.deleted.map((function(e){return e})),i.hasMore=n.has_more,i.nextToken=n.next,i}return t(n,e),n}(Pe),ko={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Do=function(e){return w("string",e.title)&&(t=e.optionTexts,N("string",t)&&t.every((function(e){return""!==e.trim()})))&&Eo(e.data)&&w("boolean",e.allowUserSuggestion,!0)&&w("boolean",e.allowMultipleVotes,!0)&&w("number",e.closeAt,!0);var t},Ro={channelUrl:"",channelType:q.BASE,pollId:0,pollOptionId:0},Lo=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)&&e.pollId>0&&w("number",e.pollOptionId)&&e.pollOptionId>0},xo={channelUrl:"",channelType:q.BASE,pollId:0},Uo=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)},Po={},Mo=function(){function e(e,t){var n=t.sdkState,i=t.dispatcher,r=t.sessionManager,s=t.requestQueue,o=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=r,this._requestQueue=s,this._dispatcher=i,this._logger=o,Po[e]=this}return e.of=function(e){return Po[e]},e.prototype.buildPollFromSerializedData=function(e){var t=ts(e);return new vo(this._iid,vo.payloadify(t))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return ns(Uo(e)).throw(v.invalidParameters),t=new To(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(No).poll]}}))}))},e.prototype.create=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return ns(Do(e)).throw(v.invalidParameters),t=new wo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(So).poll]}}))}))},e.prototype.getOption=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return ns(Lo(e)).throw(v.invalidParameters),t=new Co(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(Ao).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,i){return void 0===i&&(i=Xs.SYNC_POLL_CHANGELOGS),r(this,void 0,void 0,(function(){var r,o,a,c,u,l,h;return s(this,(function(s){switch(s.label){case 0:return r=new Io(se({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(r)];case 1:return o=s.sent(),a=o.as(Oo),c=a.updatedPolls,u=a.deletedPollIds,l=a.hasMore,h=a.nextToken,c.length>0&&this._dispatcher.dispatch(new lo({polls:c,source:i})),[2,{updatedPolls:c,deletedPollIds:u,hasMore:l,token:h}]}}))}))},e}(),Fo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.token,s=t.limit,o=e.call(this)||this;return o.method=oe.GET,o.path=be,o.params={channel_url:n,channel_type:i,token:r,limit:s},o}return t(n,e),n}(Ue),qo=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).polls=(null!==(i=n.polls)&&void 0!==i?i:[]).map((function(e){return new vo(t,e)})),r.token=n.next,r}return t(n,e),n}(Pe),Ho=function(e){function i(t,n){return e.call(this,t,n.channelUrl,n.channelType,n)||this}return t(i,e),i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=eo.of(this._iid).requestQueue,t=new Fo(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(qo),o=r.polls,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(mo),Vo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=t.token,a=t.limit,c=e.call(this)||this;return c.method=oe.GET,c.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s),"/voters"),c.params={channel_url:n,channel_type:i,token:o,limit:a},c}return t(n,e),n}(Ue),zo=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).voters=(null!==(i=n.voters)&&void 0!==i?i:[]).map((function(e){return new rs(t,e)})),r.token=n.next,r}return t(n,e),n}(Pe),Go=function(e){function i(t,n){var i=e.call(this,t,n.channelUrl,n.channelType,n)||this;return i.pollId=n.pollId,i.pollOptionId=n.pollOptionId,i}return t(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&w("number",this.pollId)&&w("number",this.pollOptionId)},i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=eo.of(this._iid).requestQueue,t=new Vo(n(n({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(zo),o=r.voters,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(mo);export{_ as $,oe as A,hs as B,q as C,Lr as D,te as E,Ar as F,ls as G,Or as H,ss as I,os as J,Fr as K,F as L,Fe as M,$e as N,g as O,f as P,N as Q,P as R,R as S,d as T,rs as U,eo as V,qe as W,S as X,Ze as Y,Hs as Z,r as _,w as a,Z as a$,p as a0,Kr as a1,Xs as a2,M as a3,E as a4,Rr as a5,Mr as a6,H as a7,u as a8,qr as a9,ot as aA,mo as aB,ke as aC,Ee as aD,Re as aE,j as aF,Eo as aG,be as aH,yo as aI,jr as aJ,I as aK,it as aL,_o as aM,Mo as aN,bo as aO,L as aP,i as aQ,ao as aR,co as aS,ho as aT,lo as aU,uo as aV,oo as aW,Ce as aX,X as aY,pe as aZ,to as a_,Dr as aa,$r as ab,Qe as ac,We as ad,le as ae,Br as af,y as ag,z as ah,es as ai,K as aj,He as ak,Oe as al,Ie as am,so as an,W as ao,A as ap,G as aq,vo as ar,Y as as,Q as at,De as au,nt as av,ps as aw,tt as ax,B as ay,he as az,s as b,ko as b0,Do as b1,xo as b2,Uo as b3,Ro as b4,Lo as b5,go as b6,no as b7,ie as b8,Ye as b9,xe as ba,Gs as bb,me as bc,io as bd,V as be,k as bf,de as bg,C as bh,rt as bi,fo as bj,ro as bk,gs as bl,po as bm,fe as bn,_e as bo,Te as bp,Ne as bq,Ve as br,Be as bs,t as c,ce as d,re as e,Ue as f,n as g,Pe as h,O as i,ve as j,ge as k,ye as l,Ae as m,$ as n,Xe as o,c as p,a as q,Tr as r,v as s,o as t,se as u,l as v,ns as w,Ho as x,Go as y,ts as z}; +var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[i++],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 i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function c(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r0&&b.indexOf(e)>=0},I=function(e){return e>0&&m.indexOf(e)>=0},O=function(e,t){if(void 0===t&&(t=!1),t&&D(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},k=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(),i=c([],a(t),!1).sort(),r=0;r=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}(),L={encrypt:function(e){return e},decrypt:function(e){return e}},x=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return r(this,void 0,void 0,(function(){return s(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),r(this,void 0,void 0,(function(){var i,r,a,c,u,l,h,d,_,f;return s(this,(function(s){switch(s.label){case 0:return this._version=t,this._keysAddress=e,i="".concat(e,".metadata.version"),[4,this._store.get(i)];case 1:return r=s.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=s.sent())&&void 0!==n?n:[],!r||r.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(i,64),o?(this._clearOrder=s,this._customClearOrderComparator=o):this._clearOrder=E.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=c}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===E.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableAutoResend",{get:function(){return this._enableAutoResend},enumerable:!1,configurable:!0}),e}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(P||(P={}));var q,H,V,z,G,j,K,B,Q,W,Z,Y,X,J=function(){function e(){this.isRefreshing=!1}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasChatServicePermission",{get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(P.CHAT))},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]},e}(),$=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)}))},ee=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=$()}return e.prototype._register=function(e,t,n){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: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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))},e}(),te=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new ee({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new ee({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,i,r=this._container[e];if(r){var s=[];try{for(var a=o(r.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=r.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&s.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}s.forEach((function(e){return r.delete(e)}))}},e}(),ne=function(){function e(){this._dispatcher=new te}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}(),ie=function(){},re=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},se=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){for(var t=c([],a(e),!1),n=0;n0&&(i.extension_sdk_info=r.map((function(e){var t=e.product,n=e.platform,i=e.version;return"".concat(t,"/").concat(n,"/").concat(i)})).join(",")),Object.keys(i).forEach((function(e){return delete c[e]})),Object.keys(c).length>0&&(i=n(n({},i),c))}return Object.entries(i).map((function(e){var t=a(e,2),n=t[0],i=t[1];return"".concat(n,"=").concat(i)})).join("&")},e.userAgentWithExtension=function(e){var t=Xe()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",i=e.sb_uikit?"u".concat(e.sb_uikit):"",r=e["device-os-platform"]?"o".concat(e["device-os-platform"]):Je()?"omobile-web":"oweb";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(i,"/").concat(r)},e}(),tt=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=function(e){n(e)}}))},nt=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t.requestId,n}return t(n,e),n}(ie),it=function(e){function n(t){var n=e.call(this)||this;return n.method=oe.DELETE,n.path="".concat(Oe(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),t.messageToken&&(n.params=re({mesg_token:t.messageToken})),n}return t(n,e),n}(Ue);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Pe);var rt=function(e){function n(t,n,i){var r,s=this;return(s=e.call(this,t,"DELM",i)||this).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(r=i.sender_id)&&void 0!==r?r:void 0,s}return t(n,e),n}(qe),st=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=n,this._sdkState=i,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof Me&&c.cancel(e.requestId)})),this._logger=s,this._shouldImportFetchCompat=a}return e.prototype._createHeader=function(e,t){var i=this._sdkState,r=i.appId,s=i.appVersion,o=i.sendbirdRuntimeEnvironment,a=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(r).concat(s?",".concat(s):""),"SB-User-Agent":et.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":et.sendbirdSdkUserAgentWithExtension(o)});return t||(a["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(a["Session-Key"]=this._session.sessionKey),a["App-Id"]=r,this._session&&this._session.authToken&&(a["Access-Token"]=this._session.authToken),a},e.prototype._statLogApiResult=function(e,t,n){e.path.includes("/sdk/statistics")||this._dispatcher.dispatch(new Ke(new Ye({type:xe.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._isBodyRequired=function(e){var t=e.method;return t!==oe.GET&&(t!==oe.DELETE||e instanceof it)},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a,c,l,h,d,_,f,p,E,g,b,m,y,w;return s(this,(function(s){switch(s.label){case 0:t=e.path,n=e.method,i=e.uploadProgressHandler,r=this._isBodyRequired(e),o=this._sdkState.api,a="".concat(o.host).concat(t).concat(r?"":e.query),c=r?e.payload:null,l=this._createHeader(e,c instanceof FormData?c:void 0),h=new AbortController,d=h.signal,this._abortControl.set(e.requestId,h),_=Date.now(),s.label=1;case 1:return s.trys.push([1,13,,14]),i?[4,import("./__bundle-3f550679.js")]:[3,6];case 2:f=s.sent().xmlHttpRequest,s.label=3;case 3:return s.trys.push([3,5,,6]),[4,f(this._iid,{requestId:e.requestId,method:e.method,url:a,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i})];case 4:return p=s.sent(),this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,p];case 5:if(!((E=s.sent())instanceof v&&E.code===u.XMLHTTPREQUEST_NOT_SUPPORTED))throw E;return this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),[3,6];case 6:return 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,8]:[4,import("./__bundle-7c3d40f4.js")];case 7:s.sent(),s.label=8;case 8:return"function"==typeof fetch?[3,10]:[4,import("./__bundle-46d64517.js")];case 9:s.sent(),s.label=10;case 10:return[4,fetch(a,{method:n,body:c,headers:l,signal:d})];case 11:return[4,(g=s.sent()).json()];case 12:if(b=s.sent(),g.ok||g.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,_),[2,new Pe(this._iid,b)];if(b){if((m=new v(b)).isSessionExpiredError){if(this._dispatcher.dispatch(new Fe({reason:m.code,message:m.message})),!(e instanceof Ve))return y=new tt,this._dispatcher.dispatch(new Be({request:e,deferred:y,error:m})),[2,y.promise];throw m}throw m.isSessionInvalidatedError?(this._dispatcher.dispatch(new Fe({reason:m.code,message:m.message})),m):m}throw v.requestFailed;case 13:throw w=s.sent(),this._statLogApiResult(e,_,w),w instanceof v?(this._logger.debug("fail api request",w),w):"AbortError"===(null==w?void 0:w.name)?v.requestCanceled:(this._logger.debug("fail api request",w),v.networkError);case 14:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new nt({requestId:e}))},e.prototype.cancelAll=function(){var e,t;try{for(var n=o(this._abortControl.values()),i=n.next();!i.done;i=n.next()){i.value.abort()}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear(),this._dispatcher.dispatch(new nt({}))},e}(),ot=function(){};function at(e){let t=e.length;for(;--t>=0;)e[t]=0}const ct=256,ut=286,lt=30,ht=15,dt=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]),_t=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]),ft=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),pt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Et=new Array(576);at(Et);const gt=new Array(60);at(gt);const vt=new Array(512);at(vt);const bt=new Array(256);at(bt);const mt=new Array(29);at(mt);const yt=new Array(lt);function wt(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}let St,Tt,Nt;function Ct(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}at(yt);const At=e=>e<256?vt[e]:vt[256+(e>>>7)],It=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Ot=(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<{Ot(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},Rt=(e,t,n)=>{const i=new Array(16);let r,s,o=0;for(r=1;r<=ht;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=Dt(i[t]++,t))}},Lt=e=>{let t;for(t=0;t{e.bi_valid>8?It(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ut=(e,t,n,i)=>{const r=2*t,s=2*n;return e[r]{const i=e.heap[n];let r=n<<1;for(;r<=e.heap_len&&(r{let i,r,s,o,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,r=e.pending_buf[e.sym_buf+a++],0===i?kt(e,r,t):(s=bt[r],kt(e,s+ct+1,t),o=dt[s],0!==o&&(r-=mt[s],Ot(e,r,o)),i--,s=At(i),kt(e,s,n),o=_t[s],0!==o&&(i-=yt[s],Ot(e,i,o)))}while(a{const n=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)Pt(e,n,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Pt(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,n[2*c]=n[2*o]+n[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,n[2*o+1]=n[2*a+1]=c,e.heap[1]=c++,Pt(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,i=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=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<=ht;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>i||(e.bl_count[d]++,_=0,l>=a&&(_=o[l-a]),f=n[2*l],e.opt_len+=f*(d+_),s&&(e.static_len+=f*(r[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>i||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),Rt(n,u,e.bl_count)},qt=(e,t,n)=>{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=t[2*(i+1)+1],++a{let i,r,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),i=0;i<=n;i++)if(r=o,o=t[2*(i+1)+1],!(++a{Ot(e,0+(i?1:0),3),xt(e),It(e,n),It(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Gt=(e,t,n,i)=>{let r,s,o=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(qt(e,e.dyn_ltree,e.l_desc.max_code),qt(e,e.dyn_dtree,e.d_desc.max_code),Ft(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*pt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&-1!==t?zt(e,t,n,i):4===e.strategy||s===r?(Ot(e,2+(i?1:0),3),Mt(e,Et,gt)):(Ot(e,4+(i?1:0),3),((e,t,n,i)=>{let r;for(Ot(e,t-257,5),Ot(e,n-1,5),Ot(e,i-4,4),r=0;r{Vt||((()=>{let e,t,n,i,r;const s=new Array(16);for(n=0,i=0;i<28;i++)for(mt[i]=n,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++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(bt[n]+ct+1)]++,e.dyn_dtree[2*At(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Ot(e,2,3),kt(e,256,Et),(e=>{16===e.bi_valid?(It(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 Kt=(e,t,n,i)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+t[i++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Bt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Qt=(e,t,n,i)=>{const r=Bt,s=i+n;e^=-1;for(let n=i;n>>8^r[255&(e^t[n])];return~e},Wt={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"},Zt={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:Yt,_tr_stored_block:Xt,_tr_flush_block:Jt,_tr_tally:$t,_tr_align:en}=jt,{Z_NO_FLUSH:tn,Z_PARTIAL_FLUSH:nn,Z_FULL_FLUSH:rn,Z_FINISH:sn,Z_BLOCK:on,Z_OK:an,Z_STREAM_END:cn,Z_STREAM_ERROR:un,Z_DATA_ERROR:ln,Z_BUF_ERROR:hn,Z_DEFAULT_COMPRESSION:dn,Z_FILTERED:_n,Z_HUFFMAN_ONLY:fn,Z_RLE:pn,Z_FIXED:En,Z_DEFAULT_STRATEGY:gn,Z_UNKNOWN:vn,Z_DEFLATED:bn}=Zt,mn=258,yn=262,wn=42,Sn=113,Tn=666,Nn=(e,t)=>(e.msg=Wt[t],t),Cn=e=>2*e-(e>4?9:0),An=e=>{let t=e.length;for(;--t>=0;)e[t]=0},In=e=>{let t,n,i,r=e.w_size;t=e.hash_size,i=t;do{n=e.head[--i],e.head[i]=n>=r?n-r:0}while(--t);t=r,i=t;do{n=e.prev[--i],e.prev[i]=n>=r?n-r:0}while(--t)};let On=(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)=>{Jt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,kn(e.strm)},Rn=(e,t)=>{e.pending_buf[e.pending++]=t},Ln=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},xn=(e,t,n,i)=>{let r=e.avail_in;return r>i&&(r=i),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),n),1===e.state.wrap?e.adler=Kt(e.adler,t,r,n):2===e.state.wrap&&(e.adler=Qt(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)},Un=(e,t)=>{let n,i,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-yn?e.strstart-(e.w_size-yn):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+mn;let _=u[s+o-1],f=u[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+o]===f&&u[n+o-1]===_&&u[n]===u[s]&&u[++n]===u[s+1]){s+=2,n++;do{}while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&so){if(e.match_start=t,o=i,i>=a)break;_=u[s+o-1],f=u[s+o]}}}while((t=h[t&l])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead},Pn=e=>{const t=e.w_size;let n,i,r;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-yn)&&(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),In(e),i+=t),0===e.strm.avail_in)break;if(n=xn(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=n,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=On(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=On(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,i,r,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(n=65535,r=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(n=i+e.strm.avail_in),n>r&&(n=r),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,kn(e.strm),i&&(i>n&&(i=n),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,n-=i),n&&(xn(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===o);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_waterr&&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++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(xn(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,s=r>e.w_size?e.w_size:r,i=e.strstart-e.block_start,(i>=s||(i||t===sn)&&t!==tn&&0===e.strm.avail_in&&i<=r)&&(n=i>r?r:i,o=t===sn&&0===e.strm.avail_in&&n===i?1:0,Xt(e,e.block_start,n,o),e.block_start+=n,kn(e.strm)),o?3:1)},Fn=(e,t)=>{let n,i;for(;;){if(e.lookahead=3&&(e.ins_h=On(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-yn&&(e.match_length=Un(e,n)),e.match_length>=3)if(i=$t(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=On(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=On(e,e.ins_h,e.window[e.strstart+1]);else i=$t(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(Dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===sn?(Dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Dn(e,!1),0===e.strm.avail_out)?1:2},qn=(e,t)=>{let n,i,r;for(;;){if(e.lookahead=3&&(e.ins_h=On(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){r=e.strstart+e.lookahead-3,i=$t(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=On(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++,i&&(Dn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=$t(e,0,e.window[e.strstart-1]),i&&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&&(i=$t(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===sn?(Dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Dn(e,!1),0===e.strm.avail_out)?1:2};function Hn(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}const Vn=[new Hn(0,0,0,0,Mn),new Hn(4,4,8,4,Fn),new Hn(4,5,16,8,Fn),new Hn(4,6,32,32,Fn),new Hn(4,4,16,16,qn),new Hn(8,16,32,32,qn),new Hn(8,16,128,128,qn),new Hn(8,32,128,256,qn),new Hn(32,128,258,1024,qn),new Hn(32,258,258,4096,qn)];function zn(){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=bn,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),An(this.dyn_ltree),An(this.dyn_dtree),An(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),An(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),An(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 Gn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==wn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Sn&&t.status!==Tn?1:0},jn=e=>{if(Gn(e))return Nn(e,un);e.total_in=e.total_out=0,e.data_type=vn;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?wn:Sn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Yt(t),an},Kn=e=>{const t=jn(e);var n;return t===an&&((n=e.state).window_size=2*n.w_size,An(n.head),n.max_lazy_match=Vn[n.level].max_lazy,n.good_match=Vn[n.level].good_length,n.nice_match=Vn[n.level].nice_length,n.max_chain_length=Vn[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},Bn=(e,t,n,i,r,s)=>{if(!e)return un;let o=1;if(t===dn&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>9||n!==bn||i<8||i>15||t<0||t>9||s<0||s>En||8===i&&1!==o)return Nn(e,un);8===i&&(i=9);const a=new zn;return e.state=a,a.strm=e,a.status=wn,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<Bn(e,t,bn,15,8,gn),deflateInit2:Bn,deflateReset:Kn,deflateResetKeep:jn,deflateSetHeader:(e,t)=>Gn(e)||2!==e.state.wrap?un:(e.state.gzhead=t,an),deflate:(e,t)=>{if(Gn(e)||t>on||t<0)return e?Nn(e,un):un;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Tn&&t!==sn)return Nn(e,0===e.avail_out?hn:un);const i=n.last_flush;if(n.last_flush=t,0!==n.pending){if(kn(e),0===e.avail_out)return n.last_flush=-1,an}else if(0===e.avail_in&&Cn(t)<=Cn(i)&&t!==sn)return Nn(e,hn);if(n.status===Tn&&0!==e.avail_in)return Nn(e,hn);if(n.status===wn&&0===n.wrap&&(n.status=Sn),n.status===wn){let t=bn+(n.w_bits-8<<4)<<8,i=-1;if(i=n.strategy>=fn||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=i<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Ln(n,t),0!==n.strstart&&(Ln(n,e.adler>>>16),Ln(n,65535&e.adler)),e.adler=1,n.status=Sn,kn(e),0!==n.pending)return n.last_flush=-1,an}if(57===n.status)if(e.adler=0,Rn(n,31),Rn(n,139),Rn(n,8),n.gzhead)Rn(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)),Rn(n,255&n.gzhead.time),Rn(n,n.gzhead.time>>8&255),Rn(n,n.gzhead.time>>16&255),Rn(n,n.gzhead.time>>24&255),Rn(n,9===n.level?2:n.strategy>=fn||n.level<2?4:0),Rn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Rn(n,255&n.gzhead.extra.length),Rn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Qt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Rn(n,0),Rn(n,0),Rn(n,0),Rn(n,0),Rn(n,0),Rn(n,9===n.level?2:n.strategy>=fn||n.level<2?4:0),Rn(n,3),n.status=Sn,kn(e),0!==n.pending)return n.last_flush=-1,an;if(69===n.status){if(n.gzhead.extra){let t=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=r,kn(e),0!==n.pending)return n.last_flush=-1,an;t=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>t&&(e.adler=Qt(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,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,an;i=0}t=n.gzindexi&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i)),kn(e),0!==n.pending)return n.last_flush=-1,an;i=0}t=n.gzindexi&&(e.adler=Qt(e.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(kn(e),0!==n.pending))return n.last_flush=-1,an;Rn(n,255&e.adler),Rn(n,e.adler>>8&255),e.adler=0}if(n.status=Sn,kn(e),0!==n.pending)return n.last_flush=-1,an}if(0!==e.avail_in||0!==n.lookahead||t!==tn&&n.status!==Tn){let i=0===n.level?Mn(n,t):n.strategy===fn?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Pn(e),0===e.lookahead)){if(t===tn)return 1;break}if(e.match_length=0,n=$t(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===sn?(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===pn?((e,t)=>{let n,i,r,s;const o=e.window;for(;;){if(e.lookahead<=mn){if(Pn(e),e.lookahead<=mn&&t===tn)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=e.strstart+mn;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=$t(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=$t(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===sn?(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):Vn[n.level].func(n,t);if(3!==i&&4!==i||(n.status=Tn),1===i||3===i)return 0===e.avail_out&&(n.last_flush=-1),an;if(2===i&&(t===nn?en(n):t!==on&&(Xt(n,0,0,!1),t===rn&&(An(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),kn(e),0===e.avail_out))return n.last_flush=-1,an}return t!==sn?an:n.wrap<=0?cn:(2===n.wrap?(Rn(n,255&e.adler),Rn(n,e.adler>>8&255),Rn(n,e.adler>>16&255),Rn(n,e.adler>>24&255),Rn(n,255&e.total_in),Rn(n,e.total_in>>8&255),Rn(n,e.total_in>>16&255),Rn(n,e.total_in>>24&255)):(Ln(n,e.adler>>>16),Ln(n,65535&e.adler)),kn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?an:cn)},deflateEnd:e=>{if(Gn(e))return un;const t=e.state.status;return e.state=null,t===Sn?Nn(e,ln):an},deflateSetDictionary:(e,t)=>{let n=t.length;if(Gn(e))return un;const i=e.state,r=i.wrap;if(2===r||1===r&&i.status!==wn||i.lookahead)return un;if(1===r&&(e.adler=Kt(e.adler,t,n,0)),i.wrap=0,n>=i.w_size){0===r&&(An(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(n-i.w_size,n),0),t=e,n=i.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Pn(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=On(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,Pn(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=o,e.input=a,e.avail_in=s,i.wrap=r,an},deflateInfo:"pako deflate (from Nodeca project)"};const Wn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Zn=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)Wn(n,t)&&(e[t]=n[t])}}return e},Yn=e=>{let t=0;for(let n=0,i=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Jn[254]=Jn[254]=1;var $n=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,i,r,s,o=e.length,a=0;for(r=0;r>>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},ei=(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let i,r;const s=new Array(2*n);for(r=0,i=0;i4)s[r++]=65533,i+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&i1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Xn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let i=0;i{(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+Jn[e[n]]>t?n:t};var ni=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 ii=Object.prototype.toString,{Z_NO_FLUSH:ri,Z_SYNC_FLUSH:si,Z_FULL_FLUSH:oi,Z_FINISH:ai,Z_OK:ci,Z_STREAM_END:ui,Z_DEFAULT_COMPRESSION:li,Z_DEFAULT_STRATEGY:hi,Z_DEFLATED:di}=Zt;function _i(e){this.options=Zn({level:li,method:di,chunkSize:16384,windowBits:15,memLevel:8,strategy:hi},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 ni,this.strm.avail_out=0;let n=Qn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ci)throw new Error(Wt[n]);if(t.header&&Qn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?$n(t.dictionary):"[object ArrayBuffer]"===ii.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Qn.deflateSetDictionary(this.strm,e),n!==ci)throw new Error(Wt[n]);this._dict_set=!0}}function fi(e,t){const n=new _i(t);if(n.push(e,!0),n.err)throw n.msg||Wt[n.err];return n.result}_i.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?ai:ri,"string"==typeof e?n.input=$n(e):"[object ArrayBuffer]"===ii.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(i),n.next_out=0,n.avail_out=i),(s===si||s===oi)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(r=Qn.deflate(n,s),r===ui)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),r=Qn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===ci;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},_i.prototype.onData=function(e){this.chunks.push(e)},_i.prototype.onEnd=function(e){e===ci&&(this.result=Yn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var pi={Deflate:_i,deflate:fi,deflateRaw:function(e,t){return(t=t||{}).raw=!0,fi(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,fi(e,t)},constants:Zt};const Ei=16209;var gi=function(e,t){let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T,N;const C=e.state;n=e.next_in,T=e.input,i=n+(e.avail_in-5),r=e.next_out,N=e.output,s=r-(t-e.avail_out),o=r+(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,E=(1<>>24,d>>>=b,_-=b,b=v>>>16&255,0===b)N[r++]=65535&v;else{if(!(16&b)){if(64&b){if(32&b){C.mode=16191;break e}e.msg="invalid literal/length code",C.mode=Ei;break e}v=f[(65535&v)+(d&(1<>>=b,_-=b),_<15&&(d+=T[n++]<<_,_+=8,d+=T[n++]<<_,_+=8),v=p[d&g];;){if(b=v>>>24,d>>>=b,_-=b,b=v>>>16&255,16&b){if(y=65535&v,b&=15,_a){e.msg="invalid distance too far back",C.mode=Ei;break e}if(d>>>=b,_-=b,b=r-s,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=Ei;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)N[r++]=S[w++],N[r++]=S[w++],N[r++]=S[w++],m-=3;m&&(N[r++]=S[w++],m>1&&(N[r++]=S[w++]))}else{w=r-y;do{N[r++]=N[w++],N[r++]=N[w++],N[r++]=N[w++],m-=3}while(m>2);m&&(N[r++]=N[w++],m>1&&(N[r++]=N[w++]))}break}if(64&b){e.msg="invalid distance code",C.mode=Ei;break e}v=p[(65535&v)+(d&(1<>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=r,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,E=0,g=0,v=0,b=0,m=0,y=0,w=0,S=0,T=0,N=null;const C=new Uint16Array(16),A=new Uint16Array(16);let I,O,k,D=null;for(p=0;p<=vi;p++)C[p]=0;for(E=0;E=1&&0===C[v];v--);if(b>v&&(b=v),0===v)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(A[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){I=p-y,o[E]+1=f?(O=D[o[E]-f],k=N[o[E]-f]):(O=96,k=0),u=1<>y)+l]=I<<24|O<<16|k}while(0!==l);for(u=1<>=1;if(0!==u?(T&=u-1,T+=u):T=0,E++,0==--C[p]){if(p===v)break;p=t[n+o[E]]}if(p>b&&(T&d)!==h){for(0===y&&(y=b),_+=g,m=p-y,w=1<852||2===e&&S>592)return 1;h=T&d,r[h]=b<<24|m<<16|_-s}}return 0!==T&&(r[_+T]=p-y<<24|64<<16),a.bits=b,0};const{Z_FINISH:Ti,Z_BLOCK:Ni,Z_TREES:Ci,Z_OK:Ai,Z_STREAM_END:Ii,Z_NEED_DICT:Oi,Z_STREAM_ERROR:ki,Z_DATA_ERROR:Di,Z_MEM_ERROR:Ri,Z_BUF_ERROR:Li,Z_DEFLATED:xi}=Zt,Ui=16180,Pi=16190,Mi=16191,Fi=16192,qi=16194,Hi=16199,Vi=16200,zi=16206,Gi=16209,ji=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ki(){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 Bi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Qi=e=>{if(Bi(e))return ki;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=Ui,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,Ai},Wi=e=>{if(Bi(e))return ki;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Qi(e)},Zi=(e,t)=>{let n;if(Bi(e))return ki;const i=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ki:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,Wi(e))},Yi=(e,t)=>{if(!e)return ki;const n=new Ki;e.state=n,n.strm=e,n.window=null,n.mode=Ui;const i=Zi(e,t);return i!==Ai&&(e.state=null),i};let Xi,Ji,$i=!0;const er=e=>{if($i){Xi=new Int32Array(512),Ji=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(Si(1,e.lens,0,288,Xi,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Si(2,e.lens,0,32,Ji,0,e.work,{bits:5}),$i=!1}e.lencode=Xi,e.lenbits=9,e.distcode=Ji,e.distbits=5},tr=(e,t,n,i)=>{let r;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):(r=s.wsize-s.wnext,r>i&&(r=i),s.window.set(t.subarray(n-i,n-i+r),s.wnext),(i-=r)?(s.window.set(t.subarray(n-i,n),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whaveYi(e,15),inflateInit2:Yi,inflate:(e,t)=>{let n,i,r,s,o,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,S,T=0;const N=new Uint8Array(4);let C,A;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Bi(e)||!e.output||!e.input&&0!==e.avail_in)return ki;n=e.state,n.mode===Mi&&(n.mode=Fi),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=Ai;e:for(;;)switch(n.mode){case Ui:if(0===n.wrap){n.mode=Fi;break}for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>>8&255,n.check=Qt(n.check,N,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=Gi;break}if((15&u)!==xi){e.msg="unknown compression method",n.mode=Gi;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=Gi;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Qt(n.check,N,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>8&255,N[2]=u>>>16&255,N[3]=u>>>24&255,n.check=Qt(n.check,N,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=i[s++]<>8),512&n.flags&&4&n.wrap&&(N[0]=255&u,N[1]=u>>>8&255,n.check=Qt(n.check,N,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+=i[s++]<>>8&255,n.check=Qt(n.check,N,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(i.subarray(s,s+_),w)),512&n.flags&&4&n.wrap&&(n.check=Qt(n.check,i,_,s)),a-=_,s+=_,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=i[s+_++],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=Mi;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=i[s++]<>>=7&l,l-=7&l,n.mode=zi;break}for(;l<3;){if(0===a)break e;a--,u+=i[s++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(er(n),n.mode=Hi,t===Ci){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Gi}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=i[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Gi;break}if(n.length=65535&u,u=0,l=0,n.mode=qi,t===Ci)break e;case qi:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;r.set(i.subarray(s,s+_),o),a-=_,s+=_,c-=_,o+=_,n.length-=_;break}n.mode=Mi;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=i[s++]<>>=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=Gi;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,C={bits:n.lenbits},S=Si(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=Gi;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=E,l-=E,n.lens[n.have++]=v;else{if(16===v){for(A=E+2;l>>=E,l-=E,0===n.have){e.msg="invalid bit length repeat",n.mode=Gi;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===v){for(A=E+3;l>>=E,l-=E,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(A=E+7;l>>=E,l-=E,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Gi;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===Gi)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Gi;break}if(n.lenbits=9,C={bits:n.lenbits},S=Si(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=Gi;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=Si(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=Gi;break}if(n.mode=Hi,t===Ci)break e;case Hi:n.mode=Vi;case Vi:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,n.hold=u,n.bits=l,gi(e,d),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===Mi&&(n.back=-1);break}for(n.back=0;T=n.lencode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,n.length=v,0===g){n.mode=16205;break}if(32&g){n.back=-1,n.mode=Mi;break}if(64&g){e.msg="invalid literal/length code",n.mode=Gi;break}n.extra=15&g,n.mode=16201;case 16201:if(n.extra){for(A=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;T=n.distcode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=i[s++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=i[s++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,64&g){e.msg="invalid distance code",n.mode=Gi;break}n.offset=v,n.extra=15&g,n.mode=16203;case 16203:if(n.extra){for(A=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=Gi;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=Gi;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=r,f=o-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{r[o++]=p[f++]}while(--_);0===n.length&&(n.mode=Vi);break;case 16205:if(0===c)break e;r[o++]=n.length,c--,n.mode=Vi;break;case zi:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=i[s++]<{if(Bi(e))return ki;let t=e.state;return t.window&&(t.window=null),e.state=null,Ai},inflateGetHeader:(e,t)=>{if(Bi(e))return ki;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Ai):ki},inflateSetDictionary:(e,t)=>{const n=t.length;let i,r,s;return Bi(e)?ki:(i=e.state,0!==i.wrap&&i.mode!==Pi?ki:i.mode===Pi&&(r=1,r=Kt(r,t,n,0),r!==i.check)?Di:(s=tr(e,t,n,n),s?(i.mode=16210,Ri):(i.havedict=1,Ai)))},inflateInfo:"pako inflate (from Nodeca project)"};var ir=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 rr=Object.prototype.toString,{Z_NO_FLUSH:sr,Z_FINISH:or,Z_OK:ar,Z_STREAM_END:cr,Z_NEED_DICT:ur,Z_STREAM_ERROR:lr,Z_DATA_ERROR:hr,Z_MEM_ERROR:dr}=Zt;function _r(e){this.options=Zn({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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ni,this.strm.avail_out=0;let n=nr.inflateInit2(this.strm,t.windowBits);if(n!==ar)throw new Error(Wt[n]);if(this.header=new ir,nr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=$n(t.dictionary):"[object ArrayBuffer]"===rr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=nr.inflateSetDictionary(this.strm,t.dictionary),n!==ar)))throw new Error(Wt[n])}function fr(e,t){const n=new _r(t);if(n.push(e),n.err)throw n.msg||Wt[n.err];return n.result}_r.prototype.push=function(e,t){const n=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?or:sr,"[object ArrayBuffer]"===rr.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(i),n.next_out=0,n.avail_out=i),s=nr.inflate(n,o),s===ur&&r&&(s=nr.inflateSetDictionary(n,r),s===ar?s=nr.inflate(n,o):s===hr&&(s=ur));n.avail_in>0&&s===cr&&n.state.wrap>0&&0!==e[n.next_in];)nr.inflateReset(n),s=nr.inflate(n,o);switch(s){case lr:case hr:case ur:case dr:return this.onEnd(s),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||s===cr))if("string"===this.options.to){let e=ti(n.output,n.next_out),t=n.next_out-e,r=ei(n.output,e);n.next_out=t,n.avail_out=i-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==ar||0!==a){if(s===cr)return s=nr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},_r.prototype.onData=function(e){this.chunks.push(e)},_r.prototype.onEnd=function(e){e===ar&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Yn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var pr={Inflate:_r,inflate:fr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,fr(e,t)},ungzip:fr,constants:Zt};const{Deflate:Er,deflate:gr,deflateRaw:vr,gzip:br}=pi,{Inflate:mr,inflate:yr,inflateRaw:wr,ungzip:Sr}=pr;var Tr,Nr={Deflate:Er,deflate:gr,deflateRaw:vr,gzip:br,Inflate:mr,inflate:yr,inflateRaw:wr,ungzip:Sr,constants:Zt},Cr=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){return t=Nr.ungzip(e),[2,String.fromCharCode.apply(null,t)]}))}))};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(Tr||(Tr={}));var Ar,Ir=function(e){function n(t,n){var i=n.sdkState,r=n.dispatcher,s=n.logger,o=e.call(this)||this;return o.lastActive=0,o._iid=t,o._sdkState=i,o._dispatcher=r,o._logger=s,o}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===Tr.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return Tr.CONNECTING;case 1:return Tr.OPEN}return Tr.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ws",{get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._handleMessage=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 i=new Fe(n.payload);i.expiresIn>=0&&t._dispatcher.dispatch(i)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e,t){return void 0===t&&(t=""),r(this,void 0,void 0,(function(){var n=this;return s(this,(function(i){return this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return r(n,void 0,void 0,(function(){var t,n,i,o,a,c,u,l=this;return s(this,(function(h){switch(h.label){case 0:return(null===(u=this._sdkState.websocket)||void 0===u?void 0:u.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return r(l,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,Cr(t.result)];case 1:return e=i.sent(),this._handleMessage(e),[3,3];case 2:return n=i.sent(),this.error(n),[3,3];case 3:return[2]}}))}))},[3,12]):[3,1]:[3,13];case 1:if(!(e.data instanceof ArrayBuffer))return[3,6];h.label=2;case 2:return h.trys.push([2,4,,5]),[4,Cr(new Uint8Array(e.data))];case 3:return a=h.sent(),this._handleMessage(a),[3,5];case 4:return n=h.sent(),this.error(n),[3,5];case 5:return[3,12];case 6:if(!("undefined"!=typeof Buffer&&e.data instanceof Buffer))return[3,11];h.label=7;case 7:return h.trys.push([7,9,,10]),i=e.data,o=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),[4,Cr(o)];case 8:return a=h.sent(),this._handleMessage(a),[3,10];case 9:return c=h.sent(),this.error(c),[3,10];case 10:return[3,12];case 11:"string"==typeof e.data&&this._handleMessage(e.data),h.label=12;case 12:return[3,14];case 13:this._handleMessage(e.data),h.label=14;case 14:return[2]}}))}))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",v.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now(),[2]}))}))},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws?(e._ws.onopen=ot,e._ws.onmessage=ot,e._ws.onerror=ot,e.connectionState!==Tr.CLOSED?(e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=void 0):t()):t()}))},n.prototype.send=function(e){if(!this._ws)throw v.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}(te),Or=function(e){function n(t){var n=t.all,i=t.feed,r=t.custom_types,s=t.ts,o=e.call(this)||this;return o.all=n,o.feed=i,o.customTypes=r,o.ts=s,o}return t(n,e),n}(ie),kr=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,o=t.useFetchCompat,a=void 0!==o&&o,c=this;this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=r,this._logger=s,this.apiClient=new st(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:a}),this.websocketClient=new Ir(e,{sdkState:i,dispatcher:r,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new Or(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 v({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(v.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r=this;return s(this,(function(s){if(!this._sdkState.websocket)throw v.connectionRequired;if(t=new tt,e.ackRequired){i=function(i,s){r._ackStateMap.has(e.requestId)&&(r._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),i?(r._logger.debug("fail websocket request",e.requestId,i),t.reject(i)):(r._logger.debug("receive websocket ack",e.requestId,e),r._logger.debug("receive websocket ack",s),t.resolve(s)))};try{n=setTimeout((function(){return i(v.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return i(void 0,e)},reject:function(e){return i(e)}}),this.websocketClient.send(e)}catch(e){i(e)}}else try{this.websocketClient.send(e),t.resolve()}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return e instanceof Ue?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof He?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw v.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"}(Ar||(Ar={}));var Dr,Rr,Lr=function(e){function n(t){var n=t.stateType,i=e.call(this)||this;return i.stateType=n,i}return t(n,e),n}(ie),xr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Ur=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Pr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(ie),Mr=function(){function e(e){var t,n,i,r;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(n=e.feed_channels)&&void 0!==n?n:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(r=e.settings_updated_at)&&void 0!==r?r:0}return e.payloadify=function(e){return re(se({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))},e}(),Fr=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},qr=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 re(se({last_updated_at:e.lastUpdatedAt}))},e}(),Hr=function(){function e(e){var t;this.token=null!==(t=e.template_list_token)&&void 0!==t?t:""}return e.payloadify=function(e){return re(se({template_list_token:e.token}))},e}(),Vr=function(){function e(e){void 0===e&&(e={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}),this.minStatCount=e.min_stat_count,this.minInterval=1e3*e.min_interval,this.maxStatCountPerRequest=e.max_stat_count_per_request,this.lowerThreshold=e.lower_threshold,this.requestDelayRange=1e3*e.request_delay_range}return e.payloadify=function(e){return re(se({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))},e}(),zr=function(){function e(e){void 0===e&&(e={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}),this.default=new Vr(e.default),this.realTime=new Vr(e.realtime)}return e.payloadify=function(e){return re(se({default:Vr.payloadify(e.default),realtime:Vr.payloadify(e.realTime)}))},e}(),Gr=1048576,jr=5;!function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Dr||(Dr={})),function(e){e[e.NONE=0]="NONE",e[e.INCLUDE_REPLY=1]="INCLUDE_REPLY",e[e.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",e[e.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"}(Rr||(Rr={}));var Kr=function(){function e(e){var t,n,i,r,s,o,a;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Gr: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!==(i=e.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(r=e.allow_sdk_log_ingestion)||void 0===r||r,this.unreadCountThreadingPolicy=null!==(s=e.unread_cnt_threading_policy)&&void 0!==s?s:Dr.NONE,this.lastMessageThreadingPolicy=null!==(o=e.last_msg_threading_policy)&&void 0!==o?o:Rr.NONE,this.uikitConfigInfo=new qr(null!==(a=e.uikit_config)&&void 0!==a?a:{}),this.notificationInfo=e.notifications?new Mr(e.notifications):null,this.messageTemplateInfo=e.message_template?new Hr(e.message_template):null,this.statConfigInfo=e.log_publish_config?new zr(e.log_publish_config):new zr}return e.payloadify=function(e){return re(se({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Gr,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?qr.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Mr.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Hr.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?zr.payloadify(e.statConfigInfo):null}))},e}(),Br=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return{}},e}(),Qr=function(e){function n(t){var n=t.userId,i=t.metadata,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(ce,"/").concat(n,"/metadata"),r.params={metadata:i},r}return t(n,e),n}(Ue),Wr=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metaData=n,i}return t(n,e),n}(Pe),Zr=function(e){function n(t){var n=t.userId,i=t.metadata,r=t.upsert,s=e.call(this)||this;return s.method=oe.PUT,s.path="".concat(ce,"/").concat(n,"/metadata"),s.params={metadata:i,upsert:r},s}return t(n,e),n}(Ue),Yr=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.metadata=n,i}return t(n,e),n}(Pe),Xr=function(e){function n(t){var n=t.userId,i=t.metadataKey,r=e.call(this)||this;return r.method=oe.DELETE,r.path="".concat(ce,"/").concat(n,"/metadata/").concat(i),r}return t(n,e),n}(Ue);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Pe);var Jr=function(e){function n(t){var n=t.userId,i=e.call(this)||this;return i.method=oe.DELETE,i.path="".concat(ce,"/").concat(n,"/metadata"),i}return t(n,e),n}(Ue);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Pe);var $r,es=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},ts=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ns=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"}($r||($r={}));var is,rs=function(e){function i(t,n){var i,r,s,o,u,l,h,d,_,f,p,E,g=this;return(g=e.call(this,t)||this).userId=null!==(r=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==r?r:"",g.nickname=null!==(o=null!==(s=n.nickname)&&void 0!==s?s:n.name)&&void 0!==o?o:"",g.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",g.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,g.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},g.connectionStatus=$r.NON_AVAILABLE,S($r,n.is_online)?g.connectionStatus=n.is_online:w("boolean",n.is_online)&&(g.connectionStatus=n.is_online?$r.ONLINE:$r.OFFLINE),g.isActive=null===(_=n.is_active)||void 0===_||_,g.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,g.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,g.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,g.friendName=null!==(E=n.friend_name)&&void 0!==E?E:null,g}return t(i,e),i.payloadify=function(t){return re(se(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(i.prototype,"profileUrl",{get:function(){var e=eo.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),i.prototype.serialize=function(){return es(this)},i.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)}))},i.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(i){t?delete n.metaData[i]:n.metaData[i]=e[i]}))},i.prototype.createMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return ns(this._isValidMetaData(e)).throw(v.invalidParameters),t=eo.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Qr({userId:n.userId,metadata:e}),[4,i.send(r)];case 1:return o=s.sent(),a=o.as(Wr).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},i.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n,i,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:return ns(this._isValidMetaData(e)).throw(v.invalidParameters),n=eo.of(this._iid),i=n.sdkState,r=n.requestQueue,o=new Zr({userId:i.userId,metadata:e,upsert:t}),[4,r.send(o)];case 1:return a=s.sent(),c=a.as(Yr).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},i.prototype.deleteMetaData=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return ns(w("string",e)).throw(v.invalidParameters),t=eo.of(this._iid),n=t.sdkState,i=t.requestQueue,r=new Xr({userId:n.userId,metadataKey:e}),[4,i.send(r)];case 1:return s.sent(),this._applyMetaData(((o={})[e]=!0,o),!0),[2,this.metaData]}}))}))},i.prototype.deleteAllMetaData=function(){return r(this,void 0,void 0,(function(){var e,t,n,i;return s(this,(function(r){switch(r.label){case 0:return e=eo.of(this._iid),t=e.sdkState,n=e.requestQueue,i=new Jr({userId:t.userId}),[4,n.send(i)];case 1:return r.sent(),this.metaData={},[2]}}))}))},i}(Br),ss=function(e){function n(t){var n=t.userProfile,i=e.call(this)||this;return i.userProfile=n,i}return t(n,e),n}(ie),os=function(){function e(e,t){var n,i,r,s,o,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new Kr(t),this.user=new rs(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=t.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(r=t.pong_timeout)&&void 0!==r?r:5e3,this.reconnectInterval=null!==(o=null===(s=t.reconnect)||void 0===s?void 0:s.interval)&&void 0!==o?o: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 re(se(n(n(n({},rs.payloadify(e.user)),Kr.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,i=eo.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:function(i){return i>0?1e3*Math.min(e*Math.pow(n,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 ss({userProfile:this}))},e}(),as=function(e){function i(t){var i=t.request,r=void 0===i||i,s=t.features,o=void 0===s?{}:s,a=t.options,c=void 0===a?{}:a,u=t.statConfigInfo,l=e.call(this)||this;return l.request=r,l.features=n({localCache:!0,notification:!0},o),l.options=n({ingestion:!0},c),l.statConfigInfo=u,l}return t(i,e),i}(ie),cs=function(e){function i(t,n,i){var r,s,o,a,c=this;return(c=e.call(this,t,n,i)||this).error=null,c.services=[],c.userProfile=new os(t,i),c.deviceTokenLastDeletedAt=null!==(r=i.device_token_last_deleted_at)&&void 0!==r?r:0,c.key=null!==(s=i.key)&&void 0!==s?s:"",c.ekey=null!==(o=i.ekey)&&void 0!==o?o:"",c.error=i.error?new v(i):null,c.services=null!==(a=i.services)&&void 0!==a?a:[],c}return t(i,e),i.asError=function(e){return new i("","LOGI",n({user_id:"",error:!0},e))},i.prototype.applyTo=function(e){return r(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(r){switch(r.label){case 0:return this.error?[3,4]:(t=eo.of(e))?(n=t.sessionManager,i=t.dispatcher,[4,n.login(this)]):[3,2];case 1:return r.sent(),this.userProfile.apply(),i.dispatch(new as({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),[3,3];case 2:throw v.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},i}(qe),us=function(){function e(){this.type=Ar.NONE,this.name="none"}return e.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,t.cause,r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e}(),ls=function(e){return r(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e()];case 1:return n.sent(),[3,3];case 2:if(!((t=n.sent())instanceof v))throw t;return t.throwOutside(),[3,3];case 3:return[2]}}))}))},hs=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e()];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},ds=function(e){function n(t){void 0===t&&(t={});var n,i=this;return(i=e.call(this)||this).type=Ar.LOGOUT,i.name="logout",i._wasPreviouslyConnected=null===(n=t.wasPreviouslyConnected)||void 0===n||n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(o){switch(o.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return o.sent(),[4,e.changeState(new Ts,t)];case 2:return o.sent(),this._wasPreviouslyConnected&&ls((function(){return r(i,void 0,void 0,(function(){return s(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(us),_s=function(e){function n(){var t=e.call(this)||this;return t.type=Ar.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new ys({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new vs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ds,t)];case 1:return n.sent(),[2]}}))}))},n}(us),fs=function(e){function n(t){var n=t.autoReconnect,i=e.call(this)||this;return i.type=Ar.INTERNAL_DISCONNECTED,i.name="internaldisconnected",i._autoReconnect=!1,i._autoReconnect=n,i}return t(n,e),n.prototype.run=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new vs,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new ys({authToken:t}),n)];case 2:return i.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new vs,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new _s,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ds,t)];case 1:return n.sent(),[2]}}))}))},n}(us),ps=function(e){return r(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},Es=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),gs=function(e,t,n){return void 0===n&&(n=new Es),r(void 0,void 0,void 0,(function(){var i,r,o,a,c,u;return s(this,(function(s){switch(s.label){case 0:i=0,r=null,o=function(e){return r=null!=e?e:new Error("Halted")},a=function(){i=0},s.label=1;case 1:if(!(-1===t||i=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Lr({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 r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return n.sent(),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.session.authToken=void 0,t.error.isSessionExpiredError||t.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Fe({reason:t.error.code,message:t.error.message})):this._logger.warn("login failed: ".concat(t.error)),this._rejectConnectionRequest(t.error),n.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(){var e,t=this.sdkState,n=t.appId,i=t.appVersion,r=t.userId,s=t.extensions,o=t.sendbirdRuntimeEnvironment,a=this.cacheContext.localCacheEnabled,c=this._sessionManager.session,u=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=s?s:{}).sb_uikit,d=et.userAgentWithExtension(s);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(n).concat(i?"&av=".concat(i):"").concat(c.hasSession?"":"&user_id=".concat(encodeURIComponent(r)),"&pmce=").concat(u?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent(et.sendbirdSdkUserAgentWithExtension(o)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(As))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(a?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")},n.prototype._statLogConnection=function(e){var t;this._dispatcher.dispatch(new Ke(new Ye({type:xe.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:this._connectedAt>0?this._connectedAt-this._connectingAt:Date.now()-this._connectingAt,logi_latency:this._logiReceivedAt>0?this._logiReceivedAt-this._connectingAt:void 0,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=""),r(this,void 0,void 0,(function(){var n,i,r,o=this;return s(this,(function(s){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(v.connectionCanceled)),n=new tt,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout((function(){o._loginTimer=void 0,o._rejectConnectionRequest(v.loginTimeout)}),null===(t=this.sdkState.websocket)||void 0===t?void 0:t.responseTimeout),i=this._sessionManager.session,e&&(i.authToken=e,i.sessionKey=void 0),r=this._url(),i.sessionKey||i.authToken?this._websocketClient.connect(r,JSON.stringify(i.hasSession?{auth:i.sessionKey}:{token:i.authToken})):this._websocketClient.connect(r,JSON.stringify({}))),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(cs.asError(v.connectionRenew))},n.prototype.disconnect=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,[4,this.disconnect()];case 1:return e.sent(),[4,this._sessionManager.clear()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)},n}(te),Os=function(e){function n(t){var n=t.appId,i=t.userId,r=t.includeUIKitConfig,s=void 0!==r&&r,o=t.localCacheEnabled,a=void 0===o||o,c=t.expiringSession,u=void 0===c||c,l=e.call(this)||this;return l.path="".concat(ue,"/").concat(i,"/authentication"),l.method=oe.POST,l.params=re({expiring_session:!!u,include_logi:!0,include_extra_data:String(As),uikit_config:s,use_local_cache:a,app_id:n}),l.requireAuth=!1,l}return t(n,e),n}(Ue),ks=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.logi=new cs(t,"LOGI",n),i}return t(n,e),n}(Pe);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(Ss||(Ss={}));var Ds,Rs,Ls=[Ve,Os],xs=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,s=t.logger,a=t.useFetchCompat,c=void 0!==a&&a,u=this;this._currentConnectionStateType=Ar.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new kr(e,{session:n,sdkState:i,dispatcher:r,logger:s,useFetchCompat:c}),this._session=n,this._logger=s,this._dispatcher=r,this._dispatcher.on((function(e){var t,n,i;if(e instanceof Lr){var r=e.stateType;switch(u._currentConnectionStateType=r,r){case Ar.CONNECTED:u._resolveLazyCallQueue();break;case Ar.INITIALIZED:case Ar.INTERNAL_DISCONNECTED:case Ar.EXTERNAL_DISCONNECTED:case Ar.LOGOUT:u._rejectLazyCallQueue((null===(i=u._session)||void 0===i?void 0:i.hasSession)?v.connectionClosed:v.connectionRequired)}}else if(e instanceof xr)u._session.hasChatServicePermission||u._resolveLazyCallQueue(Ss.API);else if(e instanceof Ur||e instanceof Pr)u._rejectLazyCallQueue(v.connectionClosed);else if(e instanceof Be){var s=e.request,a=e.deferred,c=e.error;try{for(var l=o(Ls),h=l.next();!h.done;h=l.next()){if(s instanceof h.value)return void a.reject(c)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}u._lazyCallQueue.push({command:s,deferred:a})}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===Ar.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Ar.CONNECTING||this._currentConnectionStateType===Ar.RECONNECTING||this._session.isRefreshing},enumerable:!1,configurable:!0}),e.prototype._classifyLazyCallQueueByScope=function(e){var t,n=[],i=[];switch(e){case Ss.ALL:t=null;break;case Ss.WEBSOCKET:t=He;break;case Ss.API:t=Ue}var r=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(r=!0),r?i.push(e):n.push(e)})),[n,i]},e.prototype._resolveLazyCallQueue=function(e){var t=this;void 0===e&&(e=Ss.ALL);var n=a(this._classifyLazyCallQueueByScope(e),2),i=n[0],o=n[1];this._lazyCallQueue=o,i.forEach((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:t=e.command,n=e.deferred,(i=e.timeout)&&clearTimeout(i),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.send(t)];case 2:return r=s.sent(),n.resolve(r),[3,4];case 3:return o=s.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}))},e.prototype._rejectLazyCallQueue=function(e,t){var n=this;void 0===t&&(t=Ss.ALL);var i=a(this._classifyLazyCallQueueByScope(t),2),o=i[0],c=i[1];this._lazyCallQueue=c,o.forEach((function(t){return r(n,void 0,void 0,(function(){var n,i;return s(this,(function(r){return n=t.deferred,i=t.timeout,clearTimeout(i),n.reject(e),[2]}))}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i=this;return s(this,(function(r){switch(r.label){case 0:return e instanceof He?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:case 7:return[2,r.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new tt,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),v.connectionRequired;case 3:case 9:return[3,11];case 4:return e instanceof Ue?this._session.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,10];case 6:return e.hasSessionKey?(this._logger.debug("send api request with tmp session key",e),[4,this.commandRouter.send(e)]):[3,8];case 8:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new tt,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=v.connectionRequired,this._logger.debug("fail api request",n),n;case 10:throw v.invalidCommand;case 11:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),e instanceof He||e instanceof Ue?[4,this.commandRouter.send(e)]:[3,2];case 1:return[2,t.sent()];case 2:throw v.invalidCommand}}))}))},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(v.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}(),Us="sendbird@devicetokens",Ps=function(){function e(e){var t=e.type,n=e.token,i=e.device_os,r=e.device_manufacturer,s=e.system_push_enabled;this.type=t,this.token=n,this.deviceOS=i,this.deviceManufacturer=r,this.systemPushEnabled=s}return e.payloadify=function(e){return re(se({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))},e}(),Ms=new WeakMap,Fs=function(e){function n(t){var n=t._iid,i=t.session,r=t.cacheContext,s=t.sdkState,o=t.dispatcher,a=t.requestQueue,c=t.logger,u=t.pushNotificationAckManager,l=e.call(this)||this;return l._currentConnectionStateType=Ar.INITIALIZED,l._isRefreshingAuthToken=!1,l.currentUser=null,l.session=i,l._iid=n,l._cacheContext=r,l._sdkState=s,l._dispatcher=o,l._requestQueue=a,l._logger=c,l._pushNotificationAckManager=u,l._deviceTokens=[],l._dispatcher.on((function(e){var t,n,i;if(e instanceof Lr){var r=e.stateType;l._currentConnectionStateType=r}else if(e instanceof Fe&&l.handler&&!l.isSessionKeyRefreshing){if(l._currentConnectionStateType===Ar.CONNECTING)return;(null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?l.close():((null===(n=e.error)||void 0===n?void 0:n.isSessionTokenExpiredError)&&l.refreshAuthToken().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e})),(null===(i=e.error)||void 0===i?void 0:i.isSessionKeyExpiredError)&&(l._logger.debug("session expired"),l.handler.onSessionExpired&&l.handler.onSessionExpired(),l.refreshSessionKey().catch((function(e){if(g(e)&&"foreground"===l._sdkState.appState)throw e}))))}})),l}return t(n,e),Object.defineProperty(n.prototype,"ekey",{get:function(){return Ms.get(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokens",{get:function(){return this._deviceTokens},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceTokenLastDeletedAt",{get:function(){return this._deviceTokenLastDeletedAt},enumerable:!1,configurable:!0}),n.prototype.indexOfDeviceToken=function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))},n.prototype.hasDeviceToken=function(e,t){return this.indexOfDeviceToken(e,t)>=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return new ze({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=s.sent(),i=n.as(je),r=i.newKey,o=i.error)throw o;return this.session.sessionKey=null!=r?r:this.session.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(i){switch(i.label){case 0:return t=new Ve({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),[4,gs((function(e){return r(n,void 0,void 0,(function(){var n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=s.sent(),i=n.as(Ge),r=i.key,o=i.services,this.session.sessionKey=r,this.session.services=o,[3,3];case 2:if(a=s.sent(),!this._isSessionRelatedError(a))throw a;return e(a),[3,3];case 3:return[2]}}))}))}),3)];case 1:return i.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:if(this._currentConnectionStateType!==Ar.CONNECTED)return[3,8];r.label=1;case 1:return r.trys.push([1,3,,8]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return r.sent(),this.complete(),[2];case 3:n=r.sent(),r.label=4;case 4:return r.trys.push([4,6,,7]),[4,this._handleSessionRefreshError(n,t)];case 5:return r.sent(),[2];case 6:return r.sent(),[3,7];case 7:return[3,8];case 8:return r.trys.push([8,10,,12]),[4,this._refreshSessionKeyByApi(e)];case 9:return r.sent(),this.complete(),[3,12];case 10:return i=r.sent(),[4,this._handleSessionRefreshError(i,t)];case 11:return r.sent(),[3,12];case 12:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e,t=this,n=new tt;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var i=null,o=function(){i&&(clearTimeout(i),i=null)},a=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},c=function(e){o(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};i=setTimeout((function(){return c()}),1e3*this._sdkState.sessionTokenRefreshTimeout),ls((function(){return r(t,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(a,c),[2]}))}))}))}else n.resolve(null);return n.promise},n.prototype._handleSessionRefreshError=function(e,t){return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return e instanceof v&&(e.isSessionTokenExpiredError||e.code===u.APPLICATION_NOT_FOUND)?(this.session.authToken=void 0,t?[4,this._receiveNewAuthToken()]:[3,6]):[3,6];case 1:return(n=i.sent())?(this.session.authToken=n,[4,this._refreshSessionKey(this.session.authToken,!1)]):[3,3];case 2:return i.sent(),[3,5];case 3:return[4,this.clear()];case 4:i.sent(),i.label=5;case 5:return[2];case 6:throw e}}))}))},n.prototype._isSessionRelatedError=function(e){return e instanceof v&&(e.isSessionExpiredError||e.isSessionInvalidatedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this.session.isRefreshing},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isSessionExpiring",{get:function(){return!!this.handler},enumerable:!1,configurable:!0}),n.prototype.authenticate=function(e,t){var n;return r(this,void 0,void 0,(function(){var i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.session.authToken=t,i=new Os({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:this.isSessionExpiring}),[4,this._requestQueue.commandRouter.send(i)];case 1:return r=s.sent(),(o=r.as(ks).logi).error?[3,4]:this.session.hasChatServicePermission?[3,3]:[4,o.applyTo(this._iid)];case 2:s.sent(),s.label=3;case 3:return[3,5];case 4:throw o.error;case 5:return[2]}}))}))},n.prototype.login=function(e){var t;return r(this,void 0,void 0,(function(){var n,i,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return n=e.key,i=e.ekey,r=e.services,o=e.userProfile,a=e.deviceTokenLastDeletedAt,c=void 0===a?0:a,this.session.sessionKey=n,this.session.services=r,Ms.set(this,i),this._deviceTokenCacheEnabled=null===(t=null==o?void 0:o.appInfo)||void 0===t?void 0:t.deviceTokenCache,u=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,u.get(Us)]:[3,5];case 1:return!(l=s.sent())||l.lastDeletedAt0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])},e.prototype._isDuplicateStat=function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t},e.prototype._save=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=c(c([],a(this.queue),!1),a(this.flushWaitQueue),!1),[4,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:e.map((function(e){return Ye.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})];case 1:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save(),[2]}))}))},e}(),Gs=function(e){function n(t){var n,i,r,s,o=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:o,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,i=n.getFullYear(),r=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0"),"".concat(i).concat(r).concat(s)),"_").concat(o),l}return t(n,e),n}(Ye),js=function(e){function n(t){var n=t.deviceId,i=t.statLogs,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(we),r.params={device_id:n,log_entries:i.map((function(e){return Ye.payloadify(e)}))},r}return t(n,e),n}(Ue),Ks=function(e){function n(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(n,e),Object.defineProperty(n.prototype,"_isSendable",{get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),n.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,e.prototype.init.call(this,t+".daily")];case 1:return n.sent(),this.queue=this.logInfo.statLogs.map((function(e){return new Ye({type:e.stat_type,ts:e.ts,data:e.data})})),[2]}}))}))},n.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),t.localCacheStat?(this.enabledState=t.enabledStat?Ds.ENABLED:Ds.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=Ds.DISABLED,[4,this.clear()];case 2:s.sent(),s.label=3;case 3:return this.isEnabled&&this._isSendable?[4,this._getUploadStats()]:[3,9];case 4:n=s.sent(),i=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),r=0,s.label=5;case 5:return r0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new js({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Vs,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=Ds.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ds.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},n}(zs),Bs=function(e){function i(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(i,e),i.prototype._isSendable=function(e){if(void 0===e&&(e=!1),this.queue.length0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new js({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Vs,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=Ds.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ds.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},i}(zs),Qs=function(e){function n(t){var n=t.deviceId,i=t.statLogs,r=e.call(this)||this;return r.method=oe.POST,r.path="".concat(Se),r.params={device_id:n,log_entries:i.map((function(e){return Ye.payloadify(e)}))},r}return t(n,e),n}(Ue),Ws=function(e){function i(t){var n=t.deviceId,i=t.cacheContext,r=t.requestQueue;return e.call(this,{deviceId:n,cacheContext:i,requestQueue:r})||this}return t(i,e),Object.defineProperty(i.prototype,"_isSendable",{get:function(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),i.prototype.init=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,e.prototype.init.call(this,t+".realtime")];case 1:return i.sent(),this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new Ye({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}})),[2]}}))}))},i.prototype.setConfig=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.statConfig=e,this._mergeQueue(),t.notificationStat?(this.enabledState=t.enabledStat?Ds.ENABLED:Ds.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=Ds.DISABLED,[4,this.clear()];case 2:i.sent(),i.label=3;case 3:return this.isEnabled&&this._isSendable?(n=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),[4,ps(n)]):[3,6];case 4:return i.sent(),[4,this._flush(this.queue)];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},i.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.enabledState===Ds.DISABLED?[2,!0]:(t=this.enabledState===Ds.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,this._isDuplicateStat(e)?[2,!0]:(t.push(e),this.enabledState===Ds.PENDING?[3,2]:[4,this._save()]));case 1:n.sent(),n.label=2;case 2:return this.isEnabled?(this._mergeQueue(),this.isEnabled&&this._isSendable?[4,this._flush(t)]:[3,4]):[3,4];case 3:return[2,n.sent()];case 4:return[2,!0]}}))}))},i.prototype._flush=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r;return s(this,(function(s){switch(s.label){case 0:if(t=!0,!(e.length>0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,s.label=1;case 1:return s.trys.push([1,4,8,9]),n=c([],a(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Qs({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(i)];case 2:return s.sent(),this.queue=c([],a(e),!1).slice(n.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Vs,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return s.sent(),[3,9];case 4:return(r=s.sent())instanceof v?r.code!==u.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return s.sent(),this.enabledState=Ds.DISABLED,[3,7];case 6:r.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ds.COLLECT_ONLY),s.label=7;case 7:return this.limit=this.limit+20,t=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,s.label=11;case 11:return[2,t]}}))}))},i}(zs),Zs=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,i=e.dispatcher,r=e.logger;this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=$(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=i,this.logger=r,this._dailyStatCollector=new Ks({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Bs({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new Ws({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}return e.prototype._migration=function(){return r(this,void 0,void 0,(function(){var e,t,i,r;return s(this,(function(s){switch(s.label){case 0:return[4,this.cacheContext.preference.get(this.key)];case 1:return(e=s.sent())?(t=[],e.statLogs.forEach((function(e){e.stat_type===xe.FEATURE_LOCALCACHE&&t.push(new Ye({type:e.stat_type,ts:e.ts,data:e.data}))})),[4,this.cacheContext.preference.set(this.key+".daily",{deviceId:e.deviceId,statLogs:t.map((function(e){return Ye.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})]):[3,6];case 2:return s.sent(),i=[],e.statLogs.forEach((function(e){e.stat_type!==xe.FEATURE_LOCALCACHE&&e.stat_type!==xe.NOTIFICATION&&(e.stat_type===xe.FEATURE_LOCALCACHE_EVENT&&(e.data=n({message_init_policy:"",starting_point:0},e.data)),i.push(new Ye({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".default",{deviceId:e.deviceId,statLogs:i.map((function(e){return Ye.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 3:return s.sent(),r=[],e.statLogs.forEach((function(e){var t;e.stat_type===xe.NOTIFICATION&&(e.data=re(n(n({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),r.push(new Ye({type:e.stat_type,ts:e.ts,data:e.data})))})),[4,this.cacheContext.preference.set(this.key+".realtime",{deviceId:e.deviceId,statLogs:r.map((function(e){return Ye.payloadify(e)})),generation:e.generation,lastFlushedAt:e.lastFlushedAt})];case 4:return s.sent(),[4,this.cacheContext.preference.remove(this.key)];case 5:s.sent(),s.label=6;case 6:return[2]}}))}))},e.prototype.init=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.key=e,[4,this._migration()];case 1:return n.sent(),[4,this._dailyStatCollector.init(this.key)];case 2:return n.sent(),[4,this._defaultStatCollector.init(this.key)];case 3:return n.sent(),[4,this._notificationStatCollector.init(this.key)];case 4:return n.sent(),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return r(t,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){return e instanceof Ke?(t=e.statLog,this.put(t)):e instanceof as&&(n=e.request,i=e.features,r=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=n,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:r.ingestion}),this._notificationStatCollector.setConfig(null!==(a=this._statConfig.realTime)&&void 0!==a?a:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:r.ingestion})),[2]}))}))}))),[2]}}))}))},e.prototype.put=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=!0,e instanceof Gs?this._collectFeatureLocalCacheStat?[4,this._dailyStatCollector.put(e)]:[3,2]:[3,3];case 1:t=n.sent(),n.label=2;case 2:return[3,13];case 3:switch(e.type){case xe.API_RESULT:case xe.WEBSOCKET_CONNECT:return[3,4];case xe.FEATURE_LOCALCACHE:case xe.FEATURE_LOCALCACHE_EVENT:return[3,7];case xe.NOTIFICATION:return[3,10]}return[3,13];case 4:return this._collectRequestStat?[4,this._defaultStatCollector.put(e)]:[3,6];case 5:t=n.sent(),n.label=6;case 6:return[3,13];case 7:return this._collectFeatureLocalCacheStat?[4,this._defaultStatCollector.put(e)]:[3,9];case 8:t=n.sent(),n.label=9;case 9:return[3,13];case 10:return this._collectionNotificationStat?[4,this._notificationStatCollector.put(e)]:[3,12];case 11:t=n.sent(),n.label=12;case 12:return[3,13];case 13:return t?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Ds.COLLECT_ONLY,this._defaultStatCollector.enabledState=Ds.COLLECT_ONLY,this._notificationStatCollector.enabledState=Ds.COLLECT_ONLY,this.logger.debug(v.statLogUploadLimitExceededError))),[2]}}))}))},e.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)},e}(),Ys=function(){function e(e){var t=e.limit,n=void 0===t?5:t;this.workersByKey={},this.limit=n}return e.prototype.run=function(e,t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return this.workersByKey[e]||(this.workersByKey[e]=[]),this.workersByKey[e].length0})).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},i.payloadify=function(t){return re(se(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 go.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})))},i.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[i];r>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=r)}})),i.req_id&&i.voted_option_ids&&(this.votedPollOptionIds=i.voted_option_ids),"number"==typeof i.voter_count&&(this.voterCount=i.voter_count),!0},i.prototype.serialize=function(){return es(this)},i}(Br),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,i,r){var s=e.call(this,t,r)||this;return s.channelUrl=n,s.channelType=i,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(q,this.channelType)},n}(bo),yo=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},wo=function(e){function n(t){var n=t.title,i=t.optionTexts,r=t.data,s=t.allowUserSuggestion,o=t.allowMultipleVotes,a=t.closeAt,c=e.call(this)||this;return c.method=oe.POST,c.path=be,c.params={title:n,options:i,data:r,allow_user_suggestion:s,allow_multiple_votes:o,close_at:a},c}return t(n,e),n}(Ue),So=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new vo(t,n),i}return t(n,e),n}(Pe),To=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=e.call(this)||this;return s.method=oe.GET,s.path="".concat(be,"/").concat(encodeURIComponent(r)),s.params={channel_url:n,channel_type:i},s}return t(n,e),n}(Ue),No=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.poll=new vo(t,n),i}return t(n,e),n}(Pe),Co=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s)),o.params={channel_url:n,channel_type:i},o}return t(n,e),n}(Ue),Ao=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.pollOption=new go(t,n),i}return t(n,e),n}(Pe),Io=function(e){function n(t){var n=t.channelType,i=t.channelUrl,r=t.timestamp,s=t.token,o=e.call(this)||this;return o.method=oe.GET,o.path="".concat(Oe(n),"/").concat(encodeURIComponent(i),"/polls/changelogs"),o.params=re({change_ts:r,token:s}),o}return t(n,e),n}(Ue),Oo=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.updatedPolls=n.updated.map((function(e){return function(e,t){return new vo(e,t)}(t,e)})),i.deletedPollIds=n.deleted.map((function(e){return e})),i.hasMore=n.has_more,i.nextToken=n.next,i}return t(n,e),n}(Pe),ko={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Do=function(e){return w("string",e.title)&&(t=e.optionTexts,N("string",t)&&t.every((function(e){return""!==e.trim()})))&&Eo(e.data)&&w("boolean",e.allowUserSuggestion,!0)&&w("boolean",e.allowMultipleVotes,!0)&&w("number",e.closeAt,!0);var t},Ro={channelUrl:"",channelType:q.BASE,pollId:0,pollOptionId:0},Lo=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)&&e.pollId>0&&w("number",e.pollOptionId)&&e.pollOptionId>0},xo={channelUrl:"",channelType:q.BASE,pollId:0},Uo=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&S(q,e.channelType)&&w("number",e.pollId)},Po={},Mo=function(){function e(e,t){var n=t.sdkState,i=t.dispatcher,r=t.sessionManager,s=t.requestQueue,o=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=r,this._requestQueue=s,this._dispatcher=i,this._logger=o,Po[e]=this}return e.of=function(e){return Po[e]},e.prototype.buildPollFromSerializedData=function(e){var t=ts(e);return new vo(this._iid,vo.payloadify(t))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return ns(Uo(e)).throw(v.invalidParameters),t=new To(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(No).poll]}}))}))},e.prototype.create=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return ns(Do(e)).throw(v.invalidParameters),t=new wo(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(So).poll]}}))}))},e.prototype.getOption=function(e){return r(this,void 0,void 0,(function(){var t,i;return s(this,(function(r){switch(r.label){case 0:return ns(Lo(e)).throw(v.invalidParameters),t=new Co(n({},e)),[4,this._requestQueue.send(t)];case 1:return i=r.sent(),[2,i.as(Ao).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,i){return void 0===i&&(i=Xs.SYNC_POLL_CHANGELOGS),r(this,void 0,void 0,(function(){var r,o,a,c,u,l,h;return s(this,(function(s){switch(s.label){case 0:return r=new Io(se({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(r)];case 1:return o=s.sent(),a=o.as(Oo),c=a.updatedPolls,u=a.deletedPollIds,l=a.hasMore,h=a.nextToken,c.length>0&&this._dispatcher.dispatch(new lo({polls:c,source:i})),[2,{updatedPolls:c,deletedPollIds:u,hasMore:l,token:h}]}}))}))},e}(),Fo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.token,s=t.limit,o=e.call(this)||this;return o.method=oe.GET,o.path=be,o.params={channel_url:n,channel_type:i,token:r,limit:s},o}return t(n,e),n}(Ue),qo=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).polls=(null!==(i=n.polls)&&void 0!==i?i:[]).map((function(e){return new vo(t,e)})),r.token=n.next,r}return t(n,e),n}(Pe),Ho=function(e){function i(t,n){return e.call(this,t,n.channelUrl,n.channelType,n)||this}return t(i,e),i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=eo.of(this._iid).requestQueue,t=new Fo(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(qo),o=r.polls,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(mo),Vo=function(e){function n(t){var n=t.channelUrl,i=t.channelType,r=t.pollId,s=t.pollOptionId,o=t.token,a=t.limit,c=e.call(this)||this;return c.method=oe.GET,c.path="".concat(be,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(s),"/voters"),c.params={channel_url:n,channel_type:i,token:o,limit:a},c}return t(n,e),n}(Ue),zo=function(e){function n(t,n){var i,r=this;return(r=e.call(this,t,n)||this).voters=(null!==(i=n.voters)&&void 0!==i?i:[]).map((function(e){return new rs(t,e)})),r.token=n.next,r}return t(n,e),n}(Pe),Go=function(e){function i(t,n){var i=e.call(this,t,n.channelUrl,n.channelType,n)||this;return i.pollId=n.pollId,i.pollOptionId=n.pollOptionId,i}return t(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&w("number",this.pollId)&&w("number",this.pollOptionId)},i.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=eo.of(this._iid).requestQueue,t=new Vo(n(n({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return i=s.sent(),r=i.as(zo),o=r.voters,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},i}(mo);export{_ as $,oe as A,hs as B,q as C,Lr as D,te as E,Ar as F,ls as G,Or as H,ss as I,os as J,Fr as K,F as L,Fe as M,$e as N,g as O,f as P,N as Q,P as R,R as S,d as T,rs as U,eo as V,qe as W,S as X,Ze as Y,Hs as Z,r as _,w as a,Z as a$,p as a0,Kr as a1,Xs as a2,M as a3,E as a4,Rr as a5,Mr as a6,H as a7,u as a8,qr as a9,ot as aA,mo as aB,ke as aC,Ee as aD,Re as aE,j as aF,Eo as aG,be as aH,yo as aI,jr as aJ,I as aK,it as aL,_o as aM,Mo as aN,bo as aO,L as aP,i as aQ,ao as aR,co as aS,ho as aT,lo as aU,uo as aV,oo as aW,Ce as aX,X as aY,pe as aZ,to as a_,Dr as aa,$r as ab,Qe as ac,We as ad,le as ae,Br as af,y as ag,z as ah,es as ai,K as aj,He as ak,Oe as al,Ie as am,so as an,W as ao,A as ap,G as aq,vo as ar,Y as as,Q as at,De as au,nt as av,ps as aw,tt as ax,B as ay,he as az,s as b,ko as b0,Do as b1,xo as b2,Uo as b3,Ro as b4,Lo as b5,go as b6,no as b7,ie as b8,Ye as b9,xe as ba,Gs as bb,me as bc,io as bd,V as be,k as bf,de as bg,C as bh,rt as bi,fo as bj,ro as bk,gs as bl,po as bm,fe as bn,_e as bo,Te as bp,Ne as bq,Ve as br,Be as bs,t as c,ce as d,re as e,Ue as f,n as g,Pe as h,O as i,ve as j,ge as k,ye as l,Ae as m,$ as n,Xe as o,c as p,a as q,Tr as r,v as s,o as t,se as u,l as v,ns as w,Ho as x,Go as y,ts as z}; diff --git a/lib/__bundle-b5ef7de4.js b/lib/__bundle-3f550679.js similarity index 95% rename from lib/__bundle-b5ef7de4.js rename to lib/__bundle-3f550679.js index 28105b0..afccd4d 100644 --- a/lib/__bundle-b5ef7de4.js +++ b/lib/__bundle-3f550679.js @@ -1 +1 @@ -import{V as e,s as t,h as s,M as r,br as a,ax as n,bs as o,av as d}from"./__bundle-c03282ec.js";var i=function(i,u){return new Promise((function(c,p){if("undefined"!=typeof XMLHttpRequest){var f=e.of(i),l=f.dispatcher,g=f.logger,h=u.requestId,m=u.method,q=u.url,v=u.headers,w=void 0===v?{}:v,b=u.data,E=void 0===b?"":b,x=u.uploadProgressHandler,y=!1,H=new XMLHttpRequest;H.open(m,q),Object.keys(w).forEach((function(e){H.setRequestHeader(e,w[e])})),x&&H.upload.addEventListener("progress",(function(e){e.lengthComputable?x(h,e.loaded,e.total):g.debug("Progress computing failed: `Content-Length` header is not given.")})),H.onabort=function(){p(t.requestCanceled)},H.onerror=function(e){p(t.networkError)},H.onreadystatechange=function(){if(H.readyState===XMLHttpRequest.DONE&&!y)if(0===H.status||H.status>=200&&H.status<400)try{var e=JSON.parse(H.responseText);c(new s(i,e))}catch(u){p(t.networkError)}else try{var d=JSON.parse(H.responseText);if(d){var u=new t(d);if(u.isSessionExpiredError){if(l.dispatch(new r({reason:u.code,message:u.message})),!(H instanceof a)){var f=new n;return l.dispatch(new o({request:H,deferred:f,error:u})),f.promise}}else u.isSessionInvalidatedError&&l.dispatch(new r({reason:u.code,message:u.message}));p(u)}else p(t.requestFailed)}catch(u){p(t.requestFailed)}},l.on((function(e){e instanceof d&&(e.requestId&&e.requestId!==h||(y=!0,H.abort()))})),H.send(E)}else p(t.xmlHttpRequestNotSupported)}))};export{i as xmlHttpRequest}; +import{V as e,s as t,h as s,M as r,br as a,ax as n,bs as o,av as d}from"./__bundle-0ca331b6.js";var i=function(i,u){return new Promise((function(c,p){if("undefined"!=typeof XMLHttpRequest){var f=e.of(i),l=f.dispatcher,g=f.logger,h=u.requestId,m=u.method,q=u.url,v=u.headers,w=void 0===v?{}:v,b=u.data,E=void 0===b?"":b,x=u.uploadProgressHandler,y=!1,H=new XMLHttpRequest;H.open(m,q),Object.keys(w).forEach((function(e){H.setRequestHeader(e,w[e])})),x&&H.upload.addEventListener("progress",(function(e){e.lengthComputable?x(h,e.loaded,e.total):g.debug("Progress computing failed: `Content-Length` header is not given.")})),H.onabort=function(){p(t.requestCanceled)},H.onerror=function(e){p(t.networkError)},H.onreadystatechange=function(){if(H.readyState===XMLHttpRequest.DONE&&!y)if(0===H.status||H.status>=200&&H.status<400)try{var e=JSON.parse(H.responseText);c(new s(i,e))}catch(u){p(t.networkError)}else try{var d=JSON.parse(H.responseText);if(d){var u=new t(d);if(u.isSessionExpiredError){if(l.dispatch(new r({reason:u.code,message:u.message})),!(H instanceof a)){var f=new n;return l.dispatch(new o({request:H,deferred:f,error:u})),f.promise}}else u.isSessionInvalidatedError&&l.dispatch(new r({reason:u.code,message:u.message}));p(u)}else p(t.requestFailed)}catch(u){p(t.requestFailed)}},l.on((function(e){e instanceof d&&(e.requestId&&e.requestId!==h||(y=!0,H.abort()))})),H.send(E)}else p(t.xmlHttpRequestNotSupported)}))};export{i as xmlHttpRequest}; diff --git a/lib/__bundle-5f5bca4c.js b/lib/__bundle-5f5bca4c.js deleted file mode 100644 index 78170cd..0000000 --- a/lib/__bundle-5f5bca4c.js +++ /dev/null @@ -1 +0,0 @@ -import{c as t,b8 as n}from"./__bundle-c03282ec.js";var e=function(t){return["-lastMessageUpdatedAt","-createdAt","syncIndex"]},r=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t(e,n),e}(n);export{r as N,e as g}; diff --git a/lib/__bundle-1a7e946b.js b/lib/__bundle-735270df.js similarity index 97% rename from lib/__bundle-1a7e946b.js rename to lib/__bundle-735270df.js index 9a79823..b05d6a9 100644 --- a/lib/__bundle-1a7e946b.js +++ b/lib/__bundle-735270df.js @@ -1 +1 @@ -import{c as e,b8 as t,_ as s,b as n,ao as r,aK as a,D as i,F as o,t as u,a8 as c,an as d,a2 as h,ay as l,U as _,W as A}from"./__bundle-c03282ec.js";import{u as g,K as f}from"./__bundle-45809bc9.js";var E,p,R;!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"}(E||(E={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(p||(p={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(R||(R={}));var C,L=function(e){switch(e){case E.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case E.CHRONOLOGICAL:return["-createdAt","syncIndex"];case E.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},b=function(t){function s(e){var s=e.message,n=t.call(this)||this;return n.message=s,n}return e(s,t),s}(t),I={},S=function(){function e(e,t){var s=t.localCacheEnabled,n=t.enableAutoResend,r=t.dispatcher,a=t.sdkState,u=t.logger,c=this;this._iid=e,I[e]=this,this._localCacheEnabled=s,this._enableAutoResend=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=u,this._sdkState=a,this._localCacheEnabled&&r.on((function(e){if(e instanceof i)switch(e.stateType){case o.CONNECTED:c._isProcessingAutoResend||c.processAutoResendRegisteredPendingMessages().then((function(){return c._processNextAutoResend()}));break;case o.INTERNAL_DISCONNECTED:case o.EXTERNAL_DISCONNECTED:c._isProcessingAutoResend=!1}}))}return e.of=function(e){return I[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,a,i,o;return n(this,(function(n){switch(n.label){case 0:return this._enableAutoResend?[4,this._fetchAllCachedPendingMessages()]:[2];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())0===(a=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",a.reqId),a.sendingStatus=r.FAILED,a.errorCode=c.ACK_TIMEOUT,this._dispatcher.dispatch(new d({messages:[a],source:h.LOCAL_MESSAGE_FAILED})))}catch(e){i={error:e}}finally{try{s&&!s.done&&(o=t.return)&&o.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,i,o,c,l,_;return n(this,(function(n){switch(n.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())i=s.value,this._enableAutoResend&&i.errorCode&&a(i.errorCode)&&(o=(new Date).getTime(),c=i.createdAt+2592e5,this._enableAutoResend&&o<=c?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(c).toLocaleString()),i.sendingStatus=r.FAILED,this._dispatcher.dispatch(new d({messages:[i],source:h.LOCAL_MESSAGE_FAILED}))))}catch(e){l={error:e}}finally{try{s&&!s.done&&(_=t.return)&&_.call(t)}finally{if(l)throw l.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===r.SUCCEEDED||e.sendingStatus===r.FAILED&&!a(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t;return n(this,(function(s){switch(s.label){case 0:return e=g.of(this._iid),(t=new f).replyType=l.ALL,[4,e.fetch({sendingStatus:r.PENDING,backward:!0,filter:t})];case 1:return[2,s.sent()]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return s(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(this._localCacheEnabled&&this._enableAutoResend&&"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 b({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"}(C||(C={}));var N=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var s=t.data,n=s.blocker,r=s.blockee;return{blocker:new _(e,n),blockee:new _(e,r)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var s=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(s)?s.map((function(t){return new _(e,t)})):[]}},e}(),v=function(t){function s(e,s){var n=s.userId,r=t.call(this)||this;return r._iid=e,r.userId=n,r}return e(s,t),s}(t),D=function(t){function s(){return t.call(this)||this}return e(s,t),s}(t),T=function(t){function s(e,s,n){var r=t.call(this,e,"USEV",n)||this;return r.event=new N(n),r}return e(s,t),s}(A);export{S as A,v as D,E as G,p as P,D as R,R as S,T as U,C as a,N as b,b as c,L as g}; +import{c as e,b8 as t,_ as s,b as n,ao as r,aK as a,D as i,F as o,t as u,a8 as c,an as d,a2 as h,ay as l,U as _,W as A}from"./__bundle-0ca331b6.js";import{u as g,K as f}from"./__bundle-af65b142.js";var E,p,R;!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"}(E||(E={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(p||(p={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(R||(R={}));var C,L=function(e){switch(e){case E.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case E.CHRONOLOGICAL:return["-createdAt","syncIndex"];case E.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},b=function(t){function s(e){var s=e.message,n=t.call(this)||this;return n.message=s,n}return e(s,t),s}(t),I={},S=function(){function e(e,t){var s=t.localCacheEnabled,n=t.enableAutoResend,r=t.dispatcher,a=t.sdkState,u=t.logger,c=this;this._iid=e,I[e]=this,this._localCacheEnabled=s,this._enableAutoResend=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=u,this._sdkState=a,this._localCacheEnabled&&r.on((function(e){if(e instanceof i)switch(e.stateType){case o.CONNECTED:c._isProcessingAutoResend||c.processAutoResendRegisteredPendingMessages().then((function(){return c._processNextAutoResend()}));break;case o.INTERNAL_DISCONNECTED:case o.EXTERNAL_DISCONNECTED:c._isProcessingAutoResend=!1}}))}return e.of=function(e){return I[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,a,i,o;return n(this,(function(n){switch(n.label){case 0:return this._enableAutoResend?[4,this._fetchAllCachedPendingMessages()]:[2];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())0===(a=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",a.reqId),a.sendingStatus=r.FAILED,a.errorCode=c.ACK_TIMEOUT,this._dispatcher.dispatch(new d({messages:[a],source:h.LOCAL_MESSAGE_FAILED})))}catch(e){i={error:e}}finally{try{s&&!s.done&&(o=t.return)&&o.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,i,o,c,l,_;return n(this,(function(n){switch(n.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())i=s.value,this._enableAutoResend&&i.errorCode&&a(i.errorCode)&&(o=(new Date).getTime(),c=i.createdAt+2592e5,this._enableAutoResend&&o<=c?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(c).toLocaleString()),i.sendingStatus=r.FAILED,this._dispatcher.dispatch(new d({messages:[i],source:h.LOCAL_MESSAGE_FAILED}))))}catch(e){l={error:e}}finally{try{s&&!s.done&&(_=t.return)&&_.call(t)}finally{if(l)throw l.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===r.SUCCEEDED||e.sendingStatus===r.FAILED&&!a(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t;return n(this,(function(s){switch(s.label){case 0:return e=g.of(this._iid),(t=new f).replyType=l.ALL,[4,e.fetch({sendingStatus:r.PENDING,backward:!0,filter:t})];case 1:return[2,s.sent()]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return s(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(this._localCacheEnabled&&this._enableAutoResend&&"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 b({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"}(C||(C={}));var N=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var s=t.data,n=s.blocker,r=s.blockee;return{blocker:new _(e,n),blockee:new _(e,r)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var s=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(s)?s.map((function(t){return new _(e,t)})):[]}},e}(),v=function(t){function s(e,s){var n=s.userId,r=t.call(this)||this;return r._iid=e,r.userId=n,r}return e(s,t),s}(t),D=function(t){function s(){return t.call(this)||this}return e(s,t),s}(t),T=function(t){function s(e,s,n){var r=t.call(this,e,"USEV",n)||this;return r.event=new N(n),r}return e(s,t),s}(A);export{S as A,v as D,E as G,p as P,D as R,R as S,T as U,C as a,N as b,b as c,L as g}; diff --git a/lib/__bundle-45809bc9.js b/lib/__bundle-af65b142.js similarity index 99% rename from lib/__bundle-45809bc9.js rename to lib/__bundle-af65b142.js index ac13a64..c431784 100644 --- a/lib/__bundle-45809bc9.js +++ b/lib/__bundle-af65b142.js @@ -1 +1 @@ -import{e,u as t,V as n,c as r,A as i,ae as s,f as a,h as o,g as u,U as c,af as l,Q as d,a as h,X as f,p,q as m,t as v,a7 as y,ag as _,ah as g,ai as b,C as I,aj as E,ak as T,al as w,W as M,am as S,_ as A,b as U,an as N,a2 as C,s as O,a8 as P,ao as k,ap as R,aq as x,w as D,ar as L,as as F,at as q,au as z,av as B,D as j,F as K,aw as Q,i as G,ax as V,ay as H,az as W,aA as Y,aB as J,aC as X,aD as Z,aE as $,aF as ee,aG as te,aH as ne,aI as re,aJ as ie,n as se,G as ae,O as oe,aK as ue,x as ce,y as le,aL as de,aM as he,aN as fe,d as pe,aO as me,aP as ve,aQ as ye,aR as _e,aS as ge,B as be,aT as Ie,aU as Ee,aV as Te,aW as we,aX as Me,aY as Se,z as Ae,aZ as Ue,a_ as Ne}from"./__bundle-c03282ec.js";var Ce,Oe=function(){function r(e,t,n){var r,i;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(r=t.real_width)&&void 0!==r?r:t.width,this.realHeight=null!==(i=t.real_height)&&void 0!==i?i:t.height,this._requireAuth=n}return r.payloadify=function(n){return e(t(n instanceof r?{url:n.plainUrl,width:n.width,height:n.height,real_width:n.realWidth,real_height:n.realHeight}:{url:"",width:n.maxWidth,height:n.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(r.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),r}(),Pe=function(t){function n(n){var r=t.call(this)||this;if(r.method=i.POST,r.path="".concat(s),r.params=e({file:n.file,channel_url:n.channelUrl}),n.thumbnailSizes)for(var a=0;a0:void 0,u.lastRepliedAt=null!==(a=t.last_replied_at)&&void 0!==a?a:0,u.updatedAt=null!==(o=t.updated_at)&&void 0!==o?o:0,u}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{reply_count:r.replyCount,unread_message_count:r.unreadReplyCount,member_count:r.memberCount,most_replies:Array.isArray(r.mostRepliedUsers)?r.mostRepliedUsers.map((function(e){return c.payloadify(e)})):[],push_enabled:"boolean"==typeof r.isPushNotificationEnabled?r.isPushNotificationEnabled?1:0:void 0,last_replied_at:r.lastRepliedAt,updated_at:r.updatedAt})))},Object.defineProperty(i.prototype,"_isUpdateRequired",{get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled},enumerable:!1,configurable:!0}),i.prototype._updateFrom=function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled},i}(l);!function(e){e.ADD="add",e.DELETE="delete"}(Ce||(Ce={}));var xe,De=function(e){this.messageId=0,this.operation=null,this.updatedAt=0;var t=h("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,n=e.user_id,r=e.operation?e.operation.toLowerCase():null,i=e.reaction,s=e.updated_at;t&&h("string",n)&&h("string",r)&&f(Ce,r)&&h("string",i)&&i&&h("number",s)&&(this.messageId=t,this.userId=n,this.key=i,this.operation=r,this.updatedAt=s)},Le=function(){function n(e){var t,n,r,i=e.key,s=null!==(r=p([],m(e.user_ids),!1))&&void 0!==r?r:[],a=e.updated_at;h("string",i)&&i&&d("string",s)&&s.length>0&&h("number",a)&&(this.key=i,this.userIds=s,this.updatedAt=a);var o={};try{for(var u=v(this.userIds),c=u.next();!c.done;c=u.next()){o[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._version=o}return Object.defineProperty(n.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({key:n.key,user_ids:n.userIds,updated_at:n.updatedAt}))},n.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 Ce.ADD:t<0&&this.userIds.push(e.userId);break;case Ce.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},n}(),Fe=function(){function n(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 n.payloadify=function(n){var r,i;return e(t({url:n.url,secure_url:n.secureUrl,type:n.type,width:null!==(r=n.width)&&void 0!==r?r:0,height:null!==(i=n.height)&&void 0!==i?i:0,alt:n.alt}))},n}(),qe=function(){function n(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 Fe(e["og:image"]))}return n.payloadify=function(n){return e(t({"og:title":n.title,"og:url":n.url,"og:description":n.description,"og:image":n.defaultImage?Fe.payloadify(n.defaultImage):null}))},n}(),ze=function(){function n(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 n.prototype.serialize=function(){return{name:this.name,volume:this.volume}},n.payloadify=function(n){return e(t({name:n.name,volume:n.volume}))},n}();!function(e){e.GOOD="good",e.BAD="bad"}(xe||(xe={}));var Be=function(){function n(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}return n._getStatus=function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"},n._isSubmitted=function(e){return"SUBMITTED"===n._getStatus(e)},n._getPayloadByStatus=function(e){return"NO_FEEDBACK"===e?{}:null},n.payloadify=function(n){return e(t({id:n.id,rating:n.rating,comment:n.comment}))},n}(),je=function(n){function i(e,t){var r,i=this;return(i=n.call(this,e,t)||this).isBlockedByMe=!1,i.role=f(y,t.role)?t.role:y.NONE,i.isBlockedByMe=null!==(r=t.is_blocked_by_me)&&void 0!==r&&r,i}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{role:r.role,is_blocked_by_me:r.isBlockedByMe})))},i}(c),Ke=function(){function n(e){this.key=e.key,this.value=d("string",e.value)?p([],m(e.value),!1):[]}return n.payloadify=function(n){var r;return e(t({key:n.key,value:null!==(r=n.value)&&void 0!==r?r:[]}))},n}(),Qe=function(e){switch(e){case g.BASE:return"";case g.USER:return"MESG";case g.FILE:return"FILE";case g.ADMIN:return"ADMM"}},Ge=function(n){function i(e,t){var r,i,s,a,o,u,l,d,h,p=this;(p=n.call(this,e)||this).channelType=I.BASE,p.messageType=g.BASE,p.mentionType=null,p.mentionedUsers=null,p.mentionedUserIds=null,p.mentionedMessageTemplate=void 0,p.metaArrays=[],p.extendedMessage={},p.createdAt=0,p.updatedAt=0,p.channelUrl=t.channel_url,p.channelType=f(I,t.channel_type)?t.channel_type:I.GROUP,t.channel&&(t.channel.channel_url&&(p.channelUrl=t.channel.channel_url),t.channel.channel_type&&(p.channelType=t.channel.channel_type)),p.data=null!==(r=t.data)&&void 0!==r?r:"",p.customType=null!==(i=t.custom_type)&&void 0!==i?i:"",p.mentionType=f(E,t.mention_type)?t.mention_type:null,p.mentionedUsers=t.mentioned_users?t.mentioned_users.map((function(e){return new c(p._iid,e)})):null,p.mentionedUserIds=null!==(s=t.mentioned_user_ids)&&void 0!==s?s:null,p.mentionedUsers&&!p.mentionedUserIds&&(p.mentionedUserIds=p.mentionedUsers.map((function(e){return e.userId}))),p.mentionedMessageTemplate=t.mentioned_message_template;var m=null!==(a=t.metaarray)&&void 0!==a?a:{},v=null!==(o=t.metaarray_key_order)&&void 0!==o?o:Object.keys(m).sort((function(e,t){return e.localeCompare(t)}));p.metaArrays=[];for(var y=0;y0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({id:n.id,name:n.name,items:n.items.map((function(e){return dt.payloadify(e)})),version:n.version,is_submitted:n._isSubmitted}))},n.isMessageFormPayload=function(e){return Boolean(null==e?void 0:e.message_form)},n}(),dt=function(){function n(t){var n=t.id,r=t.name,i=t.required,s=t.sort_order,a=t.placeholder,o=t.style,u=t.item_type,c=t.validators,l=t.value,d=t.values;this.id=n,this.name=r,this.required=i,this.sortOrder=s,this.placeholder=a,0===Object.keys(o).length?this.style={layout:u}:this.style=e({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),d?this.submittedValues=d:l&&(this.submittedValues=[l]),this._validators=c}return n.prototype.isValid=function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case it.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case it.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case it.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case it.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case it.DECIMAL_PLACE:return 0!==e.length&&(n=Number(e),!(isNaN(n)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(n,t.max_decimal_place)));default:return!0}}))}(e,t._validators);return n}))},n.payloadify=function(n){return e(t({id:n.id,name:n.name,required:n.required,sort_order:n.sortOrder,placeholder:n.placeholder,style:e({layout:n.style.layout,options:n.style.options,default_options:n.style.defaultOptions,result_count:n.style.resultCount}),item_type:n.style.layout,validators:n._validators,values:n.submittedValues}))},n}(),ht=function(t){function n(n){var r=t.call(this)||this;return r.method=i.POST,r.path="".concat(S,"/").concat(n.formId,"/submit"),r.params=e({message_id:n.messageId,items:n.items}),r}return r(n,t),n}(a);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ut||(ut={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ct||(ct={}));var ft,pt=function(i){function s(e,t){var n,r,s,a,o,u,c,l,d,h=this;return(h=i.call(this,e,t)||this).parentMessage=null,h.silent=!1,h.isOperatorMessage=!1,h.threadInfo=null,h.reactions=[],h.appleCriticalAlertOptions=null,h.scheduledInfo=null,h.suggestedReplies=null,h.myFeedback=null,h.myFeedbackStatus="NOT_APPLICABLE",h.messageForm=null,h._isContinuousMessages=!1,h._scheduledStatus=null,h.messageId=null!==(r=null!==(n=t.msg_id)&&void 0!==n?n:t.message_id)&&void 0!==r?r:0,h.parentMessageId=null!==(s="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==s?s:0,h.threadInfo=t.thread_info?new Re(h._iid,t.thread_info):null,h.reactions=t.reactions?t.reactions.map((function(e){return new Le(e)})):[],h.ogMetaData=t.og_tag?new qe(t.og_tag):null,h.silent=null!==(a=t.silent)&&void 0!==a&&a,h.isOperatorMessage=null!==(o=t.is_op_msg)&&void 0!==o&&o,h.appleCriticalAlertOptions=t.apple_critical_alert_options?new ze(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(h.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},h._scheduledStatus=t.scheduled_status),h._isContinuousMessages=null!==(u=t.is_continuous_messages)&&void 0!==u&&u,h.myFeedback=Be._isSubmitted(t.feedback)?new Be(t.feedback):null,h.myFeedbackStatus=Be._getStatus(t.feedback),h.suggestedReplies=null!==(l=null===(c=t.extended_message_payload)||void 0===c?void 0:c.suggested_replies)&&void 0!==l?l:null,h.messageForm=lt.isMessageFormPayload(t.extended_message_payload)?new lt(h.messageId,t.extended_message_payload.message_form):null,h.message=null!==(d=t.message)&&void 0!==d?d:"",h}return r(s,i),s.payloadify=function(n){var r,s;return e(t(u(u({},i.payloadify.call(this,n)),{message_id:n.messageId,parent_message_id:n.parentMessageId,thread_info:n.threadInfo?Re.payloadify(n.threadInfo):null,reactions:n.reactions.map((function(e){return Le.payloadify(e)})),og_tag:n.ogMetaData?qe.payloadify(n.ogMetaData):null,silent:n.silent,is_op_msg:n.isOperatorMessage,apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,scheduled_message_id:null===(r=n.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=n.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:n._scheduledStatus,feedback:n.myFeedback?Be.payloadify(n.myFeedback):Be._getPayloadByStatus(n.myFeedbackStatus),message:n.message})))},s._getParentMessageInfoPayload=function(n){return e(t({type:Qe(n.messageType),ts:n.createdAt,user:n.sender?je.payloadify(n.sender):null,message:n.message,file:{url:n.plainUrl,name:n.name,type:n.type,require_auth:n.requireAuth},files:Array.isArray(n.fileInfoList)?n.fileInfoList.map((function(e){return at.payloadify(e)})):null}))},s.prototype.isIdentical=function(e){return this.messageId===e.messageId},s.prototype.applyThreadInfoUpdateEvent=function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)},s.prototype.applyReactionEvent=function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1},s.prototype._triggerThreadInfoUpdatedEvent=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){return(e=n.of(this._iid).dispatcher).dispatch(new ot({channelType:I.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_THREADINFO_UPDATED})),[2]}))}))},s.prototype.markThreadAsRead=function(){return A(this,void 0,void 0,(function(){var e,t;return U(this,(function(r){switch(r.label){case 0:return e=n.of(this._iid).requestQueue,t=new Xe({channelUrl:this.channelUrl,messageId:this.messageId}),[4,e.send(t)];case 1:return r.sent(),this.threadInfo&&0!==this.threadInfo.unreadReplyCount?(this.threadInfo.unreadReplyCount=0,[4,this._triggerThreadInfoUpdatedEvent()]):[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},s.prototype.setPushNotificationEnabled=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return t=n.of(this._iid).requestQueue,r=new Ze({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),[4,t.send(r)];case 1:return i.sent(),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e),[2]}}))}))},s.prototype.submitMessageForm=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(t=n.of(this._iid).requestQueue,r=null,i=null,s=this.messageForm,!e&&s){if(!s.isSubmittable)throw new O({code:P.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(s.isSubmitted)throw new O({code:P.INVALID_PARAMETER,message:"The form has already been submitted."});r=s.id,i=s.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[])}else e&&(r=e.formId,i=Object.entries(e.answers).reduce((function(e,t){var n=m(t,2),r=n[0],i=n[1],s=Number(r);if(Number.isNaN(s))throw new O({code:P.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:s,value:i}),e}),[]));if(!r||!i)throw new O({code:P.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});return a=new ht({messageId:this.messageId,formId:r,items:i}),[4,t.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.submitFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new $e({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(et),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_ADDED})),[2]}}))}))},s.prototype.updateFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new tt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(nt),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_UPDATED})),[2]}}))}))},s.prototype.deleteFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new rt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e}),[4,r.send(s)];case 1:return a.sent(),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_DELETED})),[2]}}))}))},s}(Ge),mt=function(n){function i(e,t){var r,i,s,a,o=this;if((o=n.call(this,e,t)||this).reqId="",o.replyToChannel=!1,o.errorCode=0,o.sender=t.user?new je(o._iid,t.user):t.sender_id,o.reqId=null!==(i=null!==(r=t.req_id)&&void 0!==r?r:t.request_id)&&void 0!==i?i:"",o.replyToChannel=null!==(s=t.is_reply_to_channel)&&void 0!==s&&s,t.request_state&&f(k,t.request_state)&&(o.sendingStatus=t.request_state),!o.sendingStatus)if(o.messageId>0)o.sendingStatus=k.SUCCEEDED;else if(o.scheduledInfo)switch(t.scheduled_status&&(o._scheduledStatus=t.scheduled_status),t.scheduled_status){case ct.SENT:case ct.IN_QUEUE:o.sendingStatus=k.SUCCEEDED;break;case ct.PENDING:o.sendingStatus=k.SCHEDULED;break;case ct.FAILED:case ct.REMOVED:o.sendingStatus=k.FAILED;break;case ct.CANCELED:o.sendingStatus=k.CANCELED}else o.sendingStatus=k.PENDING;return o.errorCode=null!==(a=t.error_code)&&void 0!==a?a:0,o._messageToken=t.mesg_token,o}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{user:je.payloadify(r.sender),req_id:r.reqId,is_reply_to_channel:r.replyToChannel,request_state:r.sendingStatus,error_code:r.errorCode,mesg_token:r._messageToken})))},Object.defineProperty(i.prototype,"isResendable",{get:function(){return(this.sendingStatus===k.FAILED||this.sendingStatus===k.CANCELED)&&R(this.errorCode)},enumerable:!1,configurable:!0}),i.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},i}(pt),vt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},yt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)},_t=function(n){function i(r,i){var s,a,o,c=this;if((c=n.call(this,r,i)||this).translations={},c.messageType=g.ADMIN,c.translations=null!==(s=i.translations)&&void 0!==s?s:{},i.parent_message_info){var l=i.parent_message_info;c.parentMessage=Mt(r,e(t(u(u({},l),{message_id:c.parentMessageId,channel_url:c.channelUrl,channel_type:c.channelType,file:l.file,url:null===(a=l.file)||void 0===a?void 0:a.url,require_auth:null===(o=l.file)||void 0===o?void 0:o.require_auth}))))}return c}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{translations:r.translations,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i}(pt),gt=function(){function n(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&&h("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return n.payloadify=function(n){return e(t({type:n.type,vendor:n.vendor,detail:n.detail}))},n}(),bt=function(){function t(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}return t.payloadify=function(t){return e({status:t.status,original_message_info:t.originalMessageInfo?{id:t.originalMessageInfo.messageId,ts:t.originalMessageInfo.createdAt}:void 0})},t}(),It=function(n){function i(r,i){var s,a,o,c,l,d,h,f=this;if((f=n.call(this,r,i)||this).messageParams=null,f.translations={},f.translationTargetLanguages=[],f.messageSurvivalSeconds=-1,f.plugins=[],f._poll=null,f.messageType=g.USER,f.translations=null!==(o=i.translations)&&void 0!==o?o:{},f.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(f.translations).length&&f.translationTargetLanguages.length>0)try{for(var p=v(f.translationTargetLanguages),m=p.next();!m.done;m=p.next()){var y=m.value;f.translations[y]=""}}catch(e){s={error:e}}finally{try{m&&!m.done&&(a=p.return)&&a.call(p)}finally{if(s)throw s.error}}if(f.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,f.plugins=i.plugins?i.plugins.map((function(e){return new gt(e)})):[],f._poll=i.poll?new L(f._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;f.parentMessage=Mt(r,e(t(u(u({},_),{created_at:_.ts,message_id:f.parentMessageId,channel_url:f.channelUrl,channel_type:f.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(f.messageReviewInfo=new bt(i.review_info)),f}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{translations:r.translations,message_survival_seconds:r.messageSurvivalSeconds,plugins:r.plugins.map((function(e){return gt.payloadify(e)})),poll:r._poll?L.payloadify(r._poll):null,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null,review_info:r.messageReviewInfo?bt.payloadify(r.messageReviewInfo):void 0})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(i.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),i}(mt),Et=function(n){function i(r,i){var s,a,o,c,l,d,h,f,p=this;if((p=n.call(this,r,i)||this).messageParams=null,p.fileInfoList=[],p.messageSurvivalSeconds=-1,p.messageType=g.FILE,p.data=null!==(o=null!==(a=null===(s=i.file)||void 0===s?void 0:s.data)&&void 0!==a?a:i.custom)&&void 0!==o?o:"",p.fileInfoList=null!==(l=null===(c=i.files)||void 0===c?void 0:c.map((function(e){return new at(r,e)})))&&void 0!==l?l:[],p.messageSurvivalSeconds=null!==(d=i.message_survival_seconds)&&void 0!==d?d:-1,i.parent_message_info){var m=i.parent_message_info;p.parentMessage=Mt(r,e(t(u(u({},m),{created_at:m.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:m.file,url:null===(h=m.file)||void 0===h?void 0:h.url,require_auth:null===(f=m.file)||void 0===f?void 0:f.require_auth}))))}return p}return r(i,n),i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.payloadify=function(r){var i,s,a,o,c,l;return e(t(u(u({},n.payloadify.call(this,r)),{file:{name:null!==(s=null===(i=r.fileInfoList[0])||void 0===i?void 0:i.fileName)&&void 0!==s?s:"",size:null!==(o=null===(a=r.fileInfoList[0])||void 0===a?void 0:a.fileSize)&&void 0!==o?o:0,type:null!==(l=null===(c=r.fileInfoList[0])||void 0===c?void 0:c.mimeType)&&void 0!==l?l:"",data:r.data},files:Array.isArray(r.fileInfoList)?r.fileInfoList.map((function(e){return at.payloadify(e)})):null,message_survival_seconds:r.messageSurvivalSeconds,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},i._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},i}(mt);!function(e){e.SENT="SENT",e.READ="READ"}(ft||(ft={}));var Tt=function(n){function i(e,t){var r,i,s=this;if((s=n.call(this,e,t)||this).notificationData=null,s.notificationId=t.notification_message_id,s.messageType=g.ADMIN,s.messageStatus=null!==(r=t.message_status)&&void 0!==r?r:ft.SENT,s.priority=null!==(i=t.priority)&&void 0!==i?i:F.NORMAL,s.notificationEventDeadline=t.notification_event_deadline,0===s.extendedMessage.sub_type)try{var a=JSON.parse(s.extendedMessage.sub_data),o=a.label,u=a.tags,c=void 0===u?[]:u,l=a.template_key,d=a.template_variables;s.notificationData={label:o,tags:c,templateKey:l,templateVariables:d}}catch(e){}return s}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{notification_message_id:r.notificationId,message_status:r.messageStatus,priority:r.priority,notification_event_deadline:r.notificationEventDeadline})))},i.prototype.isIdentical=function(e){return this.notificationId===e.notificationId},i}(Ge),wt=function(e){if(e.notificationId)return Tt.payloadify(e);switch(e.messageType){case g.USER:return It.payloadify(e);case g.FILE:return e.fileInfoList?Et.payloadify(e):St.payloadify(e);case g.ADMIN:return _t.payloadify(e);default:throw O.unknown}},Mt=function(e,t){if(t.notification_message_id)return new Tt(e,t);switch(t.type){case"MESG":return new It(e,t);case"FILE":return Et._isMultipleFilesMessagePayload(t)?new Et(e,t):new St(e,t);case"ADMM":case"BRDM":return new _t(e,t);default:return null}},St=function(i){function s(n,r){var s,a,o,c,l,d,h,f,p,m,v,y,_,b,I=this;(I=i.call(this,n,r)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=g.FILE;var E=r.file;if(I.plainUrl=(null!==(a=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==a?a:"").split("?auth=")[0],I.name=null!==(c=null!==(o=null==E?void 0:E.name)&&void 0!==o?o:r.name)&&void 0!==c?c:"File",I.size=null!==(d=null!==(l=null==E?void 0:E.size)&&void 0!==l?l:r.size)&&void 0!==d?d:0,I.data=null!==(f=null!==(h=null==E?void 0:E.data)&&void 0!==h?h:r.custom)&&void 0!==f?f:"",I.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(m=r.type)&&void 0!==m?m:"",I.requireAuth=null!==(v=r.require_auth)&&void 0!==v&&v,I.thumbnails=r.thumbnails?r.thumbnails.map((function(e){var t;return new Oe(I._iid,"string"==typeof e?{url:e,width:0,height:0}:u(u({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),I.requireAuth)})):[],I.messageSurvivalSeconds=null!==(y=r.message_survival_seconds)&&void 0!==y?y:-1,r.parent_message_info){var T=r.parent_message_info;I.parentMessage=Mt(n,e(t(u(u({},T),{created_at:T.ts,message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:T.file,url:null===(_=T.file)||void 0===_?void 0:_.url,require_auth:null===(b=T.file)||void 0===b?void 0:b.require_auth}))))}return I}return r(s,i),s.payloadify=function(n){var r;return e(t(u(u({},i.payloadify.call(this,n)),{url:n.plainUrl,require_auth:n.requireAuth,file:{name:n.name,size:n.size,type:n.type,data:n.data},thumbnails:null===(r=n.thumbnails)||void 0===r?void 0:r.map((function(e){return{url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:n.messageSurvivalSeconds,parent_message_info:n.parentMessage?i._getParentMessageInfoPayload.call(this,n.parentMessage):null})))},Object.defineProperty(s.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},s}(mt),At=function(e){function t(t,n){var r=n.file,i=n.fileUrl,s=n.fileName,a=n.fileSize,o=n.mimeType,u=n.thumbnailSizes,c=n._uploadedMetaData,l=n._thumbnails,d=e.call(this,t)||this;return d._plainUrl=i,d.file=r,d.fileName=s,d.fileSize=a,d.mimeType=o,d.thumbnailSizes=u,d._uploadedMetaData=c,d._thumbnails=l,d}return r(t,e),t.getPlainUrl=function(e){return e instanceof t?e._plainUrl:e.fileUrl},Object.defineProperty(t.prototype,"fileUrl",{get:function(){var e,t=n.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}},t}(l),Ut=function(n){function i(r){var i,s,a,o,u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,files:r.files?Pt(r.files):null,url:r.url,name:null!==(i=r.fileName)&&void 0!==i?i:"",type:null!==(s=r.mimeType)&&void 0!==s?s:"",size:null!==(a=r.fileSize)&&void 0!==a?a:0,custom:r.data,custom_type:r.customType,thumbnails:null===(o=r._thumbnails)||void 0===o?void 0:o.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:u,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,pin_message:r.isPinnedMessage,message:r.message}))})||this}return r(i,n),i}(T),Nt=function(n){function s(r){var s,a,o=this;o=n.call(this)||this;var u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),o.method=i.POST,o.path="".concat(w(r.channelType),"/").concat(encodeURIComponent(r.channelUrl),"/messages"),o.params=e(t({message_type:g.FILE,user_id:r.userId,files:r.files?Pt(r.files):null,url:r.fileUrl,mention_type:r.mentionType,mentioned_user_ids:u,file_name:r.fileName,file_size:r.fileSize,file_type:r.mimeType,data:r.data,custom_type:r.customType,thumbnails:null===(s=r._thumbnails)||void 0===s?void 0:s.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,sorted_metaarray:null===(a=r.metaArrays)||void 0===a?void 0:a.map((function(e){return Ke.payloadify(e)})),push_option:r.pushNotificationDeliveryOption,parent_message_id:r.parentMessageId?r.parentMessageId:null,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,reply_to_channel:r.isReplyToChannel,req_id:r.reqId,pin_message:r.isPinnedMessage})),o}return r(s,n),s}(a),Ct=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"FILE",i)||this).message=i.files&&i.files.length>=2?new Et(t,i):new St(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),Ot=function(e){function t(t,r){var i,s,a,o,u=this;(u=e.call(this,t,r)||this).message=r.files&&r.files.length>=2?new Et(t,r):new St(t,r);var c=n.of(t).sdkState;return u.isMentioned=z(u.message.mentionType,null!==(a=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(s=u.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return r(t,e),t}(o);function Pt(n){return n.map((function(n){var r,i;return e(t({url:At.getPlainUrl(n),file_name:n.fileName,file_type:n.mimeType,file_size:n.fileSize,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),require_auth:null===(i=n._uploadedMetaData)||void 0===i?void 0:i.requireAuth}))}))}var kt;!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"}(kt||(kt={}));var Rt=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext,o=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=a,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof j&&(o._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===K.CONNECTED||this._connectionState===K.CONNECTING||this._connectionState===K.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){switch(s.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(r=new Ut(n),[4,this._requestQueue.send(r)]):[3,2];case 1:return i=s.sent(),[2,i.as(Ct).message];case 2:return r=new Nt(u(u({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),[2,i.as(Ot).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=u(u({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{r=t.params;n.url=r.fileUrl,n.requireAuth=r.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p;return U(this,(function(m){switch(m.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,r=[],i=!0,m.label=1;case 1:m.trys.push([1,15,16,17]),s=v(n.messageQueue),a=s.next(),m.label=2;case 2:if(a.done)return[3,14];switch(o=a.value,o.state){case kt.PENDING:case kt.UPLOADING:return[3,3];case kt.UPLOADED:return[3,4];case kt.FAILED:return[3,12]}return[3,13];case 3:return i=!1,r.push(o),[3,13];case 4:if(!i)return[3,10];m.label=5;case 5:return m.trys.push([5,8,,9]),o.state=kt.SENDING,[4,this._sendFileMessage(e,o)];case 6:return u=m.sent(),o.deferred.resolve(u),[4,Q(100)];case 7:return m.sent(),[3,9];case 8:return c=m.sent(),o.deferred.reject(c),[3,9];case 9:return[3,11];case 10:r.push(o),m.label=11;case 11:return[3,13];case 12:return l=null!==(t=o.error)&&void 0!==t?t:O.unknown,o.deferred.reject(l.code===P.REQUEST_CANCELED?O.fileUploadCanceled:l),[3,13];case 13:return a=s.next(),[3,2];case 14:return[3,17];case 15:return d=m.sent(),f={error:d},[3,17];case 16:try{a&&!a.done&&(p=s.return)&&p.call(s)}finally{if(f)throw f.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:m.sent(),m.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,m.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d;return U(this,(function(h){switch(h.label){case 0:return(n=this._queueMap.get(e.url))&&(r=n.messageQueue.find((function(e){return e.state===kt.PENDING})))?r.multipleFileUploadInfo?(i=r.multipleFileUploadInfo,s=i.uploadIndex,a=i.uploadCount,o=i.requestHandler,d=r.params,u=d.fileInfoList[s],!G(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]):[3,4]:[3,9];case 1:return h.sent(),[3,3];case 2:r.state=s=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,u,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return a=new Pe({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(a)];case 1:return o=v.sent(),u=o.as(ke),c=u.url,l=u.fileSize,d=void 0===l?n.fileSize:l,h=u.thumbnails,f=void 0===h?[]:h,p=u.requireAuth,m=void 0!==p&&p,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(i=n.mimeType)&&void 0!==i?i:n.file.type,n.fileSize=null!==(s=n.fileSize)&&void 0!==s?s:n.file.size,n.fileUrl=c,n.fileSize=d,n.requireAuth=m,n._thumbnails=f,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,c,l,d,h,f,p,m,v,y;return U(this,(function(_){switch(_.label){case 0:return a=t.multipleFileUploadInfo.uploadIndex,o=n.fileInfoList[a],c=new Pe({file:o.file,channelUrl:e.url,thumbnailSizes:o.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(c)];case 1:return l=_.sent(),d=l.as(ke),h=d.url,f=d.fileSize,p=void 0===f?o.fileSize:f,m=d.thumbnails,v=d.requireAuth,y=void 0!==v&&v,o.fileName=null!==(r=o.fileName)&&void 0!==r?r:o.file.name,o.mimeType=null!==(i=o.mimeType)&&void 0!==i?i:o.file.type,o.fileSize=null!==(s=o.fileSize)&&void 0!==s?s:o.file.size,o.file=void 0,o.fileUrl=h,o.fileSize=p,o._thumbnails=m,o._uploadedMetaData=u(u({},o._uploadedMetaData),{requireAuth:y,isUploaded:!0}),o instanceof At||(n.fileInfoList[a]=new At(this._iid,o)),[2]}}))}))},e.prototype.request=function(e,t,n,r){return void 0===r&&(r={}),A(this,void 0,void 0,(function(){var i,s,a,o,c;return U(this,(function(l){return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),a=new V,o={requestId:t,params:n,state:kt.PENDING,deferred:a},function(e){return"fileInfoList"in e}(n)&&(c=u({uploadIndex:0,uploadCount:n.fileInfoList.length},r),o.multipleFileUploadInfo=c),s.messageQueue.push(o),this._uploadNextPendingItem(e),[2,a.promise]}))}))},e.prototype.cancel=function(e,t){var n,r,i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:p([],m(i.messageQueue),!1);try{for(var a=v(s),o=a.next();!o.done;o=a.next()){var u=o.value;if(u)switch(u.state){case kt.PENDING:if(u.state=kt.FAILED,u.error=O.requestCanceled,u.multipleFileUploadInfo&&!u.multipleFileUploadInfo.isCopy){var c=u.multipleFileUploadInfo,l=c.uploadIndex,d=c.requestHandler,h=u.params.fileInfoList[l];null==d||d._triggerOnFileUploaded(u.requestId,l,h,O.fileUploadCanceled)}this._resolveMessageQueue(e);break;case kt.UPLOADING:this._requestQueue.cancel(u.requestId),this._dispatcher.dispatch(new B({requestId:u.requestId}))}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new B({requestId:t})))},e}();var xt,Dt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:H.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Lt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&f(H,e.replyType)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)&&h("boolean",e.showSubchannelMessagesOnly)},Ft={replyType:H.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},qt=function(e){return f(H,e.replyType)&&h("boolean",e.includeReactions)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)},zt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.includeMetaArray,o=t.includeReactions,u=t.includeThreadInfo,c=t.includeParentMessageInfo,l=e.call(this)||this;return l.method=i.GET,l.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s)),l.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions:o,include_thread_info:u,include_parent_message_info:c,include_poll_details:!0},l}return r(t,e),t}(a),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o),jt=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.timestamp,u=r.token,c=r.prevResultSize,l=r.nextResultSize,d=r.isInclusive,h=r.reverse,f=r.messageTypeFilter,p=r.customTypesFilter,m=r.senderUserIdsFilter,v=r.replyType,y=r.includeMetaArray,_=r.includeReactions,g=r.parentMessageId,b=r.includeThreadInfo,I=r.includeParentMessageInfo,E=r.showSubchannelMessagesOnly,T=r.checkingHasNext,M=r.checkingContinuousMessages,S=n.call(this)||this;return S.method=i.GET,S.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages"),S.params=e(t({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:m,include_reply_type:v,with_sorted_meta_array:y,include_reactions:_,parent_message_id:g,include_thread_info:b,include_parent_message_info:I,show_subchannel_message_only:E,include_poll_details:!0,checking_has_next:T,checking_continuous_messages:M})),S}return r(s,n),s}(a),Kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return void 0!==n.is_continuous_messages&&(r.isContinuousMessages=n.is_continuous_messages),void 0!==n.has_next&&(r.hasNext=n.has_next),r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),Qt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.timestamp,a=t.token,o=t.replyType,u=t.includeMetaArray,c=t.includeReactions,l=t.includeThreadInfo,d=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=i.GET,h.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:s,token:a,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_reply_type:o,include_parent_message_info:d,include_poll_details:!0},h}return r(t,e),t}(a),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return Mt(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return r(t,e),t}(o),Vt=function(e){function t(t){var n=t.channelUrl,r=t.scheduledMessageId,s=e.call(this)||this;return s.method=i.GET,s.path="".concat(W,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),s.params={},s}return r(t,e),t}(a),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o);!function(e){e.MUTED="muted",e.BANNED="banned"}(xt||(xt={}));var Wt=function(){function n(e){var t,n,r,i;this.restrictionType=null,f(xt,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(r=null!==(n=e.end_at)&&void 0!==n?n:e.muted_end_at)&&void 0!==r?r:-1,this.remainingDuration=null!==(i=e.remaining_duration)&&void 0!==i?i:-1}return n.payloadify=function(n){return e(t({restriction_type:n.restrictionType,description:n.description,end_at:n.endAt,remaining_duration:n.remainingDuration}))},n}(),Yt=function(n){function i(e,t){var r=n.call(this,e,t)||this;return r.restrictionInfo=new Wt(t),r}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),Wt.payloadify(r.restrictionInfo))))},i}(c),Jt=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return r(t,e),t}(c),Xt=function(){function e(){this._onPending=Y,this._onFailed=Y,this._onSucceeded=Y}return e.prototype._trigger=function(e){switch(null==e?void 0:e.sendingStatus){case k.PENDING:0===e.errorCode&&this._onPending(e);break;case k.SCHEDULED:case k.SUCCEEDED:this._onSucceeded(e)}},e.prototype._triggerFailed=function(e,t){switch(null==t?void 0:t.sendingStatus){case k.FAILED:case k.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}(),Zt={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},$t=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(Ke,e.metaArrays,!0)&&h("number",e.parentMessageId,!0)&&h("boolean",e.isReplyToChannel)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)&&h("boolean",e.isPinnedMessage,!0)},en=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},tn=u(u({},Zt),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function nn(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var rn,sn=function(n){var r;return e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,pollId:null===(r=n.poll)||void 0===r?void 0:r.id,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,message:n.message,translationTargetLanguages:Object.keys(n.translations),extendedMessagePayload:n.extendedMessagePayload}))},an=function(e){return $t(e)&&h("string",e.message)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)&&h("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(rn||(rn={}));var on=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},un=function(e){return e===rn.BLOB||e===rn.FILE},cn=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},ln=u(u({},Zt),{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,message:void 0});function dn(e){var n,r,i,s;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=e.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails,message:e.message}))}var hn,fn=function(n,r){var i;return n.messageParams?(!n.url&&G(r)&&(n.messageParams.file=r),n.messageParams):e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,file:r,fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,thumbnailSizes:null===(i=n.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),message:n.message}))},pn=function(e){return $t(e)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&h("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},mn={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},vn=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(Ke,e.metaArrays,!0)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)},yn=u(u({},mn),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),_n=function(e){return vn(e)&&h("string",e.message,!0)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)},gn=u({},mn),bn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.token,a=t.limit,o=e.call(this)||this;return o.method=i.GET,o.path="".concat(w(r),"/").concat(encodeURIComponent(n),"/operators"),o.params={token:s,limit:a},o}return r(t,e),t}(a),In=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new c(t,e)})),r.token=n.next,r}return r(t,e),t}(o),En=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=n.of(this._iid).requestQueue,r=new bn(u(u({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(r)]):[3,2]):[3,5];case 1:return i=c.sent(),s=i.as(In),a=s.operators,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),Tn=function(e){function n(t,n,r,i){var s,a,o,u,c,l,d,h,f,p,m=this;return(m=e.call(this,t,n,r,i)||this).reverse=!1,m.messageTypeFilter=x.ALL,m.customTypesFilter=null,m.senderUserIdsFilter=null,m.replyType=H.NONE,m.includeMetaArray=!1,m.includeReactions=!1,m.includeParentMessageInfo=!1,m.includeThreadInfo=!1,m.showSubchannelMessagesOnly=!1,m._edge=Number.MAX_SAFE_INTEGER,m.reverse=null!==(s=i.reverse)&&void 0!==s&&s,m.messageTypeFilter=null!==(a=i.messageTypeFilter)&&void 0!==a?a:x.ALL,m.customTypesFilter=null!==(o=i.customTypesFilter)&&void 0!==o?o:null,m.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,m.replyType=null!==(c=i.replyType)&&void 0!==c?c:H.NONE,m.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,m.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,m.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,m.includeThreadInfo=null!==(f=i.includeThreadInfo)&&void 0!==f&&f,m.showSubchannelMessagesOnly=null!==(p=i.showSubchannelMessagesOnly)&&void 0!==p&&p,m}return r(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.reverse)&&f(x,this.messageTypeFilter)&&f(H,this.replyType)&&d("string",this.customTypesFilter,!0)&&d("string",this.senderUserIdsFilter,!0)&&h("boolean",this.includeMetaArray)&&h("boolean",this.includeReactions)&&h("boolean",this.includeParentMessageInfo)&&h("boolean",this.includeThreadInfo)&&h("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,$s.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t({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=n.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 O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},n}(J),wn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.limit,o=t.token;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:o},n}return r(t,e),t}(a),Mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.mutedUsers=[];var i=n.next,s=n.muted_list;return r.token=i,s&&s.length>0&&(r.mutedUsers=s.map((function(e){return new Yt(t,e)}))),r}return r(t,e),t}(o),Sn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new wn(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Mn),s=i.mutedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),An=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.limit,u=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({limit:o,token:u}),r}return r(n,t),n}(a),Un=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map((function(e){return new Yt(t,e.user)}))),r}return r(t,e),t}(o),Nn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new An(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Un),s=i.bannedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(hn||(hn={}));var Cn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var On=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var Pn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return r(t,e),t}(a),kn=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,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return r(t,e),t}(o),Rn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return r(t,e),t}(a),xn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),Dn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return r(t,e),t}(a),Ln=function(e){function t(t,n){var r,i,s=this;return(s=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},s.ts=null!==(i=n.ts)&&void 0!==i?i:null,s}return r(t,e),t}(o),Fn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata,o=t.upsert;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=o&&o},n}return r(t,e),t}(a),qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),zn=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 r(t,e),t}(M),Bn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return r(t,e),t}(a),jn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),Kn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return r(t,e),t}(a),Qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),Gn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return r(t,e),t}(a),Vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Hn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return r(t,e),t}(a),Wn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Yn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter,o=t.upsert,u=void 0!==o&&o,c=t.mode,l=void 0===c?"set":c;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:u,mode:l},n}return r(t,e),t}(a),Jn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Xn=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 r(t,e),t}(M),Zn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params={},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var $n=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var er=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId,o=t.seconds,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:o,description:u},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var tr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),nr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var rr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ir=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.userId,u=n.seconds,c=n.description;return(r=t.call(this)||this).method=i.POST,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({user_id:o,seconds:u,description:c}),r}return r(n,t),n}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var sr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(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 r(t,e),t}(M),ar=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var or=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ur=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var cr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return r(t,e),t}(M),lr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(X(s),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:o,report_description:u},n}return r(t,e),t}(a),dr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.offendingUserId,c=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(Z,"/users/").concat(u),n.params={channel_url:r,channel_type:s===I.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:o,report_description:c},n}return r(t,e),t}(a),hr=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.category,u=n.userId,c=n.offendingUserId,l=n.messageId,d=n.description,h=n.messageToken;return(r=t.call(this)||this).method=i.POST,r.path="".concat(X(a),"/").concat(encodeURIComponent(s),"/messages/").concat(l),r.params=e({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),r}return r(n,t),n}(a),fr=function(n){function i(r){var i=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,poll_id:r.pollId,pin_message:r.isPinnedMessage,extended_message_payload:r.extendedMessagePayload}))})||this}return r(i,n),i}(T),pr=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"MESG",i)||this).message=new It(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),mr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,poll_id:r.pollId}))})||this}return r(i,n),i}(T),vr=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"MEDI",s)||this).message=new It(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),yr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,apple_critical_alert_options:r.appleCriticalAlertOptions}))})||this}return r(i,n),i}(T),_r=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"FEDI",s)||this).message=new St(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),gr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),br=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(n),r}return r(t,e),t}(o),Ir=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.DELETE,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),Er=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(u({},n)),r}return r(t,e),t}(o),Tr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.translationTargetLanguages,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s),"/translation"),o.params={target_langs:a},o}return r(t,e),t}(a),wr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Mr=function(n){function s(r){var s,a=this;a=n.call(this)||this;var o=[];r.mentionType===E.USERS&&(r.mentionedUserIds?o=r.mentionedUserIds:r.mentionedUsers&&(o=r.mentionedUsers.map((function(e){return e.userId}))));var u=r.channelType,c=r.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=e(t({req_id:r.reqId,scheduled_at:r.scheduledAt,message_type:ee.USER,message:r.message,custom_type:r.customType,data:r.data,mention_type:r.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=r.metaArrays)||void 0===s?void 0:s.map((function(e){return Ke.payloadify(e)})),apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption})),a}return r(s,n),s}(a),Sr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Ar=function(e){function n(n){var r,s,a=this;a=e.call(this)||this;var o=[];n.mentionType===E.USERS&&(n.mentionedUserIds?o=n.mentionedUserIds:n.mentionedUsers&&(o=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=t({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ee.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=n.metaArrays)||void 0===s?void 0:s.map((function(e){return Ke.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,push_option:n.pushNotificationDeliveryOption}),a}return r(n,e),n}(a),Ur=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new St(t,n),r}return r(t,e),t}(o),Nr=function(e){function t(t){var n=t.pollId,r=t.title,s=t.data,a=t.allowUserSuggestion,o=t.allowMultipleVotes,u=t.closeAt,c=e.call(this)||this;return c.method=i.PUT,c.path="".concat(ne,"/").concat(encodeURIComponent(n)),c.params={title:r,data:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return r(t,e),t}(a),Cr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Or=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.DELETE,r.path="".concat(ne,"/").concat(encodeURIComponent(n)),r}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var Pr=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.PUT,r.path="".concat(ne,"/").concat(encodeURIComponent(n),"/close"),r}return r(t,e),t}(a),kr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Rr=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.pollId,a=t.optionText,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(ne,"/").concat(encodeURIComponent(s),"/options"),o.params={channel_url:n,channel_type:r,text:a},o}return r(t,e),t}(a),xr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Dr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=t.optionText,a=e.call(this)||this;return a.method=i.PUT,a.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:s},a}return r(t,e),t}(a),Lr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Fr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=e.call(this)||this;return s.method=i.DELETE,s.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var qr=function(t){function n(n){var r=n.reqId,i=n.channelType,s=n.channelUrl,a=n.pollId,o=n.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:e({req_id:r,channel_type:i===I.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:a,option_ids:o})})||this}return r(n,t),n}(T),zr=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=new re(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return r(t,e),t}(M),Br=100,jr="GroupChannel",Kr="url",Qr=100,Gr="Message",Vr="messageId",Hr=100,Wr="NotificationMessage",Yr="notificationId",Jr="Poll",Xr="pollId",Zr=100,$r="FeedChannel",ei="url";function ti(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((function(e){var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))}var ni=u(u({},Zt),{fileInfoList:[],message:""}),ri=function(e){return(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},ii=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._onFileUploaded=Y,t}return r(t,e),t.prototype._triggerOnFileUploaded=function(e,t,n,r){this._onFileUploaded(e,t,n,r)},t.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},t.prototype.onPending=function(t){return e.prototype.onPending.call(this,t),this},t.prototype.onFailed=function(t){return e.prototype.onFailed.call(this,t),this},t.prototype.onSucceeded=function(t){return e.prototype.onSucceeded.call(this,t),this},t}(Xt),si=function(e){function t(t,n){var r=e.call(this,t)||this;return r.message=null,r.message=Mt(t,n.message),r}return r(t,e),t}(l),ai=function(t){function n(n){var r=this,s=n.channelType,a=n.channelUrl,o=n.limit,u=n.token,c=n.includeReactions,l=n.includeMetaArray,d=n.includeParentMessageInfo,h=n.includeThreadInfo,f=n.includePollDetails;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/pinned_messages"),r.params=e({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),r}return r(n,t),n}(a),oi=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.pinned_messages,s=n.has_more,a=n.next;return r.pinnedMessages=i.map((function(e){return new si(t,e)})),r.hasMore=s,r.token=a,r}return r(t,e),t}(o),ui=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s.includeMetaArray=i.includeMetaArray,s.includeReactions=i.includeReactions,s.includeParentMessageInfo=i.includeParentMessageInfo,s.includeThreadInfo=i.includeThreadInfo,s.includePollDetails=i.includePollDetails,s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.includeMetaArray,!0)&&h("boolean",this.includeReactions,!0)&&h("boolean",this.includeParentMessageInfo,!0)&&h("boolean",this.includeThreadInfo,!0)&&h("boolean",this.includePollDetails,!0)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new ai(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=c.sent(),i=r.as(oi),s=i.pinnedMessages,a=i.hasMore,o=i.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ci=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.POST,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var li=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.DELETE,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var di,hi=2;!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(di||(di={}));var fi,pi=function(i){function s(e,t){var n,r,s,a,o,u,l,d=this;return(d=i.call(this,e)||this)._name="",d._createdAt=0,d.pinnedMessageIds=[],d.channelType=I.BASE,d.coverUrl="",d.customType="",d.data="",d.isFrozen=!1,d.isEphemeral=!1,d.creator=null,d._messageCollectionLastAccessedAt=0,d._url=t.channel_url,d._name=null!==(n=t.name)&&void 0!==n?n:"",d._createdAt=1e3*t.created_at,d.coverUrl=null!==(r=t.cover_url)&&void 0!==r?r:"",d.customType=null!==(s=t.custom_type)&&void 0!==s?s:"",d.data=null!==(a=t.data)&&void 0!==a?a:"",d.isFrozen=null!==(o=t.freeze)&&void 0!==o&&o,d.isEphemeral=null!==(u=t.is_ephemeral)&&void 0!==u&&u,d.creator=t.created_by?new c(d._iid,t.created_by):null,t.metadata&&Object.keys(t.metadata).length>0&&t.ts?(d._cachedMetaData=new Map,Object.keys(t.metadata).forEach((function(e){d._cachedMetaData.set(e,{value:t.metadata[e],isRemoved:!1,updatedAt:t.ts})}))):"string"==typeof t.metadata&&(d._cachedMetaData=new Map(Object.entries(JSON.parse(t.metadata)))),d.pinnedMessageIds=null!==(l=t.pinned_message_ids)&&void 0!==l?l:[],d}return r(s,i),Object.defineProperty(s.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),s.prototype.toJSON=function(){return u(u({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},s.payloadify=function(n){return e(t(u(u({},i.payloadify.call(this,n)),{channel_url:n.url,name:n.name,cover_url:n.coverUrl,custom_type:n.customType,data:n.data,freeze:n.isFrozen,is_ephemeral:n.isEphemeral,created_by:n.creator?c.payloadify(n.creator):null,created_at:n.createdAt/1e3,metadata:n.cachedMetaData,pinned_message_ids:n.pinnedMessageIds})))},s.prototype.isGroupChannel=function(){return this.channelType===I.GROUP},s.prototype.isOpenChannel=function(){return this.channelType===I.OPEN},s.prototype.isFeedChannel=function(){return this.channelType===I.FEED},Object.defineProperty(s.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(s.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),s.prototype._serializeCachedMetaData=function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}},s.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},s.prototype._update=function(t){var n=e(t);Object.assign(this,n)},s.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})}))},s.prototype._updateCachedMetaData=function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(i,s){var a;i.updatedAt<=t&&(n._cachedMetaData.set(s,{value:null!==(a=e[s])&&void 0!==a?a:i.value,isRemoved:!e[s],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}},s.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0,message:t.message})),s=new Et(this._iid,i);return s.messageParams=t,s},s.prototype._validateFailedFileMessageHasFile=function(e,t){var n;return Boolean(e.url)||G(t)||G(null===(n=e.messageParams)||void 0===n?void 0:n.file)},s.prototype._createPendingScheduledFileMessage=function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r},s.prototype._markMessageAsFailed=function(e,t,n){void 0===n&&(n=!1),e.errorCode=t.code,t.code===P.REQUEST_CANCELED||t.code===P.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=k.CANCELED:n||(e.sendingStatus=k.FAILED)},s.prototype.sendUserMessage=function(e){var t=u(u({},tn),e);return D(an(t)).throw(O.invalidParameters),this._sendUserMessage(t)},s.prototype._sendUserMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,c=null!=r?r:this._generateRequestId(),l=Date.now(),d=new Xt;return Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l);a.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(r)]}))}))}));var s=new fr(u(u({},e),{channelUrl:i.url,channelType:i.channelType,reqId:c}));o.send(s).then((function(e){var t=e.as(pr).message;a.dispatch(new N({messages:[t],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(t)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l),s=n.of(i._iid).cacheContext,o=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,o),a.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._triggerFailed(t,r)]}))}))}))}))}))})),d},s.prototype._autoResendUserMessage=function(e){return D(e instanceof It&&!!e.messageParams).throw(O.invalidParameters),this._sendUserMessage(e.messageParams,di.SEND,e.reqId)},s.prototype.resendUserMessage=function(e){var t;return A(this,void 0,void 0,(function(){var n,r;return U(this,(function(i){return D(e instanceof It&&!e.scheduledInfo).throw(O.invalidParameters),n=new V,r=null!==(t=e.messageParams)&&void 0!==t?t:sn(e),this._sendUserMessage(r,di.RESEND,e.reqId).onFailed((function(e){return n.reject(e)})).onSucceeded((function(e){return n.resolve(e)})),[2,n.promise]}))}))},s.prototype.updateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},yn),t),D(h("number",e)&&_n(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new mr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(vr).message]}}))}))},s.prototype.copyUserMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof It&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),D(!n.poll).throw(O.notSupportedError),o=new V,c=null!==(r=n.messageParams)&&void 0!==r?r:t(u(u({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(a=n.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),e._sendUserMessage(c).onSucceeded((function(e){o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.translateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof It&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Tr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(wr).message]}}))}))},s.prototype._createScheduledUserMessage=function(e,t){var r=this,i=n.of(this._iid).requestQueue,s=Date.now(),a=this._generateRequestId();Q(2).then((function(){var n=r._createPendingScheduledUserMessage(e,a,s);ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))}));var o=new Mr(u({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(o).then((function(e){var n=e.as(Sr).message;ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var i=r._createPendingScheduledUserMessage(e,a,s);r._markMessageAsFailed(i,n),ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,i)]}))}))}))}))}))},s.prototype.sendFileMessage=function(e){var t=u(u({},ln),e);return D(pn(t)).throw(O.invalidParameters),this._sendFileMessage(t)},s.prototype.sendMultipleFilesMessage=function(e){var t,r=u(u({},ni),e),i=n.of(this._iid);D(function(e,t){return void 0===t&&(t=ie),$t(e)&&h("string",e.message,!0)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return ri(e)}))}(r,null===(t=i.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(O.invalidParameters);var s=!!e.fileInfoList.find((function(e){var t=i.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return D(!s).throw(O.fileSizeLimitExceededError),this._sendMultipleFilesMessage(r)},s.prototype._sendFileMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid).dispatcher,a=$s.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new Xt;return Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u);s.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(r)]}))}))})),a.request(i,o,e).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u),a=n.of(i._iid).cacheContext,l=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,l),s.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:t.code===P.FILE_UPLOAD_CANCEL_FAILED?C.LOCAL_MESSAGE_CANCELED:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,r)]}))}))}))}))}))})),c},s.prototype._autoResendFileMessage=function(e){D(e instanceof St&&!!e.messageParams).throw(O.invalidParameters);var t=n.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,di.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},s.prototype._sendMultipleFilesMessage=function(e,t,r){var i=this,s=n.of(this._iid).dispatcher,a=$s.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new ii;return Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);s.dispatch(new N({messages:[n],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(n)]}))}))})),a.request(i,o,e,{requestHandler:c,isCopy:t===di.COPY}).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);i._markMessageAsFailed(n,t),s.dispatch(new N({messages:[n],source:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,n)]}))}))}))}))}))})),c},s.prototype._createScheduledFileMessage=function(e,t,r,i){var s=this,a=n.of(this._iid).requestQueue,o=new Ar(u(u({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(Ur).message;ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var a=s._createPendingScheduledFileMessage(e,r,i);s._markMessageAsFailed(a,n),ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,a)]}))}))}))}))}))},s.prototype.sendFileMessages=function(e){var t,n;D(e.every((function(e){return pn(u(u({},ln),e))}))).throw(O.invalidParameters);var r=new Xt;try{for(var i=v(e),s=i.next();!s.done;s=i.next()){var a=s.value;this.sendFileMessage(a).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{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},s.prototype.resendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){return n=this._validateFailedFileMessageHasFile(e,t),D(e instanceof St&&n&&!e.scheduledInfo).throw(O.invalidParameters),r=new V,i=fn(e,t),this._sendFileMessage(i,di.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),[2,r.promise]}))}))},s.prototype.resendMessage=function(e,t){var n,r;if(D(e instanceof mt&&!e.scheduledInfo&&e.isResendable).throw(O.invalidParameters),e.isUserMessage()){var i=null!==(n=e.messageParams)&&void 0!==n?n:sn(e);return this._sendUserMessage(i,di.RESEND,e.reqId)}if(e.isFileMessage()){var s=this._validateFailedFileMessageHasFile(e,t);D(s).throw(O.invalidParameters);i=null!==(r=e.messageParams)&&void 0!==r?r:fn(e,t);return this._sendFileMessage(i,di.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.updateFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},gn),t),D(h("number",e)&&function(e){return vn(e)}(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new yr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(_r).message]}}))}))},s.prototype.uploadFile=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=n.of(this._iid).requestQueue,r=se(),(i=new Pe({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:r})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(r),[4,t.send(i)];case 1:return s=c.sent(),a=s.as(ke),o=a.url,u=a.thumbnails,[2,{requestId:r,url:o,thumbnails:u}]}}))}))},s.prototype.cancelUploadingFileMessage=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),$s.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},s.prototype.copyFileMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof St&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),o=new V,c=t(u(u({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=n.thumbnails)||void 0===a?void 0:a.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(c).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.copyMessage=function(e,t){D(e instanceof s&&t instanceof mt&&t.sendingStatus===k.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(O.invalidParameters);var n=t,r=e;if(n.isUserMessage()){D(!n.poll).throw(O.notSupportedError);var i=nn(n);return r._sendUserMessage(i)}if(n.isFileMessage()){i=dn(n);return r._sendFileMessage(i)}if(t.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.deleteMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(e instanceof pt).throw(O.invalidParameters),e.messageId>0?(t=n.of(this._iid).requestQueue,r=new de({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof mt?e._messageToken:void 0}),[4,t.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},s.prototype.addReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new gr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(br).reactionEvent]}}))}))},s.prototype.deleteReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Ir({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Er).reactionEvent]}}))}))},s.prototype._updateUserMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new mr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(vr).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype._updateFileMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new yr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(_r).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype.createMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new Ke({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},s.prototype.deleteMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new Ke({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},s.prototype.addMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof Ke}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},s.prototype.removeMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof Ke}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},s.prototype.report=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return D(f(hn,e)&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new lr({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:t}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.reportUser=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof c&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new dr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.userId,category:t,description:r}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.reportMessage=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof mt&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new hr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:t,description:r,messageToken:e._messageToken}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.updatePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(h("number",e)&&function(e){return h("string",e.title,!0)&&te(e.data)&&h("boolean",e.allowUserSuggestion,!0)&&h("boolean",e.allowMultipleVotes,!0)&&h("number",e.closeAt,!0)}(t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Nr(u({pollId:e},t)),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Cr).poll]}}))}))},s.prototype.deletePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i;return U(this,(function(s){switch(s.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Or({pollId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},s.prototype.closePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Pr({pollId:e}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(kr).poll]}}))}))},s.prototype.addPollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=h("number",e)&&h("string",t)&&""!==t.trim(),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Rr({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(xr).poll]}}))}))},s.prototype.updatePollOption=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return i=h("number",e)&&h("number",t)&&h("string",r)&&""!==r.trim(),D(i).throw(O.invalidParameters),s=n.of(this._iid).requestQueue,a=new Dr({pollId:e,pollOptionId:t,optionText:r}),[4,s.send(a)];case 1:return o=u.sent(),[2,o.as(Lr).poll]}}))}))},s.prototype.deletePollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return r=h("number",e)&&h("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Fr({pollId:e,pollOptionId:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},s.prototype.votePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a,o,u,c;return U(this,(function(l){switch(l.label){case 0:return r=h("number",e)&&d("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid),s=i.requestQueue,a=i.dispatcher,o=new qr({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(zr).event,a.dispatch(new he({event:c,source:C.EVENT_POLL_VOTED})),[2,c]}}))}))},s.prototype.getPollChangeLogsSinceTimestamp=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("number",e)).throw(O.invalidParameters),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.getPollChangeLogsSinceToken=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("string",e,!0)),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new ce(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},s.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new le(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},s.prototype.pinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new ci({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s.prototype.unpinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new li({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s}(l),mi=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 r(t,e),t}((function(){this.onConnected=Y,this.onReconnectStarted=Y,this.onReconnectSucceeded=Y,this.onReconnectFailed=Y,this.onDisconnected=Y})),vi=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 r(t,e),t}((function(){this.onSessionExpired=Y,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=Y,this.onSessionRefreshed=Y,this.onSessionClosed=Y})),yi=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 r(t,e),t}((function(){this.onFriendsDiscovered=Y,this.onTotalUnreadMessageCountChanged=Y,this.onTotalUnreadMessageCountUpdated=Y})),_i=function(t){function n(n){var r=n.limit,s=n.token,a=n.userIdsFilter,o=n.metaDataKeyFilter,u=n.metaDataValuesFilter,c=n.nicknameStartsWithFilter,l=t.call(this)||this;return l.method=i.GET,l.path=pe,l.params=e({limit:r,token:s,user_ids:a,metadatakey:o,metadatavalues_in:u,nickname_startswith:c}),l}return r(n,t),n}(a),gi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),bi=function(e){function i(t,n){var r,i,s,a=this;return(a=e.call(this,t,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)&&h("string",this.metaDataKeyFilter,!0)&&d("string",this.metaDataValuesFilter,!0)&&h("string",this.nicknameStartsWithFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new _i(t(u(u({},this),{token:this._token}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(gi),a=s.users,o=s.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),Ii=function(t){function n(n){var r=n.userId,s=n.limit,a=n.token,o=n.userIdsFilter,u=t.call(this)||this;return u.method=i.GET,u.path="".concat(pe,"/").concat(r,"/block"),u.params=e({limit:s,token:a,user_ids:o}),u}return r(n,t),n}(a),Ei=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Ti=function(e){function i(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Ii(t(u(u({},this),{userId:r.userId,token:this._token}))),[4,i.send(s)]):[3,2]:[3,5];case 1:return a=d.sent(),o=a.as(Ei),c=o.users,l=o.next,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,c];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),wi=function(e){function t(t){var n=t.userId,r=t.limit,s=t.token,a=e.call(this)||this;return a.method=i.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(n),"/friends"),a.params={limit:r,token:s},a}return r(t,e),t}(a),Mi=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 c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Si=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),t=e.sdkState,r=e.requestQueue,i=new wi(u(u({},this),{userId:t.userId,token:this._token})),[4,r.send(i)]):[3,2]:[3,5];case 1:return s=d.sent(),a=s.as(Mi),o=a.users,c=a.hasMore,l=a.next,this._token=l,this._hasNext=c,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(me),Ai={},Ui=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,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,d=void 0===l?11:l,h=e.transactionApplyDelay,f=void 0===h?200:h,p=e.disableLogger,m=void 0!==p&&p;return Ai[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=c,this.blockHashConstant=d,this.transactionApplyDelay=f,this.disableLogger=m,Ai[t]=this),Ai[t]}return e.get=function(e){return Ai[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_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"}(fi||(fi={}));var Ni,Ci=function(e){function t(n){var r=n.code,i=void 0===r?fi.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 r(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:fi.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.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:fi.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:fi.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:fi.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:fi.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:fi.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:fi.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:fi.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:fi.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:fi.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:fi.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"}(Ni||(Ni={}));var Oi,Pi=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Ci.circularReferenceFound;var n;return t.set(e,!0),Array.isArray(e)?n=e.map((function(e){return Pi(e,t)})):e instanceof RegExp||e instanceof Date?n=e:(n={},Object.keys(e).forEach((function(r){n[r]=Pi(e[r],t)}))),t.delete(e),n}return e},ki=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Ci.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Ri=function(e,t){for(var n=0,r=0;r>>0)%t},xi=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Di=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!Di(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Di(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(!(ki(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(ki(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(ki(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(ki(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)},Li=function(){},Fi=function(){return Promise.resolve()},qi=function(e){return e},zi=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Oi||(Oi={}));var Bi,ji,Ki,Qi=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?qi:a,u=e.backward,c=void 0===u?Fi:u,l=e.forward,d=void 0===l?Fi:l,h=e.complete,f=void 0===h?Li:h;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=c,this._forward=d,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 A(this,void 0,void 0,(function(){var e,t,n;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(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}(),Gi=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(h=0;h0?n:t;for(var o in this.condition[i])if(a.includes(o))for(var u=r;u>=0;u--)if(s*ki(this._indexer.origin[u].columnValues[h],this.condition[i][o])<=0){r=u;break}}else for(u=r;u>=0;u--)if(s*ki(this._indexer.origin[u].columnValues[h],this.condition[i])<=0){r=u;break}}return Math.min(r+1,this._indexer.origin.length-1)}var c=0;if("function"!=typeof this.condition)for(var l=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=c;o=0){c=o;break}}));else for(var a=c;a=0){c=a;break}},d=this,h=0;h-1){var r=this._items[n];return t===Ki.PERSISTENT&&(r.state=ji.PERSISTENT),t!==Ki.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)ts.includes(this._items[r].state)&&ts.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 i=this._items.filter((function(e){return e.state===ji.VOLATILE})),s=i.length-this._limit;if(s>0){var a=[];try{for(var o=v(this._items),u=o.next();!u.done;u=o.next()){var c=u.value;c.state===ji.VOLATILE&&s>0?s--:a.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this._items=a}}}},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.clearForDatabase=function(e){this.clearByCondition((function(t){return t.key.startsWith(Hi(e))}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==ji.VOLATILE}))},e}(),is=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(Wi(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(Wi(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=[]),A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,p([],m(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],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,c,l,d;return U(this,(function(h){switch(h.label){case 0:n=rs.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return u(u({},e.data),{generation:r})})))];case 2:for(a=h.sent(),o=0;o0))return[3,4];for(t=[],n={},o=e.length-1;o>=0;o--)r=e[o],l=r.data,n[l.key]||(n[l.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=p.sent(),[4,this._store.set({key:this.recordsetKey,value:s})];case 2:return p.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(p.sent(),a=rs.get(this.dbname),o=0;o0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=a.sent())&&(s=ss.createFromCacheItem(i),null==s?void 0:s.getItemByKey(e)))return[2,s];a.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return n=Ui.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,rs.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(null==(a=s?ss.createFromCacheItem(s):new ss({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:a.add(t))?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(this,(function(r){switch(r.label){case 0:return e=Ji(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(),rs.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),os=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 u=function(e,t,n){return"".concat(Wi(e,t),"/index.").concat(n)}(t,n,i.join(">"));this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=u,this._store=a,this._transaction=s,this._transaction.on(Bi.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Bi.ERROR,this.indexerKey,(function(){return o.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=m(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=m(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var a=v(this.fields),o=a.next();!o.done;o=a.next()){var u=o.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw Ci.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=ki(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 A(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,y;return U(this,(function(_){switch(_.label){case 0:return[4,(e=rs.get(this.dbname)).find(this._store,this.indexerKey,Ki.PERSISTENT)];case 1:return(t=_.sent())?[3,11]:(n=Ji(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=_.sent(),_.label=3;case 3:_.trys.push([3,8,9,10]),i=v(r),s=i.next(),_.label=4;case 4:return s.done?[3,7]:(a=s.value).startsWith(n)?[4,e.find(this._store,a,Ki.NO_CACHE)]:[3,6];case 5:if(o=_.sent(),u=ss.createFromCacheItem(o))try{for(m=void 0,c=v(u.items),l=c.next();!l.done;l=c.next())d=l.value,this._addItem(d)}catch(e){m={error:e}}finally{try{l&&!l.done&&(y=c.return)&&y.call(c)}finally{if(m)throw m.error}}_.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return h=_.sent(),f={error:h},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=Pi(this._origin),_.label=12;case 12:return[2]}}))}))},e.prototype.drop=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return rs.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.addItem=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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=Pi(this._origin)},e.prototype.abort=function(){this._table=Pi(this._origin)},e}(),us=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},cs=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"}($i||($i={})),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"}(es||(es={}));var ls,ds={},hs=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=$i.PROCESSING,this._queue=[],this._activationQueue=[],ds[e]&&!t.forceCreate||(this.nodeId=cs(),this.key=e,us()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data;if(null==i?void 0:i.isNestDbMessage){var s=i.nodeId,a=i.requestId,o=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&o===n.key)switch(u){case es.NEWNODE:n._sendSync();break;case es.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case es.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,d=l.currentItemRequestId,h=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:es.REQUEST_LOCK,ts:e.ts})};try{for(var p=v(h),m=p.next();!m.done;m=p.next()){f(m.value)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case es.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case es.REQUEST_LOCK:n._requestLock(i);break;case es.ACQUIRE_LOCK:var y=n._queue.find((function(e){return e.requestId===a}));n._acquire(y);break;case es.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(es.REMOVENODE)}))),ds[e]=this),ds[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==$i.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:cs(),key:this.key,op:e,data:t.data,ts:Date.now()};return us()&&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(es.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){for(var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(es.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},i=!1,s=0;sr.ts){t._queue.splice(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(es.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 A(this,void 0,void 0,(function(){var e=this;return U(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=$i.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(es.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(es.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(es.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}(),fs=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=Ni.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=p([[r]],m(s.filter((function(e){return os.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new hs(function(e,t){return"".concat(Wi(e,t),".lock")}(t,n)),this._blobContainer=new Zi({dbname:t,collectionName:n,store:a}),this._transaction=new is({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return r=Yi(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===Ni.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,y,_=this;return U(this,(function(g){switch(g.label){case 0:return[4,this._mutex.lock()];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,9,,10]),t=Ui.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=g.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:g.sent(),this._blockManager=new as({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=p([],m(this.indexes),!1),i=[],s=r.map((function(e){return os.createKey(e)})),a=n?n.indexes.map((function(e){return os.createKey(e)})):[];try{for(o=v(a),u=o.next();!u.done;u=o.next())c=u.value,s.includes(c)||i.push(os.parseKey(c))}catch(e){f={error:e}}finally{try{u&&!u.done&&(y=o.return)&&y.call(o)}finally{if(f)throw f.error}}return(l=[]).push.apply(l,p([],m(r.map((function(e){var t=new os({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,p([],m(i.map((function(e){return new os({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return g.sent(),[4,this._transaction.commit()];case 6:return g.sent(),s.sort().join(",")===a.sort().join(",")?[3,8]:(d=Yi(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:d,value:this._metadata})]);case 7:g.sent(),g.label=8;case 8:return this._state=Ni.READY,this._mutex.unlock(),[3,10];case 9:throw h=g.sent(),this._mutex.unlock(),h;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Ni.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=os.createKey(e);try{for(var i=v(this._indexers),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===os.createKey(a.fields))return a}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw Ci.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return e=Yi(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return o.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return o.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return o.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:o.sent(),o.label=5;case 5:o.trys.push([5,10,11,12]),n=v(this._indexers),r=n.next(),o.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:o.sent(),o.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=o.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw Ci.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=v(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),a=v(this._indexers),o=a.next(),p.label=16;case 16:return o.done?[3,20]:0===(u=o.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return o=a.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),h={error:c},[3,23];case 22:try{o&&!o.done&&(f=a.return)&&f.call(a)}finally{if(h)throw h.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=v(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return a=c.sent(),o={error:a},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=o.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:o.sent(),o.label=3;case 3:o.trys.push([3,8,9,10]),n=v(this._indexers),r=n.next(),o.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:o.sent(),o.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=o.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return U(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=v(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(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,Pi(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Ci.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new Vi({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ci.collectionNotReady},e.prototype.insertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestInsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpdate(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p,m,y=this;return U(this,(function(_){switch(_.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:_.sent(),_.label=2;case 2:return _.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,a=e.backward,o=void 0!==a&&a,u=[],[4,new Gi({condition:r,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(s)}).each((function(e){return A(y,void 0,void 0,(function(){var n;return U(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(n=e.nextValue,Di(r,n)&&t.set&&("function"!=typeof t.set?Object.keys(t.set).forEach((function(e){var r;n[e]=null===(r=t.set)||void 0===r?void 0:r[e]})):t.set(n),u.push(n)),e.next()):e.stop(),[2]}))}))}))];case 3:_.sent(),_.label=4;case 4:_.trys.push([4,9,10,11]),c=v(u),l=c.next(),_.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestUpdate(Pi(d))]);case 6:_.sent(),_.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return h=_.sent(),p={error:h},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return _.sent(),this._mutex.unlock(),[2,u];case 13:return f=_.sent(),[4,this._transaction.clear()];case 14:throw _.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),Ci.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m=this;return U(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,a=void 0!==s&&s,o=[],[4,new Gi({condition:n,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(i)}).each((function(e){return A(m,void 0,void 0,(function(){var t,r;return U(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Di(n,t)&&(r=t[this.keyName],o.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=v(o),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return d=y.sent(),f={error:d},[3,11];case 10:try{c&&!c.done&&(p=u.return)&&p.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,o];case 13:throw h=y.sent(),this._mutex.unlock(),h;case 14:return[3,16];case 15:throw this._transaction.clear(),Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),ps="[NESTDB]",ms=!0,vs=function(){function e(){}return e.off=function(){ms=!1},e.log=function(){for(var e=[],t=0;t1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return A(o,void 0,void 0,(function(){var n,i;return U(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw Ci.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}}))}))})))]:[3,4];case 3:return a=u.sent(),[3,5];case 4:a=[r],u.label=5;case 5:return s=a,[2,this.encryption.decrypt(JSON.parse(s.join("")))];case 6:return u.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,u({},e.value)]}}))}))},e.prototype.setMany=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,p([],m(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a=this;return U(this,(function(o){switch(o.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=o.sent())?(r=n.metadata,i=this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return a._getRawKey(e,".".concat(t))})),[4,this._removeRaw(i)]):[3,3];case 2:return o.sent(),null==(s=rs.get(this.dbname))||s.remove(e),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d=this;return U(this,(function(h){switch(h.label){case 0:t=rs.get(this.dbname),n=[],r=function(e){var r,s,a;return U(this,(function(o){switch(o.label){case 0:return r=i._getRawKey(e,".0"),[4,i._getRaw(r)];case 1:return(s=o.sent())&&(a=s.metadata,n.push.apply(n,p([],m(i._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return d._getRawKey(e,".".concat(t))}))),!1))),null==t||t.remove(e),[2]}}))},i=this,h.label=1;case 1:h.trys.push([1,6,7,8]),s=v(e),a=s.next(),h.label=2;case 2:return a.done?[3,5]:(o=a.value,[5,r(o)]);case 3:h.sent(),h.label=4;case 4:return a=s.next(),[3,2];case 5:return[3,8];case 6:return u=h.sent(),c={error:u},[3,8];case 7:try{a&&!a.done&&(l=s.return)&&l.call(s)}finally{if(c)throw c.error}return[7];case 8:return n.length>0?[4,this._removeRaw(n)]:[3,10];case 9:h.sent(),h.label=10;case 10:return[2,e]}}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){return null==(e=rs.get(this.dbname))||e.clearForDatabase(this.dbname),[2]}))}))},e}(),gs={},bs=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,u(u({},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 r(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return gs[this.dbname]},set:function(e){gs[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(gs[this.dbname])return[2,Object.keys(gs[this.dbname])];throw Ci.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return gs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:return t.sent(),[2,gs[this.dbname][e]?u({key:e},gs[this.dbname][e]):null];case 2:throw Ci.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return gs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:c.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,s=r.data,a=r.metadata,gs[this.dbname][i]=Object.freeze({data:s,metadata:a})}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}}return[3,3];case 2:throw Ci.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return gs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:a.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,gs[this.dbname][r]&&delete gs[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw Ci.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 A(this,void 0,void 0,(function(){return U(this,(function(e){return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,gs[this.dbname]||(gs[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.set=function(t){return A(this,void 0,void 0,(function(){var n,r;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u;return U(this,(function(c){try{for(n=v(t),r=n.next();!r.done;r=n.next())if(i=r.value,(s=this.observer[i.key])&&"function"==typeof s.set&&(a=s.set()))throw a}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return t.sent(),[4,xi(this.delay)];case 2:return t.sent(),gs[this.dbname]={},[2]}}))}))},t}(_s),Is="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(ls||(ls={}));var Es,Ts=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=Is,r._state=ls.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 r(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype.isTransactionInactiveError=function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")},t.prototype._putToObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.put(t);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))]}))}))},t.prototype._deleteFromObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.delete(t);i.addEventListener("success",(function(){return n(t)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))]}))}))},t.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=ls.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Is,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=ls.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=ls.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=ls.UNINITIALIZED,r(e.target.error)}))}else r(Ci.storeNotAvailable)}))},t.prototype._getObjectStore=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 ls.UNINITIALIZED:case ls.OPEN:return[3,2];case ls.OPENING:case ls.CLOSED:return[3,3]}return[3,4];case 2:throw Ci.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 A(this,void 0,void 0,(function(){var e;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._putToObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._putToObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._deleteFromObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._deleteFromObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){var e,t=this;return U(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||!us())return[3,4];if(!(us()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Ci.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(Ci.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),t._indexedDb){var i=t._indexedDb.deleteDatabase("_testMozilla");i.onerror=function(){return e()},i.onsuccess=function(){return e()}}else n(Ci.storeNotAvailable)}}catch(e){n(Ci.storeNotAvailableInPrivateBrowsing)}else n(Ci.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Ci.storeNotAvailable;case 5:return[3,7];case 6:throw Ci.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(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(),[4,this._resetIfEncryptionChanged()];case 3:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this._getObjectStore("readwrite")];case 2:return t=n.sent(),[4,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 3:return[2,n.sent()]}}))}))},t}(_s),ws=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?2097152:i,a=ye(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,u(u({},a),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:t=[];try{for(n=v(e),r=n.next();!r.done;r=n.next())i=r.value,s=i.key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(s),JSON.stringify(i)])}catch(e){a={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return u.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._asyncStorage)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}}))}))},t}(_s),Ms=function(e){function t(t){var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._mmkv)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}}))}))},t}(_s);!function(e){e.INIT="INIT",e.OPENING="OPENING",e.OPENED="OPENED",e.CLOSED="CLOSED"}(Es||(Es={}));var Ss,As=function(){function e(e){var t=e.name,n=e.version,r=e.store,i=e.config;this.name=t,this._version=n,this._state=Es.INIT,this._config=i||new Ui({dbname:t}),this._store=r,this._event={success:Li,error:Li,storeReplaced:Li,upgrade:zi},this._collections=new Map,this._globalMutex=new hs("".concat(this.name,".lock")),this._config.disableLogger&&vs.off(),new rs({dbname:t,limit:this._config.cacheLimit})}return Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),e.prototype.estimateUsage=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,(t=this._store,A(void 0,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,t.usage()];case 1:return[2,e.sent()]}}))})))];case 1:return[2,e.sent()]}var t}))}))},e.prototype.commitSchema=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this._state!==Es.OPENING?[3,2]:[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=e.collectionName,n=e.keyName,r=e.index,i=void 0===r?[]:r,this._collections.has(t)||this._collections.set(t,new fs({dbname:this.name,collectionName:t,keyName:n,indexes:i,store:this._store})),(s=this._collections.get(t))?[4,s.init()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[3,3];case 2:throw Ci.databaseSchemaNotOnUpgrade;case 3:return[2]}}))}))},e.prototype.open=function(){var e;return A(this,void 0,void 0,(function(){var t,n,r,i,s=this;return U(this,(function(a){switch(a.label){case 0:return[4,this._globalMutex.lock()];case 1:if(a.sent(),this._state===Es.OPENED)return[3,12];this._state=Es.OPENING,a.label=2;case 2:return a.trys.push([2,5,,12]),[4,this._store.init(this.name)];case 3:return a.sent(),o=this.name,t="".concat(Hi(o),".metadata"),n={version:0,collectionNames:[]},[4,this._store.get(t)];case 4:return r=null!==(e=a.sent())&&void 0!==e?e:n,[2,new Promise((function(e,n){var i=function(e){r.version0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof mt))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof pt)switch(this.replyType){case H.NONE:if(e.parentMessageId>0)return!1;break;case H.ONLY_REPLY_TO_CHANNEL:if(e instanceof mt&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Us||(Us={}));var Os,Ps=function(e){switch(e){case Us.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Us.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},ks=function(){return["channelUrl","-createdAt","-notificationId"]},Rs=u(u({},tn),{scheduledAt:void 0}),xs=function(e){return an(e)&&h("number",e.scheduledAt,!0)},Ds=u(u({},Zt),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ls=function(e){return $t(e)&&h("number",e.scheduledAt)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Fs="UnsentMessage",qs="reqId",zs={},Bs=function(t){function i(e){var n=t.call(this,e)||this;return n._mutex=new hs("unsendmessagecache.lock"),zs[e]=n,n}return r(i,t),Object.defineProperty(i.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),i.of=function(e,t){return void 0===t&&(t=!1),zs[e]&&!t||(zs[e]=new i(e)),zs[e]},Object.defineProperty(i.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Fs);if(!t)throw O.databaseError;return t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),i.prototype._serialize=function(t){if(t.messageId>0)throw O.invalidParameters;var n,r=u({},t.serialize());return t instanceof It?(t.messageParams&&(r.messageParams=en(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=(n=t.scheduledInfo.scheduledMessageParams,u(u({},en(n)),{scheduledAt:n.scheduledAt})))):t instanceof St?(t.messageParams&&(r.messageParams=cn(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=function(e){return u(u({},cn(e)),{scheduledAt:e.scheduledAt})}(t.scheduledInfo.scheduledMessageParams))):t instanceof Et&&t.messageParams&&(r.messageParams=function(t){return e({fileInfoList:t.fileInfoList,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption})}(t.messageParams)),r},i.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),$s.of(this._iid).buildMessageFromSerializedData(e)},i.prototype._deserializeWithMessageCreateParams=function(e){var t,n,r;return A(this,void 0,void 0,(function(){var i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return i=$s.of(this._iid),s=this._deserialize(e),e.messageParams?s instanceof It?(o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),[3,6]):[3,1]:[3,6];case 1:return s instanceof St?(o=e.messageParams).fileKey&&"string"==typeof o.fileKey&&un(null!==(t=o.fileType)&&void 0!==t?t:"")?(a=o,[4,this.collection.getBlob(o.fileKey)]):[3,3]:[3,4];case 2:a.file=null!==(n=d.sent())&&void 0!==n?n:void 0,d.label=3;case 3:return s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(o,s),[3,6];case 4:return s instanceof Et&&((o=e.messageParams)&&o.fileInfoList)?(s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(o,s),[4,Promise.all(s.messageParams.fileInfoList.map((function(e){return A(l,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&un(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!==(s=a.sent())&&void 0!==s?s:void 0,a.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:d.sent(),d.label=6;case 6:return s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?s instanceof It?(u=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(u,s),[3,10]):[3,7]:[3,10];case 7:return s instanceof St?(u=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof u.fileKey&&"string"==typeof u.fileType&&un(u.fileType)?(c=u,[4,this.collection.getBlob(u.fileKey)]):[3,9]:[3,10];case 8:c.file=null!==(r=d.sent())&&void 0!==r?r:void 0,d.label=9;case 9:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(u,s),d.label=10;case 10:return[2,s]}}))}))},i.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},i.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new Cs:n,i=e.order,s=void 0===i?Us.CHANNEL_LATEST:i,a=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return A(this,void 0,void 0,(function(){var e,n,i,o,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?(e=Ps(s),n={"/where":function(e){return!!(s!==Us.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(l._deserialize(e))}},t&&(n.channelUrl=t),a&&(n.sendingStatus=a),i={where:n,index:e,backward:u},[4,this.collection.query(i)]):[3,3];case 1:return[4,d.sent().fetch({})];case 2:return o=d.sent(),[2,Promise.all(o.map((function(e){return A(l,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},i.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Cs),A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:Us.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},i.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return e instanceof St||e instanceof Et?[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]}}))}))},i.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},i.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.saveBlob=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i=this;return U(this,(function(s){switch(s.label){case 0:return e instanceof St?e.messageParams&&(r=e.messageParams).file&&on(r.file)?[4,this.collection.saveBlob(r.file,e.reqId)]:[3,2]:[3,5];case 1:n=s.sent(),r.fileKey=n,r.fileType=rn.BLOB,s.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&on(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=s.sent(),t.fileKey=n,t.fileType=rn.BLOB,s.label=4;case 4:return[3,7];case 5:return e instanceof Et&&((r=e.messageParams)&&r.fileInfoList&&Array.isArray(r.fileInfoList))?[4,Promise.all(r.fileInfoList.map((function(t,n){return A(i,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return t.file&&on(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=rn.BLOB,i.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},i}(l),js={},Ks=function(e){function t(t){var n=e.call(this,t)||this;return js[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Bs.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),js[e]&&!n||(js[e]=new t(e)),js[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Gr)},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 u(u({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),$s.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Cs:s,o=e.order,u=void 0===o?Us.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,d=e.parentMessageId,h=e.isPollOnly,f=void 0!==h&&h,p=e.exactMatch,m=void 0!==p&&p,v=e.inclusive,y=void 0===v||v;return A(this,void 0,void 0,(function(){var e,r,s,o=this;return U(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=Ps(u),r={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Us.CHANNEL_LATEST:if(m&&e.createdAt!==n)return!1;if(l){if(y&&e.createdAtn||!y&&e.createdAt>=n)return!1;break;case Us.NEWEST_CHILD_MESSAGE:if(!d||0===e.parentMessageId||e.parentMessageId!==d)return!1}return!(f&&!e._poll)&&a.match(o._deserialize(e))}},index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({limit:null!=i?i:void 0})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return A(o,void 0,void 0,(function(){return U(this,(function(t){return[2,this._deserialize(e)]}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Cs),A(this,void 0,void 0,(function(){return U(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:Us.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,13];case 1:d.sent(),d.label=2;case 2:d.trys.push([2,7,8,9]),n=v(e),r=n.next(),d.label=3;case 3:return r.done?[3,6]:(i=r.value,(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)?[4,this.get(i.messageId)]:[3,5]);case 4:(null==(s=d.sent())?void 0:s.threadInfo)&&i.threadInfo._updateFrom(s.threadInfo),d.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return a=d.sent(),u={error:a},[3,9];case 8:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 9:return o=e.map((function(e){return l._serialize(e)})),[4,this.collection.upsertMany(o)];case 10:return d.sent(),[4,this.upsertChildMessages(e)];case 11:return d.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 12:d.sent(),d.label=13;case 13:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:Ps(Us.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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:Ps(Us.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=Ps(Us.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 A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return e instanceof St&&e.messageParams&&((t=e.messageParams).file&&on(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.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=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return s=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return a=o.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),s&&(t+=JSON.stringify(s).length),a&&(t+=JSON.stringify(a).length),[2,t]}}))}))},t}(l),Qs={},Gs=function(e){function t(t){var n=e.call(this,t)||this;return Qs[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),Qs[e]&&!n||(Qs[e]=new t(e)),Qs[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Wr)},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 u({},e.serialize())},t.prototype._deserialize=function(e){return $s.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Cs:s,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,d=e.inclusive,h=void 0===d||d;return A(this,void 0,void 0,(function(){var e,r=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(e={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(h&&e.createdAtn||!h&&e.createdAt>=n)return!1}return a.match(r._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},[4,this.collection.query(e)]):[3,3];case 1:return[4,s.sent().fetch({limit:null!=i?i:void 0})];case 2:return[2,s.sent().map((function(e){return r._deserialize(e)}))];case 3:return[2,[]]}}))}))},t.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?(t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.markAsReadByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,messageStatus:ft.SENT,createdAt:{"<":t}}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.markAsReadByMessageIds=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:ft.SENT}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:return[2,n.sent().length];case 2:return[2,0]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]})]:[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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:Ps(Us.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=["channelUrl","-createdAt","-notificationId"],[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}(l),Vs={},Hs=function(e){function t(t){var n=e.call(this,t)||this;return n._observers=new Map,n._dispatcherContext=n._dispatcher.on((function(e){return A(n,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,v,y,_,g,b=this;return U(this,(function(E){switch(E.label){case 0:return e instanceof N?(t=e.messages,g=e.source,a=e.isWebSocketEventComing,n=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&e.messageId>0})),r=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&0===e.messageId})),i=t.filter((function(e){return e instanceof Tt})),n.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(n)];case 1:return e.sent(),[4,this._unsentMessageCache.remove(n.map((function(e){return e instanceof mt?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,7];case 1:E.sent(),a||this._broadcastUpdateEvent(n,g),E.label=2;case 2:return r.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.upsert(r)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:E.sent(),a||this._broadcastUpdateEvent(r,g),E.label=4;case 4:return i.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._notificationCache.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,6];case 5:E.sent(),a||this._broadcastUpdateEvent(i,g),E.label=6;case 6:return[3,24];case 7:return e instanceof we?(s=e.messageIds,g=e.source,a=e.isWebSocketEventComing,o=s.filter((function(e){return"number"==typeof e})),u=s.filter((function(e){return"string"==typeof e})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return o.length>0?[4,this._messageCache.remove(o)]:[3,2];case 1:e.sent(),e.label=2;case 2:return u.length>0?[4,this._notificationCache.remove(u)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))}))]):[3,9];case 8:return E.sent(),a||this._broadcastRemoveEvent(s,g),[3,24];case 9:return e instanceof Te?(c=e.reqId,g=e.source,[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.remove([c])];case 1:return e.sent(),[2]}}))}))}))]):[3,11];case 10:return E.sent(),this._broadcastRemoveUnsentEvent(c,g),[3,24];case 11:return e instanceof Ee?(l=e.polls,g=e.source,this._cacheContext.localCacheEnabled?(d=l.map((function(e){return e.messageId})),[4,Promise.all(d.map((function(e){return b._messageCache.get(e)})))]):[3,14]):[3,15];case 12:return(h=E.sent().filter((function(e){return e}))).length>0&&l.forEach((function(e){var t=h.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(h)];case 1:return[2,e.sent()]}}))}))}))];case 13:E.sent(),E.label=14;case 14:return this._broadcastPollChangeLogEvent(l,g),[3,24];case 15:return e instanceof Ie?(f=e.event,g=e.source,[4,this._messageCache.get(f.messageId)]):[3,19];case 16:return(p=E.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollUpdateEvent(f)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([p])];case 1:return[2,e.sent()]}}))}))}))]:[3,18];case 17:E.sent(),E.label=18;case 18:return this._broadcastPollUpdateEvent(f,g),[3,24];case 19:return e instanceof he?(m=e.event,g=e.source,[4,this._messageCache.get(m.messageId)]):[3,23];case 20:return(v=E.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(m)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,22];case 21:E.sent(),E.label=22;case 22:return this._broadcastPollVoteEvent(m,g),[3,24];case 23:e instanceof _e?(y=e.event,g=e.source,y.messageId>0&&this._broadcastReactionUpdateEvent(y,g)):e instanceof ge&&(_=e.event,g=e.source,this._broadcastThreadUpdateEvent(_,g)),E.label=24;case 24:return[2]}}))}))})),n}return r(t,e),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dispatcher",{get:function(){return n.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_messageCache",{get:function(){return Ks.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Bs.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_notificationCache",{get:function(){return Gs.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){var r;return void 0===n&&(n=!1),Vs[e]&&!n||(Vs[e]&&(null===(r=Vs[e]._dispatcherContext)||void 0===r||r.close()),Vs[e]=new t(e)),Vs[e]},t.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemove&&a.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastReactionUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastThreadUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype.subscribe=function(e,t){this._observers.set(e,t)},t.prototype.unsubscribe=function(e){this._observers.delete(e)},t.prototype.unsubscribeAll=function(){this._observers.clear()},t}(l),Ws=function(t){function n(n){var r=this,s=n.reverse,a=void 0!==s&&s,o=n.limit,u=void 0===o?20:o,c=n.keys,l=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(Me),r.params=e({token:l,limit:u,reverse:a,order:Se.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),r}return r(n,t),n}(a),Ys=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.next,s=n.has_more,a=void 0!==s&&s,o=n.templates;return r.nextToken=i,r.hasMore=a,r.templates=o.map((function(e){return{template:JSON.stringify(e)}})),r}return r(t,e),t}(o),Js=function(e){function t(t){var n=this,r=t.key;return(n=e.call(this)||this).method=i.GET,n.path="".concat(Me,"/").concat(r),n}return r(t,e),t}(a),Xs=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.template=JSON.stringify(n),r}return r(t,e),t}(o),Zs={},$s=function(){function n(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=a,Ks.of(e),Bs.of(e),Hs.of(e),this.fileMessageQueue=new Rt(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),Zs[e]=this}return n.of=function(e){return Zs[e]},n.prototype.buildMessageFromSerializedData=function(e){var t=Ae(e);if(t.notificationId)return new Tt(this._iid,Tt.payloadify(t));switch(t.messageType){case g.USER:return new It(this._iid,It.payloadify(t));case g.FILE:return Et._isMultipleFilesMessageSerializedData(t)?new Et(this._iid,Et.payloadify(t)):new St(this._iid,St.payloadify(t));case g.ADMIN:return new _t(this._iid,_t.payloadify(t))}throw O.invalidParameters},n.prototype.buildUserMessageCreateParamsFromSerializedData=function(n,r){return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,message:r.message,translationTargetLanguages:Object.keys(r.translations),pollId:n.pollId}))},n.prototype.buildFileMessageCreateParamsFromSerializedData=function(n,r){var i;return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,file:n.file,fileKey:n.fileKey,fileUrl:r.plainUrl,fileName:r.name,fileSize:r.size,mimeType:r.type,thumbnailSizes:null===(i=r.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:n.fileType,requireAuth:r.requireAuth}))},n.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(t,n){var r=this;return e({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUserIds:n.mentionedUserIds,mentionedUsers:n.mentionedUsers,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption,appleCriticalAlertOptions:n.appleCriticalAlertOptions,reqId:n.reqId,fileInfoList:t.fileInfoList.map((function(e){return new At(r._iid,e)}))})},n.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildSenderFromSerializedData=function(e){var t=Ae(e);return new je(this._iid,je.payloadify(t))},n.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new zt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Bt).message]}}))}))},n.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Vt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Ht).message]}}))}))},n.prototype.getMessagesByMessageId=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new jt(u(u({channelType:t,channelUrl:e,token:String(n)},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(Kt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype.getMessagesByTimestamp=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new jt(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(Kt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype._getMessagesByTimestampForCollection=function(e,t,n,r,i,s,a){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var o,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return o=new jt(u(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r),{checkingHasNext:s,checkingContinuousMessages:a})),[4,this._requestQueue.send(o)];case 1:return c=p.sent(),l=c.as(Kt),d=l.messages,h=l.isContinuousMessages,f=l.hasNext,this._dispatcher.dispatch(new N({messages:d,source:i})),[2,{messages:d,isContinuousMessages:h,hasNext:f}]}}))}))},n.prototype.getThreadedMessagesByTimestamp=function(e,t,n,r){return void 0===r&&(r=C.REQUEST_THREADED_MESSAGE),A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return i=new jt(u(u(u({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},vt),n),{replyType:H.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return s=c.sent(),a=s.as(Kt).messages,(o=a.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new N({messages:o,source:r})),[2,{parentMessage:a[0],threadedMessages:o}]}}))}))},n.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return n=new Ws(u({token:e},t)),[4,this._requestQueue.send(n)];case 1:return r=c.sent(),i=r.as(Ys),s=i.hasMore,a=i.nextToken,o=i.templates,[2,{hasMore:s,token:a,templates:o}]}}))}))},n.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Js({key:e}),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,{template:n.as(Xs).template}]}}))}))},n.prototype.getMessageChangelogs=function(n,r,i,s,a){return void 0===a&&(a=C.REQUEST_MESSAGE_CHANGELOGS),A(this,void 0,void 0,(function(){var o,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return o=new Qt(e(t(u(u({channelType:r,channelUrl:n,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},Ft),s)))),[4,this._requestQueue.send(o)];case 1:return c=v.sent(),l=c.as(Gt),d=l.updatedMessages,h=l.deletedMessagesInfo,f=l.hasMore,p=l.nextToken,m=h.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new N({messages:d,source:a})),m.length>0&&this._dispatcher.dispatch(new we({messageIds:m,source:a})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:f,token:p}]}}))}))},n}(),ea=function(e){function t(t,n){var r=e.call(this,t)||this;r.targetMessageId=0;var i=n.thread_info,s=n.parent_message_id,a=n.channel_url,o=n.channel_type;return i&&h("object",i)&&h("number",s)&&h("string",a)&&h("string",o)&&(r.threadInfo=new Re(t,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return r(t,e),t}(l),ta={channelUrl:"",channelType:I.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},na=function(e){function t(t){var n=t.channelCustomType,r=t.keyword,s=t.limit,a=t.reverse,o=t.exactMatch,u=t.channelUrl,c=t.order,l=t.messageTimestampFrom,d=t.messageTimestampTo,h=t.advancedQuery,f=t.targetFields,p=t.nextToken,m=e.call(this)||this;return m.method=i.GET,m.path="".concat(Ue,"/messages"),m.params={custom_type:n,query:r,limit:s,reverse:a,exact_match:o,channel_url:u,message_ts_from:l,message_ts_to:d,sort_field:c,advanced_query:h,target_fields:f,after:p},m}return r(t,e),t}(a),ra=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return Mt(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return r(t,e),t}(o);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Os||(Os={}));var ia=function(e){function i(t,n){var r,i,s,a,o,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Os.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(a=n.channelCustomType)&&void 0!==a?a:"",h.messageTimestampFrom=null!==(o=n.messageTimestampFrom)&&void 0!==o?o:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:Os.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&h("string",this.keyword)&&this.keyword.length>0&&h("boolean",this.reverse)&&h("boolean",this.exactMatch)&&h("string",this.channelUrl)&&h("string",this.channelCustomType)&&(h("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(h("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&f(Os,this.order)&&h("boolean",this.advancedQuery)&&d("string",this.targetFields,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new na(t(u(u({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=d.sent(),s=i.as(ra),a=s.messages,o=s.hasNext,c=s.nextToken,l=s.totalCount,this._nextToken=c,this._hasNext=o,this._isLoading=!1,this.totalCount=l,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),sa=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.limit,u=r.token,c=n.call(this)||this;return c.method=i.GET,c.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages/parent_thread_message"),c.params=e(t({limit:o,token:u})),c}return r(s,n),s}(a),aa=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.next,r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),oa=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s._edge="",s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.load=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new sa({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(aa),s=i.messages,a=i.token,this._edge=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ua={channelUrl:"",scheduledMessageId:0},ca={reverse:!1,limit:20},la=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return r(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new $s(t,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},t.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},t.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},t.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=u(u({},ta),e),D(function(e){return h("string",e.channelUrl)&&f(I,e.channelType)&&h("number",e.messageId)&&h("boolean",e.includeReactions,!0)&&h("boolean",e.includeMetaArray,!0)&&h("boolean",e.includeParentMessageInfo,!0)&&h("boolean",e.includeThreadInfo,!0)}(t)).throw(O.invalidParameters),[4,this._manager.getMessage(t)];case 1:if((n=r.sent())instanceof pt||n instanceof Tt||null===n)return[2,n];throw"Unknown message type is given."}}))}))},t.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){return t=u(u({},ua),e),D(function(e){return h("string",e.channelUrl)&&""!==e.channelUrl&&h("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(O.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},t.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return n=u(u({},ca),t),D(h("string",e,!0)&&function(e){return h("boolean",e.reverse,!0)&&h("number",e.limit,!0)&&d("string",e.keys,!0)}(n)).throw(O.invalidParameters),[2,this._manager.getMessageTemplatesByToken(e,n)]}))}))},t.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),[2,this._manager.getMessageTemplate(e)]}))}))},t}(Ne);export{It as $,ws as A,Ti as B,mi as C,Sn as D,gt as E,Si as F,Yt as G,Wt as H,Ts as I,xt as J,Cs as K,Ns as L,Us as M,Gr as N,En as O,Jt as P,Br as Q,hn as R,vi as S,Mt as T,yi as U,ut as V,si as W,ui as X,Ve as Y,ct as Z,ot as _,jr as a,Ce as a$,St as a0,ea as a1,Re as a2,Xn as a3,zn as a4,cr as a5,or as a6,sr as a7,tr as a8,rr as a9,di as aA,fn as aB,nn as aC,dn as aD,ti as aE,Xt as aF,He as aG,Sr as aH,hi as aI,ke as aJ,Pe as aK,Hs as aL,_t as aM,De as aN,Zr as aO,Gs as aP,Hr as aQ,ft as aR,Je as aS,We as aT,bt as aU,Os as aV,Et as aW,Fe as aX,qe as aY,Tn as aZ,Le as a_,zr as aa,pt as ab,Ye as ac,mt as ad,vr as ae,_r as af,pr as ag,Ct as ah,Qr as ai,Tt as aj,$s as ak,mn as al,vn as am,yn as an,_n as ao,Oe as ap,Ke as aq,ze as ar,wt as as,oa as at,ii as au,Rs as av,xs as aw,Ds as ax,Ls as ay,sn as az,Kr as b,je as b0,at as b1,Be as b2,xe as b3,lt as b4,dt as b5,st as b6,Vr as c,Fs as d,qs as e,Jr as f,Ps as g,Xr as h,$r as i,ei as j,Wr as k,Yr as l,ks as m,Ss as n,bs as o,Ms as p,la as q,bi as r,ia as s,Ks as t,Bs as u,Es as v,As as w,Ui as x,Nn as y,pi as z}; +import{e,u as t,V as n,c as r,A as i,ae as s,f as a,h as o,g as u,U as c,af as l,Q as d,a as h,X as f,p,q as m,t as v,a7 as y,ag as _,ah as g,ai as b,C as I,aj as E,ak as T,al as w,W as M,am as S,_ as A,b as U,an as N,a2 as C,s as O,a8 as P,ao as k,ap as R,aq as x,w as D,ar as L,as as F,at as q,au as z,av as B,D as j,F as K,aw as Q,i as G,ax as V,ay as H,az as W,aA as Y,aB as J,aC as X,aD as Z,aE as $,aF as ee,aG as te,aH as ne,aI as re,aJ as ie,n as se,G as ae,O as oe,aK as ue,x as ce,y as le,aL as de,aM as he,aN as fe,d as pe,aO as me,aP as ve,aQ as ye,aR as _e,aS as ge,B as be,aT as Ie,aU as Ee,aV as Te,aW as we,aX as Me,aY as Se,z as Ae,aZ as Ue,a_ as Ne}from"./__bundle-0ca331b6.js";var Ce,Oe=function(){function r(e,t,n){var r,i;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(r=t.real_width)&&void 0!==r?r:t.width,this.realHeight=null!==(i=t.real_height)&&void 0!==i?i:t.height,this._requireAuth=n}return r.payloadify=function(n){return e(t(n instanceof r?{url:n.plainUrl,width:n.width,height:n.height,real_width:n.realWidth,real_height:n.realHeight}:{url:"",width:n.maxWidth,height:n.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(r.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),r}(),Pe=function(t){function n(n){var r=t.call(this)||this;if(r.method=i.POST,r.path="".concat(s),r.params=e({file:n.file,channel_url:n.channelUrl}),n.thumbnailSizes)for(var a=0;a0:void 0,u.lastRepliedAt=null!==(a=t.last_replied_at)&&void 0!==a?a:0,u.updatedAt=null!==(o=t.updated_at)&&void 0!==o?o:0,u}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{reply_count:r.replyCount,unread_message_count:r.unreadReplyCount,member_count:r.memberCount,most_replies:Array.isArray(r.mostRepliedUsers)?r.mostRepliedUsers.map((function(e){return c.payloadify(e)})):[],push_enabled:"boolean"==typeof r.isPushNotificationEnabled?r.isPushNotificationEnabled?1:0:void 0,last_replied_at:r.lastRepliedAt,updated_at:r.updatedAt})))},Object.defineProperty(i.prototype,"_isUpdateRequired",{get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled},enumerable:!1,configurable:!0}),i.prototype._updateFrom=function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled},i}(l);!function(e){e.ADD="add",e.DELETE="delete"}(Ce||(Ce={}));var xe,De=function(e){this.messageId=0,this.operation=null,this.updatedAt=0;var t=h("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,n=e.user_id,r=e.operation?e.operation.toLowerCase():null,i=e.reaction,s=e.updated_at;t&&h("string",n)&&h("string",r)&&f(Ce,r)&&h("string",i)&&i&&h("number",s)&&(this.messageId=t,this.userId=n,this.key=i,this.operation=r,this.updatedAt=s)},Le=function(){function n(e){var t,n,r,i=e.key,s=null!==(r=p([],m(e.user_ids),!1))&&void 0!==r?r:[],a=e.updated_at;h("string",i)&&i&&d("string",s)&&s.length>0&&h("number",a)&&(this.key=i,this.userIds=s,this.updatedAt=a);var o={};try{for(var u=v(this.userIds),c=u.next();!c.done;c=u.next()){o[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._version=o}return Object.defineProperty(n.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({key:n.key,user_ids:n.userIds,updated_at:n.updatedAt}))},n.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 Ce.ADD:t<0&&this.userIds.push(e.userId);break;case Ce.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},n}(),Fe=function(){function n(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 n.payloadify=function(n){var r,i;return e(t({url:n.url,secure_url:n.secureUrl,type:n.type,width:null!==(r=n.width)&&void 0!==r?r:0,height:null!==(i=n.height)&&void 0!==i?i:0,alt:n.alt}))},n}(),qe=function(){function n(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 Fe(e["og:image"]))}return n.payloadify=function(n){return e(t({"og:title":n.title,"og:url":n.url,"og:description":n.description,"og:image":n.defaultImage?Fe.payloadify(n.defaultImage):null}))},n}(),ze=function(){function n(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 n.prototype.serialize=function(){return{name:this.name,volume:this.volume}},n.payloadify=function(n){return e(t({name:n.name,volume:n.volume}))},n}();!function(e){e.GOOD="good",e.BAD="bad"}(xe||(xe={}));var Be=function(){function n(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}return n._getStatus=function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"},n._isSubmitted=function(e){return"SUBMITTED"===n._getStatus(e)},n._getPayloadByStatus=function(e){return"NO_FEEDBACK"===e?{}:null},n.payloadify=function(n){return e(t({id:n.id,rating:n.rating,comment:n.comment}))},n}(),je=function(n){function i(e,t){var r,i=this;return(i=n.call(this,e,t)||this).isBlockedByMe=!1,i.role=f(y,t.role)?t.role:y.NONE,i.isBlockedByMe=null!==(r=t.is_blocked_by_me)&&void 0!==r&&r,i}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{role:r.role,is_blocked_by_me:r.isBlockedByMe})))},i}(c),Ke=function(){function n(e){this.key=e.key,this.value=d("string",e.value)?p([],m(e.value),!1):[]}return n.payloadify=function(n){var r;return e(t({key:n.key,value:null!==(r=n.value)&&void 0!==r?r:[]}))},n}(),Qe=function(e){switch(e){case g.BASE:return"";case g.USER:return"MESG";case g.FILE:return"FILE";case g.ADMIN:return"ADMM"}},Ge=function(n){function i(e,t){var r,i,s,a,o,u,l,d,h,p=this;(p=n.call(this,e)||this).channelType=I.BASE,p.messageType=g.BASE,p.mentionType=null,p.mentionedUsers=null,p.mentionedUserIds=null,p.mentionedMessageTemplate=void 0,p.metaArrays=[],p.extendedMessage={},p.createdAt=0,p.updatedAt=0,p.channelUrl=t.channel_url,p.channelType=f(I,t.channel_type)?t.channel_type:I.GROUP,t.channel&&(t.channel.channel_url&&(p.channelUrl=t.channel.channel_url),t.channel.channel_type&&(p.channelType=t.channel.channel_type)),p.data=null!==(r=t.data)&&void 0!==r?r:"",p.customType=null!==(i=t.custom_type)&&void 0!==i?i:"",p.mentionType=f(E,t.mention_type)?t.mention_type:null,p.mentionedUsers=t.mentioned_users?t.mentioned_users.map((function(e){return new c(p._iid,e)})):null,p.mentionedUserIds=null!==(s=t.mentioned_user_ids)&&void 0!==s?s:null,p.mentionedUsers&&!p.mentionedUserIds&&(p.mentionedUserIds=p.mentionedUsers.map((function(e){return e.userId}))),p.mentionedMessageTemplate=t.mentioned_message_template;var m=null!==(a=t.metaarray)&&void 0!==a?a:{},v=null!==(o=t.metaarray_key_order)&&void 0!==o?o:Object.keys(m).sort((function(e,t){return e.localeCompare(t)}));p.metaArrays=[];for(var y=0;y0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({id:n.id,name:n.name,items:n.items.map((function(e){return dt.payloadify(e)})),version:n.version,is_submitted:n._isSubmitted}))},n.isMessageFormPayload=function(e){return Boolean(null==e?void 0:e.message_form)},n}(),dt=function(){function n(t){var n=t.id,r=t.name,i=t.required,s=t.sort_order,a=t.placeholder,o=t.style,u=t.item_type,c=t.validators,l=t.value,d=t.values;this.id=n,this.name=r,this.required=i,this.sortOrder=s,this.placeholder=a,0===Object.keys(o).length?this.style={layout:u}:this.style=e({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),d?this.submittedValues=d:l&&(this.submittedValues=[l]),this._validators=c}return n.prototype.isValid=function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case it.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case it.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case it.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case it.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case it.DECIMAL_PLACE:return 0!==e.length&&(n=Number(e),!(isNaN(n)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(n,t.max_decimal_place)));default:return!0}}))}(e,t._validators);return n}))},n.payloadify=function(n){return e(t({id:n.id,name:n.name,required:n.required,sort_order:n.sortOrder,placeholder:n.placeholder,style:e({layout:n.style.layout,options:n.style.options,default_options:n.style.defaultOptions,result_count:n.style.resultCount}),item_type:n.style.layout,validators:n._validators,values:n.submittedValues}))},n}(),ht=function(t){function n(n){var r=t.call(this)||this;return r.method=i.POST,r.path="".concat(S,"/").concat(n.formId,"/submit"),r.params=e({message_id:n.messageId,items:n.items}),r}return r(n,t),n}(a);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ut||(ut={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ct||(ct={}));var ft,pt=function(i){function s(e,t){var n,r,s,a,o,u,c,l,d,h=this;return(h=i.call(this,e,t)||this).parentMessage=null,h.silent=!1,h.isOperatorMessage=!1,h.threadInfo=null,h.reactions=[],h.appleCriticalAlertOptions=null,h.scheduledInfo=null,h.suggestedReplies=null,h.myFeedback=null,h.myFeedbackStatus="NOT_APPLICABLE",h.messageForm=null,h._isContinuousMessages=!1,h._scheduledStatus=null,h.messageId=null!==(r=null!==(n=t.msg_id)&&void 0!==n?n:t.message_id)&&void 0!==r?r:0,h.parentMessageId=null!==(s="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==s?s:0,h.threadInfo=t.thread_info?new Re(h._iid,t.thread_info):null,h.reactions=t.reactions?t.reactions.map((function(e){return new Le(e)})):[],h.ogMetaData=t.og_tag?new qe(t.og_tag):null,h.silent=null!==(a=t.silent)&&void 0!==a&&a,h.isOperatorMessage=null!==(o=t.is_op_msg)&&void 0!==o&&o,h.appleCriticalAlertOptions=t.apple_critical_alert_options?new ze(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(h.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},h._scheduledStatus=t.scheduled_status),h._isContinuousMessages=null!==(u=t.is_continuous_messages)&&void 0!==u&&u,h.myFeedback=Be._isSubmitted(t.feedback)?new Be(t.feedback):null,h.myFeedbackStatus=Be._getStatus(t.feedback),h.suggestedReplies=null!==(l=null===(c=t.extended_message_payload)||void 0===c?void 0:c.suggested_replies)&&void 0!==l?l:null,h.messageForm=lt.isMessageFormPayload(t.extended_message_payload)?new lt(h.messageId,t.extended_message_payload.message_form):null,h.message=null!==(d=t.message)&&void 0!==d?d:"",h}return r(s,i),s.payloadify=function(n){var r,s;return e(t(u(u({},i.payloadify.call(this,n)),{message_id:n.messageId,parent_message_id:n.parentMessageId,thread_info:n.threadInfo?Re.payloadify(n.threadInfo):null,reactions:n.reactions.map((function(e){return Le.payloadify(e)})),og_tag:n.ogMetaData?qe.payloadify(n.ogMetaData):null,silent:n.silent,is_op_msg:n.isOperatorMessage,apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,scheduled_message_id:null===(r=n.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=n.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:n._scheduledStatus,feedback:n.myFeedback?Be.payloadify(n.myFeedback):Be._getPayloadByStatus(n.myFeedbackStatus),message:n.message})))},s._getParentMessageInfoPayload=function(n){return e(t({type:Qe(n.messageType),ts:n.createdAt,user:n.sender?je.payloadify(n.sender):null,message:n.message,file:{url:n.plainUrl,name:n.name,type:n.type,require_auth:n.requireAuth},files:Array.isArray(n.fileInfoList)?n.fileInfoList.map((function(e){return at.payloadify(e)})):null}))},s.prototype.isIdentical=function(e){return this.messageId===e.messageId},s.prototype.applyThreadInfoUpdateEvent=function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)},s.prototype.applyReactionEvent=function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1},s.prototype._triggerThreadInfoUpdatedEvent=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){return(e=n.of(this._iid).dispatcher).dispatch(new ot({channelType:I.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_THREADINFO_UPDATED})),[2]}))}))},s.prototype.markThreadAsRead=function(){return A(this,void 0,void 0,(function(){var e,t;return U(this,(function(r){switch(r.label){case 0:return e=n.of(this._iid).requestQueue,t=new Xe({channelUrl:this.channelUrl,messageId:this.messageId}),[4,e.send(t)];case 1:return r.sent(),this.threadInfo&&0!==this.threadInfo.unreadReplyCount?(this.threadInfo.unreadReplyCount=0,[4,this._triggerThreadInfoUpdatedEvent()]):[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},s.prototype.setPushNotificationEnabled=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return t=n.of(this._iid).requestQueue,r=new Ze({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),[4,t.send(r)];case 1:return i.sent(),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e),[2]}}))}))},s.prototype.submitMessageForm=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(t=n.of(this._iid).requestQueue,r=null,i=null,s=this.messageForm,!e&&s){if(!s.isSubmittable)throw new O({code:P.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(s.isSubmitted)throw new O({code:P.INVALID_PARAMETER,message:"The form has already been submitted."});r=s.id,i=s.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[])}else e&&(r=e.formId,i=Object.entries(e.answers).reduce((function(e,t){var n=m(t,2),r=n[0],i=n[1],s=Number(r);if(Number.isNaN(s))throw new O({code:P.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:s,value:i}),e}),[]));if(!r||!i)throw new O({code:P.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});return a=new ht({messageId:this.messageId,formId:r,items:i}),[4,t.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.submitFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new $e({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(et),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_ADDED})),[2]}}))}))},s.prototype.updateFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new tt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(nt),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_UPDATED})),[2]}}))}))},s.prototype.deleteFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new rt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e}),[4,r.send(s)];case 1:return a.sent(),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new N({messages:[this],source:C.EVENT_MESSAGE_FEEDBACK_DELETED})),[2]}}))}))},s}(Ge),mt=function(n){function i(e,t){var r,i,s,a,o=this;if((o=n.call(this,e,t)||this).reqId="",o.replyToChannel=!1,o.errorCode=0,o.sender=t.user?new je(o._iid,t.user):t.sender_id,o.reqId=null!==(i=null!==(r=t.req_id)&&void 0!==r?r:t.request_id)&&void 0!==i?i:"",o.replyToChannel=null!==(s=t.is_reply_to_channel)&&void 0!==s&&s,t.request_state&&f(k,t.request_state)&&(o.sendingStatus=t.request_state),!o.sendingStatus)if(o.messageId>0)o.sendingStatus=k.SUCCEEDED;else if(o.scheduledInfo)switch(t.scheduled_status&&(o._scheduledStatus=t.scheduled_status),t.scheduled_status){case ct.SENT:case ct.IN_QUEUE:o.sendingStatus=k.SUCCEEDED;break;case ct.PENDING:o.sendingStatus=k.SCHEDULED;break;case ct.FAILED:case ct.REMOVED:o.sendingStatus=k.FAILED;break;case ct.CANCELED:o.sendingStatus=k.CANCELED}else o.sendingStatus=k.PENDING;return o.errorCode=null!==(a=t.error_code)&&void 0!==a?a:0,o._messageToken=t.mesg_token,o}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{user:je.payloadify(r.sender),req_id:r.reqId,is_reply_to_channel:r.replyToChannel,request_state:r.sendingStatus,error_code:r.errorCode,mesg_token:r._messageToken})))},Object.defineProperty(i.prototype,"isResendable",{get:function(){return(this.sendingStatus===k.FAILED||this.sendingStatus===k.CANCELED)&&R(this.errorCode)},enumerable:!1,configurable:!0}),i.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},i}(pt),vt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},yt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)},_t=function(n){function i(r,i){var s,a,o,c=this;if((c=n.call(this,r,i)||this).translations={},c.messageType=g.ADMIN,c.translations=null!==(s=i.translations)&&void 0!==s?s:{},i.parent_message_info){var l=i.parent_message_info;c.parentMessage=Mt(r,e(t(u(u({},l),{message_id:c.parentMessageId,channel_url:c.channelUrl,channel_type:c.channelType,file:l.file,url:null===(a=l.file)||void 0===a?void 0:a.url,require_auth:null===(o=l.file)||void 0===o?void 0:o.require_auth}))))}return c}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{translations:r.translations,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i}(pt),gt=function(){function n(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&&h("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return n.payloadify=function(n){return e(t({type:n.type,vendor:n.vendor,detail:n.detail}))},n}(),bt=function(){function t(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}return t.payloadify=function(t){return e({status:t.status,original_message_info:t.originalMessageInfo?{id:t.originalMessageInfo.messageId,ts:t.originalMessageInfo.createdAt}:void 0})},t}(),It=function(n){function i(r,i){var s,a,o,c,l,d,h,f=this;if((f=n.call(this,r,i)||this).messageParams=null,f.translations={},f.translationTargetLanguages=[],f.messageSurvivalSeconds=-1,f.plugins=[],f._poll=null,f.messageType=g.USER,f.translations=null!==(o=i.translations)&&void 0!==o?o:{},f.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(f.translations).length&&f.translationTargetLanguages.length>0)try{for(var p=v(f.translationTargetLanguages),m=p.next();!m.done;m=p.next()){var y=m.value;f.translations[y]=""}}catch(e){s={error:e}}finally{try{m&&!m.done&&(a=p.return)&&a.call(p)}finally{if(s)throw s.error}}if(f.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,f.plugins=i.plugins?i.plugins.map((function(e){return new gt(e)})):[],f._poll=i.poll?new L(f._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;f.parentMessage=Mt(r,e(t(u(u({},_),{created_at:_.ts,message_id:f.parentMessageId,channel_url:f.channelUrl,channel_type:f.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(f.messageReviewInfo=new bt(i.review_info)),f}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{translations:r.translations,message_survival_seconds:r.messageSurvivalSeconds,plugins:r.plugins.map((function(e){return gt.payloadify(e)})),poll:r._poll?L.payloadify(r._poll):null,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null,review_info:r.messageReviewInfo?bt.payloadify(r.messageReviewInfo):void 0})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(i.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),i}(mt),Et=function(n){function i(r,i){var s,a,o,c,l,d,h,f,p=this;if((p=n.call(this,r,i)||this).messageParams=null,p.fileInfoList=[],p.messageSurvivalSeconds=-1,p.messageType=g.FILE,p.data=null!==(o=null!==(a=null===(s=i.file)||void 0===s?void 0:s.data)&&void 0!==a?a:i.custom)&&void 0!==o?o:"",p.fileInfoList=null!==(l=null===(c=i.files)||void 0===c?void 0:c.map((function(e){return new at(r,e)})))&&void 0!==l?l:[],p.messageSurvivalSeconds=null!==(d=i.message_survival_seconds)&&void 0!==d?d:-1,i.parent_message_info){var m=i.parent_message_info;p.parentMessage=Mt(r,e(t(u(u({},m),{created_at:m.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:m.file,url:null===(h=m.file)||void 0===h?void 0:h.url,require_auth:null===(f=m.file)||void 0===f?void 0:f.require_auth}))))}return p}return r(i,n),i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.payloadify=function(r){var i,s,a,o,c,l;return e(t(u(u({},n.payloadify.call(this,r)),{file:{name:null!==(s=null===(i=r.fileInfoList[0])||void 0===i?void 0:i.fileName)&&void 0!==s?s:"",size:null!==(o=null===(a=r.fileInfoList[0])||void 0===a?void 0:a.fileSize)&&void 0!==o?o:0,type:null!==(l=null===(c=r.fileInfoList[0])||void 0===c?void 0:c.mimeType)&&void 0!==l?l:"",data:r.data},files:Array.isArray(r.fileInfoList)?r.fileInfoList.map((function(e){return at.payloadify(e)})):null,message_survival_seconds:r.messageSurvivalSeconds,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},i._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},i}(mt);!function(e){e.SENT="SENT",e.READ="READ"}(ft||(ft={}));var Tt=function(n){function i(e,t){var r,i,s=this;if((s=n.call(this,e,t)||this).notificationData=null,s.notificationId=t.notification_message_id,s.messageType=g.ADMIN,s.messageStatus=null!==(r=t.message_status)&&void 0!==r?r:ft.SENT,s.priority=null!==(i=t.priority)&&void 0!==i?i:F.NORMAL,s.notificationEventDeadline=t.notification_event_deadline,0===s.extendedMessage.sub_type)try{var a=JSON.parse(s.extendedMessage.sub_data),o=a.label,u=a.tags,c=void 0===u?[]:u,l=a.template_key,d=a.template_variables;s.notificationData={label:o,tags:c,templateKey:l,templateVariables:d}}catch(e){}return s}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{notification_message_id:r.notificationId,message_status:r.messageStatus,priority:r.priority,notification_event_deadline:r.notificationEventDeadline})))},i.prototype.isIdentical=function(e){return this.notificationId===e.notificationId},i}(Ge),wt=function(e){if(e.notificationId)return Tt.payloadify(e);switch(e.messageType){case g.USER:return It.payloadify(e);case g.FILE:return e.fileInfoList?Et.payloadify(e):St.payloadify(e);case g.ADMIN:return _t.payloadify(e);default:throw O.unknown}},Mt=function(e,t){if(t.notification_message_id)return new Tt(e,t);switch(t.type){case"MESG":return new It(e,t);case"FILE":return Et._isMultipleFilesMessagePayload(t)?new Et(e,t):new St(e,t);case"ADMM":case"BRDM":return new _t(e,t);default:return null}},St=function(i){function s(n,r){var s,a,o,c,l,d,h,f,p,m,v,y,_,b,I=this;(I=i.call(this,n,r)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=g.FILE;var E=r.file;if(I.plainUrl=(null!==(a=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==a?a:"").split("?auth=")[0],I.name=null!==(c=null!==(o=null==E?void 0:E.name)&&void 0!==o?o:r.name)&&void 0!==c?c:"File",I.size=null!==(d=null!==(l=null==E?void 0:E.size)&&void 0!==l?l:r.size)&&void 0!==d?d:0,I.data=null!==(f=null!==(h=null==E?void 0:E.data)&&void 0!==h?h:r.custom)&&void 0!==f?f:"",I.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(m=r.type)&&void 0!==m?m:"",I.requireAuth=null!==(v=r.require_auth)&&void 0!==v&&v,I.thumbnails=r.thumbnails?r.thumbnails.map((function(e){var t;return new Oe(I._iid,"string"==typeof e?{url:e,width:0,height:0}:u(u({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),I.requireAuth)})):[],I.messageSurvivalSeconds=null!==(y=r.message_survival_seconds)&&void 0!==y?y:-1,r.parent_message_info){var T=r.parent_message_info;I.parentMessage=Mt(n,e(t(u(u({},T),{created_at:T.ts,message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:T.file,url:null===(_=T.file)||void 0===_?void 0:_.url,require_auth:null===(b=T.file)||void 0===b?void 0:b.require_auth}))))}return I}return r(s,i),s.payloadify=function(n){var r;return e(t(u(u({},i.payloadify.call(this,n)),{url:n.plainUrl,require_auth:n.requireAuth,file:{name:n.name,size:n.size,type:n.type,data:n.data},thumbnails:null===(r=n.thumbnails)||void 0===r?void 0:r.map((function(e){return{url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:n.messageSurvivalSeconds,parent_message_info:n.parentMessage?i._getParentMessageInfoPayload.call(this,n.parentMessage):null})))},Object.defineProperty(s.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){switch(r.label){case 0:return n=u(u({},vt),t),D(this.messageId>0&&h("number",e)&&yt(n)).throw(O.invalidParameters),[4,$s.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},s}(mt),At=function(e){function t(t,n){var r=n.file,i=n.fileUrl,s=n.fileName,a=n.fileSize,o=n.mimeType,u=n.thumbnailSizes,c=n._uploadedMetaData,l=n._thumbnails,d=e.call(this,t)||this;return d._plainUrl=i,d.file=r,d.fileName=s,d.fileSize=a,d.mimeType=o,d.thumbnailSizes=u,d._uploadedMetaData=c,d._thumbnails=l,d}return r(t,e),t.getPlainUrl=function(e){return e instanceof t?e._plainUrl:e.fileUrl},Object.defineProperty(t.prototype,"fileUrl",{get:function(){var e,t=n.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}},t}(l),Ut=function(n){function i(r){var i,s,a,o,u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,files:r.files?Pt(r.files):null,url:r.url,name:null!==(i=r.fileName)&&void 0!==i?i:"",type:null!==(s=r.mimeType)&&void 0!==s?s:"",size:null!==(a=r.fileSize)&&void 0!==a?a:0,custom:r.data,custom_type:r.customType,thumbnails:null===(o=r._thumbnails)||void 0===o?void 0:o.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:u,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,pin_message:r.isPinnedMessage,message:r.message}))})||this}return r(i,n),i}(T),Nt=function(n){function s(r){var s,a,o=this;o=n.call(this)||this;var u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),o.method=i.POST,o.path="".concat(w(r.channelType),"/").concat(encodeURIComponent(r.channelUrl),"/messages"),o.params=e(t({message_type:g.FILE,user_id:r.userId,files:r.files?Pt(r.files):null,url:r.fileUrl,mention_type:r.mentionType,mentioned_user_ids:u,file_name:r.fileName,file_size:r.fileSize,file_type:r.mimeType,data:r.data,custom_type:r.customType,thumbnails:null===(s=r._thumbnails)||void 0===s?void 0:s.map((function(e){return Oe.payloadify(e)})),require_auth:r.requireAuth,sorted_metaarray:null===(a=r.metaArrays)||void 0===a?void 0:a.map((function(e){return Ke.payloadify(e)})),push_option:r.pushNotificationDeliveryOption,parent_message_id:r.parentMessageId?r.parentMessageId:null,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,reply_to_channel:r.isReplyToChannel,req_id:r.reqId,pin_message:r.isPinnedMessage})),o}return r(s,n),s}(a),Ct=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"FILE",i)||this).message=i.files&&i.files.length>=2?new Et(t,i):new St(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),Ot=function(e){function t(t,r){var i,s,a,o,u=this;(u=e.call(this,t,r)||this).message=r.files&&r.files.length>=2?new Et(t,r):new St(t,r);var c=n.of(t).sdkState;return u.isMentioned=z(u.message.mentionType,null!==(a=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(s=u.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return r(t,e),t}(o);function Pt(n){return n.map((function(n){var r,i;return e(t({url:At.getPlainUrl(n),file_name:n.fileName,file_type:n.mimeType,file_size:n.fileSize,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),require_auth:null===(i=n._uploadedMetaData)||void 0===i?void 0:i.requireAuth}))}))}var kt;!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"}(kt||(kt={}));var Rt=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext,o=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=a,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof j&&(o._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===K.CONNECTED||this._connectionState===K.CONNECTING||this._connectionState===K.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){switch(s.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(r=new Ut(n),[4,this._requestQueue.send(r)]):[3,2];case 1:return i=s.sent(),[2,i.as(Ct).message];case 2:return r=new Nt(u(u({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),[2,i.as(Ot).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=u(u({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{r=t.params;n.url=r.fileUrl,n.requireAuth=r.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p;return U(this,(function(m){switch(m.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,r=[],i=!0,m.label=1;case 1:m.trys.push([1,15,16,17]),s=v(n.messageQueue),a=s.next(),m.label=2;case 2:if(a.done)return[3,14];switch(o=a.value,o.state){case kt.PENDING:case kt.UPLOADING:return[3,3];case kt.UPLOADED:return[3,4];case kt.FAILED:return[3,12]}return[3,13];case 3:return i=!1,r.push(o),[3,13];case 4:if(!i)return[3,10];m.label=5;case 5:return m.trys.push([5,8,,9]),o.state=kt.SENDING,[4,this._sendFileMessage(e,o)];case 6:return u=m.sent(),o.deferred.resolve(u),[4,Q(100)];case 7:return m.sent(),[3,9];case 8:return c=m.sent(),o.deferred.reject(c),[3,9];case 9:return[3,11];case 10:r.push(o),m.label=11;case 11:return[3,13];case 12:return l=null!==(t=o.error)&&void 0!==t?t:O.unknown,o.deferred.reject(l.code===P.REQUEST_CANCELED?O.fileUploadCanceled:l),[3,13];case 13:return a=s.next(),[3,2];case 14:return[3,17];case 15:return d=m.sent(),f={error:d},[3,17];case 16:try{a&&!a.done&&(p=s.return)&&p.call(s)}finally{if(f)throw f.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:m.sent(),m.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,m.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d;return U(this,(function(h){switch(h.label){case 0:return(n=this._queueMap.get(e.url))&&(r=n.messageQueue.find((function(e){return e.state===kt.PENDING})))?r.multipleFileUploadInfo?(i=r.multipleFileUploadInfo,s=i.uploadIndex,a=i.uploadCount,o=i.requestHandler,d=r.params,u=d.fileInfoList[s],!G(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]):[3,4]:[3,9];case 1:return h.sent(),[3,3];case 2:r.state=s=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,u,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return a=new Pe({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(a)];case 1:return o=v.sent(),u=o.as(ke),c=u.url,l=u.fileSize,d=void 0===l?n.fileSize:l,h=u.thumbnails,f=void 0===h?[]:h,p=u.requireAuth,m=void 0!==p&&p,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(i=n.mimeType)&&void 0!==i?i:n.file.type,n.fileSize=null!==(s=n.fileSize)&&void 0!==s?s:n.file.size,n.fileUrl=c,n.fileSize=d,n.requireAuth=m,n._thumbnails=f,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var r,i,s;return A(this,void 0,void 0,(function(){var a,o,c,l,d,h,f,p,m,v,y;return U(this,(function(_){switch(_.label){case 0:return a=t.multipleFileUploadInfo.uploadIndex,o=n.fileInfoList[a],c=new Pe({file:o.file,channelUrl:e.url,thumbnailSizes:o.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(c)];case 1:return l=_.sent(),d=l.as(ke),h=d.url,f=d.fileSize,p=void 0===f?o.fileSize:f,m=d.thumbnails,v=d.requireAuth,y=void 0!==v&&v,o.fileName=null!==(r=o.fileName)&&void 0!==r?r:o.file.name,o.mimeType=null!==(i=o.mimeType)&&void 0!==i?i:o.file.type,o.fileSize=null!==(s=o.fileSize)&&void 0!==s?s:o.file.size,o.file=void 0,o.fileUrl=h,o.fileSize=p,o._thumbnails=m,o._uploadedMetaData=u(u({},o._uploadedMetaData),{requireAuth:y,isUploaded:!0}),o instanceof At||(n.fileInfoList[a]=new At(this._iid,o)),[2]}}))}))},e.prototype.request=function(e,t,n,r){return void 0===r&&(r={}),A(this,void 0,void 0,(function(){var i,s,a,o,c;return U(this,(function(l){return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),a=new V,o={requestId:t,params:n,state:kt.PENDING,deferred:a},function(e){return"fileInfoList"in e}(n)&&(c=u({uploadIndex:0,uploadCount:n.fileInfoList.length},r),o.multipleFileUploadInfo=c),s.messageQueue.push(o),this._uploadNextPendingItem(e),[2,a.promise]}))}))},e.prototype.cancel=function(e,t){var n,r,i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:p([],m(i.messageQueue),!1);try{for(var a=v(s),o=a.next();!o.done;o=a.next()){var u=o.value;if(u)switch(u.state){case kt.PENDING:if(u.state=kt.FAILED,u.error=O.requestCanceled,u.multipleFileUploadInfo&&!u.multipleFileUploadInfo.isCopy){var c=u.multipleFileUploadInfo,l=c.uploadIndex,d=c.requestHandler,h=u.params.fileInfoList[l];null==d||d._triggerOnFileUploaded(u.requestId,l,h,O.fileUploadCanceled)}this._resolveMessageQueue(e);break;case kt.UPLOADING:this._requestQueue.cancel(u.requestId),this._dispatcher.dispatch(new B({requestId:u.requestId}))}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new B({requestId:t})))},e}();var xt,Dt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:x.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:H.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Lt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(x,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&f(H,e.replyType)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)&&h("boolean",e.showSubchannelMessagesOnly)},Ft={replyType:H.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},qt=function(e){return f(H,e.replyType)&&h("boolean",e.includeReactions)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeParentMessageInfo)&&h("boolean",e.includeThreadInfo)},zt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.includeMetaArray,o=t.includeReactions,u=t.includeThreadInfo,c=t.includeParentMessageInfo,l=e.call(this)||this;return l.method=i.GET,l.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s)),l.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions:o,include_thread_info:u,include_parent_message_info:c,include_poll_details:!0},l}return r(t,e),t}(a),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o),jt=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.timestamp,u=r.token,c=r.prevResultSize,l=r.nextResultSize,d=r.isInclusive,h=r.reverse,f=r.messageTypeFilter,p=r.customTypesFilter,m=r.senderUserIdsFilter,v=r.replyType,y=r.includeMetaArray,_=r.includeReactions,g=r.parentMessageId,b=r.includeThreadInfo,I=r.includeParentMessageInfo,E=r.showSubchannelMessagesOnly,T=r.checkingHasNext,M=r.checkingContinuousMessages,S=n.call(this)||this;return S.method=i.GET,S.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages"),S.params=e(t({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:m,include_reply_type:v,with_sorted_meta_array:y,include_reactions:_,parent_message_id:g,include_thread_info:b,include_parent_message_info:I,show_subchannel_message_only:E,include_poll_details:!0,checking_has_next:T,checking_continuous_messages:M})),S}return r(s,n),s}(a),Kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return void 0!==n.is_continuous_messages&&(r.isContinuousMessages=n.is_continuous_messages),void 0!==n.has_next&&(r.hasNext=n.has_next),r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),Qt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.timestamp,a=t.token,o=t.replyType,u=t.includeMetaArray,c=t.includeReactions,l=t.includeThreadInfo,d=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=i.GET,h.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:s,token:a,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_reply_type:o,include_parent_message_info:d,include_poll_details:!0},h}return r(t,e),t}(a),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return Mt(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return r(t,e),t}(o),Vt=function(e){function t(t){var n=t.channelUrl,r=t.scheduledMessageId,s=e.call(this)||this;return s.method=i.GET,s.path="".concat(W,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),s.params={},s}return r(t,e),t}(a),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?Mt(t,u({},n)):null,r}return r(t,e),t}(o);!function(e){e.MUTED="muted",e.BANNED="banned"}(xt||(xt={}));var Wt=function(){function n(e){var t,n,r,i;this.restrictionType=null,f(xt,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(r=null!==(n=e.end_at)&&void 0!==n?n:e.muted_end_at)&&void 0!==r?r:-1,this.remainingDuration=null!==(i=e.remaining_duration)&&void 0!==i?i:-1}return n.payloadify=function(n){return e(t({restriction_type:n.restrictionType,description:n.description,end_at:n.endAt,remaining_duration:n.remainingDuration}))},n}(),Yt=function(n){function i(e,t){var r=n.call(this,e,t)||this;return r.restrictionInfo=new Wt(t),r}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),Wt.payloadify(r.restrictionInfo))))},i}(c),Jt=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return r(t,e),t}(c),Xt=function(){function e(){this._onPending=Y,this._onFailed=Y,this._onSucceeded=Y}return e.prototype._trigger=function(e){switch(null==e?void 0:e.sendingStatus){case k.PENDING:0===e.errorCode&&this._onPending(e);break;case k.SCHEDULED:case k.SUCCEEDED:this._onSucceeded(e)}},e.prototype._triggerFailed=function(e,t){switch(null==t?void 0:t.sendingStatus){case k.FAILED:case k.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}(),Zt={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},$t=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(Ke,e.metaArrays,!0)&&h("number",e.parentMessageId,!0)&&h("boolean",e.isReplyToChannel)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)&&h("boolean",e.isPinnedMessage,!0)},en=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},tn=u(u({},Zt),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function nn(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var rn,sn=function(n){var r;return e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,pollId:null===(r=n.poll)||void 0===r?void 0:r.id,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,message:n.message,translationTargetLanguages:Object.keys(n.translations),extendedMessagePayload:n.extendedMessagePayload}))},an=function(e){return $t(e)&&h("string",e.message)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)&&h("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(rn||(rn={}));var on=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},un=function(e){return e===rn.BLOB||e===rn.FILE},cn=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},ln=u(u({},Zt),{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,message:void 0});function dn(e){var n,r,i,s;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=e.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails,message:e.message}))}var hn,fn=function(n,r){var i;return n.messageParams?(!n.url&&G(r)&&(n.messageParams.file=r),n.messageParams):e(t({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,file:r,fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,thumbnailSizes:null===(i=n.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),message:n.message}))},pn=function(e){return $t(e)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&h("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},mn={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},vn=function(e){return h("string",e.data,!0)&&h("string",e.customType,!0)&&f(E,e.mentionType)&&d("string",e.mentionedUserIds,!0)&&d(c,e.mentionedUsers,!0)&&h("string",e.mentionedMessageTemplate,!0)&&d(Ke,e.metaArrays,!0)&&f(q,e.pushNotificationDeliveryOption,!0)&&h(ze,e.appleCriticalAlertOptions,!0)},yn=u(u({},mn),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),_n=function(e){return vn(e)&&h("string",e.message,!0)&&d("string",e.translationTargetLanguages,!0)&&h("number",e.pollId,!0)},gn=u({},mn),bn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.token,a=t.limit,o=e.call(this)||this;return o.method=i.GET,o.path="".concat(w(r),"/").concat(encodeURIComponent(n),"/operators"),o.params={token:s,limit:a},o}return r(t,e),t}(a),In=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new c(t,e)})),r.token=n.next,r}return r(t,e),t}(o),En=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=n.of(this._iid).requestQueue,r=new bn(u(u({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(r)]):[3,2]):[3,5];case 1:return i=c.sent(),s=i.as(In),a=s.operators,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),Tn=function(e){function n(t,n,r,i){var s,a,o,u,c,l,d,h,f,p,m=this;return(m=e.call(this,t,n,r,i)||this).reverse=!1,m.messageTypeFilter=x.ALL,m.customTypesFilter=null,m.senderUserIdsFilter=null,m.replyType=H.NONE,m.includeMetaArray=!1,m.includeReactions=!1,m.includeParentMessageInfo=!1,m.includeThreadInfo=!1,m.showSubchannelMessagesOnly=!1,m._edge=Number.MAX_SAFE_INTEGER,m.reverse=null!==(s=i.reverse)&&void 0!==s&&s,m.messageTypeFilter=null!==(a=i.messageTypeFilter)&&void 0!==a?a:x.ALL,m.customTypesFilter=null!==(o=i.customTypesFilter)&&void 0!==o?o:null,m.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,m.replyType=null!==(c=i.replyType)&&void 0!==c?c:H.NONE,m.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,m.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,m.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,m.includeThreadInfo=null!==(f=i.includeThreadInfo)&&void 0!==f&&f,m.showSubchannelMessagesOnly=null!==(p=i.showSubchannelMessagesOnly)&&void 0!==p&&p,m}return r(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.reverse)&&f(x,this.messageTypeFilter)&&f(H,this.replyType)&&d("string",this.customTypesFilter,!0)&&d("string",this.senderUserIdsFilter,!0)&&h("boolean",this.includeMetaArray)&&h("boolean",this.includeReactions)&&h("boolean",this.includeParentMessageInfo)&&h("boolean",this.includeThreadInfo)&&h("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,$s.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t({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=n.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 O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},n}(J),wn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.limit,o=t.token;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:o},n}return r(t,e),t}(a),Mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.mutedUsers=[];var i=n.next,s=n.muted_list;return r.token=i,s&&s.length>0&&(r.mutedUsers=s.map((function(e){return new Yt(t,e)}))),r}return r(t,e),t}(o),Sn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new wn(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Mn),s=i.mutedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),An=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.limit,u=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({limit:o,token:u}),r}return r(n,t),n}(a),Un=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map((function(e){return new Yt(t,e.user)}))),r}return r(t,e),t}(o),Nn=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new An(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Un),s=i.bannedUsers,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(hn||(hn={}));var Cn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var On=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var Pn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return r(t,e),t}(a),kn=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,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return r(t,e),t}(o),Rn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return r(t,e),t}(a),xn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),Dn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return r(t,e),t}(a),Ln=function(e){function t(t,n){var r,i,s=this;return(s=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},s.ts=null!==(i=n.ts)&&void 0!==i?i:null,s}return r(t,e),t}(o),Fn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metadata,o=t.upsert;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=o&&o},n}return r(t,e),t}(a),qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return r(t,e),t}(o),zn=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 r(t,e),t}(M),Bn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return r(t,e),t}(a),jn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),Kn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return r(t,e),t}(a),Qn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return r(t,e),t}(o),Gn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.keys;return(n=e.call(this)||this).method=i.GET,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return r(t,e),t}(a),Vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Hn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return r(t,e),t}(a),Wn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Yn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.metaCounter,o=t.upsert,u=void 0!==o&&o,c=t.mode,l=void 0===c?"set":c;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:u,mode:l},n}return r(t,e),t}(a),Jn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return r(t,e),t}(o),Xn=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 r(t,e),t}(M),Zn=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.key;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params={},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var $n=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var er=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId,o=t.seconds,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:o,description:u},n}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var tr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),nr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var rr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ir=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.userId,u=n.seconds,c=n.description;return(r=t.call(this)||this).method=i.POST,r.path="".concat(w(a),"/").concat(encodeURIComponent(s),"/ban"),r.params=e({user_id:o,seconds:u,description:c}),r}return r(n,t),n}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var sr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(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 r(t,e),t}(M),ar=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.userId;return(n=e.call(this)||this).method=i.DELETE,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var or=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Yt(t,r.data),i}return r(t,e),t}(M),ur=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=i.PUT,n.path="".concat(w(s),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var cr=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return r(t,e),t}(M),lr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(X(s),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:o,report_description:u},n}return r(t,e),t}(a),dr=function(e){function t(t){var n=this,r=t.channelUrl,s=t.channelType,a=t.category,o=t.userId,u=t.offendingUserId,c=t.description;return(n=e.call(this)||this).method=i.POST,n.path="".concat(Z,"/users/").concat(u),n.params={channel_url:r,channel_type:s===I.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:o,report_description:c},n}return r(t,e),t}(a),hr=function(t){function n(n){var r=this,s=n.channelUrl,a=n.channelType,o=n.category,u=n.userId,c=n.offendingUserId,l=n.messageId,d=n.description,h=n.messageToken;return(r=t.call(this)||this).method=i.POST,r.path="".concat(X(a),"/").concat(encodeURIComponent(s),"/messages/").concat(l),r.params=e({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),r}return r(n,t),n}(a),fr=function(n){function i(r){var i=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,poll_id:r.pollId,pin_message:r.isPinnedMessage,extended_message_payload:r.extendedMessagePayload}))})||this}return r(i,n),i}(T),pr=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"MESG",i)||this).message=new It(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),mr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,message:r.message,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,mentioned_message_template:r.mentionedMessageTemplate,apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,poll_id:r.pollId}))})||this}return r(i,n),i}(T),vr=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"MEDI",s)||this).message=new It(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),yr=function(n){function i(r){var i=null;return r.mentionType===E.USERS&&(r.mentionedUserIds?i=r.mentionedUserIds:r.mentionedUsers&&(i=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,msg_id:r.messageId,data:r.data,custom_type:r.customType,metaarray:r.metaArrayParams,mention_type:r.mentionType,mentioned_user_ids:i,apple_critical_alert_options:r.appleCriticalAlertOptions}))})||this}return r(i,n),i}(T),_r=function(e){function i(r,i,s){var a,o,u,c,l,d=this;(d=e.call(this,r,"FEDI",s)||this).message=new St(r,s);var h=n.of(r).sdkState;return d.mentionCountChange=$({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mentioned_user_ids)&&void 0!==u?u:[]},t({mentionType:d.message.mentionType,mentionedUserIds:null!==(c=d.message.mentionedUserIds)&&void 0!==c?c:null===(l=d.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),h.userId),d}return r(i,e),i}(M),gr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),br=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(n),r}return r(t,e),t}(o),Ir=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=i.DELETE,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return r(t,e),t}(a),Er=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new De(u({},n)),r}return r(t,e),t}(o),Tr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.translationTargetLanguages,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(s),"/translation"),o.params={target_langs:a},o}return r(t,e),t}(a),wr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Mr=function(n){function s(r){var s,a=this;a=n.call(this)||this;var o=[];r.mentionType===E.USERS&&(r.mentionedUserIds?o=r.mentionedUserIds:r.mentionedUsers&&(o=r.mentionedUsers.map((function(e){return e.userId}))));var u=r.channelType,c=r.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=e(t({req_id:r.reqId,scheduled_at:r.scheduledAt,message_type:ee.USER,message:r.message,custom_type:r.customType,data:r.data,mention_type:r.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=r.metaArrays)||void 0===s?void 0:s.map((function(e){return Ke.payloadify(e)})),apple_critical_alert_options:r.appleCriticalAlertOptions?ze.payloadify(r.appleCriticalAlertOptions):null,target_langs:r.translationTargetLanguages,push_option:r.pushNotificationDeliveryOption})),a}return r(s,n),s}(a),Sr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new It(t,n),r}return r(t,e),t}(o),Ar=function(e){function n(n){var r,s,a=this;a=e.call(this)||this;var o=[];n.mentionType===E.USERS&&(n.mentionedUserIds?o=n.mentionedUserIds:n.mentionedUsers&&(o=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return a.method=i.POST,a.path="".concat(w(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params=t({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ee.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=n.metaArrays)||void 0===s?void 0:s.map((function(e){return Ke.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?ze.payloadify(n.appleCriticalAlertOptions):null,push_option:n.pushNotificationDeliveryOption}),a}return r(n,e),n}(a),Ur=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new St(t,n),r}return r(t,e),t}(o),Nr=function(e){function t(t){var n=t.pollId,r=t.title,s=t.data,a=t.allowUserSuggestion,o=t.allowMultipleVotes,u=t.closeAt,c=e.call(this)||this;return c.method=i.PUT,c.path="".concat(ne,"/").concat(encodeURIComponent(n)),c.params={title:r,data:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return r(t,e),t}(a),Cr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Or=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.DELETE,r.path="".concat(ne,"/").concat(encodeURIComponent(n)),r}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var Pr=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=i.PUT,r.path="".concat(ne,"/").concat(encodeURIComponent(n),"/close"),r}return r(t,e),t}(a),kr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Rr=function(e){function t(t){var n=t.channelUrl,r=t.channelType,s=t.pollId,a=t.optionText,o=e.call(this)||this;return o.method=i.POST,o.path="".concat(ne,"/").concat(encodeURIComponent(s),"/options"),o.params={channel_url:n,channel_type:r,text:a},o}return r(t,e),t}(a),xr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Dr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=t.optionText,a=e.call(this)||this;return a.method=i.PUT,a.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:s},a}return r(t,e),t}(a),Lr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new L(t,n),r}return r(t,e),t}(o),Fr=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,s=e.call(this)||this;return s.method=i.DELETE,s.path="".concat(ne,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s}return r(t,e),t}(a);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(o);var qr=function(t){function n(n){var r=n.reqId,i=n.channelType,s=n.channelUrl,a=n.pollId,o=n.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:e({req_id:r,channel_type:i===I.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:a,option_ids:o})})||this}return r(n,t),n}(T),zr=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=new re(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return r(t,e),t}(M),Br=100,jr="GroupChannel",Kr="url",Qr=100,Gr="Message",Vr="messageId",Hr=100,Wr="NotificationMessage",Yr="notificationId",Jr="Poll",Xr="pollId",Zr=100,$r="FeedChannel",ei="url";function ti(e){var n,r,i;return null!==(n=e.messageParams)&&void 0!==n?n:t(u(u({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(r=e.mentionedUserIds)&&void 0!==r?r:null===(i=e.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((function(e){var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))}var ni=u(u({},Zt),{fileInfoList:[],message:""}),ri=function(e){return(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},ii=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._onFileUploaded=Y,t}return r(t,e),t.prototype._triggerOnFileUploaded=function(e,t,n,r){this._onFileUploaded(e,t,n,r)},t.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},t.prototype.onPending=function(t){return e.prototype.onPending.call(this,t),this},t.prototype.onFailed=function(t){return e.prototype.onFailed.call(this,t),this},t.prototype.onSucceeded=function(t){return e.prototype.onSucceeded.call(this,t),this},t}(Xt),si=function(e){function t(t,n){var r=e.call(this,t)||this;return r.message=null,r.message=Mt(t,n.message),r}return r(t,e),t}(l),ai=function(t){function n(n){var r=this,s=n.channelType,a=n.channelUrl,o=n.limit,u=n.token,c=n.includeReactions,l=n.includeMetaArray,d=n.includeParentMessageInfo,h=n.includeThreadInfo,f=n.includePollDetails;return(r=t.call(this)||this).method=i.GET,r.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/pinned_messages"),r.params=e({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),r}return r(n,t),n}(a),oi=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.pinned_messages,s=n.has_more,a=n.next;return r.pinnedMessages=i.map((function(e){return new si(t,e)})),r.hasMore=s,r.token=a,r}return r(t,e),t}(o),ui=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s.includeMetaArray=i.includeMetaArray,s.includeReactions=i.includeReactions,s.includeParentMessageInfo=i.includeParentMessageInfo,s.includeThreadInfo=i.includeThreadInfo,s.includePollDetails=i.includePollDetails,s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&h("boolean",this.includeMetaArray,!0)&&h("boolean",this.includeReactions,!0)&&h("boolean",this.includeParentMessageInfo,!0)&&h("boolean",this.includeThreadInfo,!0)&&h("boolean",this.includePollDetails,!0)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new ai(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=c.sent(),i=r.as(oi),s=i.pinnedMessages,a=i.hasMore,o=i.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ci=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.POST,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var li=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=e.call(this)||this;return a.method=i.DELETE,a.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var di,hi=2;!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(di||(di={}));var fi,pi=function(i){function s(e,t){var n,r,s,a,o,u,l,d=this;return(d=i.call(this,e)||this)._name="",d._createdAt=0,d.pinnedMessageIds=[],d.channelType=I.BASE,d.coverUrl="",d.customType="",d.data="",d.isFrozen=!1,d.isEphemeral=!1,d.creator=null,d._messageCollectionLastAccessedAt=0,d._url=t.channel_url,d._name=null!==(n=t.name)&&void 0!==n?n:"",d._createdAt=1e3*t.created_at,d.coverUrl=null!==(r=t.cover_url)&&void 0!==r?r:"",d.customType=null!==(s=t.custom_type)&&void 0!==s?s:"",d.data=null!==(a=t.data)&&void 0!==a?a:"",d.isFrozen=null!==(o=t.freeze)&&void 0!==o&&o,d.isEphemeral=null!==(u=t.is_ephemeral)&&void 0!==u&&u,d.creator=t.created_by?new c(d._iid,t.created_by):null,t.metadata&&Object.keys(t.metadata).length>0&&t.ts?(d._cachedMetaData=new Map,Object.keys(t.metadata).forEach((function(e){d._cachedMetaData.set(e,{value:t.metadata[e],isRemoved:!1,updatedAt:t.ts})}))):"string"==typeof t.metadata&&(d._cachedMetaData=new Map(Object.entries(JSON.parse(t.metadata)))),d.pinnedMessageIds=null!==(l=t.pinned_message_ids)&&void 0!==l?l:[],d}return r(s,i),Object.defineProperty(s.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),s.prototype.toJSON=function(){return u(u({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},s.payloadify=function(n){return e(t(u(u({},i.payloadify.call(this,n)),{channel_url:n.url,name:n.name,cover_url:n.coverUrl,custom_type:n.customType,data:n.data,freeze:n.isFrozen,is_ephemeral:n.isEphemeral,created_by:n.creator?c.payloadify(n.creator):null,created_at:n.createdAt/1e3,metadata:n.cachedMetaData,pinned_message_ids:n.pinnedMessageIds})))},s.prototype.isGroupChannel=function(){return this.channelType===I.GROUP},s.prototype.isOpenChannel=function(){return this.channelType===I.OPEN},s.prototype.isFeedChannel=function(){return this.channelType===I.FEED},Object.defineProperty(s.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(s.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),s.prototype._serializeCachedMetaData=function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}},s.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},s.prototype._update=function(t){var n=e(t);Object.assign(this,n)},s.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})}))},s.prototype._updateCachedMetaData=function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(i,s){var a;i.updatedAt<=t&&(n._cachedMetaData.set(s,{value:null!==(a=e[s])&&void 0!==a?a:i.value,isRemoved:!e[s],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}},s.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0,message:t.message})),s=new Et(this._iid,i);return s.messageParams=t,s},s.prototype._validateFailedFileMessageHasFile=function(e,t){var n;return Boolean(e.url)||G(t)||G(null===(n=e.messageParams)||void 0===n?void 0:n.file)},s.prototype._createPendingScheduledFileMessage=function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r},s.prototype._markMessageAsFailed=function(e,t,n){void 0===n&&(n=!1),e.errorCode=t.code,t.code===P.REQUEST_CANCELED||t.code===P.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=k.CANCELED:n||(e.sendingStatus=k.FAILED)},s.prototype.sendUserMessage=function(e){var t=u(u({},tn),e);return D(an(t)).throw(O.invalidParameters),this._sendUserMessage(t)},s.prototype._sendUserMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,c=null!=r?r:this._generateRequestId(),l=Date.now(),d=new Xt;return Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l);a.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(r)]}))}))}));var s=new fr(u(u({},e),{channelUrl:i.url,channelType:i.channelType,reqId:c}));o.send(s).then((function(e){var t=e.as(pr).message;a.dispatch(new N({messages:[t],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._trigger(t)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingUserMessage(e,c,l),s=n.of(i._iid).cacheContext,o=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,o),a.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,d._triggerFailed(t,r)]}))}))}))}))}))})),d},s.prototype._autoResendUserMessage=function(e){return D(e instanceof It&&!!e.messageParams).throw(O.invalidParameters),this._sendUserMessage(e.messageParams,di.SEND,e.reqId)},s.prototype.resendUserMessage=function(e){var t;return A(this,void 0,void 0,(function(){var n,r;return U(this,(function(i){return D(e instanceof It&&!e.scheduledInfo).throw(O.invalidParameters),n=new V,r=null!==(t=e.messageParams)&&void 0!==t?t:sn(e),this._sendUserMessage(r,di.RESEND,e.reqId).onFailed((function(e){return n.reject(e)})).onSucceeded((function(e){return n.resolve(e)})),[2,n.promise]}))}))},s.prototype.updateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},yn),t),D(h("number",e)&&_n(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new mr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(vr).message]}}))}))},s.prototype.copyUserMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof It&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),D(!n.poll).throw(O.notSupportedError),o=new V,c=null!==(r=n.messageParams)&&void 0!==r?r:t(u(u({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(a=n.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),e._sendUserMessage(c).onSucceeded((function(e){o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.translateUserMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof It&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Tr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(wr).message]}}))}))},s.prototype._createScheduledUserMessage=function(e,t){var r=this,i=n.of(this._iid).requestQueue,s=Date.now(),a=this._generateRequestId();Q(2).then((function(){var n=r._createPendingScheduledUserMessage(e,a,s);ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))}));var o=new Mr(u({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(o).then((function(e){var n=e.as(Sr).message;ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var i=r._createPendingScheduledUserMessage(e,a,s);r._markMessageAsFailed(i,n),ae((function(){return A(r,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,i)]}))}))}))}))}))},s.prototype.sendFileMessage=function(e){var t=u(u({},ln),e);return D(pn(t)).throw(O.invalidParameters),this._sendFileMessage(t)},s.prototype.sendMultipleFilesMessage=function(e){var t,r=u(u({},ni),e),i=n.of(this._iid);D(function(e,t){return void 0===t&&(t=ie),$t(e)&&h("string",e.message,!0)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return ri(e)}))}(r,null===(t=i.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(O.invalidParameters);var s=!!e.fileInfoList.find((function(e){var t=i.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return D(!s).throw(O.fileSizeLimitExceededError),this._sendMultipleFilesMessage(r)},s.prototype._sendFileMessage=function(e,t,r){var i=this;void 0===t&&(t=di.SEND);var s=n.of(this._iid).dispatcher,a=$s.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new Xt;return Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u);s.dispatch(new N({messages:[r],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(r)]}))}))})),a.request(i,o,e).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var r=i._createPendingFileMessage(e,o,u),a=n.of(i._iid).cacheContext,l=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&ue(t.code);i._markMessageAsFailed(r,t,l),s.dispatch(new N({messages:[r],source:r.sendingStatus===k.PENDING?C.REQUEST_RESEND_MESSAGE:t.code===P.FILE_UPLOAD_CANCEL_FAILED?C.LOCAL_MESSAGE_CANCELED:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,r)]}))}))}))}))}))})),c},s.prototype._autoResendFileMessage=function(e){D(e instanceof St&&!!e.messageParams).throw(O.invalidParameters);var t=n.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,di.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},s.prototype._sendMultipleFilesMessage=function(e,t,r){var i=this,s=n.of(this._iid).dispatcher,a=$s.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new ii;return Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);s.dispatch(new N({messages:[n],source:t===di.RESEND?C.LOCAL_MESSAGE_RESEND_STARTED:C.EVENT_MESSAGE_SENT_PENDING})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._trigger(n)]}))}))})),a.request(i,o,e,{requestHandler:c,isCopy:t===di.COPY}).then((function(e){s.dispatch(new N({messages:[e],source:C.EVENT_MESSAGE_SENT_SUCCESS})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(oe(t))throw t;Q(2).then((function(){var n=i._createPendingMultipleFilesMessage(e,o,u);i._markMessageAsFailed(n,t),s.dispatch(new N({messages:[n],source:C.EVENT_MESSAGE_SENT_FAILED})),ae((function(){return A(i,void 0,void 0,(function(){return U(this,(function(e){return[2,c._triggerFailed(t,n)]}))}))}))}))}))})),c},s.prototype._createScheduledFileMessage=function(e,t,r,i){var s=this,a=n.of(this._iid).requestQueue,o=new Ar(u(u({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(Ur).message;ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(n){if(oe(n))throw n;Q(2).then((function(){var a=s._createPendingScheduledFileMessage(e,r,i);s._markMessageAsFailed(a,n),ae((function(){return A(s,void 0,void 0,(function(){return U(this,(function(e){return[2,t._triggerFailed(n,a)]}))}))}))}))}))},s.prototype.sendFileMessages=function(e){var t,n;D(e.every((function(e){return pn(u(u({},ln),e))}))).throw(O.invalidParameters);var r=new Xt;try{for(var i=v(e),s=i.next();!s.done;s=i.next()){var a=s.value;this.sendFileMessage(a).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{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},s.prototype.resendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return U(this,(function(s){return n=this._validateFailedFileMessageHasFile(e,t),D(e instanceof St&&n&&!e.scheduledInfo).throw(O.invalidParameters),r=new V,i=fn(e,t),this._sendFileMessage(i,di.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),[2,r.promise]}))}))},s.prototype.resendMessage=function(e,t){var n,r;if(D(e instanceof mt&&!e.scheduledInfo&&e.isResendable).throw(O.invalidParameters),e.isUserMessage()){var i=null!==(n=e.messageParams)&&void 0!==n?n:sn(e);return this._sendUserMessage(i,di.RESEND,e.reqId)}if(e.isFileMessage()){var s=this._validateFailedFileMessageHasFile(e,t);D(s).throw(O.invalidParameters);i=null!==(r=e.messageParams)&&void 0!==r?r:fn(e,t);return this._sendFileMessage(i,di.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.updateFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=u(u({},gn),t),D(h("number",e)&&function(e){return vn(e)}(r)).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new yr(u({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(_r).message]}}))}))},s.prototype.uploadFile=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=n.of(this._iid).requestQueue,r=se(),(i=new Pe({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:r})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(r),[4,t.send(i)];case 1:return s=c.sent(),a=s.as(ke),o=a.url,u=a.thumbnails,[2,{requestId:r,url:o,thumbnails:u}]}}))}))},s.prototype.cancelUploadingFileMessage=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),$s.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},s.prototype.copyFileMessage=function(e,n){var r,i,a;return A(this,void 0,void 0,(function(){var o,c;return U(this,(function(l){return D(e instanceof s&&n instanceof St&&n.sendingStatus===k.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(O.invalidParameters),o=new V,c=t(u(u({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:q.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=n.thumbnails)||void 0===a?void 0:a.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(c).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},s.prototype.copyMessage=function(e,t){D(e instanceof s&&t instanceof mt&&t.sendingStatus===k.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(O.invalidParameters);var n=t,r=e;if(n.isUserMessage()){D(!n.poll).throw(O.notSupportedError);var i=nn(n);return r._sendUserMessage(i)}if(n.isFileMessage()){i=dn(n);return r._sendFileMessage(i)}if(t.isMultipleFilesMessage())throw O.channelTypeNotSupportedError},s.prototype.deleteMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(e instanceof pt).throw(O.invalidParameters),e.messageId>0?(t=n.of(this._iid).requestQueue,r=new de({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof mt?e._messageToken:void 0}),[4,t.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},s.prototype.addReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new gr({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(br).reactionEvent]}}))}))},s.prototype.deleteReaction=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(e instanceof pt&&e.messageId>0&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Ir({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Er).reactionEvent]}}))}))},s.prototype._updateUserMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new mr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(vr).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype._updateFileMessageMetaArray=function(e,t,r,i){return A(this,void 0,void 0,(function(){var s,a,o,u,c,l;return U(this,(function(d){switch(d.label){case 0:return s=n.of(this._iid),a=s.dispatcher,o=s.requestQueue,u=new yr({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:r,upsert:i}}),[4,o.send(u)];case 1:return c=d.sent(),l=c.as(_r).message,a.dispatch(new N({messages:[l],source:C.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},s.prototype.createMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new Ke({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},s.prototype.deleteMessageMetaArrayKeys=function(e,t){return A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return D(e instanceof pt&&e.messageId>0&&d("string",t)).throw(O.invalidParameters),n=t.map((function(e){return new Ke({key:e})})),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},s.prototype.addMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof Ke}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},s.prototype.removeMessageMetaArrayValues=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return D(e instanceof pt&&e.messageId>0&&t.every((function(e){return e instanceof Ke}))).throw(O.invalidParameters),e instanceof St?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},s.prototype.report=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return D(f(hn,e)&&h("string",t)).throw(O.invalidParameters),r=n.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new lr({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:t}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.reportUser=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof c&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new dr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.userId,category:t,description:r}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.reportMessage=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return D(e instanceof mt&&f(hn,t)&&h("string",r)).throw(O.invalidParameters),i=n.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new hr({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:t,description:r,messageToken:e._messageToken}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},s.prototype.updatePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return D(h("number",e)&&function(e){return h("string",e.title,!0)&&te(e.data)&&h("boolean",e.allowUserSuggestion,!0)&&h("boolean",e.allowMultipleVotes,!0)&&h("number",e.closeAt,!0)}(t)).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Nr(u({pollId:e},t)),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Cr).poll]}}))}))},s.prototype.deletePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i;return U(this,(function(s){switch(s.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Or({pollId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},s.prototype.closePoll=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=h("number",e),D(t).throw(O.invalidParameters),r=n.of(this._iid).requestQueue,i=new Pr({pollId:e}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(kr).poll]}}))}))},s.prototype.addPollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return r=h("number",e)&&h("string",t)&&""!==t.trim(),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Rr({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(xr).poll]}}))}))},s.prototype.updatePollOption=function(e,t,r){return A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(u){switch(u.label){case 0:return i=h("number",e)&&h("number",t)&&h("string",r)&&""!==r.trim(),D(i).throw(O.invalidParameters),s=n.of(this._iid).requestQueue,a=new Dr({pollId:e,pollOptionId:t,optionText:r}),[4,s.send(a)];case 1:return o=u.sent(),[2,o.as(Lr).poll]}}))}))},s.prototype.deletePollOption=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s;return U(this,(function(a){switch(a.label){case 0:return r=h("number",e)&&h("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid).requestQueue,s=new Fr({pollId:e,pollOptionId:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},s.prototype.votePoll=function(e,t){return A(this,void 0,void 0,(function(){var r,i,s,a,o,u,c;return U(this,(function(l){switch(l.label){case 0:return r=h("number",e)&&d("number",t),D(r).throw(O.invalidParameters),i=n.of(this._iid),s=i.requestQueue,a=i.dispatcher,o=new qr({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(zr).event,a.dispatch(new he({event:c,source:C.EVENT_POLL_VOTED})),[2,c]}}))}))},s.prototype.getPollChangeLogsSinceTimestamp=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("number",e)).throw(O.invalidParameters),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.getPollChangeLogsSinceToken=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return D(h("string",e,!0)),[4,fe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new ce(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},s.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new le(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},s.prototype.pinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new ci({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s.prototype.unpinMessage=function(e){return A(this,void 0,void 0,(function(){var t,r;return U(this,(function(i){switch(i.label){case 0:return D(h("number",e)&&e>0).throw(O.invalidParameters),t=n.of(this._iid).requestQueue,r=new li({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(r)];case 1:return i.sent(),[2]}}))}))},s}(l),mi=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 r(t,e),t}((function(){this.onConnected=Y,this.onReconnectStarted=Y,this.onReconnectSucceeded=Y,this.onReconnectFailed=Y,this.onDisconnected=Y})),vi=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 r(t,e),t}((function(){this.onSessionExpired=Y,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=Y,this.onSessionRefreshed=Y,this.onSessionClosed=Y})),yi=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 r(t,e),t}((function(){this.onFriendsDiscovered=Y,this.onTotalUnreadMessageCountChanged=Y,this.onTotalUnreadMessageCountUpdated=Y})),_i=function(t){function n(n){var r=n.limit,s=n.token,a=n.userIdsFilter,o=n.metaDataKeyFilter,u=n.metaDataValuesFilter,c=n.nicknameStartsWithFilter,l=t.call(this)||this;return l.method=i.GET,l.path=pe,l.params=e({limit:r,token:s,user_ids:a,metadatakey:o,metadatavalues_in:u,nickname_startswith:c}),l}return r(n,t),n}(a),gi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),bi=function(e){function i(t,n){var r,i,s,a=this;return(a=e.call(this,t,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)&&h("string",this.metaDataKeyFilter,!0)&&d("string",this.metaDataValuesFilter,!0)&&h("string",this.nicknameStartsWithFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new _i(t(u(u({},this),{token:this._token}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(gi),a=s.users,o=s.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),Ii=function(t){function n(n){var r=n.userId,s=n.limit,a=n.token,o=n.userIdsFilter,u=t.call(this)||this;return u.method=i.GET,u.path="".concat(pe,"/").concat(r,"/block"),u.params=e({limit:s,token:a,user_ids:o}),u}return r(n,t),n}(a),Ei=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Ti=function(e){function i(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&d("string",this.userIdsFilter,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Ii(t(u(u({},this),{userId:r.userId,token:this._token}))),[4,i.send(s)]):[3,2]:[3,5];case 1:return a=d.sent(),o=a.as(Ei),c=o.users,l=o.next,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,c];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),wi=function(e){function t(t){var n=t.userId,r=t.limit,s=t.token,a=e.call(this)||this;return a.method=i.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(n),"/friends"),a.params={limit:r,token:s},a}return r(t,e),t}(a),Mi=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 c(t,e)})),r.next=n.next,r}return r(t,e),t}(o),Si=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid),t=e.sdkState,r=e.requestQueue,i=new wi(u(u({},this),{userId:t.userId,token:this._token})),[4,r.send(i)]):[3,2]:[3,5];case 1:return s=d.sent(),a=s.as(Mi),o=a.users,c=a.hasMore,l=a.next,this._token=l,this._hasNext=c,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(me),Ai={},Ui=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,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,d=void 0===l?11:l,h=e.transactionApplyDelay,f=void 0===h?200:h,p=e.disableLogger,m=void 0!==p&&p;return Ai[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=c,this.blockHashConstant=d,this.transactionApplyDelay=f,this.disableLogger=m,Ai[t]=this),Ai[t]}return e.get=function(e){return Ai[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_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"}(fi||(fi={}));var Ni,Ci=function(e){function t(n){var r=n.code,i=void 0===r?fi.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 r(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:fi.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.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:fi.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:fi.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:fi.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:fi.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:fi.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:fi.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:fi.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:fi.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:fi.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:fi.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:fi.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:fi.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:fi.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:fi.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:fi.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"}(Ni||(Ni={}));var Oi,Pi=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Ci.circularReferenceFound;var n;return t.set(e,!0),Array.isArray(e)?n=e.map((function(e){return Pi(e,t)})):e instanceof RegExp||e instanceof Date?n=e:(n={},Object.keys(e).forEach((function(r){n[r]=Pi(e[r],t)}))),t.delete(e),n}return e},ki=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Ci.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Ri=function(e,t){for(var n=0,r=0;r>>0)%t},xi=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Di=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!Di(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Di(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(!(ki(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(ki(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(ki(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(ki(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)},Li=function(){},Fi=function(){return Promise.resolve()},qi=function(e){return e},zi=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Oi||(Oi={}));var Bi,ji,Ki,Qi=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?qi:a,u=e.backward,c=void 0===u?Fi:u,l=e.forward,d=void 0===l?Fi:l,h=e.complete,f=void 0===h?Li:h;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=c,this._forward=d,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 A(this,void 0,void 0,(function(){var e,t,n;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(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}(),Gi=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(h=0;h0?n:t;for(var o in this.condition[i])if(a.includes(o))for(var u=r;u>=0;u--)if(s*ki(this._indexer.origin[u].columnValues[h],this.condition[i][o])<=0){r=u;break}}else for(u=r;u>=0;u--)if(s*ki(this._indexer.origin[u].columnValues[h],this.condition[i])<=0){r=u;break}}return Math.min(r+1,this._indexer.origin.length-1)}var c=0;if("function"!=typeof this.condition)for(var l=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=c;o=0){c=o;break}}));else for(var a=c;a=0){c=a;break}},d=this,h=0;h-1){var r=this._items[n];return t===Ki.PERSISTENT&&(r.state=ji.PERSISTENT),t!==Ki.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)ts.includes(this._items[r].state)&&ts.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 i=this._items.filter((function(e){return e.state===ji.VOLATILE})),s=i.length-this._limit;if(s>0){var a=[];try{for(var o=v(this._items),u=o.next();!u.done;u=o.next()){var c=u.value;c.state===ji.VOLATILE&&s>0?s--:a.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this._items=a}}}},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.clearForDatabase=function(e){this.clearByCondition((function(t){return t.key.startsWith(Hi(e))}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==ji.VOLATILE}))},e}(),is=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(Wi(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(Wi(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=[]),A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,p([],m(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],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,c,l,d;return U(this,(function(h){switch(h.label){case 0:n=rs.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return u(u({},e.data),{generation:r})})))];case 2:for(a=h.sent(),o=0;o0))return[3,4];for(t=[],n={},o=e.length-1;o>=0;o--)r=e[o],l=r.data,n[l.key]||(n[l.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=p.sent(),[4,this._store.set({key:this.recordsetKey,value:s})];case 2:return p.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(p.sent(),a=rs.get(this.dbname),o=0;o0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=a.sent())&&(s=ss.createFromCacheItem(i),null==s?void 0:s.getItemByKey(e)))return[2,s];a.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return n=Ui.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,rs.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(null==(a=s?ss.createFromCacheItem(s):new ss({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:a.add(t))?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var e,t,n;return U(this,(function(r){switch(r.label){case 0:return e=Ji(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(),rs.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),os=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 u=function(e,t,n){return"".concat(Wi(e,t),"/index.").concat(n)}(t,n,i.join(">"));this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=u,this._store=a,this._transaction=s,this._transaction.on(Bi.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Bi.ERROR,this.indexerKey,(function(){return o.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=m(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=m(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var a=v(this.fields),o=a.next();!o.done;o=a.next()){var u=o.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw Ci.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=ki(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 A(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,y;return U(this,(function(_){switch(_.label){case 0:return[4,(e=rs.get(this.dbname)).find(this._store,this.indexerKey,Ki.PERSISTENT)];case 1:return(t=_.sent())?[3,11]:(n=Ji(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=_.sent(),_.label=3;case 3:_.trys.push([3,8,9,10]),i=v(r),s=i.next(),_.label=4;case 4:return s.done?[3,7]:(a=s.value).startsWith(n)?[4,e.find(this._store,a,Ki.NO_CACHE)]:[3,6];case 5:if(o=_.sent(),u=ss.createFromCacheItem(o))try{for(m=void 0,c=v(u.items),l=c.next();!l.done;l=c.next())d=l.value,this._addItem(d)}catch(e){m={error:e}}finally{try{l&&!l.done&&(y=c.return)&&y.call(c)}finally{if(m)throw m.error}}_.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return h=_.sent(),f={error:h},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=Pi(this._origin),_.label=12;case 12:return[2]}}))}))},e.prototype.drop=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return rs.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.addItem=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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=Pi(this._origin)},e.prototype.abort=function(){this._table=Pi(this._origin)},e}(),us=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},cs=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"}($i||($i={})),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"}(es||(es={}));var ls,ds={},hs=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=$i.PROCESSING,this._queue=[],this._activationQueue=[],ds[e]&&!t.forceCreate||(this.nodeId=cs(),this.key=e,us()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data;if(null==i?void 0:i.isNestDbMessage){var s=i.nodeId,a=i.requestId,o=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&o===n.key)switch(u){case es.NEWNODE:n._sendSync();break;case es.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case es.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,d=l.currentItemRequestId,h=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:es.REQUEST_LOCK,ts:e.ts})};try{for(var p=v(h),m=p.next();!m.done;m=p.next()){f(m.value)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case es.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case es.REQUEST_LOCK:n._requestLock(i);break;case es.ACQUIRE_LOCK:var y=n._queue.find((function(e){return e.requestId===a}));n._acquire(y);break;case es.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(es.REMOVENODE)}))),ds[e]=this),ds[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==$i.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:cs(),key:this.key,op:e,data:t.data,ts:Date.now()};return us()&&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(es.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){for(var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(es.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},i=!1,s=0;sr.ts){t._queue.splice(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(es.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 A(this,void 0,void 0,(function(){var e=this;return U(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=$i.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(es.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(es.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(es.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}(),fs=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=Ni.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=p([[r]],m(s.filter((function(e){return os.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new hs(function(e,t){return"".concat(Wi(e,t),".lock")}(t,n)),this._blobContainer=new Zi({dbname:t,collectionName:n,store:a}),this._transaction=new is({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return r=Yi(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===Ni.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,y,_=this;return U(this,(function(g){switch(g.label){case 0:return[4,this._mutex.lock()];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,9,,10]),t=Ui.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=g.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:g.sent(),this._blockManager=new as({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=p([],m(this.indexes),!1),i=[],s=r.map((function(e){return os.createKey(e)})),a=n?n.indexes.map((function(e){return os.createKey(e)})):[];try{for(o=v(a),u=o.next();!u.done;u=o.next())c=u.value,s.includes(c)||i.push(os.parseKey(c))}catch(e){f={error:e}}finally{try{u&&!u.done&&(y=o.return)&&y.call(o)}finally{if(f)throw f.error}}return(l=[]).push.apply(l,p([],m(r.map((function(e){var t=new os({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,p([],m(i.map((function(e){return new os({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return g.sent(),[4,this._transaction.commit()];case 6:return g.sent(),s.sort().join(",")===a.sort().join(",")?[3,8]:(d=Yi(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:d,value:this._metadata})]);case 7:g.sent(),g.label=8;case 8:return this._state=Ni.READY,this._mutex.unlock(),[3,10];case 9:throw h=g.sent(),this._mutex.unlock(),h;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Ni.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=os.createKey(e);try{for(var i=v(this._indexers),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===os.createKey(a.fields))return a}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw Ci.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return e=Yi(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return o.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return o.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return o.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:o.sent(),o.label=5;case 5:o.trys.push([5,10,11,12]),n=v(this._indexers),r=n.next(),o.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:o.sent(),o.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=o.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw Ci.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=v(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),a=v(this._indexers),o=a.next(),p.label=16;case 16:return o.done?[3,20]:0===(u=o.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return o=a.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),h={error:c},[3,23];case 22:try{o&&!o.done&&(f=a.return)&&f.call(a)}finally{if(h)throw h.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=v(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return a=c.sent(),o={error:a},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=o.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:o.sent(),o.label=3;case 3:o.trys.push([3,8,9,10]),n=v(this._indexers),r=n.next(),o.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:o.sent(),o.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=o.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return U(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=v(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(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,Pi(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Ci.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new Vi({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ci.collectionNotReady},e.prototype.insertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestInsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpsert(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return U(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Ci.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=v(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Pi(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionKeyNotGiven;return[4,this._requestUpdate(Pi(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p,m,y=this;return U(this,(function(_){switch(_.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:_.sent(),_.label=2;case 2:return _.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,a=e.backward,o=void 0!==a&&a,u=[],[4,new Gi({condition:r,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(s)}).each((function(e){return A(y,void 0,void 0,(function(){var n;return U(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(n=e.nextValue,Di(r,n)&&t.set&&("function"!=typeof t.set?Object.keys(t.set).forEach((function(e){var r;n[e]=null===(r=t.set)||void 0===r?void 0:r[e]})):t.set(n),u.push(n)),e.next()):e.stop(),[2]}))}))}))];case 3:_.sent(),_.label=4;case 4:_.trys.push([4,9,10,11]),c=v(u),l=c.next(),_.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestUpdate(Pi(d))]);case 6:_.sent(),_.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return h=_.sent(),p={error:h},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return _.sent(),this._mutex.unlock(),[2,u];case 13:return f=_.sent(),[4,this._transaction.clear()];case 14:throw _.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),Ci.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m=this;return U(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,a=void 0!==s&&s,o=[],[4,new Gi({condition:n,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(i)}).each((function(e){return A(m,void 0,void 0,(function(){var t,r;return U(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Di(n,t)&&(r=t[this.keyName],o.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=v(o),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return d=y.sent(),f={error:d},[3,11];case 10:try{c&&!c.done&&(p=u.return)&&p.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,o];case 13:throw h=y.sent(),this._mutex.unlock(),h;case 14:return[3,16];case 15:throw this._transaction.clear(),Ci.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(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 Ci.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),ps="[NESTDB]",ms=!0,vs=function(){function e(){}return e.off=function(){ms=!1},e.log=function(){for(var e=[],t=0;t1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return A(o,void 0,void 0,(function(){var n,i;return U(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw Ci.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}}))}))})))]:[3,4];case 3:return a=u.sent(),[3,5];case 4:a=[r],u.label=5;case 5:return s=a,[2,this.encryption.decrypt(JSON.parse(s.join("")))];case 6:return u.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,u({},e.value)]}}))}))},e.prototype.setMany=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,p([],m(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a=this;return U(this,(function(o){switch(o.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=o.sent())?(r=n.metadata,i=this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return a._getRawKey(e,".".concat(t))})),[4,this._removeRaw(i)]):[3,3];case 2:return o.sent(),null==(s=rs.get(this.dbname))||s.remove(e),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d=this;return U(this,(function(h){switch(h.label){case 0:t=rs.get(this.dbname),n=[],r=function(e){var r,s,a;return U(this,(function(o){switch(o.label){case 0:return r=i._getRawKey(e,".0"),[4,i._getRaw(r)];case 1:return(s=o.sent())&&(a=s.metadata,n.push.apply(n,p([],m(i._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return d._getRawKey(e,".".concat(t))}))),!1))),null==t||t.remove(e),[2]}}))},i=this,h.label=1;case 1:h.trys.push([1,6,7,8]),s=v(e),a=s.next(),h.label=2;case 2:return a.done?[3,5]:(o=a.value,[5,r(o)]);case 3:h.sent(),h.label=4;case 4:return a=s.next(),[3,2];case 5:return[3,8];case 6:return u=h.sent(),c={error:u},[3,8];case 7:try{a&&!a.done&&(l=s.return)&&l.call(s)}finally{if(c)throw c.error}return[7];case 8:return n.length>0?[4,this._removeRaw(n)]:[3,10];case 9:h.sent(),h.label=10;case 10:return[2,e]}}))}))},e.prototype.clear=function(){return A(this,void 0,void 0,(function(){var e;return U(this,(function(t){return null==(e=rs.get(this.dbname))||e.clearForDatabase(this.dbname),[2]}))}))},e}(),gs={},bs=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,u(u({},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 r(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return gs[this.dbname]},set:function(e){gs[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(gs[this.dbname])return[2,Object.keys(gs[this.dbname])];throw Ci.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return gs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:return t.sent(),[2,gs[this.dbname][e]?u({key:e},gs[this.dbname][e]):null];case 2:throw Ci.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return U(this,(function(c){switch(c.label){case 0:return gs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:c.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,s=r.data,a=r.metadata,gs[this.dbname][i]=Object.freeze({data:s,metadata:a})}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}}return[3,3];case 2:throw Ci.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return gs[this.dbname]?[4,xi(this.delay)]:[3,2];case 1:a.sent();try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,gs[this.dbname][r]&&delete gs[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw Ci.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 A(this,void 0,void 0,(function(){return U(this,(function(e){return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,gs[this.dbname]||(gs[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.set=function(t){return A(this,void 0,void 0,(function(){var n,r;return U(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 A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u;return U(this,(function(c){try{for(n=v(t),r=n.next();!r.done;r=n.next())if(i=r.value,(s=this.observer[i.key])&&"function"==typeof s.set&&(a=s.set()))throw a}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return t.sent(),[4,xi(this.delay)];case 2:return t.sent(),gs[this.dbname]={},[2]}}))}))},t}(_s),Is="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(ls||(ls={}));var Es,Ts=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=Is,r._state=ls.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 r(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype.isTransactionInactiveError=function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")},t.prototype._putToObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.put(t);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))]}))}))},t.prototype._deleteFromObjectStore=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){return[2,new Promise((function(n,r){var i=e.delete(t);i.addEventListener("success",(function(){return n(t)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))]}))}))},t.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=ls.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Is,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=ls.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=ls.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=ls.UNINITIALIZED,r(e.target.error)}))}else r(Ci.storeNotAvailable)}))},t.prototype._getObjectStore=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 ls.UNINITIALIZED:case ls.OPEN:return[3,2];case ls.OPENING:case ls.CLOSED:return[3,3]}return[3,4];case 2:throw Ci.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 A(this,void 0,void 0,(function(){var e;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._putToObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._putToObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c=this;return U(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:t=l.sent(),l.label=2;case 2:return l.trys.push([2,4,,15]),[4,Promise.all(e.map((function(e){return c._deleteFromObjectStore(t,e)})))];case 3:return l.sent(),[3,15];case 4:if(n=l.sent(),!this.isTransactionInactiveError(n))return[3,13];l.label=5;case 5:l.trys.push([5,10,11,12]),r=v(e),i=r.next(),l.label=6;case 6:return i.done?[3,9]:(s=i.value,[4,this._deleteFromObjectStore(t,s)]);case 7:l.sent(),l.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=l.sent(),o={error:a},[3,12];case 11:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){var e,t=this;return U(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||!us())return[3,4];if(!(us()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Ci.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(Ci.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),t._indexedDb){var i=t._indexedDb.deleteDatabase("_testMozilla");i.onerror=function(){return e()},i.onsuccess=function(){return e()}}else n(Ci.storeNotAvailable)}}catch(e){n(Ci.storeNotAvailableInPrivateBrowsing)}else n(Ci.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Ci.storeNotAvailable;case 5:return[3,7];case 6:throw Ci.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(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(),[4,this._resetIfEncryptionChanged()];case 3:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this._getObjectStore("readwrite")];case 2:return t=n.sent(),[4,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 3:return[2,n.sent()]}}))}))},t}(_s),ws=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?2097152:i,a=ye(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,u(u({},a),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a,o;return U(this,(function(u){switch(u.label){case 0:t=[];try{for(n=v(e),r=n.next();!r.done;r=n.next())i=r.value,s=i.key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(s),JSON.stringify(i)])}catch(e){a={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return u.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(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 A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._asyncStorage)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}}))}))},t}(_s),Ms=function(e){function t(t){var n,r=this;return(r=e.call(this,u(u({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}return r(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 A(this,void 0,void 0,(function(){var e,t=this;return U(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 A(this,void 0,void 0,(function(){var t;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){try{for(t=v(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.checkAvailability=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){if(!this._mmkv)throw Ci.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}}))}))},t}(_s);!function(e){e.INIT="INIT",e.OPENING="OPENING",e.OPENED="OPENED",e.CLOSED="CLOSED"}(Es||(Es={}));var Ss,As=function(){function e(e){var t=e.name,n=e.version,r=e.store,i=e.config;this.name=t,this._version=n,this._state=Es.INIT,this._config=i||new Ui({dbname:t}),this._store=r,this._event={success:Li,error:Li,storeReplaced:Li,upgrade:zi},this._collections=new Map,this._globalMutex=new hs("".concat(this.name,".lock")),this._config.disableLogger&&vs.off(),new rs({dbname:t,limit:this._config.cacheLimit})}return Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),e.prototype.estimateUsage=function(){return A(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,(t=this._store,A(void 0,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,t.usage()];case 1:return[2,e.sent()]}}))})))];case 1:return[2,e.sent()]}var t}))}))},e.prototype.commitSchema=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this._state!==Es.OPENING?[3,2]:[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return t=e.collectionName,n=e.keyName,r=e.index,i=void 0===r?[]:r,this._collections.has(t)||this._collections.set(t,new fs({dbname:this.name,collectionName:t,keyName:n,indexes:i,store:this._store})),(s=this._collections.get(t))?[4,s.init()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[3,3];case 2:throw Ci.databaseSchemaNotOnUpgrade;case 3:return[2]}}))}))},e.prototype.open=function(){var e;return A(this,void 0,void 0,(function(){var t,n,r,i,s=this;return U(this,(function(a){switch(a.label){case 0:return[4,this._globalMutex.lock()];case 1:if(a.sent(),this._state===Es.OPENED)return[3,12];this._state=Es.OPENING,a.label=2;case 2:return a.trys.push([2,5,,12]),[4,this._store.init(this.name)];case 3:return a.sent(),o=this.name,t="".concat(Hi(o),".metadata"),n={version:0,collectionNames:[]},[4,this._store.get(t)];case 4:return r=null!==(e=a.sent())&&void 0!==e?e:n,[2,new Promise((function(e,n){var i=function(e){r.version0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof mt))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof pt)switch(this.replyType){case H.NONE:if(e.parentMessageId>0)return!1;break;case H.ONLY_REPLY_TO_CHANNEL:if(e instanceof mt&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Us||(Us={}));var Os,Ps=function(e){switch(e){case Us.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Us.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},ks=function(){return["channelUrl","-createdAt","-notificationId"]},Rs=u(u({},tn),{scheduledAt:void 0}),xs=function(e){return an(e)&&h("number",e.scheduledAt,!0)},Ds=u(u({},Zt),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ls=function(e){return $t(e)&&h("number",e.scheduledAt)&&(G(e.file)||h("string",e.fileUrl))&&h("string",e.fileName,!0)&&h("string",e.mimeType,!0)&&h("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return h("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Fs="UnsentMessage",qs="reqId",zs={},Bs=function(t){function i(e){var n=t.call(this,e)||this;return n._mutex=new hs("unsendmessagecache.lock"),zs[e]=n,n}return r(i,t),Object.defineProperty(i.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),i.of=function(e,t){return void 0===t&&(t=!1),zs[e]&&!t||(zs[e]=new i(e)),zs[e]},Object.defineProperty(i.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Fs);if(!t)throw O.databaseError;return t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),i.prototype._serialize=function(t){if(t.messageId>0)throw O.invalidParameters;var n,r=u({},t.serialize());return t instanceof It?(t.messageParams&&(r.messageParams=en(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=(n=t.scheduledInfo.scheduledMessageParams,u(u({},en(n)),{scheduledAt:n.scheduledAt})))):t instanceof St?(t.messageParams&&(r.messageParams=cn(t.messageParams)),t.scheduledInfo&&t.scheduledInfo.scheduledMessageParams&&(r.scheduledInfo.scheduledMessageParams=function(e){return u(u({},cn(e)),{scheduledAt:e.scheduledAt})}(t.scheduledInfo.scheduledMessageParams))):t instanceof Et&&t.messageParams&&(r.messageParams=function(t){return e({fileInfoList:t.fileInfoList,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption})}(t.messageParams)),r},i.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),$s.of(this._iid).buildMessageFromSerializedData(e)},i.prototype._deserializeWithMessageCreateParams=function(e){var t,n,r;return A(this,void 0,void 0,(function(){var i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return i=$s.of(this._iid),s=this._deserialize(e),e.messageParams?s instanceof It?(o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),[3,6]):[3,1]:[3,6];case 1:return s instanceof St?(o=e.messageParams).fileKey&&"string"==typeof o.fileKey&&un(null!==(t=o.fileType)&&void 0!==t?t:"")?(a=o,[4,this.collection.getBlob(o.fileKey)]):[3,3]:[3,4];case 2:a.file=null!==(n=d.sent())&&void 0!==n?n:void 0,d.label=3;case 3:return s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(o,s),[3,6];case 4:return s instanceof Et&&((o=e.messageParams)&&o.fileInfoList)?(s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(o,s),[4,Promise.all(s.messageParams.fileInfoList.map((function(e){return A(l,void 0,void 0,(function(){var t,n,r,i,s;return U(this,(function(a){switch(a.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&un(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!==(s=a.sent())&&void 0!==s?s:void 0,a.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:d.sent(),d.label=6;case 6:return s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?s instanceof It?(u=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(u,s),[3,10]):[3,7]:[3,10];case 7:return s instanceof St?(u=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof u.fileKey&&"string"==typeof u.fileType&&un(u.fileType)?(c=u,[4,this.collection.getBlob(u.fileKey)]):[3,9]:[3,10];case 8:c.file=null!==(r=d.sent())&&void 0!==r?r:void 0,d.label=9;case 9:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(u,s),d.label=10;case 10:return[2,s]}}))}))},i.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},i.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new Cs:n,i=e.order,s=void 0===i?Us.CHANNEL_LATEST:i,a=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return A(this,void 0,void 0,(function(){var e,n,i,o,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?(e=Ps(s),n={"/where":function(e){return!!(s!==Us.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(l._deserialize(e))}},t&&(n.channelUrl=t),a&&(n.sendingStatus=a),i={where:n,index:e,backward:u},[4,this.collection.query(i)]):[3,3];case 1:return[4,d.sent().fetch({})];case 2:return o=d.sent(),[2,Promise.all(o.map((function(e){return A(l,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},i.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Cs),A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:Us.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},i.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return e instanceof St||e instanceof Et?[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]}}))}))},i.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return U(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]}}))}))},i.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},i.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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]}}))}))},i.prototype.saveBlob=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i=this;return U(this,(function(s){switch(s.label){case 0:return e instanceof St?e.messageParams&&(r=e.messageParams).file&&on(r.file)?[4,this.collection.saveBlob(r.file,e.reqId)]:[3,2]:[3,5];case 1:n=s.sent(),r.fileKey=n,r.fileType=rn.BLOB,s.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&on(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=s.sent(),t.fileKey=n,t.fileType=rn.BLOB,s.label=4;case 4:return[3,7];case 5:return e instanceof Et&&((r=e.messageParams)&&r.fileInfoList&&Array.isArray(r.fileInfoList))?[4,Promise.all(r.fileInfoList.map((function(t,n){return A(i,void 0,void 0,(function(){var r;return U(this,(function(i){switch(i.label){case 0:return t.file&&on(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=rn.BLOB,i.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},i}(l),js={},Ks=function(e){function t(t){var n=e.call(this,t)||this;return js[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Bs.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),js[e]&&!n||(js[e]=new t(e)),js[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Gr)},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 u(u({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=u(u({},e),{messageId:parseInt(e.messageId)}),$s.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Cs:s,o=e.order,u=void 0===o?Us.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,d=e.parentMessageId,h=e.isPollOnly,f=void 0!==h&&h,p=e.exactMatch,m=void 0!==p&&p,v=e.inclusive,y=void 0===v||v;return A(this,void 0,void 0,(function(){var e,r,s,o=this;return U(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=Ps(u),r={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Us.CHANNEL_LATEST:if(m&&e.createdAt!==n)return!1;if(l){if(y&&e.createdAtn||!y&&e.createdAt>=n)return!1;break;case Us.NEWEST_CHILD_MESSAGE:if(!d||0===e.parentMessageId||e.parentMessageId!==d)return!1}return!(f&&!e._poll)&&a.match(o._deserialize(e))}},index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({limit:null!=i?i:void 0})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return A(o,void 0,void 0,(function(){return U(this,(function(t){return[2,this._deserialize(e)]}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Cs),A(this,void 0,void 0,(function(){return U(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:Us.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l=this;return U(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,13];case 1:d.sent(),d.label=2;case 2:d.trys.push([2,7,8,9]),n=v(e),r=n.next(),d.label=3;case 3:return r.done?[3,6]:(i=r.value,(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)?[4,this.get(i.messageId)]:[3,5]);case 4:(null==(s=d.sent())?void 0:s.threadInfo)&&i.threadInfo._updateFrom(s.threadInfo),d.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return a=d.sent(),u={error:a},[3,9];case 8:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 9:return o=e.map((function(e){return l._serialize(e)})),[4,this.collection.upsertMany(o)];case 10:return d.sent(),[4,this.upsertChildMessages(e)];case 11:return d.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 12:d.sent(),d.label=13;case 13:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:Ps(Us.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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:Ps(Us.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=Ps(Us.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 A(this,void 0,void 0,(function(){var t=this;return U(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return e instanceof St&&e.messageParams&&((t=e.messageParams).file&&on(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 A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.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=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return s=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return a=o.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),s&&(t+=JSON.stringify(s).length),a&&(t+=JSON.stringify(a).length),[2,t]}}))}))},t}(l),Qs={},Gs=function(e){function t(t){var n=e.call(this,t)||this;return Qs[t]=n,n}return r(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return n.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),Qs[e]&&!n||(Qs[e]=new t(e)),Qs[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return D(!!e).throw(O.databaseError),e.collection(Wr)},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 u({},e.serialize())},t.prototype._deserialize=function(e){return $s.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey(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,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Cs:s,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,d=e.inclusive,h=void 0===d||d;return A(this,void 0,void 0,(function(){var e,r=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(e={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(h&&e.createdAtn||!h&&e.createdAt>=n)return!1}return a.match(r._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},[4,this.collection.query(e)]):[3,3];case 1:return[4,s.sent().fetch({limit:null!=i?i:void 0})];case 2:return[2,s.sent().map((function(e){return r._deserialize(e)}))];case 3:return[2,[]]}}))}))},t.prototype.upsert=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return U(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?(t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=v(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},t.prototype.markAsReadByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,messageStatus:ft.SENT,createdAt:{"<":t}}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.markAsReadByMessageIds=function(e,t){return A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:ft.SENT}},{set:{messageStatus:ft.READ}})]:[3,2];case 1:return[2,n.sent().length];case 2:return[2,0]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]})]:[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 A(this,void 0,void 0,(function(){return U(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:Ps(Us.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return A(this,void 0,void 0,(function(){return U(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 A(this,void 0,void 0,(function(){var r,i=this;return U(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=["channelUrl","-createdAt","-notificationId"],[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}(l),Vs={},Hs=function(e){function t(t){var n=e.call(this,t)||this;return n._observers=new Map,n._dispatcherContext=n._dispatcher.on((function(e){return A(n,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m,v,y,_,g,b=this;return U(this,(function(E){switch(E.label){case 0:return e instanceof N?(t=e.messages,g=e.source,a=e.isWebSocketEventComing,n=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&e.messageId>0})),r=t.filter((function(e){return e instanceof pt&&e.channelType!==I.OPEN&&0===e.messageId})),i=t.filter((function(e){return e instanceof Tt})),n.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(n)];case 1:return e.sent(),[4,this._unsentMessageCache.remove(n.map((function(e){return e instanceof mt?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,7];case 1:E.sent(),a||this._broadcastUpdateEvent(n,g),E.label=2;case 2:return r.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.upsert(r)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:E.sent(),a||this._broadcastUpdateEvent(r,g),E.label=4;case 4:return i.length>0?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._notificationCache.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,6];case 5:E.sent(),a||this._broadcastUpdateEvent(i,g),E.label=6;case 6:return[3,24];case 7:return e instanceof we?(s=e.messageIds,g=e.source,a=e.isWebSocketEventComing,o=s.filter((function(e){return"number"==typeof e})),u=s.filter((function(e){return"string"==typeof e})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return o.length>0?[4,this._messageCache.remove(o)]:[3,2];case 1:e.sent(),e.label=2;case 2:return u.length>0?[4,this._notificationCache.remove(u)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))}))]):[3,9];case 8:return E.sent(),a||this._broadcastRemoveEvent(s,g),[3,24];case 9:return e instanceof Te?(c=e.reqId,g=e.source,[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.remove([c])];case 1:return e.sent(),[2]}}))}))}))]):[3,11];case 10:return E.sent(),this._broadcastRemoveUnsentEvent(c,g),[3,24];case 11:return e instanceof Ee?(l=e.polls,g=e.source,this._cacheContext.localCacheEnabled?(d=l.map((function(e){return e.messageId})),[4,Promise.all(d.map((function(e){return b._messageCache.get(e)})))]):[3,14]):[3,15];case 12:return(h=E.sent().filter((function(e){return e}))).length>0&&l.forEach((function(e){var t=h.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(h)];case 1:return[2,e.sent()]}}))}))}))];case 13:E.sent(),E.label=14;case 14:return this._broadcastPollChangeLogEvent(l,g),[3,24];case 15:return e instanceof Ie?(f=e.event,g=e.source,[4,this._messageCache.get(f.messageId)]):[3,19];case 16:return(p=E.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollUpdateEvent(f)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([p])];case 1:return[2,e.sent()]}}))}))}))]:[3,18];case 17:E.sent(),E.label=18;case 18:return this._broadcastPollUpdateEvent(f,g),[3,24];case 19:return e instanceof he?(m=e.event,g=e.source,[4,this._messageCache.get(m.messageId)]):[3,23];case 20:return(v=E.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(m)?[4,be((function(){return A(b,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,22];case 21:E.sent(),E.label=22;case 22:return this._broadcastPollVoteEvent(m,g),[3,24];case 23:e instanceof _e?(y=e.event,g=e.source,y.messageId>0&&this._broadcastReactionUpdateEvent(y,g)):e instanceof ge&&(_=e.event,g=e.source,this._broadcastThreadUpdateEvent(_,g)),E.label=24;case 24:return[2]}}))}))})),n}return r(t,e),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return n.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dispatcher",{get:function(){return n.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_messageCache",{get:function(){return Ks.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Bs.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_notificationCache",{get:function(){return Gs.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){var r;return void 0===n&&(n=!1),Vs[e]&&!n||(Vs[e]&&(null===(r=Vs[e]._dispatcherContext)||void 0===r||r.close()),Vs[e]=new t(e)),Vs[e]},t.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemove&&a.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastReactionUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastThreadUpdateEvent=function(e,t){var n,r;try{for(var i=v(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype.subscribe=function(e,t){this._observers.set(e,t)},t.prototype.unsubscribe=function(e){this._observers.delete(e)},t.prototype.unsubscribeAll=function(){this._observers.clear()},t}(l),Ws=function(t){function n(n){var r=this,s=n.reverse,a=void 0!==s&&s,o=n.limit,u=void 0===o?20:o,c=n.keys,l=n.token;return(r=t.call(this)||this).method=i.GET,r.path="".concat(Me),r.params=e({token:l,limit:u,reverse:a,order:Se.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),r}return r(n,t),n}(a),Ys=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.next,s=n.has_more,a=void 0!==s&&s,o=n.templates;return r.nextToken=i,r.hasMore=a,r.templates=o.map((function(e){return{template:JSON.stringify(e)}})),r}return r(t,e),t}(o),Js=function(e){function t(t){var n=this,r=t.key;return(n=e.call(this)||this).method=i.GET,n.path="".concat(Me,"/").concat(r),n}return r(t,e),t}(a),Xs=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.template=JSON.stringify(n),r}return r(t,e),t}(o),Zs={},$s=function(){function n(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=a,Ks.of(e),Bs.of(e),Hs.of(e),this.fileMessageQueue=new Rt(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),Zs[e]=this}return n.of=function(e){return Zs[e]},n.prototype.buildMessageFromSerializedData=function(e){var t=Ae(e);if(t.notificationId)return new Tt(this._iid,Tt.payloadify(t));switch(t.messageType){case g.USER:return new It(this._iid,It.payloadify(t));case g.FILE:return Et._isMultipleFilesMessageSerializedData(t)?new Et(this._iid,Et.payloadify(t)):new St(this._iid,St.payloadify(t));case g.ADMIN:return new _t(this._iid,_t.payloadify(t))}throw O.invalidParameters},n.prototype.buildUserMessageCreateParamsFromSerializedData=function(n,r){return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,message:r.message,translationTargetLanguages:Object.keys(r.translations),pollId:n.pollId}))},n.prototype.buildFileMessageCreateParamsFromSerializedData=function(n,r){var i;return e(t({data:r.data,customType:r.customType,mentionType:r.mentionType,mentionedUserIds:r.mentionedUserIds,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,metaArrays:r.metaArrays,parentMessageId:r.parentMessageId,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,appleCriticalAlertOptions:r.appleCriticalAlertOptions,reqId:r.reqId,file:n.file,fileKey:n.fileKey,fileUrl:r.plainUrl,fileName:r.name,fileSize:r.size,mimeType:r.type,thumbnailSizes:null===(i=r.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:n.fileType,requireAuth:r.requireAuth}))},n.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(t,n){var r=this;return e({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUserIds:n.mentionedUserIds,mentionedUsers:n.mentionedUsers,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption,appleCriticalAlertOptions:n.appleCriticalAlertOptions,reqId:n.reqId,fileInfoList:t.fileInfoList.map((function(e){return new At(r._iid,e)}))})},n.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return u(u({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},n.prototype.buildSenderFromSerializedData=function(e){var t=Ae(e);return new je(this._iid,je.payloadify(t))},n.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new zt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Bt).message]}}))}))},n.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Vt(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Ht).message]}}))}))},n.prototype.getMessagesByMessageId=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new jt(u(u({channelType:t,channelUrl:e,token:String(n)},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(Kt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype.getMessagesByTimestamp=function(e,t,n,r,i){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var s,a,o;return U(this,(function(c){switch(c.label){case 0:return s=new jt(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(Kt).messages,this._dispatcher.dispatch(new N({messages:o,source:i})),[2,o]}}))}))},n.prototype._getMessagesByTimestampForCollection=function(e,t,n,r,i,s,a){return void 0===i&&(i=C.REQUEST_MESSAGE),A(this,void 0,void 0,(function(){var o,c,l,d,h,f;return U(this,(function(p){switch(p.label){case 0:return o=new jt(u(u(u({channelType:t,channelUrl:e,timestamp:n},Dt),r),{checkingHasNext:s,checkingContinuousMessages:a})),[4,this._requestQueue.send(o)];case 1:return c=p.sent(),l=c.as(Kt),d=l.messages,h=l.isContinuousMessages,f=l.hasNext,this._dispatcher.dispatch(new N({messages:d,source:i})),[2,{messages:d,isContinuousMessages:h,hasNext:f}]}}))}))},n.prototype.getThreadedMessagesByTimestamp=function(e,t,n,r){return void 0===r&&(r=C.REQUEST_THREADED_MESSAGE),A(this,void 0,void 0,(function(){var i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return i=new jt(u(u(u({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},vt),n),{replyType:H.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return s=c.sent(),a=s.as(Kt).messages,(o=a.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new N({messages:o,source:r})),[2,{parentMessage:a[0],threadedMessages:o}]}}))}))},n.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n,r,i,s,a,o;return U(this,(function(c){switch(c.label){case 0:return n=new Ws(u({token:e},t)),[4,this._requestQueue.send(n)];case 1:return r=c.sent(),i=r.as(Ys),s=i.hasMore,a=i.nextToken,o=i.templates,[2,{hasMore:s,token:a,templates:o}]}}))}))},n.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=new Js({key:e}),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,{template:n.as(Xs).template}]}}))}))},n.prototype.getMessageChangelogs=function(n,r,i,s,a){return void 0===a&&(a=C.REQUEST_MESSAGE_CHANGELOGS),A(this,void 0,void 0,(function(){var o,c,l,d,h,f,p,m;return U(this,(function(v){switch(v.label){case 0:return o=new Qt(e(t(u(u({channelType:r,channelUrl:n,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},Ft),s)))),[4,this._requestQueue.send(o)];case 1:return c=v.sent(),l=c.as(Gt),d=l.updatedMessages,h=l.deletedMessagesInfo,f=l.hasMore,p=l.nextToken,m=h.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new N({messages:d,source:a})),m.length>0&&this._dispatcher.dispatch(new we({messageIds:m,source:a})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:f,token:p}]}}))}))},n}(),ea=function(e){function t(t,n){var r=e.call(this,t)||this;r.targetMessageId=0;var i=n.thread_info,s=n.parent_message_id,a=n.channel_url,o=n.channel_type;return i&&h("object",i)&&h("number",s)&&h("string",a)&&h("string",o)&&(r.threadInfo=new Re(t,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return r(t,e),t}(l),ta={channelUrl:"",channelType:I.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},na=function(e){function t(t){var n=t.channelCustomType,r=t.keyword,s=t.limit,a=t.reverse,o=t.exactMatch,u=t.channelUrl,c=t.order,l=t.messageTimestampFrom,d=t.messageTimestampTo,h=t.advancedQuery,f=t.targetFields,p=t.nextToken,m=e.call(this)||this;return m.method=i.GET,m.path="".concat(Ue,"/messages"),m.params={custom_type:n,query:r,limit:s,reverse:a,exact_match:o,channel_url:u,message_ts_from:l,message_ts_to:d,sort_field:c,advanced_query:h,target_fields:f,after:p},m}return r(t,e),t}(a),ra=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return Mt(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return r(t,e),t}(o);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Os||(Os={}));var ia=function(e){function i(t,n){var r,i,s,a,o,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Os.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(a=n.channelCustomType)&&void 0!==a?a:"",h.messageTimestampFrom=null!==(o=n.messageTimestampFrom)&&void 0!==o?o:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:Os.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return r(i,e),i.prototype._validate=function(){return e.prototype._validate.call(this)&&h("string",this.keyword)&&this.keyword.length>0&&h("boolean",this.reverse)&&h("boolean",this.exactMatch)&&h("string",this.channelUrl)&&h("string",this.channelCustomType)&&(h("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(h("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&f(Os,this.order)&&h("boolean",this.advancedQuery)&&d("string",this.targetFields,!0)},i.prototype.next=function(){return A(this,void 0,void 0,(function(){var e,r,i,s,a,o,c,l;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,r=new na(t(u(u({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=d.sent(),s=i.as(ra),a=s.messages,o=s.hasNext,c=s.nextToken,l=s.totalCount,this._nextToken=c,this._hasNext=o,this._isLoading=!1,this.totalCount=l,[2,a];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},i}(me),sa=function(n){function s(r){var s=r.channelType,a=r.channelUrl,o=r.limit,u=r.token,c=n.call(this)||this;return c.method=i.GET,c.path="".concat(w(s),"/").concat(encodeURIComponent(a),"/messages/parent_thread_message"),c.params=e(t({limit:o,token:u})),c}return r(s,n),s}(a),aa=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.next,r.messages=n.messages.map((function(e){return Mt(t,e)})),r}return r(t,e),t}(o),oa=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s._edge="",s}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.load=function(){return A(this,void 0,void 0,(function(){var e,t,r,i,s,a;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=n.of(this._iid).requestQueue,t=new sa({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(aa),s=i.messages,a=i.token,this._edge=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},t}(J),ua={channelUrl:"",scheduledMessageId:0},ca={reverse:!1,limit:20},la=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return r(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new $s(t,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},t.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},t.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},t.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n;return U(this,(function(r){switch(r.label){case 0:return t=u(u({},ta),e),D(function(e){return h("string",e.channelUrl)&&f(I,e.channelType)&&h("number",e.messageId)&&h("boolean",e.includeReactions,!0)&&h("boolean",e.includeMetaArray,!0)&&h("boolean",e.includeParentMessageInfo,!0)&&h("boolean",e.includeThreadInfo,!0)}(t)).throw(O.invalidParameters),[4,this._manager.getMessage(t)];case 1:if((n=r.sent())instanceof pt||n instanceof Tt||null===n)return[2,n];throw"Unknown message type is given."}}))}))},t.prototype.getScheduledMessage=function(e){return A(this,void 0,void 0,(function(){var t;return U(this,(function(n){return t=u(u({},ua),e),D(function(e){return h("string",e.channelUrl)&&""!==e.channelUrl&&h("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(O.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},t.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),A(this,void 0,void 0,(function(){var n;return U(this,(function(r){return n=u(u({},ca),t),D(h("string",e,!0)&&function(e){return h("boolean",e.reverse,!0)&&h("number",e.limit,!0)&&d("string",e.keys,!0)}(n)).throw(O.invalidParameters),[2,this._manager.getMessageTemplatesByToken(e,n)]}))}))},t.prototype.getMessageTemplate=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){return D(h("string",e)).throw(O.invalidParameters),[2,this._manager.getMessageTemplate(e)]}))}))},t}(Ne);export{It as $,ws as A,Ti as B,mi as C,Sn as D,gt as E,Si as F,Yt as G,Wt as H,Ts as I,xt as J,Cs as K,Ns as L,Us as M,Gr as N,En as O,Jt as P,Br as Q,hn as R,vi as S,Mt as T,yi as U,ut as V,si as W,ui as X,Ve as Y,ct as Z,ot as _,jr as a,Ce as a$,St as a0,ea as a1,Re as a2,Xn as a3,zn as a4,cr as a5,or as a6,sr as a7,tr as a8,rr as a9,di as aA,fn as aB,nn as aC,dn as aD,ti as aE,Xt as aF,He as aG,Sr as aH,hi as aI,ke as aJ,Pe as aK,Hs as aL,_t as aM,De as aN,Zr as aO,Gs as aP,Hr as aQ,ft as aR,Je as aS,We as aT,bt as aU,Os as aV,Et as aW,Fe as aX,qe as aY,Tn as aZ,Le as a_,zr as aa,pt as ab,Ye as ac,mt as ad,vr as ae,_r as af,pr as ag,Ct as ah,Qr as ai,Tt as aj,$s as ak,mn as al,vn as am,yn as an,_n as ao,Oe as ap,Ke as aq,ze as ar,wt as as,oa as at,ii as au,Rs as av,xs as aw,Ds as ax,Ls as ay,sn as az,Kr as b,je as b0,at as b1,Be as b2,xe as b3,lt as b4,dt as b5,st as b6,Vr as c,Fs as d,qs as e,Jr as f,Ps as g,Xr as h,$r as i,ei as j,Wr as k,Yr as l,ks as m,Ss as n,bs as o,Ms as p,la as q,bi as r,ia as s,Ks as t,Bs as u,Es as v,As as w,Ui as x,Nn as y,pi as z}; diff --git a/lib/__bundle-5dbd9d35.js b/lib/__bundle-bfc18da1.js similarity index 97% rename from lib/__bundle-5dbd9d35.js rename to lib/__bundle-bfc18da1.js index 97f2304..4152add 100644 --- a/lib/__bundle-5dbd9d35.js +++ b/lib/__bundle-bfc18da1.js @@ -1 +1 @@ -import{C as e,c as n,W as t,U as s,g as r,_ as a,b as i,af as o,V as u,au as E,aE as N,u as c,bm as _}from"./__bundle-c03282ec.js";import{T as l,aL as d,aM as h,aN as C,a1 as A}from"./__bundle-45809bc9.js";import{P as p}from"./__bundle-acd77193.js";var f;!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"}(f||(f={}));var m=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}(),v=function(e){function t(n,t,s){var r=e.call(this,n,"SYEV",s)||this;return r.event=new m(s),r}return n(t,e),t}(t),T=function(e){function t(n,t,r){var a=e.call(this,n,t,r)||this,i=r.data.operators,o=void 0===i?[]:i;return a.operators=o.map((function(e){return new s(a._iid,e)})),a}return n(t,e),t}(v),g=function(e){function t(n,t,s){var a,i=this;return(i=e.call(this,n,"SYEV",s)||this).pinnedMessageIds=[],i.latestPinnedMessage=null,i.ts=0,s.data&&(i.pinnedMessageIds=null!==(a=s.data.pinned_message_ids)&&void 0!==a?a:[],i.latestPinnedMessage=s.data.latest_pinned_message?l(n,r({},s.data.latest_pinned_message)):null),i.ts=s.ts,i}return n(t,e),t}(t),H=function(e){function t(n,t){var s=e.call(this,n)||this;return s._logger=t.logger,s._sdkState=t.sdkState,s._sessionManager=t.sessionManager,s._requestQueue=t.requestQueue,s._dispatcher=t.dispatcher,s._cacheContext=t.cacheContext,s._channelType=t.channelType,s}return n(t,e),Object.defineProperty(t.prototype,"_messageBroadcast",{get:function(){return d.of(this._iid)},enumerable:!1,configurable:!0}),t.prototype.subscribeMessageEvent=function(e,n){this._messageBroadcast.subscribe(e,n)},t.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},t.prototype.getMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,null]}))}))},t.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,n,t){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getMessagesFromCache=function(e,n,t,s,r,o){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getPollMessagesFromCache=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getCachedMessageCountBetween=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,0]}))}))},t.prototype.getUnsentMessagesFromCache=function(e,n){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.removeFailedMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},t}(o),L=function(e){function t(n,t,s){var r,a,i,o,N=this;(N=e.call(this,n,"ADMM",s)||this).message=new h(n,s);var c=u.of(n).sdkState;return N.isMentioned=E(N.message.mentionType,null!==(i=null!==(r=N.message.mentionedUserIds)&&void 0!==r?r:null===(a=N.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==i?i:[],c.userId),N.forceUpdateLastMessage=null!==(o=s.force_update_last_message)&&void 0!==o&&o,N}return n(t,e),t}(t),I=function(e){function t(n,t,s){var r,a,i,o,E,_=this;(_=e.call(this,n,"AEDI",s)||this).message=new h(n,s);var l=u.of(n).sdkState;return _.mentionCountChange=N({mentionType:null===(r=s.old_values)||void 0===r?void 0:r.mention_type,mentionedUserIds:null!==(i=null===(a=s.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==i?i:[]},c({mentionType:_.message.mentionType,mentionedUserIds:null!==(o=_.message.mentionedUserIds)&&void 0!==o?o:null===(E=_.message.mentionedUsers)||void 0===E?void 0:E.map((function(e){return e.userId}))}),l.userId),_}return n(t,e),t}(t),U=function(e){function t(n,t,s){var r=e.call(this,n,"MRCT",s)||this;return r.channelUrl=s.channel_url,r.channelType=s.channel_type,r.event=new C(s),r}return n(t,e),t}(t),M=function(e){function t(n,t,s){var r=e.call(this,n,"MTHD",s)||this;return r.event=new A(n,s),r}return n(t,e),t}(t),y=function(e){function t(n,t,s){var r=e.call(this,n,"MCNT",s)||this;return r.groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),r.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),r}return n(t,e),t}(t),b=function(e){function t(n,t,s){var r=e.call(this,n,"PEDI",s)||this;return r.event=new p(n,s),r.status=_(s.poll.status)||s.poll.status,r.channelUrl=s.channel_url,r.channelType=s.channel_type,r}return n(t,e),t}(t);export{L as A,H as B,v as C,y as M,T as O,b as P,U as R,M as T,g as U,f as a,I as b}; +import{C as e,c as n,W as t,U as s,g as r,_ as a,b as i,af as o,V as u,au as E,aE as N,u as c,bm as _}from"./__bundle-0ca331b6.js";import{T as l,aL as d,aM as h,aN as C,a1 as A}from"./__bundle-af65b142.js";import{P as p}from"./__bundle-acd77193.js";var f;!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"}(f||(f={}));var m=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}(),v=function(e){function t(n,t,s){var r=e.call(this,n,"SYEV",s)||this;return r.event=new m(s),r}return n(t,e),t}(t),T=function(e){function t(n,t,r){var a=e.call(this,n,t,r)||this,i=r.data.operators,o=void 0===i?[]:i;return a.operators=o.map((function(e){return new s(a._iid,e)})),a}return n(t,e),t}(v),g=function(e){function t(n,t,s){var a,i=this;return(i=e.call(this,n,"SYEV",s)||this).pinnedMessageIds=[],i.latestPinnedMessage=null,i.ts=0,s.data&&(i.pinnedMessageIds=null!==(a=s.data.pinned_message_ids)&&void 0!==a?a:[],i.latestPinnedMessage=s.data.latest_pinned_message?l(n,r({},s.data.latest_pinned_message)):null),i.ts=s.ts,i}return n(t,e),t}(t),H=function(e){function t(n,t){var s=e.call(this,n)||this;return s._logger=t.logger,s._sdkState=t.sdkState,s._sessionManager=t.sessionManager,s._requestQueue=t.requestQueue,s._dispatcher=t.dispatcher,s._cacheContext=t.cacheContext,s._channelType=t.channelType,s}return n(t,e),Object.defineProperty(t.prototype,"_messageBroadcast",{get:function(){return d.of(this._iid)},enumerable:!1,configurable:!0}),t.prototype.subscribeMessageEvent=function(e,n){this._messageBroadcast.subscribe(e,n)},t.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},t.prototype.getMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,null]}))}))},t.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,n,t){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getMessagesFromCache=function(e,n,t,s,r,o){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getPollMessagesFromCache=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.getCachedMessageCountBetween=function(e,n,t,s){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,0]}))}))},t.prototype.getUnsentMessagesFromCache=function(e,n){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2,[]]}))}))},t.prototype.removeFailedMessageFromCache=function(e){return a(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},t}(o),L=function(e){function t(n,t,s){var r,a,i,o,N=this;(N=e.call(this,n,"ADMM",s)||this).message=new h(n,s);var c=u.of(n).sdkState;return N.isMentioned=E(N.message.mentionType,null!==(i=null!==(r=N.message.mentionedUserIds)&&void 0!==r?r:null===(a=N.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==i?i:[],c.userId),N.forceUpdateLastMessage=null!==(o=s.force_update_last_message)&&void 0!==o&&o,N}return n(t,e),t}(t),I=function(e){function t(n,t,s){var r,a,i,o,E,_=this;(_=e.call(this,n,"AEDI",s)||this).message=new h(n,s);var l=u.of(n).sdkState;return _.mentionCountChange=N({mentionType:null===(r=s.old_values)||void 0===r?void 0:r.mention_type,mentionedUserIds:null!==(i=null===(a=s.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==i?i:[]},c({mentionType:_.message.mentionType,mentionedUserIds:null!==(o=_.message.mentionedUserIds)&&void 0!==o?o:null===(E=_.message.mentionedUsers)||void 0===E?void 0:E.map((function(e){return e.userId}))}),l.userId),_}return n(t,e),t}(t),U=function(e){function t(n,t,s){var r=e.call(this,n,"MRCT",s)||this;return r.channelUrl=s.channel_url,r.channelType=s.channel_type,r.event=new C(s),r}return n(t,e),t}(t),M=function(e){function t(n,t,s){var r=e.call(this,n,"MTHD",s)||this;return r.event=new A(n,s),r}return n(t,e),t}(t),y=function(e){function t(n,t,s){var r=e.call(this,n,"MCNT",s)||this;return r.groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),r.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),r}return n(t,e),t}(t),b=function(e){function t(n,t,s){var r=e.call(this,n,"PEDI",s)||this;return r.event=new p(n,s),r.status=_(s.poll.status)||s.poll.status,r.channelUrl=s.channel_url,r.channelType=s.channel_type,r}return n(t,e),t}(t);export{L as A,H as B,v as C,y as M,T as O,b as P,U as R,M as T,g as U,f as a,I as b}; diff --git a/lib/__bundle-dfeaa7a2.js b/lib/__bundle-dfeaa7a2.js new file mode 100644 index 0000000..04cc3dd --- /dev/null +++ b/lib/__bundle-dfeaa7a2.js @@ -0,0 +1 @@ +import{c as t,b8 as n}from"./__bundle-0ca331b6.js";var a=function(t){return["-lastMessageUpdatedAt","-createdAt","syncIndex"]},e=function(n){function a(){return null!==n&&n.apply(this,arguments)||this}return t(a,n),a}(n);export{e as N,a as g}; diff --git a/lib/__bundle-03052043.js b/lib/__bundle-e06a35d9.js similarity index 99% rename from lib/__bundle-03052043.js rename to lib/__bundle-e06a35d9.js index 5bd2d82..d242ae6 100644 --- a/lib/__bundle-03052043.js +++ b/lib/__bundle-e06a35d9.js @@ -1 +1 @@ -import{c as e,e as t,u as n,g as s,X as r,a7 as a,C as i,U as o,af as u,bf as c,w as l,s as h,p as d,q as _,_ as p,b as f,t as v,Q as m,a as g,i as E,aq as C,a2 as y,b8 as M,B as b,A as N,d as U,f as S,h as T,bg as A,az as I,bc as w,W as L,ak as D,bh as x,ai as R,aO as F,V as P,z as k,O,G as H,a3 as V,be as G,aM as B,aT as q,aS as z,an as j,aR as W,aW as Q,bi as Y,a8 as K,bj as J,E as X,D as Z,F as $,b9 as ee,ba as te,ay as ne,aN as se,al as re,ao as ae,bk as ie,n as oe,aA as ue,bl as ce,bb as le,aB as he,aj as de,aF as _e,a5 as pe,aa as fe,aw as ve,$ as me,aV as ge}from"./__bundle-c03282ec.js";import{G as Ee,a as Ce,Q as ye,V as Me,Z as be,t as Ne,u as Ue,_ as Se,$ as Te,a0 as Ae,a1 as Ie,a2 as we,K as Le,v as De,a3 as xe,a4 as Re,a5 as Fe,a6 as Pe,a7 as ke,a8 as Oe,a9 as He,aa as Ve,ab as Ge,ac as Be,ad as qe,ae as ze,af as je,ag as We,ah as Qe,ai as Ye,aj as Ke,ak as Je,T as Xe,al as Ze,am as $e,an as et,ao as tt,ap as nt,aq as st,ar as rt,as as at,at as it,Y as ot,au as ut,av as ct,aw as lt,ax as ht,ay as dt,az as _t,aA as pt,aB as ft,z as vt,aC as mt,aD as gt,aE as Et,aF as Ct,aG as yt,aH as Mt,aI as bt,aJ as Nt,aK as Ut}from"./__bundle-45809bc9.js";import{G as St,g as Tt,D as At,c as It,R as wt,U as Lt,a as Dt,b as xt,A as Rt}from"./__bundle-1a7e946b.js";import{C as Ft,B as Pt,U as kt,a as Ot,O as Ht,P as Vt,M as Gt,T as Bt,R as qt,b as zt,A as jt}from"./__bundle-5dbd9d35.js";var Wt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Wt||(Wt={}));var Qt,Yt,Kt,Jt,Xt,Zt,$t,en,tn=function(i){function o(e,t){var n=i.call(this,e,t)||this;return n.state=null,n.role=null,n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,n.state=r(Wt,t.state)?t.state:null,n.role=r(a,t.role)?t.role:null,"boolean"==typeof t.is_muted&&(n.isMuted=t.is_muted),"boolean"==typeof t.is_blocked_by_me&&(n.isBlockedByMe=t.is_blocked_by_me),"boolean"==typeof t.is_blocking_me&&(n.isBlockingMe=t.is_blocking_me),n}return e(o,i),o.payloadify=function(e){return t(n(s(s({},i.payloadify.call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))},o}(Ee),nn=function(t){function n(e,n){var s,r,a=this;return(a=t.call(this,e)||this).channelUrl=null!==(s=n.channel_url)&&void 0!==s?s:"",a.channelType=null!==(r=n.channel_type)&&void 0!==r?r:i.GROUP,a.member=new o(a._iid,n.user),a.deliveryAt=n.ts,a}return e(n,t),n}(u);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Qt||(Qt={})),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"}(Yt||(Yt={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Kt||(Kt={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Jt||(Jt={})),function(e){e.ALL="all",e.UNHIDDEN="unhidden_only",e.HIDDEN="hidden_only",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Xt||(Xt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Zt||(Zt={})),function(e){e.AND="AND",e.OR="OR"}($t||($t={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(en||(en={}));var sn,rn=function(){function e(e){var t,n,s,r,a,i,o,u,c,l,h,d,_,p,f;this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(t=null==e?void 0:e.includeEmpty)&&void 0!==t&&t,this.nicknameContainsFilter=null!==(n=null==e?void 0:e.nicknameContainsFilter)&&void 0!==n?n:null,this.nicknameStartsWithFilter=null!==(s=null==e?void 0:e.nicknameStartsWithFilter)&&void 0!==s?s:null,this.nicknameExactMatchFilter=null!==(r=null==e?void 0:e.nicknameExactMatchFilter)&&void 0!==r?r:null,this.channelNameContainsFilter=null!==(a=null==e?void 0:e.channelNameContainsFilter)&&void 0!==a?a:"",this.myMemberStateFilter=null!==(i=null==e?void 0:e.myMemberStateFilter)&&void 0!==i?i:Yt.ALL,this.customTypesFilter=null!==(o=null==e?void 0:e.customTypesFilter)&&void 0!==o?o:null,this.channelUrlsFilter=null!==(u=null==e?void 0:e.channelUrlsFilter)&&void 0!==u?u:null,this.superChannelFilter=null!==(c=null==e?void 0:e.superChannelFilter)&&void 0!==c?c:Kt.ALL,this.publicChannelFilter=null!==(l=null==e?void 0:e.publicChannelFilter)&&void 0!==l?l:Qt.ALL,this.customTypeStartsWithFilter=null!==(h=null==e?void 0:e.customTypeStartsWithFilter)&&void 0!==h?h:null,this.unreadChannelFilter=null!==(d=null==e?void 0:e.unreadChannelFilter)&&void 0!==d?d:Jt.ALL,this.hiddenChannelFilter=null!==(_=null==e?void 0:e.hiddenChannelFilter)&&void 0!==_?_:Xt.UNHIDDEN,this.includeFrozen=null===(p=null==e?void 0:e.includeFrozen)||void 0===p||p,(null==e?void 0:e.createdAfter)&&(this.createdAfter=e.createdAfter),(null==e?void 0:e.createdBefore)&&(this.createdBefore=e.createdBefore),this.includeMetaData=null===(f=null==e?void 0:e.includeMetaData)||void 0===f||f}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=$t.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 s=JSON.parse(JSON.stringify(this));return Object.keys(s).forEach((function(e){n[e]=s[e]})),n},e.prototype.match=function(e,t){if(this._searchFilter){var n=this._searchFilter,s=n.query,r=n.fields;if(s&&r&&r.length>0&&!r.some((function(t){switch(t){case en.CHANNEL_NAME:return e.name.toLowerCase().includes(s.toLowerCase());case en.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(s.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var a=this._userIdsFilter,i=a.userIds,o=a.includeMode,u=a.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(i.length>0)switch(u){case $t.AND:if(i.some((function(e){return!l.includes(e)})))return!1;break;case $t.OR:if(i.every((function(e){return!l.includes(e)})))return!1}}else{if(i.includes(t)||i.push(t),e.members.length>i.length)return!1;if(!c(i,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var _=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=_})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Yt.ALL:if("none"===e.myMemberState)return!1;break;case Yt.JOINED:if("joined"!==e.myMemberState)return!1;break;case Yt.INVITED:if("invited"!==e.myMemberState)return!1;break;case Yt.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Yt.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Xt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Xt.HIDDEN:if(!e.isHidden)return!1;break;case Xt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Xt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Jt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Qt.PUBLIC:if(!e.isPublic)return!1;break;case Qt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Kt.SUPER:if(!e.isSuper)return!1;break;case Kt.NON_SUPER:if(e.isSuper)return!1}return!(this.createdAfter&&e.createdAtthis.createdBefore)},e}(),an=function(t){function n(e,n){var s=n.sdkState,r=n.cacheContext,a=t.call(this,e)||this;return a._channels=new Map,a._sdkState=s,a._cacheContext=r,a}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return l(!!e).throw(h.databaseError),e.collection(Ce)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return ps.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],_(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case St.CHRONOLOGICAL:if(!a&&n.createdAt>t||a&&n.createdAtt||a&&n.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)s._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});s._update(e),n.push(s)}else a._channels.set(e.url,e),n.push(e)})),!this.localCacheEnabled)return[3,2];for(s=[],r=0;r0?[4,this.upsert(s)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},n.prototype.unblock=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],_(this._channels.keys()),!1)),p(this,void 0,void 0,(function(){var n,s,r,a,i,o,u,c;return f(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),s=v(t),r=s.next(),l.label=2;case 2:return r.done?[3,5]:(a=r.value,[4,this.get(a)]);case 3:(null==(i=l.sent())?void 0:i._updateUnreadMemberState(this._sdkState.userId,e))&&(i._updateUnreadCount(0,0),n.push(i)),l.label=4;case 4:return r=s.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{r&&!r.done&&(c=s.return)&&c.call(s)}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}(u),on={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},un=function(e){return m("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},cn={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},ln=function(e){return m("string",e.customTypes,!0)&&g("boolean",e.includeEmpty,!0)&&g("boolean",e.includeFrozen,!0)&&g("boolean",e.includeMetaData,!0)&&g("boolean",e.includeChatNotification,!0)},hn={myMemberStateFilter:Yt.ALL},dn=function(e){return r(Yt,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"}(sn||(sn={}));var _n={keys:[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT,sn.NONSUPER_UNREAD_MENTION_COUNT,sn.SUPER_UNREAD_MENTION_COUNT,sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,sn.NONSUPER_UNREAD_MESSAGE_COUNT,sn.SUPER_UNREAD_MESSAGE_COUNT,sn.GROUP_CHANNEL_INVITATION_COUNT,sn.NONSUPER_INVITATION_COUNT,sn.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},pn={channelCustomTypesFilter:void 0,superChannelFilter:Kt.ALL},fn=function(e){return m("string",e.channelCustomTypesFilter,!0)&&r(Kt,e.superChannelFilter)},vn={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:C.ALL},mn=s({},y),gn=function(e){return e.startsWith("EVENT_")||e===y.SYNC_CHANNEL_CHANGELOGS||e===y.REFRESH_CHANNEL},En=function(t){function n(e){var n=e.channels,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=e.ts,o=t.call(this)||this;return o.channels=n,o.context=s,o.isWebSocketEventComing=a,o.ts=i,o}return e(n,t),n}(M),Cn=function(t){function n(e){var n=e.channelUrls,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=t.call(this)||this;return i.channelUrls=n,i.context=s,i.isWebSocketEventComing=a,i}return e(n,t),n}(M),yn=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,s=e.unsentMessageCache,r=e.dispatcher,a=this;this._observers=new Map,r.on((function(e){return p(a,void 0,void 0,(function(){var r,a,i,o,u,c,l,h,d,_,m,g,E,C,M,N,U,S,T=this;return f(this,(function(A){switch(A.label){case 0:if(!(e instanceof En))return[3,19];if(r=e.channels,E=e.context,C=e.isWebSocketEventComing,a=r.filter((function(e){return e instanceof ur})),E.source!==y.EVENT_CHANNEL_RESET_HISTORY&&E.source!==y.EVENT_CHANNEL_HIDDEN)return[3,9];A.label=1;case 1:A.trys.push([1,6,7,8]),i=v(a),o=i.next(),A.label=2;case 2:return o.done?[3,5]:(d=o.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 3:A.sent(),A.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return u=A.sent(),M={error:u},[3,8];case 7:try{o&&!o.done&&(N=i.return)&&N.call(i)}finally{if(M)throw M.error}return[7];case 8:return[3,17];case 9:c=t.filterOffsetChanged(a),A.label=10;case 10:A.trys.push([10,15,16,17]),l=v(c),h=l.next(),A.label=11;case 11:return h.done?[3,14]:(d=h.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 12:A.sent(),A.label=13;case 13:return h=l.next(),[3,11];case 14:return[3,17];case 15:return _=A.sent(),U={error:_},[3,17];case 16:try{h&&!h.done&&(S=l.return)&&S.call(l)}finally{if(U)throw U.error}return[7];case 17:return[4,t.upsert(a,e.ts)];case 18:return m=A.sent(),C||this._broadcastUpdateEvent(m,E),[3,24];case 19:return e instanceof Cn?(g=e.channelUrls,E=e.context,C=e.isWebSocketEventComing,[4,t.remove(g)]):[3,22];case 20:return A.sent(),[4,b((function(){return p(T,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=v(g),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(r=t.value,[4,n.removeMessagesOfChannel(r)]);case 2:return u.sent(),[4,s.removeMessagesOfChannel(r)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return a=u.sent(),i={error:a},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(i)throw i.error}return[7];case 8:return[2]}}))}))}))];case 21:return A.sent(),C||this._broadcastRemoveEvent(g,E),[3,24];case 22:return e instanceof At?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,24];case 23:A.sent(),A.label=24;case 24:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onUpdate&&i.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onRemove&&i.onRemove(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}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}(),Mn=function(r){function a(e){var a=e.userId,i=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c,h=r.call(this)||this,d=s(s({},cn),u),_=d.customTypes,p=d.includeEmpty,f=d.includeFrozen;return h.method=N.GET,h.path="".concat(U,"/").concat(encodeURIComponent(a),"/my_group_channels/changelogs"),h.params=t(n({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:_,show_empty:p,show_frozen:f,include_chat_notification:l})),h}return e(a,r),a}(S),bn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedChannels=n.updated.map((function(t){return new ur(e,Object.assign(t,{ts:n.ts}))})),s.deletedChannelUrls=n.deleted,s.hasMore=n.has_more,s.token=n.next,s.ts=n.ts,s}return e(n,t),n}(T),Nn=function(t){function n(e){var n=e.channelUrl,s=e.isInternalCall,r=e.showLatestMessage,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(s?A:I,"/").concat(encodeURIComponent(n)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=r&&r},a}return e(n,t),n}(S),Un=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Sn={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:Yt.ALL,unreadChannelFilter:Jt.ALL,superChannelFilter:Kt.ALL,publicChannelFilter:Qt.ALL,hiddenChannelFilter:Xt.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:$t.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:St.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0},Tn=function(n){function s(e){var s=this,r=e.userId,a=e.token,i=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,_=e.nicknameContainsFilter,p=e.nicknameStartsWithFilter,f=e.nicknameExactMatchFilter,v=e.channelNameContainsFilter,m=e.channelUrlsFilter,g=e.customTypesFilter,E=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,y=e.metadataOrderKeyFilter,M=e.metadataKey,b=e.metadataValues,S=e.metadataValueStartsWith,T=e.includeFrozen,A=e.includeMetaData,I=e.searchFilter,w=e.userIdsFilter,L=e.includeChatNotification,D=void 0!==L&&L,x=e.includeLeftChannel,R=void 0!==x&&x,F=e.createdAfter,P=e.createdBefore;return(s=n.call(this)||this).method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(r),"/my_group_channels"),s.params=t({token:a,limit:i,order:null!=o?o:Sn.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=u?u:Sn.includeEmpty,member_state_filter:null!=c?c:Sn.myMemberStateFilter,super_mode:null!=l?l:Sn.superChannelFilter,public_mode:null!=h?h:Sn.publicChannelFilter,unread_filter:null!=d?d:Sn.unreadChannelFilter,members_nickname_contains:_,members_nickname_startswith:p,members_nickname:f,name_contains:v,channel_urls:m,custom_types:g,custom_type_startswith:E,hidden_mode:C,metadata_order_key:y,metadata_key:M,metadata_values:b,metadata_value_startswith:S,show_frozen:T,show_metadata:A,include_chat_notification:D,include_left_channel:R,created_after:F,created_before:P}),I&&I.query&&I.fields&&(s.params.search_query=I.query,s.params.search_fields=I.fields),w&&w.userIds&&w.userIds.length>0&&(w.includeMode?(s.params.members_include_in=w.userIds,s.params.query_type=w.queryType.toUpperCase()):s.params.members_exactly_in=w.userIds),s}return e(s,n),s}(S),An=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.channels=[];var r=n.next,a=n.channels,i=n.ts;return s.token=r,a&&a.length>0&&(s.channels=a.map((function(t){return t.ts=i,new ur(e,t)}))),s.ts=null!=i?i:0,s}return e(n,t),n}(T),In=function(t){function n(e){var n=e.userId,s=e.filter,r=t.call(this)||this,a=s.myMemberStateFilter;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/group_channel_count"),r.params={state:null!=a?a:Yt.ALL},r}return e(n,t),n}(S),wn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.groupChannelCount=n.group_channel_count,s}return e(n,t),n}(T),Ln=function(n){function s(e){var s=e.userId,r=e.filter,a=n.call(this)||this,i=r.keys,o=r.customTypeFilters,u=r.customTypesFilter;return a.method=N.GET,a.path="".concat(U,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=t({item_keys:i,custom_types:null!=u?u:o}),a}return e(s,n),s}(S),Dn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=n[sn.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=n[sn.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=n[sn.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=n[sn.SUPER_INVITATION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=n[sn.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=n[sn.NONSUPER_INVITATION_COUNT]),s}return e(n,t),n}(T),xn=function(t){function n(e){var n=e.userId,s=t.call(this)||this;return s.method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_channel_count"),s}return e(n,t),n}(S),Rn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s}return e(n,t),n}(T),Fn=function(t){function n(e){var n=e.userId,s=e.filter,r=e.includeFeedChannel,a=void 0!==r&&r,i=t.call(this)||this,o=s.channelCustomTypesFilter,u=s.superChannelFilter;return i.method=N.GET,i.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_message_count"),i.params={super_mode:null!=u?u:Kt.ALL,custom_types:o,include_feed_channel:a},i}return e(n,t),n}(S),Pn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s.unreadFeedCount=n.unread_feed_count,s}return e(n,t),n}(T),kn=function(t){function n(e){var n=e.channelUrl,s=e.scheduledStatus,r=e.messageTypeFilter,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(w,"/count"),a.params={channel_url:n,status:Hn(s)},r&&(a.params.message_type=r),a}return e(n,t),n}(S),On=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.count=n.count,s}return e(n,t),n}(T),Hn=function(e){if(!e)return[];var t=[];return e.forEach((function(e){switch(e){case Me.PENDING:t.push(be.PENDING);break;case Me.SENT:t.push(be.IN_QUEUE),t.push(be.SENT);break;case Me.CANCELED:t.push(be.CANCELED);break;case Me.FAILED:t.push(be.FAILED)}})),t},Vn=function(n){function s(e){var s=this,r=e.userId,a=e.channelUrl,i=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,h=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,E=e.name,C=e.data,y=e.customType,M=e.messageSurvivalSeconds,b=e.invitedUserIds,U=e.operatorUserIds;return(s=n.call(this)||this).method=N.POST,s.path=I,s.params=t({user_ids:d([r],_(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:a,cover_url:i,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:p,is_public:h,is_discoverable:f,strict:v,is_ephemeral:m,access_code:g,name:E,data:C,custom_type:y,operator_ids:U,message_survival_seconds:M}),s}return e(s,n),s}(S),Gn=function(t){function n(e,n){var s,r=this;return(r=t.call(this,e,n)||this).channel=new ur(e,n),r.isCreated=null===(s=n.is_created)||void 0===s||s,r}return e(n,t),n}(T),Bn=function(t){function n(e){var n=e.userId,s=e.channelUrls,r=t.call(this)||this;return r.method=N.PUT,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),r.params={channel_urls:s},r}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var qn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/join"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),zn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u,l=a.users,h=void 0===l?null:l;return r.memberCount=o,r.joinedMemberCount=c,r.members=Array.isArray(h)?h.map((function(t){return new tn(e,t)})):[new tn(e,s.data)],r}return e(n,t),n}(Ft),Wn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/leave"),n.params={user_id:r,should_remove_operator_status:a},n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Qn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u;return r.memberCount=o,r.joinedMemberCount=c,r.member=new tn(r._iid,s.data),r}return e(n,t),n}(Ft),Yn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userIds;return(n=t.call(this)||this).method=N.POST,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/invite"),n.params={user_ids:r},n}return e(n,t),n}(S),Kn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this;r.inviter=null;var a=s.data,i=a.member_count,u=void 0===i?0:i,c=a.joined_member_count,l=void 0===c?0:c,h=a.inviter,d=a.invitees,_=void 0===d?[]:d;return r.memberCount=u,r.joinedMemberCount=l,h&&Object.keys(h).length>0&&(r.inviter=new o(e,h)),r.invitees=_.map((function(t){return new tn(e,t)})),r}return e(n,t),n}(Ft),Xn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/decline"),n.params={user_id:r},n}return e(n,t),n}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.NONE,s}e(n,t)}(T);var Zn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,u=a.joined_member_count,c=a.inviter,l=a.invitee;return r.memberCount=null!=i?i:0,r.joinedMemberCount=null!=u?u:0,r.inviter=new o(e,c),r.invitee=new tn(e,l),r}return e(n,t),n}(Ft),$n={hidePreviousMessages:!1,allowAutoUnhide:!0},es=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.hidePreviousMessages,i=e.allowAutoUnhide;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n.params={user_id:r,hide_previous_messages:null!=a?a:$n.hidePreviousMessages,allow_auto_unhide:null!=i?i:$n.allowAutoUnhide},n}return e(n,t),n}(S),ts=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),ns=function(t){function n(e,n,s){var r,a,i,o=this;return(o=t.call(this,e,"SYEV",s)||this).allowAutoUnhide=null,o.hidePreviousMessages=null,o.messageOffsetTimestamp=null,s.data&&(o.allowAutoUnhide=null!==(r=s.data.allow_auto_unhide)&&void 0!==r?r:null,o.hidePreviousMessages=null!==(a=s.data.hide_previous_messages)&&void 0!==a?a:null),o.messageOffsetTimestamp=null!==(i=s.ts_message_offset)&&void 0!==i?i:null,o}return e(n,t),n}(L),ss=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),rs=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),as=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),is=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),os=function(t){function n(e){var n=e.channelUrl,s=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:s}})||this}return e(n,t),n}(D),us=function(t){function a(e,n){var s,r,a,i,o,u,c,l,h,d,_,p,f,v,m,g,E,C,y,M,b,N,U,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.includeChatNotification=!1,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Yt.ALL,S.unreadChannelFilter=Jt.ALL,S.superChannelFilter=Kt.ALL,S.publicChannelFilter=Qt.ALL,S.hiddenChannelFilter=Xt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=St.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,S.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,S.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,S.includeChatNotification=null!==(i=n.includeChatNotification)&&void 0!==i&&i,S.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,S.customTypesFilter=null!==(u=n.customTypesFilter)&&void 0!==u?u:null,S.customTypeStartsWithFilter=null!==(c=n.customTypeStartsWithFilter)&&void 0!==c?c:"",S.nicknameContainsFilter=null!==(l=n.nicknameContainsFilter)&&void 0!==l?l:null,S.nicknameStartsWithFilter=null!==(h=n.nicknameStartsWithFilter)&&void 0!==h?h:null,S.nicknameExactMatchFilter=null!==(d=n.nicknameExactMatchFilter)&&void 0!==d?d:null,S.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Yt.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Jt.ALL,S.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:Kt.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Qt.ALL,S.hiddenChannelFilter=null!==(g=n.hiddenChannelFilter)&&void 0!==g?g:Xt.UNHIDDEN,S.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},S.userIdsFilter=null!==(C=n.userIdsFilter)&&void 0!==C?C:{userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null!==(y=n.metadataKey)&&void 0!==y?y:null,S.metadataValues=null!==(M=n.metadataValues)&&void 0!==M?M:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(N=n.metadataValueStartsWith)&&void 0!==N?N:null,S.order=null!==(U=n.order)&&void 0!==U?U:St.LATEST_LAST_MESSAGE,n.createdAfter&&(S.createdAfter=n.createdAfter),n.createdBefore&&(S.createdBefore=n.createdBefore),S}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&m("string",this.channelUrlsFilter,!0)&&m("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&r(Yt,this.myMemberStateFilter)&&r(Kt,this.superChannelFilter)&&r(Qt,this.publicChannelFilter)&&r(Jt,this.unreadChannelFilter)&&r(Xt,this.hiddenChannelFilter)&&m(en,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&m("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&r($t,this.userIdsFilter.queryType)&&r(St,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&m("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)&&x(this.createdAfter,!0)&&x(this.createdBefore,!0)},a.prototype.serialize=function(){return R(this)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,ps.of(this._iid).getMyGroupChannels(this._token,n(s({},this)),this.limit,y.REQUEST_CHANNEL,!0)]):[3,2]:[3,5];case 1:return e=a.sent(),t=e.channels,r=e.token,this._token=r,this._hasNext=!!r,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(F),cs=function(n){function s(e){var s=e.channelUrl,r=e.userId,a=n.call(this)||this;return a.method=N.PUT,a.path="".concat(I,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=t({userId:r}),a}return e(s,n),s}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var ls,hs=function(t){function n(e,n,s){var r=t.call(this,e,"DLVR",s)||this;return r.channelUrl=s.channel_url,r.deliveredStateUpdate=s.updated,r}return e(n,t),n}(L),ds=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,s=e.bottom,r=void 0===s?0:s;this.top=n,this.bottom=r}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0&&n.onMentionReceived&&n.onMentionReceived(g,_)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=6;case 6:return[3,79];case 7:return U=e.as(Y),me=U.channelUrl,ge=U.channelType,S=U.messageId,T=U.silent,A=U.messageCreatedAt,I=U.senderId,ge!==i.GROUP?[3,9]:[4,this.getChannel(me,!0)];case 8:w=xn.sent(),L=I===this._sdkState.userId,T||L||A>0&&w.myLastRead0&&w._updateUnreadCount(w.unreadMessageCount-1,0),this._dispatcher.dispatch(new Q({messageIds:[S],source:y.EVENT_MESSAGE_DELETED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onMessageDeleted&&n.onMessageDeleted(w,S)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=9;case 9:return[3,79];case 10:return(D=e.as(Be).readStatus).channelType!==i.GROUP?[3,12]:(V=this._groupChannelCache.isCachedInMemory(D.channelUrl),[4,this.getChannel(D.channelUrl,!0)]);case 11:x=xn.sent(),V&&x._updateUnreadMemberState(D.reader.userId,D.readAt),D.reader.userId===this._sdkState.userId?V?(x.unreadMessageCount>0||x.unreadMentionCount>0)&&(x._updateUnreadCount(0,0),this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):0!==x.unreadMessageCount&&0!==x.unreadMentionCount||(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUnreadMemberStatusUpdated&&n.onUnreadMemberStatusUpdated(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),xn.label=12;case 12:return[3,79];case 13:return R=e.as(hs),me=R.channelUrl,F=R.deliveredStateUpdate,k=void 0===F?{}:F,V=this._groupChannelCache.isCachedInMemory(me),[4,this.getChannel(me,!0)];case 14:return K=xn.sent(),V&&Object.keys(k).forEach((function(e){K._updateUndeliveredMemberState(e,k[e])})),Object.keys(k).some((function(e){return e!==Dn._sdkState.userId}))&&(this._dispatcher.dispatch(new En({channels:[K],context:{source:y.EVENT_CHANNEL_DELIVERED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUndeliveredMemberStatusUpdated&&n.onUndeliveredMemberStatusUpdated(K)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 15:return X=e.as(qt),me=X.channelUrl,ge=X.channelType,Z=X.event,ge!==i.GROUP?[3,18]:[4,this.getChannel(me,!0)];case 16:return $=xn.sent(),[4,this.getMessageFromCache(Z.messageId)];case 17:(ne=xn.sent())?ne instanceof Ge&&(ne.applyReactionEvent(Z),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new W({event:Z,source:y.EVENT_MESSAGE_REACTION_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onReactionUpdated&&n.onReactionUpdated($,Z)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=18;case 18:return[3,79];case 19:return(ee=e.as(Bt).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(ee.channelUrl,!0)];case 20:return te=xn.sent(),[4,this.getMessageFromCache(ee.targetMessageId)];case 21:(ne=xn.sent())?ne instanceof Ge&&(ne.applyThreadInfoUpdateEvent(ee),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new z({event:ee,source:y.EVENT_MESSAGE_THREADINFO_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onThreadInfoUpdated&&n.onThreadInfoUpdated(te,ee)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=22;case 22:return[3,79];case 23:se=e.as(Gt).groupChannelMemberCounts,re=[],xn.label=24;case 24:xn.trys.push([24,29,30,31]),ae=v(se),ie=ae.next(),xn.label=25;case 25:return ie.done?[3,28]:(oe=ie.value,me=oe.channelUrl,ct=oe.memberCount,lt=oe.joinedMemberCount,ue=oe.updatedAt,[4,this.getChannelFromCache(me)]);case 26:(ce=xn.sent())&&ce._setLatestMemberCount(ct,lt,ue)&&re.push(ce),xn.label=27;case 27:return ie=ae.next(),[3,25];case 28:return[3,31];case 29:return le=xn.sent(),Nn={error:le},[3,31];case 30:try{ie&&!ie.done&&(Un=ae.return)&&Un.call(ae)}finally{if(Nn)throw Nn.error}return[7];case 31:return re.length>0&&(this._dispatcher.dispatch(new En({channels:re,context:{source:y.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelMemberCountChanged&&n.onChannelMemberCountChanged(re)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 32:return he=e.as(Vt),de=he.event,_e=he.status,me=he.channelUrl,ge=he.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,34];case 33:pe=xn.sent(),this._dispatcher.dispatch(new q({event:de,source:y.EVENT_POLL_UPDATED})),H(_e===J?function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollDeleted&&n.onPollDeleted(pe,de.pollId)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}:function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollUpdated&&n.onPollUpdated(pe,de)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}),xn.label=34;case 34:return[3,79];case 35:return fe=e.as(Ve),ve=fe.event,me=fe.channelUrl,ge=fe.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,37];case 36:Ee=xn.sent(),this._dispatcher.dispatch(new B({event:ve,source:y.EVENT_POLL_VOTED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollVoted&&n.onPollVoted(Ee,ve)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=37;case 37:return[3,79];case 38:if(!(Ce=e.as(Ft).event).isGroupChannelEvent)return[3,77];switch(Ce.category){case Ot.CHANNEL_JOIN:return[3,39];case Ot.CHANNEL_LEAVE:return[3,41];case Ot.CHANNEL_OPERATOR_UPDATE:return[3,45];case Ot.CHANNEL_INVITE:return[3,47];case Ot.CHANNEL_DECLINE_INVITE:return[3,49];case Ot.TYPING_START:case Ot.TYPING_END:return[3,51];case Ot.USER_CHANNEL_MUTE:case Ot.USER_CHANNEL_UNMUTE:return[3,53];case Ot.USER_CHANNEL_BAN:return[3,55];case Ot.USER_CHANNEL_UNBAN:return[3,59];case Ot.CHANNEL_FREEZE:case Ot.CHANNEL_UNFREEZE:return[3,61];case Ot.CHANNEL_HIDE:return[3,63];case Ot.CHANNEL_UNHIDE:return[3,65];case Ot.CHANNEL_DELETED:return[3,67];case Ot.CHANNEL_PROP_CHANGED:return[3,69];case Ot.CHANNEL_META_DATA_CHANGED:return[3,71];case Ot.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case Ot.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(Ce.channelUrl,!0)];case 40:return ye=xn.sent(),Me=e.as(jn),be=Me.memberCount,Ne=Me.joinedMemberCount,Ue=Me.members,Se=!1,Ue.forEach((function(e){ye.isExclusive||ye.isSuper||ye.isBroadcast?Se=Se||ye._setLatestMemberCount(be,Ne,Ce.ts):(e.state=Wt.JOINED,ye.addMember(e,Ce.ts),Dn._updateJoinedMemberCount(ye)),e.userId===Dn._sdkState.userId&&(ye.myMemberState=Wt.JOINED)})),this._dispatcher.dispatch(new En({channels:[ye],context:{source:y.EVENT_CHANNEL_JOINED,users:Ue}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var s=v(Ue),r=s.next();!r.done;r=s.next()){var a=r.value;e.onUserJoined&&e.onUserJoined(ye,a)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}ye.isBroadcast&&Se&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,77];case 41:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Ae=Mt.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(Ce.channelUrl,!0)];case 43:Ae=xn.sent(),xn.label=44;case 44:return Te=Ae,Ie=e.as(Qn),ct=Ie.memberCount,lt=Ie.joinedMemberCount,we=Ie.member,Le=!1,De=P.of(this._iid).appInfo,Te.isExclusive||Te.isSuper||Te.isBroadcast?Le=Te._setLatestMemberCount(ct,lt,Ce.ts):((null==De?void 0:De.enabledChannelMemberShipHistory)?((Ye=Te.members.find((function(e){return e.userId===we.userId})))&&(Ye.state=Wt.LEFT),Te.memberCount=ct):Te.removeMember(we),this._updateJoinedMemberCount(Te)),we.userId===this._sdkState.userId?(Te.myMemberState=Wt.NONE,Te.invitedAt=0,Te.joinedAt=0,Te._updateUnreadCount(0,0),Te.isPublic?this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})):(this._markAsLeave(Te),this._dispatcher.dispatch(new Cn({channelUrls:[Te.url],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})))):this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(Te,we),Te.isBroadcast&&Le&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Te])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(Ce.channelUrl,!0)];case 46:Ke=xn.sent(),Je=e.as(Ht).operators,Xe=Je.map((function(e){return e.userId}));try{for(Ze=v(Ke.members),$e=Ze.next();!$e.done;$e=Ze.next())(yt=$e.value).role=Xe.includes(yt.userId)?a.OPERATOR:a.NONE}catch(e){Sn={error:e}}finally{try{$e&&!$e.done&&(Tn=Ze.return)&&Tn.call(Ze)}finally{if(Sn)throw Sn.error}}return Ke.myRole=Xe.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new En({channels:[Ke],context:{source:y.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Je}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ke,Je)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(Ce.channelUrl,!0)];case 48:et=xn.sent(),tt=e.as(Jn),ct=tt.memberCount,lt=tt.joinedMemberCount,nt=tt.inviter,(st=tt.invitees).forEach((function(e){return e.state=Wt.INVITED}));try{for(rt=v(st),at=rt.next();!at.done;at=rt.next())it=at.value,et.isExclusive||et.isSuper||et.isBroadcast?et._setLatestMemberCount(ct,lt,Ce.ts):et.addMember(it,Ce.ts),this._sdkState.userId===it.userId&&(et.hiddenState=tr.UNHIDDEN,et.myMemberState!==Wt.JOINED&&(et.myMemberState=Wt.INVITED),et.invitedAt=Ce.ts)}catch(e){An={error:e}}finally{try{at&&!at.done&&(In=rt.return)&&In.call(rt)}finally{if(An)throw An.error}}return this._dispatcher.dispatch(new En({channels:[et],context:{source:y.EVENT_CHANNEL_INVITED,inviter:nt,invitees:st}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(et,nt,st)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(Ce.channelUrl,!0)];case 50:return ot=xn.sent(),ut=e.as(Zn),ct=ut.memberCount,lt=ut.joinedMemberCount,ht=ut.inviter,dt=ut.invitee,ot.isExclusive||ot.isSuper||ot.isBroadcast?ot._setLatestMemberCount(ct,lt,Ce.ts):ot.removeMember(dt),this._sdkState.userId===dt.userId?(ot.invitedAt=0,ot.myMemberState=Wt.NONE,ot.isPublic?this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})):this._dispatcher.dispatch(new Cn({channelUrls:[ot.url],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}}))):this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ot,ht,dt)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(Ce.channelUrl,!0)];case 52:return _t=xn.sent(),pt=Ce.category===Ot.TYPING_START,ft=e.as(pt?rs:is).user,_t._updateTypingStatus(ft,pt?Ce.ts:0),this._dispatcher.dispatch(new En({channels:[_t],context:{source:y.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(_t)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(Ce.channelUrl,!0)];case 54:vt=xn.sent(),mt=Ce.category===Ot.USER_CHANNEL_MUTE,(gt=e.as(mt?Oe:He).user).userId===this._sdkState.userId&&(vt.myMutedState=mt?G.MUTED:G.UNMUTED,vt._myMutedRemainingTime=gt.restrictionInfo.remainingDuration);try{for(Et=v(vt.members),Ct=Et.next();!Ct.done;Ct=Et.next())if((yt=Ct.value).userId===gt.userId){yt.isMuted=mt;break}}catch(e){wn={error:e}}finally{try{Ct&&!Ct.done&&(Ln=Et.return)&&Ln.call(Et)}finally{if(wn)throw wn.error}}return this._dispatcher.dispatch(new En({channels:[vt],context:{source:mt?y.EVENT_CHANNEL_MUTED:y.EVENT_CHANNEL_UNMUTED,user:gt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){mt?e.onUserMuted&&e.onUserMuted(vt,gt):e.onUserUnmuted&&e.onUserUnmuted(vt,gt)})),[2]}))}))})),[3,77];case 55:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Nt=Mt.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(Ce.channelUrl,!0)];case 57:Nt=xn.sent(),xn.label=58;case 58:return bt=Nt,this._markAsLeave(bt),Ut=e.as(ke).user,Ut.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[bt.url],context:{source:y.EVENT_CHANNEL_BANNED,user:Ut}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(bt,Ut)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(Ce.channelUrl,!0)];case 60:return St=xn.sent(),Tt=e.as(Pe).user,Tt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[St.url],context:{source:y.EVENT_CHANNEL_UNBANNED,user:Tt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(St,Tt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(Ce.channelUrl,!0)];case 62:return At=xn.sent(),It=e.as(Fe).freeze,At.isFrozen=It,this._dispatcher.dispatch(new En({channels:[At],context:{source:It?y.EVENT_CHANNEL_FROZEN:y.EVENT_CHANNEL_UNFROZEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){It?e.onChannelFrozen&&e.onChannelFrozen(At):e.onChannelUnfrozen&&e.onChannelUnfrozen(At)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(Ce.channelUrl,!0)];case 64:return wt=xn.sent(),Rt=e.as(ns),Pt=Rt.allowAutoUnhide,Qt=Rt.hidePreviousMessages,Yt=Rt.messageOffsetTimestamp,null!==Pt&&(wt.hiddenState=Pt?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Qt&&Qt&&wt._updateUnreadCount(0,0),null!==Yt&&(wt.messageOffsetTimestamp=Yt),this._dispatcher.dispatch(new En({channels:[wt],context:{source:y.EVENT_CHANNEL_HIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(wt)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(Ce.channelUrl,!0)];case 66:return(Kt=xn.sent()).hiddenState=tr.UNHIDDEN,this._dispatcher.dispatch(new En({channels:[Kt],context:{source:y.EVENT_CHANNEL_UNHIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Kt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(Ce.channelUrl,!0)];case 68:return Jt=xn.sent(),this._dispatcher.dispatch(new Cn({channelUrls:[Ce.channelUrl],context:{source:y.EVENT_CHANNEL_DELETED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Jt.url,Jt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(Ce.channelUrl,!0)];case 70:return Xt=xn.sent(),this._dispatcher.dispatch(new En({channels:[Xt],context:{source:y.EVENT_CHANNEL_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Xt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(Ce.channelUrl,!0)];case 72:return Zt=xn.sent(),$t=e.as(Re),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&(Zt._upsertCachedMetaData(en,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_CREATED,metaData:en},ts:Ce.ts}))),tn&&(Zt._upsertCachedMetaData(tn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_UPDATED,metaData:tn},ts:Ce.ts}))),nn&&(Zt._removeFromCachedMetaData(nn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:nn},ts:Ce.ts}))),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){en&&e.onMetaDataCreated&&e.onMetaDataCreated(Zt,en),tn&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Zt,tn),nn&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Zt,nn)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(Ce.channelUrl,!0)];case 74:return sn=xn.sent(),rn=e.as(xe),an=rn.created,on=rn.updated,un=rn.deleted,an&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:an}})),on&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:on}})),un&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:un}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){an&&e.onMetaCounterCreated&&e.onMetaCounterCreated(sn,an),on&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(sn,on),un&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(sn,un)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(Ce.channelUrl,!0)];case 76:return cn=xn.sent(),ln=e.as(kt),hn=ln.pinnedMessageIds,dn=ln.latestPinnedMessage,(_n=ln.ts)>cn._pinnedMessagesUpdatedAt&&(cn.pinnedMessageIds=null!=hn?hn:[],cn.lastPinnedMessage=dn,cn._pinnedMessagesUpdatedAt=_n,this._dispatcher.dispatch(new En({channels:[cn],context:{source:y.EVENT_PINNED_MESSAGE_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(cn)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(cn)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((pn=e.as(Lt).event).category){case Dt.USER_BLOCK:fn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=fn.blocker,gn=fn.blockee,this._groupChannelCache.block(mn.userId,gn.userId);break;case Dt.USER_UNBLOCK:vn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=vn.blocker,gn=vn.blockee,this._groupChannelCache.unblock(mn.userId,gn.userId)}return[3,79];case 79:return[3,81];case 80:if(yn=xn.sent(),O(yn))throw yn;return[3,81];case 81:return[2]}}))}))},u.prototype._markAsLeave=function(e){var t,n=this,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((function(){s.ref--,0===s.ref&&n._leftChannels.delete(e.url)}),1e4)},u.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},u.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},u.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},u.prototype.subscribeChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},u.prototype.unsubscribeChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},u.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===Wt.JOINED})).length},u.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n;return f(this,(function(s){switch(s.label){case 0:l(g("string",e)).throw(h.invalidParameters),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=s.sent())?[2,n]:[3,4];case 3:return s.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,s.sent()]}}))}))},u.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return l(g("string",e)).throw(h.invalidParameters),n=new Nn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(s=o.sent(),r=s.as(Un).channel,a=r.unreadMessageCount,i=r.unreadMentionCount,r.myCountPreference){case er.UNREAD_MESSAGE_COUNT_ONLY:i=0;break;case er.UNREAD_MENTION_COUNT_ONLY:a=0;break;case er.OFF:a=0,i=0}return r._updateUnreadCount(a,i),[4,this.upsertChannelsToCache([r])];case 2:return[2,o.sent()[0]]}}))}))},u.prototype.refreshChannel=function(e,t,n,s){return void 0===t&&(t=!0),void 0===n&&(n=y.REFRESH_CHANNEL),void 0===s&&(s=!1),p(this,void 0,void 0,(function(){var r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Nn({channelUrl:e,isInternalCall:t,showLatestMessage:s}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Un).channel).myMemberState!==Wt.NONE?[3,2]:(this._dispatcher.dispatch(new Cn({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new En({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(u=c.sent()).code!==K.NON_AUTHORIZED&&u.code!==K.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Cn({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},u.prototype.getMyGroupChannels=function(e,t,n,r,a){return void 0===r&&(r=y.REQUEST_CHANNEL),void 0===a&&(a=!1),p(this,void 0,void 0,(function(){var i,o,u,c,l,h,d,_,p;return f(this,(function(f){switch(f.label){case 0:return t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3)),i=!1,a&&(o=P.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(i=!0)),l=new Tn(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n,includeLeftChannel:a&&i})),[4,this._requestQueue.send(l)];case 1:return h=f.sent(),d=h.as(An),_=d.channels,p=d.token,this._dispatcher.dispatch(new En({channels:_,context:{source:r}})),[2,{channels:_,token:p}]}}))}))},u.prototype.getMyGroupChannelChangeLogs=function(e,t,r){return void 0===r&&(r=y.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var a,i,o,u,c,d,_,p;return f(this,(function(f){switch(f.label){case 0:return a=s(s({},cn),t),l((g("string",e)||g("number",e))&&ln(a)).throw(h.invalidParameters),i=new Mn(n({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:a})),[4,this._requestQueue.send(i)];case 1:return o=f.sent(),u=o.as(bn),c=u.updatedChannels,d=u.deletedChannelUrls,_=u.hasMore,p=u.ts,c.length>0&&this._dispatcher.dispatch(new En({channels:c,context:{source:r},ts:p})),d.length>0&&this._dispatcher.dispatch(new Cn({channelUrls:d,context:{source:r}})),[2,{updatedChannels:c,deletedChannelUrls:d,hasMore:_,token:u.token}]}}))}))},u.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(a){switch(a.label){case 0:return t=s(s({},hn),e),l(dn(t)).throw(h.invalidParameters),n=new In({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),[2,r.as(wn).groupChannelCount]}}))}))},u.prototype.getUnreadItemCount=function(e){return p(this,void 0,void 0,(function(){var n,r,a,i,o,u,c,d,_,p,v,g,E,C,y,M;return f(this,(function(f){switch(f.label){case 0:return n=s(s({},_n),e),l(function(e){return m(sn,e.keys)&&m("string",e.customTypeFilters,!0)&&m("string",e.customTypesFilter,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid),a=r.sdkState,i=r.requestQueue,o=new Ln({userId:a.userId,filter:n}),[4,i.send(o)];case 1:return u=f.sent(),c=u.as(Dn),d=c.groupChannelUnreadMentionCount,_=c.groupChannelUnreadMessageCount,p=c.groupChannelInvitationCount,v=c.superGroupChannelUnreadMentionCount,g=c.superGroupChannelUnreadMessageCount,E=c.superGroupChannelInvitationCount,C=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,M=c.nonSuperGroupChannelInvitationCount,[2,t({groupChannelUnreadMentionCount:d,groupChannelUnreadMessageCount:_,groupChannelInvitationCount:p,superGroupChannelUnreadMentionCount:v,superGroupChannelUnreadMessageCount:g,superGroupChannelInvitationCount:E,nonSuperGroupChannelUnreadMentionCount:C,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:M})]}}))}))},u.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new xn({userId:t.userId}),[4,n.send(s)];case 1:return r=a.sent(),[2,r.as(Rn).unreadCount]}}))}))},u.prototype.getTotalUnreadMessageCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return t=s(s({},pn),e),l(fn(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Fn({userId:r.userId,filter:t}),[4,a.send(i)];case 1:return o=u.sent(),[2,o.as(Pn).unreadCount]}}))}))},u.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,a,i;return f(this,(function(o){switch(o.label){case 0:return t=s(s({},vn),e),l(function(e){return g("string",e.channelUrl,!0)&&m(Me,e.scheduledStatus,!0)&&r(C,e.messageTypeFilter)}(t)).throw(h.invalidParameters),n=P.of(this._iid).requestQueue,a=new kn(t),[4,n.send(a)];case 1:return i=o.sent(),[2,i.as(On).count]}}))}))},u.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=P.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},u.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=P.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e},u.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=P.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},u.prototype.createChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a;return f(this,(function(i){switch(i.label){case 0:return t=s(s({},on),e),l(un(t)).throw(h.invalidParameters),t.isPublic||(t.accessCode=void 0),n=new Vn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),a=r.as(Gn).channel,[4,this.upsertChannelsToCache([a])];case 2:return i.sent(),[2,a]}}))}))},u.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return e=Date.now(),l(e-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Bn({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(s=v(n),r=s.next();!r.done;r=s.next())(a=r.value)._updateUnreadMemberState(this._sdkState.userId,e),a._updateUnreadCount(0,0)}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},u.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=Date.now(),l(m("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Bn({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:d.sent(),s=this._groupChannelCache.channels,r=[];try{for(a=v(s),i=a.next();!i.done;i=a.next())o=i.value,e.includes(o.url)&&(o._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0),r.push(o))}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=a.return)&&c.call(a)}finally{if(u)throw u.error}}return r.length>0?[4,this.upsertChannelsToCache(r)]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2]}}))}))},u.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},u.prototype.getMessageFromCache=function(e){var t;return p(this,void 0,void 0,(function(){return f(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]}}))}))},u.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return p(this,void 0,void 0,(function(){return f(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,s.sent()]}}))}))},u.prototype.getMessagesFromCache=function(e,t,n,s,r,a){return void 0===r&&(r=Ye),void 0===a&&(a=!0),p(this,void 0,void 0,(function(){return f(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:s,backward:"next"===n,inclusive:a})];case 1:return[2,i.sent()]}}))}))},u.prototype.getPollMessagesFromCache=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,r.sent()]}}))}))},u.prototype.getCachedMessageCountBetween=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.countBetween(e,t,new ds({top:n,bottom:s}))];case 1:return[2,r.sent()]}}))}))},u.prototype.getUnsentMessagesFromCache=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},u.prototype.removeFailedMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},u}(Pt),fs=function(e,t){return t instanceof qe?e.findIndex((function(e){return e instanceof qe&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vs=function(e,t){return e.findIndex((function(e){return e instanceof Ge?e.messageId===t:e instanceof Ke?e.notificationId===t:void 0}))},ms=function(e,t){if(e.length>0){for(var n=0,s=e.length-1,r=Math.floor((n+s)/2);n0)s=r,r=Math.floor((n+s)/2);else{if(!(a<0))return r;n=r+1,r=Math.floor((n+s)/2)}}return e[r].createdAt>t.createdAt?r:r+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(ls||(ls={}));var gs,Es=function(t){function n(e,n,s,r){var a=t.call(this)||this;return a._state=ls.IDLE,a._retryCount=0,a._retryLimit=3,a.priority=0,a._worker=n,a}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===ls.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===ls.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===ls.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(s){switch(s.label){case 0:if(!this.isRunning)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=s.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=s.sent(),this.dispatch("error",n),this._retryCount0&&(r=s.map((function(e){return e.createdAt})),(null===(v=this._metadata)||void 0===v?void 0:(i=v.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.length0&&(r=s.map((function(e){return e.createdAt})),(null===(h=this._metadata)||void 0===h?void 0:(i=h.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit,this._metadata&&(t.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return f.sent(),[3,7];case 5:throw a=f.sent(),m.debug("message background next sync error",a),a;case 6:return g.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:n.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(v=null===(p=l.localCacheConfig)||void 0===p?void 0:p.maxSize)&&void 0!==v?v:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[2,t]}}))}))}))];case 1:return[2,s.sent()]}}))}))})),this._connectionEventContext=v.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n){return Cs[t]||(Cs[t]={}),Cs[t][n.url]||(Cs[t][n.url]=new e({_iid:t,channel:n})),Cs[t][n.url].ref++,Cs[t][n.url]},e.clear=function(e,t){Cs[e]&&Cs[e][t]&&(Cs[e][t].close(),delete Cs[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 ds({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{range:new ds(e.range),previousComplete:e.previousComplete}:{range:new ds({}),previousComplete:!1},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(e){var t,n,s,r;void 0===e&&(e=Date.now());var a=P.of(this._iid),i=a.logger,o=a.sessionManager;a.cacheContext.localCacheEnabled&&o.session.hasSession&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==n?n:e),this._nextSync.start(null!==(r=null===(s=this._metadata)||void 0===s?void 0:s.range.bottom)&&void 0!==r?r:e))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Cs[this._iid][this._channel.url])},e}(),Ms={},bs=function(){function e(e){var t=e._iid,n=e.channel,r=e.includeParams,a=this;this.ref=0,this._iid=t,this._channel=n,this._includeParams=r;var i,o,u=P.of(this._iid),c=u.logger,l=u.sdkState,d=u.dispatcher;this._metadataKey=(i=l.userId,o=n.url,"sendbird:".concat(i,"@groupchannel/").concat(o,"/message/changelogs.meta"));var _=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(l.userId,this._channel.url);this._sync=new Es(_,(function(){return p(a,void 0,void 0,(function(){var e,t,n,r,a,i,o,u;return f(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:l.sent(),c.debug("message changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),l.label=2;case 2:return l.trys.push([2,5,,8]),[4,Je.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,s({replyType:ne.ALL},this._includeParams),y.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=l.sent(),n=t.updatedMessages,r=t.deletedMessageIds,a=t.hasMore,i=t.token,e.hasNext=a,e.nextToken=i,(n.length>0||r.length>0)&&this._metadata&&(this._metadata.token=i),c.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return l.sent(),[3,8];case 5:return o=l.sent(),c.debug("message changelog sync error",o),o instanceof h&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:l.sent(),l.label=7;case 7:throw o;case 8:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n,s){return Ms[t]||(Ms[t]={}),Ms[t][n.url]||(Ms[t][n.url]=new e({_iid:t,channel:n,includeParams:s})),Ms[t][n.url].ref++,Ms[t][n.url]},e.clear=function(e,t){Ms[e]&&Ms[e][t]&&(Ms[e][t].close(),delete Ms[e])},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=P.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:s=r.sent(),this._metadata={token:s?s.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e=P.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Ms[this._iid][this._channel.url])},e}(),Ns={},Us=function(){function e(e){var t=e._iid,n=e.channel,s=e.hasPollMessage,r=this;this.ref=0,this._iid=t,this._channel=n;var a,i,o=P.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(a=c.userId,i=n.url,"sendbird:".concat(a,"@groupchannel/").concat(i,"/poll/changelogs.meta"));var d=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new Es(d,(function(){return p(r,void 0,void 0,(function(){var e,t,n,r,a,i,o,c;return f(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,s()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=P.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,se.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return r=l.sent(),a=r.hasMore,i=r.token,e.hasNext=a,e.nextToken=i,this._metadata.token=i,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 h&&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 Z)if(e.stateType===$.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n,s){return Ns[t]||(Ns[t]={}),Ns[t][n.url]||(Ns[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:s})),Ns[t][n.url].ref++,Ns[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.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 p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){P.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){P.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 Ns[this._iid][this._channel.url])},e}(),Ss=function(n){function s(e){var s,r,a,i,o,u,c,l,h,d,_=this;return(_=n.call(this)||this).method=N.GET,_.path="".concat(re(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),_.params=t({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!==(r=e.customTypes)&&void 0!==r?r:["*"],message_type:null!==(a=e.messageType)&&void 0!==a?a:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:ne.NONE,include_reactions:null===(o=e.includeReactions)||void 0===o||o,include_meta_array:null===(u=e.includeMetaArray)||void 0===u||u,include_thread_info:null===(c=e.includeThreadInfo)||void 0===c||c,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(d=e.showSubchannelMessagesOnly)&&void 0!==d&&d,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),_}return e(s,n),s}(S),Ts=function(t){function n(e,n){var s,r,a,i,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(s=n.prev_messages)&&void 0!==s?s:[]).map((function(t){return Xe(e,t)})),c.prevHasMore=null!==(r=n.prev_hasmore)&&void 0!==r&&r,c.isContinuousPrevMessages=null!==(a=n.is_continuous_prev_messages)&&void 0!==a&&a,c.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return Xe(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}(T),As={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(gs||(gs={}));var Is,ws,Ls,Ds=function(){function e(){this._onCacheResult=ue,this._onApiResult=ue}return e.prototype._invokeResponse=function(e,t,n){var s=this;H((function(){return p(s,void 0,void 0,(function(){return f(this,(function(s){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}(),xs=function(){function e(e,t){var n=t.filter,s=t.startingPoint,r=t.limit,a=t.prevResultLimit,i=t.nextResultLimit,o=t.channel,u=t.channelManager,c=t.disableBackgroundSync,l=void 0!==c&&c,h=this;this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key="mc-".concat(oe()),this._isDisposed=!1,this.filter=null!=n?n:new Le,this._channel=o,this._syncRange=new ds({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=r||Ye,this._prevResultLimit=null!=a?a:Math.floor(this._limit/2),this._nextResultLimit=null!=i?i:Math.floor(this._limit/2),this._channelManager=u;var m=P.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source,s=e.findIndex((function(e){return e.isIdentical(h.channel)}));s>=0&&(h._replaceChannelOfCollection(e[s]),h.channel._runIfHandleableWithGroupChannel((function(e){switch(n){case y.EVENT_CHANNEL_UPDATED:for(var s=!1,r=0;r=e.messageOffsetTimestamp){s=!0;var a=r;if(a>0){var i=h._messages.splice(0,a);h._removeMessagesFromView(i.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&h._messages.length>0&&h._removeMessagesFromView(h._messages.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED);break;case y.EVENT_CHANNEL_UNMUTED:var o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&h._clearCheckMyMutedTimer();break;case y.EVENT_CHANNEL_MUTED:o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&-1!==e._myMutedRemainingTime&&h._startCheckMyMutedTimer(e._myMutedRemainingTime);break;case y.EVENT_CHANNEL_LEFT:e.isPublic&&h._clearCheckMyMutedTimer()}H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(s){return gn(n)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel),[2]}))}))}))})),h._postprocessChannelUpdateEvent(e[s],n))},onRemove:function(e,t){var n=e.indexOf(h.channel.url);n>=0&&(h._clearCheckMyMutedTimer(),H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(n){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url),[2]}))}))})),h._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,s,r=[],a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value;u.channelUrl===h._channel.url&&(h.filter.match(u)?r.push(u):a.push(h.keyOf(u)))}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}if(ie(t)){if(r.length>0)switch(t){case y.LOCAL_MESSAGE_CANCELED:case y.LOCAL_MESSAGE_RESEND_STARTED:case y.EVENT_MESSAGE_SENT_FAILED:case y.EVENT_MESSAGE_SENT_SUCCESS:case y.EVENT_MESSAGE_UPDATED:case y.EVENT_MESSAGE_THREADINFO_UPDATED:case y.EVENT_MESSAGE_REACTION_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_ADDED:case y.EVENT_MESSAGE_FEEDBACK_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_DELETED:case y.SYNC_MESSAGE_CHANGELOGS:h._updateMessagesToView(r,t);break;case y.EVENT_MESSAGE_SENT_PENDING:h._addMessagesToView(r,t);break;case y.EVENT_MESSAGE_RECEIVED:h.hasNext||h._addMessagesToView(r,t);break;case y.SYNC_MESSAGE_FILL:h._addMessagesToView(r,t)}a.length>0&&h._removeMessagesFromView(a,t)}h._postprocessMessageUpdateEvent(e,t)},onRemove:function(e,t){h._removeMessagesFromView(e,t),h._postprocessMessageRemoveEvent(e)},onRemoveUnsent:function(e,t){h._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){h._updatePollsToView(e,t)},onPollUpdate:function(e,t){h._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){h._applyPollVoteEventToView(e,t)},onReactionUpdate:function(e,t){h._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){h._applyThreadInfoEventToView(e,t)}});var g=P.of(this._iid),E=g.cacheContext,C=g.dispatcher,M=g.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),C.dispatch(new En({channels:[this._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=ys.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=bs.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Us.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Es(this._key,(function(e){return p(h,void 0,void 0,(function(){var t=this;return f(this,(function(n){switch(n.label){case 0:return[4,M.run("message-fill-sync-".concat(o.url,"-prev"),(function(){return p(t,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:y.SYNC_MESSAGE_FILL,checkingContinuousMessages:E.localCacheEnabled})];case 1:return t=u.sent(),n=t.messages,s=t.isContinuousMessages,n.length>0?(r=Math.min.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:n.length>=this._prevResultLimit&&this.viewTop0?(r=Math.max.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:!(n.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>r,nextToken:this._syncRange.bottom}]):(E.localCacheEnabled&&m.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(o=null===(i=E.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==o?o:0,use_local_cache:E.localCacheEnabled,starting_point:0,message_init_policy:""}})),[2,{hasNext:!1,nextToken:0}])}}))}))}))];case 1:return[2,n.sent()]}}))}))})),this._connectionEventContext=C.on((function(e){if(e instanceof Z)switch(e.stateType){case $.CONNECTED:b((function(){return p(h,void 0,void 0,(function(){return f(this,(function(e){return this._activate(),[2]}))}))}));break;case $.LOGOUT:h.dispose();break;default:h._clearCheckMyMutedTimer(),h._prevFill.stop(),h._nextFill.stop()}}))}return e.prototype.keyOf=function(e){return 0},Object.defineProperty(e.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),e.prototype._postprocessChannelUpdateEvent=function(e,t){},e.prototype._postprocessChannelRemoveEvent=function(e){},e.prototype._postprocessMessageUpdateEvent=function(e,t){},e.prototype._postprocessMessageRemoveEvent=function(e){},Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],_(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype._activate=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return P.of(this._iid).logger.debug("check huge gap"),this._checkHugeGap(),[4,this._refreshChannel(y.SYNC_CHANNEL_CHANGELOGS)];case 1:return e.sent(),[2]}}))}))},e.prototype._replaceChannelOfCollection=function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)},e.prototype._shouldStartBackgroundSync=function(){var e=P.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled},e.prototype._setBaseMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n instanceof Ge&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,s,r=this,a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value,c=vs(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l.isUserMessage()&&l.applyPoll(u),a.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}return a.length>0&&ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},a.length>0&&(null===(s=(n=this._handler).onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,a)),[2]}))}))})),a},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollUpdateEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollVoteEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyReactionEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyReactionEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._applyThreadInfoEventToView=function(e,t){var n=this,s=vs(this._messages,e.targetMessageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyThreadInfoUpdateEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._removeMessagesFromView=function(e,t){var n,s,r=this,a=[],i=[],o=function(e){var t=u._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var n=u._messages[t];a.push(u.keyOf(n)),i.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=v(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(n)throw n.error}}return ie(t)&&i.length>0&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===s||s.call(n,e,this.channel,a,i),[2]}))}))})),a},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,s=void 0===n?0:n,r=t.nextLimit,a=void 0===r?0:r,i=t.inclusive,o=void 0===i||i;return p(this,void 0,void 0,(function(){var t,n,r,i,u;return f(this,(function(c){switch(c.label){case 0:return t=[],o?[4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter)]:[3,2];case 1:t=c.sent(),c.label=2;case 2:return s>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,s,!1)]:[3,4];case 3:return r=c.sent(),[3,5];case 4:r=[],c.label=5;case 5:return n=r,a>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,a,!1)]:[3,7];case 6:return u=c.sent(),[3,8];case 7:u=[],c.label=8;case 8:return i=u,[2,{messages:d(d(d([],_(t),!1),_(n),!1),_(i),!1).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:n.length,nextMessagesCount:i.length}]}}))}))},e.prototype._getRemoteMessages=function(e,t){var r=t.prevLimit,a=void 0===r?0:r,i=t.nextLimit,o=void 0===i?0:i,u=t.source,c=void 0===u?y.REQUEST_MESSAGE:u,l=t.reverse,h=void 0!==l&&l,d=t.checkingHasNext,_=void 0!==d&&d,v=t.checkingContinuousMessages,m=void 0!==v&&v;return p(this,void 0,void 0,(function(){var t,r;return f(this,(function(i){switch(i.label){case 0:return t=Je.of(this._iid),a>0||o>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,n(s(s(s({},this.filter),As),{isInclusive:!0,reverse:h,prevResultSize:a,nextResultSize:o})),c,_,m)]:[3,2];case 1:return r=i.sent(),[3,3];case 2:r={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,r]}}))}))},e.prototype._checkHugeGap=function(){var e,t,n,r,a;return p(this,void 0,void 0,(function(){var i,o,u,c,l,v,m,g,E,C,M,b,N,U,S,T,A,I,w,L,D,x,R,F,k,O=this;return f(this,(function(V){switch(V.label){case 0:return i=P.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=i.cacheContext,l=i.statManager,v=i.logger,this._messages.length>0?(m=this._syncRange.top,g=this.viewTop,E=this._syncRange.bottom,C=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,g,m)]):[3,8];case 1:return M=V.sent(),[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,E,C)];case 2:b=V.sent(),V.label=3;case 3:return V.trys.push([3,5,6,7]),[4,ce((function(){return p(O,void 0,void 0,(function(){var e,t,n,r,a,i,l,h,v,N,U,S,T,A,I,w,L,D=this;return f(this,(function(x){switch(x.label){case 0:return e=new Ss(s(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:g,prevEnd:m,prevCount:M,nextStart:E,nextEnd:C,nextCount:b,checkingContinuousMessages:c.localCacheEnabled},this.filter),As)),[4,u.send(e)];case 1:return t=x.sent(),n=t.as(Ts),r=n.isHugeGap,a=n.prevMessages,i=void 0===a?[]:a,l=n.prevHasMore,h=n.isContinuousPrevMessages,v=n.nextMessages,N=void 0===v?[]:v,U=n.nextHasmore,S=n.isContinuousNextMessages,r?H((function(){return p(D,void 0,void 0,(function(){var e;return f(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected(),[2]}))}))})):(T=this.viewTop,A=this.viewBottom,I=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,T],_(i.map((function(e){return e.createdAt}))),!1)),w=Math.max.apply(Math,d([0,A],_(N.map((function(e){return e.createdAt}))),!1)),o.dispatch(new j({messages:i,source:y.SYNC_MESSAGE_FILL})),o.dispatch(new j({messages:N,source:y.SYNC_MESSAGE_FILL})),this._syncRange.extends(I,w),(h||S)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(I,w)),l&&this._prevFill.start(I),U&&this._nextFill.start(w)),[2]}}))}))}),1)];case 4:return V.sent(),[3,7];case 5:return N=V.sent(),v.debug("Failed HugeGap Check ",N),[3,7];case 6:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=c.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[3,13];case 8:U=Date.now(),V.label=9;case 9:return V.trys.push([9,11,12,13]),[4,this._getRemoteMessages(U,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:y.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:c.localCacheEnabled})];case 10:if(S=V.sent(),T=S.messages,A=S.isContinuousMessages,I=S.hasNext,T.length>0){for(w=T.map((function(e){return e.createdAt})),L=0,D=0,x=0;x=U&&D++;this._hasPrevious=L>=this._prevResultLimit,this._hasNext=null!=I?I:D>=this._nextResultLimit,(k=this._syncRange).extends.apply(k,d([],_(w),!1)),A&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(T,y.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,13];case 11:return(F=V.sent())instanceof h&&F.code===K.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,13];case 12:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(a=null===(r=c.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 13:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return e=this,[4,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return e._unsentMessages=t.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s;return f(this,(function(r){switch(r.label){case 0:n=P.of(this._iid).logger,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._channelManager.refreshChannel(this.channel.url,!0,e,t)];case 2:return r.sent(),[3,4];case 3:return s=r.sent(),n.warn("Failed to refresh channel",s),[3,4];case 4:return[2]}}))}))},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return p(t,void 0,void 0,(function(){var e,t,n,s=this;return f(this,(function(r){switch(r.label){case 0:this._checkMyMutedStateTimer=void 0,e=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=r.sent(),e=!t.isMuted,[3,5];case 3:return r.sent(),e=!0,[3,5];case 4:return e&&(n=P.of(this._iid).sessionManager,this.channel._runIfHandleableWithGroupChannel((function(e){var t,r;e.myMutedState=G.UNMUTED;var a={source:y.EVENT_CHANNEL_UNMUTED,user:n.currentUser};null===(r=null===(t=s._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===r||r.call(t,a,s.channel)}))),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)},e.prototype._setHasNextAndHasPrevious=function(e,t){for(var n=e.map((function(e){return e.createdAt})),s=0,r=0,a=0;athis._startingPoint&&r++}this._hasPrevious=s>=this._prevResultLimit,this._hasNext=null!=t?t:r>=this._nextResultLimit},e.prototype.initialize=function(e){var t=this,n=new Ds;this._messages=[],this._unsentMessages=[],this._syncRange=new ds({}),this._hasNext=!0,this._hasPrevious=!0;var s=[],r={messages:[],prevMessagesCount:0,nextMessagesCount:0};return H((function(){return p(t,void 0,void 0,(function(){var t,a,i,o,u,c=this;return f(this,(function(l){switch(l.label){case 0:return[4,null===(u=this._backgroundSync)||void 0===u?void 0:u.loadMetadata()];case 1:if(t=l.sent(),a=P.of(this._iid),i=a.cacheContext,o=a.statManager,e===gs.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(e){return p(c,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return r=e,s=this._filterUnderOffsetMessage(r.messages),this._addMessagesToView(s,y.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return t.sent(),n._invokeResponse("local",null,s),[2]}}))}))})).catch((function(e){if(O(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){return p(c,void 0,void 0,(function(){var a,i,u,c,l,h,p,v=this;return f(this,(function(f){switch(f.label){case 0:return a=P.of(this._iid).cacheContext,i=!0,u=!0,c=!1,a.localCacheEnabled&&s.length>0&&(l=t.range).includes.apply(l,d([],_(s.map((function(e){return e.createdAt}))),!1))&&(!t.previousComplete&&r.prevMessagesCountt.range.bottom||r.nextMessagesCount=e._latestMessageInfo.createdAt&&(u=!1)})),u?(i=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:a.localCacheEnabled}).then((function(e){var t,s,r,a=e.messages,i=e.isContinuousMessages,o=e.hasNext,u=v._filterUnderOffsetMessage(a);v._messages=[],u.length>0?(v._setHasNextAndHasPrevious(u,o),(t=v._syncRange).extends.apply(t,d([],_(u.map((function(e){return e.createdAt}))),!1)),i&&(null===(s=v._backgroundSync)||void 0===s?void 0:s.range.overlap(v._syncRange))&&(null===(r=v._backgroundSync)||void 0===r||r.range.extends(v._syncRange.top,v._syncRange.bottom)),v._addMessagesToView(u,y.REQUEST_MESSAGE)):(v._hasPrevious=!1,v._hasNext=!1),n._invokeResponse("remote",null,u)})).catch((function(e){if(O(e))throw e;n._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(s),n._invokeResponse("remote",null,s)),a.localCacheEnabled&&o.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:i?"cache_hit":"cache_miss",max_db_size:null!==(p=null===(h=a.localCacheConfig)||void 0===h?void 0:h.maxSize)&&void 0!==p?p:0,message_init_policy:e,use_local_cache:a.localCacheEnabled,collection_id:this._key}})),[2]}}))}))}));return o.put(new le({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}})),[2]}}))}))})),n},e.prototype.loadPrevious=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasPrevious?this._isLoadingPrevious?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingPrevious=!0,o=this.viewTop,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{prevLimit:this._prevResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._prevResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h=this;return f(this,(function(p){switch(p.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=p.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top))),u=u.filter((function(e){return fs(h._messages,e)<0})),this._hasPrevious=u.length>=this._prevResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(c=null===(i=e.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==c?c:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=u.length>=this._prevResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingPrevious=!1,[2,u]}}))}))},e.prototype.loadNext=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasNext?this._isLoadingNext?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingNext=!0,o=this.viewBottom,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{nextLimit:this._nextResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._nextResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h,p=this;return f(this,(function(f){switch(f.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=f.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom))),u=u.filter((function(e){return fs(p._messages,e)<0})),this._hasNext=null!==(i=t.hasNext)&&void 0!==i?i:u.length>=this._nextResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(h=null===(c=e.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==h?h:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=u.length>=this._nextResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingNext=!1,[2,u]}}))}))},e.prototype.removeFailedMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return[4,this._channelManager.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,s=this;if(!this._isDisposed){this._isDisposed=!0;var r=P.of(this._iid),a=r.cacheContext,i=r.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(e){e.myMemberState!==Wt.NONE&&(s._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new En({channels:[s._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})))})),a.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}},e}(),Rs=function(t){function n(e,n){return t.call(this,e,s(s({},n),{channelManager:ps.of(e)}))||this}return e(n,t),n.prototype.keyOf=function(e){return e.messageId},n.prototype.initialize=function(e){var n=this;return b((function(){return p(n,void 0,void 0,(function(){var e;return f(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]}}))}))})),t.prototype.initialize.call(this,e)},n.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},n.prototype._activate=function(){return p(this,void 0,void 0,(function(){var e=this;return f(this,(function(n){switch(n.label){case 0:return[4,t.prototype._activate.call(this)];case 1:return n.sent(),[4,b((function(){return p(e,void 0,void 0,(function(){var e;return f(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]}}))}))}))];case 2:return n.sent(),[2]}}))}))},n.prototype._addMessagesToView=function(e,t){var n,s,r=this,a=this._filterUnderOffsetMessage(e),i=[],o=[];try{for(var u=v(a),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===y.SYNC_MESSAGE_FILL){if(l.messageId>0){if((E=fs(this._messages,l))<0){fs(this._unsentMessages,l)<0&&i.push(l);var h=ms(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof qe){(E=fs(this._unsentMessages,l))<0&&fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l))}}else if(l.messageId>0){if((E=fs(this._messages,l))<0){var m=fs(this._unsentMessages,l);m<0?i.push(l):(this._unsentMessages.splice(m,1),o.push(l));h=ms(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[E]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,d([],_(g),!1))}}else if(l instanceof qe){var E;(E=fs(this._unsentMessages,l))<0?fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l)):(o.push(l),this._unsentMessages[E]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,a;return f(this,(function(u){return e={source:t},i.length>0&&(null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===s||s.call(n,e,this.channel,i)),o.length>0&&(null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,e,this.channel,o)),[2]}))}))}))},n.prototype._updateMessagesToView=function(e,t){var n,s,r=this,a=[],i=[],o=[];try{for(var u=v(e),c=u.next();!c.done;c=u.next()){var l,h=c.value;if(h.messageId>0)if((l=fs(this._messages,h))>=0)i.push(h),this._messages[l]=h;else{var m=fs(this._unsentMessages,h);if(m>=0){var g=_(this._unsentMessages.splice(m,1),1)[0];if(this.hasNext&&g)o.push(g);else{i.push(h);var E=ms(this._messages,h);this._messages.splice(E,0,h)}}else{var C=this._messages.map((function(e){return e.createdAt}));(h.createdAtMath.max.apply(Math,d([],_(C),!1))&&!this._hasNext)&&a.push(h)}}else if(h instanceof qe)(l=fs(this._unsentMessages,h))>=0&&(i.push(h),this._unsentMessages[l]=h)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}return ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,u;return f(this,(function(c){return e={source:t},i.length>0?null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,i):o.length>0?null===(u=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===u||u.call(r,e,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t),[2]}))}))})),i},n}(xs),Fs={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},Ps=function(t){function n(e){var n=this,s=e.channelUrl,r=e.token,a=e.limit,i=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=N.GET,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/members"),n.params={token:r,limit:a,order:i,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}(S),ks=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.members=[];var r=n.next,a=n.members;return s.token=r,a&&a.length>0&&(s.members=a.map((function(t){return new tn(e,t)}))),s}return e(n,t),n}(T);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Is||(Is={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(ws||(ws={})),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"}(Ls||(Ls={}));var Os=function(t){function a(e,n,s){var r,a,o,u,c=this;return(c=t.call(this,e,n,i.GROUP,s)||this).mutedMemberFilter=Is.ALL,c.memberStateFilter=Ls.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Zt.ALL,c.order=ws.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(r=s.mutedMemberFilter)&&void 0!==r?r:Is.ALL,c.memberStateFilter=null!==(a=s.memberStateFilter)&&void 0!==a?a:Ls.ALL,c.nicknameStartsWithFilter=null!==(o=s.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=s.order)&&void 0!==u?u:ws.MEMBER_NICKNAME_ALPHABETICAL,c}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&r(Is,this.mutedMemberFilter)&&r(Ls,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&r(Zt,this.operatorFilter)&&r(ws,this.order)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=P.of(this._iid).requestQueue,t=new Ps(n(s(s({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=u.sent(),a=r.as(ks),i=a.members,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(he),Hs=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/accept"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),Vs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.JOINED,s}return e(n,t),n}(T),Gs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.isDistinct,i=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,_=e.customType,p=e.operatorUserIds,f=e.messageSurvivalSeconds;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r)),s.params=t({is_distinct:a,is_public:i,is_discoverable:o,name:h,data:d,custom_type:_,cover_url:u,cover_file:c,access_code:l,operator_ids:p,message_survival_seconds:f}),s}return e(s,n),s}(S),Bs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),qs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s)),n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var zs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var js=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.countPreference,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:r},a}return e(n,t),n}(S),Ws=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.countPreference=n.count_preference,s}return e(n,t),n}(T),Qs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.locale;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r),"/reset_user_history"),s.params=t({locale:a}),s}return e(s,n),s}(S),Ys=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),Ks=s(s({},Ze),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Js=s(s({},et),{scheduledAt:void 0}),Xs=function(s){function r(e){var r,a,i=this;i=s.call(this)||this;var o=[];e.mentionType===de.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((function(e){return e.userId}))));var u=e.channelType,c=e.channelUrl,l=e.scheduledMessageId;return i.method=N.PUT,i.path="".concat(re(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((function(e){return nt.payloadify(e)})),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(a=e.metaArrays)||void 0===a?void 0:a.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})),i}return e(r,s),r}(S),Zs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Ae(e,n),s}return e(n,t),n}(T),$s=function(s){function r(e){var r,a=this;a=s.call(this)||this;var i=[];e.mentionType===de.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return a.method=N.PUT,a.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),a.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(r=e.metaArrays)||void 0===r?void 0:r.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),a}return e(r,s),r}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Te(e,n),s}e(n,t)}(T);var er,tr,nr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.DELETE,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a)),n}return e(n,t),n}(S),sr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.POST,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a),"/send_now"),n}return e(n,t),n}(S),rr=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.pushTriggerOption,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:r},a}return e(n,t),n}(S),ar=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T),ir=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=t.call(this)||this;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),r}return e(n,t),n}(S),or=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T);!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"}(er||(er={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(tr||(tr={}));var ur=function(u){function c(e,t){var n,c,l,h,p,f,v,m,E,C,y,M,b,N,U,S,T,A,I,w,L=this;return(L=u.call(this,e,t)||this)._unreadMemberStateMap=new Map,L._undeliveredMemberStateMap=new Map,L._typingStatus=new Map,L._lastMemberCountUpdated=0,L._typingStarted=0,L._typingEnded=0,L._hasBotInfo={general:!1,ai:!1},L.isDistinct=!1,L.isSuper=!1,L.isBroadcast=!1,L.isExclusive=!1,L.isPublic=!1,L.isDiscoverable=!0,L.isChatNotification=!1,L.isAccessCodeRequired=!1,L.isPushEnabled=!1,L.unreadMessageCount=0,L.unreadMentionCount=0,L.totalUnreadReplyCount=0,L.members=[],L.memberCount=0,L.joinedMemberCount=0,L.hiddenState=tr.UNHIDDEN,L.lastMessage=null,L.messageOffsetTimestamp=0,L.messageSurvivalSeconds=-1,L.myMemberState=Wt.NONE,L.myRole=a.NONE,L.myMutedState=G.UNMUTED,L.myLastRead=0,L.myCountPreference=er.ALL,L.myPushTriggerOption=me.DEFAULT,L.inviter=null,L.invitedAt=0,L.joinedAt=0,L.lastPinnedMessage=null,L._latestMessageInfo=null,L._pinnedMessagesUpdatedAt=0,L._myMutedRemainingTime=-1,L.channelType=i.GROUP,L.isDistinct=null!==(c=t.is_distinct)&&void 0!==c&&c,L.isSuper=null!==(l=t.is_super)&&void 0!==l&&l,L.isBroadcast=null!==(h=t.is_broadcast)&&void 0!==h&&h,L.isExclusive=null!==(p=t.is_exclusive)&&void 0!==p&&p,L.isPublic=null!==(f=t.is_public)&&void 0!==f&&f,L.isDiscoverable=null!==(v=t.is_discoverable)&&void 0!==v?v:L.isPublic,L.isChatNotification=null!==(m=t.is_chat_notification)&&void 0!==m&&m,L.isAccessCodeRequired=null!==(E=t.is_access_code_required)&&void 0!==E&&E,L.isPushEnabled=null!==(C=t.is_push_enabled)&&void 0!==C&&C,Array.isArray(t.members)&&(n=L.members).push.apply(n,d([],_(t.members.map((function(e){return new tn(L._iid,e)}))),!1)),L.memberCount=null!==(y=t.member_count)&&void 0!==y?y:0,L.joinedMemberCount=null!==(M=t.joined_member_count)&&void 0!==M?M:0,L.hiddenState=r(tr,t.hidden_state)?t.hidden_state:tr.UNHIDDEN,L.messageOffsetTimestamp=null!==(b=t.ts_message_offset)&&void 0!==b?b:0,L.messageSurvivalSeconds=null!==(N=t.message_survival_seconds)&&void 0!==N?N:-1,L.lastMessage=t.last_message?Xe(L._iid,s({channel_type:L.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((function(e){g("number",t.read_receipt[e])&&L._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((function(e){g("number",t.delivery_receipt[e])&&L._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),L.myMemberState=r(Wt,t.member_state)?t.member_state:Wt.NONE,L.myRole=r(a,t.my_role)?t.my_role:a.NONE,r(G,t.is_muted)?L.myMutedState=t.is_muted:g("boolean",t.is_muted)?L.myMutedState=t.is_muted?G.MUTED:G.UNMUTED:L.myMutedState=G.UNMUTED,L.myCountPreference=r(er,t.count_preference)?t.count_preference:er.ALL,L.myPushTriggerOption=r(me,t.push_trigger_option)?t.push_trigger_option:me.ALL,L.myLastRead=null!==(U=t.user_last_read)&&void 0!==U?U:0,L.inviter=t.inviter?new o(L._iid,t.inviter):null,L.invitedAt=null!==(S=t.invited_at)&&void 0!==S?S:0,L.joinedAt=null!==(T=t.joined_ts)&&void 0!==T?T:0,L._updateUnreadCount(null!==(A=t.unread_message_count)&&void 0!==A?A:0,null!==(I=t.unread_mention_count)&&void 0!==I?I:0),L.totalUnreadReplyCount=null!==(w=t.total_unread_thread_message_count)&&void 0!==w?w:0,L.lastPinnedMessage=t.latest_pinned_message?Xe(L._iid,s({channel_type:L.channelType},t.latest_pinned_message)):null,t.latest_message&&(L._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),L._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot},L}return e(c,u),Object.defineProperty(c.prototype,"isHidden",{get:function(){return this.hiddenState!==tr.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._unreadMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._undeliveredMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasBot",{get:function(){return this._hasBotInfo.general},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasAiBot",{get:function(){return this._hasBotInfo.ai},enumerable:!1,configurable:!0}),c.payloadify=function(e){return t(n(s(s({},u.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,total_unread_thread_message_count:e.totalUnreadReplyCount,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 tn.payloadify(e)})),last_message:e.lastMessage?at(e.lastMessage):null,inviter:e.inviter?o.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?at(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))},c.prototype._shouldUpdateLastMessageWith=function(e){if(e.silent)return!1;var t=P.of(this._iid).appInfo;switch(null==t?void 0:t.lastMessageThreadingPolicy){case pe.NONE:case pe.INCLUDE_REPLY:break;case pe.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case pe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case fe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},c.prototype._updateLastMessage=function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)},c.prototype._updateUnreadCount=function(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===er.ALL||this.myCountPreference===er.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=P.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===er.ALL||this.myCountPreference===er.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},c.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)},c.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},c.prototype._setLatestMemberCount=function(e,t,n){var s=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,s=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),s},c.prototype.isReadMessage=function(e){var t=P.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt},c.prototype.serialize=function(){var e=this;return R(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))},c.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Rs(this._iid,s(s({},e),{channel:this}))},c.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Os(this._iid,this.url,e)},c.prototype.createThreadedParentMessageListQuery=function(e){return void 0===e&&(e={}),new it(this._iid,this.url,this.channelType,e)},c.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 s=this.members[n];s.state===Wt.JOINED&&(e.state=s.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},c.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof tn?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},c.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof qe&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var s=P.of(this._iid).sdkState,r=e.createdAt,a=0;try{for(var i=v(this.members),o=i.next();!o.done;o=i.next()){var u=o.value;if(s.userId!==u.userId&&u.state===Wt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&a.push(i)}})),a},c.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var s=P.of(this._iid).sdkState;if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var r=e instanceof qe?e.sender:null,a=[];return this.members.forEach((function(i){if(t||i.userId!==s.userId&&i.userId!==(null==r?void 0:r.userId)){var o=n._unreadMemberStateMap.get(i.userId);o&&o=t&&(e._typingStatus.delete(a),s=!0)})),s},c.prototype.refresh=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){return[2,this._refresh()]}))}))},c.prototype._refresh=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return t=P.of(this._iid),n=t.requestQueue,s=t.dispatcher,r=new Nn({channelUrl:this.url}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Un).channel,this._update(i),e||s.dispatch(new En({channels:[i],context:{source:y.REFRESH_CHANNEL}})),[2,this]}}))}))},c.prototype.freeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.freeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.unfreeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.unfreeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.updateChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return t=s(s({},Fs),e),l(function(e){return g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new Gs(s({channelUrl:this.url},t)),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Bs).channel,this._update(u),r.dispatch(new En({channels:[u],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.invite=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return l(e.every((function(e){return e instanceof o}))).throw(h.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},c.prototype.inviteWithUserIds=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(m("string",e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.requestQueue,r=t.sessionManager,a=new Yn({channelUrl:this.url,userIds:e}),[4,s.send(a)];case 1:return i=u.sent(),o=i.as(Kn).channel,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_INVITED,inviter:r.currentUser,invitees:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.join=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new qn({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(zn).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.leave=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return t=P.of(this._iid),n=t.sdkState,s=t.requestQueue,r=new Wn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,s.send(r)];case 1:return a.sent(),this.myMemberState=Wt.NONE,[2]}}))}))},c.prototype.acceptInvitation=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new Hs({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(Vs).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.declineInvitation=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new Xn({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),this.myMemberState=Wt.NONE,[2,this]}}))}))},c.prototype.sendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),ps.of(t._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.updateUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateUserMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendMultipleFilesMessage=function(e){var t=this,n=new ut,s=P.of(this._iid).dispatcher;return u.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){n._trigger(e)})).onFailed((function(e,t){n._triggerFailed(e,t)})).onSucceeded((function(e){var r=ps.of(t._iid);t._updateLastMessage(e),r.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})).onFileUploaded((function(e,t,s,r){n._triggerOnFileUploaded(e,t,s,r)})),n},c.prototype.updateFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateFileMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.deleteMessage=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,u.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&e instanceof qe&&P.of(this._iid).dispatcher.dispatch(new ge({reqId:e.reqId,source:y.EVENT_MESSAGE_DELETED})),[2]}}))}))},c.prototype.hide=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=s(s({},$n),e),l(function(e){return g("boolean",e.hidePreviousMessages,!0)&&g("boolean",e.allowAutoUnhide,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.sdkState,i=n.requestQueue,o=new es(s({channelUrl:this.url,userId:a.userId},t)),[4,i.send(o)];case 1:return u=d.sent(),c=u.as(ts).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.unhide=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=new zs({channelUrl:this.url}),[4,n.send(s)];case 1:return r.sent(),this.hiddenState=tr.UNHIDDEN,t.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.delete=function(){return p(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=P.of(this._iid).requestQueue,t=new qs({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o=this;return f(this,(function(u){switch(u.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.dispatcher,s=e.requestQueue,r=new yt({channelUrl:this.url}),[4,s.send(r)];case 1:return a=u.sent(),i=a.as(Be).readStatus,this._updateUnreadMemberState(t.userId,i.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_READ}})),[2]}}))}))},c.prototype.markAsDelivered=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new cs({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),[2]}}))}))},c.prototype.startTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=n?(this._typingStarted=s,this._typingEnded=0,r=new ss({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.endTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=n?(this._typingStarted=0,this._typingEnded=s,r=new as({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.createScheduledUserMessage=function(e){e=s(s({},ct),e),l(lt(e)).throw(h.invalidParameters);var t=new Ct;return this._createScheduledUserMessage(e,t),t},c.prototype.updateScheduledUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a,i;return f(this,(function(o){switch(o.label){case 0:return n=s(s({},Js),t),l(function(e){return tt(e)&&g("number",e.scheduledAt,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid).requestQueue,a=new $s(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(a)];case 1:return i=o.sent(),[2,i.as(Mt).message]}}))}))},c.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},ht),e),l(dt(e)).throw(h.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new Ct;return ve(bt).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);H((function(){return p(t,void 0,void 0,(function(){return f(this,(function(e){return[2,a._trigger(s)]}))}))}))})),E(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a},c.prototype.updateScheduledFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a;return f(this,(function(i){switch(i.label){case 0:return n=s(s({},Ks),t),l(function(e){return $e(e)&&g("number",e.scheduledAt,!0)&&(E(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(h.invalidParameters),E(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return r=new Xs(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,P.of(this._iid).requestQueue.send(r)];case 3:return a=i.sent(),[2,a.as(Zs).message]}}))}))},c.prototype.cancelScheduledMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new nr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.sendScheduledMessageNow=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new sr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.getMyPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a;return f(this,(function(i){switch(i.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new ir({userId:t.userId,channelUrl:this.url}),[4,n.send(s)];case 1:return r=i.sent(),a=r.as(or).pushTriggerOption,this.myPushTriggerOption=a,[2,a]}}))}))},c.prototype.setMyPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(me,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new rr({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(ar).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.setMyCountPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(er,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new js({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Ws).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.resetMyHistory=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=e.sdkState,r=new Qs({channelUrl:this.url,locale:s.localeForChatbot}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Ys).messageOffsetTimestamp,this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt0&&!r.some((function(t){switch(t){case en.CHANNEL_NAME:return e.name.toLowerCase().includes(s.toLowerCase());case en.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(s.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var a=this._userIdsFilter,i=a.userIds,o=a.includeMode,u=a.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(i.length>0)switch(u){case $t.AND:if(i.some((function(e){return!l.includes(e)})))return!1;break;case $t.OR:if(i.every((function(e){return!l.includes(e)})))return!1}}else{if(i.includes(t)||i.push(t),e.members.length>i.length)return!1;if(!c(i,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var _=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=_})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Yt.ALL:if("none"===e.myMemberState)return!1;break;case Yt.JOINED:if("joined"!==e.myMemberState)return!1;break;case Yt.INVITED:if("invited"!==e.myMemberState)return!1;break;case Yt.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Yt.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Xt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Xt.HIDDEN:if(!e.isHidden)return!1;break;case Xt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Xt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Jt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Qt.PUBLIC:if(!e.isPublic)return!1;break;case Qt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Kt.SUPER:if(!e.isSuper)return!1;break;case Kt.NON_SUPER:if(e.isSuper)return!1}return!(this.createdAfter&&e.createdAtthis.createdBefore)},e}(),an=function(t){function n(e,n){var s=n.sdkState,r=n.cacheContext,a=t.call(this,e)||this;return a._channels=new Map,a._sdkState=s,a._cacheContext=r,a}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return l(!!e).throw(h.databaseError),e.collection(Ce)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return ps.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],_(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case St.CHRONOLOGICAL:if(!a&&n.createdAt>t||a&&n.createdAtt||a&&n.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)s._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});s._update(e),n.push(s)}else a._channels.set(e.url,e),n.push(e)})),!this.localCacheEnabled)return[3,2];for(s=[],r=0;r0?[4,this.upsert(s)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},n.prototype.unblock=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],_(this._channels.keys()),!1)),p(this,void 0,void 0,(function(){var n,s,r,a,i,o,u,c;return f(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),s=v(t),r=s.next(),l.label=2;case 2:return r.done?[3,5]:(a=r.value,[4,this.get(a)]);case 3:(null==(i=l.sent())?void 0:i._updateUnreadMemberState(this._sdkState.userId,e))&&(i._updateUnreadCount(0,0),n.push(i)),l.label=4;case 4:return r=s.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{r&&!r.done&&(c=s.return)&&c.call(s)}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}(u),on={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},un=function(e){return m("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},cn={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},ln=function(e){return m("string",e.customTypes,!0)&&g("boolean",e.includeEmpty,!0)&&g("boolean",e.includeFrozen,!0)&&g("boolean",e.includeMetaData,!0)&&g("boolean",e.includeChatNotification,!0)},hn={myMemberStateFilter:Yt.ALL},dn=function(e){return r(Yt,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"}(sn||(sn={}));var _n={keys:[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT,sn.NONSUPER_UNREAD_MENTION_COUNT,sn.SUPER_UNREAD_MENTION_COUNT,sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,sn.NONSUPER_UNREAD_MESSAGE_COUNT,sn.SUPER_UNREAD_MESSAGE_COUNT,sn.GROUP_CHANNEL_INVITATION_COUNT,sn.NONSUPER_INVITATION_COUNT,sn.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},pn={channelCustomTypesFilter:void 0,superChannelFilter:Kt.ALL},fn=function(e){return m("string",e.channelCustomTypesFilter,!0)&&r(Kt,e.superChannelFilter)},vn={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:C.ALL},mn=s({},y),gn=function(e){return e.startsWith("EVENT_")||e===y.SYNC_CHANNEL_CHANGELOGS||e===y.REFRESH_CHANNEL},En=function(t){function n(e){var n=e.channels,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=e.ts,o=t.call(this)||this;return o.channels=n,o.context=s,o.isWebSocketEventComing=a,o.ts=i,o}return e(n,t),n}(M),Cn=function(t){function n(e){var n=e.channelUrls,s=e.context,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=t.call(this)||this;return i.channelUrls=n,i.context=s,i.isWebSocketEventComing=a,i}return e(n,t),n}(M),yn=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,s=e.unsentMessageCache,r=e.dispatcher,a=this;this._observers=new Map,r.on((function(e){return p(a,void 0,void 0,(function(){var r,a,i,o,u,c,l,h,d,_,m,g,E,C,M,N,U,S,T=this;return f(this,(function(A){switch(A.label){case 0:if(!(e instanceof En))return[3,19];if(r=e.channels,E=e.context,C=e.isWebSocketEventComing,a=r.filter((function(e){return e instanceof ur})),E.source!==y.EVENT_CHANNEL_RESET_HISTORY&&E.source!==y.EVENT_CHANNEL_HIDDEN)return[3,9];A.label=1;case 1:A.trys.push([1,6,7,8]),i=v(a),o=i.next(),A.label=2;case 2:return o.done?[3,5]:(d=o.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 3:A.sent(),A.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return u=A.sent(),M={error:u},[3,8];case 7:try{o&&!o.done&&(N=i.return)&&N.call(i)}finally{if(M)throw M.error}return[7];case 8:return[3,17];case 9:c=t.filterOffsetChanged(a),A.label=10;case 10:A.trys.push([10,15,16,17]),l=v(c),h=l.next(),A.label=11;case 11:return h.done?[3,14]:(d=h.value,[4,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)]);case 12:A.sent(),A.label=13;case 13:return h=l.next(),[3,11];case 14:return[3,17];case 15:return _=A.sent(),U={error:_},[3,17];case 16:try{h&&!h.done&&(S=l.return)&&S.call(l)}finally{if(U)throw U.error}return[7];case 17:return[4,t.upsert(a,e.ts)];case 18:return m=A.sent(),C||this._broadcastUpdateEvent(m,E),[3,24];case 19:return e instanceof Cn?(g=e.channelUrls,E=e.context,C=e.isWebSocketEventComing,[4,t.remove(g)]):[3,22];case 20:return A.sent(),[4,b((function(){return p(T,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=v(g),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(r=t.value,[4,n.removeMessagesOfChannel(r)]);case 2:return u.sent(),[4,s.removeMessagesOfChannel(r)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return a=u.sent(),i={error:a},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(i)throw i.error}return[7];case 8:return[2]}}))}))}))];case 21:return A.sent(),C||this._broadcastRemoveEvent(g,E),[3,24];case 22:return e instanceof At?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,24];case 23:A.sent(),A.label=24;case 24:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onUpdate&&i.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,s;try{for(var r=v(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onRemove&&i.onRemove(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}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}(),Mn=function(r){function a(e){var a=e.userId,i=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c,h=r.call(this)||this,d=s(s({},cn),u),_=d.customTypes,p=d.includeEmpty,f=d.includeFrozen;return h.method=N.GET,h.path="".concat(U,"/").concat(encodeURIComponent(a),"/my_group_channels/changelogs"),h.params=t(n({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:_,show_empty:p,show_frozen:f,include_chat_notification:l})),h}return e(a,r),a}(S),bn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedChannels=n.updated.map((function(t){return new ur(e,Object.assign(t,{ts:n.ts}))})),s.deletedChannelUrls=n.deleted,s.hasMore=n.has_more,s.token=n.next,s.ts=n.ts,s}return e(n,t),n}(T),Nn=function(t){function n(e){var n=e.channelUrl,s=e.isInternalCall,r=e.showLatestMessage,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(s?A:I,"/").concat(encodeURIComponent(n)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=r&&r},a}return e(n,t),n}(S),Un=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Sn={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:Yt.ALL,unreadChannelFilter:Jt.ALL,superChannelFilter:Kt.ALL,publicChannelFilter:Qt.ALL,hiddenChannelFilter:Xt.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:$t.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:St.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0},Tn=function(n){function s(e){var s=this,r=e.userId,a=e.token,i=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,_=e.nicknameContainsFilter,p=e.nicknameStartsWithFilter,f=e.nicknameExactMatchFilter,v=e.channelNameContainsFilter,m=e.channelUrlsFilter,g=e.customTypesFilter,E=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,y=e.metadataOrderKeyFilter,M=e.metadataKey,b=e.metadataValues,S=e.metadataValueStartsWith,T=e.includeFrozen,A=e.includeMetaData,I=e.searchFilter,w=e.userIdsFilter,L=e.includeChatNotification,D=void 0!==L&&L,x=e.includeLeftChannel,R=void 0!==x&&x,F=e.createdAfter,P=e.createdBefore;return(s=n.call(this)||this).method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(r),"/my_group_channels"),s.params=t({token:a,limit:i,order:null!=o?o:Sn.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=u?u:Sn.includeEmpty,member_state_filter:null!=c?c:Sn.myMemberStateFilter,super_mode:null!=l?l:Sn.superChannelFilter,public_mode:null!=h?h:Sn.publicChannelFilter,unread_filter:null!=d?d:Sn.unreadChannelFilter,members_nickname_contains:_,members_nickname_startswith:p,members_nickname:f,name_contains:v,channel_urls:m,custom_types:g,custom_type_startswith:E,hidden_mode:C,metadata_order_key:y,metadata_key:M,metadata_values:b,metadata_value_startswith:S,show_frozen:T,show_metadata:A,include_chat_notification:D,include_left_channel:R,created_after:F,created_before:P}),I&&I.query&&I.fields&&(s.params.search_query=I.query,s.params.search_fields=I.fields),w&&w.userIds&&w.userIds.length>0&&(w.includeMode?(s.params.members_include_in=w.userIds,s.params.query_type=w.queryType.toUpperCase()):s.params.members_exactly_in=w.userIds),s}return e(s,n),s}(S),An=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.channels=[];var r=n.next,a=n.channels,i=n.ts;return s.token=r,a&&a.length>0&&(s.channels=a.map((function(t){return t.ts=i,new ur(e,t)}))),s.ts=null!=i?i:0,s}return e(n,t),n}(T),In=function(t){function n(e){var n=e.userId,s=e.filter,r=t.call(this)||this,a=s.myMemberStateFilter;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/group_channel_count"),r.params={state:null!=a?a:Yt.ALL},r}return e(n,t),n}(S),wn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.groupChannelCount=n.group_channel_count,s}return e(n,t),n}(T),Ln=function(n){function s(e){var s=e.userId,r=e.filter,a=n.call(this)||this,i=r.keys,o=r.customTypeFilters,u=r.customTypesFilter;return a.method=N.GET,a.path="".concat(U,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=t({item_keys:i,custom_types:null!=u?u:o}),a}return e(s,n),s}(S),Dn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=n[sn.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=n[sn.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=n[sn.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=n[sn.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=n[sn.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=n[sn.SUPER_INVITATION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=n[sn.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=n[sn.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[sn.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=n[sn.NONSUPER_INVITATION_COUNT]),s}return e(n,t),n}(T),xn=function(t){function n(e){var n=e.userId,s=t.call(this)||this;return s.method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_channel_count"),s}return e(n,t),n}(S),Rn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s}return e(n,t),n}(T),Fn=function(t){function n(e){var n=e.userId,s=e.filter,r=e.includeFeedChannel,a=void 0!==r&&r,i=t.call(this)||this,o=s.channelCustomTypesFilter,u=s.superChannelFilter;return i.method=N.GET,i.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_message_count"),i.params={super_mode:null!=u?u:Kt.ALL,custom_types:o,include_feed_channel:a},i}return e(n,t),n}(S),Pn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s.unreadFeedCount=n.unread_feed_count,s}return e(n,t),n}(T),kn=function(t){function n(e){var n=e.channelUrl,s=e.scheduledStatus,r=e.messageTypeFilter,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(w,"/count"),a.params={channel_url:n,status:Hn(s)},r&&(a.params.message_type=r),a}return e(n,t),n}(S),On=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.count=n.count,s}return e(n,t),n}(T),Hn=function(e){if(!e)return[];var t=[];return e.forEach((function(e){switch(e){case Me.PENDING:t.push(be.PENDING);break;case Me.SENT:t.push(be.IN_QUEUE),t.push(be.SENT);break;case Me.CANCELED:t.push(be.CANCELED);break;case Me.FAILED:t.push(be.FAILED)}})),t},Vn=function(n){function s(e){var s=this,r=e.userId,a=e.channelUrl,i=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,h=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,E=e.name,C=e.data,y=e.customType,M=e.messageSurvivalSeconds,b=e.invitedUserIds,U=e.operatorUserIds;return(s=n.call(this)||this).method=N.POST,s.path=I,s.params=t({user_ids:d([r],_(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:a,cover_url:i,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:p,is_public:h,is_discoverable:f,strict:v,is_ephemeral:m,access_code:g,name:E,data:C,custom_type:y,operator_ids:U,message_survival_seconds:M}),s}return e(s,n),s}(S),Gn=function(t){function n(e,n){var s,r=this;return(r=t.call(this,e,n)||this).channel=new ur(e,n),r.isCreated=null===(s=n.is_created)||void 0===s||s,r}return e(n,t),n}(T),Bn=function(t){function n(e){var n=e.userId,s=e.channelUrls,r=t.call(this)||this;return r.method=N.PUT,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),r.params={channel_urls:s},r}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var qn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/join"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),zn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u,l=a.users,h=void 0===l?null:l;return r.memberCount=o,r.joinedMemberCount=c,r.members=Array.isArray(h)?h.map((function(t){return new tn(e,t)})):[new tn(e,s.data)],r}return e(n,t),n}(Ft),Wn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/leave"),n.params={user_id:r,should_remove_operator_status:a},n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Qn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u;return r.memberCount=o,r.joinedMemberCount=c,r.member=new tn(r._iid,s.data),r}return e(n,t),n}(Ft),Yn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userIds;return(n=t.call(this)||this).method=N.POST,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/invite"),n.params={user_ids:r},n}return e(n,t),n}(S),Kn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),Jn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this;r.inviter=null;var a=s.data,i=a.member_count,u=void 0===i?0:i,c=a.joined_member_count,l=void 0===c?0:c,h=a.inviter,d=a.invitees,_=void 0===d?[]:d;return r.memberCount=u,r.joinedMemberCount=l,h&&Object.keys(h).length>0&&(r.inviter=new o(e,h)),r.invitees=_.map((function(t){return new tn(e,t)})),r}return e(n,t),n}(Ft),Xn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/decline"),n.params={user_id:r},n}return e(n,t),n}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.NONE,s}e(n,t)}(T);var Zn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,u=a.joined_member_count,c=a.inviter,l=a.invitee;return r.memberCount=null!=i?i:0,r.joinedMemberCount=null!=u?u:0,r.inviter=new o(e,c),r.invitee=new tn(e,l),r}return e(n,t),n}(Ft),$n={hidePreviousMessages:!1,allowAutoUnhide:!0},es=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.hidePreviousMessages,i=e.allowAutoUnhide;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n.params={user_id:r,hide_previous_messages:null!=a?a:$n.hidePreviousMessages,allow_auto_unhide:null!=i?i:$n.allowAutoUnhide},n}return e(n,t),n}(S),ts=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),ns=function(t){function n(e,n,s){var r,a,i,o=this;return(o=t.call(this,e,"SYEV",s)||this).allowAutoUnhide=null,o.hidePreviousMessages=null,o.messageOffsetTimestamp=null,s.data&&(o.allowAutoUnhide=null!==(r=s.data.allow_auto_unhide)&&void 0!==r?r:null,o.hidePreviousMessages=null!==(a=s.data.hide_previous_messages)&&void 0!==a?a:null),o.messageOffsetTimestamp=null!==(i=s.ts_message_offset)&&void 0!==i?i:null,o}return e(n,t),n}(L),ss=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),rs=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),as=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(D),is=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(L),os=function(t){function n(e){var n=e.channelUrl,s=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:s}})||this}return e(n,t),n}(D),us=function(t){function a(e,n){var s,r,a,i,o,u,c,l,h,d,_,p,f,v,m,g,E,C,y,M,b,N,U,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.includeChatNotification=!1,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Yt.ALL,S.unreadChannelFilter=Jt.ALL,S.superChannelFilter=Kt.ALL,S.publicChannelFilter=Qt.ALL,S.hiddenChannelFilter=Xt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=St.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,S.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,S.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,S.includeChatNotification=null!==(i=n.includeChatNotification)&&void 0!==i&&i,S.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,S.customTypesFilter=null!==(u=n.customTypesFilter)&&void 0!==u?u:null,S.customTypeStartsWithFilter=null!==(c=n.customTypeStartsWithFilter)&&void 0!==c?c:"",S.nicknameContainsFilter=null!==(l=n.nicknameContainsFilter)&&void 0!==l?l:null,S.nicknameStartsWithFilter=null!==(h=n.nicknameStartsWithFilter)&&void 0!==h?h:null,S.nicknameExactMatchFilter=null!==(d=n.nicknameExactMatchFilter)&&void 0!==d?d:null,S.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Yt.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Jt.ALL,S.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:Kt.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Qt.ALL,S.hiddenChannelFilter=null!==(g=n.hiddenChannelFilter)&&void 0!==g?g:Xt.UNHIDDEN,S.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},S.userIdsFilter=null!==(C=n.userIdsFilter)&&void 0!==C?C:{userIds:[],includeMode:!0,queryType:$t.AND},S.metadataKey=null!==(y=n.metadataKey)&&void 0!==y?y:null,S.metadataValues=null!==(M=n.metadataValues)&&void 0!==M?M:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(N=n.metadataValueStartsWith)&&void 0!==N?N:null,S.order=null!==(U=n.order)&&void 0!==U?U:St.LATEST_LAST_MESSAGE,n.createdAfter&&(S.createdAfter=n.createdAfter),n.createdBefore&&(S.createdBefore=n.createdBefore),S}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&m("string",this.channelUrlsFilter,!0)&&m("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&r(Yt,this.myMemberStateFilter)&&r(Kt,this.superChannelFilter)&&r(Qt,this.publicChannelFilter)&&r(Jt,this.unreadChannelFilter)&&r(Xt,this.hiddenChannelFilter)&&m(en,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&m("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&r($t,this.userIdsFilter.queryType)&&r(St,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&m("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)&&x(this.createdAfter,!0)&&x(this.createdBefore,!0)},a.prototype.serialize=function(){return R(this)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,ps.of(this._iid).getMyGroupChannels(this._token,n(s({},this)),this.limit,y.REQUEST_CHANNEL,!0)]):[3,2]:[3,5];case 1:return e=a.sent(),t=e.channels,r=e.token,this._token=r,this._hasNext=!!r,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(F),cs=function(n){function s(e){var s=e.channelUrl,r=e.userId,a=n.call(this)||this;return a.method=N.PUT,a.path="".concat(I,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=t({userId:r}),a}return e(s,n),s}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var ls,hs=function(t){function n(e,n,s){var r=t.call(this,e,"DLVR",s)||this;return r.channelUrl=s.channel_url,r.deliveredStateUpdate=s.updated,r}return e(n,t),n}(L),ds=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,s=e.bottom,r=void 0===s?0:s;this.top=n,this.bottom=r}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0&&n.onMentionReceived&&n.onMentionReceived(g,_)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=6;case 6:return[3,79];case 7:return U=e.as(Y),me=U.channelUrl,ge=U.channelType,S=U.messageId,T=U.silent,A=U.messageCreatedAt,I=U.senderId,ge!==i.GROUP?[3,9]:[4,this.getChannel(me,!0)];case 8:w=xn.sent(),L=I===this._sdkState.userId,T||L||A>0&&w.myLastRead0&&w._updateUnreadCount(w.unreadMessageCount-1,0),this._dispatcher.dispatch(new Q({messageIds:[S],source:y.EVENT_MESSAGE_DELETED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onMessageDeleted&&n.onMessageDeleted(w,S)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=9;case 9:return[3,79];case 10:return(D=e.as(Be).readStatus).channelType!==i.GROUP?[3,12]:(V=this._groupChannelCache.isCachedInMemory(D.channelUrl),[4,this.getChannel(D.channelUrl,!0)]);case 11:x=xn.sent(),V&&x._updateUnreadMemberState(D.reader.userId,D.readAt),D.reader.userId===this._sdkState.userId?V?(x.unreadMessageCount>0||x.unreadMentionCount>0)&&(x._updateUnreadCount(0,0),this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):0!==x.unreadMessageCount&&0!==x.unreadMentionCount||(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new En({channels:[x],context:{source:y.EVENT_CHANNEL_READ}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUnreadMemberStatusUpdated&&n.onUnreadMemberStatusUpdated(x)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),xn.label=12;case 12:return[3,79];case 13:return R=e.as(hs),me=R.channelUrl,F=R.deliveredStateUpdate,k=void 0===F?{}:F,V=this._groupChannelCache.isCachedInMemory(me),[4,this.getChannel(me,!0)];case 14:return K=xn.sent(),V&&Object.keys(k).forEach((function(e){K._updateUndeliveredMemberState(e,k[e])})),Object.keys(k).some((function(e){return e!==Dn._sdkState.userId}))&&(this._dispatcher.dispatch(new En({channels:[K],context:{source:y.EVENT_CHANNEL_DELIVERED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUndeliveredMemberStatusUpdated&&n.onUndeliveredMemberStatusUpdated(K)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 15:return X=e.as(qt),me=X.channelUrl,ge=X.channelType,Z=X.event,ge!==i.GROUP?[3,18]:[4,this.getChannel(me,!0)];case 16:return $=xn.sent(),[4,this.getMessageFromCache(Z.messageId)];case 17:(ne=xn.sent())?ne instanceof Ge&&(ne.applyReactionEvent(Z),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new W({event:Z,source:y.EVENT_MESSAGE_REACTION_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onReactionUpdated&&n.onReactionUpdated($,Z)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=18;case 18:return[3,79];case 19:return(ee=e.as(Bt).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(ee.channelUrl,!0)];case 20:return te=xn.sent(),[4,this.getMessageFromCache(ee.targetMessageId)];case 21:(ne=xn.sent())?ne instanceof Ge&&(ne.applyThreadInfoUpdateEvent(ee),this._dispatcher.dispatch(new j({messages:[ne],source:y.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new z({event:ee,source:y.EVENT_MESSAGE_THREADINFO_UPDATED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onThreadInfoUpdated&&n.onThreadInfoUpdated(te,ee)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=22;case 22:return[3,79];case 23:se=e.as(Gt).groupChannelMemberCounts,re=[],xn.label=24;case 24:xn.trys.push([24,29,30,31]),ae=v(se),ie=ae.next(),xn.label=25;case 25:return ie.done?[3,28]:(oe=ie.value,me=oe.channelUrl,ct=oe.memberCount,lt=oe.joinedMemberCount,ue=oe.updatedAt,[4,this.getChannelFromCache(me)]);case 26:(ce=xn.sent())&&ce._setLatestMemberCount(ct,lt,ue)&&re.push(ce),xn.label=27;case 27:return ie=ae.next(),[3,25];case 28:return[3,31];case 29:return le=xn.sent(),Nn={error:le},[3,31];case 30:try{ie&&!ie.done&&(Un=ae.return)&&Un.call(ae)}finally{if(Nn)throw Nn.error}return[7];case 31:return re.length>0&&(this._dispatcher.dispatch(new En({channels:re,context:{source:y.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelMemberCountChanged&&n.onChannelMemberCountChanged(re)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 32:return he=e.as(Vt),de=he.event,_e=he.status,me=he.channelUrl,ge=he.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,34];case 33:pe=xn.sent(),this._dispatcher.dispatch(new q({event:de,source:y.EVENT_POLL_UPDATED})),H(_e===J?function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollDeleted&&n.onPollDeleted(pe,de.pollId)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}:function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollUpdated&&n.onPollUpdated(pe,de)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}),xn.label=34;case 34:return[3,79];case 35:return fe=e.as(Ve),ve=fe.event,me=fe.channelUrl,ge=fe.channelType,me&&ge===i.GROUP?[4,this.getChannel(me,!0)]:[3,37];case 36:Ee=xn.sent(),this._dispatcher.dispatch(new B({event:ve,source:y.EVENT_POLL_VOTED})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollVoted&&n.onPollVoted(Ee,ve)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),xn.label=37;case 37:return[3,79];case 38:if(!(Ce=e.as(Ft).event).isGroupChannelEvent)return[3,77];switch(Ce.category){case Ot.CHANNEL_JOIN:return[3,39];case Ot.CHANNEL_LEAVE:return[3,41];case Ot.CHANNEL_OPERATOR_UPDATE:return[3,45];case Ot.CHANNEL_INVITE:return[3,47];case Ot.CHANNEL_DECLINE_INVITE:return[3,49];case Ot.TYPING_START:case Ot.TYPING_END:return[3,51];case Ot.USER_CHANNEL_MUTE:case Ot.USER_CHANNEL_UNMUTE:return[3,53];case Ot.USER_CHANNEL_BAN:return[3,55];case Ot.USER_CHANNEL_UNBAN:return[3,59];case Ot.CHANNEL_FREEZE:case Ot.CHANNEL_UNFREEZE:return[3,61];case Ot.CHANNEL_HIDE:return[3,63];case Ot.CHANNEL_UNHIDE:return[3,65];case Ot.CHANNEL_DELETED:return[3,67];case Ot.CHANNEL_PROP_CHANGED:return[3,69];case Ot.CHANNEL_META_DATA_CHANGED:return[3,71];case Ot.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case Ot.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(Ce.channelUrl,!0)];case 40:return ye=xn.sent(),Me=e.as(jn),be=Me.memberCount,Ne=Me.joinedMemberCount,Ue=Me.members,Se=!1,Ue.forEach((function(e){ye.isExclusive||ye.isSuper||ye.isBroadcast?Se=Se||ye._setLatestMemberCount(be,Ne,Ce.ts):(e.state=Wt.JOINED,ye.addMember(e,Ce.ts),Dn._updateJoinedMemberCount(ye)),e.userId===Dn._sdkState.userId&&(ye.myMemberState=Wt.JOINED)})),this._dispatcher.dispatch(new En({channels:[ye],context:{source:y.EVENT_CHANNEL_JOINED,users:Ue}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var s=v(Ue),r=s.next();!r.done;r=s.next()){var a=r.value;e.onUserJoined&&e.onUserJoined(ye,a)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}ye.isBroadcast&&Se&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,77];case 41:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Ae=Mt.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(Ce.channelUrl,!0)];case 43:Ae=xn.sent(),xn.label=44;case 44:return Te=Ae,Ie=e.as(Qn),ct=Ie.memberCount,lt=Ie.joinedMemberCount,we=Ie.member,Le=!1,De=P.of(this._iid).appInfo,Te.isExclusive||Te.isSuper||Te.isBroadcast?Le=Te._setLatestMemberCount(ct,lt,Ce.ts):((null==De?void 0:De.enabledChannelMemberShipHistory)?((Ye=Te.members.find((function(e){return e.userId===we.userId})))&&(Ye.state=Wt.LEFT),Te.memberCount=ct):Te.removeMember(we),this._updateJoinedMemberCount(Te)),we.userId===this._sdkState.userId?(Te.myMemberState=Wt.NONE,Te.invitedAt=0,Te.joinedAt=0,Te._updateUnreadCount(0,0),Te.isPublic?this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})):(this._markAsLeave(Te),this._dispatcher.dispatch(new Cn({channelUrls:[Te.url],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})))):this._dispatcher.dispatch(new En({channels:[Te],context:{source:y.EVENT_CHANNEL_LEFT,user:we}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(Te,we),Te.isBroadcast&&Le&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Te])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(Ce.channelUrl,!0)];case 46:Ke=xn.sent(),Je=e.as(Ht).operators,Xe=Je.map((function(e){return e.userId}));try{for(Ze=v(Ke.members),$e=Ze.next();!$e.done;$e=Ze.next())(yt=$e.value).role=Xe.includes(yt.userId)?a.OPERATOR:a.NONE}catch(e){Sn={error:e}}finally{try{$e&&!$e.done&&(Tn=Ze.return)&&Tn.call(Ze)}finally{if(Sn)throw Sn.error}}return Ke.myRole=Xe.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new En({channels:[Ke],context:{source:y.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Je}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ke,Je)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(Ce.channelUrl,!0)];case 48:et=xn.sent(),tt=e.as(Jn),ct=tt.memberCount,lt=tt.joinedMemberCount,nt=tt.inviter,(st=tt.invitees).forEach((function(e){return e.state=Wt.INVITED}));try{for(rt=v(st),at=rt.next();!at.done;at=rt.next())it=at.value,et.isExclusive||et.isSuper||et.isBroadcast?et._setLatestMemberCount(ct,lt,Ce.ts):et.addMember(it,Ce.ts),this._sdkState.userId===it.userId&&(et.hiddenState=tr.UNHIDDEN,et.myMemberState!==Wt.JOINED&&(et.myMemberState=Wt.INVITED),et.invitedAt=Ce.ts)}catch(e){An={error:e}}finally{try{at&&!at.done&&(In=rt.return)&&In.call(rt)}finally{if(An)throw An.error}}return this._dispatcher.dispatch(new En({channels:[et],context:{source:y.EVENT_CHANNEL_INVITED,inviter:nt,invitees:st}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(et,nt,st)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(Ce.channelUrl,!0)];case 50:return ot=xn.sent(),ut=e.as(Zn),ct=ut.memberCount,lt=ut.joinedMemberCount,ht=ut.inviter,dt=ut.invitee,ot.isExclusive||ot.isSuper||ot.isBroadcast?ot._setLatestMemberCount(ct,lt,Ce.ts):ot.removeMember(dt),this._sdkState.userId===dt.userId?(ot.invitedAt=0,ot.myMemberState=Wt.NONE,ot.isPublic?this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})):this._dispatcher.dispatch(new Cn({channelUrls:[ot.url],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}}))):this._dispatcher.dispatch(new En({channels:[ot],context:{source:y.EVENT_CHANNEL_DECLINED_INVITE,inviter:ht,invitee:dt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ot,ht,dt)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(Ce.channelUrl,!0)];case 52:return _t=xn.sent(),pt=Ce.category===Ot.TYPING_START,ft=e.as(pt?rs:is).user,_t._updateTypingStatus(ft,pt?Ce.ts:0),this._dispatcher.dispatch(new En({channels:[_t],context:{source:y.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(_t)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(Ce.channelUrl,!0)];case 54:vt=xn.sent(),mt=Ce.category===Ot.USER_CHANNEL_MUTE,(gt=e.as(mt?Oe:He).user).userId===this._sdkState.userId&&(vt.myMutedState=mt?G.MUTED:G.UNMUTED,vt._myMutedRemainingTime=gt.restrictionInfo.remainingDuration);try{for(Et=v(vt.members),Ct=Et.next();!Ct.done;Ct=Et.next())if((yt=Ct.value).userId===gt.userId){yt.isMuted=mt;break}}catch(e){wn={error:e}}finally{try{Ct&&!Ct.done&&(Ln=Et.return)&&Ln.call(Et)}finally{if(wn)throw wn.error}}return this._dispatcher.dispatch(new En({channels:[vt],context:{source:mt?y.EVENT_CHANNEL_MUTED:y.EVENT_CHANNEL_UNMUTED,user:gt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){mt?e.onUserMuted&&e.onUserMuted(vt,gt):e.onUserUnmuted&&e.onUserUnmuted(vt,gt)})),[2]}))}))})),[3,77];case 55:return(Mt=this._leftChannels.get(Ce.channelUrl))?(Nt=Mt.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(Ce.channelUrl,!0)];case 57:Nt=xn.sent(),xn.label=58;case 58:return bt=Nt,this._markAsLeave(bt),Ut=e.as(ke).user,Ut.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[bt.url],context:{source:y.EVENT_CHANNEL_BANNED,user:Ut}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(bt,Ut)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(Ce.channelUrl,!0)];case 60:return St=xn.sent(),Tt=e.as(Pe).user,Tt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Cn({channelUrls:[St.url],context:{source:y.EVENT_CHANNEL_UNBANNED,user:Tt}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(St,Tt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(Ce.channelUrl,!0)];case 62:return At=xn.sent(),It=e.as(Fe).freeze,At.isFrozen=It,this._dispatcher.dispatch(new En({channels:[At],context:{source:It?y.EVENT_CHANNEL_FROZEN:y.EVENT_CHANNEL_UNFROZEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){It?e.onChannelFrozen&&e.onChannelFrozen(At):e.onChannelUnfrozen&&e.onChannelUnfrozen(At)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(Ce.channelUrl,!0)];case 64:return wt=xn.sent(),Rt=e.as(ns),Pt=Rt.allowAutoUnhide,Qt=Rt.hidePreviousMessages,Yt=Rt.messageOffsetTimestamp,null!==Pt&&(wt.hiddenState=Pt?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Qt&&Qt&&wt._updateUnreadCount(0,0),null!==Yt&&(wt.messageOffsetTimestamp=Yt),this._dispatcher.dispatch(new En({channels:[wt],context:{source:y.EVENT_CHANNEL_HIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(wt)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(Ce.channelUrl,!0)];case 66:return(Kt=xn.sent()).hiddenState=tr.UNHIDDEN,this._dispatcher.dispatch(new En({channels:[Kt],context:{source:y.EVENT_CHANNEL_UNHIDDEN}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Kt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(Ce.channelUrl,!0)];case 68:return Jt=xn.sent(),this._dispatcher.dispatch(new Cn({channelUrls:[Ce.channelUrl],context:{source:y.EVENT_CHANNEL_DELETED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Jt.url,Jt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(Ce.channelUrl,!0)];case 70:return Xt=xn.sent(),this._dispatcher.dispatch(new En({channels:[Xt],context:{source:y.EVENT_CHANNEL_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Xt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(Ce.channelUrl,!0)];case 72:return Zt=xn.sent(),$t=e.as(Re),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&(Zt._upsertCachedMetaData(en,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_CREATED,metaData:en},ts:Ce.ts}))),tn&&(Zt._upsertCachedMetaData(tn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_UPDATED,metaData:tn},ts:Ce.ts}))),nn&&(Zt._removeFromCachedMetaData(nn,Ce.ts),this._dispatcher.dispatch(new En({channels:[Zt],context:{source:y.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:nn},ts:Ce.ts}))),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){en&&e.onMetaDataCreated&&e.onMetaDataCreated(Zt,en),tn&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Zt,tn),nn&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Zt,nn)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(Ce.channelUrl,!0)];case 74:return sn=xn.sent(),rn=e.as(xe),an=rn.created,on=rn.updated,un=rn.deleted,an&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:an}})),on&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:on}})),un&&this._dispatcher.dispatch(new En({channels:[sn],context:{source:y.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:un}})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){an&&e.onMetaCounterCreated&&e.onMetaCounterCreated(sn,an),on&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(sn,on),un&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(sn,un)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(Ce.channelUrl,!0)];case 76:return cn=xn.sent(),ln=e.as(kt),hn=ln.pinnedMessageIds,dn=ln.latestPinnedMessage,(_n=ln.ts)>cn._pinnedMessagesUpdatedAt&&(cn.pinnedMessageIds=null!=hn?hn:[],cn.lastPinnedMessage=dn,cn._pinnedMessagesUpdatedAt=_n,this._dispatcher.dispatch(new En({channels:[cn],context:{source:y.EVENT_PINNED_MESSAGE_UPDATED}})),H((function(){return p(Dn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(cn)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),H((function(){return p(Dn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(cn)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((pn=e.as(Lt).event).category){case Dt.USER_BLOCK:fn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=fn.blocker,gn=fn.blockee,this._groupChannelCache.block(mn.userId,gn.userId);break;case Dt.USER_UNBLOCK:vn=xt.getDataAsUserBlockEvent(this._iid,pn),mn=vn.blocker,gn=vn.blockee,this._groupChannelCache.unblock(mn.userId,gn.userId)}return[3,79];case 79:return[3,81];case 80:if(yn=xn.sent(),O(yn))throw yn;return[3,81];case 81:return[2]}}))}))},u.prototype._markAsLeave=function(e){var t,n=this,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((function(){s.ref--,0===s.ref&&n._leftChannels.delete(e.url)}),1e4)},u.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},u.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},u.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},u.prototype.subscribeChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},u.prototype.unsubscribeChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},u.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===Wt.JOINED})).length},u.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n;return f(this,(function(s){switch(s.label){case 0:l(g("string",e)).throw(h.invalidParameters),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=s.sent())?[2,n]:[3,4];case 3:return s.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,s.sent()]}}))}))},u.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return l(g("string",e)).throw(h.invalidParameters),n=new Nn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(s=o.sent(),r=s.as(Un).channel,a=r.unreadMessageCount,i=r.unreadMentionCount,r.myCountPreference){case er.UNREAD_MESSAGE_COUNT_ONLY:i=0;break;case er.UNREAD_MENTION_COUNT_ONLY:a=0;break;case er.OFF:a=0,i=0}return r._updateUnreadCount(a,i),[4,this.upsertChannelsToCache([r])];case 2:return[2,o.sent()[0]]}}))}))},u.prototype.refreshChannel=function(e,t,n,s){return void 0===t&&(t=!0),void 0===n&&(n=y.REFRESH_CHANNEL),void 0===s&&(s=!1),p(this,void 0,void 0,(function(){var r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Nn({channelUrl:e,isInternalCall:t,showLatestMessage:s}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Un).channel).myMemberState!==Wt.NONE?[3,2]:(this._dispatcher.dispatch(new Cn({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new En({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(u=c.sent()).code!==K.NON_AUTHORIZED&&u.code!==K.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Cn({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},u.prototype.getMyGroupChannels=function(e,t,n,r,a){return void 0===r&&(r=y.REQUEST_CHANNEL),void 0===a&&(a=!1),p(this,void 0,void 0,(function(){var i,o,u,c,l,h,d,_,p;return f(this,(function(f){switch(f.label){case 0:return t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3)),i=!1,a&&(o=P.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(i=!0)),l=new Tn(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n,includeLeftChannel:a&&i})),[4,this._requestQueue.send(l)];case 1:return h=f.sent(),d=h.as(An),_=d.channels,p=d.token,this._dispatcher.dispatch(new En({channels:_,context:{source:r}})),[2,{channels:_,token:p}]}}))}))},u.prototype.getMyGroupChannelChangeLogs=function(e,t,r){return void 0===r&&(r=y.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var a,i,o,u,c,d,_,p;return f(this,(function(f){switch(f.label){case 0:return a=s(s({},cn),t),l((g("string",e)||g("number",e))&&ln(a)).throw(h.invalidParameters),i=new Mn(n({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:a})),[4,this._requestQueue.send(i)];case 1:return o=f.sent(),u=o.as(bn),c=u.updatedChannels,d=u.deletedChannelUrls,_=u.hasMore,p=u.ts,c.length>0&&this._dispatcher.dispatch(new En({channels:c,context:{source:r},ts:p})),d.length>0&&this._dispatcher.dispatch(new Cn({channelUrls:d,context:{source:r}})),[2,{updatedChannels:c,deletedChannelUrls:d,hasMore:_,token:u.token}]}}))}))},u.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(a){switch(a.label){case 0:return t=s(s({},hn),e),l(dn(t)).throw(h.invalidParameters),n=new In({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),[2,r.as(wn).groupChannelCount]}}))}))},u.prototype.getUnreadItemCount=function(e){return p(this,void 0,void 0,(function(){var n,r,a,i,o,u,c,d,_,p,v,g,E,C,y,M;return f(this,(function(f){switch(f.label){case 0:return n=s(s({},_n),e),l(function(e){return m(sn,e.keys)&&m("string",e.customTypeFilters,!0)&&m("string",e.customTypesFilter,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid),a=r.sdkState,i=r.requestQueue,o=new Ln({userId:a.userId,filter:n}),[4,i.send(o)];case 1:return u=f.sent(),c=u.as(Dn),d=c.groupChannelUnreadMentionCount,_=c.groupChannelUnreadMessageCount,p=c.groupChannelInvitationCount,v=c.superGroupChannelUnreadMentionCount,g=c.superGroupChannelUnreadMessageCount,E=c.superGroupChannelInvitationCount,C=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,M=c.nonSuperGroupChannelInvitationCount,[2,t({groupChannelUnreadMentionCount:d,groupChannelUnreadMessageCount:_,groupChannelInvitationCount:p,superGroupChannelUnreadMentionCount:v,superGroupChannelUnreadMessageCount:g,superGroupChannelInvitationCount:E,nonSuperGroupChannelUnreadMentionCount:C,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:M})]}}))}))},u.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new xn({userId:t.userId}),[4,n.send(s)];case 1:return r=a.sent(),[2,r.as(Rn).unreadCount]}}))}))},u.prototype.getTotalUnreadMessageCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return t=s(s({},pn),e),l(fn(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Fn({userId:r.userId,filter:t}),[4,a.send(i)];case 1:return o=u.sent(),[2,o.as(Pn).unreadCount]}}))}))},u.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,a,i;return f(this,(function(o){switch(o.label){case 0:return t=s(s({},vn),e),l(function(e){return g("string",e.channelUrl,!0)&&m(Me,e.scheduledStatus,!0)&&r(C,e.messageTypeFilter)}(t)).throw(h.invalidParameters),n=P.of(this._iid).requestQueue,a=new kn(t),[4,n.send(a)];case 1:return i=o.sent(),[2,i.as(On).count]}}))}))},u.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=P.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},u.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=P.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e},u.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=P.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},u.prototype.createChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a;return f(this,(function(i){switch(i.label){case 0:return t=s(s({},on),e),l(un(t)).throw(h.invalidParameters),t.isPublic||(t.accessCode=void 0),n=new Vn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),a=r.as(Gn).channel,[4,this.upsertChannelsToCache([a])];case 2:return i.sent(),[2,a]}}))}))},u.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return e=Date.now(),l(e-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Bn({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(s=v(n),r=s.next();!r.done;r=s.next())(a=r.value)._updateUnreadMemberState(this._sdkState.userId,e),a._updateUnreadCount(0,0)}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},u.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=Date.now(),l(m("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Bn({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:d.sent(),s=this._groupChannelCache.channels,r=[];try{for(a=v(s),i=a.next();!i.done;i=a.next())o=i.value,e.includes(o.url)&&(o._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0),r.push(o))}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=a.return)&&c.call(a)}finally{if(u)throw u.error}}return r.length>0?[4,this.upsertChannelsToCache(r)]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2]}}))}))},u.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},u.prototype.getMessageFromCache=function(e){var t;return p(this,void 0,void 0,(function(){return f(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]}}))}))},u.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return p(this,void 0,void 0,(function(){return f(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,s.sent()]}}))}))},u.prototype.getMessagesFromCache=function(e,t,n,s,r,a){return void 0===r&&(r=Ye),void 0===a&&(a=!0),p(this,void 0,void 0,(function(){return f(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:s,backward:"next"===n,inclusive:a})];case 1:return[2,i.sent()]}}))}))},u.prototype.getPollMessagesFromCache=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,r.sent()]}}))}))},u.prototype.getCachedMessageCountBetween=function(e,t,n,s){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.countBetween(e,t,new ds({top:n,bottom:s}))];case 1:return[2,r.sent()]}}))}))},u.prototype.getUnsentMessagesFromCache=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},u.prototype.removeFailedMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},u}(Pt),fs=function(e,t){return t instanceof qe?e.findIndex((function(e){return e instanceof qe&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vs=function(e,t){return e.findIndex((function(e){return e instanceof Ge?e.messageId===t:e instanceof Ke?e.notificationId===t:void 0}))},ms=function(e,t){if(e.length>0){for(var n=0,s=e.length-1,r=Math.floor((n+s)/2);n0)s=r,r=Math.floor((n+s)/2);else{if(!(a<0))return r;n=r+1,r=Math.floor((n+s)/2)}}return e[r].createdAt>t.createdAt?r:r+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(ls||(ls={}));var gs,Es=function(t){function n(e,n,s,r){var a=t.call(this)||this;return a._state=ls.IDLE,a._retryCount=0,a._retryLimit=3,a.priority=0,a._worker=n,a}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===ls.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===ls.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===ls.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(s){switch(s.label){case 0:if(!this.isRunning)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=s.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=s.sent(),this.dispatch("error",n),this._retryCount0&&(r=s.map((function(e){return e.createdAt})),(null===(v=this._metadata)||void 0===v?void 0:(i=v.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.length0&&(r=s.map((function(e){return e.createdAt})),(null===(h=this._metadata)||void 0===h?void 0:(i=h.range).intersect.apply(i,d([],_(r),!1)))?this.extendRange(s):this._metadata={range:new ds({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=s.length>=this._limit,this._metadata&&(t.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return f.sent(),[3,7];case 5:throw a=f.sent(),m.debug("message background next sync error",a),a;case 6:return g.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:n.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(v=null===(p=l.localCacheConfig)||void 0===p?void 0:p.maxSize)&&void 0!==v?v:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[2,t]}}))}))}))];case 1:return[2,s.sent()]}}))}))})),this._connectionEventContext=v.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n){return Cs[t]||(Cs[t]={}),Cs[t][n.url]||(Cs[t][n.url]=new e({_iid:t,channel:n})),Cs[t][n.url].ref++,Cs[t][n.url]},e.clear=function(e,t){Cs[e]&&Cs[e][t]&&(Cs[e][t].close(),delete Cs[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 ds({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{range:new ds(e.range),previousComplete:e.previousComplete}:{range:new ds({}),previousComplete:!1},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(e){var t,n,s,r;void 0===e&&(e=Date.now());var a=P.of(this._iid),i=a.logger,o=a.sessionManager;a.cacheContext.localCacheEnabled&&o.session.hasSession&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.range.top)&&void 0!==n?n:e),this._nextSync.start(null!==(r=null===(s=this._metadata)||void 0===s?void 0:s.range.bottom)&&void 0!==r?r:e))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Cs[this._iid][this._channel.url])},e}(),Ms={},bs=function(){function e(e){var t=e._iid,n=e.channel,r=e.includeParams,a=this;this.ref=0,this._iid=t,this._channel=n,this._includeParams=r;var i,o,u=P.of(this._iid),c=u.logger,l=u.sdkState,d=u.dispatcher;this._metadataKey=(i=l.userId,o=n.url,"sendbird:".concat(i,"@groupchannel/").concat(o,"/message/changelogs.meta"));var _=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(l.userId,this._channel.url);this._sync=new Es(_,(function(){return p(a,void 0,void 0,(function(){var e,t,n,r,a,i,o,u;return f(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:l.sent(),c.debug("message changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),l.label=2;case 2:return l.trys.push([2,5,,8]),[4,Je.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,s({replyType:ne.ALL},this._includeParams),y.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=l.sent(),n=t.updatedMessages,r=t.deletedMessageIds,a=t.hasMore,i=t.token,e.hasNext=a,e.nextToken=i,(n.length>0||r.length>0)&&this._metadata&&(this._metadata.token=i),c.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return l.sent(),[3,8];case 5:return o=l.sent(),c.debug("message changelog sync error",o),o instanceof h&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:l.sent(),l.label=7;case 7:throw o;case 8:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof Z)if(e.stateType===$.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n,s){return Ms[t]||(Ms[t]={}),Ms[t][n.url]||(Ms[t][n.url]=new e({_iid:t,channel:n,includeParams:s})),Ms[t][n.url].ref++,Ms[t][n.url]},e.clear=function(e,t){Ms[e]&&Ms[e][t]&&(Ms[e][t].close(),delete Ms[e])},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=P.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:s=r.sent(),this._metadata={token:s?s.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e=P.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){P.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Ms[this._iid][this._channel.url])},e}(),Ns={},Us=function(){function e(e){var t=e._iid,n=e.channel,s=e.hasPollMessage,r=this;this.ref=0,this._iid=t,this._channel=n;var a,i,o=P.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(a=c.userId,i=n.url,"sendbird:".concat(a,"@groupchannel/").concat(i,"/poll/changelogs.meta"));var d=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new Es(d,(function(){return p(r,void 0,void 0,(function(){var e,t,n,r,a,i,o,c;return f(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,s()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=P.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,se.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return r=l.sent(),a=r.hasMore,i=r.token,e.hasNext=a,e.nextToken=i,this._metadata.token=i,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 h&&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 Z)if(e.stateType===$.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n,s){return Ns[t]||(Ns[t]={}),Ns[t][n.url]||(Ns[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:s})),Ns[t][n.url].ref++,Ns[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,P.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 p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,P.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,P.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){P.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){P.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 Ns[this._iid][this._channel.url])},e}(),Ss=function(n){function s(e){var s,r,a,i,o,u,c,l,h,d,_=this;return(_=n.call(this)||this).method=N.GET,_.path="".concat(re(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),_.params=t({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!==(r=e.customTypes)&&void 0!==r?r:["*"],message_type:null!==(a=e.messageType)&&void 0!==a?a:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:ne.NONE,include_reactions:null===(o=e.includeReactions)||void 0===o||o,include_meta_array:null===(u=e.includeMetaArray)||void 0===u||u,include_thread_info:null===(c=e.includeThreadInfo)||void 0===c||c,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(d=e.showSubchannelMessagesOnly)&&void 0!==d&&d,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),_}return e(s,n),s}(S),Ts=function(t){function n(e,n){var s,r,a,i,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(s=n.prev_messages)&&void 0!==s?s:[]).map((function(t){return Xe(e,t)})),c.prevHasMore=null!==(r=n.prev_hasmore)&&void 0!==r&&r,c.isContinuousPrevMessages=null!==(a=n.is_continuous_prev_messages)&&void 0!==a&&a,c.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return Xe(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}(T),As={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(gs||(gs={}));var Is,ws,Ls,Ds=function(){function e(){this._onCacheResult=ue,this._onApiResult=ue}return e.prototype._invokeResponse=function(e,t,n){var s=this;H((function(){return p(s,void 0,void 0,(function(){return f(this,(function(s){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}(),xs=function(){function e(e,t){var n=t.filter,s=t.startingPoint,r=t.limit,a=t.prevResultLimit,i=t.nextResultLimit,o=t.channel,u=t.channelManager,c=t.disableBackgroundSync,l=void 0!==c&&c,h=this;this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=e,this._key="mc-".concat(oe()),this._isDisposed=!1,this.filter=null!=n?n:new Le,this._channel=o,this._syncRange=new ds({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER,this._limit=r||Ye,this._prevResultLimit=null!=a?a:Math.floor(this._limit/2),this._nextResultLimit=null!=i?i:Math.floor(this._limit/2),this._channelManager=u;var m=P.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source,s=e.findIndex((function(e){return e.isIdentical(h.channel)}));s>=0&&(h._replaceChannelOfCollection(e[s]),h.channel._runIfHandleableWithGroupChannel((function(e){switch(n){case y.EVENT_CHANNEL_UPDATED:for(var s=!1,r=0;r=e.messageOffsetTimestamp){s=!0;var a=r;if(a>0){var i=h._messages.splice(0,a);h._removeMessagesFromView(i.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&h._messages.length>0&&h._removeMessagesFromView(h._messages.map((function(e){return h.keyOf(e)})),y.EVENT_MESSAGE_OFFSET_UPDATED);break;case y.EVENT_CHANNEL_UNMUTED:var o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&h._clearCheckMyMutedTimer();break;case y.EVENT_CHANNEL_MUTED:o=P.of(h._iid).sdkState,u=t.user;o.userId===u.userId&&-1!==e._myMutedRemainingTime&&h._startCheckMyMutedTimer(e._myMutedRemainingTime);break;case y.EVENT_CHANNEL_LEFT:e.isPublic&&h._clearCheckMyMutedTimer()}H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(s){return gn(n)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(t,this.channel),[2]}))}))}))})),h._postprocessChannelUpdateEvent(e[s],n))},onRemove:function(e,t){var n=e.indexOf(h.channel.url);n>=0&&(h._clearCheckMyMutedTimer(),H((function(){return p(h,void 0,void 0,(function(){var e;return f(this,(function(n){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url),[2]}))}))})),h._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,s,r=[],a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value;u.channelUrl===h._channel.url&&(h.filter.match(u)?r.push(u):a.push(h.keyOf(u)))}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}if(ie(t)){if(r.length>0)switch(t){case y.LOCAL_MESSAGE_CANCELED:case y.LOCAL_MESSAGE_RESEND_STARTED:case y.EVENT_MESSAGE_SENT_FAILED:case y.EVENT_MESSAGE_SENT_SUCCESS:case y.EVENT_MESSAGE_UPDATED:case y.EVENT_MESSAGE_THREADINFO_UPDATED:case y.EVENT_MESSAGE_REACTION_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_ADDED:case y.EVENT_MESSAGE_FEEDBACK_UPDATED:case y.EVENT_MESSAGE_FEEDBACK_DELETED:case y.SYNC_MESSAGE_CHANGELOGS:h._updateMessagesToView(r,t);break;case y.EVENT_MESSAGE_SENT_PENDING:h._addMessagesToView(r,t);break;case y.EVENT_MESSAGE_RECEIVED:h.hasNext||h._addMessagesToView(r,t);break;case y.SYNC_MESSAGE_FILL:h._addMessagesToView(r,t)}a.length>0&&h._removeMessagesFromView(a,t)}h._postprocessMessageUpdateEvent(e,t)},onRemove:function(e,t){h._removeMessagesFromView(e,t),h._postprocessMessageRemoveEvent(e)},onRemoveUnsent:function(e,t){h._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){h._updatePollsToView(e,t)},onPollUpdate:function(e,t){h._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){h._applyPollVoteEventToView(e,t)},onReactionUpdate:function(e,t){h._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){h._applyThreadInfoEventToView(e,t)}});var g=P.of(this._iid),E=g.cacheContext,C=g.dispatcher,M=g.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),C.dispatch(new En({channels:[this._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=ys.of(this._iid,this._channel),!l&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=bs.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Us.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Es(this._key,(function(e){return p(h,void 0,void 0,(function(){var t=this;return f(this,(function(n){switch(n.label){case 0:return[4,M.run("message-fill-sync-".concat(o.url,"-prev"),(function(){return p(t,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._prevResultLimit,source:y.SYNC_MESSAGE_FILL,checkingContinuousMessages:E.localCacheEnabled})];case 1:return t=u.sent(),n=t.messages,s=t.isContinuousMessages,n.length>0?(r=Math.min.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:n.length>=this._prevResultLimit&&this.viewTop0?(r=Math.max.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:!(n.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>r,nextToken:this._syncRange.bottom}]):(E.localCacheEnabled&&m.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(o=null===(i=E.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==o?o:0,use_local_cache:E.localCacheEnabled,starting_point:0,message_init_policy:""}})),[2,{hasNext:!1,nextToken:0}])}}))}))}))];case 1:return[2,n.sent()]}}))}))})),this._connectionEventContext=C.on((function(e){if(e instanceof Z)switch(e.stateType){case $.CONNECTED:b((function(){return p(h,void 0,void 0,(function(){return f(this,(function(e){return this._activate(),[2]}))}))}));break;case $.LOGOUT:h.dispose();break;default:h._clearCheckMyMutedTimer(),h._prevFill.stop(),h._nextFill.stop()}}))}return e.prototype.keyOf=function(e){return 0},Object.defineProperty(e.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),e.prototype._postprocessChannelUpdateEvent=function(e,t){},e.prototype._postprocessChannelRemoveEvent=function(e){},e.prototype._postprocessMessageUpdateEvent=function(e,t){},e.prototype._postprocessMessageRemoveEvent=function(e){},Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],_(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ae.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype._activate=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return P.of(this._iid).logger.debug("check huge gap"),this._checkHugeGap(),[4,this._refreshChannel(y.SYNC_CHANNEL_CHANGELOGS)];case 1:return e.sent(),[2]}}))}))},e.prototype._replaceChannelOfCollection=function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)},e.prototype._shouldStartBackgroundSync=function(){var e=P.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled},e.prototype._setBaseMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n instanceof Ge&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,s,r=this,a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value,c=vs(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l.isUserMessage()&&l.applyPoll(u),a.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}return a.length>0&&ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},a.length>0&&(null===(s=(n=this._handler).onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,a)),[2]}))}))})),a},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollUpdateEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollVoteEvent(e)&&ie(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyReactionEventToView=function(e,t){var n=this,s=vs(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyReactionEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._applyThreadInfoEventToView=function(e,t){var n=this,s=vs(this._messages,e.targetMessageId);if(s>=0){var r=this._messages[s];r&&(r.isUserMessage()||r.isFileMessage()||r.isMultipleFilesMessage())&&ie(t)&&(r.applyThreadInfoUpdateEvent(e),H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))})))}},e.prototype._removeMessagesFromView=function(e,t){var n,s,r=this,a=[],i=[],o=function(e){var t=u._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var n=u._messages[t];a.push(u.keyOf(n)),i.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=v(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(n)throw n.error}}return ie(t)&&i.length>0&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e={source:t},null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===s||s.call(n,e,this.channel,a,i),[2]}))}))})),a},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,s=void 0===n?0:n,r=t.nextLimit,a=void 0===r?0:r,i=t.inclusive,o=void 0===i||i;return p(this,void 0,void 0,(function(){var t,n,r,i,u;return f(this,(function(c){switch(c.label){case 0:return t=[],o?[4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter)]:[3,2];case 1:t=c.sent(),c.label=2;case 2:return s>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,s,!1)]:[3,4];case 3:return r=c.sent(),[3,5];case 4:r=[],c.label=5;case 5:return n=r,a>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,a,!1)]:[3,7];case 6:return u=c.sent(),[3,8];case 7:u=[],c.label=8;case 8:return i=u,[2,{messages:d(d(d([],_(t),!1),_(n),!1),_(i),!1).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:n.length,nextMessagesCount:i.length}]}}))}))},e.prototype._getRemoteMessages=function(e,t){var r=t.prevLimit,a=void 0===r?0:r,i=t.nextLimit,o=void 0===i?0:i,u=t.source,c=void 0===u?y.REQUEST_MESSAGE:u,l=t.reverse,h=void 0!==l&&l,d=t.checkingHasNext,_=void 0!==d&&d,v=t.checkingContinuousMessages,m=void 0!==v&&v;return p(this,void 0,void 0,(function(){var t,r;return f(this,(function(i){switch(i.label){case 0:return t=Je.of(this._iid),a>0||o>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,n(s(s(s({},this.filter),As),{isInclusive:!0,reverse:h,prevResultSize:a,nextResultSize:o})),c,_,m)]:[3,2];case 1:return r=i.sent(),[3,3];case 2:r={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,r]}}))}))},e.prototype._checkHugeGap=function(){var e,t,n,r,a;return p(this,void 0,void 0,(function(){var i,o,u,c,l,v,m,g,E,C,M,b,N,U,S,T,A,I,w,L,D,x,R,F,k,O=this;return f(this,(function(V){switch(V.label){case 0:return i=P.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=i.cacheContext,l=i.statManager,v=i.logger,this._messages.length>0?(m=this._syncRange.top,g=this.viewTop,E=this._syncRange.bottom,C=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,g,m)]):[3,8];case 1:return M=V.sent(),[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,E,C)];case 2:b=V.sent(),V.label=3;case 3:return V.trys.push([3,5,6,7]),[4,ce((function(){return p(O,void 0,void 0,(function(){var e,t,n,r,a,i,l,h,v,N,U,S,T,A,I,w,L,D=this;return f(this,(function(x){switch(x.label){case 0:return e=new Ss(s(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:g,prevEnd:m,prevCount:M,nextStart:E,nextEnd:C,nextCount:b,checkingContinuousMessages:c.localCacheEnabled},this.filter),As)),[4,u.send(e)];case 1:return t=x.sent(),n=t.as(Ts),r=n.isHugeGap,a=n.prevMessages,i=void 0===a?[]:a,l=n.prevHasMore,h=n.isContinuousPrevMessages,v=n.nextMessages,N=void 0===v?[]:v,U=n.nextHasmore,S=n.isContinuousNextMessages,r?H((function(){return p(D,void 0,void 0,(function(){var e;return f(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected(),[2]}))}))})):(T=this.viewTop,A=this.viewBottom,I=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,T],_(i.map((function(e){return e.createdAt}))),!1)),w=Math.max.apply(Math,d([0,A],_(N.map((function(e){return e.createdAt}))),!1)),o.dispatch(new j({messages:i,source:y.SYNC_MESSAGE_FILL})),o.dispatch(new j({messages:N,source:y.SYNC_MESSAGE_FILL})),this._syncRange.extends(I,w),(h||S)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(I,w)),l&&this._prevFill.start(I),U&&this._nextFill.start(w)),[2]}}))}))}),1)];case 4:return V.sent(),[3,7];case 5:return N=V.sent(),v.debug("Failed HugeGap Check ",N),[3,7];case 6:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=c.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[3,13];case 8:U=Date.now(),V.label=9;case 9:return V.trys.push([9,11,12,13]),[4,this._getRemoteMessages(U,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:y.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:c.localCacheEnabled})];case 10:if(S=V.sent(),T=S.messages,A=S.isContinuousMessages,I=S.hasNext,T.length>0){for(w=T.map((function(e){return e.createdAt})),L=0,D=0,x=0;x=U&&D++;this._hasPrevious=L>=this._prevResultLimit,this._hasNext=null!=I?I:D>=this._nextResultLimit,(k=this._syncRange).extends.apply(k,d([],_(w),!1)),A&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(T,y.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,13];case 11:return(F=V.sent())instanceof h&&F.code===K.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,13];case 12:return c.localCacheEnabled&&l.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(a=null===(r=c.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:c.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 13:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return e=this,[4,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return e._unsentMessages=t.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s;return f(this,(function(r){switch(r.label){case 0:n=P.of(this._iid).logger,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._channelManager.refreshChannel(this.channel.url,!0,e,t)];case 2:return r.sent(),[3,4];case 3:return s=r.sent(),n.warn("Failed to refresh channel",s),[3,4];case 4:return[2]}}))}))},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return p(t,void 0,void 0,(function(){var e,t,n,s=this;return f(this,(function(r){switch(r.label){case 0:this._checkMyMutedStateTimer=void 0,e=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=r.sent(),e=!t.isMuted,[3,5];case 3:return r.sent(),e=!0,[3,5];case 4:return e&&(n=P.of(this._iid).sessionManager,this.channel._runIfHandleableWithGroupChannel((function(e){var t,r;e.myMutedState=G.UNMUTED;var a={source:y.EVENT_CHANNEL_UNMUTED,user:n.currentUser};null===(r=null===(t=s._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===r||r.call(t,a,s.channel)}))),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)},e.prototype._setHasNextAndHasPrevious=function(e,t){for(var n=e.map((function(e){return e.createdAt})),s=0,r=0,a=0;athis._startingPoint&&r++}this._hasPrevious=s>=this._prevResultLimit,this._hasNext=null!=t?t:r>=this._nextResultLimit},e.prototype.initialize=function(e){var t=this,n=new Ds;this._messages=[],this._unsentMessages=[],this._syncRange=new ds({}),this._hasNext=!0,this._hasPrevious=!0;var s=[],r={messages:[],prevMessagesCount:0,nextMessagesCount:0};return H((function(){return p(t,void 0,void 0,(function(){var t,a,i,o,u,c=this;return f(this,(function(l){switch(l.label){case 0:return[4,null===(u=this._backgroundSync)||void 0===u?void 0:u.loadMetadata()];case 1:if(t=l.sent(),a=P.of(this._iid),i=a.cacheContext,o=a.statManager,e===gs.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(e){return p(c,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return r=e,s=this._filterUnderOffsetMessage(r.messages),this._addMessagesToView(s,y.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return t.sent(),n._invokeResponse("local",null,s),[2]}}))}))})).catch((function(e){if(O(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){return p(c,void 0,void 0,(function(){var a,i,u,c,l,h,p,v=this;return f(this,(function(f){switch(f.label){case 0:return a=P.of(this._iid).cacheContext,i=!0,u=!0,c=!1,a.localCacheEnabled&&s.length>0&&(l=t.range).includes.apply(l,d([],_(s.map((function(e){return e.createdAt}))),!1))&&(!t.previousComplete&&r.prevMessagesCountt.range.bottom||r.nextMessagesCount=e._latestMessageInfo.createdAt&&(u=!1)})),u?(i=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:a.localCacheEnabled}).then((function(e){var t,s,r,a=e.messages,i=e.isContinuousMessages,o=e.hasNext,u=v._filterUnderOffsetMessage(a);v._messages=[],u.length>0?(v._setHasNextAndHasPrevious(u,o),(t=v._syncRange).extends.apply(t,d([],_(u.map((function(e){return e.createdAt}))),!1)),i&&(null===(s=v._backgroundSync)||void 0===s?void 0:s.range.overlap(v._syncRange))&&(null===(r=v._backgroundSync)||void 0===r||r.range.extends(v._syncRange.top,v._syncRange.bottom)),v._addMessagesToView(u,y.REQUEST_MESSAGE)):(v._hasPrevious=!1,v._hasNext=!1),n._invokeResponse("remote",null,u)})).catch((function(e){if(O(e))throw e;n._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(s),n._invokeResponse("remote",null,s)),a.localCacheEnabled&&o.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:i?"cache_hit":"cache_miss",max_db_size:null!==(p=null===(h=a.localCacheConfig)||void 0===h?void 0:h.maxSize)&&void 0!==p?p:0,message_init_policy:e,use_local_cache:a.localCacheEnabled,collection_id:this._key}})),[2]}}))}))}));return o.put(new le({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e,message:!0}}})),[2]}}))}))})),n},e.prototype.loadPrevious=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasPrevious?this._isLoadingPrevious?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingPrevious=!0,o=this.viewTop,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{prevLimit:this._prevResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._prevResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h=this;return f(this,(function(p){switch(p.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=p.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top))),u=u.filter((function(e){return fs(h._messages,e)<0})),this._hasPrevious=u.length>=this._prevResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(c=null===(i=e.localCacheConfig)||void 0===i?void 0:i.maxSize)&&void 0!==c?c:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=u.length>=this._prevResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingPrevious=!1,[2,u]}}))}))},e.prototype.loadNext=function(){var e,t,n;return p(this,void 0,void 0,(function(){var s,r,a,i,o,u,c,l,v=this;return f(this,(function(m){switch(m.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return s=P.of(this._iid),r=s.cacheContext,a=s.statManager,i=s.logger,this._hasNext?this._isLoadingNext?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingNext=!0,o=this.viewBottom,u=[],[4,b((function(){return p(v,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalMessages(o,{nextLimit:this._nextResultLimit,inclusive:!1})];case 1:return e=t.sent(),u=this._filterUnderOffsetMessage(e.messages),[2]}}))}))}))]):[2,[]];case 1:return m.sent(),c=u.length>=this._nextResultLimit,r.localCacheEnabled&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:c?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=r.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:r.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),c&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(u))?[3,3]:(l=!1,[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,n,s,r,i,c,h,p=this;return f(this,(function(f){switch(f.label){case 0:return e=P.of(this._iid).cacheContext,[4,this._getRemoteMessages(o,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:e.localCacheEnabled})];case 1:return t=f.sent(),(u=this._filterUnderOffsetMessage(t.messages)).length>0&&((n=this._syncRange).extends.apply(n,d([],_(u.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&t.isContinuousMessages&&(l=!0,null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom))),u=u.filter((function(e){return fs(p._messages,e)<0})),this._hasNext=null!==(i=t.hasNext)&&void 0!==i?i:u.length>=this._nextResultLimit,l&&a.put(new ee({type:te.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(h=null===(c=e.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==h?h:0,use_local_cache:e.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}}))}))}))]);case 2:return m.sent(),this._addMessagesToView(u,y.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=u.length>=this._nextResultLimit,u.length>0&&this._addMessagesToView(u,y.REQUEST_MESSAGE),m.label=4;case 4:return this._isLoadingNext=!1,[2,u]}}))}))},e.prototype.removeFailedMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:if(this._isDisposed)throw new h({code:K.COLLECTION_DISPOSED,message:"Collection has been disposed."});return[4,this._channelManager.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,s=this;if(!this._isDisposed){this._isDisposed=!0;var r=P.of(this._iid),a=r.cacheContext,i=r.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(e){e.myMemberState!==Wt.NONE&&(s._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new En({channels:[s._channel],context:{source:y.CHANNEL_LASTACCESSEDAT_UPDATED}})))})),a.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}},e}(),Rs=function(t){function n(e,n){return t.call(this,e,s(s({},n),{channelManager:ps.of(e)}))||this}return e(n,t),n.prototype.keyOf=function(e){return e.messageId},n.prototype.initialize=function(e){var n=this;return b((function(){return p(n,void 0,void 0,(function(){var e;return f(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]}}))}))})),t.prototype.initialize.call(this,e)},n.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},n.prototype._activate=function(){return p(this,void 0,void 0,(function(){var e=this;return f(this,(function(n){switch(n.label){case 0:return[4,t.prototype._activate.call(this)];case 1:return n.sent(),[4,b((function(){return p(e,void 0,void 0,(function(){var e;return f(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]}}))}))}))];case 2:return n.sent(),[2]}}))}))},n.prototype._addMessagesToView=function(e,t){var n,s,r=this,a=this._filterUnderOffsetMessage(e),i=[],o=[];try{for(var u=v(a),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===y.SYNC_MESSAGE_FILL){if(l.messageId>0){if((E=fs(this._messages,l))<0){fs(this._unsentMessages,l)<0&&i.push(l);var h=ms(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof qe){(E=fs(this._unsentMessages,l))<0&&fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l))}}else if(l.messageId>0){if((E=fs(this._messages,l))<0){var m=fs(this._unsentMessages,l);m<0?i.push(l):(this._unsentMessages.splice(m,1),o.push(l));h=ms(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[E]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,d([],_(g),!1))}}else if(l instanceof qe){var E;(E=fs(this._unsentMessages,l))<0?fs(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l)):(o.push(l),this._unsentMessages[E]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,a;return f(this,(function(u){return e={source:t},i.length>0&&(null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===s||s.call(n,e,this.channel,i)),o.length>0&&(null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,e,this.channel,o)),[2]}))}))}))},n.prototype._updateMessagesToView=function(e,t){var n,s,r=this,a=[],i=[],o=[];try{for(var u=v(e),c=u.next();!c.done;c=u.next()){var l,h=c.value;if(h.messageId>0)if((l=fs(this._messages,h))>=0)i.push(h),this._messages[l]=h;else{var m=fs(this._unsentMessages,h);if(m>=0){var g=_(this._unsentMessages.splice(m,1),1)[0];if(this.hasNext&&g)o.push(g);else{i.push(h);var E=ms(this._messages,h);this._messages.splice(E,0,h)}}else{var C=this._messages.map((function(e){return e.createdAt}));(h.createdAtMath.max.apply(Math,d([],_(C),!1))&&!this._hasNext)&&a.push(h)}}else if(h instanceof qe)(l=fs(this._unsentMessages,h))>=0&&(i.push(h),this._unsentMessages[l]=h)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}return ie(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,u;return f(this,(function(c){return e={source:t},i.length>0?null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,i):o.length>0?null===(u=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===u||u.call(r,e,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t),[2]}))}))})),i},n}(xs),Fs={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},Ps=function(t){function n(e){var n=this,s=e.channelUrl,r=e.token,a=e.limit,i=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=N.GET,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/members"),n.params={token:r,limit:a,order:i,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}(S),ks=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.members=[];var r=n.next,a=n.members;return s.token=r,a&&a.length>0&&(s.members=a.map((function(t){return new tn(e,t)}))),s}return e(n,t),n}(T);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Is||(Is={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(ws||(ws={})),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"}(Ls||(Ls={}));var Os=function(t){function a(e,n,s){var r,a,o,u,c=this;return(c=t.call(this,e,n,i.GROUP,s)||this).mutedMemberFilter=Is.ALL,c.memberStateFilter=Ls.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Zt.ALL,c.order=ws.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(r=s.mutedMemberFilter)&&void 0!==r?r:Is.ALL,c.memberStateFilter=null!==(a=s.memberStateFilter)&&void 0!==a?a:Ls.ALL,c.nicknameStartsWithFilter=null!==(o=s.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=s.order)&&void 0!==u?u:ws.MEMBER_NICKNAME_ALPHABETICAL,c}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&r(Is,this.mutedMemberFilter)&&r(Ls,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&r(Zt,this.operatorFilter)&&r(ws,this.order)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=P.of(this._iid).requestQueue,t=new Ps(n(s(s({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=u.sent(),a=r.as(ks),i=a.members,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(he),Hs=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/accept"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),Vs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s.channel.myMemberState=Wt.JOINED,s}return e(n,t),n}(T),Gs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.isDistinct,i=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,_=e.customType,p=e.operatorUserIds,f=e.messageSurvivalSeconds;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r)),s.params=t({is_distinct:a,is_public:i,is_discoverable:o,name:h,data:d,custom_type:_,cover_url:u,cover_file:c,access_code:l,operator_ids:p,message_survival_seconds:f}),s}return e(s,n),s}(S),Bs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new ur(e,n),s}return e(n,t),n}(T),qs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s)),n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var zs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var js=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.countPreference,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:r},a}return e(n,t),n}(S),Ws=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.countPreference=n.count_preference,s}return e(n,t),n}(T),Qs=function(n){function s(e){var s=this,r=e.channelUrl,a=e.locale;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r),"/reset_user_history"),s.params=t({locale:a}),s}return e(s,n),s}(S),Ys=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),Ks=s(s({},Ze),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Js=s(s({},et),{scheduledAt:void 0}),Xs=function(s){function r(e){var r,a,i=this;i=s.call(this)||this;var o=[];e.mentionType===de.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((function(e){return e.userId}))));var u=e.channelType,c=e.channelUrl,l=e.scheduledMessageId;return i.method=N.PUT,i.path="".concat(re(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((function(e){return nt.payloadify(e)})),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(a=e.metaArrays)||void 0===a?void 0:a.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})),i}return e(r,s),r}(S),Zs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Ae(e,n),s}return e(n,t),n}(T),$s=function(s){function r(e){var r,a=this;a=s.call(this)||this;var i=[];e.mentionType===de.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return a.method=N.PUT,a.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),a.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:_e.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(r=e.metaArrays)||void 0===r?void 0:r.map((function(e){return st.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?rt.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),a}return e(r,s),r}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Te(e,n),s}e(n,t)}(T);var er,tr,nr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.DELETE,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a)),n}return e(n,t),n}(S),sr=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.POST,n.path="".concat(re(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a),"/send_now"),n}return e(n,t),n}(S),rr=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.pushTriggerOption,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:r},a}return e(n,t),n}(S),ar=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T),ir=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=t.call(this)||this;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),r}return e(n,t),n}(S),or=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T);!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"}(er||(er={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(tr||(tr={}));var ur=function(u){function c(e,t){var n,c,l,h,p,f,v,m,E,C,y,M,b,N,U,S,T,A,I,w,L=this;return(L=u.call(this,e,t)||this)._unreadMemberStateMap=new Map,L._undeliveredMemberStateMap=new Map,L._typingStatus=new Map,L._lastMemberCountUpdated=0,L._typingStarted=0,L._typingEnded=0,L._hasBotInfo={general:!1,ai:!1},L.isDistinct=!1,L.isSuper=!1,L.isBroadcast=!1,L.isExclusive=!1,L.isPublic=!1,L.isDiscoverable=!0,L.isChatNotification=!1,L.isAccessCodeRequired=!1,L.isPushEnabled=!1,L.unreadMessageCount=0,L.unreadMentionCount=0,L.totalUnreadReplyCount=0,L.members=[],L.memberCount=0,L.joinedMemberCount=0,L.hiddenState=tr.UNHIDDEN,L.lastMessage=null,L.messageOffsetTimestamp=0,L.messageSurvivalSeconds=-1,L.myMemberState=Wt.NONE,L.myRole=a.NONE,L.myMutedState=G.UNMUTED,L.myLastRead=0,L.myCountPreference=er.ALL,L.myPushTriggerOption=me.DEFAULT,L.inviter=null,L.invitedAt=0,L.joinedAt=0,L.lastPinnedMessage=null,L._latestMessageInfo=null,L._pinnedMessagesUpdatedAt=0,L._myMutedRemainingTime=-1,L.channelType=i.GROUP,L.isDistinct=null!==(c=t.is_distinct)&&void 0!==c&&c,L.isSuper=null!==(l=t.is_super)&&void 0!==l&&l,L.isBroadcast=null!==(h=t.is_broadcast)&&void 0!==h&&h,L.isExclusive=null!==(p=t.is_exclusive)&&void 0!==p&&p,L.isPublic=null!==(f=t.is_public)&&void 0!==f&&f,L.isDiscoverable=null!==(v=t.is_discoverable)&&void 0!==v?v:L.isPublic,L.isChatNotification=null!==(m=t.is_chat_notification)&&void 0!==m&&m,L.isAccessCodeRequired=null!==(E=t.is_access_code_required)&&void 0!==E&&E,L.isPushEnabled=null!==(C=t.is_push_enabled)&&void 0!==C&&C,Array.isArray(t.members)&&(n=L.members).push.apply(n,d([],_(t.members.map((function(e){return new tn(L._iid,e)}))),!1)),L.memberCount=null!==(y=t.member_count)&&void 0!==y?y:0,L.joinedMemberCount=null!==(M=t.joined_member_count)&&void 0!==M?M:0,L.hiddenState=r(tr,t.hidden_state)?t.hidden_state:tr.UNHIDDEN,L.messageOffsetTimestamp=null!==(b=t.ts_message_offset)&&void 0!==b?b:0,L.messageSurvivalSeconds=null!==(N=t.message_survival_seconds)&&void 0!==N?N:-1,L.lastMessage=t.last_message?Xe(L._iid,s({channel_type:L.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((function(e){g("number",t.read_receipt[e])&&L._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((function(e){g("number",t.delivery_receipt[e])&&L._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),L.myMemberState=r(Wt,t.member_state)?t.member_state:Wt.NONE,L.myRole=r(a,t.my_role)?t.my_role:a.NONE,r(G,t.is_muted)?L.myMutedState=t.is_muted:g("boolean",t.is_muted)?L.myMutedState=t.is_muted?G.MUTED:G.UNMUTED:L.myMutedState=G.UNMUTED,L.myCountPreference=r(er,t.count_preference)?t.count_preference:er.ALL,L.myPushTriggerOption=r(me,t.push_trigger_option)?t.push_trigger_option:me.ALL,L.myLastRead=null!==(U=t.user_last_read)&&void 0!==U?U:0,L.inviter=t.inviter?new o(L._iid,t.inviter):null,L.invitedAt=null!==(S=t.invited_at)&&void 0!==S?S:0,L.joinedAt=null!==(T=t.joined_ts)&&void 0!==T?T:0,L._updateUnreadCount(null!==(A=t.unread_message_count)&&void 0!==A?A:0,null!==(I=t.unread_mention_count)&&void 0!==I?I:0),L.totalUnreadReplyCount=null!==(w=t.total_unread_thread_message_count)&&void 0!==w?w:0,L.lastPinnedMessage=t.latest_pinned_message?Xe(L._iid,s({channel_type:L.channelType},t.latest_pinned_message)):null,t.latest_message&&(L._latestMessageInfo={messageId:t.latest_message.message_id,createdAt:t.latest_message.created_at}),L._hasBotInfo={general:!!t.has_bot,ai:!!t.has_ai_bot},L}return e(c,u),Object.defineProperty(c.prototype,"isHidden",{get:function(){return this.hiddenState!==tr.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._unreadMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var s=v(this._undeliveredMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasBot",{get:function(){return this._hasBotInfo.general},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"hasAiBot",{get:function(){return this._hasBotInfo.ai},enumerable:!1,configurable:!0}),c.payloadify=function(e){return t(n(s(s({},u.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,total_unread_thread_message_count:e.totalUnreadReplyCount,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 tn.payloadify(e)})),last_message:e.lastMessage?at(e.lastMessage):null,inviter:e.inviter?o.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,latest_pinned_message:e.lastPinnedMessage?at(e.lastPinnedMessage):null,latest_message:e._latestMessageInfo?{message_id:e._latestMessageInfo.messageId,created_at:e._latestMessageInfo.createdAt}:null,has_bot:e.hasBot,has_ai_bot:e.hasAiBot})))},c.prototype._shouldUpdateLastMessageWith=function(e){if(e.silent)return!1;var t=P.of(this._iid).appInfo;switch(null==t?void 0:t.lastMessageThreadingPolicy){case pe.NONE:case pe.INCLUDE_REPLY:break;case pe.EXCLUDE_REPLY:if(e.parentMessageId>0)return!1;break;case pe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case fe.INCLUDE_REPLY_TO_CHANNEL:if(e instanceof qe&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},c.prototype._updateLastMessage=function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)},c.prototype._updateUnreadCount=function(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===er.ALL||this.myCountPreference===er.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=P.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===er.ALL||this.myCountPreference===er.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},c.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)},c.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},c.prototype._setLatestMemberCount=function(e,t,n){var s=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,s=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),s},c.prototype.isReadMessage=function(e){var t=P.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt},c.prototype.serialize=function(){var e=this;return R(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))},c.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Rs(this._iid,s(s({},e),{channel:this}))},c.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Os(this._iid,this.url,e)},c.prototype.createThreadedParentMessageListQuery=function(e){return void 0===e&&(e={}),new it(this._iid,this.url,this.channelType,e)},c.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 s=this.members[n];s.state===Wt.JOINED&&(e.state=s.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},c.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof tn?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},c.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof qe&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var s=P.of(this._iid).sdkState,r=e.createdAt,a=0;try{for(var i=v(this.members),o=i.next();!o.done;o=i.next()){var u=o.value;if(s.userId!==u.userId&&u.state===Wt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&a.push(i)}})),a},c.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var s=P.of(this._iid).sdkState;if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var r=e instanceof qe?e.sender:null,a=[];return this.members.forEach((function(i){if(t||i.userId!==s.userId&&i.userId!==(null==r?void 0:r.userId)){var o=n._unreadMemberStateMap.get(i.userId);o&&o=t&&(e._typingStatus.delete(a),s=!0)})),s},c.prototype.refresh=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){return[2,this._refresh()]}))}))},c.prototype._refresh=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return t=P.of(this._iid),n=t.requestQueue,s=t.dispatcher,r=new Nn({channelUrl:this.url}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Un).channel,this._update(i),e||s.dispatch(new En({channels:[i],context:{source:y.REFRESH_CHANNEL}})),[2,this]}}))}))},c.prototype.freeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.freeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.unfreeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.unfreeze.call(this)];case 1:return e.sent(),P.of(this._iid).dispatcher.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.updateChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return t=s(s({},Fs),e),l(function(e){return g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new Gs(s({channelUrl:this.url},t)),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Bs).channel,this._update(u),r.dispatch(new En({channels:[u],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.invite=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return l(e.every((function(e){return e instanceof o}))).throw(h.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},c.prototype.inviteWithUserIds=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(m("string",e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.requestQueue,r=t.sessionManager,a=new Yn({channelUrl:this.url,userIds:e}),[4,s.send(a)];case 1:return i=u.sent(),o=i.as(Kn).channel,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_INVITED,inviter:r.currentUser,invitees:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.join=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new qn({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(zn).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.leave=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return t=P.of(this._iid),n=t.sdkState,s=t.requestQueue,r=new Wn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,s.send(r)];case 1:return a.sent(),this.myMemberState=Wt.NONE,[2]}}))}))},c.prototype.acceptInvitation=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new Hs({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(Vs).channel).myMemberState=this.myMemberState=Wt.JOINED,this._update(o),n.dispatch(new En({channels:[o],context:{source:y.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.declineInvitation=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new Xn({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),this.myMemberState=Wt.NONE,[2,this]}}))}))},c.prototype.sendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),ps.of(t._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.updateUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateUserMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendUserMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype.sendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.sendMultipleFilesMessage=function(e){var t=this,n=new ut,s=P.of(this._iid).dispatcher;return u.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){n._trigger(e)})).onFailed((function(e,t){n._triggerFailed(e,t)})).onSucceeded((function(e){var r=ps.of(t._iid);t._updateLastMessage(e),r.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})).onFileUploaded((function(e,t,s,r){n._triggerOnFileUploaded(e,t,s,r)})),n},c.prototype.updateFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=P.of(this._iid).dispatcher,[4,u.prototype.updateFileMessage.call(this,e,t)];case 1:return s=o.sent(),r=this._updateLastMessage(s),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new En({channels:[this],context:{source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}}))),a&&ps.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new j({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendFileMessage=function(e){var t=this,n=new Ct,s=P.of(this._iid).dispatcher,r=Rt.of(this._iid);return u.prototype._autoResendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=ps.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._updateLastMessage(e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new En({channels:[t],context:{source:y.EVENT_MESSAGE_SENT}})),n._trigger(e)})),n},c.prototype.deleteMessage=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,u.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&e instanceof qe&&P.of(this._iid).dispatcher.dispatch(new ge({reqId:e.reqId,source:y.EVENT_MESSAGE_DELETED})),[2]}}))}))},c.prototype.hide=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=s(s({},$n),e),l(function(e){return g("boolean",e.hidePreviousMessages,!0)&&g("boolean",e.allowAutoUnhide,!0)}(t)).throw(h.invalidParameters),n=P.of(this._iid),r=n.dispatcher,a=n.sdkState,i=n.requestQueue,o=new es(s({channelUrl:this.url,userId:a.userId},t)),[4,i.send(o)];case 1:return u=d.sent(),c=u.as(ts).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?tr.HIDDEN_ALLOW_AUTO_UNHIDE:tr.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.unhide=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=new zs({channelUrl:this.url}),[4,n.send(s)];case 1:return r.sent(),this.hiddenState=tr.UNHIDDEN,t.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.delete=function(){return p(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=P.of(this._iid).requestQueue,t=new qs({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o=this;return f(this,(function(u){switch(u.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.dispatcher,s=e.requestQueue,r=new yt({channelUrl:this.url}),[4,s.send(r)];case 1:return a=u.sent(),i=a.as(Be).readStatus,this._updateUnreadMemberState(t.userId,i.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),ps.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_READ}})),[2]}}))}))},c.prototype.markAsDelivered=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new cs({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),[2]}}))}))},c.prototype.startTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=n?(this._typingStarted=s,this._typingEnded=0,r=new ss({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.endTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=P.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=n?(this._typingStarted=0,this._typingEnded=s,r=new as({channelUrl:this.url,time:this._typingStarted}),[4,t.send(r)]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},c.prototype.createScheduledUserMessage=function(e){e=s(s({},ct),e),l(lt(e)).throw(h.invalidParameters);var t=new Ct;return this._createScheduledUserMessage(e,t),t},c.prototype.updateScheduledUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a,i;return f(this,(function(o){switch(o.label){case 0:return n=s(s({},Js),t),l(function(e){return tt(e)&&g("number",e.scheduledAt,!0)}(n)).throw(h.invalidParameters),r=P.of(this._iid).requestQueue,a=new $s(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(a)];case 1:return i=o.sent(),[2,i.as(Mt).message]}}))}))},c.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},ht),e),l(dt(e)).throw(h.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new Ct;return ve(bt).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);H((function(){return p(t,void 0,void 0,(function(){return f(this,(function(e){return[2,a._trigger(s)]}))}))}))})),E(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a},c.prototype.updateScheduledFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a;return f(this,(function(i){switch(i.label){case 0:return n=s(s({},Ks),t),l(function(e){return $e(e)&&g("number",e.scheduledAt,!0)&&(E(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(h.invalidParameters),E(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return r=new Xs(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,P.of(this._iid).requestQueue.send(r)];case 3:return a=i.sent(),[2,a.as(Zs).message]}}))}))},c.prototype.cancelScheduledMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new nr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.sendScheduledMessageNow=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new sr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,P.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.getMyPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a;return f(this,(function(i){switch(i.label){case 0:return e=P.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new ir({userId:t.userId,channelUrl:this.url}),[4,n.send(s)];case 1:return r=i.sent(),a=r.as(or).pushTriggerOption,this.myPushTriggerOption=a,[2,a]}}))}))},c.prototype.setMyPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(me,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new rr({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(ar).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.setMyCountPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(er,e)).throw(h.invalidParameters),t=P.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new js({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Ws).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new En({channels:[this],context:{source:y.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.resetMyHistory=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return e=P.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=e.sdkState,r=new Qs({channelUrl:this.url,locale:s.localeForChatbot}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(Ys).messageOffsetTimestamp,this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt=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),ve={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},_e=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:l,"/").concat(encodeURIComponent(t)),a.params={show_pinned_messages:!0},a}return e(t,n),t}(c),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),ye=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds,C=e.isEphemeral;return(t=n.call(this)||this).method=o.POST,t.path=l,t.params=d(p({channel_url:r,cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f,is_ephemeral:C})),t}return e(t,n),t}(c);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}e(t,n)}(h);var me=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),Ue=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"SYEV",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),Ee=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),Me=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"EXIT",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),we={},Pe=function(r){function o(e,a){var s=r.call(this,e,y(y({},a),{channelType:m.OPEN}))||this;return s.subscribeChannelEvent=U,s.unsubscribeChannelEvent=U,s.refreshChannel=function(){return n(s,void 0,void 0,(function(){return t(this,(function(e){return[2,U()]}))}))},s._openChannelCache=new Ce(e),s._openChannelHandlers=new Map,s._dispatcher.on((function(e){var n,t;if(e instanceof E)s._handleEvent(e).catch((function(e){if(M(e)&&"foreground"===s._sdkState.appState)throw e}));else if(e instanceof w&&e.stateType===P.CONNECTED){var r=s._openChannelCache.enteredChannels;try{for(var a=T(r),i=a.next();!i.done;i=a.next()){i.value.enter()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),we[e]||(we[e]=s),s}return e(o,r),o.of=function(e){return we[e]},o.prototype.buildOpenChannelFromSerializedData=function(e){var n=v(e);return new xe(this._iid,xe.payloadify(n))},o.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]}}))}))},o.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()]}}))}))},o.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,s,i,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=T(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 s=t.sent(),i={error:s},[3,7];case 6:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},o.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},o.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},Object.defineProperty(o.prototype,"handlers",{get:function(){return _([],g(this._openChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),o.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,s,i,o,u,l,c,h,d,p,f,C,v,_,g,y,U,E,w,P,O,x,L,R,F,k,S,$,J,ee,ne,te,ae,fe,Ce,ve,_e,ge,ye,me,Ee,we,Pe,Te,be,Ne,De,He,Ie,Oe,xe,Ae,Le,Re,Fe,ke,Se,ze,qe,Qe,Ge,je,Be,Ke,Ve,We,Xe,Ye,Ze,$e,Je,en,nn,tn=this;return t(this,(function(rn){switch(rn.label){case 0:switch(rn.trys.push([0,59,,60]),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,58];case 1:return i=null,"MESG"===e.code?i=e.as(Y):"FILE"===e.code?i=e.as(Z):"ADMM"!==e.code&&"BRDM"!=e.code||(i=e.as(pe)),i?(r=i.message,a=i.isMentioned,r.channelType!==m.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:s=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){var e,n,i,o,u;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())i=n.value,this._openChannelCache.isEnteredChannel(s.url)&&(i.onMessageReceived&&i.onMessageReceived(s,r),a&&i.onMentionReceived&&i.onMentionReceived(s,r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}}return[2]}))}))})),rn.label=3;case 3:return[3,58];case 4:return i=null,"MEDI"===e.code?i=e.as(W):"FEDI"===e.code?i=e.as(X):"AEDI"===e.code&&(i=e.as(de)),i?(o=i.message,u=i.mentionCountChange,o.channelType!==m.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:l=rn.sent(),c=!1,l.lastPinnedMessage&&l.lastPinnedMessage.messageId===o.messageId&&l.lastPinnedMessage.updatedAt0&&r.onMentionReceived&&r.onMentionReceived(l,o))}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=6;case 6:return[3,58];case 7:return h=e.as(I),ne=h.channelUrl,te=h.channelType,d=h.messageId,te!==m.OPEN?[3,9]:[4,this.getChannel(ne,!0)];case 8:p=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(p.url)&&r.onMessageDeleted&&r.onMessageDeleted(p,d)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=9;case 9:return[3,58];case 10:return f=e.as(he),ne=f.channelUrl,te=f.channelType,C=f.event,te!==m.OPEN?[3,12]:[4,this.getChannel(ne,!0)];case 11:v=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated&&r.onReactionUpdated(v,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=12;case 12:return[3,58];case 13:return(_=e.as(ce).event).channelType!==m.OPEN?[3,15]:[4,this.getChannel(_.channelUrl,!0)];case 14:g=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(g.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(g,_)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=15;case 15:return[3,58];case 16:y=e.as(le).openChannelMemberCounts,U=[],rn.label=17;case 17:rn.trys.push([17,22,23,24]),E=T(y),w=E.next(),rn.label=18;case 18:return w.done?[3,21]:(P=w.value,ne=P.channelUrl,Ee=P.participantCount,O=P.updatedAt,[4,this.getChannelFromCache(ne)]);case 19:(x=rn.sent())&&x._updateParticipantCount(Ee,O)&&U.push(x),rn.label=20;case 20:return w=E.next(),[3,18];case 21:return[3,24];case 22:return L=rn.sent(),en={error:L},[3,24];case 23:try{w&&!w.done&&(nn=E.return)&&nn.call(E)}finally{if(en)throw en.error}return[7];case 24:return U.length>0?[4,this.upsertChannelsToCache(U)]:[3,26];case 25:R=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(R)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=26;case 26:return[3,58];case 27:return F=e.as(ue),k=F.event,S=F.status,ne=F.channelUrl,te=F.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,29];case 28:$=rn.sent(),this._dispatcher.dispatch(new H({event:k,source:D.EVENT_POLL_UPDATED})),b(S===A?function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted($,k.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated($,k)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),rn.label=29;case 29:return[3,58];case 30:return J=e.as(V),ee=J.event,ne=J.channelUrl,te=J.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,32];case 31:ae=rn.sent(),this._dispatcher.dispatch(new N({event:ee,source:D.EVENT_POLL_VOTED})),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(ae,ee)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=32;case 32:return[3,58];case 33:if(!(fe=e.as(re).event).isOpenChannelEvent)return[3,57];switch(fe.category){case ie.CHANNEL_ENTER:return[3,34];case ie.CHANNEL_EXIT:return[3,36];case ie.CHANNEL_OPERATOR_UPDATE:return[3,38];case ie.USER_CHANNEL_MUTE:case ie.USER_CHANNEL_UNMUTE:return[3,40];case ie.USER_CHANNEL_BAN:case ie.USER_CHANNEL_UNBAN:return[3,42];case ie.CHANNEL_FREEZE:case ie.CHANNEL_UNFREEZE:return[3,44];case ie.CHANNEL_DELETED:return[3,46];case ie.CHANNEL_PROP_CHANGED:return[3,49];case ie.CHANNEL_META_DATA_CHANGED:return[3,51];case ie.CHANNEL_META_COUNTERS_CHANGED:return[3,53];case ie.PINNED_MESSAGE_CHANGED:return[3,55]}return[3,57];case 34:return[4,this.getChannel(fe.channelUrl,!0)];case 35:return Ce=rn.sent(),ve=e.as(Ue),Ee=ve.participantCount,_e=ve.user,ge=Ce._updateParticipantCount(Ee,fe.ts),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(Ce,_e),ge&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(Ce)})),[2]}))}))})),[3,57];case 36:return[4,this.getChannel(fe.channelUrl,!0)];case 37:return ye=rn.sent(),me=e.as(Me),Ee=me.participantCount,we=me.user,Pe=ye._updateParticipantCount(Ee,fe.ts),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(ye,we),Pe&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ye)})),[2]}))}))})),[3,57];case 38:return[4,this.getChannel(fe.channelUrl,!0)];case 39:return Te=rn.sent(),be=e.as(oe).operators,Te.operators=be,this.upsertChannelsToCache([Te]),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Te,be)})),[2]}))}))})),[3,57];case 40:return[4,this.getChannel(fe.channelUrl,!0)];case 41:return Ne=rn.sent(),De=fe.category===ie.USER_CHANNEL_MUTE,He=e.as(De?B:K).user,b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){De?e.onUserMuted&&e.onUserMuted(Ne,He):e.onUserUnmuted&&e.onUserUnmuted(Ne,He)})),[2]}))}))})),[3,57];case 42:return[4,this.getChannel(fe.channelUrl,!0)];case 43:return Ie=rn.sent(),Oe=fe.category===ie.USER_CHANNEL_BAN,xe=e.as(Oe?G:j).user,b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Oe?e.onUserBanned&&e.onUserBanned(Ie,xe):e.onUserUnbanned&&e.onUserUnbanned(Ie,xe)})),[2]}))}))})),[3,57];case 44:return[4,this.getChannel(fe.channelUrl,!0)];case 45:return Ae=rn.sent(),Le=e.as(Q).freeze,Ae.isFrozen=Le,this.upsertChannelsToCache([Ae]),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Le?e.onChannelFrozen&&e.onChannelFrozen(Ae):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ae)})),[2]}))}))})),[3,57];case 46:return[4,this.getChannel(fe.channelUrl,!0)];case 47:return Re=rn.sent(),[4,this.removeChannelsFromCache([Re.url])];case 48:return rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Re.url,Re.channelType)})),[2]}))}))})),[3,57];case 49:return[4,this.getChannelWithoutCache(fe.channelUrl,!0)];case 50:return Fe=rn.sent(),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Fe)})),[2]}))}))})),[3,57];case 51:return[4,this.getChannel(fe.channelUrl,!0)];case 52:return ke=rn.sent(),Se=e.as(q),ze=Se.created,qe=Se.updated,Qe=Se.deleted,ze&&ke._upsertCachedMetaData(ze,fe.ts),qe&&ke._upsertCachedMetaData(qe,fe.ts),Qe&&ke._removeFromCachedMetaData(Qe,fe.ts),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ze&&e.onMetaDataCreated&&e.onMetaDataCreated(ke,ze),qe&&e.onMetaDataUpdated&&e.onMetaDataUpdated(ke,qe),Qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(ke,Qe)})),[2]}))}))})),[3,57];case 53:return[4,this.getChannel(fe.channelUrl,!0)];case 54:return Ge=rn.sent(),je=e.as(z),Be=je.created,Ke=je.updated,Ve=je.deleted,b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Be&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Ge,Be),Ke&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ge,Ke),Ve&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Ge,Ve)})),[2]}))}))})),[3,57];case 55:return[4,this.getChannel(fe.channelUrl,!0)];case 56:return We=rn.sent(),Xe=e.as(se),Ye=Xe.pinnedMessageIds,Ze=Xe.latestPinnedMessage,($e=Xe.ts)>We._pinnedMessagesUpdatedAt&&(We.pinnedMessageIds=Ye,We.lastPinnedMessage=Ze,We._pinnedMessagesUpdatedAt=$e,this.upsertChannelsToCache([We]),b((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=T(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelChanged&&r.onChannelChanged(We)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),b((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(We)})),[2]}))}))}))),[3,57];case 57:return[3,58];case 58:return[3,60];case 59:if(Je=rn.sent(),M(Je))throw Je;return[3,60];case 60:return[2]}}))}))},o.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},o.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},o.prototype.clearHandler=function(){this._openChannelHandlers.clear()},o.prototype.getChannel=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:O(s("string",e)).throw(x.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,r)];case 5:return[2,t.sent()]}}))}))},o.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,i;return t(this,(function(t){switch(t.label){case 0:return O(s("string",e)).throw(x.invalidParameters),n=new _e({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),i=a.as(ge).channel,[4,this.upsertChannelsToCache([i])];case 2:return[2,t.sent()[0]]}}))}))},o.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},ve),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)&&(s("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&s("boolean",e.isEphemeral,!0)}(n)).throw(x.invalidParameters),r=new ye(n),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(ge).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},o}(ae),Te={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},be=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,s=e.limit;return(t=n.call(this)||this).method=o.GET,t.path="".concat(l,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:s},t}return e(t,n),t}(c),Ne=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,s=t.participants;return r.token=a,r.participants=s.map((function(n){return new $(e,n)})),r}return e(t,n),t}(h),De=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,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new be(y(y({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Ne),s=a.participants,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},a}(L),He=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=o.PUT,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f})),t}return e(t,n),t}(c),Ie=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),Oe=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=o.DELETE,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(c);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var xe=function(r){function o(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.lastPinnedMessage=null,a._pinnedMessagesUpdatedAt=0,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 C(e,n)})):[],a.lastPinnedMessage=n.latest_pinned_message?ne(a._iid,y({channel_type:a.channelType},n.latest_pinned_message)):null,a}return e(o,r),o.payloadify=function(e){return d(p(y(y({},J.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return C.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?ee(e.lastPinnedMessage):null})))},o.prototype.serialize=function(){return F(this)},o.prototype.isOperator=function(e){return e instanceof C?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},o.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},o.prototype.createParticipantListQuery=function(e){return new De(this._iid,this.url,e)},o.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Pe.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},o.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new me({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Ue),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Ee({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Me),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setExitedToCache(this),te.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},Te),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)}(n)).throw(x.invalidParameters),r=R.of(this._iid).requestQueue,o=new He(y({channelUrl:this.url},n)),[4,r.send(o)];case 1:return u=t.sent(),l=u.as(Ie).channel,this._update(l),[4,Pe.of(this._iid).upsertChannelsToCache([l])];case 2:return t.sent(),[2,this]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(e,r,a,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=y(y({},Te),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:s,customType:i}),[2,this.updateChannel(n)]}))}))},o.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Oe({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,Pe.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.updateUserMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateUserMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o.prototype.updateFileMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateFileMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o}(J),Ae=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=U,e.onUserExited=U,e.onChannelParticipantCountChanged=U,e.onPollUpdated=U,e.onPollVoted=U,e.onPollDeleted=U,e.onPinnedMessageUpdated=U,e}return e(t,n),t}(fe)),Le=function(n){function t(e){var t=this,r=e.token,a=e.limit,s=e.nameKeyword,i=e.urlKeyword,u=e.customTypes,c=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=o.GET,t.path=l,t.params=d({token:r,limit:a,name_contains:s,url_contains:i,custom_types:u,show_frozen:c,show_metadata:h,show_pinned_messages:!0}),t}return e(t,n),t}(c),Re=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,s=t.channels,i=t.ts;return r.token=a,s&&s.length>0&&(r.channels=s.map((function(n){return new xe(e,n)}))),r.ts="number"==typeof i?i:null,r}return e(t,n),t}(h),Fe=function(r){function i(e,n){var t,a,s,i,o,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,u.urlKeyword=null!==(i=n.urlKeyword)&&void 0!==i?i:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return e(i,r),i.prototype._validate=function(){return r.prototype._validate.call(this)&&s("boolean",this.includeFrozen)&&s("boolean",this.includeMetaData)&&s("string",this.nameKeyword,!0)&&s("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},i.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Le(p(y(y({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Re),s=a.channels,i=a.token,this._token=i,this._hasNext=!!i,[4,Pe.of(this._iid).upsertChannelsToCache(s)];case 2:return t.sent(),this._isLoading=!1,[2,s];case 3:return[2,[]];case 4:throw x.queryInProgress;case 5:return[3,7];case 6:throw x.invalidParameters;case 7:return[2]}}))}))},i}(k),ke=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,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new Pe(e,{sdkState:t,dispatcher:a,requestQueue:i,logger:o,cacheContext:l,sessionManager:s})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new Fe(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,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=y({},ve)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=s,n.customType=i,[2,this._manager.createChannel(n)]}))}))},a}(S);export{xe as OpenChannel,Ae as OpenChannelHandler,Fe as OpenChannelListQuery,ke as OpenChannelModule,De as ParticipantListQuery}; +import{c as e,_ as n,b as t,af as r,Q as a,a as s,i,A as o,bn as u,bo as l,f as c,h,e as d,u as p,ak as f,U as C,z as v,p as _,q as g,g as y,C as m,aA as U,W as E,O as M,D as w,F as P,t as b,G as T,aM as N,a2 as D,aT as H,bi as I,w as O,s as x,bj as A,aB as L,V as R,ai as F,aO as k,a_ as S}from"./lib/__bundle-0ca331b6.js";import{a3 as z,a4 as q,a5 as Q,a7 as G,a6 as j,a8 as B,a9 as K,aa as V,ae as W,af as X,ag as Y,ah as Z,P as $,z as J,as as ee,T as ne,ak as te}from"./lib/__bundle-af65b142.js";import{C as re,B as ae,U as se,a as ie,O as oe,P as ue,M as le,T as ce,R as he,b as de,A as pe}from"./lib/__bundle-bfc18da1.js";import{B as fe}from"./lib/__bundle-e4c89c6a.js";import"./lib/__bundle-acd77193.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),ve={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},_e=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:l,"/").concat(encodeURIComponent(t)),a.params={show_pinned_messages:!0},a}return e(t,n),t}(c),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),ye=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds,C=e.isEphemeral;return(t=n.call(this)||this).method=o.POST,t.path=l,t.params=d(p({channel_url:r,cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f,is_ephemeral:C})),t}return e(t,n),t}(c);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}e(t,n)}(h);var me=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),Ue=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"SYEV",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),Ee=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),Me=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"EXIT",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),we={},Pe=function(r){function o(e,a){var s=r.call(this,e,y(y({},a),{channelType:m.OPEN}))||this;return s.subscribeChannelEvent=U,s.unsubscribeChannelEvent=U,s.refreshChannel=function(){return n(s,void 0,void 0,(function(){return t(this,(function(e){return[2,U()]}))}))},s._openChannelCache=new Ce(e),s._openChannelHandlers=new Map,s._dispatcher.on((function(e){var n,t;if(e instanceof E)s._handleEvent(e).catch((function(e){if(M(e)&&"foreground"===s._sdkState.appState)throw e}));else if(e instanceof w&&e.stateType===P.CONNECTED){var r=s._openChannelCache.enteredChannels;try{for(var a=b(r),i=a.next();!i.done;i=a.next()){i.value.enter()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),we[e]||(we[e]=s),s}return e(o,r),o.of=function(e){return we[e]},o.prototype.buildOpenChannelFromSerializedData=function(e){var n=v(e);return new xe(this._iid,xe.payloadify(n))},o.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]}}))}))},o.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()]}}))}))},o.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,s,i,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=b(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 s=t.sent(),i={error:s},[3,7];case 6:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},o.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},o.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},Object.defineProperty(o.prototype,"handlers",{get:function(){return _([],g(this._openChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),o.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,s,i,o,u,l,c,h,d,p,f,C,v,_,g,y,U,E,w,P,O,x,L,R,F,k,S,$,J,ee,ne,te,ae,fe,Ce,ve,_e,ge,ye,me,Ee,we,Pe,be,Te,Ne,De,He,Ie,Oe,xe,Ae,Le,Re,Fe,ke,Se,ze,qe,Qe,Ge,je,Be,Ke,Ve,We,Xe,Ye,Ze,$e,Je,en,nn,tn=this;return t(this,(function(rn){switch(rn.label){case 0:switch(rn.trys.push([0,59,,60]),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,58];case 1:return i=null,"MESG"===e.code?i=e.as(Y):"FILE"===e.code?i=e.as(Z):"ADMM"!==e.code&&"BRDM"!=e.code||(i=e.as(pe)),i?(r=i.message,a=i.isMentioned,r.channelType!==m.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:s=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,i,o,u;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())i=n.value,this._openChannelCache.isEnteredChannel(s.url)&&(i.onMessageReceived&&i.onMessageReceived(s,r),a&&i.onMentionReceived&&i.onMentionReceived(s,r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}}return[2]}))}))})),rn.label=3;case 3:return[3,58];case 4:return i=null,"MEDI"===e.code?i=e.as(W):"FEDI"===e.code?i=e.as(X):"AEDI"===e.code&&(i=e.as(de)),i?(o=i.message,u=i.mentionCountChange,o.channelType!==m.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:l=rn.sent(),c=!1,l.lastPinnedMessage&&l.lastPinnedMessage.messageId===o.messageId&&l.lastPinnedMessage.updatedAt0&&r.onMentionReceived&&r.onMentionReceived(l,o))}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=6;case 6:return[3,58];case 7:return h=e.as(I),ne=h.channelUrl,te=h.channelType,d=h.messageId,te!==m.OPEN?[3,9]:[4,this.getChannel(ne,!0)];case 8:p=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(p.url)&&r.onMessageDeleted&&r.onMessageDeleted(p,d)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=9;case 9:return[3,58];case 10:return f=e.as(he),ne=f.channelUrl,te=f.channelType,C=f.event,te!==m.OPEN?[3,12]:[4,this.getChannel(ne,!0)];case 11:v=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated&&r.onReactionUpdated(v,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=12;case 12:return[3,58];case 13:return(_=e.as(ce).event).channelType!==m.OPEN?[3,15]:[4,this.getChannel(_.channelUrl,!0)];case 14:g=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(g.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(g,_)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=15;case 15:return[3,58];case 16:y=e.as(le).openChannelMemberCounts,U=[],rn.label=17;case 17:rn.trys.push([17,22,23,24]),E=b(y),w=E.next(),rn.label=18;case 18:return w.done?[3,21]:(P=w.value,ne=P.channelUrl,Ee=P.participantCount,O=P.updatedAt,[4,this.getChannelFromCache(ne)]);case 19:(x=rn.sent())&&x._updateParticipantCount(Ee,O)&&U.push(x),rn.label=20;case 20:return w=E.next(),[3,18];case 21:return[3,24];case 22:return L=rn.sent(),en={error:L},[3,24];case 23:try{w&&!w.done&&(nn=E.return)&&nn.call(E)}finally{if(en)throw en.error}return[7];case 24:return U.length>0?[4,this.upsertChannelsToCache(U)]:[3,26];case 25:R=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(R)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=26;case 26:return[3,58];case 27:return F=e.as(ue),k=F.event,S=F.status,ne=F.channelUrl,te=F.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,29];case 28:$=rn.sent(),this._dispatcher.dispatch(new H({event:k,source:D.EVENT_POLL_UPDATED})),T(S===A?function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted($,k.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated($,k)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),rn.label=29;case 29:return[3,58];case 30:return J=e.as(V),ee=J.event,ne=J.channelUrl,te=J.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,32];case 31:ae=rn.sent(),this._dispatcher.dispatch(new N({event:ee,source:D.EVENT_POLL_VOTED})),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(ae,ee)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=32;case 32:return[3,58];case 33:if(!(fe=e.as(re).event).isOpenChannelEvent)return[3,57];switch(fe.category){case ie.CHANNEL_ENTER:return[3,34];case ie.CHANNEL_EXIT:return[3,36];case ie.CHANNEL_OPERATOR_UPDATE:return[3,38];case ie.USER_CHANNEL_MUTE:case ie.USER_CHANNEL_UNMUTE:return[3,40];case ie.USER_CHANNEL_BAN:case ie.USER_CHANNEL_UNBAN:return[3,42];case ie.CHANNEL_FREEZE:case ie.CHANNEL_UNFREEZE:return[3,44];case ie.CHANNEL_DELETED:return[3,46];case ie.CHANNEL_PROP_CHANGED:return[3,49];case ie.CHANNEL_META_DATA_CHANGED:return[3,51];case ie.CHANNEL_META_COUNTERS_CHANGED:return[3,53];case ie.PINNED_MESSAGE_CHANGED:return[3,55]}return[3,57];case 34:return[4,this.getChannel(fe.channelUrl,!0)];case 35:return Ce=rn.sent(),ve=e.as(Ue),Ee=ve.participantCount,_e=ve.user,ge=Ce._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(Ce,_e),ge&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(Ce)})),[2]}))}))})),[3,57];case 36:return[4,this.getChannel(fe.channelUrl,!0)];case 37:return ye=rn.sent(),me=e.as(Me),Ee=me.participantCount,we=me.user,Pe=ye._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(ye,we),Pe&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ye)})),[2]}))}))})),[3,57];case 38:return[4,this.getChannel(fe.channelUrl,!0)];case 39:return be=rn.sent(),Te=e.as(oe).operators,be.operators=Te,this.upsertChannelsToCache([be]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(be,Te)})),[2]}))}))})),[3,57];case 40:return[4,this.getChannel(fe.channelUrl,!0)];case 41:return Ne=rn.sent(),De=fe.category===ie.USER_CHANNEL_MUTE,He=e.as(De?B:K).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){De?e.onUserMuted&&e.onUserMuted(Ne,He):e.onUserUnmuted&&e.onUserUnmuted(Ne,He)})),[2]}))}))})),[3,57];case 42:return[4,this.getChannel(fe.channelUrl,!0)];case 43:return Ie=rn.sent(),Oe=fe.category===ie.USER_CHANNEL_BAN,xe=e.as(Oe?G:j).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Oe?e.onUserBanned&&e.onUserBanned(Ie,xe):e.onUserUnbanned&&e.onUserUnbanned(Ie,xe)})),[2]}))}))})),[3,57];case 44:return[4,this.getChannel(fe.channelUrl,!0)];case 45:return Ae=rn.sent(),Le=e.as(Q).freeze,Ae.isFrozen=Le,this.upsertChannelsToCache([Ae]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Le?e.onChannelFrozen&&e.onChannelFrozen(Ae):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ae)})),[2]}))}))})),[3,57];case 46:return[4,this.getChannel(fe.channelUrl,!0)];case 47:return Re=rn.sent(),[4,this.removeChannelsFromCache([Re.url])];case 48:return rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Re.url,Re.channelType)})),[2]}))}))})),[3,57];case 49:return[4,this.getChannelWithoutCache(fe.channelUrl,!0)];case 50:return Fe=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Fe)})),[2]}))}))})),[3,57];case 51:return[4,this.getChannel(fe.channelUrl,!0)];case 52:return ke=rn.sent(),Se=e.as(q),ze=Se.created,qe=Se.updated,Qe=Se.deleted,ze&&ke._upsertCachedMetaData(ze,fe.ts),qe&&ke._upsertCachedMetaData(qe,fe.ts),Qe&&ke._removeFromCachedMetaData(Qe,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ze&&e.onMetaDataCreated&&e.onMetaDataCreated(ke,ze),qe&&e.onMetaDataUpdated&&e.onMetaDataUpdated(ke,qe),Qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(ke,Qe)})),[2]}))}))})),[3,57];case 53:return[4,this.getChannel(fe.channelUrl,!0)];case 54:return Ge=rn.sent(),je=e.as(z),Be=je.created,Ke=je.updated,Ve=je.deleted,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Be&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Ge,Be),Ke&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ge,Ke),Ve&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Ge,Ve)})),[2]}))}))})),[3,57];case 55:return[4,this.getChannel(fe.channelUrl,!0)];case 56:return We=rn.sent(),Xe=e.as(se),Ye=Xe.pinnedMessageIds,Ze=Xe.latestPinnedMessage,($e=Xe.ts)>We._pinnedMessagesUpdatedAt&&(We.pinnedMessageIds=Ye,We.lastPinnedMessage=Ze,We._pinnedMessagesUpdatedAt=$e,this.upsertChannelsToCache([We]),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelChanged&&r.onChannelChanged(We)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(We)})),[2]}))}))}))),[3,57];case 57:return[3,58];case 58:return[3,60];case 59:if(Je=rn.sent(),M(Je))throw Je;return[3,60];case 60:return[2]}}))}))},o.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},o.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},o.prototype.clearHandler=function(){this._openChannelHandlers.clear()},o.prototype.getChannel=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:O(s("string",e)).throw(x.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,r)];case 5:return[2,t.sent()]}}))}))},o.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,i;return t(this,(function(t){switch(t.label){case 0:return O(s("string",e)).throw(x.invalidParameters),n=new _e({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),i=a.as(ge).channel,[4,this.upsertChannelsToCache([i])];case 2:return[2,t.sent()[0]]}}))}))},o.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},ve),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)&&(s("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&s("boolean",e.isEphemeral,!0)}(n)).throw(x.invalidParameters),r=new ye(n),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(ge).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},o}(ae),be={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Te=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,s=e.limit;return(t=n.call(this)||this).method=o.GET,t.path="".concat(l,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:s},t}return e(t,n),t}(c),Ne=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,s=t.participants;return r.token=a,r.participants=s.map((function(n){return new $(e,n)})),r}return e(t,n),t}(h),De=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,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Te(y(y({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Ne),s=a.participants,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},a}(L),He=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=o.PUT,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f})),t}return e(t,n),t}(c),Ie=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),Oe=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=o.DELETE,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(c);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var xe=function(r){function o(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.lastPinnedMessage=null,a._pinnedMessagesUpdatedAt=0,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 C(e,n)})):[],a.lastPinnedMessage=n.latest_pinned_message?ne(a._iid,y({channel_type:a.channelType},n.latest_pinned_message)):null,a}return e(o,r),o.payloadify=function(e){return d(p(y(y({},J.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return C.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?ee(e.lastPinnedMessage):null})))},o.prototype.serialize=function(){return F(this)},o.prototype.isOperator=function(e){return e instanceof C?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},o.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},o.prototype.createParticipantListQuery=function(e){return new De(this._iid,this.url,e)},o.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Pe.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},o.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new me({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Ue),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Ee({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Me),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setExitedToCache(this),te.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},be),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)}(n)).throw(x.invalidParameters),r=R.of(this._iid).requestQueue,o=new He(y({channelUrl:this.url},n)),[4,r.send(o)];case 1:return u=t.sent(),l=u.as(Ie).channel,this._update(l),[4,Pe.of(this._iid).upsertChannelsToCache([l])];case 2:return t.sent(),[2,this]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(e,r,a,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=y(y({},be),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:s,customType:i}),[2,this.updateChannel(n)]}))}))},o.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Oe({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,Pe.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.updateUserMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateUserMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o.prototype.updateFileMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateFileMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o}(J),Ae=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=U,e.onUserExited=U,e.onChannelParticipantCountChanged=U,e.onPollUpdated=U,e.onPollVoted=U,e.onPollDeleted=U,e.onPinnedMessageUpdated=U,e}return e(t,n),t}(fe)),Le=function(n){function t(e){var t=this,r=e.token,a=e.limit,s=e.nameKeyword,i=e.urlKeyword,u=e.customTypes,c=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=o.GET,t.path=l,t.params=d({token:r,limit:a,name_contains:s,url_contains:i,custom_types:u,show_frozen:c,show_metadata:h,show_pinned_messages:!0}),t}return e(t,n),t}(c),Re=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,s=t.channels,i=t.ts;return r.token=a,s&&s.length>0&&(r.channels=s.map((function(n){return new xe(e,n)}))),r.ts="number"==typeof i?i:null,r}return e(t,n),t}(h),Fe=function(r){function i(e,n){var t,a,s,i,o,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,u.urlKeyword=null!==(i=n.urlKeyword)&&void 0!==i?i:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return e(i,r),i.prototype._validate=function(){return r.prototype._validate.call(this)&&s("boolean",this.includeFrozen)&&s("boolean",this.includeMetaData)&&s("string",this.nameKeyword,!0)&&s("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},i.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Le(p(y(y({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Re),s=a.channels,i=a.token,this._token=i,this._hasNext=!!i,[4,Pe.of(this._iid).upsertChannelsToCache(s)];case 2:return t.sent(),this._isLoading=!1,[2,s];case 3:return[2,[]];case 4:throw x.queryInProgress;case 5:return[3,7];case 6:throw x.invalidParameters;case 7:return[2]}}))}))},i}(k),ke=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,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new Pe(e,{sdkState:t,dispatcher:a,requestQueue:i,logger:o,cacheContext:l,sessionManager:s})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new Fe(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,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=y({},ve)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=s,n.customType=i,[2,this._manager.createChannel(n)]}))}))},a}(S);export{xe as OpenChannel,Ae as OpenChannelHandler,Fe as OpenChannelListQuery,ke as OpenChannelModule,De as ParticipantListQuery}; diff --git a/package.json b/package.json index e799bc7..1590671 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.14.5", + "version": "4.14.6", "description": "Sendbird SDK for JavaScript", "sideEffects": false, "name": "@sendbird/chat", diff --git a/poll.js b/poll.js index a060bcc..0c73d3d 100644 --- a/poll.js +++ b/poll.js @@ -1 +1 @@ -import{c as t,aN as e,_ as r,a_ as a,b as n,g as o,b0 as i,w as s,b1 as l,s as u,b2 as c,b3 as p,b4 as d,b5 as h}from"./lib/__bundle-c03282ec.js";export{ar as Poll,x as PollListQuery,b6 as PollOption,b7 as PollStatus,aI as PollVoteEvent,y as PollVoterListQuery}from"./lib/__bundle-c03282ec.js";export{P as PollUpdateEvent}from"./lib/__bundle-acd77193.js";var g=function(a){function g(){var t=null!==a&&a.apply(this,arguments)||this;return t.name="poll",t}return t(g,a),g.prototype.init=function(t,r){var n=r.sdkState,o=r.dispatcher,i=r.sessionManager,s=r.requestQueue,l=r.logger,u=r.onlineDetector,c=r.cacheContext;a.prototype.init.call(this,t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c}),this._manager=new e(t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c})},g.prototype.create=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},i),t),s(l(e)).throw(u.invalidParameters),[2,this._manager.create(e)]}))}))},g.prototype.get=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},c),t),s(p(e)).throw(u.invalidParameters),[2,this._manager.get(e)]}))}))},g.prototype.getOption=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},d),t),s(h(e)).throw(u.invalidParameters),[2,this._manager.getOption(e)]}))}))},g.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},g}(a);export{g as PollModule}; +import{c as t,aN as e,_ as r,a_ as a,b as n,g as o,b0 as i,w as s,b1 as l,s as u,b2 as c,b3 as p,b4 as d,b5 as h}from"./lib/__bundle-0ca331b6.js";export{ar as Poll,x as PollListQuery,b6 as PollOption,b7 as PollStatus,aI as PollVoteEvent,y as PollVoterListQuery}from"./lib/__bundle-0ca331b6.js";export{P as PollUpdateEvent}from"./lib/__bundle-acd77193.js";var b=function(a){function b(){var t=null!==a&&a.apply(this,arguments)||this;return t.name="poll",t}return t(b,a),b.prototype.init=function(t,r){var n=r.sdkState,o=r.dispatcher,i=r.sessionManager,s=r.requestQueue,l=r.logger,u=r.onlineDetector,c=r.cacheContext;a.prototype.init.call(this,t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c}),this._manager=new e(t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c})},b.prototype.create=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},i),t),s(l(e)).throw(u.invalidParameters),[2,this._manager.create(e)]}))}))},b.prototype.get=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},c),t),s(p(e)).throw(u.invalidParameters),[2,this._manager.get(e)]}))}))},b.prototype.getOption=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},d),t),s(h(e)).throw(u.invalidParameters),[2,this._manager.getOption(e)]}))}))},b.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},b}(a);export{b as PollModule}; diff --git a/sendbird.min.js b/sendbird.min.js index 2730e1d..0cc6f7f 100644 --- a/sendbird.min.js +++ b/sendbird.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Sendbird={})}(this,(function(e){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=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 i,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw i}}}}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(r){var a=Object.getOwnPropertyDescriptor(r,t);return a.get?a.get.call(arguments.length<3?e:n):a.value}},o.apply(null,arguments)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function d(){d=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",u=i.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 i=t&&t.prototype instanceof g?t:g,s=Object.create(i.prototype),o=new M(r||[]);return a(s,"_invoke",{value:T(e,n,o)}),s}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var f="suspendedStart",p="suspendedYield",v="executing",_="completed",m={};function g(){}function y(){}function E(){}var k={};c(k,s,(function(){return this}));var b=Object.getPrototypeOf,C=b&&b(b(O([])));C&&C!==n&&r.call(C,s)&&(k=C);var w=E.prototype=g.prototype=Object.create(k);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(a,i,s,o){var u=h(e[a],e,i);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,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var i;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return i=i?i.then(a,a):a()}})}function T(t,n,r){var a=f;return function(i,s){if(a===v)throw Error("Generator is already running");if(a===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var o=r.delegate;if(o){var u=I(o,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===f)throw a=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=v;var c=h(t,n,r);if("normal"===c.type){if(a=r.done?_:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(a=_,r.method="throw",r.arg=c.arg)}}}function I(t,n){var r=n.method,a=t.iterator[r];if(a===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,I(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=h(a,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function N(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 A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function M(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(N,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function n(){for(;++a=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(u&&c){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),A(n),m}},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;A(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:O(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),m}},t}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,s,o=[],u=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(o.push(r.value),o.length!==t);u=!0);}catch(e){c=!0,a=e}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw a}}return o}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t,n,r){var a=o(u(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof a?function(e){return a.apply(n,e)}:a}function v(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){var t=function(e,t){if("object"!=typeof e||!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:t+""}function m(e){return m="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},m(e)}function g(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function y(e){var t="function"==typeof Map?new Map:void 0;return y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(l())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var a=new(e.bind.apply(e,r));return n&&h(a,n.prototype),a}(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)},y(e)}function E(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var k,b="4.14.5",C=function(){function e(){r(this,e)}return i(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return b}},{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.SendbirdErrorCode=void 0,(k=e.SendbirdErrorCode||(e.SendbirdErrorCode={}))[k.NON_AUTHORIZED=400108]="NON_AUTHORIZED",k[k.INVALID_TOKEN=400111]="INVALID_TOKEN",k[k.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",k[k.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",k[k.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",k[k.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",k[k.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",k[k.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",k[k.SESSION_REVOKED=400310]="SESSION_REVOKED",k[k.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",k[k.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",k[k.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",k[k.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",k[k.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",k[k.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",k[k.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",k[k.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",k[k.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",k[k.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",k[k.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",k[k.LOST_INSTANCE=700100]="LOST_INSTANCE",k[k.CONNECTION_RENEW=700102]="CONNECTION_RENEW",k[k.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",k[k.INVALID_COMMAND=700700]="INVALID_COMMAND",k[k.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",k[k.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",k[k.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",k[k.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",k[k.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",k[k.INVALID_PARAMETER=800110]="INVALID_PARAMETER",k[k.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",k[k.NETWORK_ERROR=800120]="NETWORK_ERROR",k[k.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",k[k.MALFORMED_DATA=800130]="MALFORMED_DATA",k[k.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",k[k.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",k[k.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",k[k.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",k[k.ACK_TIMEOUT=800180]="ACK_TIMEOUT",k[k.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",k[k.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",k[k.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",k[k.REQUEST_FAILED=800220]="REQUEST_FAILED",k[k.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",k[k.REQUEST_CANCELED=800240]="REQUEST_CANCELED",k[k.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",k[k.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",k[k.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED",k[k.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",k[k.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",k[k.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",k[k.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",k[k.DATABASE_ERROR=800700]="DATABASE_ERROR",k[k.USER_DEACTIVATED=900021]="USER_DEACTIVATED",k[k.CHANNEL_IS_FROZEN=900050]="CHANNEL_IS_FROZEN",k[k.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";var w,x,S,T,I,N=function(e){return!(e instanceof A&&!e.shouldThrowOutside)},A=function(t){function a(e){var t,i=e.code,s=void 0===i?0:i,o=e.message,u=void 0===o?"":o;return r(this,a),(t=n(this,a,[u])).shouldThrowOutside=!1,t._detail="",t.name="SendbirdError",t.code=s,Object.setPrototypeOf(t,a.prototype),t}return c(a,t),i(a,[{key:"detail",get:function(){return this._detail}},{key:"setDetail",value:function(e){this._detail=e}},{key:"isInvalidTokenError",get:function(){return this.code===e.SendbirdErrorCode.INVALID_TOKEN}},{key:"isSessionExpiredError",get:function(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}},{key:"isSessionTokenExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_KEY_EXPIRED}},{key:"isSessionInvalidatedError",get:function(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}},{key:"isSessionRevokedError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_REVOKED}},{key:"isUserAuthDeactivedError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DEACTIVATED}},{key:"isUserAuthDeletedOrNotFoundError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}},{key:"isNetworkError",get:function(){return this.code===e.SendbirdErrorCode.NETWORK_ERROR||this.code===e.SendbirdErrorCode.NETWORK_ROUTING_ERROR}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new a({code:e.SendbirdErrorCode.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new a({code:e.SendbirdErrorCode.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"invalidCommand",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new a({code:e.SendbirdErrorCode.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{key:"connectionRenew",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"xmlHttpRequestNotSupported",get:function(){return new a({code:e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}},{key:"connectionRequired",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"channelTypeNotSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}},{key:"networkError",get:function(){return new a({code:e.SendbirdErrorCode.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new a({code:e.SendbirdErrorCode.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new a({code:e.SendbirdErrorCode.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new a({code:e.SendbirdErrorCode.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new a({code:e.SendbirdErrorCode.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new a({code:e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Request failed."})}},{key:"tooManyRequests",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}},{key:"alreadyConnectedAsAnotherUser",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}},{key:"fileUploadCanceled",get:function(){return new a({code:e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new a({code:e.SendbirdErrorCode.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}},{key:"statLogUploadLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}},{key:"malformedDataError",get:function(){return new a({code:e.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}}])}(y(Error)),M=[e.SendbirdErrorCode.CONNECTION_REQUIRED,e.SendbirdErrorCode.NETWORK_ERROR,e.SendbirdErrorCode.ACK_TIMEOUT,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,e.SendbirdErrorCode.REQUEST_CANCELED,e.SendbirdErrorCode.INTERNAL_SERVER_ERROR,e.SendbirdErrorCode.RATE_LIMIT_EXCEEDED,e.SendbirdErrorCode.UNKNOWN_SERVER_ERROR,e.SendbirdErrorCode.USER_DEACTIVATED,e.SendbirdErrorCode.CHANNEL_IS_FROZEN,e.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],O=[e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.CONNECTION_REQUIRED,e.SendbirdErrorCode.CHANNEL_IS_FROZEN],U=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},D=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||("string"!=typeof e?"object"===m(e)?R(e,t):L(e,t):m(t)===e)},R=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Object.values(e).includes(t)},L=function(e,t){return t instanceof e},P=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Array.isArray(t)&&t.every((function(t){return D(e,t)}))},F=function(e){return!!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))||"number"==typeof e&&13===e.toString().length},q=function(e){return e>0&&O.indexOf(e)>=0},H=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))return!0;var t="object"===m(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},G=function(e){return null==e},j=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,i=t.typingIndicatorInvalidateTime,s=void 0===i?1e4:i,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,d=t.websocketPayloadDecompression,h=void 0===d||d,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=s,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=h}),[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){D("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){D("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){D("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){D("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){D("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}])}(),V={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){return i((function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}),[{key:"_savePreferenceKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:v(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._version=n,this._keysAddress=e,a="".concat(e,".metadata.version"),r.next=5,this._store.get(a);case 5:return i=r.sent,r.next=8,this._store.get(e);case 8:if(r.t1=t=r.sent,r.t0=null!==r.t1,!r.t0){r.next=12;break}r.t0=void 0!==t;case 12:if(!r.t0){r.next=16;break}r.t2=t,r.next=17;break;case 16:r.t2=[];case 17:if(o=r.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},a=n.maxSize,i=void 0===a?256:a,s=n.clearOrder,o=void 0===s?e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT:s,u=n.customClearOrderComparator,c=n.enableAutoResend,l=void 0===c||c;r(this,t),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(i,64),u?(this._clearOrder=o,this._customClearOrderComparator=u):this._clearOrder=e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=l}),[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var t;return this._clearOrder===e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(t=this._customClearOrderComparator)&&void 0!==t?t:this._clearOrderComparatorUseMessageCollectionAccessedAt}},{key:"enableAutoResend",get:function(){return this._enableAutoResend}}])}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(Q||(Q={}));var Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue=function(){return i((function e(){r(this,e),this.isRefreshing=!1}),[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"hasChatServicePermission",get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(Q.CHAT))}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}])}(),ce=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)}))},le=function(){return i((function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=ce()}),[{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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))}}])}(),de=function(){return i((function e(){r(this,e),this._container={}}),[{key:"on",value:function(e,t){return new le({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new le({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],i=s(n.keys());try{for(i.s();!(r=i.n()).done;){var o=r.value,u=n.get(o);u.handler(t),u.occurence>0&&(u.occurence--,0===u.occurence&&a.push(o))}}catch(e){i.e(e)}finally{i.f()}a.forEach((function(e){return n.delete(e)}))}}}])}(),he=function(){return i((function e(){r(this,e),this._dispatcher=new de}),[{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)}}])}(),fe=i((function e(){r(this,e)})),pe=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},ve=function(e){if(null!=e){if("object"===m(e)){if(Array.isArray(e)){for(var t=v(e),n=0;n3&&void 0!==arguments[3]?arguments[3]:"";return r(this,t),(s=n(this,t))._iid=e,s.code=a,s.payload=i,s.requestId=null!==(o=i.req_id)&&void 0!==o?o:u,s}return c(t,e),i(t,[{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,n){var r=n.substring(0,4),a={};try{a=JSON.parse(n.substring(4))}catch(e){r="NOOP"}finally{return new t(e,r,a)}}}])}(fe),We=function(e){function t(e){var a,i,s=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?{}:u;return r(this,t),(a=n(this,t)).code=s,a.payload=c,a.requestId=null!==(i=a.payload.req_id)&&void 0!==i?i:ce(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return c(t,e),i(t,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}])}(fe),Ye=function(e){function t(e){var a,i=e.userId,s=e.authToken,o=e.services,u=e.expiringSession,c=void 0===u||u;return r(this,t),(a=n(this,t)).path="".concat(ge,"/").concat(i,"/session_key"),a.method=_e.POST,a.params=pe({token:s,services:o,expiring_session:!!c}),a.requireAuth=!1,a}return c(t,e),i(t)}(Ve),Ze=function(e){function t(e){var a=e.authToken,i=e.expiringSession,s=void 0===i||i,o=e.requestId,u=void 0===o?void 0:o;return r(this,t),n(this,t,[{code:"LOGI",payload:pe({token:a,expiring_session:s?1:0,req_id:u}),ackRequired:!0}])}return c(t,e),i(t)}(We),Xe=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.key,o=a.expires_at,u=a.services;return i.key=s,i.expiresAt=o,i.services=u,i}return c(t,e),i(t)}(ze),Je=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"LOGI",i])).error=null,s.newKey=null,s.newKey=null!==(o=i.new_key)&&void 0!==o?o:null,s.error=i.error?new A(i):null,s}return c(t,e),i(t)}(Ke),$e=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).statLog=e,a}return c(t,e),i(t)}(fe),et=function(e){function t(e){var a,i=e.request,s=e.deferred,o=e.error,u=void 0===o?A.requestFailed:o;return r(this,t),(a=n(this,t)).request=i,a.deferred=s,a.error=u,a}return c(t,e),i(t)}(fe);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",e.NOTIFICATION="noti:stats",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(je||(je={}));var tt,nt,rt,at=function(){return i((function e(t){var n=t.type,a=t.data,i=t.ts,s=void 0===i?Date.now():i;r(this,e),this.type=n,this.createdAt=s,this.data=a}),null,[{key:"payloadify",value:function(e){return pe({stat_type:e.type,ts:e.createdAt,data:pe(e.data)})}}])}(),it=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},st=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};e.SendbirdProduct=void 0,(tt=e.SendbirdProduct||(e.SendbirdProduct={})).CHAT="chat",tt.CALLS="calls",tt.DESK="desk",tt.LIVE="live",tt.UIKIT_CHAT="uikit-chat",tt.UIKIT_LIVE="uikit-live",e.SendbirdPlatform=void 0,(nt=e.SendbirdPlatform||(e.SendbirdPlatform={})).ANDROID="android",nt.IOS="ios",nt.JS="js",nt.UNREAL="unreal",nt.UNITY="unity",nt.REACT_NATIVE="react-native",nt.FLUTTER="flutter",e.DeviceOsPlatform=void 0,(rt=e.DeviceOsPlatform||(e.DeviceOsPlatform={})).ANDROID="android",rt.IOS="ios",rt.WEB="web",rt.MOBILE_WEB="mobile_web",rt.WINDOWS="windows";var ot=i((function e(){r(this,e)}));ot.sendbirdSdkUserAgentWithExtension=function(t){var n=it()?e.SendbirdPlatform.REACT_NATIVE:e.SendbirdPlatform.JS,r={main_sdk_info:"chat/".concat(n,"/").concat(C.SDK_VERSION),device_os_platform:st()?"mobile-web":"web",os_version:C.OS_VERSION};if(t){var a=t.sendbirdExtensions,i=t.deviceOS,s=t.customData,o=void 0===s?{}:s;i.version&&(r.os_version=i.version),i.platform&&(r.device_os_platform=i.platform),a.length>0&&(r.extension_sdk_info=a.map((function(e){var t=e.product,n=e.platform,r=e.version;return"".concat(t,"/").concat(n,"/").concat(r)})).join(",")),Object.keys(r).forEach((function(e){return delete o[e]})),Object.keys(o).length>0&&(r=Object.assign(Object.assign({},r),o))}return Object.entries(r).map((function(e){var t=f(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join("&")},ot.userAgentWithExtension=function(e){var t=it()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):st()?"omobile-web":"oweb";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)};var ut=i((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=function(e){n(e)}}))})),ct=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).requestId=e.requestId,a}return c(t,e),i(t)}(fe),lt=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),e.messageToken&&(a.params=pe({mesg_token:e.messageToken})),a}return c(t,e),i(t)}(Ve),dt=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"DELM",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(o=i.sender_id)&&void 0!==o?o:void 0,s}return c(t,e),i(t)}(Ke),ht=function(){return i((function e(t,n){var a=this,i=n.session,s=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._session=i,this._sdkState=s,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof Be&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}),[{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,i=n.sendbirdRuntimeEnvironment,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":ot.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":ot.sendbirdSdkUserAgentWithExtension(i)});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(s["Session-Key"]=this._session.sessionKey),s["App-Id"]=r,this._session&&this._session.authToken&&(s["Access-Token"]=this._session.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){e.path.includes("/sdk/statistics")||this._dispatcher.dispatch(new $e(new at({type:je.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:"_isBodyRequired",value:function(e){var t=e.method;return t!==_e.GET&&(t!==_e.DELETE||e instanceof lt)}},{key:"send",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=t.path,a=t.method,i=t.uploadProgressHandler,s=this._isBodyRequired(t),o=this._sdkState.api,u="".concat(o.host).concat(r).concat(s?"":t.query),c=s?t.payload:null,l=this._createHeader(t,c instanceof FormData?c:void 0),h=new AbortController,f=h.signal,this._abortControl.set(t.requestId,h),p=Date.now(),n.prev=10,!i){n.next=32;break}return n.next=14,Promise.resolve().then((function(){return ym}));case 14:return v=n.sent,_=v.xmlHttpRequest,n.prev=16,n.next=19,_(this._iid,{requestId:t.requestId,method:t.method,url:u,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i});case 19:return m=n.sent,this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",m);case 25:if(n.prev=25,n.t0=n.catch(16),!(n.t0 instanceof A&&n.t0.code===e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED)){n.next=31;break}this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),n.next=32;break;case 31:throw n.t0;case 32: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){n.next=36;break}return n.next=36,Promise.resolve().then((function(){return Em}));case 36:if("function"==typeof fetch){n.next=39;break}return n.next=39,Promise.resolve().then((function(){return Qm}));case 39:return n.next=41,fetch(u,{method:a,body:c,headers:l,signal:f});case 41:return g=n.sent,n.next=44,g.json();case 44:if(y=n.sent,!g.ok&&!g.redirected){n.next=51;break}return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",new ze(this._iid,y));case 51:if(!y){n.next=70;break}if(!(E=new A(y)).isSessionExpiredError){n.next=62;break}if(this._dispatcher.dispatch(new Qe({reason:E.code,message:E.message})),t instanceof Ye){n.next=59;break}return k=new ut,this._dispatcher.dispatch(new et({request:t,deferred:k,error:E})),n.abrupt("return",k.promise);case 59:case 67:throw E;case 62:if(!E.isSessionInvalidatedError){n.next=67;break}throw this._dispatcher.dispatch(new Qe({reason:E.code,message:E.message})),E;case 68:n.next=71;break;case 70:throw A.requestFailed;case 71:n.next=87;break;case 73:if(n.prev=73,n.t1=n.catch(10),this._statLogApiResult(t,p,n.t1),!(n.t1 instanceof A)){n.next=81;break}throw this._logger.debug("fail api request",n.t1),n.t1;case 81:if("AbortError"!==(null===n.t1||void 0===n.t1?void 0:n.t1.name)){n.next=85;break}throw A.requestCanceled;case 85:throw this._logger.debug("fail api request",n.t1),A.networkError;case 87:case"end":return n.stop()}}),n,this,[[10,73],[16,25]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new ct({requestId:e}))}},{key:"cancelAll",value:function(){var e,t=s(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(),this._dispatcher.dispatch(new ct({}))}}])}(),ft=function(){};function pt(e){let t=e.length;for(;--t>=0;)e[t]=0}const vt=256,_t=286,mt=30,gt=15,yt=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]),Et=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]),kt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),bt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ct=new Array(576);pt(Ct);const wt=new Array(60);pt(wt);const xt=new Array(512);pt(xt);const St=new Array(256);pt(St);const Tt=new Array(29);pt(Tt);const It=new Array(mt);function Nt(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let At,Mt,Ot;function Ut(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}pt(It);const Dt=e=>e<256?xt[e]:xt[256+(e>>>7)],Rt=(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])},Ft=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},qt=(e,t,n)=>{const r=new Array(16);let a,i,s=0;for(a=1;a<=gt;a++)s=s+n[a-1]<<1,r[a]=s;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=Ft(r[t]++,t))}},Ht=e=>{let t;for(t=0;t<_t;t++)e.dyn_ltree[2*t]=0;for(t=0;t{e.bi_valid>8?Rt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},jt=(e,t,n,r)=>{const a=2*t,i=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,i,s,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?Pt(e,a,t):(i=St[a],Pt(e,i+vt+1,t),s=yt[i],0!==s&&(a-=Tt[i],Lt(e,a,s)),r--,i=Dt(r),Pt(e,i,n),s=Et[i],0!==s&&(r-=It[i],Lt(e,r,s)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,i=t.stat_desc.elems;let s,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)Vt(e,n,s);u=i;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Vt(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,n[2*u]=n[2*s]+n[2*o],e.depth[u]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,n[2*s+1]=n[2*o+1]=u,e.heap[1]=u++,Vt(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,i=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,d,h,f,p,v=0;for(h=0;h<=gt;h++)e.bl_count[h]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],h=n[2*n[2*l+1]+1]+1,h>u&&(h=u,v++),n[2*l+1]=h,l>r||(e.bl_count[h]++,f=0,l>=o&&(f=s[l-o]),p=n[2*l],e.opt_len+=p*(h+f),i&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(h=u-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(h=u;0!==h;h--)for(l=e.bl_count[h];0!==l;)d=e.heap[--c],d>r||(n[2*d+1]!==h&&(e.opt_len+=(h-n[2*d+1])*n[2*d],n[2*d+1]=h),l--)}})(e,t),qt(n,c,e.bl_count)},Qt=(e,t,n)=>{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=s,s=t[2*(r+1)+1],++o{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),r=0;r<=n;r++)if(a=s,s=t[2*(r+1)+1],!(++o{Lt(e,0+(r?1:0),3),Gt(e),Rt(e,n),Rt(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Zt=(e,t,n,r)=>{let a,i,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(Qt(e,e.dyn_ltree,e.l_desc.max_code),Qt(e,e.dyn_dtree,e.d_desc.max_code),Bt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*bt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=a&&(a=i)):a=i=n+5,n+4<=a&&-1!==t?Yt(e,t,n,r):4===e.strategy||i===a?(Lt(e,2+(r?1:0),3),zt(e,Ct,wt)):(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{Wt||((()=>{let e,t,n,r,a;const i=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*(St[n]+vt+1)]++,e.dyn_dtree[2*Dt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Lt(e,2,3),Pt(e,256,Ct),(e=>{16===e.bi_valid?(Rt(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 Jt=(e,t,n,r)=>{let a=65535&e,i=e>>>16&65535,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{a=a+t[r++]|0,i=i+a|0}while(--s);a%=65521,i%=65521}return a|i<<16};const $t=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 en=(e,t,n,r)=>{const a=$t,i=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return~e},tn={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"},nn={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:rn,_tr_stored_block:an,_tr_flush_block:sn,_tr_tally:on,_tr_align:un}=Xt,{Z_NO_FLUSH:cn,Z_PARTIAL_FLUSH:ln,Z_FULL_FLUSH:dn,Z_FINISH:hn,Z_BLOCK:fn,Z_OK:pn,Z_STREAM_END:vn,Z_STREAM_ERROR:_n,Z_DATA_ERROR:mn,Z_BUF_ERROR:gn,Z_DEFAULT_COMPRESSION:yn,Z_FILTERED:En,Z_HUFFMAN_ONLY:kn,Z_RLE:bn,Z_FIXED:Cn,Z_DEFAULT_STRATEGY:wn,Z_UNKNOWN:xn,Z_DEFLATED:Sn}=nn,Tn=258,In=262,Nn=42,An=113,Mn=666,On=(e,t)=>(e.msg=tn[t],t),Un=e=>2*e-(e>4?9:0),Dn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Rn=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))},Fn=(e,t)=>{sn(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Pn(e.strm)},qn=(e,t)=>{e.pending_buf[e.pending++]=t},Hn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Gn=(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=Jt(e.adler,t,a,n):2===e.state.wrap&&(e.adler=en(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},jn=(e,t)=>{let n,r,a=e.max_chain_length,i=e.strstart,s=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-In?e.strstart-(e.w_size-In):0,c=e.window,l=e.w_mask,d=e.prev,h=e.strstart+Tn;let f=c[i+s-1],p=c[i+s];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+s]===p&&c[n+s-1]===f&&c[n]===c[i]&&c[++n]===c[i+1]){i+=2,n++;do{}while(c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&is){if(e.match_start=t,s=r,r>=o)break;f=c[i+s-1],p=c[i+s]}}}while((t=d[t&l])>u&&0!=--a);return s<=e.lookahead?s:e.lookahead},Vn=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-In)&&(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),Rn(e),r+=t),0===e.strm.avail_in)break;if(n=Gn(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,i=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=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,Pn(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&&(Gn(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 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&&(Gn(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,i=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=i||(r||t===hn)&&t!==cn&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,s=t===hn&&0===e.strm.avail_in&&n===r?1:0,an(e,e.block_start,n,s),e.block_start+=n,Pn(e.strm)),s?3:1)},Bn=(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-In&&(e.match_length=jn(e,n)),e.match_length>=3)if(r=on(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=on(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2},Qn=(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=on(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&&(Fn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=on(e,0,e.window[e.strstart-1]),r&&Fn(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=on(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2};function Kn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const Wn=[new Kn(0,0,0,0,zn),new Kn(4,4,8,4,Bn),new Kn(4,5,16,8,Bn),new Kn(4,6,32,32,Bn),new Kn(4,4,16,16,Qn),new Kn(8,16,32,32,Qn),new Kn(8,16,128,128,Qn),new Kn(8,32,128,256,Qn),new Kn(32,128,258,1024,Qn),new Kn(32,258,258,4096,Qn)];function Yn(){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=Sn,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),Dn(this.dyn_ltree),Dn(this.dyn_dtree),Dn(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),Dn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Dn(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 Zn=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!==An&&t.status!==Mn?1:0},Xn=e=>{if(Zn(e))return On(e,_n);e.total_in=e.total_out=0,e.data_type=xn;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:An,e.adler=2===t.wrap?0:1,t.last_flush=-2,rn(t),pn},Jn=e=>{const t=Xn(e);var n;return t===pn&&((n=e.state).window_size=2*n.w_size,Dn(n.head),n.max_lazy_match=Wn[n.level].max_lazy,n.good_match=Wn[n.level].good_length,n.nice_match=Wn[n.level].nice_length,n.max_chain_length=Wn[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},$n=(e,t,n,r,a,i)=>{if(!e)return _n;let s=1;if(t===yn&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),a<1||a>9||n!==Sn||r<8||r>15||t<0||t>9||i<0||i>Cn||8===r&&1!==s)return On(e,_n);8===r&&(r=9);const o=new Yn;return e.state=o,o.strm=e,o.status=Nn,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<$n(e,t,Sn,15,8,wn),deflateInit2:$n,deflateReset:Jn,deflateResetKeep:Xn,deflateSetHeader:(e,t)=>Zn(e)||2!==e.state.wrap?_n:(e.state.gzhead=t,pn),deflate:(e,t)=>{if(Zn(e)||t>fn||t<0)return e?On(e,_n):_n;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Mn&&t!==hn)return On(e,0===e.avail_out?gn:_n);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Pn(e),0===e.avail_out)return n.last_flush=-1,pn}else if(0===e.avail_in&&Un(t)<=Un(r)&&t!==hn)return On(e,gn);if(n.status===Mn&&0!==e.avail_in)return On(e,gn);if(n.status===Nn&&0===n.wrap&&(n.status=An),n.status===Nn){let t=Sn+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=kn||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,Hn(n,t),0!==n.strstart&&(Hn(n,e.adler>>>16),Hn(n,65535&e.adler)),e.adler=1,n.status=An,Pn(e),0!==n.pending)return n.last_flush=-1,pn}if(57===n.status)if(e.adler=0,qn(n,31),qn(n,139),qn(n,8),n.gzhead)qn(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)),qn(n,255&n.gzhead.time),qn(n,n.gzhead.time>>8&255),qn(n,n.gzhead.time>>16&255),qn(n,n.gzhead.time>>24&255),qn(n,9===n.level?2:n.strategy>=kn||n.level<2?4:0),qn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(qn(n,255&n.gzhead.extra.length),qn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=en(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(qn(n,0),qn(n,0),qn(n,0),qn(n,0),qn(n,0),qn(n,9===n.level?2:n.strategy>=kn||n.level<2?4:0),qn(n,3),n.status=An,Pn(e),0!==n.pending)return n.last_flush=-1,pn;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=en(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,Pn(e),0!==n.pending)return n.last_flush=-1,pn;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=en(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=en(e.adler,n.pending_buf,n.pending-r,r)),Pn(e),0!==n.pending)return n.last_flush=-1,pn;r=0}t=n.gzindexr&&(e.adler=en(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=en(e.adler,n.pending_buf,n.pending-r,r)),Pn(e),0!==n.pending)return n.last_flush=-1,pn;r=0}t=n.gzindexr&&(e.adler=en(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&&(Pn(e),0!==n.pending))return n.last_flush=-1,pn;qn(n,255&e.adler),qn(n,e.adler>>8&255),e.adler=0}if(n.status=An,Pn(e),0!==n.pending)return n.last_flush=-1,pn}if(0!==e.avail_in||0!==n.lookahead||t!==cn&&n.status!==Mn){let r=0===n.level?zn(n,t):n.strategy===kn?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Vn(e),0===e.lookahead)){if(t===cn)return 1;break}if(e.match_length=0,n=on(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===bn?((e,t)=>{let n,r,a,i;const s=e.window;for(;;){if(e.lookahead<=Tn){if(Vn(e),e.lookahead<=Tn&&t===cn)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=s[a],r===s[++a]&&r===s[++a]&&r===s[++a])){i=e.strstart+Tn;do{}while(r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=on(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=on(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2})(n,t):Wn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=Mn),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),pn;if(2===r&&(t===ln?un(n):t!==fn&&(an(n,0,0,!1),t===dn&&(Dn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Pn(e),0===e.avail_out))return n.last_flush=-1,pn}return t!==hn?pn:n.wrap<=0?vn:(2===n.wrap?(qn(n,255&e.adler),qn(n,e.adler>>8&255),qn(n,e.adler>>16&255),qn(n,e.adler>>24&255),qn(n,255&e.total_in),qn(n,e.total_in>>8&255),qn(n,e.total_in>>16&255),qn(n,e.total_in>>24&255)):(Hn(n,e.adler>>>16),Hn(n,65535&e.adler)),Pn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?pn:vn)},deflateEnd:e=>{if(Zn(e))return _n;const t=e.state.status;return e.state=null,t===An?On(e,mn):pn},deflateSetDictionary:(e,t)=>{let n=t.length;if(Zn(e))return _n;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==Nn||r.lookahead)return _n;if(1===a&&(e.adler=Jt(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(Dn(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 i=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Vn(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,Vn(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=o,e.avail_in=i,r.wrap=a,pn},deflateInfo:"pako deflate (from Nodeca project)"};const tr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var nr=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)tr(n,t)&&(e[t]=n[t])}}return e},rr=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;ir[254]=ir[254]=1;var sr=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,i,s=e.length,o=0;for(a=0;a>>6,t[i++]=128|63&n):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|63&n):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|63&n);return t},or=(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 i=new Array(2*n);for(a=0,r=0;r4)i[a++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?i[a++]=65533:t<65536?i[a++]=t:(t-=65536,i[a++]=55296|t>>10&1023,i[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&ar)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+ir[e[n]]>t?n:t};var cr=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 lr=Object.prototype.toString,{Z_NO_FLUSH:dr,Z_SYNC_FLUSH:hr,Z_FULL_FLUSH:fr,Z_FINISH:pr,Z_OK:vr,Z_STREAM_END:_r,Z_DEFAULT_COMPRESSION:mr,Z_DEFAULT_STRATEGY:gr,Z_DEFLATED:yr}=nn;function Er(e){this.options=nr({level:mr,method:yr,chunkSize:16384,windowBits:15,memLevel:8,strategy:gr},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 cr,this.strm.avail_out=0;let n=er.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==vr)throw new Error(tn[n]);if(t.header&&er.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?sr(t.dictionary):"[object ArrayBuffer]"===lr.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=er.deflateSetDictionary(this.strm,e),n!==vr)throw new Error(tn[n]);this._dict_set=!0}}function kr(e,t){const n=new Er(t);if(n.push(e,!0),n.err)throw n.msg||tn[n.err];return n.result}Er.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,i;if(this.ended)return!1;for(i=t===~~t?t:!0===t?pr:dr,"string"==typeof e?n.input=sr(e):"[object ArrayBuffer]"===lr.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),(i===hr||i===fr)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=er.deflate(n,i),a===_r)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=er.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===vr;if(0!==n.avail_out){if(i>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},Er.prototype.onData=function(e){this.chunks.push(e)},Er.prototype.onEnd=function(e){e===vr&&(this.result=rr(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var br={Deflate:Er,deflate:kr,deflateRaw:function(e,t){return(t=t||{}).raw=!0,kr(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,kr(e,t)},constants:nn};const Cr=16209;var wr=function(e,t){let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x;const S=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,i=a-(t-e.avail_out),s=a+(e.avail_out-257),o=S.dmax,u=S.wsize,c=S.whave,l=S.wnext,d=S.window,h=S.hold,f=S.bits,p=S.lencode,v=S.distcode,_=(1<>>24,h>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(64&y){if(32&y){S.mode=16191;break e}e.msg="invalid literal/length code",S.mode=Cr;break e}g=p[(65535&g)+(h&(1<>>=y,f-=y),f<15&&(h+=w[n++]<>>24,h>>>=y,f-=y,y=g>>>16&255,16&y){if(k=65535&g,y&=15,fo){e.msg="invalid distance too far back",S.mode=Cr;break e}if(h>>>=y,f-=y,y=a-i,k>y){if(y=k-y,y>c&&S.sane){e.msg="invalid distance too far back",S.mode=Cr;break e}if(b=0,C=d,0===l){if(b+=u-y,y2;)x[a++]=C[b++],x[a++]=C[b++],x[a++]=C[b++],E-=3;E&&(x[a++]=C[b++],E>1&&(x[a++]=C[b++]))}else{b=a-k;do{x[a++]=x[b++],x[a++]=x[b++],x[a++]=x[b++],E-=3}while(E>2);E&&(x[a++]=x[b++],E>1&&(x[a++]=x[b++]))}break}if(64&y){e.msg="invalid distance code",S.mode=Cr;break e}g=v[(65535&g)+(h&(1<>3,n-=E,f-=E<<3,h&=(1<{const u=o.bits;let c,l,d,h,f,p,v=0,_=0,m=0,g=0,y=0,E=0,k=0,b=0,C=0,w=0,x=null;const S=new Uint16Array(16),T=new Uint16Array(16);let I,N,A,M=null;for(v=0;v<=xr;v++)S[v]=0;for(_=0;_=1&&0===S[g];g--);if(y>g&&(y=g),0===g)return a[i++]=20971520,a[i++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(T[1]=0,v=1;v852||2===e&&C>592)return 1;for(;;){I=v-k,s[_]+1=p?(N=M[s[_]-p],A=x[s[_]-p]):(N=96,A=0),c=1<>k)+l]=I<<24|N<<16|A}while(0!==l);for(c=1<>=1;if(0!==c?(w&=c-1,w+=c):w=0,_++,0==--S[v]){if(v===g)break;v=t[n+s[_]]}if(v>y&&(w&h)!==d){for(0===k&&(k=y),f+=m,E=v-k,b=1<852||2===e&&C>592)return 1;d=w&h,a[d]=y<<24|E<<16|f-i}}return 0!==w&&(a[f+w]=v-k<<24|64<<16),o.bits=y,0};const{Z_FINISH:Mr,Z_BLOCK:Or,Z_TREES:Ur,Z_OK:Dr,Z_STREAM_END:Rr,Z_NEED_DICT:Lr,Z_STREAM_ERROR:Pr,Z_DATA_ERROR:Fr,Z_MEM_ERROR:qr,Z_BUF_ERROR:Hr,Z_DEFLATED:Gr}=nn,jr=16180,Vr=16190,zr=16191,Br=16192,Qr=16194,Kr=16199,Wr=16200,Yr=16206,Zr=16209,Xr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Jr(){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},ea=e=>{if($r(e))return Pr;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=jr,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,Dr},ta=e=>{if($r(e))return Pr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ea(e)},na=(e,t)=>{let n;if($r(e))return Pr;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Pr:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,ta(e))},ra=(e,t)=>{if(!e)return Pr;const n=new Jr;e.state=n,n.strm=e,n.window=null,n.mode=jr;const r=na(e,t);return r!==Dr&&(e.state=null),r};let aa,ia,sa=!0;const oa=e=>{if(sa){aa=new Int32Array(512),ia=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(Ar(1,e.lens,0,288,aa,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Ar(2,e.lens,0,32,ia,0,e.work,{bits:5}),sa=!1}e.lencode=aa,e.lenbits=9,e.distcode=ia,e.distbits=5},ua=(e,t,n,r)=>{let a;const i=e.state;return null===i.window&&(i.wsize=1<=i.wsize?(i.window.set(t.subarray(n-i.wsize,n),0),i.wnext=0,i.whave=i.wsize):(a=i.wsize-i.wnext,a>r&&(a=r),i.window.set(t.subarray(n-r,n-r+a),i.wnext),(r-=a)?(i.window.set(t.subarray(n-r,n),0),i.wnext=r,i.whave=i.wsize):(i.wnext+=a,i.wnext===i.wsize&&(i.wnext=0),i.whavera(e,15),inflateInit2:ra,inflate:(e,t)=>{let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w=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($r(e)||!e.output||!e.input&&0!==e.avail_in)return Pr;n=e.state,n.mode===zr&&(n.mode=Br),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,d=o,h=u,C=Dr;e:for(;;)switch(n.mode){case jr:if(0===n.wrap){n.mode=Br;break}for(;l<16;){if(0===o)break e;o--,c+=r[i++]<>>8&255,n.check=en(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=Zr;break}if((15&c)!==Gr){e.msg="unknown compression method",n.mode=Zr;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=Zr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=en(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[i++]<>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=en(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[i++]<>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=en(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[i++]<>>8&255,n.check=en(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(i,i+f),b)),512&n.flags&&4&n.wrap&&(n.check=en(n.check,r,f,i)),o-=f,i+=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[i+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=zr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[i++]<>>=7&l,l-=7&l,n.mode=Yr;break}for(;l<3;){if(0===o)break e;o--,c+=r[i++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(oa(n),n.mode=Kr,t===Ur){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Zr}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[i++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Zr;break}if(n.length=65535&c,c=0,l=0,n.mode=Qr,t===Ur)break e;case Qr: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(i,i+f),s),o-=f,i+=f,u-=f,s+=f,n.length-=f;break}n.mode=zr;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[i++]<>>=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=Zr;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},C=Ar(0,n.lens,0,19,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid code lengths set",n.mode=Zr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=_,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=Zr;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=Zr;break}for(;f--;)n.lens[n.have++]=b}}if(n.mode===Zr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Zr;break}if(n.lenbits=9,S={bits:n.lenbits},C=Ar(1,n.lens,0,n.nlen,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid literal/lengths set",n.mode=Zr;break}if(n.distbits=6,n.distcode=n.distdyn,S={bits:n.distbits},C=Ar(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,S),n.distbits=S.bits,C){e.msg="invalid distances set",n.mode=Zr;break}if(n.mode=Kr,t===Ur)break e;case Kr:n.mode=Wr;case Wr:if(o>=6&&u>=258){e.next_out=s,e.avail_out=u,e.next_in=i,e.avail_in=o,n.hold=c,n.bits=l,wr(e,h),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===zr&&(n.back=-1);break}for(n.back=0;w=n.lencode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=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=zr;break}if(64&m){e.msg="invalid literal/length code",n.mode=Zr;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(;w=n.distcode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=Zr;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=Zr;break}n.mode=16204;case 16204:if(0===u)break e;if(f=h-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Zr;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=s-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[s++]=v[p++]}while(--f);0===n.length&&(n.mode=Wr);break;case 16205:if(0===u)break e;a[s++]=n.length,u--,n.mode=Wr;break;case Yr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[i++]<{if($r(e))return Pr;let t=e.state;return t.window&&(t.window=null),e.state=null,Dr},inflateGetHeader:(e,t)=>{if($r(e))return Pr;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Dr):Pr},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,i;return $r(e)?Pr:(r=e.state,0!==r.wrap&&r.mode!==Vr?Pr:r.mode===Vr&&(a=1,a=Jt(a,t,n,0),a!==r.check)?Fr:(i=ua(e,t,n,n),i?(r.mode=16210,qr):(r.havedict=1,Dr)))},inflateInfo:"pako inflate (from Nodeca project)"};var la=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 da=Object.prototype.toString,{Z_NO_FLUSH:ha,Z_FINISH:fa,Z_OK:pa,Z_STREAM_END:va,Z_NEED_DICT:_a,Z_STREAM_ERROR:ma,Z_DATA_ERROR:ga,Z_MEM_ERROR:ya}=nn;function Ea(e){this.options=nr({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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new cr,this.strm.avail_out=0;let n=ca.inflateInit2(this.strm,t.windowBits);if(n!==pa)throw new Error(tn[n]);if(this.header=new la,ca.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=sr(t.dictionary):"[object ArrayBuffer]"===da.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ca.inflateSetDictionary(this.strm,t.dictionary),n!==pa)))throw new Error(tn[n])}function ka(e,t){const n=new Ea(t);if(n.push(e),n.err)throw n.msg||tn[n.err];return n.result}Ea.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let i,s,o;if(this.ended)return!1;for(s=t===~~t?t:!0===t?fa:ha,"[object ArrayBuffer]"===da.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),i=ca.inflate(n,s),i===_a&&a&&(i=ca.inflateSetDictionary(n,a),i===pa?i=ca.inflate(n,s):i===ga&&(i=_a));n.avail_in>0&&i===va&&n.state.wrap>0&&0!==e[n.next_in];)ca.inflateReset(n),i=ca.inflate(n,s);switch(i){case ma:case ga:case _a:case ya:return this.onEnd(i),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||i===va))if("string"===this.options.to){let e=ur(n.output,n.next_out),t=n.next_out-e,a=or(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(i!==pa||0!==o){if(i===va)return i=ca.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Ea.prototype.onData=function(e){this.chunks.push(e)},Ea.prototype.onEnd=function(e){e===pa&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=rr(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ba={Inflate:Ea,inflate:ka,inflateRaw:function(e,t){return(t=t||{}).raw=!0,ka(e,t)},ungzip:ka,constants:nn};const{Deflate:Ca,deflate:wa,deflateRaw:xa,gzip:Sa}=br,{Inflate:Ta,inflate:Ia,inflateRaw:Na,ungzip:Aa}=ba;var Ma,Oa={Deflate:Ca,deflate:wa,deflateRaw:xa,gzip:Sa,Inflate:Ta,inflate:Ia,inflateRaw:Na,ungzip:Aa,constants:nn},Ua=function(e){return E(void 0,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Oa.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,n));case 2:case"end":return t.stop()}}),t)})))};e.ConnectionState=void 0,(Ma=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",Ma.OPEN="OPEN",Ma.CLOSED="CLOSED";var Da,Ra=function(t){function a(e,t){var i,s=t.sdkState,o=t.dispatcher,u=t.logger;return r(this,a),(i=n(this,a)).lastActive=0,i._iid=e,i._sdkState=s,i._dispatcher=o,i._logger=u,i}return c(a,t),i(a,[{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:"ws",get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ke.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 Qe(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return E(this,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){r._logger.debug("websocket open"),r.dispatch("open")},this._ws.onmessage=function(e){return E(r,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)){t.next=38;break}if(!(e.data instanceof Blob)){t.next=7;break}(r=new FileReader).readAsArrayBuffer(e.data),r.onloadend=function(){return E(u,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Ua(r.result);case 3:t=e.sent,this._handleMessage(t),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),this.error(e.t0);case 10:case"end":return e.stop()}}),e,this,[[0,7]])})))},t.next=36;break;case 7:if(!(e.data instanceof ArrayBuffer)){t.next=20;break}return t.prev=8,t.next=11,Ua(new Uint8Array(e.data));case 11:a=t.sent,this._handleMessage(a),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),this.error(t.t0);case 18:t.next=36;break;case 20:if(!("undefined"!=typeof Buffer&&e.data instanceof Buffer)){t.next=35;break}return t.prev=21,i=e.data,s=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),t.next=26,Ua(s);case 26:o=t.sent,this._handleMessage(o),t.next=33;break;case 30:t.prev=30,t.t1=t.catch(21),this.error(t.t1);case 33:t.next=36;break;case 35:"string"==typeof e.data&&this._handleMessage(e.data);case 36:t.next=39;break;case 38:this._handleMessage(e.data);case 39:case"end":return t.stop()}}),t,this,[[8,15],[21,30]])})))},this._ws.onerror=function(){r._logger.debug("websocket error"),r.dispatch("error",A.networkError)},this._ws.onclose=function(){r._logger.debug("websocket close"),r.dispatch("close")},this.lastActive=Date.now();case 6:case"end":return n.stop()}}),n,this)})))}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws?(t._ws.onopen=ft,t._ws.onmessage=ft,t._ws.onerror=ft,t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=void 0):n()):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)}}])}(de),La=function(e){function t(e){var a,i=e.all,s=e.feed,o=e.custom_types,u=e.ts;return r(this,t),(a=n(this,t)).all=i,a.feed=s,a.customTypes=o,a.ts=u,a}return c(t,e),i(t)}(fe),Pa=function(){return i((function e(t,n){var a=this,i=n.session,s=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=s,this._dispatcher=o,this._logger=u,this.apiClient=new ht(t,{session:i,sdkState:s,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new Ra(t,{sdkState:s,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new La(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()}))}),[{key:"_sendApiRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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(n=new ut,e.ackRequired){a=function(t,a){i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),r&&(clearTimeout(r),r=null),t?(i._logger.debug("fail websocket request",e.requestId,t),n.reject(t)):(i._logger.debug("receive websocket ack",e.requestId,e),i._logger.debug("receive websocket ack",a),n.resolve(a)))};try{r=setTimeout((function(){return a(A.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return a(void 0,e)},reject:function(e){return a(e)}}),this.websocketClient.send(e)}catch(e){a(e)}}else try{this.websocketClient.send(e),n.resolve()}catch(e){n.reject(e)}return t.abrupt("return",n.promise);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ve)){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 We)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw A.invalidParameters;case 11:case"end":return t.stop()}}),t,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}])}();!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"}(Da||(Da={}));var Fa,qa,Ha=function(e){function t(e){var a,i=e.stateType;return r(this,t),(a=n(this,t)).stateType=i,a}return c(t,e),i(t)}(fe),Ga=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),ja=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Va=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),za=function(){return i((function e(t){var n,a,i,s;r(this,e),this.isEnabled=null!==(n=t.enabled)&&void 0!==n&&n,this.feedChannels=null!==(a=t.feed_channels)&&void 0!==a?a:{},this.templateListToken=null!==(i=t.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(s=t.settings_updated_at)&&void 0!==s?s:0}),null,[{key:"payloadify",value:function(e){return pe(ve({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}])}(),Ba=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},Qa=function(){return i((function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}),null,[{key:"payloadify",value:function(e){return pe(ve({last_updated_at:e.lastUpdatedAt}))}}])}(),Ka=function(){return i((function e(t){var n;r(this,e),this.token=null!==(n=t.template_list_token)&&void 0!==n?n:""}),null,[{key:"payloadify",value:function(e){return pe(ve({template_list_token:e.token}))}}])}(),Wa=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180};r(this,e),this.minStatCount=t.min_stat_count,this.minInterval=1e3*t.min_interval,this.maxStatCountPerRequest=t.max_stat_count_per_request,this.lowerThreshold=t.lower_threshold,this.requestDelayRange=1e3*t.request_delay_range}),null,[{key:"payloadify",value:function(e){return pe(ve({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}])}(),Ya=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}};r(this,e),this.default=new Wa(t.default),this.realTime=new Wa(t.realtime)}),null,[{key:"payloadify",value:function(e){return pe(ve({default:Wa.payloadify(e.default),realtime:Wa.payloadify(e.realTime)}))}}])}(),Za=1048576;e.UnreadCountThreadingPolicy=void 0,(Fa=e.UnreadCountThreadingPolicy||(e.UnreadCountThreadingPolicy={}))[Fa.NONE=0]="NONE",Fa[Fa.INCLUDE_REPLY=1]="INCLUDE_REPLY",Fa[Fa.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Fa[Fa.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",e.LastMessageThreadingPolicy=void 0,(qa=e.LastMessageThreadingPolicy||(e.LastMessageThreadingPolicy={}))[qa.NONE=0]="NONE",qa[qa.INCLUDE_REPLY=1]="INCLUDE_REPLY",qa[qa.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",qa[qa.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";var Xa,Ja=function(){return i((function t(){var n,a,i,s,o,u,c,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),this.emojiHash=l.emoji_hash||"",this.uploadSizeLimit=l.file_upload_size_limit?l.file_upload_size_limit*Za:Number.MAX_SAFE_INTEGER,this.useReaction=!!l.use_reaction,this.applicationAttributes=null!==(n=l.application_attributes)&&void 0!==n?n:[],this.premiumFeatureList=null!==(a=l.premium_feature_list)&&void 0!==a?a:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(i=l.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(s=l.allow_sdk_log_ingestion)||void 0===s||s,this.unreadCountThreadingPolicy=null!==(o=l.unread_cnt_threading_policy)&&void 0!==o?o:e.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(u=l.last_msg_threading_policy)&&void 0!==u?u:e.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new Qa(null!==(c=l.uikit_config)&&void 0!==c?c:{}),this.notificationInfo=l.notifications?new za(l.notifications):null,this.messageTemplateInfo=l.message_template?new Ka(l.message_template):null,this.statConfigInfo=l.log_publish_config?new Ya(l.log_publish_config):new Ya}),null,[{key:"payloadify",value:function(e){return pe(ve({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Za,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?Qa.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?za.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Ka.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Ya.payloadify(e.statConfigInfo):null}))}}])}(),$a=function(){return i((function e(t){r(this,e),this._iid="",this._iid=t}),null,[{key:"payloadify",value:function(e){return{}}}])}(),ei=function(e){function t(e){var a,i=e.userId,s=e.metadata;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s},a}return c(t,e),i(t)}(Ve),ti=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaData=a,i}return c(t,e),i(t)}(ze),ni=function(e){function t(e){var a,i=e.userId,s=e.metadata,o=e.upsert;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s,upsert:o},a}return c(t,e),i(t)}(Ve),ri=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metadata=a,i}return c(t,e),i(t)}(ze),ai=function(e){function t(e){var a,i=e.userId,s=e.metadataKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata/").concat(s),a}return c(t,e),i(t)}(Ve),ii=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata"),a}return c(t,e),i(t)}(Ve),si=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},oi=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ui=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(Xa=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",Xa.OFFLINE="offline",Xa.NON_AVAILABLE="nonavailable";var ci,li=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y;return r(this,a),(s=n(this,a,[t])).userId=null!==(u=null!==(o=i.guest_id)&&void 0!==o?o:i.user_id)&&void 0!==u?u:"",s.nickname=null!==(l=null!==(c=i.nickname)&&void 0!==c?c:i.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(h=null!==(d=i.profile_url)&&void 0!==d?d:i.image)&&void 0!==h?h:"",s.requireAuth=null!==(f=i.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=i.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,R(e.UserOnlineState,i.is_online)?s.connectionStatus=i.is_online:D("boolean",i.is_online)&&(s.connectionStatus=i.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(_=i.is_active)||void 0===_||_,s.lastSeenAt=null!==(m=i.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=i.preferred_languages?v(i.preferred_languages):null,s.friendDiscoveryKey=null!==(g=i.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=i.friend_name)&&void 0!==y?y:null,s}return c(a,t),i(a,[{key:"profileUrl",get:function(){var e=ss.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return si(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 D("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,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(this._isValidMetaData(e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ei({userId:r.userId,metadata:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(ti),u=o.metaData,this._applyMetaData(u),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(this._isValidMetaData(e)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new ni({userId:a.userId,metadata:e,upsert:t}),n.next=5,i.send(s);case 5:return o=n.sent,u=o.as(ri),c=u.metadata,this._applyMetaData(c),n.abrupt("return",this.metaData);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ai({userId:r.userId,metadataKey:e}),t.next=5,a.send(i);case 5:return this._applyMetaData((s={},u=!0,(o=_(o=e))in s?Object.defineProperty(s,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):s[o]=u,s),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var s,o,u}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ii({userId:n.userId}),e.next=4,r.send(a);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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})))}}])}($a),di=function(e){function t(e){var a,i=e.userProfile;return r(this,t),(a=n(this,t)).userProfile=i,a}return c(t,e),i(t)}(fe),hi=function(){return i((function e(t,n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new Ja(n),this.user=new li(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=n.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(s=n.pong_timeout)&&void 0!==s?s: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!==(h=null===(d=n.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==h?h: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}),[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=ss.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 di({userProfile:this}))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign(Object.assign({},li.payloadify(e.user)),Ja.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})))}}])}(),fi=function(e){function t(e){var a,i=e.request,s=void 0===i||i,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c,d=e.statConfigInfo;return r(this,t),(a=n(this,t)).request=s,a.features=Object.assign({localCache:!0,notification:!0},u),a.options=Object.assign({ingestion:!0},l),a.statConfigInfo=d,a}return c(t,e),i(t)}(fe),pi=function(e){function t(e,a,i){var s,o,u,c,l;return r(this,t),(s=n(this,t,[e,a,i])).error=null,s.services=[],s.userProfile=new hi(e,i),s.deviceTokenLastDeletedAt=null!==(o=i.device_token_last_deleted_at)&&void 0!==o?o:0,s.key=null!==(u=i.key)&&void 0!==u?u:"",s.ekey=null!==(c=i.ekey)&&void 0!==c?c:"",s.error=i.error?new A(i):null,s.services=null!==(l=i.services)&&void 0!==l?l:[],s}return c(t,e),i(t,[{key:"applyTo",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=13;break}if(!(n=ss.of(e))){t.next=10;break}return r=n.sessionManager,a=n.dispatcher,t.next=6,r.login(this);case 6:this.userProfile.apply(),a.dispatch(new fi({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),t.next=11;break;case 10:throw A.lostInstance;case 11:t.next=14;break;case 13:throw this.error;case 14:case"end":return t.stop()}}),t,this)})))}}],[{key:"asError",value:function(e){return new t("","LOGI",Object.assign({user_id:"",error:!0},e))}}])}(Ke),vi=function(){return i((function e(){r(this,e),this.type=Da.NONE,this.name="none"}),[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,t){return t.resetReconnectCount,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,t){return t.error,t.autoReconnect,t.cause,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}(),_i=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=12;break;case 5:if(t.prev=5,t.t0=t.catch(0),!(t.t0 instanceof A)){t.next=11;break}t.t0.throwOutside(),t.next=12;break;case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,null,[[0,5]])})))},mi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=7;break;case 5:t.prev=5,t.t0=t.catch(0);case 7:case"end":return t.stop()}}),t,null,[[0,5]])})))},gi=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t)).type=Da.LOGOUT,e.name="logout",e._wasPreviouslyConnected=null===(a=i.wasPreviouslyConnected)||void 0===a||a,e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=e.sdkState.userId,t.next=4,e.logout();case 4:return t.next=6,e.changeState(new Ai,n);case 6:this._wasPreviouslyConnected&&_i((function(){return E(a,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(r)}));case 1:case"end":return t.stop()}}),t)})))}));case 7:case"end":return t.stop()}}),t,this)})))}}])}(vi),yi=function(e){function t(){var e;return r(this,t),(e=n(this,t)).type=Da.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),t)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ti({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new wi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new gi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(vi),Ei=function(e){function t(e){var a,i=e.autoReconnect;return r(this,t),(a=n(this,t)).type=Da.INTERNAL_DISCONNECTED,a.name="internaldisconnected",a._autoReconnect=!1,a._autoReconnect=i,a}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new wi,n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ti({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new wi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new yi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new gi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(vi),ki=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),t)})))},bi=function(){return i((function e(){r(this,e)}),[{key:"calcTimeout",value:function(){return 0}}])}(),Ci=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new bi;return E(void 0,void 0,void 0,d().mark((function r(){var a,i,s,o,u;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=0,i=null,s=function(e){return i=null!=e?e:new Error("Halted")},o=function(){a=0};case 4:if(!(-1===t||a0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,e&&(this._webSocketClosedCause=ci.ExternalDisconnectWebSocket),t.next=4,n.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause});case 4:case"end":return t.stop()}}),t,this)})))}},{key:"logout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),t.next=4,n.onLogout(this._context,e);case 4:case"end":return t.stop()}}),t,this)})))}}])}(),Ti=function(t){function a(e){var t,i=e.authToken;return r(this,a),(t=n(this,a)).type=Da.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=i,t}return c(a,t),i(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(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ut,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,Ci((function(n){return E(i,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._haltConnect=n,r.prev=1,r.next=4,t.connect(this._authToken);case 4:r.next=16;break;case 6:if(r.prev=6,r.t0=r.catch(1),t.clearLoginTimer(),!(r.t0 instanceof A)){r.next=15;break}r.t1=r.t0.code,r.next=r.t1===e.SendbirdErrorCode.CONNECTION_CANCELED?13:15;break;case 13:return n(r.t0),r.abrupt("return");case 15:throw r.t0;case 16:case"end":return r.stop()}}),r,this,[[1,6]])})))}),t.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,t.changeState(new xi,r);case 8:_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(),t.connectionHandlers.forEach((function(e){e.onConnected&&e.onConnected(t.sdkState.userId)}));case 2:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),N(n.t0)){n.next=23;break}return n.next=16,t.disconnect();case 16:if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===e.SendbirdErrorCode.CONNECTION_CANCELED){n.next=20;break}return n.next=20,t.changeState(new Ai,r);case 20:_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new ut,this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){var n=t.error,r=void 0===n?null:n,a=t.autoReconnect,i=void 0!==a&&a,s=t.cause,o=void 0===s?null:s;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Date.now(),this._halt(null!=r?r:Ii(o)),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Ei({autoReconnect:i}),n);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new gi,n);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._halt(Ii((null==t?void 0:t.cause)||null)),r=Date.now(),!e.hasSession){n.next=7;break}return n.next=5,e.changeState(new yi,r);case 5:n.next=9;break;case 7:return n.next=9,e.changeState(new gi,r);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),this._halt(null!=t?t:A.connectionCanceled),n.next=4,e.changeState(new gi,r);case 4:case"end":return n.stop()}}),n,this)})))}}])}(vi);function Ii(e){var t=A.connectionCanceled;if(e){var n=null;switch(e){case ci.ExternalSetBackground:n="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case ci.ExternalDisconnectWebSocket:n="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}n&&t.setDetail(n)}return t}var Ni,Ai=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).type=Da.INITIALIZED,e.name="initialized",e}return c(t,e),i(t,[{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.changeState(new Ti({authToken:t}),r);case 3:case"end":return n.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new gi({wasPreviouslyConnected:!1}),n);case 3:case"end":return t.stop()}}),t)})))}}])}(vi),Mi=function(e){function t(){return r(this,t),n(this,t,[{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1}])}return c(t,e),i(t)}(We),Oi=function(){return i((function e(t){var n=t.pingDelegate,a=t.sdkState,i=t.logger;r(this,e),this.pingDelegate=n,this.sdkState=a,this._logger=i}),[{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 Mi;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)}}])}(),Ui=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"],Di=function(e){function t(e,a){var i,s,o=a.sdkState,u=a.cacheContext,c=a.connectionHandlers,l=a.sessionManager,d=a.websocketClient,h=a.dispatcher,f=a.logger,p=a.entryState,v=void 0===p?new Ai:p;return r(this,t),(i=n(this,t))._stateUpdatedAt=0,i._connectingAt=0,i._connectedAt=0,i._logiReceivedAt=0,i._connectionRequestQueue=[],i._iid=e,i.sdkState=o,i.cacheContext=u,i.connectionHandlers=c,i._sessionManager=l,i._websocketClient=d,i._dispatcher=h,i._logger=f,i._currentState=v,(null===(s=i.sdkState.websocket)||void 0===s?void 0:s.pingerDisabled)||(i._pinger=new Oi({pingDelegate:{send:function(e){return i._websocketClient.send(e)},error:function(e){return i._websocketClient.error(e)}},sdkState:i.sdkState,logger:f})),i._websocketClient.on("open",(function(){i._connectedAt=Date.now(),i._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)i.clearLoginTimer(),i._dispatcher.dispatch(e.as(pi))})).on("ping-refresh",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){i._logiProcessingTimer=setTimeout((function(){i._logiProcessingTimer=void 0,i._unresolvedLogi||i._rejectConnectionRequest(A.networkError)}),500)})),i._dispatcher.on((function(e){e instanceof pi&&(i._unresolvedLogi=e,i._tryResolveConnectionRequest())})),i}return c(t,e),i(t,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.session.hasSession}},{key:"changeState",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>=this._stateUpdatedAt)){n.next=8;break}return this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Ha({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),n.next=7,this._currentState.run(this);case 7:return n.abrupt("return",!0);case 8:return n.abrupt("return",!1);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._unresolvedLogi,!this._websocketClient.isOpen||!n){t.next=17;break}if(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),n.error){t.next=14;break}return t.next=7,n.applyTo(this._iid);case 7: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=17;break;case 14:this._sessionManager.session.authToken=void 0,n.error.isSessionExpiredError||n.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Qe({reason:n.error.code,message:n.error.message})):this._logger.warn("login failed: ".concat(n.error)),this._rejectConnectionRequest(n.error);case 17:case"end":return t.stop()}}),t,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=this.sdkState,n=t.appId,r=t.appVersion,a=t.userId,i=t.extensions,s=t.sendbirdRuntimeEnvironment,o=this.cacheContext.localCacheEnabled,u=this._sessionManager.session,c=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=i?i:{}).sb_uikit,d=ot.userAgentWithExtension(i);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(u.hasSession?"":"&user_id=".concat(encodeURIComponent(a)),"&pmce=").concat(c?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent(ot.sendbirdSdkUserAgentWithExtension(s)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(Ui))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new $e(new at({type:je.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:this._connectedAt>0?this._connectedAt-this._connectingAt:0,logi_latency:this._logiReceivedAt>0?this._logiReceivedAt-this._connectedAt:void 0,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(A.connectionCanceled)),r=new ut,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout((function(){s._loginTimer=void 0,s._rejectConnectionRequest(A.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),a=this._sessionManager.session,t&&(a.authToken=t,a.sessionKey=void 0),i=this._url(),a.sessionKey||a.authToken?this._websocketClient.connect(i,JSON.stringify(a.hasSession?{auth:a.sessionKey}:{token:a.authToken})):this._websocketClient.connect(i,JSON.stringify({}))),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(pi.asError(A.connectionRenew))}},{key:"disconnect",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){return d().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.disconnect();case 4:return e.next=6,this._sessionManager.clear();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}])}(de),Ri=function(e){function t(e){var a,i=e.appId,s=e.userId,o=e.includeUIKitConfig,u=void 0!==o&&o,c=e.localCacheEnabled,l=void 0===c||c,d=e.expiringSession,h=void 0===d||d;return r(this,t),(a=n(this,t)).path="".concat(ye,"/").concat(s,"/authentication"),a.method=_e.POST,a.params=pe({expiring_session:!!h,include_logi:!0,include_extra_data:String(Ui),uikit_config:u,use_local_cache:l,app_id:i}),a.requireAuth=!1,a}return c(t,e),i(t)}(Ve),Li=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).logi=new pi(e,"LOGI",a),i}return c(t,e),i(t)}(ze);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(Ni||(Ni={}));var Pi,Fi,qi=[Ye,Ri],Hi=function(){return i((function e(t,n){var a=this,i=n.session,o=n.sdkState,u=n.dispatcher,c=n.logger,l=n.useFetchCompat,d=void 0!==l&&l;r(this,e),this._currentConnectionStateType=Da.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Pa(t,{session:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:d}),this._session=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){var t;if(e instanceof Ha){var n=e.stateType;switch(a._currentConnectionStateType=n,n){case Da.CONNECTED:a._resolveLazyCallQueue();break;case Da.INITIALIZED:case Da.INTERNAL_DISCONNECTED:case Da.EXTERNAL_DISCONNECTED:case Da.LOGOUT:a._rejectLazyCallQueue((null===(t=a._session)||void 0===t?void 0:t.hasSession)?A.connectionClosed:A.connectionRequired)}}else if(e instanceof Ga)a._session.hasChatServicePermission||a._resolveLazyCallQueue(Ni.API);else if(e instanceof ja||e instanceof Va)a._rejectLazyCallQueue(A.connectionClosed);else if(e instanceof et){var r,i=e.request,o=e.deferred,u=e.error,c=s(qi);try{for(c.s();!(r=c.n()).done;){if(i instanceof r.value)return void o.reject(u)}}catch(e){c.e(e)}finally{c.f()}a._lazyCallQueue.push({command:i,deferred:o})}}))}),[{key:"isReady",get:function(){return this._currentConnectionStateType===Da.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===Da.CONNECTING||this._currentConnectionStateType===Da.RECONNECTING||this._session.isRefreshing}},{key:"_classifyLazyCallQueueByScope",value:function(e){var t,n=[],r=[];switch(e){case Ni.ALL:t=null;break;case Ni.WEBSOCKET:t=We;break;case Ni.API:t=Ve}var a=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(a=!0),a?r.push(e):n.push(e)})),[n,r]}},{key:"_resolveLazyCallQueue",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ni.ALL,n=f(this._classifyLazyCallQueueByScope(t),2),r=n[0],a=n[1];this._lazyCallQueue=a,r.forEach((function(t){return E(e,void 0,void 0,d().mark((function e(){var n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.command,r=t.deferred,(a=t.timeout)&&clearTimeout(a),e.prev=2,e.next=5,this.send(n);case 5:i=e.sent,r.resolve(i),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),r.reject(e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])})))}))}},{key:"_rejectLazyCallQueue",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ni.ALL,r=f(this._classifyLazyCallQueueByScope(n),2),a=r[0],i=r[1];this._lazyCallQueue=i,a.forEach((function(n){return E(t,void 0,void 0,d().mark((function t(){var r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n.deferred,a=n.timeout,clearTimeout(a),r.reject(e);case 3:case"end":return t.stop()}}),t)})))}))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof We)){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:case 31:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),n=new ut,this._lazyCallQueue.push({command:e,deferred:n,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",n.promise);case 15:throw this._logger.debug("fail websocket request"),A.connectionRequired;case 17:case 44:t.next=47;break;case 19:if(!(e instanceof Ve)){t.next=46;break}if(!this._session.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!e.hasSessionKey){t.next=34;break}return this._logger.debug("send api request with tmp session key",e),t.next=31,this.commandRouter.send(e);case 34:if(!this.isLazyCallActivated){t.next=41;break}return this._logger.debug("wait api request",e),r=new ut,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 41:throw a=A.connectionRequired,this._logger.debug("fail api request",a),a;case 46:throw A.invalidCommand;case 47:case"end":return t.stop()}}),t,this)})))}},{key:"forceSend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._logger.debug("send forced request",e),!(e instanceof We||e instanceof Ve)){t.next=7;break}return t.next=4,this.commandRouter.send(e);case 4:return t.abrupt("return",t.sent);case 7:throw A.invalidCommand;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(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()}}])}(),Gi="sendbird@devicetokens",ji=function(){return i((function e(t){var n=t.type,a=t.token,i=t.device_os,s=t.device_manufacturer,o=t.system_push_enabled;r(this,e),this.type=n,this.token=a,this.deviceOS=i,this.deviceManufacturer=s,this.systemPushEnabled=o}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}])}(),Vi=new WeakMap,zi=function(t){function a(e){var t,i=e._iid,s=e.session,o=e.cacheContext,u=e.sdkState,c=e.dispatcher,l=e.requestQueue,d=e.logger,h=e.pushNotificationAckManager;return r(this,a),(t=n(this,a))._currentConnectionStateType=Da.INITIALIZED,t._isRefreshingAuthToken=!1,t.currentUser=null,t.session=s,t._iid=i,t._cacheContext=o,t._sdkState=u,t._dispatcher=c,t._requestQueue=l,t._logger=d,t._pushNotificationAckManager=h,t._deviceTokens=[],t._dispatcher.on((function(e){var n,r,a;if(e instanceof Ha){var i=e.stateType;t._currentConnectionStateType=i}else if(e instanceof Qe&&t.handler&&!t.isSessionKeyRefreshing){if(t._currentConnectionStateType===Da.CONNECTING)return;(null===(n=e.error)||void 0===n?void 0:n.isSessionInvalidatedError)?t.close():((null===(r=e.error)||void 0===r?void 0:r.isSessionTokenExpiredError)&&t.refreshAuthToken().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e})),(null===(a=e.error)||void 0===a?void 0:a.isSessionKeyExpiredError)&&(t._logger.debug("session expired"),t.handler.onSessionExpired&&t.handler.onSessionExpired(),t.refreshSessionKey().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e}))))}})),t}return c(a,t),i(a,[{key:"ekey",get:function(){return Vi.get(this)}},{key:"deviceTokens",get:function(){return this._deviceTokens}},{key:"deviceTokenLastDeletedAt",get:function(){return this._deviceTokenLastDeletedAt}},{key:"indexOfDeviceToken",value:function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))}},{key:"hasDeviceToken",value:function(e,t){return this.indexOfDeviceToken(e,t)>=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new Ze({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(n);case 3:if(r=t.sent,a=r.as(Je),i=a.newKey,!(s=a.error)){t.next=7;break}throw s;case 7:this.session.sessionKey=null!=i?i:this.session.sessionKey;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Ye({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),t.next=3,Ci((function(e){return E(r,void 0,void 0,d().mark((function t(){var r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(n);case 3:r=t.sent,a=r.as(Xe),i=a.key,s=a.services,this.session.sessionKey=i,this.session.services=s,t.next=16;break;case 9:if(t.prev=9,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=15;break}e(t.t0),t.next=16;break;case 15:throw t.t0;case 16:case"end":return t.stop()}}),t,this,[[0,9]])})))}),3);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKey",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._currentConnectionStateType!==Da.CONNECTED){n.next=18;break}return n.prev=1,n.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),n.abrupt("return");case 8:return n.prev=8,n.t0=n.catch(1),n.prev=10,n.next=13,this._handleSessionRefreshError(n.t0,t);case 13:return n.abrupt("return");case 16:n.prev=16,n.t1=n.catch(10);case 18:return n.prev=18,n.next=21,this._refreshSessionKeyByApi(e);case 21:this.complete(),n.next=28;break;case 24:return n.prev=24,n.t2=n.catch(18),n.next=28,this._handleSessionRefreshError(n.t2,t);case 28:case"end":return n.stop()}}),n,this,[[1,8],[10,16],[18,24]])})))}},{key:"_receiveNewAuthToken",value:function(){var e,t=this,n=new ut;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var r=null,a=function(){r&&(clearTimeout(r),r=null)},i=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},s=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};r=setTimeout((function(){return s()}),1e3*this._sdkState.sessionTokenRefreshTimeout),_i((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(i,s);case 1:case"end":return e.stop()}}),e,this)})))}))}else n.resolve(null);return n.promise}},{key:"_handleSessionRefreshError",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(t instanceof A)){r.next=16;break}if(!t.isSessionTokenExpiredError&&t.code!==e.SendbirdErrorCode.APPLICATION_NOT_FOUND){r.next=16;break}if(this.session.authToken=void 0,!n){r.next=16;break}return r.next=6,this._receiveNewAuthToken();case 6:if(!(a=r.sent)){r.next=13;break}return this.session.authToken=a,r.next=11,this._refreshSessionKey(this.session.authToken,!1);case 11:r.next=15;break;case 13:return r.next=15,this.clear();case 15:return r.abrupt("return");case 16:throw t;case 17:case"end":return r.stop()}}),r,this)})))}},{key:"_isSessionRelatedError",value:function(e){return e instanceof A&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}},{key:"isSessionKeyRefreshing",get:function(){return this.session.isRefreshing}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"isSessionExpiring",get:function(){return!!this.handler}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.session.authToken=t,a=new Ri({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!t||this.isSessionExpiring}),r.next=4,this._requestQueue.commandRouter.send(a);case 4:if(i=r.sent,s=i.as(Li),(o=s.logi).error){r.next=12;break}if(this.session.hasChatServicePermission){r.next=10;break}return r.next=10,o.applyTo(this._iid);case 10:r.next=13;break;case 12:throw o.error;case 13:case"end":return r.stop()}}),r,this)})))}},{key:"login",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=e.key,a=e.ekey,i=e.services,s=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.session.sessionKey=r,this.session.services=i,Vi.set(this,a),this._deviceTokenCacheEnabled=null===(t=null==s?void 0:s.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){n.next=21;break}return n.next=9,c.get(Gi);case 9:if((l=n.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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return t=this._cacheContext.preference,e.next=4,t.set(Gi,{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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.session.clear(),this.close(),Vi.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:this._pushNotificationAckManager.clear();case 9:case"end":return e.stop()}}),e,this)})))}}])}(de),Bi=function(e,t){if(null!==e&&null!==t){var n,r=Object.keys(e),a=Object.keys(t),i={},o=s(v(new Set([].concat(r,a))));try{for(o.s();!(n=o.n()).done;){var u=n.value,c=m(e[u]),l=m(t[u]);"undefined"===c?i[u]=t[u]:"undefined"===l?i[u]=e[u]:c!==l?i[u]=t[u]:"object"===c&&e[u]&&t[u]?i[u]=Bi(e[u],t[u]):i[u]=t[u]}}catch(e){o.e(e)}finally{o.f()}return i}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"}(Pi||(Pi={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(Fi||(Fi={}));var Qi,Ki=100,Wi=function(){return i((function e(t){var n=t.deviceId,a=t.cacheContext,i=t.requestQueue;r(this,e),this.queue=[],this.flushWaitQueue=[],this.enabledState=Pi.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=n,this.cacheContext=a,this.requestQueue=i,this.logInfo={deviceId:n,statLogs:[],generation:1,lastFlushedAt:0},this.limit=Ki}),[{key:"isEnabled",get:function(){return this.enabledState===Pi.ENABLED}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:(n=t.sent)&&(this.logInfo=n);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_mergeQueue",value:function(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}},{key:"_isDuplicateStat",value:function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}},{key:"_save",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(v(this.queue),v(this.flushWaitQueue)),e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:t.map((function(e){return at.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save();case 4:case"end":return e.stop()}}),e,this)})))}}])}(),Yi=function(e){function t(e){var a,i,s,o,u,c=e.type,l=e.data,d=e.ts,h=void 0===d?Date.now():d;return r(this,t),(a=n(this,t,[{type:c,data:l,ts:h}])).date=new Date(h),a.key="".concat((i=a.date,s=i.getFullYear(),o=String(i.getMonth()+1).padStart(2,"0"),u=String(i.getDate()).padStart(2,"0"),"".concat(s).concat(o).concat(u)),"_").concat(c),a}return c(t,e),i(t)}(at),Zi=function(e){function t(e){var a,i=e.deviceId,s=e.statLogs;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Oe),a.params={device_id:i,log_entries:s.map((function(e){return at.payloadify(e)}))},a}return c(t,e),i(t)}(Ve),Xi=function(t){function a(e){var t=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:i,requestQueue:s}])}return c(a,t),i(a,[{key:"_isSendable",get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var t=this,n=Object.create(null,{init:{get:function(){return p(a,"init",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.init.call(this,e+".daily");case 2:this.queue=this.logInfo.statLogs.map((function(e){return new at({type:e.stat_type,ts:e.ts,data:e.data})}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),!t.localCacheStat){n.next=7;break}this.enabledState=t.enabledStat?Pi.ENABLED:Pi.COLLECT_ONLY,n.next=10;break;case 7:return this.enabledState=Pi.DISABLED,n.next=10,this.clear();case 10:if(!this.isEnabled||!this._isSendable){n.next=25;break}return n.next=13,this._getUploadStats();case 13:r=n.sent,a=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),i=0;case 16:if(!(i0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Zi({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Ki,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Pi.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Pi.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}(Wi),Ji=function(t){function a(e){var t=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:i,requestQueue:s}])}return c(a,t),i(a,[{key:"_isSendable",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.queue.length0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Zi({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Ki,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Pi.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Pi.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}(Wi),$i=function(e){function t(e){var a,i=e.deviceId,s=e.statLogs;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Ue),a.params={device_id:i,log_entries:s.map((function(e){return at.payloadify(e)}))},a}return c(t,e),i(t)}(Ve),es=function(t){function a(e){var t=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:i,requestQueue:s}])}return c(a,t),i(a,[{key:"_isSendable",get:function(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var t=this,n=Object.create(null,{init:{get:function(){return p(a,"init",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.init.call(this,e+".realtime");case 2:this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new at({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this._mergeQueue(),!t.notificationStat){n.next=6;break}this.enabledState=t.enabledStat?Pi.ENABLED:Pi.COLLECT_ONLY,n.next=9;break;case 6:return this.enabledState=Pi.DISABLED,n.next=9,this.clear();case 9:if(!this.isEnabled||!this._isSendable){n.next=15;break}return r=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),n.next=13,ki(r);case 13:return n.next=15,this._flush(this.queue);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState!==Pi.DISABLED){t.next=2;break}return t.abrupt("return",!0);case 2:if(n=this.enabledState===Pi.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,!this._isDuplicateStat(e)){t.next=5;break}return t.abrupt("return",!0);case 5:if(n.push(e),this.enabledState===Pi.PENDING){t.next=9;break}return t.next=9,this._save();case 9:if(!this.isEnabled){t.next=15;break}if(this._mergeQueue(),!this.isEnabled||!this._isSendable){t.next=15;break}return t.next=14,this._flush(n);case 14:return t.abrupt("return",t.sent);case 15:return t.abrupt("return",!0);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"_flush",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=!0,!(t.length>0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new $i({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Ki,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Pi.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Pi.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}(Wi),ts=function(){return i((function e(t){var n=t.cacheContext,a=t.requestQueue,i=t.dispatcher,s=t.logger;r(this,e),this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=ce(),this.cacheContext=n,this.requestQueue=a,this.dispatcher=i,this.logger=s,this._dailyStatCollector=new Xi({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Ji({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new es({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}),[{key:"_migration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cacheContext.preference.get(this.key);case 2:if(!(t=e.sent)){e.next=18;break}return n=[],t.statLogs.forEach((function(e){e.stat_type===je.FEATURE_LOCALCACHE&&n.push(new at({type:e.stat_type,ts:e.ts,data:e.data}))})),e.next=8,this.cacheContext.preference.set(this.key+".daily",{deviceId:t.deviceId,statLogs:n.map((function(e){return at.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 8:return r=[],t.statLogs.forEach((function(e){e.stat_type!==je.FEATURE_LOCALCACHE&&e.stat_type!==je.NOTIFICATION&&(e.stat_type===je.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),r.push(new at({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=12,this.cacheContext.preference.set(this.key+".default",{deviceId:t.deviceId,statLogs:r.map((function(e){return at.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 12:return a=[],t.statLogs.forEach((function(e){var t;e.stat_type===je.NOTIFICATION&&(e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),a.push(new at({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=16,this.cacheContext.preference.set(this.key+".realtime",{deviceId:t.deviceId,statLogs:a.map((function(e){return at.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 16:return e.next=18,this.cacheContext.preference.remove(this.key);case 18:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this._migration();case 3:return t.next=5,this._dailyStatCollector.init(this.key);case 5:return t.next=7,this._defaultStatCollector.init(this.key);case 7:return t.next=9,this._notificationStatCollector.init(this.key);case 9:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e instanceof $e?(r=e.statLog,this.put(r)):e instanceof fi&&(a=e.request,i=e.features,s=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=a,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._notificationStatCollector.setConfig(null!==(n=this._statConfig.realTime)&&void 0!==n?n:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:s.ingestion}));case 1:case"end":return t.stop()}}),t,this)})))})));case 10:case"end":return t.stop()}}),t,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=!0,!(e instanceof Yi)){t.next=8;break}if(!this._collectFeatureLocalCacheStat){t.next=6;break}return t.next=5,this._dailyStatCollector.put(e);case 5:n=t.sent;case 6:t.next=26;break;case 8:t.t0=e.type,t.next=t.t0===je.API_RESULT||t.t0===je.WEBSOCKET_CONNECT?11:t.t0===je.FEATURE_LOCALCACHE||t.t0===je.FEATURE_LOCALCACHE_EVENT?16:t.t0===je.NOTIFICATION?21:26;break;case 11:if(!this._collectRequestStat){t.next=15;break}return t.next=14,this._defaultStatCollector.put(e);case 14:n=t.sent;case 15:return t.abrupt("break",26);case 16:if(!this._collectFeatureLocalCacheStat){t.next=20;break}return t.next=19,this._defaultStatCollector.put(e);case 19:n=t.sent;case 20:return t.abrupt("break",26);case 21:if(!this._collectionNotificationStat){t.next=25;break}return t.next=24,this._notificationStatCollector.put(e);case 24:n=t.sent;case 25:return t.abrupt("break",26);case 26:n?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Pi.COLLECT_ONLY,this._defaultStatCollector.enabledState=Pi.COLLECT_ONLY,this._notificationStatCollector.enabledState=Pi.COLLECT_ONLY,this.logger.debug(A.statLogUploadLimitExceededError)));case 27:case"end":return t.stop()}}),t,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}])}(),ns=function(){return i((function e(t){var n=t.limit,a=void 0===n?5:n;r(this,e),this.workersByKey={},this.limit=a}),[{key:"run",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.workersByKey[e]||(this.workersByKey[e]=[]),!(this.workersByKey[e].length0:void 0,i.lastRepliedAt=null!==(c=a.last_replied_at)&&void 0!==c?c:0,i.updatedAt=null!==(l=a.updated_at)&&void 0!==l?l:0,i}return c(t,e),i(t,[{key:"_isUpdateRequired",get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}},{key:"_updateFrom",value:function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((function(e){return li.payloadify(e)})):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}}])}($a);e.ReactionEventOperation=void 0,(rs=e.ReactionEventOperation||(e.ReactionEventOperation={})).ADD="add",rs.DELETE="delete";var hs,fs=i((function t(n){r(this,t),this.messageId=0,this.operation=null,this.updatedAt=0;var a=D("string",n.msg_id)?parseInt(n.msg_id):n.msg_id,i=n.user_id,s=n.operation?n.operation.toLowerCase():null,o=n.reaction,u=n.updated_at;a&&D("string",i)&&D("string",s)&&R(e.ReactionEventOperation,s)&&D("string",o)&&o&&D("number",u)&&(this.messageId=a,this.userId=i,this.key=o,this.operation=s,this.updatedAt=u)})),ps=function(){return i((function e(t){var n;r(this,e);var a=t.key,i=null!==(n=v(t.user_ids))&&void 0!==n?n:[],o=t.updated_at;D("string",a)&&a&&P("string",i)&&i.length>0&&D("number",o)&&(this.key=a,this.userIds=i,this.updatedAt=o);var u,c={},l=s(this.userIds);try{for(l.s();!(u=l.n()).done;){c[u.value]=this.updatedAt}}catch(e){l.e(e)}finally{l.f()}this._version=c}),[{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 pe(ve({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}}])}(),vs=function(){return i((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)}),null,[{key:"payloadify",value:function(e){var t,n;return pe(ve({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}))}}])}(),_s=function(){return i((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 vs(t["og:image"]))}),null,[{key:"payloadify",value:function(e){return pe(ve({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?vs.payloadify(e.defaultImage):null}))}}])}(),ms=function(){return i((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}),[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return pe(ve({name:e.name,volume:e.volume}))}}])}();e.FeedbackRating=void 0,(hs=e.FeedbackRating||(e.FeedbackRating={})).GOOD="good",hs.BAD="bad";var gs,ys=function(){function e(t){r(this,e),this.id=t.id,this.rating=t.rating,this.comment=t.comment}return i(e,null,[{key:"_getStatus",value:function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}},{key:"_isSubmitted",value:function(t){return"SUBMITTED"===e._getStatus(t)}},{key:"_getPayloadByStatus",value:function(e){return"NO_FEEDBACK"===e?{}:null}},{key:"payloadify",value:function(e){return pe(ve({id:e.id,rating:e.rating,comment:e.comment}))}}])}(),Es=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i])).isBlockedByMe=!1,s.role=R(e.Role,i.role)?i.role:e.Role.NONE,s.isBlockedByMe=null!==(o=i.is_blocked_by_me)&&void 0!==o&&o,s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}])}(li),ks=function(){return i((function e(t){r(this,e),this.key=t.key,this.value=P("string",t.value)?v(t.value):[]}),null,[{key:"payloadify",value:function(e){var t;return pe(ve({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}])}(),bs=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"}},Cs=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;r(this,a),(s=n(this,a,[t])).channelType=e.ChannelType.BASE,s.messageType=e.MessageType.BASE,s.mentionType=null,s.mentionedUsers=null,s.mentionedUserIds=null,s.mentionedMessageTemplate=void 0,s.metaArrays=[],s.extendedMessage={},s.createdAt=0,s.updatedAt=0,s.channelUrl=i.channel_url,s.channelType=R(e.ChannelType,i.channel_type)?i.channel_type:e.ChannelType.GROUP,i.channel&&(i.channel.channel_url&&(s.channelUrl=i.channel.channel_url),i.channel.channel_type&&(s.channelType=i.channel.channel_type)),s.data=null!==(o=i.data)&&void 0!==o?o:"",s.customType=null!==(u=i.custom_type)&&void 0!==u?u:"",s.mentionType=R(e.MentionType,i.mention_type)?i.mention_type:null,s.mentionedUsers=i.mentioned_users?i.mentioned_users.map((function(e){return new li(s._iid,e)})):null,s.mentionedUserIds=null!==(c=i.mentioned_user_ids)&&void 0!==c?c:null,s.mentionedUsers&&!s.mentionedUserIds&&(s.mentionedUserIds=s.mentionedUsers.map((function(e){return e.userId}))),s.mentionedMessageTemplate=i.mentioned_message_template;var _=null!==(l=i.metaarray)&&void 0!==l?l:{},m=null!==(d=i.metaarray_key_order)&&void 0!==d?d:Object.keys(_).sort((function(e,t){return e.localeCompare(t)}));s.metaArrays=[];for(var g=0;g0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,items:e.items.map((function(e){return Xs.payloadify(e)})),version:e.version,is_submitted:e._isSubmitted}))}},{key:"isMessageFormPayload",value:function(e){return Boolean(null==e?void 0:e.message_form)}}])}(),Xs=function(){return i((function e(t){r(this,e);var n=t.id,a=t.name,i=t.required,s=t.sort_order,o=t.placeholder,u=t.style,c=t.item_type,l=t.validators,d=t.value,h=t.values;this.id=n,this.name=a,this.required=i,this.sortOrder=s,this.placeholder=o,0===Object.keys(u).length?this.style={layout:c}:this.style=pe({layout:u.layout,options:u.options,defaultOptions:u.default_options,resultCount:u.result_count}),h?this.submittedValues=h:d&&(this.submittedValues=[d]),this._validators=l}),[{key:"isValid",value:function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case Ds.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case Ds.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case Ds.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case Ds.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case Ds.DECIMAL_PLACE:if(0===e.length)return!1;var r=Number(e);return!(isNaN(r)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(r,t.max_decimal_place));default:return!0}}))}(e,t._validators);return n}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:pe({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}])}(),Js=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le,"/").concat(e.formId,"/submit"),a.params=pe({message_id:e.messageId,items:e.items}),a}return c(t,e),i(t)}(Ve);e.ScheduledStatus=void 0,(Ws=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",Ws.SENT="sent",Ws.FAILED="failed",Ws.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 $s,eo=function(t){function a(e,t){var i,s,o,u,c,l,d,h,f,p;return r(this,a),(i=n(this,a,[e,t])).parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.threadInfo=null,i.reactions=[],i.appleCriticalAlertOptions=null,i.scheduledInfo=null,i.suggestedReplies=null,i.myFeedback=null,i.myFeedbackStatus="NOT_APPLICABLE",i.messageForm=null,i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(o=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==o?o:0,i.parentMessageId=null!==(u="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==u?u:0,i.threadInfo=t.thread_info?new ds(i._iid,t.thread_info):null,i.reactions=t.reactions?t.reactions.map((function(e){return new ps(e)})):[],i.ogMetaData=t.og_tag?new _s(t.og_tag):null,i.silent=null!==(c=t.silent)&&void 0!==c&&c,i.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,i.appleCriticalAlertOptions=t.apple_critical_alert_options?new ms(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(i.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},i._scheduledStatus=t.scheduled_status),i._isContinuousMessages=null!==(d=t.is_continuous_messages)&&void 0!==d&&d,i.myFeedback=ys._isSubmitted(t.feedback)?new ys(t.feedback):null,i.myFeedbackStatus=ys._getStatus(t.feedback),i.suggestedReplies=null!==(f=null===(h=t.extended_message_payload)||void 0===h?void 0:h.suggested_replies)&&void 0!==f?f:null,i.messageForm=Zs.isMessageFormPayload(t.extended_message_payload)?new Zs(i.messageId,t.extended_message_payload.message_form):null,i.message=null!==(p=t.message)&&void 0!==p?p:"",i}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.messageId===e.messageId}},{key:"applyThreadInfoUpdateEvent",value:function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}},{key:"applyReactionEvent",value:function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1}},{key:"_triggerThreadInfoUpdatedEvent",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=ss.of(this._iid),(r=n.dispatcher).dispatch(new Ks({channelType:e.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),r.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"markThreadAsRead",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Ts({channelUrl:this.channelUrl,messageId:this.messageId}),e.next=4,n.send(r);case 4:if(!this.threadInfo||0===this.threadInfo.unreadReplyCount){e.next=8;break}return this.threadInfo.unreadReplyCount=0,e.next=8,this._triggerThreadInfoUpdatedEvent();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setPushNotificationEnabled",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Is({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),t.next=4,r.send(a);case 4:this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"submitMessageForm",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=ss.of(this._iid),a=r.requestQueue,i=null,s=null,o=this.messageForm,t||!o){n.next=13;break}if(o.isSubmittable){n.next=7;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});case 7:if(!o.isSubmitted){n.next=9;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});case 9:i=o.id,s=o.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[]),n.next=14;break;case 13:t&&(i=t.formId,s=Object.entries(t.answers).reduce((function(t,n){var r=f(n,2),a=r[0],i=r[1],s=Number(a);if(Number.isNaN(s))throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return t.push({form_item_id:s,value:i}),t}),[]));case 14:if(i&&s){n.next=16;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});case 16:return u=new Js({messageId:this.messageId,formId:i,items:s}),n.next=19,a.send(u);case 19:case"end":return n.stop()}}),n,this)})))}},{key:"submitFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ns({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(As),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ms({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t.id,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(Os),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Us({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t}),n.next=4,a.send(s);case 4:this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}));case 7:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?ds.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return ps.payloadify(e)})),og_tag:e.ogMetaData?_s.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?ms.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(t=e.scheduledInfo)||void 0===t?void 0:t.scheduledMessageId,scheduled_at:null===(n=e.scheduledInfo)||void 0===n?void 0:n.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?ys.payloadify(e.myFeedback):ys._getPayloadByStatus(e.myFeedbackStatus),message:e.message})))}},{key:"_getParentMessageInfoPayload",value:function(e){return pe(ve({type:bs(e.messageType),ts:e.createdAt,user:e.sender?Es.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Qs.payloadify(e)})):null}))}}])}(Cs),to=function(t){function a(t,i){var s,o,u,c,l;if(r(this,a),(s=n(this,a,[t,i])).reqId="",s.replyToChannel=!1,s.errorCode=0,s.sender=i.user?new Es(s._iid,i.user):i.sender_id,s.reqId=null!==(u=null!==(o=i.req_id)&&void 0!==o?o:i.request_id)&&void 0!==u?u:"",s.replyToChannel=null!==(c=i.is_reply_to_channel)&&void 0!==c&&c,i.request_state&&R(e.SendingStatus,i.request_state)&&(s.sendingStatus=i.request_state),!s.sendingStatus)if(s.messageId>0)s.sendingStatus=e.SendingStatus.SUCCEEDED;else if(s.scheduledInfo)switch(i.scheduled_status&&(s._scheduledStatus=i.scheduled_status),i.scheduled_status){case Ys.SENT:case Ys.IN_QUEUE:s.sendingStatus=e.SendingStatus.SUCCEEDED;break;case Ys.PENDING:s.sendingStatus=e.SendingStatus.SCHEDULED;break;case Ys.FAILED:case Ys.REMOVED:s.sendingStatus=e.SendingStatus.FAILED;break;case Ys.CANCELED:s.sendingStatus=e.SendingStatus.CANCELED}else s.sendingStatus=e.SendingStatus.PENDING;return s.errorCode=null!==(l=i.error_code)&&void 0!==l?l:0,s._messageToken=i.mesg_token,s}return c(a,t),i(a,[{key:"isResendable",get:function(){return(this.sendingStatus===e.SendingStatus.FAILED||this.sendingStatus===e.SendingStatus.CANCELED)&&((t=this.errorCode)>0&&M.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 pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{user:Es.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}}])}(eo),no={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ro=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)},ao=function(t){function a(t,i){var s,o,u,c;if(r(this,a),(s=n(this,a,[t,i])).translations={},s.messageType=e.MessageType.ADMIN,s.translations=null!==(o=i.translations)&&void 0!==o?o:{},i.parent_message_info){var l=i.parent_message_info;s.parentMessage=go(t,pe(ve(Object.assign(Object.assign({},l),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:l.file,url:null===(u=l.file)||void 0===u?void 0:u.url,require_auth:null===(c=l.file)||void 0===c?void 0:c.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{translations:e.translations,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(eo),io=function(){return i((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&&D("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,vendor:e.vendor,detail:e.detail}))}}])}();!function(e){e.OPEN="open",e.CLOSED="closed"}($s||($s={}));var so,oo="removed",uo=function(e){switch(e){case"open":return $s.OPEN;case"closed":return $s.CLOSED;default:return null}},co=function(e){return!e||!!e.text&&D("string",e.text)},lo=function(e){function t(e,a){var i,s,o,u,c,l,d,h;return r(this,t),(i=n(this,t,[e])).pollId=0,i.id=0,i.text=null,i.voteCount=0,i.createdBy=null,i.createdAt=0,i.updatedAt=0,i._lastVotedAt=0,i.pollId=null!==(s=a.poll_id)&&void 0!==s?s:0,i.id=null!==(o=a.id)&&void 0!==o?o:0,i.text=null!==(u=a.text)&&void 0!==u?u:null,i.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,i.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,i.createdAt=null!==(d=a.created_at)&&void 0!==d?d:0,i.updatedAt=null!==(h=a.updated_at)&&void 0!==h?h:0,i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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})))}}])}($a),ho=function(e){function t(e,a){var i,s,o,u,c,l,d,h,f,p,v,_,m,g;return r(this,t),(i=n(this,t,[e])).id=0,i.title=null,i.createdAt=0,i.updatedAt=0,i.closeAt=-1,i.status=$s.CLOSED,i.messageId=0,i.data=null,i.voterCount=-1,i.options=[],i.createdBy=null,i.allowUserSuggestion=!1,i.allowMultipleVotes=!1,i.votedPollOptionIds=[],i.id=null!==(s=a.id)&&void 0!==s?s:0,i.title=null!==(o=a.title)&&void 0!==o?o:null,i.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,i.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,i.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,i.status=null!==(d=uo(a.status))&&void 0!==d?d:$s.CLOSED,i.messageId=null!==(h=a.message_id)&&void 0!==h?h:0,i.data=null!==(f=a.data)&&void 0!==f?f:null,i.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,i.options=a.options?a.options.map((function(e){return new lo(i._iid,e)})):[],i.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,i.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,i.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,i.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],i}return c(t,e),i(t,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,i,s,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=uo(e.status))&&void 0!==a?a:this.status,this.data=null!==(i=e.data)&&void 0!==i?i:this.data,this.voterCount=null!==(s=e.voter_count)&&void 0!==s?s:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new lo(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var i=t[r];a>=i._lastVotedAt&&(i.voteCount=e.vote_count,i._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0}},{key:"serialize",value:function(){return si(this)}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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 lo.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}])}($a),fo=function(){return i((function e(t){r(this,e),this.status=t.status,t.original_message_info&&(this.originalMessageInfo={createdAt:t.original_message_info.ts,messageId:t.original_message_info.id})}),null,[{key:"payloadify",value:function(e){return pe({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}])}(),po=function(t){function a(t,i){var o,u,c,l,d,h;if(r(this,a),(o=n(this,a,[t,i])).messageParams=null,o.translations={},o.translationTargetLanguages=[],o.messageSurvivalSeconds=-1,o.plugins=[],o._poll=null,o.messageType=e.MessageType.USER,o.translations=null!==(u=i.translations)&&void 0!==u?u:{},o.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(o.translations).length&&o.translationTargetLanguages.length>0){var f,p=s(o.translationTargetLanguages);try{for(p.s();!(f=p.n()).done;){var v=f.value;o.translations[v]=""}}catch(e){p.e(e)}finally{p.f()}}if(o.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,o.plugins=i.plugins?i.plugins.map((function(e){return new io(e)})):[],o._poll=i.poll?new ho(o._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;o.parentMessage=go(t,pe(ve(Object.assign(Object.assign({},_),{created_at:_.ts,message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(o.messageReviewInfo=new fo(i.review_info)),o}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return io.payloadify(e)})),poll:e._poll?ho.payloadify(e._poll):null,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null,review_info:e.messageReviewInfo?fo.payloadify(e.messageReviewInfo):void 0})))}}])}(to),vo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p;if(r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.fileInfoList=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE,s.data=null!==(c=null!==(u=null===(o=i.file)||void 0===o?void 0:o.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",s.fileInfoList=null!==(d=null===(l=i.files)||void 0===l?void 0:l.map((function(e){return new Qs(t,e)})))&&void 0!==d?d:[],s.messageSurvivalSeconds=null!==(h=i.message_survival_seconds)&&void 0!==h?h:-1,i.parent_message_info){var v=i.parent_message_info;s.parentMessage=go(t,pe(ve(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===(f=v.file)||void 0===f?void 0:f.url,require_auth:null===(p=v.file)||void 0===p?void 0:p.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n,r,i,s,o;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{file:{name:null!==(n=null===(t=e.fileInfoList[0])||void 0===t?void 0:t.fileName)&&void 0!==n?n:"",size:null!==(i=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.fileSize)&&void 0!==i?i:0,type:null!==(o=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Qs.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([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)}}])}(to);!function(e){e.SENT="SENT",e.READ="READ"}(so||(so={}));var _o=function(t){function a(t,i){var s,o,u;if(r(this,a),(s=n(this,a,[t,i])).notificationData=null,s.notificationId=i.notification_message_id,s.messageType=e.MessageType.ADMIN,s.messageStatus=null!==(o=i.message_status)&&void 0!==o?o:so.SENT,s.priority=null!==(u=i.priority)&&void 0!==u?u:se.NORMAL,s.notificationEventDeadline=i.notification_event_deadline,0===s.extendedMessage.sub_type)try{var c=JSON.parse(s.extendedMessage.sub_data),l=c.label,d=c.tags,h=void 0===d?[]:d,f=c.template_key,p=c.template_variables;s.notificationData={label:l,tags:h,templateKey:f,templateVariables:p}}catch(e){}return s}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.notificationId===e.notificationId}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}}])}(Cs),mo=function(t){if(t.notificationId)return _o.payloadify(t);switch(t.messageType){case e.MessageType.USER:return po.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?vo.payloadify(t):yo.payloadify(t);case e.MessageType.ADMIN:return ao.payloadify(t);default:throw A.unknown}},go=function(e,t){if(t.notification_message_id)return new _o(e,t);switch(t.type){case"MESG":return new po(e,t);case"FILE":return vo._isMultipleFilesMessagePayload(t)?new vo(e,t):new yo(e,t);case"ADMM":case"BRDM":return new ao(e,t);default:return null}},yo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var k=i.file;if(s.plainUrl=(null!==(u=null!==(o=null==k?void 0:k.url)&&void 0!==o?o:i.url)&&void 0!==u?u:"").split("?auth=")[0],s.name=null!==(l=null!==(c=null==k?void 0:k.name)&&void 0!==c?c:i.name)&&void 0!==l?l:"File",s.size=null!==(h=null!==(d=null==k?void 0:k.size)&&void 0!==d?d:i.size)&&void 0!==h?h:0,s.data=null!==(p=null!==(f=null==k?void 0:k.data)&&void 0!==f?f:i.custom)&&void 0!==p?p:"",s.type=k?null!==(v=k.type)&&void 0!==v?v:"":null!==(_=i.type)&&void 0!==_?_:"",s.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,s.thumbnails=i.thumbnails?i.thumbnails.map((function(e){var t;return new us(s._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),s.requireAuth)})):[],s.messageSurvivalSeconds=null!==(g=i.message_survival_seconds)&&void 0!==g?g:-1,i.parent_message_info){var b=i.parent_message_info;s.parentMessage=go(t,pe(ve(Object.assign(Object.assign({},b),{created_at:b.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:b.file,url:null===(y=b.file)||void 0===y?void 0:y.url,require_auth:null===(E=b.file)||void 0===E?void 0:E.require_auth}))))}return s}return c(a,t),i(a,[{key:"url",get:function(){var e=ss.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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.plainUrl,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(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(to),Eo=function(e){function t(e,a){var i,s=a.file,o=a.fileUrl,u=a.fileName,c=a.fileSize,l=a.mimeType,d=a.thumbnailSizes,h=a._uploadedMetaData,f=a._thumbnails;return r(this,t),(i=n(this,t,[e]))._plainUrl=o,i.file=s,i.fileName=u,i.fileSize=c,i.mimeType=l,i.thumbnailSizes=d,i._uploadedMetaData=h,i._thumbnails=f,i}return c(t,e),i(t,[{key:"fileUrl",get:function(){var e,t=ss.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e}},{key:"toJSON",value:function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}],[{key:"getPlainUrl",value:function(e){return e instanceof t?e._plainUrl:e.fileUrl}}])}($a),ko=function(t){function a(t){var i,s,o,u;r(this,a);var c=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?c=t.mentionedUserIds:t.mentionedUsers&&(c=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FILE",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,files:t.files?xo(t.files):null,url:t.url,name:null!==(i=t.fileName)&&void 0!==i?i:"",type:null!==(s=t.mimeType)&&void 0!==s?s:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:null===(u=t._thumbnails)||void 0===u?void 0:u.map((function(e){return us.payloadify(e)})),require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:c,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.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,message:t.message}))}])}return c(a,t),i(a)}(We),bo=function(t){function a(t){var i,s,o;r(this,a),i=n(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})))),i.method=_e.POST,i.path="".concat(Pe(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),i.params=pe(ve({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?xo(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===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return us.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return ks.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage})),i}return c(a,t),i(a)}(Ve),Co=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"FILE",i])).message=i.files&&i.files.length>=2?new vo(e,i):new yo(e,i);var d=ss.of(e).sdkState;return s.isMentioned=qe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),wo=function(e){function t(e,a){var i,s,o,u,c;r(this,t),(i=n(this,t,[e,a])).message=a.files&&a.files.length>=2?new vo(e,a):new yo(e,a);var l=ss.of(e).sdkState;return i.isMentioned=qe(i.message.mentionType,null!==(u=null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:null===(o=i.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),i.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,i}return c(t,e),i(t)}(ze);function xo(e){return e.map((function(e){var t,n;return pe(ve({url:Eo.getPlainUrl(e),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 us.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var So;!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"}(So||(So={}));var To=function(){return i((function e(t,n){var a=this,i=n.sdkState,s=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._iid=t,this._sdkState=i,this._requestQueue=o,this._cacheContext=c,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof Ha&&(a._connectionState=e.stateType)})),this._onlineDetector=u}),[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===Da.CONNECTED||this._connectionState===Da.CONNECTING||this._connectionState===Da.RECONNECTING}},{key:"_sendFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=this._createSendFileMessageRequestParams(e,t),!this._shouldSendThroughWebSocket){n.next=10;break}return a=new ko(r),n.next=5,this._requestQueue.send(a);case 5:return i=n.sent,s=i.as(Co),o=s.message,n.abrupt("return",o);case 10:return u=new bo(Object.assign(Object.assign({},r),{userId:this._sdkState.userId})),n.next=13,this._requestQueue.send(u);case 13:return c=n.sent,l=c.as(wo),h=l.message,n.abrupt("return",h);case 16:case"end":return n.stop()}}),n,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(t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(a=this._queueMap.get(t.url))){r.next=58;break}if(a.isResolving){r.next=57;break}a.isResolving=!0,i=[],o=!0,u=s(a.messageQueue),r.prev=7,u.s();case 9:if((c=u.n()).done){r.next=40;break}l=c.value,r.t0=l.state,r.next=r.t0===So.PENDING||r.t0===So.UPLOADING?14:r.t0===So.UPLOADED?17:r.t0===So.FAILED?35:38;break;case 14:return o=!1,i.push(l),r.abrupt("break",38);case 17:if(!o){r.next=33;break}return r.prev=18,l.state=So.SENDING,r.next=22,this._sendFileMessage(t,l);case 22:return h=r.sent,l.deferred.resolve(h),r.next=26,ki(100);case 26:r.next=31;break;case 28:r.prev=28,r.t1=r.catch(18),l.deferred.reject(r.t1);case 31:r.next=34;break;case 33:i.push(l);case 34:return r.abrupt("break",38);case 35:return f=null!==(n=l.error)&&void 0!==n?n:A.unknown,l.deferred.reject(f.code===e.SendbirdErrorCode.REQUEST_CANCELED?A.fileUploadCanceled:f),r.abrupt("break",38);case 38:r.next=9;break;case 40:r.next=45;break;case 42:r.prev=42,r.t2=r.catch(7),u.e(r.t2);case 45:return r.prev=45,u.f(),r.finish(45);case 48:if(p=a.isResolveRequestPending,a.messageQueue=i,a.isResolving=!1,a.isResolveRequestPending=!1,!p){r.next=55;break}return r.next=55,this._resolveMessageQueue(t);case 55:r.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return r.stop()}}),r,this,[[7,42,45,48],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(r=this._queueMap.get(e.url))){n.next=30;break}if(!(a=r.messageQueue.find((function(e){return e.state===So.PENDING})))){n.next=30;break}if(!a.multipleFileUploadInfo){n.next=19;break}if(i=a.multipleFileUploadInfo,s=i.uploadIndex,o=i.uploadCount,u=i.requestHandler,c=a.params,l=c.fileInfoList[s],!H(l.file)||(null===(t=l._uploadedMetaData)||void 0===t?void 0:t.isUploaded)){n.next=13;break}return n.next=11,this._tryUploadNextItemAndUpdateItemState(e,r,a);case 11:n.next=14;break;case 13:a.state=s=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=new cs({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),s.next=3,this._requestQueue.send(o);case 3:u=s.sent,c=u.as(ls),l=c.url,h=c.fileSize,f=void 0===h?n.fileSize:h,p=c.thumbnails,v=void 0===p?[]:p,_=c.requireAuth,m=void 0!==_&&_,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i:n.file.size,n.fileUrl=l,n.fileSize=f,n.requireAuth=m,n._thumbnails=v;case 12:case"end":return s.stop()}}),s,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[o],c=new cs({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),s.next=5,this._requestQueue.send(c);case 5:l=s.sent,h=l.as(ls),f=h.url,p=h.fileSize,v=void 0===p?u.fileSize:p,_=h.thumbnails,m=h.requireAuth,g=void 0!==m&&m,u.fileName=null!==(r=u.fileName)&&void 0!==r?r: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=f,u.fileSize=v,u._thumbnails=_,u._uploadedMetaData=Object.assign(Object.assign({},u._uploadedMetaData),{requireAuth:g,isUploaded:!0}),u instanceof Eo||(n.fileInfoList[o]=new Eo(this._iid,u));case 16:case"end":return s.stop()}}),s,this)})))}},{key:"request",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),o=new ut,u={requestId:t,params:n,state:So.PENDING,deferred:o},Io(n)&&(c=n,l=Object.assign({uploadIndex:0,uploadCount:c.fileInfoList.length},r),u.multipleFileUploadInfo=l),s.messageQueue.push(u),this._uploadNextPendingItem(e),a.abrupt("return",o.promise);case 8:case"end":return a.stop()}}),a,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}))]:v(n.messageQueue),i=s(a);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o)switch(o.state){case So.PENDING:if(o.state=So.FAILED,o.error=A.requestCanceled,o.multipleFileUploadInfo&&!o.multipleFileUploadInfo.isCopy){var u=o.multipleFileUploadInfo,c=u.uploadIndex,l=u.requestHandler,d=o.params.fileInfoList[c];null==l||l._triggerOnFileUploaded(o.requestId,c,d,A.fileUploadCanceled)}this._resolveMessageQueue(e);break;case So.UPLOADING:this._requestQueue.cancel(o.requestId),this._dispatcher.dispatch(new ct({requestId:o.requestId}))}}}catch(e){i.e(e)}finally{i.f()}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new ct({requestId:t})))}}])}();function Io(e){return"fileInfoList"in e}var No,Ao={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},Mo=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&R(e.ReplyType,t.replyType)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)&&D("boolean",t.showSubchannelMessagesOnly)},Oo={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Uo=function(t){return R(e.ReplyType,t.replyType)&&D("boolean",t.includeReactions)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)},Do=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:d,include_poll_details:!0},a}return c(t,e),i(t)}(Ve),Ro=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?go(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(ze),Lo=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,d=e.isInclusive,h=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,E=e.includeThreadInfo,k=e.includeParentMessageInfo,b=e.showSubchannelMessagesOnly,C=e.checkingHasNext,w=e.checkingContinuousMessages;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages"),a.params=pe(ve({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,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:E,include_parent_message_info:k,show_subchannel_message_only:b,include_poll_details:!0,checking_has_next:C,checking_continuous_messages:w})),a}return c(t,e),i(t)}(Ve),Po=function(e){function t(e,a){var i;return r(this,t),i=n(this,t,[e,a]),void 0!==a.is_continuous_messages&&(i.isContinuousMessages=a.is_continuous_messages),void 0!==a.has_next&&(i.hasNext=a.has_next),i.messages=a.messages.map((function(t){return go(e,t)})),i}return c(t,e),i(t)}(ze),Fo=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,d=e.includeReactions,h=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:d,include_thread_info:h,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return c(t,e),i(t)}(Ve),qo=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedMessages=a.updated.map((function(t){return go(e,t)})),i.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(ze),Ho=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledMessageId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s)),a.params={},a}return c(t,e),i(t)}(Ve),Go=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?go(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(ze);e.RestrictionType=void 0,(No=e.RestrictionType||(e.RestrictionType={})).MUTED="muted",No.BANNED="banned";var jo=function(){return i((function t(n){var a,i,s,o;r(this,t),this.restrictionType=null,R(e.RestrictionType,n.restriction_type)&&(this.restrictionType=n.restriction_type),this.description=null!==(a=n.description)&&void 0!==a?a:null,this.endAt=null!==(s=null!==(i=n.end_at)&&void 0!==i?i:n.muted_end_at)&&void 0!==s?s:-1,this.remainingDuration=null!==(o=n.remaining_duration)&&void 0!==o?o:-1}),null,[{key:"payloadify",value:function(e){return pe(ve({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}])}(),Vo=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).restrictionInfo=new jo(a),i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),jo.payloadify(e.restrictionInfo))))}}])}(li),zo=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.isMuted=null!==(s=a.is_muted)&&void 0!==s&&s,i}return c(t,e),i(t)}(li),Bo=function(){return i((function e(){r(this,e),this._onPending=ft,this._onFailed=ft,this._onSucceeded=ft}),[{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}}])}(),Qo={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},Ko=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(li,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(ks,t.metaArrays,!0)&&D("number",t.parentMessageId,!0)&&D("boolean",t.isReplyToChannel)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ms,t.appleCriticalAlertOptions,!0)&&D("boolean",t.isPinnedMessage,!0)},Wo=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Yo=Object.assign(Object.assign({},Qo),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function Zo(t){var n,r,a;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(t.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var Xo,Jo=function(e){var t;return pe(ve({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),extendedMessagePayload:e.extendedMessagePayload}))},$o=function(e){return Ko(e)&&D("string",e.message)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)&&D("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Xo||(Xo={}));var eu=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},tu=function(e){return e===Xo.BLOB||e===Xo.FILE},nu=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},ru=Object.assign(Object.assign({},Qo),{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,message:void 0});function au(t){var n,r,a,i;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.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,_thumbnails:t.thumbnails,message:t.message}))}var iu,su=function(e,t){var n;return e.messageParams?(!e.url&&H(t)&&(e.messageParams.file=t),e.messageParams):pe(ve({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}})),message:e.message}))},ou=function(e){return Ko(e)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&D("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},uu={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},cu=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(li,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(ks,t.metaArrays,!0)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ms,t.appleCriticalAlertOptions,!0)},lu=Object.assign(Object.assign({},uu),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),du=function(e){return cu(e)&&D("string",e.message,!0)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)},hu=Object.assign({},uu),fu=function(e){return cu(e)},pu=function(){return i((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}),[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return D("number",this.limit)&&this.limit>0}}])}(),vu=function(t){function a(e,t,i,s){var o;return r(this,a),(o=n(this,a,[e,s])).channelUrl=t,o.channelType=i,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl)&&R(e.ChannelType,this.channelType)}}])}(pu),_u=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={token:o,limit:u},a}return c(t,e),i(t)}(Ve),mu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).operators=a.operators.map((function(t){return new li(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(ze),gu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=ss.of(this._iid),r=n.requestQueue,a=new _u(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(mu),o=s.operators,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(vu),yu=function(t){function a(t,i,s,o){var u,c,l,d,h,f,p,v,_,m,g;return r(this,a),(u=n(this,a,[t,i,s,o])).reverse=!1,u.messageTypeFilter=e.MessageTypeFilter.ALL,u.customTypesFilter=null,u.senderUserIdsFilter=null,u.replyType=e.ReplyType.NONE,u.includeMetaArray=!1,u.includeReactions=!1,u.includeParentMessageInfo=!1,u.includeThreadInfo=!1,u.showSubchannelMessagesOnly=!1,u._edge=Number.MAX_SAFE_INTEGER,u.reverse=null!==(c=o.reverse)&&void 0!==c&&c,u.messageTypeFilter=null!==(l=o.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,u.customTypesFilter=null!==(d=o.customTypesFilter)&&void 0!==d?d:null,u.senderUserIdsFilter=null!==(h=o.senderUserIdsFilter)&&void 0!==h?h:null,u.replyType=null!==(f=o.replyType)&&void 0!==f?f:e.ReplyType.NONE,u.includeMetaArray=null!==(p=o.includeMetaArray)&&void 0!==p&&p,u.includeReactions=null!==(v=o.includeReactions)&&void 0!==v&&v,u.includeParentMessageInfo=null!==(_=o.includeParentMessageInfo)&&void 0!==_&&_,u.includeThreadInfo=null!==(m=o.includeThreadInfo)&&void 0!==m&&m,u.showSubchannelMessagesOnly=null!==(g=o.showSubchannelMessagesOnly)&&void 0!==g&&g,u}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.reverse)&&R(e.MessageTypeFilter,this.messageTypeFilter)&&R(e.ReplyType,this.replyType)&&P("string",this.customTypesFilter,!0)&&P("string",this.senderUserIdsFilter,!0)&&D("boolean",this.includeMetaArray)&&D("boolean",this.includeReactions)&&D("boolean",this.includeParentMessageInfo)&&D("boolean",this.includeThreadInfo)&&D("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,t=oh.of(this._iid),e.next=7,t.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,ve({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));case 7:return n=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(v(n.map((function(e){return e.createdAt}))))),this._hasNext=n.length>=this.limit,this._isLoading=!1,e.abrupt("return",n);case 12:return e.abrupt("return",[]);case 15:throw A.queryInProgress;case 16:e.next=19;break;case 18:throw A.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}])}(vu),Eu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={limit:o,token:u},a}return c(t,e),i(t)}(Ve),ku=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).mutedUsers=[];var s=a.next,o=a.muted_list;return i.token=s,o&&o.length>0&&(i.mutedUsers=o.map((function(t){return new Vo(e,t)}))),i}return c(t,e),i(t)}(ze),bu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Eu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(ku),s=i.mutedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),Cu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({limit:o,token:u}),a}return c(t,e),i(t)}(Ve),wu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).bannedUsers=[];var s=a.next,o=a.banned_list;return i.token=s,o&&o.length>0&&(i.bannedUsers=o.map((function(t){return new Vo(e,t.user)}))),i}return c(t,e),i(t)}(ze),xu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Cu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(wu),s=i.bannedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu);e.ReportCategory=void 0,(iu=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",iu.HARASSING="harassing",iu.SUSPICIOUS="suspicious",iu.INAPPROPRIATE="inappropriate";var Su=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(Ve),Tu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(Ve),Iu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute/").concat(o),a}return c(t,e),i(t)}(Ve),Nu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.startAt=0,i.endAt=0;var s=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return i.isMuted=s,i.startAt=o,i.endAt=u,i.remainingDuration=c,i.description=l,i}return c(t,e),i(t)}(ze),Au=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={keys:o,include_ts:!0},a}return c(t,e),i(t)}(Ve),Mu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(ze),Ou=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0},a}return c(t,e),i(t)}(Ve),Uu=function(e){function t(e,a){var i,s,o;return r(this,t),(i=n(this,t,[e,a])).metaData=null!==(s=a.metadata)&&void 0!==s?s:{},i.ts=null!==(o=a.ts)&&void 0!==o?o:null,i}return c(t,e),i(t)}(ze),Du=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata,u=e.upsert;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return c(t,e),i(t)}(Ve),Ru=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(ze),Lu=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),Pu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(o),a.params={include_ts:!0},a}return c(t,e),i(t)}(Ve),Fu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(ze),qu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={include_ts:!0},a}return c(t,e),i(t)}(Ve),Hu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(ze),Gu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={keys:o},a}return c(t,e),i(t)}(Ve),ju=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(ze),Vu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o},a}return c(t,e),i(t)}(Ve),zu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(ze),Bu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,d=void 0===l?"set":l;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o,upsert:c,mode:d},a}return c(t,e),i(t)}(Ve),Qu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(ze),Ku=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),Wu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(o),a.params={},a}return c(t,e),i(t)}(Ve),Yu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={},a}return c(t,e),i(t)}(Ve),Zu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return c(t,e),i(t)}(Ve),Xu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),s}return c(t,e),i(t)}(Ke),Ju=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(Ve),$u=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),s}return c(t,e),i(t)}(Ke),ec=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({user_id:o,seconds:u,description:c}),a}return c(t,e),i(t)}(Ve),tc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),i.data.member_count&&(s.memberCount=i.data.member_count),i.data.joined_member_count&&(s.joinedMemberCount=i.data.joined_member_count),s}return c(t,e),i(t)}(Ke),nc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(Ve),rc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),s}return c(t,e),i(t)}(Ke),ac=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.freezing;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/freeze"),a.params={freeze:o},a}return c(t,e),i(t)}(Ve),ic=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).freeze=i.data.freeze,s}return c(t,e),i(t)}(Ke),sc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Fe(s),"/").concat(encodeURIComponent(i)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return c(t,e),i(t)}(Ve),oc=function(t){function a(t){var i;r(this,a);var s=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,d=t.description;return(i=n(this,a)).method=_e.POST,i.path="".concat(Se,"/users/").concat(l),i.params={channel_url:s,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:d},i}return c(a,t),i(a)}(Ve),uc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,d=e.description,h=e.messageToken;return(a=n(this,t)).method=_e.POST,a.path="".concat(Fe(s),"/").concat(encodeURIComponent(i),"/messages/").concat(l),a.params=pe({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),a}return c(t,e),i(t)}(Ve),cc=function(t){function a(t){r(this,a);var i=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MESG",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:i,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,extended_message_payload:t.extendedMessagePayload}))}])}return c(a,t),i(a)}(We),lc=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"MESG",i])).message=new po(e,i);var d=ss.of(e).sdkState;return s.isMentioned=qe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),dc=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MEDI",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))}])}return c(a,t),i(a)}(We),hc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"MEDI",i])).message=new po(e,i);var h=ss.of(e).sdkState;return s.mentionCountChange=He({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),fc=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FEDI",ackRequired:!0,payload:pe(ve({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:i,apple_critical_alert_options:t.appleCriticalAlertOptions}))}])}return c(a,t),i(a)}(We),pc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"FEDI",i])).message=new yo(e,i);var h=ss.of(e).sdkState;return s.mentionCountChange=He({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),vc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(Ve),_c=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new fs(a),i}return c(t,e),i(t)}(ze),mc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(Ve),gc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new fs(Object.assign({},a)),i}return c(t,e),i(t)}(ze),yc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return c(t,e),i(t)}(Ve),Ec=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new po(e,a),i}return c(t,e),i(t)}(ze),kc=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.POST,i.path="".concat(Pe(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(Ve),bc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new po(e,a),i}return c(t,e),i(t)}(ze),Cc=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl;return i.method=_e.POST,i.path="".concat(Pe(c),"/").concat(encodeURIComponent(l),"/scheduled_messages"),i.params=ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return us.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),i}return c(a,t),i(a)}(Ve),wc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new yo(e,a),i}return c(t,e),i(t)}(ze),xc=function(e){return D("string",e.title,!0)&&co(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0)},Sc=function(e){function t(e){var a,i=e.pollId,s=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a.params={title:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(Ve),Tc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Ic=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(Ve),Nc=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/close"),a}return c(t,e),i(t)}(Ve),Ac=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Mc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.optionText;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:i,channel_type:s,text:u},a}return c(t,e),i(t)}(Ve),Oc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Uc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId,o=e.optionText;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a.params={text:o},a}return c(t,e),i(t)}(Ve),Dc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Rc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),Lc=function(t){function a(t){var i=t.reqId,s=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n(this,a,[{code:"VOTE",ackRequired:!0,payload:pe({req_id:i,channel_type:s===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})}])}return c(a,t),i(a)}(We),Pc=i((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})),Fc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"VOTE",i])).event=new Pc(i),s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),qc=function(e){function t(e){var a,i=e.title,s=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=Ne,a.params={title:i,options:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(Ve),Hc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Gc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(Ve),jc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Vc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(Ve),zc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pollOption=new lo(e,a),i}return c(t,e),i(t)}(ze),Bc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/polls/changelogs"),a.params=pe({change_ts:o,token:u}),a}return c(t,e),i(t)}(Ve),Qc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedPolls=a.updated.map((function(t){return function(e,t){return new ho(e,t)}(e,t)})),i.deletedPollIds=a.deleted.map((function(e){return e})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(ze),Kc={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Wc=function(e){return D("string",e.title)&&(t=e.optionTexts,P("string",t)&&t.every((function(e){return""!==e.trim()})))&&co(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0);var t},Yc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},Zc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)&&t.pollId>0&&D("number",t.pollOptionId)&&t.pollOptionId>0},Xc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},Jc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)},$c={},el=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,u=n.logger;r(this,e),this._iid=t,this._sdkState=a,this._sessionManager=s,this._requestQueue=o,this._dispatcher=i,this._logger=u,$c[t]=this}),[{key:"buildPollFromSerializedData",value:function(e){var t=oi(e);return new ho(this._iid,ho.payloadify(t))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(Jc(e)).throw(A.invalidParameters),n=new Gc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(jc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(Wc(e)).throw(A.invalidParameters),n=new qc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Hc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(Zc(e)).throw(A.invalidParameters),n=new Vc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(zc),i=a.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogs",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.SYNC_POLL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Bc(ve({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null})),e.next=3,this._requestQueue.send(i);case 3:return s=e.sent,o=s.as(Qc),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,u.length>0&&this._dispatcher.dispatch(new Vs({polls:u,source:a})),e.abrupt("return",{updatedPolls:u,deletedPollIds:c,hasMore:l,token:h});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return $c[e]}}])}(),tl="GroupChannel",nl="Message",rl="NotificationMessage",al=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=Ne,a.params={channel_url:i,channel_type:s,token:o,limit:u},a}return c(t,e),i(t)}(Ve),il=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).polls=(null!==(s=a.polls)&&void 0!==s?s:[]).map((function(t){return new ho(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(ze),sl=function(e){function t(e,a){return r(this,t),n(this,t,[e,a.channelUrl,a.channelType,a])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new al(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(il),s=i.polls,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),ol=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:i,channel_type:s,token:c,limit:l},a}return c(t,e),i(t)}(Ve),ul=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).voters=(null!==(s=a.voters)&&void 0!==s?s:[]).map((function(t){return new li(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(ze),cl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a.channelUrl,a.channelType,a])).pollId=a.pollId,i.pollOptionId=a.pollOptionId,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("number",this.pollId)&&D("number",this.pollOptionId)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new ol(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(ul),s=i.voters,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu);var ll,dl=Object.assign(Object.assign({},Qo),{fileInfoList:[],message:""}),hl=function(e){return(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},fl=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._onFileUploaded=ft,e}return c(t,e),i(t,[{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(t,"onPending",this,3)([e]),this}},{key:"onFailed",value:function(e){return p(t,"onFailed",this,3)([e]),this}},{key:"onSucceeded",value:function(e){return p(t,"onSucceeded",this,3)([e]),this}}])}(Bo),pl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e])).message=null,i.message=go(e,a.message),i}return c(t,e),i(t)}($a),vl=function(e){function t(e){var a;r(this,t);var i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,d=e.includeParentMessageInfo,h=e.includeThreadInfo,f=e.includePollDetails;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/pinned_messages"),a.params=pe({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),a}return c(t,e),i(t)}(Ve),_l=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.pinned_messages,o=a.has_more,u=a.next;return i.pinnedMessages=s.map((function(t){return new pl(e,t)})),i.hasMore=o,i.token=u,i}return c(t,e),i(t)}(ze),ml=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s])).includeMetaArray=s.includeMetaArray,o.includeReactions=s.includeReactions,o.includeParentMessageInfo=s.includeParentMessageInfo,o.includeThreadInfo=s.includeThreadInfo,o.includePollDetails=s.includePollDetails,o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeMetaArray,!0)&&D("boolean",this.includeReactions,!0)&&D("boolean",this.includeParentMessageInfo,!0)&&D("boolean",this.includeThreadInfo,!0)&&D("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new vl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(_l),s=i.pinnedMessages,o=i.hasMore,u=i.token,this._token=u,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(vu),gl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(Ve),yl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(Ve);!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(ll||(ll={}));var El,kl=function(t){function a(t,i){var s,o,u,c,l,d,h,f;return r(this,a),(s=n(this,a,[t]))._name="",s._createdAt=0,s.pinnedMessageIds=[],s.channelType=e.ChannelType.BASE,s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s._messageCollectionLastAccessedAt=0,s._url=i.channel_url,s._name=null!==(o=i.name)&&void 0!==o?o:"",s._createdAt=1e3*i.created_at,s.coverUrl=null!==(u=i.cover_url)&&void 0!==u?u:"",s.customType=null!==(c=i.custom_type)&&void 0!==c?c:"",s.data=null!==(l=i.data)&&void 0!==l?l:"",s.isFrozen=null!==(d=i.freeze)&&void 0!==d&&d,s.isEphemeral=null!==(h=i.is_ephemeral)&&void 0!==h&&h,s.creator=i.created_by?new li(s._iid,i.created_by):null,i.metadata&&Object.keys(i.metadata).length>0&&i.ts?(s._cachedMetaData=new Map,Object.keys(i.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:i.metadata[e],isRemoved:!1,updatedAt:i.ts})}))):"string"==typeof i.metadata&&(s._cachedMetaData=new Map(Object.entries(JSON.parse(i.metadata)))),s.pinnedMessageIds=null!==(f=i.pinned_message_ids)&&void 0!==f?f:[],s}return c(a,t),i(a,[{key:"url",get:function(){return this._url}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"createdAt",get:function(){return this._createdAt}},{key:"toJSON",value:function(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}},{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"isFeedChannel",value:function(){return this.channelType===e.ChannelType.FEED}},{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:"_serializeCachedMetaData",value:function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=pe(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:"_updateCachedMetaData",value:function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(a,i){var s;a.updatedAt<=t&&(n._cachedMetaData.set(i,{value:null!==(s=e[i])&&void 0!==s?s:a.value,isRemoved:!e[i],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}}},{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 gu(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new bu(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new xu(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yu(this._iid,this.url,this.channelType,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ml(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Su({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"removeOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Tu({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyMutedInfo",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Iu({channelUrl:this.url,channelType:this.channelType,userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Nu),o=s.isMuted,u=s.startAt,c=s.endAt,l=s.remainingDuration,h=s.description,e.abrupt("return",{isMuted:o,startAt:u,endAt:c,remainingDuration:l,description:h});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Au({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(Mu),o=s.metadata,u=s.ts,this._upsertCachedMetaData(o,u),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Au({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Mu),s=i.metadata,o=i.ts,this._updateCachedMetaData(s,o),e.abrupt("return",s);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Ou({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Uu),o=s.metaData,this._upsertCachedMetaData(o,0),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=new Du({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Ru),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Pu({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:i=t.sent,s=i.as(Fu),o=s.ts,this._removeFromCachedMetaData([e],o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new qu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Hu),s=i.ts,this._removeFromCachedMetaData(v(this._cachedMetaData.keys()),s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Gu({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(ju),o=s.metaCounter,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Gu({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(ju),s=i.metaCounter,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Vu({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(zu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaCounters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=new Bu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Qu),u=o.metaCounter,n.abrupt("return",u);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Bu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Qu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Bu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Qu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Wu({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Yu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.muteUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"muteUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new Zu({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unmuteUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Ju({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"banUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.banUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"banUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new ec({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unbanUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unbanUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new nc({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"freeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new ac({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,n.send(r);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new ac({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,n.send(r);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Ao),t),ui(D("number",e)&&Mo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessagesByMessageId(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Ao),t),ui(D("number",e)&&Mo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessagesByTimestamp(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Oo),t),ui(D("number",e)&&Uo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Oo),t),ui(D("string",e)&&Uo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,i=ss.of(this._iid).sessionManager;return pe(ve({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 ks.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:i.currentUser?Es.payloadify(i.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 li.payloadify(e)}))}))}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var i,o=s(t.translationTargetLanguages);try{for(o.s();!(i=o.n()).done;){a[i.value]=""}}catch(e){o.e(e)}finally{o.f()}}var u=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a,extended_message_payload:t.extendedMessagePayload})),c=new po(this._iid,u);return c.messageParams=t,c}},{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,i,s,o,u,c,l,d=pe(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===(i=t.file)||void 0===i?void 0:i.name,size:null!==(s=t.fileSize)&&void 0!==s?s: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:null===(l=t._thumbnails)||void 0===l?void 0:l.map((function(e){return us.payloadify(e)})),message:t.message})),h=new yo(this._iid,d);return h.messageParams=t,h}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,file:t.fileInfoList.length>0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0,message:t.message})),i=new vo(this._iid,a);return i.messageParams=t,i}},{key:"_validateFailedFileMessageHasFile",value:function(e,t){var n;return Boolean(e.url)||H(t)||H(null===(n=e.messageParams)||void 0===n?void 0:n.file)}},{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.SendbirdErrorCode.REQUEST_CANCELED||n.code===e.SendbirdErrorCode.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({},Yo),e);return ui($o(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ll.SEND,a=arguments.length>2?arguments[2]:void 0,i=ss.of(this._iid),s=i.dispatcher,o=i.requestQueue,u=null!=a?a:this._generateRequestId(),c=Date.now(),l=new Bo;return ki(2).then((function(){var a=n._createPendingUserMessage(t,u,c);s.dispatch(new Fs({messages:[a],source:r===ll.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a));case 1:case"end":return e.stop()}}),e)})))}));var i=new cc(Object.assign(Object.assign({},t),{channelUrl:n.url,channelType:n.channelType,reqId:u}));o.send(i).then((function(t){var r=t.as(lc).message;s.dispatch(new Fs({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().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)})))}))})).catch((function(r){if(N(r))throw r;ki(2).then((function(){var a=n._createPendingUserMessage(t,u,c),i=ss.of(n._iid).cacheContext,o=i.localCacheEnabled&&i.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,o),s.dispatch(new Fs({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),l}},{key:"_autoResendUserMessage",value:function(e){return ui(e instanceof po&&!!e.messageParams).throw(A.invalidParameters),this._sendUserMessage(e.messageParams,ll.SEND,e.reqId)}},{key:"resendUserMessage",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof po&&!e.scheduledInfo).throw(A.invalidParameters),r=new ut,a=null!==(t=e.messageParams)&&void 0!==t?t:Jo(e),this._sendUserMessage(a,ll.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"updateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},lu),t),ui(D("number",e)&&du(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new dc(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(hc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"copyUserMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ui(t instanceof a&&n instanceof po&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),ui(!n.poll).throw(A.notSupportedError),u=new ut,c=null!==(r=n.messageParams)&&void 0!==r?r:ve(Object.assign(Object.assign({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(s=n.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),t._sendUserMessage(c).onSucceeded((function(e){u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 6:case"end":return o.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof po&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new yc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(Ec),u=o.message,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_createScheduledUserMessage",value:function(e,t){var n=this,r=ss.of(this._iid).requestQueue,a=Date.now(),i=this._generateRequestId();ki(2).then((function(){var r=n._createPendingScheduledUserMessage(e,i,a);_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))}));var s=new kc(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(bc).message;_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;ki(2).then((function(){var s=n._createPendingScheduledUserMessage(e,i,a);n._markMessageAsFailed(s,r),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},ru),e);return ui(ou(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},dl),e),r=ss.of(this._iid);ui(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return Ko(e)&&D("string",e.message,!0)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return hl(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 ui(!a).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ll.SEND,a=arguments.length>2?arguments[2]:void 0,i=ss.of(this._iid).dispatcher,s=oh.of(this._iid).fileMessageQueue,o=null!=a?a:this._generateRequestId(),u=Date.now(),c=new Bo;return ki(2).then((function(){var a=n._createPendingFileMessage(t,o,u);i.dispatch(new Fs({messages:[a],source:r===ll.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a));case 1:case"end":return e.stop()}}),e)})))})),s.request(n,o,t).then((function(t){i.dispatch(new Fs({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;ki(2).then((function(){var a=n._createPendingFileMessage(t,o,u),s=ss.of(n._iid).cacheContext,l=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,l),i.dispatch(new Fs({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:r.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_autoResendFileMessage",value:function(e){ui(e instanceof yo&&!!e.messageParams).throw(A.invalidParameters);var t=ss.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,ll.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(t,n,r){var a=this,i=ss.of(this._iid).dispatcher,s=oh.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new fl;return ki(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);i.dispatch(new Fs({messages:[r],source:n===ll.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(r));case 1:case"end":return e.stop()}}),e)})))})),s.request(a,o,t,{requestHandler:c,isCopy:n===ll.COPY}).then((function(t){i.dispatch(new Fs({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(n){if(N(n))throw n;ki(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);a._markMessageAsFailed(r,n),i.dispatch(new Fs({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(n,r));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_createScheduledFileMessage",value:function(e,t,n,r){var a=this,i=ss.of(this._iid).requestQueue,s=new Cc(Object.assign(Object.assign({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(s).then((function(e){var n=e.as(wc).message;_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(N(i))throw i;ki(2).then((function(){var s=a._createPendingScheduledFileMessage(e,n,r);a._markMessageAsFailed(s,i),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(i,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){ui(e.every((function(e){return ou(Object.assign(Object.assign({},ru),e))}))).throw(A.invalidParameters);var t,n=new Bo,r=s(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,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._validateFailedFileMessageHasFile(e,t),ui(e instanceof yo&&r&&!e.scheduledInfo).throw(A.invalidParameters),a=new ut,i=su(e,t),this._sendFileMessage(i,ll.RESEND,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),n.abrupt("return",a.promise);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"resendMessage",value:function(e,t){var n,r;if(ui(e instanceof to&&!e.scheduledInfo&&e.isResendable).throw(A.invalidParameters),e.isUserMessage()){var a=null!==(n=e.messageParams)&&void 0!==n?n:Jo(e);return this._sendUserMessage(a,ll.RESEND,e.reqId)}if(e.isFileMessage()){var i=this._validateFailedFileMessageHasFile(e,t);ui(i).throw(A.invalidParameters);var s=null!==(r=e.messageParams)&&void 0!==r?r:su(e,t);return this._sendFileMessage(s,ll.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"updateFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},hu),t),ui(D("number",e)&&fu(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new fc(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(pc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"uploadFile",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=ce(),(i=new cs({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a),t.next=7,r.send(i);case 7:return s=t.sent,o=s.as(ls),u=o.url,c=o.thumbnails,t.abrupt("return",{requestId:a,url:u,thumbnails:c});case 10:case"end":return t.stop()}}),t,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=oh.of(this._iid),n.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"copyFileMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ui(t instanceof a&&n instanceof yo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),u=new ut,c=ve(Object.assign(Object.assign({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=n.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),t._sendFileMessage(c).onSucceeded((function(e){return u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 5:case"end":return o.stop()}}),o,this)})))}},{key:"copyMessage",value:function(t,n){ui(t instanceof a&&n instanceof to&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters);var r=n,i=t;if(r.isUserMessage()){ui(!r.poll).throw(A.notSupportedError);var s=Zo(r);return i._sendUserMessage(s)}if(r.isFileMessage()){var o=au(r);return i._sendFileMessage(o)}if(n.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"deleteMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ui(e instanceof eo).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return n=ss.of(this._iid),r=n.requestQueue,a=new lt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof to?e._messageToken:void 0}),t.next=6,r.send(a);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"addReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof eo&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new vc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(_c),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof eo&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new mc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(gc),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_updateUserMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=ss.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new dc({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(hc),f=h.message,o.dispatch(new Fs({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=ss.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new fc({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(pc),f=h.message,o.dispatch(new Fs({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new ks({key:e})})),!(e instanceof yo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"add",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"add",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new ks({key:e})})),!(e instanceof yo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"remove",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"remove",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&t.every((function(e){return e instanceof ks}))).throw(A.invalidParameters),!(e instanceof yo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"add",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"add",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&t.every((function(e){return e instanceof ks}))).throw(A.invalidParameters),!(e instanceof yo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"remove",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"remove",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"report",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(R(e.ReportCategory,t)&&D("string",n)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new sc({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:t,description:n}),r.next=5,s.send(o);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"reportUser",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ui(t instanceof li&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=ss.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new oc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.userId,category:n,description:r}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"reportMessage",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ui(t instanceof to&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=ss.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new uc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r,messageToken:t._messageToken}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"updatePoll",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("number",e)&&xc(t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Sc(Object.assign({pollId:e},t)),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(Tc),u=o.poll,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deletePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ui(n).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Ic({pollId:e}),t.next=6,a.send(i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"closePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ui(n).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Nc({pollId:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Ac),u=o.poll,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"addPollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("string",t)&&""!==t.trim(),ui(r).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new Mc({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(Oc),c=u.poll,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updatePollOption",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",e)&&D("number",t)&&D("string",n)&&""!==n.trim(),ui(a).throw(A.invalidParameters),i=ss.of(this._iid),s=i.requestQueue,o=new Uc({pollId:e,pollOptionId:t,optionText:n}),r.next=6,s.send(o);case 6:return u=r.sent,c=u.as(Dc),l=c.poll,r.abrupt("return",l);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"deletePollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("number",t),ui(r).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new Rc({pollId:e,pollOptionId:t}),n.next=6,i.send(s);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"votePoll",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",t)&&P("number",n),ui(a).throw(A.invalidParameters),i=ss.of(this._iid),s=i.requestQueue,o=i.dispatcher,u=new Lc({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:n}),r.next=6,s.send(u);case 6:return c=r.sent,l=c.as(Fc),h=l.event,o.dispatch(new Bs({event:h,source:e.CollectionEventSource.EVENT_POLL_VOTED})),r.abrupt("return",h);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("number",e)).throw(A.invalidParameters),n=el.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e,!0)),n=el.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new sl(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 cl(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}},{key:"pinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("number",e)&&e>0).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new gl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unpinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("number",e)&&e>0).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new yl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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?li.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}}])}($a),bl=i((function e(t){r(this,e),this.key=t.key,this.url=t.url})),Cl=i((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 bl(e)})):[]})),wl=i((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new Cl(e)})):[]})),xl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onConnected=ft,this.onReconnectStarted=ft,this.onReconnectSucceeded=ft,this.onReconnectFailed=ft,this.onDisconnected=ft}))),Sl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onSessionExpired=ft,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=ft,this.onSessionRefreshed=ft,this.onSessionClosed=ft}))),Tl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onFriendsDiscovered=ft,this.onTotalUnreadMessageCountChanged=ft,this.onTotalUnreadMessageCountUpdated=ft}))),Il=function(e){function t(e){var a,i=e.limit,s=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=ge,a.params=pe({limit:i,token:s,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return c(t,e),i(t)}(Ve),Nl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new li(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(ze),Al=function(e){function t(e,a){var i,s,o,u;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.metaDataKeyFilter=null,i.metaDataValuesFilter=null,i.nicknameStartsWithFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i.metaDataKeyFilter=null!==(o=a.metaDataKeyFilter)&&void 0!==o?o:null,i.metaDataValuesFilter=null!==(u=a.metaDataValuesFilter)&&void 0!==u?u:null,i.nicknameStartsWithFilter=a.nicknameStartsWithFilter||null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)&&D("string",this.metaDataKeyFilter,!0)&&P("string",this.metaDataValuesFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Il(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Nl),s=i.users,o=i.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),Ml=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token,u=e.userIdsFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/block"),a.params=pe({limit:s,token:o,user_ids:u}),a}return c(t,e),i(t)}(Ve),Ol=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new li(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(ze),Ul=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ml(ve(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token}))),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Ol),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),Dl=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={limit:s,token:o},a}return c(t,e),i(t)}(Ve),Rl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).hasMore=a.has_more,i.users=a.users.map((function(t){return new li(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(ze),Ll=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Dl(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Rl),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),Pl={},Fl=function(){return i((function e(t){var n=t.dbname,a=t.itemSizeLimit,i=void 0===a?1048576:a,s=t.cacheLimit,o=void 0===s?256:s,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,d=void 0===l?10:l,h=t.blockHashConstant,f=void 0===h?11:h,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),Pl[n]||(this.itemSizeLimit=i,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=d,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,Pl[n]=this),Pl[n]}),null,[{key:"get",value:function(e){return Pl[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"}(El||(El={}));var ql,Hl=function(e){function t(e){var a,i=e.code,s=void 0===i?El.UNKNOWN_ERROR:i,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,t),(a=n(this,t,[u])).code=s,Object.setPrototypeOf(a,t.prototype),a}return c(t,e),i(t,null,[{key:"storeNotDefined",get:function(){return new t({code:El.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new t({code:El.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new t({code:El.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new t({code:El.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new t({code:El.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new t({code:El.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new t({code:El.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new t({code:El.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new t({code:El.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new t({code:El.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new t({code:El.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new t({code:El.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new t({code:El.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new t({code:El.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new t({code:El.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new t({code:El.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new t({code:El.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new t({code:El.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new t({code:El.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new t({code:El.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new t({code:El.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new t({code:El.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new t({code:El.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new t({code:El.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new t({code:El.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}])}(y(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(ql||(ql={}));var Gl,jl=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===m(e)&&null!==e){if(t.has(e))throw Hl.circularReferenceFound;var n;return t.set(e,!0),Array.isArray(e)?n=e.map((function(e){return jl(e,t)})):e instanceof RegExp||e instanceof Date?n=e:(n={},Object.keys(e).forEach((function(r){n[r]=jl(e[r],t)}))),t.delete(e),n}return e},Vl=function(e,t){if(null==t)return 1;if(null==e)return-1;if(m(e)!==m(t))throw Hl.compareTypesNotMatch;var n=0;switch(m(e)){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},zl=function(e,t){for(var n=0,r=0;r>>0)%t},Bl=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Ql=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!Ql(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Ql(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"===m(e[r])){var a=e[r];for(var i in a)switch(i){case"/eq":case"=":if(t[r]!==a[i])return!1;break;case"/neq":case"!=":if(t[r]===a[i])return!1;break;case"/gt":case">":var s=t[r],o=a[i];if(!(Vl(s,o)>0))return!1;break;case"/gte":case">=":var u=t[r],c=a[i];if(!(Vl(u,c)>=0))return!1;break;case"/lt":case"<":var l=t[r],d=a[i];if(!(Vl(l,d)<0))return!1;break;case"/lte":case"<=":var h=t[r],f=a[i];if(!(Vl(h,f)<=0))return!1;break;case"/in":var p=t[r];if(!a[i].includes(p))return!1;break;case"/nin":var v=t[r];if(a[i].includes(v))return!1;break;case"/contain":var _=t[r],g=a[i];if(!_.includes(g))return!1;break;case"/regex":var y=t[r];if(!a[i].test(y))return!1;break;case"/where":var E=t[r];if(!(0,a[i])(E))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)},Kl=function(){},Wl=function(){return Promise.resolve()},Yl=function(e){return e},Zl=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Gl||(Gl={}));var Xl,Jl,$l,ed=function(){return i((function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,i=t.initialNextValue,s=void 0===i?null:i,o=t.iterator,u=t.map,c=void 0===u?Yl:u,l=t.backward,d=void 0===l?Wl:l,h=t.forward,f=void 0===h?Wl:h,p=t.complete,v=void 0===p?Kl:p;r(this,e),this._prevValue=a,this._nextValue=s,this._error=null,this._map=c,this._backward=d,this._forward=f,this._iterator=o,this._complete=v}),[{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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,t=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,t=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}])}(),td=function(){return i((function e(t){var n=t.condition,a=void 0===n?{}:n,i=t.backward,s=void 0!==i&&i,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=s,this._blockManager=o,this._indexer=u}),[{key:"findOptimizedStartPosition",value: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 a=0;a0?n:t;for(var u in this.condition[i])if(o.includes(u))for(var c=r;c>=0;c--)if(s*Vl(this._indexer.origin[c].columnValues[a],this.condition[i][u])<=0){r=c;break}}else for(var l=r;l>=0;l--)if(s*Vl(this._indexer.origin[l].columnValues[a],this.condition[i])<=0){r=l;break}}return Math.min(r+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var h=function(r){var a=e._indexer.fields[r],i=1;if("-"===a[0]&&(a=a.slice(1),i=-1),e.condition[a])if("object"===m(e.condition[a]))Object.keys(e.condition[a]).forEach((function(s){if((i>0?t:n).includes(s))for(var o=d;o=0){d=o;break}}));else for(var s=d;s=0){d=s;break}},f=0;f0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Math.max(e.offset||0,0),0!==(r="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){t.next=6;break}return t.abrupt("return",[]);case 6:if(!(r<0)){t.next=8;break}throw Hl.collectionQueryNotValid;case 8:return t.prev=8,a=[],t.next=12,this._mutex.lock();case 12:return t.next=14,this._iterator.each((function(e){return E(i,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===n?(a.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(od(e,t)).concat(n,".").concat(r)},cd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=i}),[{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(n=t.sent)){t.next=19;break}if(r=n.data,a=n.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(r);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(s=[],o=atob(r.split(",")[1]),u=0;u1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,new Promise((function(n){var r=ud(o.dbname,o.collectionName,t),a=new FileReader;a.onload=function(){n({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return r=n.sent,a=r.blobId,i=r.data,s=r.type,n.next=8,this.store.set({key:a,value:{data:i,type:s}});case 8:return n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=od(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return n=e.sent,e.next=6,Promise.all(n.filter((function(e){return e.startsWith(t)})).map((function(e){return E(r,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}])}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Xl||(Xl={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Jl||(Jl={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}($l||($l={}));var ld,dd,hd=[Jl.PENDING,Jl.VOLATILE],fd={},pd=function(){return i((function e(t){var n=t.dbname,a=t.limit,i=void 0===a?256:a;return r(this,e),fd[n]||(this.dbname=n,this._items=[],this._limit=i,fd[n]=this),fd[n]}),[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$l.DEFAULT;return E(this,void 0,void 0,d().mark((function r(){var a,i;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=this.get(t)){r.next=8;break}return r.next=4,e.get(t);case 4:(i=r.sent)&&(a={key:t,value:i,state:n===$l.PERSISTENT?Jl.PERSISTENT:Jl.VOLATILE},this.put(a)),r.next=9;break;case 8:n===$l.PERSISTENT&&(a.state=Jl.PERSISTENT);case 9:return r.abrupt("return",a);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$l.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===$l.PERSISTENT&&(r.state=Jl.PERSISTENT),t!==$l.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)hd.includes(this._items[t].state)&&hd.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===Jl.VOLATILE})),r=n.length-this._limit;if(r>0){var a,i=[],o=s(this._items);try{for(o.s();!(a=o.n()).done;){var u=a.value;u.state===Jl.VOLATILE&&r>0?r--:i.push(u)}}catch(e){o.e(e)}finally{o.f()}this._items=i}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clearForDatabase",value:function(e){this.clearByCondition((function(t){return t.key.startsWith(rd(e))}))}},{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!==Jl.VOLATILE}))}}],[{key:"get",value:function(e){return fd[e]}}])}(),vd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=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(ad(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(ad(e,t),"/trans.recordset")}(n,a),this._store=i}),[{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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(n=t.t0).push.apply(n,v(e)),t.abrupt("return",this._reduceRecordSet(n));case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],i=[],s=a.requests.length-1;s>=0;s--){var o=a.requests[s],u=o.data;n[u.key]||(i.unshift(o),n[u.key]=!0)}i.length>0&&(a.requests=i,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=pd.get(this.dbname),a=t.generation,i=t.requests,s=null,n.prev=3,n.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:a})})));case 6:for(o=n.sent,u=0;u0)){e.next=20;break}for(n=[],r={},a=t.length-1;a>=0;a--)i=t[a],s=i.data,r[s.key]||(r[s.key]=!0,n.unshift(i));return o={generation:this.generation,requests:n},e.next=8,this._getReducedRecordset([o]);case 8:return u=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:u});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(c=pd.get(this.dbname),l=0;l1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=i,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||zl)(e,r)}(e,i,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(sd(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=pd.get(this.dbname),r=this.metadata.blockLevel;case 2:if(!(r>0)){t.next=15;break}return a=this.createBlockId(e,r),t.next=6,n.find(this._store,a);case 6:if(!(i=t.sent)){t.next=12;break}if(s=_d.createFromCacheItem(i),!(null==s?void 0:s.getItemByKey(e))){t.next=12;break}return t.abrupt("return",s);case 12:r--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"getFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return n=t.sent,t.abrupt("return",n?n.getItemByKey(e):null);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"putToBlock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Fl.get(this.dbname),a=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/r.itemSizeLimit),s=pd.get(this.dbname),n.next=6,s.find(this._store,a);case 6:if(o=n.sent,!(null==(u=o?_d.createFromCacheItem(o):new _d({blockId:a,keyName:this.keyName,items:[],limit:i}))?void 0:u.add(t))){n.next=11;break}return this._transaction.requestWrite({key:u.blockId,value:u.serialize()}),n.abrupt("return",!0);case 11:return n.abrupt("return",!1);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"removeFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(n=t.sent)){t.next=7;break}if(!n.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:n.blockId,value:n.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"clearAllBlocks",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=sd(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return n=e.sent,r=n.filter((function(e){return e.startsWith(t)})),e.next=7,this._store.removeMany(r);case 7:return e.next=9,this._transaction.clear();case 9:pd.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(t)}));case 11:case"end":return e.stop()}}),e,this)})))}}])}(),gd=function(){return i((function e(t){var n=this,a=t.dbname,i=t.collectionName,s=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(ad(e,t),"/index.").concat(n)}(a,i,o.join(">"));this.dbname=a,this.collectionName=i,this.keyName=s,this.fields=o,this.indexerKey=l,this._store=c,this._transaction=u,this._transaction.on(Xl.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Xl.ERROR,this.indexerKey,(function(){return n.abort()}))}),[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=f(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=f(this.indexOf(n),2),a=r[0];if(r[1]){var i=this._table[a].keys.indexOf(t);if(i>-1)return this._table[a].keys.splice(i,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,n,r,a=[],i=s(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),n=e[o],r=void 0,r=m(n),null!==n&&"undefined"!==r&&"boolean"!==r&&"number"!==r&&"string"!==r)throw Hl.indexTypesNotMatch;a.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return a}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Vl(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,d().mark((function e(){var t,n,r,a,i,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=pd.get(this.dbname),e.next=3,t.find(this._store,this.indexerKey,$l.PERSISTENT);case 3:if(n=e.sent){e.next=33;break}return r=sd(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:a=e.sent,i=s(a),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=22;break}if(!(u=o.value).startsWith(r)){e.next=20;break}return e.next=17,t.find(this._store,u,$l.NO_CACHE);case 17:if(c=e.sent,l=_d.createFromCacheItem(c)){h=s(l.items);try{for(h.s();!(f=h.n()).done;)p=f.value,this._addItem(p)}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=n.value,this._table=jl(this._origin);case 35:case"end":return e.stop()}}),e,this,[[10,24,27,30]])})))}},{key:"drop",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return pd.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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=jl(this._origin)}},{key:"abort",value:function(){this._table=jl(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}}])}(),yd=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},Ed=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"}(ld||(ld={})),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"}(dd||(dd={}));var kd,bd={},Cd=function(){return i((function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=ld.PROCESSING,this._queue=[],this._activationQueue=[],bd[t]&&!a.forceCreate||(this.nodeId=Ed(),this.key=t,yd()&&(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;if(null==t?void 0:t.isNestDbMessage){var r=t.nodeId,a=t.requestId,i=t.key,o=t.op,u=t.data;if(r!==n.nodeId&&i===n.key)switch(o){case dd.NEWNODE:n._sendSync();break;case dd.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case dd.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var c,l=u.currentItemRequestId,d=s(u.queue);try{var h=function(){var e=c.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:dd.REQUEST_LOCK,ts:e.ts})};for(d.s();!(c=d.n()).done;)h()}catch(e){d.e(e)}finally{d.f()}n._currentItem=n._queue.find((function(e){return e.requestId===l})),n._completeSync()}break;case dd.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 dd.REQUEST_LOCK:n._requestLock(t);break;case dd.ACQUIRE_LOCK:var f=n._queue.find((function(e){return e.requestId===a}));n._acquire(f);break;case dd.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(dd.REMOVENODE)}))),bd[t]=this),bd[t]}),[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==ld.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:Ed(),key:this.key,op:e,data:n.data,ts:Date.now()};return yd()&&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(dd.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){for(var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(dd.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1,i=0;ir.ts){t._queue.splice(i,0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(dd.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,d().mark((function e(){var t=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){t._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=ld.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(dd.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(dd.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return t=this._send(dd.REQUEST_LOCK),e.next=5,this._requestLock(t);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)}}])}(),wd=function(){function e(t){var n=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=ql.INIT,this._indexers=[],this.dbname=a,this.name=i,this.keyName=s,this.indexes=[[s]].concat(v(u.filter((function(e){return gd.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new Cd(function(e,t){return"".concat(ad(e,t),".lock")}(a,i)),this._blobContainer=new cd({dbname:a,collectionName:i,store:c}),this._transaction=new vd({dbname:a,collectionName:i,store:c})}return i(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===ql.READY}},{key:"init",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l,h,f,p,_=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,n=Fl.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return r=t.sent,this._metadata=r||{keyName:this.keyName,blockLevel:1,blockHashBase:n.blockHashBase,blockHashMultiplier:n.blockHashMultiplier,blockHashConstant:n.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new md({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),a=v(this.indexes),i=[],o=a.map((function(e){return gd.createKey(e)})),u=r?r.indexes.map((function(e){return gd.createKey(e)})):[],c=s(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(gd.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(f=[]).push.apply(f,v(a.map((function(e){var t=new gd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()})))),f.push.apply(f,v(i.map((function(e){return new gd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()})))),t.next=22,Promise.all(f);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return p=id(this.dbname,this.name),this._metadata.indexes=a,t.next=29,this._store.set({key:p,value:this._metadata});case 29:this._state=ql.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),t,this,[[2,33]])})))}},{key:"close",value:function(){this._state=ql.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=gd.createKey(e),r=s(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===gd.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Hl.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=id(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:t,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:r=s(this._indexers),t.prev=14,r.s();case 16:if((a=r.n()).done){t.next=22;break}return i=a.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),r.e(t.t0);case 27:return t.prev=27,r.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Hl.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),t,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(r=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:a=s(this._indexers),t.prev=14,a.s();case 16:if((i=a.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),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(n,e);case 34:u=s(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(r),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(r);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()}}),t,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(!(r=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:a=s(this._indexers),t.prev=8,a.s();case 10:if((i=a.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(r),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(r);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),a.e(t.t0);case 24:return t.prev=24,a.f(),t.finish(24);case 27:case"end":return t.stop()}}),t,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(n=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:r=s(this._indexers),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return i=a.value,t.next=13,i.removeItem(n);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:case"end":return t.stop()}}),t,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:t=s(this._indexers),e.prev=3,t.s();case 5:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=9,r.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return n=t.sent,this._mutex.unlock(),t.abrupt("return",jl(n));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Hl.collectionNotReady;case 18:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new nd({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Hl.collectionNotReady}},{key:"insertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Hl.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(jl(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 Hl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Hl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestInsert(jl(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Hl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Hl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(jl(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 Hl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Hl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestUpsert(jl(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Hl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Hl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(jl(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 Hl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"updateIf",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.isReady){n.next=31;break}return n.next=3,this._mutex.lock();case 3:return n.prev=3,r=e.where,a=void 0===r?{}:r,i=e.index,s=void 0===i?null:i,o=e.backward,u=void 0!==o&&o,c=[],l=new td({condition:a,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(s)}),n.next=9,l.each((function(e){return E(v,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.error){n.next=4;break}e.hasNext?(r=e.nextValue,Ql(a,r)&&t.set&&("function"!=typeof t.set?Object.keys(t.set).forEach((function(e){var n;r[e]=null===(n=t.set)||void 0===n?void 0:n[e]})):t.set(r),c.push(r)),e.next()):e.stop(),n.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return n.stop()}}),n)})))}));case 9:h=0,f=c;case 10:if(!(h1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return v(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)),i=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(i).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:i}),r}))}},{key:"_resetIfEncryptionChanged",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(this._encryptionCheckKey);case 2:if(t=e.sent,n={encrypted:Id.map((function(e){var t;return null===(t=s.encryption)||void 0===t?void 0:t.encrypt(e)}))},!t){e.next=22;break}if(!t.encrypted||!Array.isArray(t.encrypted)){e.next=20;break}e.t0=d().keys(t.encrypted);case 7:if((e.t1=e.t0()).done){e.next=18;break}if(r=e.t1.value,a=JSON.stringify(t.encrypted[r]),i=JSON.stringify(n.encrypted[r]),a===i){e.next=16;break}return Td.warning("Encryption algorithm has changed. Stored data would be cleared."),e.next=15,this.clear();case 15:return e.abrupt("break",18);case 16:e.next=7;break;case 18:e.next=22;break;case 20:return e.next=22,this.clear();case 22:return e.next=24,this.set({key:this._encryptionCheckKey,value:n});case 24:case"end":return e.stop()}}),e,this)})))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=0,e.next=3,this._getAllRawKeys();case 3:n=e.sent,r=s(n),e.prev=5,r.s();case 7:if((a=r.n()).done){e.next=15;break}return i=a.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(t+=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),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})).filter((function(e){return!n._reservedKeys.includes(e)})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=21;break}if(t.prev=5,a=r.data,!((null==(i=r.metadata)?void 0:i.shards)&&i.shards>1)){t.next=13;break}return t.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return E(o,void 0,void 0,d().mark((function n(){var r,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>0)){n.next=10;break}return r=this._getRawKey(e,".".concat(t)),n.next=4,this._getRaw(r);case 4:if(i=n.sent){n.next=7;break}throw Hl.storeBrokenIntegrity;case 7:return n.abrupt("return",i.data);case 10:return n.abrupt("return",a);case 11:case"end":return n.stop()}}),n,this)})))})));case 10:t.t0=t.sent,t.next=14;break;case 13:t.t0=[a];case 14:return s=t.t0,t.abrupt("return",this.encryption.decrypt(JSON.parse(s.join(""))));case 18:return t.prev=18,t.t1=t.catch(5),t.abrupt("return",null);case 21:return t.abrupt("return",null);case 22:case"end":return t.stop()}}),t,this,[[5,18]])})))}},{key:"set",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._shardify(e),t.next=3,this._setRaw(n);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[],t.next=3,this._setRaw(n.concat.apply(n,v(e.map((function(e){return r._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=12;break}return a=r.metadata,i=this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return o._getRawKey(e,".".concat(t))})),t.next=9,this._removeRaw(i);case 9:return null==(s=pd.get(this.dbname))||s.remove(e),t.abrupt("return",!0);case 12:return t.abrupt("return",!1);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"removeMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=pd.get(this.dbname),r=[],a=s(e),t.prev=3,o=d().mark((function e(){var t,a,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.value,a=u._getRawKey(t,".0"),e.next=4,u._getRaw(a);case 4:(s=e.sent)&&(o=s.metadata,r.push.apply(r,v(u._generateShardPostfixArray(null==o?void 0:o.shards).map((function(e){return u._getRawKey(t,".".concat(e))}))))),null==n||n.remove(t);case 7:case"end":return e.stop()}}),e)})),a.s();case 6:if((i=a.n()).done){t.next=10;break}return t.delegateYield(o(),"t0",8);case 8:t.next=6;break;case 10:t.next=15;break;case 12:t.prev=12,t.t1=t.catch(3),a.e(t.t1);case 15:return t.prev=15,a.f(),t.finish(15);case 18:if(!(r.length>0)){t.next=21;break}return t.next=21,this._removeRaw(r);case 21:return t.abrupt("return",e);case 22:case"end":return t.stop()}}),t,this,[[3,12,15,18]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==(t=pd.get(this.dbname))||t.clearForDatabase(this.dbname);case 2:case"end":return e.stop()}}),e,this)})))}}])}(),Ad={},Md=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:4194304})]);var s=i.delay,o=void 0===s?1:s;return e.delay=o,e.observer={},e}return c(t,e),i(t,[{key:"rawData",get:function(){return Ad[this.dbname]},set:function(e){Ad[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Ad[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(Ad[this.dbname]));case 4:throw Hl.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ad[this.dbname]){t.next=6;break}return t.next=3,Bl(this.delay);case 3:return t.abrupt("return",Ad[this.dbname][e]?Object.assign({key:e},Ad[this.dbname][e]):null);case 6:throw Hl.storeNotAvailable;case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ad[this.dbname]){t.next=7;break}return t.next=3,Bl(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,i=a.key,o=a.data,u=a.metadata,Ad[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Hl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ad[this.dbname]){t.next=7;break}return t.next=3,Bl(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,Ad[this.dbname][a]&&delete Ad[this.dbname][a]}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Hl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,Ad[this.dbname]||(Ad[this.dbname]={}),t.next=4,this._resetIfEncryptionChanged();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(t,"set",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=this.observer[e.key])||"function"!=typeof n.set){t.next=5;break}if(!(a=n.set())){t.next=5;break}throw a;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(t,"setMany",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((a=n.n()).done){t.next=12;break}if(i=a.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),n.e(t.t0);case 17:return t.prev=17,n.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),t,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,Bl(this.delay);case 4:Ad[this.dbname]={};case 5:case"end":return e.stop()}}),e,this)})))}}])}(Nd),Od="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(kd||(kd={}));var Ud,Dd=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:104857600})]))._storeName=Od,e._state=kd.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 c(t,e),i(t,[{key:"state",get:function(){return this._state}},{key:"isTransactionInactiveError",value:function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}},{key:"_putToObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.put(t);a.addEventListener("success",(function(e){n(e.target.result)})),a.addEventListener("error",(function(){r("Failed to write.")}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_deleteFromObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.delete(t);a.addEventListener("success",(function(){return n(t)})),a.addEventListener("error",(function(e){return r(e.target.error)}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=kd.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Od,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=kd.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=kd.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=kd.UNINITIALIZED,r(e.target.error)}))}else r(Hl.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().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===kd.UNINITIALIZED||t.t0===kd.OPEN?7:t.t0===kd.OPENING||t.t0===kd.CLOSED?8:9;break;case 7:throw Hl.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){n._openJobQueue.push((function(){return t(n._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()}}),t,this)})))}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readonly");case 2:return t=e.sent,e.next=5,new Promise((function(e,n){var r=t.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return n(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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readonly");case 2:return n=t.sent,t.next=5,new Promise((function(t,r){var a=n.get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return r(e.target.error)}))}));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._putToObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._putToObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._deleteFromObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._deleteFromObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{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,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(t="undefined"!=typeof window?window:null)?void 0:t.indexedDB)||(null==t?void 0:t.mozIndexedDB)||(null==t?void 0:t.webkitIndexedDB)||(null==t?void 0:t.msIndexedDB))){e.next=16;break}if(this._indexedDb=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB,!this._window||!yd()){e.next=13;break}if(!(yd()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!t.PointerEvent&&!t.MSPointerEvent){e.next=7;break}throw Hl.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(n._indexedDb)try{var r=n._indexedDb.open("_testMozilla");r.onerror=function(){return t(Hl.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),n._indexedDb){var a=n._indexedDb.deleteDatabase("_testMozilla");a.onerror=function(){return e()},a.onsuccess=function(){return e()}}else t(Hl.storeNotAvailable)}}catch(e){t(Hl.storeNotAvailableInPrivateBrowsing)}else t(Hl.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Hl.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,d().mark((function t(){return d().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:return t.next=7,this._resetIfEncryptionChanged();case 7:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,this._getObjectStore("readwrite");case 4:return t=e.sent,e.next=7,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))}}])}(Nd),Rd=function(e){function t(e){var a;r(this,t);var i=e.AsyncStorage,s=e.itemSizeLimit,o=void 0===s?2097152:s,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof to))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}if(t instanceof eo)switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof to&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}])}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Hd||(Hd={}));var Vd,zd=function(e){switch(e){case Hd.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Hd.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Bd=Object.assign(Object.assign({},Yo),{scheduledAt:void 0}),Qd=Object.assign(Object.assign({},Qo),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Kd="UnsentMessage",Wd={},Yd=function(e){function t(e){var a;return r(this,t),(a=n(this,t,[e]))._mutex=new Cd("unsendmessagecache.lock"),Wd[e]=a,a}return c(t,e),i(t,[{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Kd);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 po?(e.messageParams&&(n.messageParams=Wo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},Wo(t)),{scheduledAt:t.scheduledAt})))):e instanceof yo?(e.messageParams&&(n.messageParams=nu(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},nu(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof vo&&e.messageParams&&(n.messageParams=function(e){return pe({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)}),oh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(i=oh.of(this._iid),s=this._deserialize(e),!e.messageParams){a.next=32;break}if(!(s instanceof po)){a.next=8;break}o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),a.next=32;break;case 8:if(!(s instanceof yo)){a.next=26;break}if(!(u=e.messageParams).fileKey||"string"!=typeof u.fileKey||!tu(null!==(t=u.fileType)&&void 0!==t?t:"")){a.next=23;break}return a.next=13,this.collection.getBlob(u.fileKey);case 13:if(a.t1=n=a.sent,a.t0=null!==a.t1,!a.t0){a.next=17;break}a.t0=void 0!==n;case 17:if(!a.t0){a.next=21;break}a.t2=n,a.next=22;break;case 21:a.t2=void 0;case 22:u.file=a.t2;case 23:s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(u,s),a.next=32;break;case 26:if(!(s instanceof vo)){a.next=32;break}if(!(c=e.messageParams)||!c.fileInfoList){a.next=32;break}return s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(c,s),a.next=32,Promise.all(s.messageParams.fileInfoList.map((function(e){return E(f,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)||!tu(null!==(a=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==a?a:"")){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()}}),t,this)})))})));case 32:if(!(s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){a.next=54;break}if(!(s instanceof po)){a.next=38;break}l=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(l,s),a.next=54;break;case 38:if(!(s instanceof yo)){a.next=54;break}if(!(h=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof h.fileKey||"string"!=typeof h.fileType||!tu(h.fileType)){a.next=53;break}return a.next=43,this.collection.getBlob(h.fileKey);case 43:if(a.t4=r=a.sent,a.t3=null!==a.t4,!a.t3){a.next=47;break}a.t3=void 0!==r;case 47:if(!a.t3){a.next=51;break}a.t5=r,a.next=52;break;case 51:a.t5=void 0;case 52:h.file=a.t5;case 53:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(h,s);case 54:return a.abrupt("return",s);case 55:case"end":return a.stop()}}),a,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new jd:n,a=e.order,i=void 0===a?Hd.CHANNEL_LATEST:a,s=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return E(this,void 0,void 0,d().mark((function e(){var n,a,o,l,h,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=zd(i),a={"/where":function(e){return!!(i!==Hd.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(f._deserialize(e))}},t&&(a.channelUrl=t),s&&(a.sendingStatus=s),o={where:a,index:n,backward:u},e.next=8,this.collection.query(o);case 8:return l=e.sent,e.next=11,l.fetch({});case 11:return h=e.sent,e.abrupt("return",Promise.all(h.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new jd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({filter:t,order:Hd.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof yo||e instanceof vo)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return n=this._serialize(e),t.next=10,this.collection.upsertOne(n);case 10:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:n=t.sent;case 5:if(!(n.length>0)){t.next=9;break}return n.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(n);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof yo)){t.next=19;break}if(!e.messageParams){t.next=9;break}if(!(n=e.messageParams).file||!eu(n.file)){t.next=9;break}return t.next=6,this.collection.saveBlob(n.file,e.reqId);case 6:r=t.sent,n.fileKey=r,n.fileType=Xo.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){t.next=17;break}if(!(a=e.scheduledInfo.scheduledMessageParams).file||!eu(a.file)){t.next=17;break}return t.next=14,this.collection.saveBlob(a.file,e.reqId);case 14:i=t.sent,a.fileKey=i,a.fileType=Xo.BLOB;case 17:t.next=24;break;case 19:if(!(e instanceof vo)){t.next=24;break}if(!((s=e.messageParams)&&s.fileInfoList&&Array.isArray(s.fileInfoList))){t.next=24;break}return t.next=24,Promise.all(s.fileInfoList.map((function(t,n){return E(o,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!t.file||!eu(t.file)){r.next=7;break}return r.next=3,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n));case 3:a=r.sent,t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=a,t._uploadedMetaData.fileType=Xo.BLOB;case 7:case"end":return r.stop()}}),r,this)})))})));case 24:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Wd[e]&&!n||(Wd[e]=new t(e)),Wd[e]}}])}($a),Zd={},Xd=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Zd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return ss.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"_unsentMessageCache",get:function(){return Yd.of(this._iid)}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ui(!!e).throw(A.databaseError),e.collection(nl)}},{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)}),oh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new jd:i,o=e.order,u=void 0===o?Hd.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,h=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,d().mark((function e(){var r,i,o,c,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r=zd(u),i={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Hd.CHANNEL_LATEST:if(_&&e.createdAt!==n)return!1;if(l){if(g&&e.createdAtn||!g&&e.createdAt>=n)return!1;break;case Hd.NEWEST_CHILD_MESSAGE:if(!h||0===e.parentMessageId||e.parentMessageId!==h)return!1}return!(p&&!e._poll)&&s.match(f._deserialize(e))}},index:r,backward:l},e.next=5,this.collection.query(i);case 5:return o=e.sent,e.next=8,o.fetch({limit:null!=a?a:void 0});case 8:return c=e.sent,e.abrupt("return",Promise.all(c.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}))));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new jd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:Hd.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=30;break}return n.next=3,this.saveBlobs(e);case 3:r=s(e),n.prev=4,r.s();case 6:if((a=r.n()).done){n.next=15;break}if(i=a.value,!(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)){n.next=13;break}return n.next=11,this.get(i.messageId);case 11:(null==(o=n.sent)?void 0:o.threadInfo)&&i.threadInfo._updateFrom(o.threadInfo);case 13:n.next=6;break;case 15:n.next=20;break;case 17:n.prev=17,n.t0=n.catch(4),r.e(n.t0);case 20:return n.prev=20,r.f(),n.finish(20);case 23:return u=e.map((function(e){return c._serialize(e)})),n.next=26,this.collection.upsertMany(u);case 26:return n.next=28,this.upsertChildMessages(e);case 28:return n.next=30,this._unsentMessageCache.upsertChildMessages(e);case 30:case"end":return n.stop()}}),n,this,[[4,17,20,23]])})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!((null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)&&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()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove("".concat(a));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:zd(Hd.CHANNEL_LATEST)});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:zd(Hd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=zd(Hd.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof yo&&e.messageParams)){t.next=7;break}if(!(n=e.messageParams).file||!eu(n.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(n.file,e.reqId);case 5:r=t.sent,n.fileKey=r;case 7:case"end":return t.stop()}}),t,this)})))})));case 2:case"end":return t.stop()}}),t)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=0,r=this._cacheContext.preference,t.next=4,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return a=t.sent,t.next=7,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return s=t.sent,t.next=13,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return o=t.sent,a&&(n+=JSON.stringify(a).length),i&&(n+=JSON.stringify(i).length),s&&(n+=JSON.stringify(s).length),o&&(n+=JSON.stringify(o).length),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Zd[e]&&!n||(Zd[e]=new t(e)),Zd[e]}}])}($a),Jd={},$d=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Jd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return ss.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ui(!!e).throw(A.databaseError),e.collection(rl)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign({},e.serialize())}},{key:"_deserialize",value:function(e){return oh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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(e);case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new jd:i,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,h=e.inclusive,f=void 0===h||h;return E(this,void 0,void 0,d().mark((function e(){var r,i,o,c=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(f&&e.createdAtn||!f&&e.createdAt>=n)return!1}return s.match(c._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},e.next=5,this.collection.query(r);case 5:return i=e.sent,e.next=8,i.fetch({limit:null!=a?a:void 0});case 8:return o=e.sent,e.abrupt("return",o.map((function(e){return c._deserialize(e)})));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=4;break}return n=e.map((function(e){return r._serialize(e)})),t.next=4,this.collection.upsertMany(n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"markAsReadByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,messageStatus:so.SENT,createdAt:{"<":t}}},{set:{messageStatus:so.READ}});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"markAsReadByMessageIds",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=5;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:so.SENT}},{set:{messageStatus:so.READ}});case 3:return r=n.sent,n.abrupt("return",r.length);case 5:return n.abrupt("return",0);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:["channelUrl","-createdAt","-notificationId"]});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:zd(Hd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=["channelUrl","-createdAt","-notificationId"],i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Jd[e]&&!n||(Jd[e]=new t(e)),Jd[e]}}])}($a),eh={},th=function(t){function a(t){var i;return r(this,a),(i=n(this,a,[t]))._observers=new Map,i._dispatcherContext=i._dispatcher.on((function(t){return E(i,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,N,A,M,O=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof Fs)){n.next=19;break}if(r=t.messages,a=t.source,i=t.isWebSocketEventComing,s=r.filter((function(t){return t instanceof eo&&t.channelType!==e.ChannelType.OPEN&&t.messageId>0})),o=r.filter((function(t){return t instanceof eo&&t.channelType!==e.ChannelType.OPEN&&0===t.messageId})),u=r.filter((function(e){return e instanceof _o})),!(s.length>0)){n.next=9;break}return n.next=8,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(s);case 2:return e.next=4,this._unsentMessageCache.remove(s.map((function(e){return e instanceof to?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e,this)})))}));case 8:i||this._broadcastUpdateEvent(s,a);case 9:if(!(o.length>0)){n.next=13;break}return n.next=12,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.upsert(o);case 2:case"end":return e.stop()}}),e,this)})))}));case 12:i||this._broadcastUpdateEvent(o,a);case 13:if(!(u.length>0)){n.next=17;break}return n.next=16,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._notificationCache.upsert(u);case 2:case"end":return e.stop()}}),e,this)})))}));case 16:i||this._broadcastUpdateEvent(u,a);case 17:n.next=71;break;case 19:if(!(t instanceof qs)){n.next=28;break}return c=t.messageIds,l=t.source,h=t.isWebSocketEventComing,f=c.filter((function(e){return"number"==typeof e})),p=c.filter((function(e){return"string"==typeof e})),n.next=25,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(f.length>0)){e.next=3;break}return e.next=3,this._messageCache.remove(f);case 3:if(!(p.length>0)){e.next=6;break}return e.next=6,this._notificationCache.remove(p);case 6:case"end":return e.stop()}}),e,this)})))}));case 25:h||this._broadcastRemoveEvent(c,l),n.next=71;break;case 28:if(!(t instanceof js)){n.next=35;break}return v=t.reqId,_=t.source,n.next=32,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.remove([v]);case 2:case"end":return e.stop()}}),e,this)})))}));case 32:this._broadcastRemoveUnsentEvent(v,_),n.next=71;break;case 35:if(!(t instanceof Vs)){n.next=48;break}if(m=t.polls,g=t.source,!this._cacheContext.localCacheEnabled){n.next=45;break}return y=m.map((function(e){return e.messageId})),n.next=41,Promise.all(y.map((function(e){return O._messageCache.get(e)})));case 41:return k=n.sent.filter((function(e){return e})),k.length>0&&m.forEach((function(e){var t=k.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=45,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(k);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 45:this._broadcastPollChangeLogEvent(m,g),n.next=71;break;case 48:if(!(t instanceof zs)){n.next=59;break}return b=t.event,C=t.source,n.next=52,this._messageCache.get(b.messageId);case 52:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollUpdateEvent(b))){n.next=56;break}return n.next=56,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 56:this._broadcastPollUpdateEvent(b,C),n.next=71;break;case 59:if(!(t instanceof Bs)){n.next=70;break}return x=t.event,S=t.source,n.next=63,this._messageCache.get(x.messageId);case 63:if(!((T=n.sent)&&T.isUserMessage()&&T.poll&&T.poll.applyPollVoteEvent(x))){n.next=67;break}return n.next=67,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([T]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 67:this._broadcastPollVoteEvent(x,S),n.next=71;break;case 70:t instanceof Hs?(I=t.event,N=t.source,I.messageId>0&&this._broadcastReactionUpdateEvent(I,N)):t instanceof Gs&&(A=t.event,M=t.source,this._broadcastThreadUpdateEvent(A,M));case 71:case"end":return n.stop()}}),n,this)})))})),i}return c(a,t),i(a,[{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"_dispatcher",get:function(){return ss.of(this._iid).dispatcher}},{key:"_messageCache",get:function(){return Xd.of(this._iid)}},{key:"_unsentMessageCache",get:function(){return Yd.of(this._iid)}},{key:"_notificationCache",get:function(){return $d.of(this._iid)}},{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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=s(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=s(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=s(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=s(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=s(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:"_broadcastReactionUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastThreadUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(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()}}],[{key:"of",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return eh[e]&&!n||(eh[e]&&(null===(t=eh[e]._dispatcherContext)||void 0===t||t.close()),eh[e]=new a(e)),eh[e]}}])}($a),nh=function(e){function t(e){var a;r(this,t);var i=e.reverse,s=void 0!==i&&i,o=e.limit,u=void 0===o?20:o,c=e.keys,l=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(De),a.params=pe({token:l,limit:u,reverse:s,order:oe.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),a}return c(t,e),i(t)}(Ve),rh=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.next,o=a.has_more,u=void 0!==o&&o,c=a.templates;return i.nextToken=s,i.hasMore=u,i.templates=c.map((function(e){return{template:JSON.stringify(e)}})),i}return c(t,e),i(t)}(ze),ah=function(e){function t(e){var a;r(this,t);var i=e.key;return(a=n(this,t)).method=_e.GET,a.path="".concat(De,"/").concat(i),a}return c(t,e),i(t)}(Ve),ih=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).template=JSON.stringify(a),i}return c(t,e),i(t)}(ze),sh={},oh=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.requestQueue,o=n.onlineDetector,u=n.cacheContext;r(this,e),this._iid=t,this._sdkState=a,this._requestQueue=s,this._dispatcher=i,this._cacheContext=u,Xd.of(t),Yd.of(t),th.of(t),this.fileMessageQueue=new To(t,{sdkState:a,dispatcher:i,requestQueue:s,onlineDetector:o,cacheContext:u}),sh[t]=this}),[{key:"buildMessageFromSerializedData",value:function(t){var n=oi(t);if(n.notificationId)return new _o(this._iid,_o.payloadify(n));switch(n.messageType){case e.MessageType.USER:return new po(this._iid,po.payloadify(n));case e.MessageType.FILE:return vo._isMultipleFilesMessageSerializedData(n)?new vo(this._iid,vo.payloadify(n)):new yo(this._iid,yo.payloadify(n));case e.MessageType.ADMIN:return new ao(this._iid,ao.payloadify(n))}throw A.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return pe(ve({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 pe(ve({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){var n=this;return pe({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.map((function(e){return new Eo(n._iid,e)}))})}},{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=oi(e);return new Es(this._iid,Es.payloadify(t))}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Do(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Ro),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Ho(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Go),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessagesByMessageId",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Lo(Object.assign(Object.assign({channelType:n,channelUrl:t,token:String(r)},Ao),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Po),c=u.messages,this._dispatcher.dispatch(new Fs({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Lo(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},Ao),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Po),c=u.messages,this._dispatcher.dispatch(new Fs({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0;return E(this,void 0,void 0,d().mark((function e(){var u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new Lo(Object.assign(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},Ao),a),{checkingHasNext:s,checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.as(Po),h=l.messages,f=l.isContinuousMessages,p=l.hasNext,this._dispatcher.dispatch(new Fs({messages:h,source:i})),e.abrupt("return",{messages:h,isContinuousMessages:f,hasNext:p});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_THREADED_MESSAGE;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=new Lo(Object.assign(Object.assign(Object.assign({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:n},no),r),{replyType:e.ReplyType.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),i.next=3,this._requestQueue.send(s);case 3:return o=i.sent,u=o.as(Po),c=u.messages,(l=c.slice(1)).forEach((function(e){e.parentMessage=t})),this._dispatcher.dispatch(new Fs({messages:l,source:a})),i.abrupt("return",{parentMessage:c[0],threadedMessages:l});case 9:case"end":return i.stop()}}),i,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new nh(Object.assign({token:e},t)),n.next=3,this._requestQueue.send(r);case 3:return a=n.sent,i=a.as(rh),s=i.hasMore,o=i.nextToken,u=i.templates,n.abrupt("return",{hasMore:s,token:o,templates:u});case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new ah({key:e}),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(ih),i=a.template,t.abrupt("return",{template:i});case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageChangelogs",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Fo(pe(ve(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null},Oo),a)))),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(qo),c=u.updatedMessages,l=u.deletedMessagesInfo,h=u.hasMore,f=u.nextToken,p=l.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new Fs({messages:c,source:i})),p.length>0&&this._dispatcher.dispatch(new qs({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:c,deletedMessageIds:p,hasMore:h,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return sh[e]}}])}(),uh=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e])).targetMessageId=0;var s=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return s&&D("object",s)&&D("number",o)&&D("string",u)&&D("string",c)&&(i.threadInfo=new ds(e,s),i.targetMessageId=o,i.channelUrl=u,i.channelType=c),i}return c(t,e),i(t)}($a),ch={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},lh=function(t){return D("string",t.channelUrl)&&R(e.ChannelType,t.channelType)&&D("number",t.messageId)&&D("boolean",t.includeReactions,!0)&&D("boolean",t.includeMetaArray,!0)&&D("boolean",t.includeParentMessageInfo,!0)&&D("boolean",t.includeThreadInfo,!0)},dh=function(e){function t(e){var a,i=e.channelCustomType,s=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,d=e.order,h=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(xe,"/messages"),a.params={custom_type:i,query:s,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:h,message_ts_to:f,sort_field:d,advanced_query:p,target_fields:v,after:_},a}return c(t,e),i(t)}(Ve),hh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).messages=a.results.map((function(t){return go(e,t)})),i.hasNext=a.has_next,i.nextToken=a.end_cursor,i.totalCount=a.total_count,i}return c(t,e),i(t)}(ze);e.MessageSearchOrder=void 0,(Vd=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",Vd.TIMESTAMP="ts";var fh,ph,vh,_h=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;return r(this,a),(s=n(this,a,[t,i])).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=i.keyword,s.reverse=null!==(o=i.reverse)&&void 0!==o&&o,s.exactMatch=null!==(u=i.exactMatch)&&void 0!==u&&u,s.channelUrl=null!==(c=i.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=i.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(d=i.messageTimestampFrom)&&void 0!==d?d:null,s.messageTimestampTo=null!==(h=i.messageTimestampTo)&&void 0!==h?h:null,s.order=null!==(f=i.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=i.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=i.targetFields)&&void 0!==v?v:null,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.keyword)&&this.keyword.length>0&&D("boolean",this.reverse)&&D("boolean",this.exactMatch)&&D("string",this.channelUrl)&&D("string",this.channelCustomType)&&(D("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(D("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&R(e.MessageSearchOrder,this.order)&&D("boolean",this.advancedQuery)&&P("string",this.targetFields,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new dh(ve(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(hh),s=i.messages,o=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,e.abrupt("return",s);case 15:return e.abrupt("return",[]);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}])}(pu),mh=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/parent_thread_message"),a.params=pe(ve({limit:o,token:u})),a}return c(t,e),i(t)}(Ve),gh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).token=a.next,i.messages=a.messages.map((function(t){return go(e,t)})),i}return c(t,e),i(t)}(ze),yh=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s]))._edge="",o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new mh({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(gh),s=i.messages,o=i.token,this._edge=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(vu),Eh={channelUrl:"",scheduledMessageId:0},kh=function(e){return D("string",e.channelUrl)&&""!==e.channelUrl&&D("number",e.scheduledMessageId)&&e.scheduledMessageId>0},bh={reverse:!1,limit:20},Ch=function(e){return D("boolean",e.reverse,!0)&&D("number",e.limit,!0)&&P("string",e.keys,!0)},wh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="message",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new oh(e,{sdkState:r,dispatcher:a,requestQueue:s,onlineDetector:u,cacheContext:c})}},{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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},ch),e),ui(lh(n)).throw(A.invalidParameters),t.next=4,this._manager.getMessage(n);case 4:if(!((r=t.sent)instanceof eo||r instanceof _o||null===r)){t.next=7;break}return t.abrupt("return",r);case 7:throw"Unknown message type is given.";case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Eh),e),ui(kh(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},bh),t),ui(D("string",e,!0)&&Ch(r)).throw(A.invalidParameters),n.abrupt("return",this._manager.getMessageTemplatesByToken(e,r));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getMessageTemplate(e));case 2:case"end":return t.stop()}}),t,this)})))}}])}(os),xh=i((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})),Sh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="poll",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new el(e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c})}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Kc),e),ui(Wc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.create(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Xc),e),ui(Jc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.get(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Yc),e),ui(Zc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getOption(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}])}(os),Th={profileImage:void 0,profileUrl:void 0,nickname:void 0},Ih=function(e){return H(e.profileImage,!0)&&D("string",e.profileUrl,!0)&&D("string",e.nickname,!0)};e.GroupChannelListOrder=void 0,(fh=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",fh.CHRONOLOGICAL="chronological",fh.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",fh.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(ph=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",ph.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",ph.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(vh=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",vh.SCHEDULED_AT="scheduled_at";var Nh,Ah=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"]}},Mh=function(t){return{v2:function(){return E(void 0,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.commitSchema([{collectionName:tl,keyName:"url",index:[Ah(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),Ah(e.GroupChannelListOrder.CHRONOLOGICAL),Ah(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:nl,keyName:"messageId",index:[zd(Hd.CHANNEL_LATEST),zd(Hd.NEWEST_CHILD_MESSAGE)]},{collectionName:Kd,keyName:"reqId",index:[zd(Hd.CHANNEL_LATEST),zd(Hd.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))},v3:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:"FeedChannel",keyName:"url",index:[["-lastMessageUpdatedAt","-createdAt","syncIndex"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))},v4:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:rl,keyName:"notificationId",index:[["channelUrl","-createdAt","-notificationId"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}},Oh=function(t){return function(n,r){return E(void 0,void 0,void 0,d().mark((function a(){var i,s,o,u,c;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=n,a.next=1===a.t0||2===a.t0||3===a.t0||4===a.t0?3:5===a.t0?5:6===a.t0?9:26;break;case 3:return r(),a.abrupt("break",27);case 5:return a.next=7,t.reset();case 7:return r(),a.abrupt("break",27);case 9:return a.prev=9,i=Mh(t),s=i.v2,o=i.v3,u=i.v4,a.next=13,s();case 13:return a.next=15,o();case 15:return a.next=17,u();case 17:return c=t.collection(nl),a.next=20,c.removeIf({where:{channelType:e.ChannelType.OPEN}});case 20:a.next=24;break;case 22:a.prev=22,a.t1=a.catch(9);case 24:return r(),a.abrupt("break",27);case 26:r();case 27:case"end":return a.stop()}}),a,null,[[9,22]])})))}},Uh=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Dh=function(e){function t(e){var a,i=e.getVisibilityState,s=void 0===i?Uh:i,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,d=e.pauseCheckDelay,h=void 0===d?3e4:d;return r(this,t),(a=n(this,t))._pauseCheckDelay=3e4,a._currentState="visible",a._getVisibilityState=s,a._pauseCheckDelay=h,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(a),a}return c(t,e),i(t,[{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})}}])}(de),Rh=function(){return i((function e(t){var n=this,a=t.logger,i=t.connectionDelegate,s=void 0===i?null:i;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,s&&(this.connectionDelegate=s)}),[{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,d().mark((function e(){return d().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:_e.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}])}(),Lh=function(e){function t(e){var a,i=e.message;return r(this,t),(a=n(this,t)).message=i,a}return c(t,e),i(t)}(fe),Ph={},Fh=function(){return i((function e(t,n){var a=this,i=n.localCacheEnabled,s=n.enableAutoResend,o=n.dispatcher,u=n.sdkState,c=n.logger;r(this,e),this._iid=t,Ph[t]=this,this._localCacheEnabled=i,this._enableAutoResend=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=o,this._logger=c,this._sdkState=u,this._localCacheEnabled&&o.on((function(e){if(e instanceof Ha)switch(e.stateType){case Da.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case Da.INTERNAL_DISCONNECTED:case Da.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}),[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._enableAutoResend){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this._fetchAllCachedPendingMessages();case 4:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)0===(i=a.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=e.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new Fs({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){r.e(e)}finally{r.f()}case 7:case"end":return t.stop()}}),t,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)i=a.value,this._enableAutoResend&&i.errorCode&&q(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,this._enableAutoResend&&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 Fs({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return t.stop()}}),t,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&this._enableAutoResend&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!q(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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Yd.of(this._iid),(r=new jd).replyType=e.ReplyType.ALL,t.next=5,n.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0,filter:r});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&this._enableAutoResend&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),t=this._autoResendQueue[0],this._dispatcher.dispatch(new Lh({message:t})),this._logger.debug("processing auto-resend for message request id: ",t.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Ph[e]}}])}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Nh||(Nh={}));var qh,Hh=function(){return i((function e(t){r(this,e),this.category=t.cat,this.data=t.data}),null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new li(e,r),blockee:new li(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 li(e,t)})):[]}}}])}(),Gh=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),jh=function(e){function t(e,a){var i,s=a.userId;return r(this,t),(i=n(this,t))._iid=e,i.userId=s,i}return c(t,e),i(t)}(fe),Vh=function(e){function t(){return r(this,t),n(this,t)}return c(t,e),i(t)}(fe),zh=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"USEV",i])).event=new Hh(i),s}return c(t,e),i(t)}(Ke),Bh=function(e){function t(e){var a,i=e.userId,s=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i)),a.params=pe(ve({nickname:s,profile_url:o,profile_file:u,preferred_languages:c})),a}return c(t,e),i(t)}(Ve),Qh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).user=new li(e,Object.assign({},a)),i}return c(t,e),i(t)}(ze),Kh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a.params=pe({apns_device_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(Ve),Wh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a.params=pe({gcm_reg_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(Ve),Yh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),Zh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),Xh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a}return c(t,e),i(t)}(Ve),Jh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a}return c(t,e),i(t)}(Ve),$h=function(e){function t(e){var a,i=e.userId,s=e.type,o=e.token,u=e.ts;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/").concat(encodeURIComponent(s),"/device_tokens"),a.params={created_ts:u,token:o},a}return c(t,e),i(t)}(Ve),ef=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).pushTokens={type:i.type?e.PushTokenType[i.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:i.device_tokens,hasMore:i.has_more,token:i.token},s}return c(a,t),i(a)}(ze),tf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a}return c(t,e),i(t)}(Ve),nf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(ze),rf=function(e){function t(e){var a,i=e.userId,s=e.willAutoAccept;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a.params={auto_accept:s},a}return c(t,e),i(t)}(Ve),af=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(ze),sf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(Ve),of=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(ze),uf=function(e){function t(e){var a,i=e.userId,s=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,d=e.timezone;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={do_not_disturb:s,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:d},a}return c(t,e),i(t)}(Ve),cf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(ze),lf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(Ve),df=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(ze),hf=function(e){function t(e){var a,i=e.userId,s=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={snooze_enabled:s,snooze_start_ts:o,snooze_end_ts:u},a}return c(t,e),i(t)}(Ve),ff=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(ze),pf=function(e){function t(e){var a,i=e.userId,s=e.blockedUserId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block"),a.params={target_id:s},a}return c(t,e),i(t)}(Ve),vf=function(e){function t(e){var a,i=e.userId,s=e.unblockedUserId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),_f=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(Ve),mf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(ze),gf=function(e){function t(e){var a,i=e.userId,s=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={push_trigger_option:s},a}return c(t,e),i(t)}(Ve),yf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(ze),Ef=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a}return c(t,e),i(t)}(Ve),kf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(ze),bf=function(e){function t(e){var a,i=e.userId,s=e.templateName;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a.params={name:s},a}return c(t,e),i(t)}(Ve),Cf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(ze),wf=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends/changelogs"),a.params={token:s},a}return c(t,e),i(t)}(Ve),xf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).changelogs={addedUsers:a.added.map((function(t){return new li(e,t)})),updatedUsers:a.updated.map((function(t){return new li(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},i}return c(t,e),i(t)}(ze),Sf=function(e){function t(e){var a,i=e.userId,s=e.discoveries;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discoveries:s.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return c(t,e),i(t)}(Ve),Tf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).friendDiscoveryRequestId=a.friend_discovery_request_id,i}return c(t,e),i(t)}(ze),If=function(e){function t(e){var a,i=e.userId,s=e.discoveryKeys;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discovery_keys:s},a}return c(t,e),i(t)}(Ve),Nf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(Ve),Af=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new li(e,t)})),i}return c(t,e),i(t)}(ze),Mf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(Ve),Of=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={},a}return c(t,e),i(t)}(Ve),Uf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).allowFriendDiscovery=a.allow_friend_discovery,i}return c(t,e),i(t)}(ze),Df=function(e){function t(e){var a,i=e.userId,s=e.allowFriendDiscovery;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={allow_friend_discovery:s},a}return c(t,e),i(t)}(Ve),Rf=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path=Ie,e}return c(t,e),i(t)}(Ve),Lf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiContainer=new wl(a),i}return c(t,e),i(t)}(ze),Pf=function(e){function t(e){var a,i=e.categoryId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ie,"/").concat(i),a}return c(t,e),i(t)}(Ve),Ff=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiCategory=new Cl(a),i}return c(t,e),i(t)}(ze),qf=function(e){function t(e){var a,i=e.key;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Te,"/").concat(i),a}return c(t,e),i(t)}(Ve),Hf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emoji=new bl(a),i}return c(t,e),i(t)}(ze),Gf=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path="".concat(Me),e}return c(t,e),i(t)}(Ve),jf=function(e){function t(e,a){var i,s;r(this,t);var o=null!=a?a:{};return(i=n(this,t,[e,a])).uikitConfiguration={string:JSON.stringify(o),json:o},i.updatedAt=null!==(s=null==a?void 0:a.updated_at)&&void 0!==s?s:0,i}return c(t,e),i(t)}(ze);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(qh||(qh={}));var Vf,zf=function(e){function t(e){var a,i=e.deviceToken,s=e.pushTrackingId,o=e.messageId,u=e.allowedPushNotification,c=e.channelKey,l=e.templateKey,d=e.eventType,h=e.notificationEventDeadline;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=Re,a.params=pe({device_token:i,push_tracking_id:s,message_id:o,allowed_push_notification:u,channel_key:c,template_key:l,event_type:d,notification_event_deadline:h}),a}return c(t,e),i(t)}(Ve);var Bf,Qf=function(){function t(e,n,a){var i=this;r(this,t),this._storeInitialized=!1,this._iid=e,this.options=n;var s=ss.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,l=s.sessionManager,h=s.requestQueue,f=s.logger,p=s.userEventHandlers,v=s.appStateToggleEnabled;this._onlineDetector=new Rh({logger:f,connectionDelegate:{reconnect:function(){return E(i,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=ss.of(e),r=n.sdkState,a=n.connectionManager,(i=n.sessionManager).session.hasSession){t.next=14;break}return t.prev=2,t.next=5,a.connect(i.session.authToken);case 5:t.next=12;break;case 7:if(t.prev=7,t.t0=t.catch(2),!N(t.t0)){t.next=11;break}throw t.t0;case 11:f.debug("connect failed by reconnect event = ",t.t0);case 12:t.next=25;break;case 14:if("foreground"!==r.appState){t.next=25;break}return t.prev=15,t.next=18,a.resetAndReconnect();case 18:t.next=25;break;case 20:if(t.prev=20,t.t1=t.catch(15),!N(t.t1)){t.next=24;break}throw t.t1;case 24:f.debug("resetAndReconnect failed by reconnect event = ",t.t1);case 25:c.dispatch(new Gh);case 26:case"end":return t.stop()}}),t,null,[[2,7],[15,20]])})))},disconnect:function(){mi((function(){return E(i,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(e),r=n.connectionManager,t.next=3,r.disconnect();case 3:case"end":return t.stop()}}),t)})))}))}}});var _=new Fh(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,dispatcher:c,sdkState:o,logger:f});a.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:l,requestQueue:h,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new Dh({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()})),c.on((function(t){var n;if(t instanceof Ha){if(t.stateType===Da.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof Ke){if("USEV"===t.code){var r=t.as(zh).event;if(r.category===Nh.FRIEND_DISCOVERED){var a=Hh.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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(t instanceof La){var s=ss.of(i._iid).subscribedUnreadMessageCount,c=!1,l=t.ts;"number"==typeof l&&l>s.ts&&(s.all!==t.all&&(c=!0),s.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){s.customTypes[e]!==t.customTypes[e]&&(c=!0),s.customTypes[e]=t.customTypes[e]})),c=c&&s.ts>0,s.ts=l),c&&_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:s.all,feedChannelCount:s.feed,customTypeUnreadCount:s.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else t instanceof di?(u.preference.set(i._getUserProfileCacheKey(o.userId),hi.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(Ba(i.appId),{value:!0})):t instanceof Qe&&t.error&&t.error.isSessionInvalidatedError&&(f.debug("session revoked."),i._internalDisconnect(t.error))}))}return i(t,[{key:"appId",get:function(){return ss.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=ss.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=ss.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!ss.of(this._iid).debugMode}},{key:"logLevel",get:function(){return ss.of(this._iid).logger.level},set:function(e){ss.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return ss.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=ss.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return ss.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=ss.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=ss.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=ss.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:"_getNestDBVersion",value:function(){return 7}},{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:"_internalDisconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.connectionManager,a=n.sdkState,i=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),t.next=6,r.logout(e);case 6:return t.next=8,this.clearCachedData();case 8:a.appState="foreground";case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getMemoryStoreForDebugging",value:function(){var e=ss.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Md?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=ss.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)}},{key:"addSendbirdExtensions",value:function(e,t,n){var r=ss.of(this._iid),a=r.logger,i=r.sdkState,s=new RegExp("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");if(0===e.length)return a.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!s.test(e.version)})))return a.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(var o=0,u=Object.entries(n);o2&&void 0!==arguments[2]?arguments[2]:{};return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(ui(D("string",e)&&D("string",t,!0)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,s=a.cacheContext,o=a.connectionManager,u=n.errorForOtherUser,!i.userId||i.userId===e){r.next=10;break}if(u){r.next=9;break}return r.next=7,o.logout();case 7:r.next=10;break;case 9:throw u;case 10:return r.prev=10,r.next=13,this.initializeCache(e);case 13:c=ss.of(this._iid),c.dispatcher.dispatch(new Vh),r.next=22;break;case 17:r.prev=17,r.t0=r.catch(10),l=ss.of(this._iid),h=l.logger,s.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 22:case"end":return r.stop()}}),r,this,[[10,17]])})))}},{key:"authenticateFeed",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.authenticate(e,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=ss.of(this._iid),i=a.sessionManager,s=a.connectionManager,r.next=3,this._ready(e,t,{errorForOtherUser:s.isConnected?A.alreadyConnectedAsAnotherUser:void 0});case 3:if(null===(n=i.session.services)||void 0===n?void 0:n.includes(Q.CHAT)){r.next=7;break}return t||i.handler||(o=new Sl,this.setSessionHandler(o)),r.next=7,i.authenticate(e,t);case 7:return r.abrupt("return",this.currentUser);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"connect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._ready(e,t);case 2:return n.prev=2,r=ss.of(this._iid),a=r.connectionManager,n.next=6,a.connect(t);case 6:return n.prev=6,this._onlineDetector.start(),this._appStateChangeDetector.start(),n.finish(6);case 10:return n.abrupt("return",this.currentUser);case 11:case"end":return n.stop()}}),n,this,[[2,,6,10]])})))}},{key:"reconnect",value:function(){var e=ss.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._internalDisconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.connectionManager,r=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),e.next=6,n.disconnectWebSocket(!0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=ss.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().catch((function(e){r.debug("setBackgroundState error = ",e)})))}},{key:"setForegroundState",value:function(){var e=ss.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,a=e.logger;"background"===n.appState&&(n.appState="foreground",a.debug("going foreground state"),t.resetAndReconnect().catch((function(e){a.debug("setForgroundState error = ",e)})),r.dispatch(new Gh))}},{key:"setSessionHandler",value:function(e){ui(e instanceof Sl).throw(A.invalidParameters),ss.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){ui(D("string",e)&&t instanceof Tl).throw(A.invalidParameters),ss.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){ss.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){ss.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){ui(D("string",e)&&t instanceof xl).throw(A.invalidParameters),ss.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){ss.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){ss.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Al(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ul(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ll(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new _h(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new sl(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new cl(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=oi(e);return new li(this._iid,li.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Object.assign(Object.assign({},Th),e),ui(Ih(n)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Bh(Object.assign({userId:a.userId},n)),t.next=7,i.send(s);case 7:return o=t.sent,u=o.as(Qh),c=u.user,this.currentUser&&(n.nickname&&(this.currentUser.nickname=c.nickname),(n.profileUrl||n.profileImage)&&(this.currentUser.plainProfileUrl=c.profileUrl)),t.abrupt("return",c);case 13:throw A.connectionRequired;case 14:case"end":return t.stop()}}),t,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ui(P("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Bh({userId:r.userId,preferredLanguages:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Qh),u=o.user,this.currentUser&&(this.currentUser.preferredLanguages=u.preferredLanguages),t.abrupt("return",u);case 12:throw A.connectionRequired;case 13:case"end":return t.stop()}}),t,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ui(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ui(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.ANDROID,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=ss.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.FCM,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new Wh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,mi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.FCM,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._fcmPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._fcmPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=ss.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Zh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,mi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.FCM,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=ss.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Jh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,mi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.FCM),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ui(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ui(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.IOS,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=ss.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.APNS,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new Kh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,mi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.APNS,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._apnsPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._apnsPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=ss.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Yh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,mi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.APNS,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._apnsPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._apnsPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=ss.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Xh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,mi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.APNS),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markPushNotificationAsDelivered",value:function(e){var t,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k,b;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=ss.of(this._iid),i=a.logger,s=a.sessionManager,o=a.requestQueue,u=a.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=qh.DELIVERED,l=u.parseData(e),h=l.pushTrackingId,f=l.sessionTopics,p=l.sessionKey,v=l.messageId,_=l.channelKey,m=l.templateKey,g=l.notificationEventDeadline,p){r.next=7;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 7:if(f.includes(Qi.PUSH_ACKNOWLEDGEMENT)){r.next=10;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 10:if(!u.isAcked(h,c)){r.next=13;break}return i.info("already delivered push notification:",h),r.abrupt("return");case 13:return y=Boolean(_),E=n&&y,k=null===(t=s.deviceTokens[0])||void 0===t?void 0:t.token,b=new zf({deviceToken:null!=k?k:"",pushTrackingId:h,eventType:c,messageId:v,channelKey:_,templateKey:m,notificationEventDeadline:g,allowedPushNotification:E}),p&&(b.headers["Session-Key"]=p),r.prev=18,r.next=21,o.send(b);case 21:u.markAsAcked(h,c),r.next=28;break;case 24:throw r.prev=24,r.t0=r.catch(18),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(h,". error: ").concat(r.t0)),r.t0;case 28:case"end":return r.stop()}}),r,this,[[18,24]])})))}},{key:"markPushNotificationAsClicked",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=ss.of(this._iid),a=r.logger,i=r.sessionManager,s=r.requestQueue,o=r.pushNotificationAckManager,a.debug("markPushNotificationAsClicked:",e),u=qh.CLICKED,c=o.parseData(e),l=c.pushTrackingId,h=c.sessionTopics,f=c.sessionKey,p=c.messageId,v=c.channelKey,_=c.templateKey,m=c.notificationEventDeadline,f){n.next=7;break}throw a.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 7:if(h.includes(Qi.PUSH_ACKNOWLEDGEMENT)){n.next=10;break}throw a.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 10:if(!o.isAcked(l,u)){n.next=13;break}return a.info("already clicked push notification:",l),n.abrupt("return");case 13:return g=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,y=new zf({deviceToken:null!=g?g:"",pushTrackingId:l,eventType:u,messageId:p,channelKey:v,templateKey:_,notificationEventDeadline:m}),f&&(y.headers["Session-Key"]=f),n.prev=16,n.next=19,s.send(y);case 19:o.markAsAcked(l,u),n.next=26;break;case 22:throw n.prev=22,n.t0=n.catch(16),a.debug("failed to mark push notification as clicked. push tracking id: ".concat(l,". error: ").concat(n.t0)),n.t0;case 26:case"end":return n.stop()}}),n,this,[[16,22]])})))}},{key:"getChannelInvitationPreference",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new tf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(nf),o=s.autoAccept,e.abrupt("return",{autoAccept:o});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("boolean",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new rf({userId:r.userId,willAutoAccept:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(af),u=o.autoAccept,t.abrupt("return",{autoAccept:u});case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getDoNotDisturb",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new sf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(of),o=s.preference,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return ui(D("boolean",e)&&D("number",t)&&D("number",n)&&D("number",r)&&D("number",a)&&D("string",i)).throw(A.invalidParameters),o=ss.of(this._iid),u=o.sdkState,c=o.requestQueue,l=new uf({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:a,timezone:i}),s.next=5,c.send(l);case 5:return h=s.sent,f=h.as(cf),p=f.preference,s.abrupt("return",p);case 8:case"end":return s.stop()}}),s,this)})))}},{key:"getSnoozePeriod",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new lf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(df),o=s.snoozePeriod,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("boolean",e)&&D("number",t)&&D("number",n)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new hf({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),r.next=5,s.send(o);case 5:return u=r.sent,c=u.as(ff),l=c.snoozePeriod,r.abrupt("return",l);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"getMyPushTokensByToken",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p,v,_;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",t)&&R(e.PushTokenType,n)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,o=a.requestQueue,u=a.sessionManager,c=new $h({userId:i.userId,type:n,token:t}),r.next=5,o.send(c);case 5:l=r.sent,h=l.as(ef),f=h.pushTokens,p=s(f.deviceTokens);try{for(p.s();!(v=p.n()).done;)_=v.value,u.setDeviceToken(f.type,_)}catch(e){p.e(e)}finally{p.f()}return r.next=11,u.saveDeviceToken();case 11:return r.abrupt("return",f);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"getPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new _f({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(mf).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new gf({userId:a.userId,pushTriggerOption:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(yf).pushTriggerOption);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"getPushTemplate",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ef({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(kf).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.PushTemplate,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new bf({userId:a.userId,templateName:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(Cf).name);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"blockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(e instanceof li||D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new pf({userId:r.userId,blockedUserId:e instanceof li?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(e instanceof li||D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new vf({userId:r.userId,unblockedUserId:e instanceof li?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new wf({userId:r.userId,token:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(xf),u=o.changelogs,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Of({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Uf),o=s.allowFriendDiscovery,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("boolean",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Df({userId:r.userId,allowFriendDiscovery:e}),t.next=5,a.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Sf({userId:r.userId,discoveries:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(Tf),u=o.friendDiscoveryRequestId,t.abrupt("return",u);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new If({userId:r.userId,discoveryKeys:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"addFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Nf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(Af),u=o.users,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Mf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getAllEmoji",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Rf,e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Lf),s=i.emojiContainer,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Pf({categoryId:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Ff),o=s.emojiCategory,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getEmoji",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new qf({key:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Hf),o=s.emoji,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getUIKitConfiguration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),ui(t.hasExtension("sb_uikit")).throw(A.notSupportedError),n=t.requestQueue,r=new Gf,e.next=6,n.send(r);case 6:return a=e.sent,i=a.as(jf),s=i.uikitConfiguration,e.abrupt("return",s);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(n){var r=n.appId,a=n.appVersion,i=n.modules,s=void 0===i?[]:i,o=n.options,u=void 0===o?new j:o,c=n.debugMode,l=void 0!==c&&c,d=n.customApiHost,h=n.customWebSocketHost,f=n.newInstance,p=void 0!==f&&f,_=n.logLevel,m=n.localCacheEnabled,g=void 0!==m&&m,y=n.localCacheConfig,E=void 0===y?new W:y,k=n.localCacheEncryption,b=n.useAsyncStorageStore,C=void 0===b?null:b,w=n.useMMKVStorageStore,x=void 0===w?null:w,S=n.appStateToggleEnabled,T=void 0===S||S;if(!Vf||p){var I="su-".concat(ce()),N=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},A=new Gd;A.level=null!=_?_:e.LogLevel.WARN;var M=new Md({encryption:N});l||(it()?x?M=new Ld({MMKV:x,encryption:N}):C&&(M=new Rd({AsyncStorage:C,encryption:N}),A.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):M=new Dd({encryption:N})),new ss(I,{appId:r,appVersion:a,options:u,apiHost:null!=d?d:"https://api-".concat(r,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(r,".sendbird.com"),store:M,encryption:N,logger:A,localCacheEnabled:g,localCacheConfig:E,debugMode:l,appStateToggleEnabled:T});var O=[new wh,new Sh],U=new t(I,u,[].concat(v(s),O));return Vf||(Vf=U),U}return Vf}},{key:"instance",get:function(){return Vf}},{key:"version",get:function(){return b}}])}();e.MemberState=void 0,(Bf=e.MemberState||(e.MemberState={})).NONE="none",Bf.JOINED="joined",Bf.INVITED="invited",Bf.LEFT="left";var Kf,Wf,Yf,Zf,Xf,Jf,$f,ep,tp=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).state=null,s.role=null,s.isMuted=!1,s.isBlockedByMe=!1,s.isBlockingMe=!1,s.state=R(e.MemberState,i.state)?i.state:null,s.role=R(e.Role,i.role)?i.role:null,"boolean"==typeof i.is_muted&&(s.isMuted=i.is_muted),"boolean"==typeof i.is_blocked_by_me&&(s.isBlockedByMe=i.is_blocked_by_me),"boolean"==typeof i.is_blocking_me&&(s.isBlockingMe=i.is_blocking_me),s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}])}(Vo),np=function(t){function a(t,i){var s,o,u;return r(this,a),(s=n(this,a,[t])).channelUrl=null!==(o=i.channel_url)&&void 0!==o?o:"",s.channelType=null!==(u=i.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,s.member=new li(s._iid,i.user),s.deliveryAt=i.ts,s}return c(a,t),i(a)}($a);e.PublicChannelFilter=void 0,(Kf=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",Kf.PUBLIC="public",Kf.PRIVATE="private",e.MyMemberStateFilter=void 0,(Wf=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",Wf.JOINED="joined_only",Wf.INVITED="invited_only",Wf.INVITED_BY_FRIEND="invited_by_friend",Wf.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(Yf=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",Yf.SUPER="super",Yf.NON_SUPER="nonsuper",Yf.BROADCAST_ONLY="broadcast_only",Yf.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(Zf=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",Zf.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(Xf=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",Xf.UNHIDDEN="unhidden_only",Xf.HIDDEN="hidden_only",Xf.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Xf.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(Jf=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",Jf.OPERATOR="operator",Jf.NONOPERATOR="nonoperator",e.QueryType=void 0,($f=e.QueryType||(e.QueryType={})).AND="AND",$f.OR="OR",e.GroupChannelSearchField=void 0,(ep=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",ep.CHANNEL_NAME="channel_name";var rp,ap=function(){function t(n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m,g;r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(a=null==n?void 0:n.includeEmpty)&&void 0!==a&&a,this.nicknameContainsFilter=null!==(i=null==n?void 0:n.nicknameContainsFilter)&&void 0!==i?i:null,this.nicknameStartsWithFilter=null!==(s=null==n?void 0:n.nicknameStartsWithFilter)&&void 0!==s?s:null,this.nicknameExactMatchFilter=null!==(o=null==n?void 0:n.nicknameExactMatchFilter)&&void 0!==o?o:null,this.channelNameContainsFilter=null!==(u=null==n?void 0:n.channelNameContainsFilter)&&void 0!==u?u:"",this.myMemberStateFilter=null!==(c=null==n?void 0:n.myMemberStateFilter)&&void 0!==c?c:e.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(l=null==n?void 0:n.customTypesFilter)&&void 0!==l?l:null,this.channelUrlsFilter=null!==(d=null==n?void 0:n.channelUrlsFilter)&&void 0!==d?d:null,this.superChannelFilter=null!==(h=null==n?void 0:n.superChannelFilter)&&void 0!==h?h:e.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(f=null==n?void 0:n.publicChannelFilter)&&void 0!==f?f:e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(p=null==n?void 0:n.customTypeStartsWithFilter)&&void 0!==p?p:null,this.unreadChannelFilter=null!==(v=null==n?void 0:n.unreadChannelFilter)&&void 0!==v?v:e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==n?void 0:n.hiddenChannelFilter)&&void 0!==_?_:e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(m=null==n?void 0:n.includeFrozen)||void 0===m||m,(null==n?void 0:n.createdAfter)&&(this.createdAfter=n.createdAfter),(null==n?void 0:n.createdBefore)&&(this.createdBefore=n.createdBefore),this.includeMetaData=null===(g=null==n?void 0:n.includeMetaData)||void 0===g||g}return i(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,i=r.fields;if(a&&i&&i.length>0&&!i.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var s=this._userIdsFilter,o=s.userIds,u=s.includeMode,c=s.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=v(e).sort(),r=v(t).sort(),a=0;a0&&!this.customTypesFilter.includes("*")&&!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 d=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(d)})))return!1}if(this.nicknameStartsWithFilter){var h=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(h)})))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.ALL:if("none"===t.myMemberState)return!1;break;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!(this.createdAfter&&t.createdAtthis.createdBefore)}}])}(),ip=function(t){function a(e,t){var i,s=t.sdkState,o=t.cacheContext;return r(this,a),(i=n(this,a,[e]))._channels=new Map,i._sdkState=s,i._cacheContext=o,i}return c(a,t),i(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ui(!!e).throw(A.databaseError),e.collection(tl)}},{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 Iv.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return v(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>n||s&&t.createdAtn||s&&t.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)n._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});n._update(e),r.push(n)}else s._channels.set(e.url,e),r.push(e)})),!this.localCacheEnabled){n.next=7;break}for(a=[],i=0;i0)){r.next=76;break}return r.next=76,this.upsert(a);case 76:case"end":return r.stop()}}),r,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!0);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"unblock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!1);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"markAsRead",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v(this._channels.keys());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=s(t),n.prev=2,a.s();case 4:if((i=a.n()).done){n.next=12;break}return o=i.value,n.next=8,this.get(o);case 8:(null==(u=n.sent)?void 0:u._updateUnreadMemberState(this._sdkState.userId,e))&&(u._updateUnreadCount(0,0),r.push(u));case 10:n.next=4;break;case 12:n.next=17;break;case 14:n.prev=14,n.t0=n.catch(2),a.e(n.t0);case 17:return n.prev=17,a.f(),n.finish(17);case 20:if(!(r.length>0)){n.next=23;break}return n.next=23,this.upsert(r);case 23:case"end":return n.stop()}}),n,this,[[2,14,17,20]])})))}}])}($a);!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"}(rp||(rp={}));var sp,op=function(){return i((function e(t){var n;r(this,e),this.channelUrl=t.channel_url,this.channelType=t.channel_type,this.category=t.cat,this.data=null!==(n=t.data)&&void 0!==n?n:{},this.ts=t.ts}),[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}])}(),up={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},cp=function(e){return P("string",e.invitedUserIds,!0)&&D("string",e.channelUrl,!0)&&D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isSuper,!0)&&D("boolean",e.isBroadcast,!0)&&D("boolean",e.isExclusive,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isStrict,!0)&&D("boolean",e.isDiscoverable,!0)&&D("boolean",e.isEphemeral,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},lp={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},dp=function(e){return P("string",e.customTypes,!0)&&D("boolean",e.includeEmpty,!0)&&D("boolean",e.includeFrozen,!0)&&D("boolean",e.includeMetaData,!0)&&D("boolean",e.includeChatNotification,!0)},hp={myMemberStateFilter:e.MyMemberStateFilter.ALL},fp=function(t){return R(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(sp=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",sp.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",sp.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",sp.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",sp.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",sp.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",sp.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",sp.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",sp.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var pp,vp={keys:[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,e.UnreadItemKey.NONSUPER_INVITATION_COUNT,e.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},_p=function(t){return P(e.UnreadItemKey,t.keys)&&P("string",t.customTypeFilters,!0)&&P("string",t.customTypesFilter,!0)},mp={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},gp=function(t){return P("string",t.channelCustomTypesFilter,!0)&&R(e.SuperChannelFilter,t.superChannelFilter)},yp={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},Ep=function(t){return D("string",t.channelUrl,!0)&&P(e.ScheduledStatus,t.scheduledStatus,!0)&&R(e.MessageTypeFilter,t.messageTypeFilter)},kp=Object.assign({},e.CollectionEventSource),bp=function(t){return t.startsWith("EVENT_")||t===e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.CollectionEventSource.REFRESH_CHANNEL},Cp=function(e){function t(e){var a,i=e.channels,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.ts;return r(this,t),(a=n(this,t)).channels=i,a.context=s,a.isWebSocketEventComing=u,a.ts=c,a}return c(t,e),i(t)}(fe),wp=function(e){function t(e){var a,i=e.channelUrls,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,t),(a=n(this,t)).channelUrls=i,a.context=s,a.isWebSocketEventComing=u,a}return c(t,e),i(t)}(fe),xp=function(){return i((function t(n){var a=this,i=n.groupChannelCache,o=n.messageCache,u=n.unsentMessageCache,c=n.dispatcher;r(this,t),this._observers=new Map,c.on((function(t){return E(a,void 0,void 0,d().mark((function n(){var r,a,c,l,h,f,p,v,_,m,g,y,k,b,C,w=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof Cp)){n.next=47;break}if(r=t.channels,a=t.context,c=t.isWebSocketEventComing,l=r.filter((function(e){return e instanceof x_})),a.source!==e.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY&&a.source!==e.CollectionEventSource.EVENT_CHANNEL_HIDDEN){n.next=23;break}h=s(l),n.prev=5,h.s();case 7:if((f=h.n()).done){n.next=13;break}return p=f.value,n.next=11,o.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),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:n.next=41;break;case 23:v=i.filterOffsetChanged(l),_=s(v),n.prev=25,_.s();case 27:if((m=_.n()).done){n.next=33;break}return g=m.value,n.next=31,o.removeUnderOffset(g.url,g.messageOffsetTimestamp);case 31:n.next=27;break;case 33:n.next=38;break;case 35:n.prev=35,n.t1=n.catch(25),_.e(n.t1);case 38:return n.prev=38,_.f(),n.finish(38);case 41:return n.next=43,i.upsert(l,t.ts);case 43:y=n.sent,c||this._broadcastUpdateEvent(y,a),n.next=59;break;case 47:if(!(t instanceof wp)){n.next=56;break}return k=t.channelUrls,b=t.context,C=t.isWebSocketEventComing,n.next=51,i.remove(k);case 51:return n.next=53,mi((function(){return E(w,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(k),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=7,o.removeMessagesOfChannel(r);case 7:return e.next=9,u.removeMessagesOfChannel(r);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 53:C||this._broadcastRemoveEvent(k,b),n.next=59;break;case 56:if(!(t instanceof jh)){n.next=59;break}return n.next=59,i.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 59:case"end":return n.stop()}}),n,this,[[5,15,18,21],[25,35,38,41]])})))}))}),[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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:"_broadcastRemoveEvent",value:function(e,t){var n,r=s(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()}}])}(),Sp=function(e){function t(e){var a,i=e.userId,s=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c;r(this,t),a=n(this,t);var d=Object.assign(Object.assign({},lp),u),h=d.customTypes,f=d.includeEmpty,p=d.includeFrozen;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels/changelogs"),a.params=pe(ve({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:s||null,token:o,custom_types:h,show_empty:f,show_frozen:p,include_chat_notification:l})),a}return c(t,e),i(t)}(Ve),Tp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedChannels=a.updated.map((function(t){return new x_(e,Object.assign(t,{ts:a.ts}))})),i.deletedChannelUrls=a.deleted,i.hasMore=a.has_more,i.token=a.next,i.ts=a.ts,i}return c(t,e),i(t)}(ze),Ip=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall,o=e.showLatestMessage;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?be:ke,"/").concat(encodeURIComponent(i)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=o&&o},a}return c(t,e),i(t)}(Ve),Np=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),Ap={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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,createdAfter:void 0,createdBefore:void 0},Mp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,d=e.superChannelFilter,h=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,E=e.customTypeStartsWithFilter,k=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,C=e.metadataKey,w=e.metadataValues,x=e.metadataValueStartsWith,S=e.includeFrozen,T=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter,A=e.includeChatNotification,M=void 0!==A&&A,O=e.includeLeftChannel,U=void 0!==O&&O,D=e.createdAfter,R=e.createdBefore;return(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels"),a.params=pe({token:s,limit:o,order:null!=u?u:Ap.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:Ap.includeEmpty,member_state_filter:null!=l?l:Ap.myMemberStateFilter,super_mode:null!=d?d:Ap.superChannelFilter,public_mode:null!=h?h:Ap.publicChannelFilter,unread_filter:null!=f?f:Ap.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:E,hidden_mode:k,metadata_order_key:b,metadata_key:C,metadata_values:w,metadata_value_startswith:x,show_frozen:S,show_metadata:T,include_chat_notification:M,include_left_channel:U,created_after:D,created_before:R}),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 c(t,e),i(t)}(Ve),Op=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new x_(e,t)}))),i.ts=null!=u?u:0,i}return c(t,e),i(t)}(ze),Up=function(t){function a(t){var i,s=t.userId,o=t.filter;r(this,a),i=n(this,a);var u=o.myMemberStateFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/group_channel_count"),i.params={state:null!=u?u:e.MyMemberStateFilter.ALL},i}return c(a,t),i(a)}(Ve),Dp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).groupChannelCount=a.group_channel_count,i}return c(t,e),i(t)}(ze),Rp=function(e){function t(e){var a,i=e.userId,s=e.filter;r(this,t),a=n(this,t);var o=s.keys,u=s.customTypeFilters,c=s.customTypesFilter;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_item_count"),a.params=pe({item_keys:o,custom_types:null!=c?c:u}),a}return c(t,e),i(t)}(Ve),Lp=function(t){function a(t,i){var s;return r(this,a),s=n(this,a,[t,i]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=i[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),s}return c(a,t),i(a)}(ze),Pp=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_channel_count"),a}return c(t,e),i(t)}(Ve),Fp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i}return c(t,e),i(t)}(ze),qp=function(t){function a(t){var i,s=t.userId,o=t.filter,u=t.includeFeedChannel,c=void 0!==u&&u;r(this,a),i=n(this,a);var l=o.channelCustomTypesFilter,d=o.superChannelFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/unread_message_count"),i.params={super_mode:null!=d?d:e.SuperChannelFilter.ALL,custom_types:l,include_feed_channel:c},i}return c(a,t),i(a)}(Ve),Hp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i.unreadFeedCount=a.unread_feed_count,i}return c(t,e),i(t)}(ze),Gp=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledStatus,o=e.messageTypeFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ae,"/count"),a.params={channel_url:i,status:Vp(s)},o&&(a.params.message_type=o),a}return c(t,e),i(t)}(Ve),jp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).count=a.count,i}return c(t,e),i(t)}(ze),Vp=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},zp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,d=e.isBroadcast,h=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,_=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,E=e.data,k=e.customType,b=e.messageSurvivalSeconds,C=e.invitedUserIds,w=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path=ke,a.params=pe({user_ids:[i].concat(v(null!=C?C:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:d,is_exclusive:f,is_public:h,is_discoverable:p,strict:_,is_ephemeral:m,access_code:g,name:y,data:E,custom_type:k,operator_ids:w,message_survival_seconds:b}),a}return c(t,e),i(t)}(Ve),Bp=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i.isCreated=null===(s=a.is_created)||void 0===s||s,i}return c(t,e),i(t)}(ze),Qp=function(e){function t(e){var a,i=e.userId,s=e.channelUrls;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/mark_as_read_all"),a.params={channel_urls:s},a}return c(t,e),i(t)}(Ve),Kp=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).event=new op(i),s}return c(t,e),i(t)}(Ke),Wp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/join"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(Ve),Yp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),Zp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.users,f=void 0===h?null:h;return s.memberCount=c,s.joinedMemberCount=d,s.members=Array.isArray(f)?f.map((function(t){return new tp(e,t)})):[new tp(e,i.data)],s}return c(t,e),i(t)}(Kp),Xp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.shouldRemoveOperatorStatus;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/leave"),a.params={user_id:s,should_remove_operator_status:o},a}return c(t,e),i(t)}(Ve),Jp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l;return s.memberCount=c,s.joinedMemberCount=d,s.member=new tp(s._iid,i.data),s}return c(t,e),i(t)}(Kp),$p=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/invite"),a.params={user_ids:s},a}return c(t,e),i(t)}(Ve),ev=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),tv=function(e){function t(e,a,i){var s;r(this,t),(s=n(this,t,[e,a,i])).inviter=null;var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.inviter,f=o.invitees,p=void 0===f?[]:f;return s.memberCount=c,s.joinedMemberCount=d,h&&Object.keys(h).length>0&&(s.inviter=new li(e,h)),s.invitees=p.map((function(t){return new tp(e,t)})),s}return c(t,e),i(t)}(Kp),nv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/decline"),a.params={user_id:s},a}return c(t,e),i(t)}(Ve),rv=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=o.joined_member_count,l=o.inviter,d=o.invitee;return s.memberCount=null!=u?u:0,s.joinedMemberCount=null!=c?c:0,s.inviter=new li(e,l),s.invitee=new tp(e,d),s}return c(t,e),i(t)}(Kp),av={hidePreviousMessages:!1,allowAutoUnhide:!0},iv=function(e){return D("boolean",e.hidePreviousMessages,!0)&&D("boolean",e.allowAutoUnhide,!0)},sv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a.params={user_id:s,hide_previous_messages:null!=o?o:av.hidePreviousMessages,allow_auto_unhide:null!=u?u:av.allowAutoUnhide},a}return c(t,e),i(t)}(Ve),ov=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(ze),uv=function(e){function t(e,a,i){var s,o,u,c;return r(this,t),(s=n(this,t,[e,"SYEV",i])).allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,i.data&&(s.allowAutoUnhide=null!==(o=i.data.allow_auto_unhide)&&void 0!==o?o:null,s.hidePreviousMessages=null!==(u=i.data.hide_previous_messages)&&void 0!==u?u:null),s.messageOffsetTimestamp=null!==(c=i.ts_message_offset)&&void 0!==c?c:null,s}return c(t,e),i(t)}(Ke),cv=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(We),lv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new li(e,i.data),s}return c(t,e),i(t)}(Ke),dv=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(We),hv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new li(e,i.data),s}return c(t,e),i(t)}(Ke),fv=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data.operators,u=void 0===o?[]:o;return s.operators=u.map((function(e){return new li(s._iid,e)})),s}return c(t,e),i(t)}(Kp),pv=function(e){function t(e){var a=e.channelUrl,i=e.messageId;return r(this,t),n(this,t,[{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:i}}])}return c(t,e),i(t)}(We),vv=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x,S,T,I,N;return r(this,a),(s=n(this,a,[t,i])).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.includeChatNotification=!1,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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.includeChatNotification=null!==(l=i.includeChatNotification)&&void 0!==l&&l,s.channelUrlsFilter=null!==(d=i.channelUrlsFilter)&&void 0!==d?d:null,s.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(f=i.customTypeStartsWithFilter)&&void 0!==f?f:"",s.nicknameContainsFilter=null!==(p=i.nicknameContainsFilter)&&void 0!==p?p:null,s.nicknameStartsWithFilter=null!==(v=i.nicknameStartsWithFilter)&&void 0!==v?v:null,s.nicknameExactMatchFilter=null!==(_=i.nicknameExactMatchFilter)&&void 0!==_?_:null,s.channelNameContainsFilter=null!==(m=i.channelNameContainsFilter)&&void 0!==m?m:"",s.myMemberStateFilter=null!==(g=i.myMemberStateFilter)&&void 0!==g?g:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(y=i.unreadChannelFilter)&&void 0!==y?y:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(E=i.superChannelFilter)&&void 0!==E?E:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=i.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=i.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(C=i.searchFilter)&&void 0!==C?C:{fields:[],query:null},s.userIdsFilter=null!==(w=i.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(x=i.metadataKey)&&void 0!==x?x:null,s.metadataValues=null!==(S=i.metadataValues)&&void 0!==S?S:null,s.metadataOrderKeyFilter=null!==(T=i.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(I=i.metadataValueStartsWith)&&void 0!==I?I:null,s.order=null!==(N=i.order)&&void 0!==N?N:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i.createdAfter&&(s.createdAfter=i.createdAfter),i.createdBefore&&(s.createdBefore=i.createdBefore),s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter)&&D("string",this.nicknameContainsFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)&&D("string",this.nicknameExactMatchFilter,!0)&&R(e.MyMemberStateFilter,this.myMemberStateFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicChannelFilter,this.publicChannelFilter)&&R(e.UnreadChannelFilter,this.unreadChannelFilter)&&R(e.HiddenChannelFilter,this.hiddenChannelFilter)&&P(e.GroupChannelSearchField,this.searchFilter.fields)&&D("string",this.searchFilter.query,!0)&&P("string",this.userIdsFilter.userIds)&&D("boolean",this.userIdsFilter.includeMode)&&R(e.QueryType,this.userIdsFilter.queryType)&&R(e.GroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)&&F(this.createdAfter,!0)&&F(this.createdBefore,!0)}},{key:"serialize",value:function(){return si(this)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._validate()){t.next=20;break}if(this._isLoading){t.next=17;break}if(!this._hasNext){t.next=14;break}return this._isLoading=!0,n=Iv.of(this._iid),t.next=7,n.getMyGroupChannels(this._token,ve(Object.assign({},this)),this.limit,e.CollectionEventSource.REQUEST_CHANNEL,!0);case 7:return r=t.sent,a=r.channels,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,t.abrupt("return",a);case 14:return t.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:t.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return t.stop()}}),t,this)})))}}])}(pu),_v=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"SYEV",i])).pinnedMessageIds=[],s.latestPinnedMessage=null,s.ts=0,i.data&&(s.pinnedMessageIds=null!==(o=i.data.pinned_message_ids)&&void 0!==o?o:[],s.latestPinnedMessage=i.data.latest_pinned_message?go(e,Object.assign({},i.data.latest_pinned_message)):null),s.ts=i.ts,s}return c(t,e),i(t)}(Ke),mv=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e]))._logger=a.logger,i._sdkState=a.sdkState,i._sessionManager=a.sessionManager,i._requestQueue=a.requestQueue,i._dispatcher=a.dispatcher,i._cacheContext=a.cacheContext,i._channelType=a.channelType,i}return c(t,e),i(t,[{key:"_messageBroadcast",get:function(){return th.of(this._iid)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"getMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null);case 1:case"end":return e.stop()}}),e)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r,a,i){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",0);case 1:case"end":return e.stop()}}),e)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}($a),gv=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"ADMM",i])).message=new ao(e,i);var d=ss.of(e).sdkState;return s.isMentioned=qe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),yv=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"AEDI",i])).message=new ao(e,i);var h=ss.of(e).sdkState;return s.mentionCountChange=He({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),Ev=function(e){function t(e){var a,i=e.channelUrl,s=e.userId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/messages/mark_as_delivered"),a.params=pe({userId:s}),a}return c(t,e),i(t)}(Ve),kv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"DLVR",i])).channelUrl=i.channel_url,s.deliveredStateUpdate=i.updated,s}return c(t,e),i(t)}(Ke),bv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MRCT",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.event=new fs(i),s}return c(t,e),i(t)}(Ke),Cv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MTHD",i])).event=new uh(e,i),s}return c(t,e),i(t)}(Ke),wv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MCNT",i])).groupChannelMemberCounts=i.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=i.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return c(t,e),i(t)}(Ke),xv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"PEDI",i])).event=new xh(e,i),s.status=uo(i.poll.status)||i.poll.status,s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),Sv=function(){return i((function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,i=t.bottom,s=void 0===i?0:i;r(this,e),this.top=a,this.bottom=s}),[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0&&r.onMentionReceived&&r.onMentionReceived(T,w)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 63:return a.abrupt("break",344);case 64:if(D=t.as(dt),R=D.channelUrl,L=D.channelType,P=D.messageId,F=D.silent,q=D.messageCreatedAt,H=D.senderId,L!==e.ChannelType.GROUP){a.next=73;break}return a.next=68,this.getChannel(R,!0);case 68:G=a.sent,j=H===this._sdkState.userId,F||j||q>0&&G.myLastRead0&&G._updateUnreadCount(G.unreadMessageCount-1,0),this._dispatcher.dispatch(new qs({messageIds:[P],source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onMessageDeleted&&r.onMessageDeleted(G,P)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 73:return a.abrupt("break",344);case 74:if(V=t.as(Ss),(z=V.readStatus).channelType!==e.ChannelType.GROUP){a.next=82;break}return B=this._groupChannelCache.isCachedInMemory(z.channelUrl),a.next=79,this.getChannel(z.channelUrl,!0);case 79:Q=a.sent,B&&Q._updateUnreadMemberState(z.reader.userId,z.readAt),z.reader.userId===this._sdkState.userId?B?(Q.unreadMessageCount>0||Q.unreadMentionCount>0)&&(Q._updateUnreadCount(0,0),this._dispatcher.dispatch(new Cp({channels:[Q],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Q)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==Q.unreadMessageCount&&0!==Q.unreadMentionCount||(this._dispatcher.dispatch(new Cp({channels:[Q],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Q)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new Cp({channels:[Q],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUnreadMemberStatusUpdated&&r.onUnreadMemberStatusUpdated(Q)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 82:return a.abrupt("break",344);case 83:return K=t.as(kv),W=K.channelUrl,Y=K.deliveredStateUpdate,Z=void 0===Y?{}:Y,X=this._groupChannelCache.isCachedInMemory(W),a.next=87,this.getChannel(W,!0);case 87:return J=a.sent,X&&Object.keys(Z).forEach((function(e){J._updateUndeliveredMemberState(e,Z[e])})),Object.keys(Z).some((function(e){return e!==mn._sdkState.userId}))&&(this._dispatcher.dispatch(new Cp({channels:[J],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELIVERED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUndeliveredMemberStatusUpdated&&r.onUndeliveredMemberStatusUpdated(J)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 91:if($=t.as(bv),ee=$.channelUrl,te=$.channelType,ne=$.event,te!==e.ChannelType.GROUP){a.next=101;break}return a.next=95,this.getChannel(ee,!0);case 95:return re=a.sent,a.next=98,this.getMessageFromCache(ne.messageId);case 98:(ae=a.sent)?ae instanceof eo&&(ae.applyReactionEvent(ne),this._dispatcher.dispatch(new Fs({messages:[ae],source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new Hs({event:ne,source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onReactionUpdated&&r.onReactionUpdated(re,ne)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 101:return a.abrupt("break",344);case 102:if(ie=t.as(Cv),(se=ie.event).channelType!==e.ChannelType.GROUP){a.next=112;break}return a.next=106,this.getChannel(se.channelUrl,!0);case 106:return oe=a.sent,a.next=109,this.getMessageFromCache(se.targetMessageId);case 109:(ue=a.sent)?ue instanceof eo&&(ue.applyThreadInfoUpdateEvent(se),this._dispatcher.dispatch(new Fs({messages:[ue],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new Gs({event:se,source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onThreadInfoUpdated&&r.onThreadInfoUpdated(oe,se)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 112:return a.abrupt("break",344);case 113:ce=t.as(wv),le=ce.groupChannelMemberCounts,de=[],he=s(le),a.prev=116,he.s();case 118:if((fe=he.n()).done){a.next=127;break}return pe=fe.value,ve=pe.channelUrl,_e=pe.memberCount,me=pe.joinedMemberCount,ge=pe.updatedAt,a.next=123,this.getChannelFromCache(ve);case 123:(ye=a.sent)&&ye._setLatestMemberCount(_e,me,ge)&&de.push(ye);case 125:a.next=118;break;case 127:a.next=132;break;case 129:a.prev=129,a.t2=a.catch(116),he.e(a.t2);case 132:return a.prev=132,he.f(),a.finish(132);case 135:return de.length>0&&(this._dispatcher.dispatch(new Cp({channels:de,context:{source:e.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(de)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 137:if(Ee=t.as(xv),ke=Ee.event,be=Ee.status,Ce=Ee.channelUrl,we=Ee.channelType,!Ce||we!==e.ChannelType.GROUP){a.next=144;break}return a.next=141,this.getChannel(Ce,!0);case 141:xe=a.sent,this._dispatcher.dispatch(new zs({event:ke,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),_i(be===oo?function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(xe,ke.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(xe,ke)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 144:return a.abrupt("break",344);case 145:if(Se=t.as(Fc),Te=Se.event,Ie=Se.channelUrl,Ne=Se.channelType,!Ie||Ne!==e.ChannelType.GROUP){a.next=152;break}return a.next=149,this.getChannel(Ie,!0);case 149:Ae=a.sent,this._dispatcher.dispatch(new Bs({event:Te,source:e.CollectionEventSource.EVENT_POLL_VOTED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(Ae,Te)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 152:return a.abrupt("break",344);case 153:if(Me=t.as(Kp),!(Oe=Me.event).isGroupChannelEvent){a.next=332;break}a.t3=Oe.category,a.next=a.t3===rp.CHANNEL_JOIN?158:a.t3===rp.CHANNEL_LEAVE?167:a.t3===rp.CHANNEL_OPERATOR_UPDATE?183:a.t3===rp.CHANNEL_INVITE?194:a.t3===rp.CHANNEL_DECLINE_INVITE?204:a.t3===rp.TYPING_START||a.t3===rp.TYPING_END?212:a.t3===rp.USER_CHANNEL_MUTE||a.t3===rp.USER_CHANNEL_UNMUTE?221:a.t3===rp.USER_CHANNEL_BAN?248:a.t3===rp.USER_CHANNEL_UNBAN?263:a.t3===rp.CHANNEL_FREEZE||a.t3===rp.CHANNEL_UNFREEZE?271:a.t3===rp.CHANNEL_HIDE?279:a.t3===rp.CHANNEL_UNHIDE?289:a.t3===rp.CHANNEL_DELETED?296:a.t3===rp.CHANNEL_PROP_CHANGED?302:a.t3===rp.CHANNEL_META_DATA_CHANGED?308:a.t3===rp.CHANNEL_META_COUNTERS_CHANGED?317:a.t3===rp.PINNED_MESSAGE_CHANGED?326:332;break;case 158:return a.next=160,this.getChannel(Oe.channelUrl,!0);case 160:return Ue=a.sent,De=t.as(Zp),Re=De.memberCount,Le=De.joinedMemberCount,Pe=De.members,Fe=!1,Pe.forEach((function(t){Ue.isExclusive||Ue.isSuper||Ue.isBroadcast?Fe=Fe||Ue._setLatestMemberCount(Re,Le,Oe.ts):(t.state=e.MemberState.JOINED,Ue.addMember(t,Oe.ts),mn._updateJoinedMemberCount(Ue)),t.userId===mn._sdkState.userId&&(Ue.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new Cp({channels:[Ue],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:Pe}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=s(Pe);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ue,r)}}catch(e){n.e(e)}finally{n.f()}Ue.isBroadcast&&Fe&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ue])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 167:if(!(qe=this._leftChannels.get(Oe.channelUrl))){a.next=172;break}a.t4=qe.channel,a.next=175;break;case 172:return a.next=174,this.getChannel(Oe.channelUrl,!0);case 174:a.t4=a.sent;case 175:return He=a.t4,Ge=t.as(Jp),je=Ge.memberCount,Ve=Ge.joinedMemberCount,ze=Ge.member,Be=!1,Qe=ss.of(this._iid),Ke=Qe.appInfo,He.isExclusive||He.isSuper||He.isBroadcast?Be=He._setLatestMemberCount(je,Ve,Oe.ts):((null==Ke?void 0:Ke.enabledChannelMemberShipHistory)?((We=He.members.find((function(e){return e.userId===ze.userId})))&&(We.state=e.MemberState.LEFT),He.memberCount=je):He.removeMember(ze),this._updateJoinedMemberCount(He)),ze.userId===this._sdkState.userId?(He.myMemberState=e.MemberState.NONE,He.invitedAt=0,He.joinedAt=0,He._updateUnreadCount(0,0),He.isPublic?this._dispatcher.dispatch(new Cp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})):(this._markAsLeave(He),this._dispatcher.dispatch(new wp({channelUrls:[He.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})))):this._dispatcher.dispatch(new Cp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(He,ze),He.isBroadcast&&Be&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([He])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 183:return a.next=185,this.getChannel(Oe.channelUrl,!0);case 185:Ye=a.sent,Ze=t.as(fv),Xe=Ze.operators,Je=Xe.map((function(e){return e.userId})),$e=s(Ye.members);try{for($e.s();!(et=$e.n()).done;)(tt=et.value).role=Je.includes(tt.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){$e.e(e)}finally{$e.f()}return Ye.myRole=Je.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new Cp({channels:[Ye],context:{source:e.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Xe}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ye,Xe)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 194:return a.next=196,this.getChannel(Oe.channelUrl,!0);case 196:nt=a.sent,rt=t.as(tv),at=rt.memberCount,it=rt.joinedMemberCount,st=rt.inviter,(ot=rt.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),ut=s(ot);try{for(ut.s();!(ct=ut.n()).done;)lt=ct.value,nt.isExclusive||nt.isSuper||nt.isBroadcast?nt._setLatestMemberCount(at,it,Oe.ts):nt.addMember(lt,Oe.ts),this._sdkState.userId===lt.userId&&(nt.hiddenState=e.HiddenState.UNHIDDEN,nt.myMemberState!==e.MemberState.JOINED&&(nt.myMemberState=e.MemberState.INVITED),nt.invitedAt=Oe.ts)}catch(e){ut.e(e)}finally{ut.f()}return this._dispatcher.dispatch(new Cp({channels:[nt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:st,invitees:ot}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(nt,st,ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 204:return a.next=206,this.getChannel(Oe.channelUrl,!0);case 206:return ht=a.sent,ft=t.as(rv),pt=ft.memberCount,vt=ft.joinedMemberCount,_t=ft.inviter,mt=ft.invitee,ht.isExclusive||ht.isSuper||ht.isBroadcast?ht._setLatestMemberCount(pt,vt,Oe.ts):ht.removeMember(mt),this._sdkState.userId===mt.userId?(ht.invitedAt=0,ht.myMemberState=e.MemberState.NONE,ht.isPublic?this._dispatcher.dispatch(new Cp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})):this._dispatcher.dispatch(new wp({channelUrls:[ht.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}}))):this._dispatcher.dispatch(new Cp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ht,_t,mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 212:return a.next=214,this.getChannel(Oe.channelUrl,!0);case 214:return gt=a.sent,yt=Oe.category===rp.TYPING_START,Et=t.as(yt?lv:hv),kt=Et.user,gt._updateTypingStatus(kt,yt?Oe.ts:0),this._dispatcher.dispatch(new Cp({channels:[gt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(gt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 221:return a.next=223,this.getChannel(Oe.channelUrl,!0);case 223:bt=a.sent,Ct=Oe.category===rp.USER_CHANNEL_MUTE,wt=t.as(Ct?Xu:$u),(xt=wt.user).userId===this._sdkState.userId&&(bt.myMutedState=Ct?e.MutedState.MUTED:e.MutedState.UNMUTED,bt._myMutedRemainingTime=xt.restrictionInfo.remainingDuration),St=s(bt.members),a.prev=228,St.s();case 230:if((Tt=St.n()).done){a.next=237;break}if((It=Tt.value).userId!==xt.userId){a.next=235;break}return It.isMuted=Ct,a.abrupt("break",237);case 235:a.next=230;break;case 237:a.next=242;break;case 239:a.prev=239,a.t5=a.catch(228),St.e(a.t5);case 242:return a.prev=242,St.f(),a.finish(242);case 245:return this._dispatcher.dispatch(new Cp({channels:[bt],context:{source:Ct?e.CollectionEventSource.EVENT_CHANNEL_MUTED:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:xt}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ct?e.onUserMuted&&e.onUserMuted(bt,xt):e.onUserUnmuted&&e.onUserUnmuted(bt,xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 248:if(!(Nt=this._leftChannels.get(Oe.channelUrl))){a.next=253;break}a.t6=Nt.channel,a.next=256;break;case 253:return a.next=255,this.getChannel(Oe.channelUrl,!0);case 255:a.t6=a.sent;case 256:return At=a.t6,this._markAsLeave(At),Mt=t.as(tc),Ot=Mt.user,Ot.userId===this._sdkState.userId&&this._dispatcher.dispatch(new wp({channelUrls:[At.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_BANNED,user:Ot}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(At,Ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 263:return a.next=265,this.getChannel(Oe.channelUrl,!0);case 265:return Ut=a.sent,Dt=t.as(rc),Rt=Dt.user,Rt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new wp({channelUrls:[Ut.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:Rt}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(Ut,Rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 271:return a.next=273,this.getChannel(Oe.channelUrl,!0);case 273:return Lt=a.sent,Pt=t.as(ic),Ft=Pt.freeze,Lt.isFrozen=Ft,this._dispatcher.dispatch(new Cp({channels:[Lt],context:{source:Ft?e.CollectionEventSource.EVENT_CHANNEL_FROZEN:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ft?e.onChannelFrozen&&e.onChannelFrozen(Lt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 279:return a.next=281,this.getChannel(Oe.channelUrl,!0);case 281:return qt=a.sent,Ht=t.as(uv),Gt=Ht.allowAutoUnhide,jt=Ht.hidePreviousMessages,Vt=Ht.messageOffsetTimestamp,null!==Gt&&(qt.hiddenState=Gt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==jt&&jt&&qt._updateUnreadCount(0,0),null!==Vt&&(qt.messageOffsetTimestamp=Vt),this._dispatcher.dispatch(new Cp({channels:[qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 289:return a.next=291,this.getChannel(Oe.channelUrl,!0);case 291:return(zt=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new Cp({channels:[zt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(zt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 296:return a.next=298,this.getChannel(Oe.channelUrl,!0);case 298:return Bt=a.sent,this._dispatcher.dispatch(new wp({channelUrls:[Oe.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Bt.url,Bt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 302:return a.next=304,this.getChannelWithoutCache(Oe.channelUrl,!0);case 304:return Qt=a.sent,this._dispatcher.dispatch(new Cp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 308:return a.next=310,this.getChannel(Oe.channelUrl,!0);case 310:return Kt=a.sent,Wt=t.as(Lu),Yt=Wt.created,Zt=Wt.updated,Xt=Wt.deleted,Yt&&(Kt._upsertCachedMetaData(Yt,Oe.ts),this._dispatcher.dispatch(new Cp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:Yt},ts:Oe.ts}))),Zt&&(Kt._upsertCachedMetaData(Zt,Oe.ts),this._dispatcher.dispatch(new Cp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:Zt},ts:Oe.ts}))),Xt&&(Kt._removeFromCachedMetaData(Xt,Oe.ts),this._dispatcher.dispatch(new Cp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:Xt},ts:Oe.ts}))),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Yt&&e.onMetaDataCreated&&e.onMetaDataCreated(Kt,Yt),Zt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Kt,Zt),Xt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Kt,Xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 317:return a.next=319,this.getChannel(Oe.channelUrl,!0);case 319:return Jt=a.sent,$t=t.as(Ku),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&this._dispatcher.dispatch(new Cp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:en}})),tn&&this._dispatcher.dispatch(new Cp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:tn}})),nn&&this._dispatcher.dispatch(new Cp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:nn}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){en&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Jt,en),tn&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Jt,tn),nn&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Jt,nn)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 326:return a.next=328,this.getChannel(Oe.channelUrl,!0);case 328:return rn=a.sent,an=t.as(_v),sn=an.pinnedMessageIds,on=an.latestPinnedMessage,(un=an.ts)>rn._pinnedMessagesUpdatedAt&&(rn.pinnedMessageIds=null!=sn?sn:[],rn.lastPinnedMessage=on,rn._pinnedMessagesUpdatedAt=un,this._dispatcher.dispatch(new Cp({channels:[rn],context:{source:e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(rn)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(rn)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",332);case 332:return a.abrupt("break",344);case 333:cn=t.as(zh),ln=cn.event,a.t7=ln.category,a.next=a.t7===Nh.USER_BLOCK?337:a.t7===Nh.USER_UNBLOCK?340:343;break;case 337:return dn=Hh.getDataAsUserBlockEvent(this._iid,ln),hn=dn.blocker,fn=dn.blockee,this._groupChannelCache.block(hn.userId,fn.userId),a.abrupt("break",343);case 340:return pn=Hh.getDataAsUserBlockEvent(this._iid,ln),vn=pn.blocker,_n=pn.blockee,this._groupChannelCache.unblock(vn.userId,_n.userId),a.abrupt("break",343);case 343:return a.abrupt("break",344);case 344:a.next=350;break;case 346:if(a.prev=346,a.t8=a.catch(0),!N(a.t8)){a.next=350;break}throw a.t8;case 350:case"end":return a.stop()}}),a,this,[[0,346],[18,29,32,35],[116,129,132,135],[228,239,242,245]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",t)).throw(A.invalidParameters),a=new Ip({channelUrl:t,isInternalCall:n}),r.next=4,this._requestQueue.send(a);case 4:i=r.sent,s=i.as(Np),o=s.channel,u=o.unreadMessageCount,c=o.unreadMentionCount,r.t0=o.myCountPreference,r.next=r.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:r.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:r.t0===e.CountPreference.OFF?14:17;break;case 10:return c=0,r.abrupt("break",17);case 12:return u=0,r.abrupt("break",17);case 14:return u=0,c=0,r.abrupt("break",17);case 17:return o._updateUnreadCount(u,c),r.next=20,this.upsertChannelsToCache([o]);case 20:return r.abrupt("return",r.sent[0]);case 21:case"end":return r.stop()}}),r,this)})))}},{key:"refreshChannel",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REFRESH_CHANNEL,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,s=new Ip({channelUrl:t,isInternalCall:n,showLatestMessage:a}),i.next=4,this._requestQueue.send(s);case 4:if(o=i.sent,u=o.as(Np),(c=u.channel).myMemberState!==e.MemberState.NONE){i.next=10;break}this._dispatcher.dispatch(new wp({channelUrls:[c.url],context:{source:r}})),i.next=14;break;case 10:return i.next=12,this.upsertChannelsToCache([c]);case 12:l=i.sent,this._dispatcher.dispatch(new Cp({channels:l,context:{source:r}}));case 14:i.next=19;break;case 16:i.prev=16,i.t0=i.catch(0),i.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&i.t0.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new wp({channelUrls:[t],context:{source:r}}));case 19:case"end":return i.stop()}}),i,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_CHANNEL,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p,v;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.createdAfter&&(n.createdAfter=Math.floor(n.createdAfter/1e3)),n.createdBefore&&(n.createdBefore=Math.floor(n.createdBefore/1e3)),s=!1,i&&(o=ss.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(s=!0)),l=new Mp(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:r,includeLeftChannel:i&&s})),e.next=7,this._requestQueue.send(l);case 7:return h=e.sent,f=h.as(Op),p=f.channels,v=f.token,this._dispatcher.dispatch(new Cp({channels:p,context:{source:a}})),e.abrupt("return",{channels:p,token:v});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Object.assign(Object.assign({},lp),n),ui((D("string",t)||D("number",t))&&dp(a)).throw(A.invalidParameters),i=new Sp(ve({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,filter:a})),e.next=5,this._requestQueue.send(i);case 5:return s=e.sent,o=s.as(Tp),u=o.updatedChannels,c=o.deletedChannelUrls,l=o.hasMore,h=o.ts,u.length>0&&this._dispatcher.dispatch(new Cp({channels:u,context:{source:r},ts:h})),c.length>0&&this._dispatcher.dispatch(new wp({channelUrls:c,context:{source:r}})),e.abrupt("return",{updatedChannels:u,deletedChannelUrls:c,hasMore:l,token:o.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},hp),e),ui(fp(n)).throw(A.invalidParameters),r=new Up({userId:this._sdkState.userId,filter:n}),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Dp),s=i.groupChannelCount,t.abrupt("return",s);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},vp),e),ui(_p(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Rp({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Lp),c=u.groupChannelUnreadMentionCount,l=u.groupChannelUnreadMessageCount,h=u.groupChannelInvitationCount,f=u.superGroupChannelUnreadMentionCount,p=u.superGroupChannelUnreadMessageCount,v=u.superGroupChannelInvitationCount,_=u.nonSuperGroupChannelUnreadMentionCount,m=u.nonSuperGroupChannelUnreadMessageCount,g=u.nonSuperGroupChannelInvitationCount,t.abrupt("return",pe({groupChannelUnreadMentionCount:c,groupChannelUnreadMessageCount:l,groupChannelInvitationCount:h,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Pp({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Fp),o=s.unreadCount,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},mp),e),ui(gp(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new qp({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Hp),c=u.unreadCount,t.abrupt("return",c);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},yp),e),ui(Ep(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Gp(n),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(jp),u=o.count,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=ss.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=ss.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=ss.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},up),e),ui(cp(n)).throw(A.invalidParameters),n.isPublic||(n.accessCode=void 0),r=new zp(Object.assign({userId:this._sdkState.userId},n)),t.next=6,this._requestQueue.send(r);case 6:return a=t.sent,i=a.as(Bp),s=i.channel,t.next=10,this.upsertChannelsToCache([s]);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Date.now(),ui(t-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Qp({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(n);case 6:r=this._groupChannelCache.channels,a=s(r);try{for(a.s();!(i=a.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0)}catch(e){a.e(e)}finally{a.f()}if(!(r.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(r);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),ui(P("string",e)&&n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new Qp({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,i=[],o=s(a);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,n),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()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return n=t.sent,t.next=5,n.markAsDelivered();case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._messageCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0});case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),r,this)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:100,i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return E(this,void 0,void 0,d().mark((function s(){return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i});case 2:return s.abrupt("return",s.sent);case 3:case"end":return s.stop()}}),s,this)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.countBetween(e,t,new Sv({top:n,bottom:r}));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:t});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return Tv[e]||(Tv[e]=new a(e,ss.of(e))),Tv[e]}},{key:"clear",value:function(e){Tv[e]&&delete Tv[e]}}])}(mv),Nv=function(e,t){return t instanceof to?e.findIndex((function(e){return e instanceof to&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Av=function(e,t){return e.findIndex((function(e){return e instanceof eo?e.messageId===t:e instanceof _o?e.notificationId===t:void 0}))},Mv=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(i<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(pp||(pp={}));var Ov=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t))._state=pp.IDLE,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=a,i}return c(t,e),i(t,[{key:"isIdle",get:function(){return this._state===pp.IDLE}},{key:"isRunning",get:function(){return this._state===pp.RUNNING}},{key:"isDone",get:function(){return this._state===pp.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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:n=t.sent,this._retryCount=0,this.dispatch("progress",n),n.hasNext?this._run(n.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(E=_.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(y=u.range).intersect.apply(y,v(E)))?this.extendRange(_):this._metadata={range:new Sv({top:Math.min.apply(Math,v(E)),bottom:Math.max.apply(Math,v(E))}),previousComplete:!1}),h.hasNext=_.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(h.nextToken=this._metadata.range.top,this._metadata.previousComplete=_.length0&&(y=f.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(_=o.range).intersect.apply(_,v(y)))?this.extendRange(f):this._metadata={range:new Sv({top:Math.min.apply(Math,v(y)),bottom:Math.max.apply(Math,v(y))}),previousComplete:!1}),l.hasNext=f.length>=this._limit,this._metadata&&(l.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",l),n.next=15,this.saveMetadata();case 15:n.next=21;break;case 17:throw n.prev=17,n.t0=n.catch(4),m.debug("message background next sync error",n.t0),n.t0;case 21:return n.prev=21,g.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:s.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=p.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.finish(21);case 24:return n.abrupt("return",l);case 25:case"end":return n.stop()}}),n,this,[[4,17,21,24]])})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=_.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 Sv({})}},{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,v(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,v(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{range:new Sv(r.range),previousComplete:r.previousComplete}:{range:new Sv({}),previousComplete:!1};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,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.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,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now(),i=ss.of(this._iid),s=i.logger,o=i.sessionManager;i.cacheContext.localCacheEnabled&&o.session.hasSession&&(s.debug("message background sync resume()"),this._prevSyncLoopCount=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(){ss.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 Uv[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n){return Uv[e]||(Uv[e]={}),Uv[e][n.url]||(Uv[e][n.url]=new t({_iid:e,channel:n})),Uv[e][n.url].ref++,Uv[e][n.url]}},{key:"clear",value:function(e,t){Uv[e]&&Uv[e][t]&&(Uv[e][t].close(),delete Uv[e])}}])}(),Rv={},Lv=function(){function t(n){var a=this,i=n._iid,s=n.channel,o=n.includeParams;r(this,t),this.ref=0,this._iid=i,this._channel=s,this._includeParams=o;var u,c,l=ss.of(this._iid),h=l.logger,f=l.sdkState,p=l.dispatcher;this._metadataKey=(u=f.userId,c=s.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var v=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(f.userId,this._channel.url);this._sync=new Ov(v,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,a=oh.of(this._iid),t.next=8,a.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:e.ReplyType.ALL},this._includeParams),e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,s=i.updatedMessages,o=i.deletedMessageIds,u=i.hasMore,c=i.token,r.hasNext=u,r.nextToken=c,(s.length>0||o.length>0)&&this._metadata&&(this._metadata.token=c),h.debug("message changelog sync progress",r),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),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",r);case 29:case"end":return t.stop()}}),t,this,[[4,21]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.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=ss.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){ss.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Rv[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n,r){return Rv[e]||(Rv[e]={}),Rv[e][n.url]||(Rv[e][n.url]=new t({_iid:e,channel:n,includeParams:r})),Rv[e][n.url].ref++,Rv[e][n.url]}},{key:"clear",value:function(e,t){Rv[e]&&Rv[e][t]&&(Rv[e][t].close(),delete Rv[e])}}])}(),Pv={},Fv=function(){function e(t){var n=this,a=t._iid,i=t.channel,s=t.hasPollMessage;r(this,e),this.ref=0,this._iid=a,this._channel=i;var o,u,c=ss.of(this._iid),l=c.logger,h=c.sdkState,f=c.dispatcher;this._metadataKey=(o=h.userId,u=i.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new Ov(p,(function(){return E(n,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o,u,c,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(l.debug("poll changelog sync from",null===(t=this._metadata)||void 0===t?void 0:t.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,s();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return r={hasNext:!1,nextToken:0},e.abrupt("return",r);case 12:return this._metadata||(a=ss.of(this._iid),i=a.firstConnectedAt,this._metadata={token:i}),e.prev=13,o=el.of(this._iid),e.next=17,o.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return u=e.sent,c=u.hasMore,h=u.token,n.hasNext=c,n.nextToken=h,this._metadata.token=h,l.debug("poll changelog sync progress",n),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),l.debug("poll changelog sync error",e.t1),!(e.t1 instanceof 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",n);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)n.resume();else n.pause()}))}return i(e,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{token:r.token}:void 0;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ss.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){ss.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 Pv[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Pv[t]||(Pv[t]={}),Pv[t][n.url]||(Pv[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Pv[t][n.url].ref++,Pv[t][n.url]}}])}(),qv=function(t){function a(t){var i,s,o,u,c,l,d,h,f,p,v;return r(this,a),(i=n(this,a)).method=_e.GET,i.path="".concat(Pe(t.channelType),"/").concat(t.channelUrl,"/messages_gap"),i.params=pe({prev_start_ts:t.prevStart,prev_end_ts:t.prevEnd,prev_cache_count:t.prevCount,next_start_ts:t.nextStart,next_end_ts:t.nextEnd,next_cache_count:t.nextCount,huge_gap_threshold:null!==(s=t.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(o=t.customTypes)&&void 0!==o?o:["*"],message_type:null!==(u=t.messageType)&&void 0!==u?u:null,include_reply_type:null!==(c=t.replyType)&&void 0!==c?c:e.ReplyType.NONE,include_reactions:null===(l=t.includeReactions)||void 0===l||l,include_meta_array:null===(d=t.includeMetaArray)||void 0===d||d,include_thread_info:null===(h=t.includeThreadInfo)||void 0===h||h,include_parent_message_info:null===(f=t.includeParentMessageInfo)||void 0===f||f,with_sorted_meta_array:null===(p=t.includeMetaArray)||void 0===p||p,show_subchannel_messages_only:null!==(v=t.showSubchannelMessagesOnly)&&void 0!==v&&v,include_poll_details:!0,checking_continuous_messages:t.checkingContinuousMessages}),i}return c(a,t),i(a)}(Ve),Hv=function(e){function t(e,a){var i,s,o,u,c,l,d;return r(this,t),(i=n(this,t,[e,a])).isHugeGap=a.is_huge_gap,i.prevMessages=(null!==(s=a.prev_messages)&&void 0!==s?s:[]).map((function(t){return go(e,t)})),i.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,i.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,i.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return go(e,t)})),i.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,i.isContinuousNextMessages=null!==(d=a.is_continuous_next_messages)&&void 0!==d&&d,i}return c(t,e),i(t)}(ze),Gv={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var jv,Vv,zv,Bv=function(){return i((function e(){r(this,e),this._onCacheResult=ft,this._onApiResult=ft}),[{key:"_invokeResponse",value:function(e,t,n){var r=this;_i((function(){return E(r,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next="local"===r.t0?3:"remote"===r.t0?5:7;break;case 3:return this._onCacheResult(t,n),r.abrupt("break",7);case 5:return this._onApiResult(t,n),r.abrupt("break",7);case 7:case"end":return r.stop()}}),r,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}])}(),Qv=function(){return i((function t(n,a){var i=this,o=a.filter,u=a.startingPoint,c=a.limit,l=a.prevResultLimit,h=a.nextResultLimit,f=a.channel,p=a.channelManager,_=a.disableBackgroundSync,m=void 0!==_&&_;r(this,t),this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=n,this._key="mc-".concat(ce()),this._isDisposed=!1,this.filter=null!=o?o:new jd,this._channel=f,this._syncRange=new Sv({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof u&&Number.isFinite(u)?u:Number.MAX_SAFE_INTEGER,this._limit=c||100,this._prevResultLimit=null!=l?l:Math.floor(this._limit/2),this._nextResultLimit=null!=h?h:Math.floor(this._limit/2),this._channelManager=p;var g=ss.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(t,n){var r=n.source,a=t.findIndex((function(e){return e.isIdentical(i.channel)}));a>=0&&(i._replaceChannelOfCollection(t[a]),i.channel._runIfHandleableWithGroupChannel((function(t){switch(r){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:for(var a=!1,s=0;s=t.messageOffsetTimestamp){a=!0;var o=s;if(o>0){var u=i._messages.splice(0,o);i._removeMessagesFromView(u.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!a&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.CollectionEventSource.EVENT_CHANNEL_UNMUTED:var c=ss.of(i._iid).sdkState,l=n.user;c.userId===l.userId&&i._clearCheckMyMutedTimer();break;case e.CollectionEventSource.EVENT_CHANNEL_MUTED:var h=ss.of(i._iid).sdkState,f=n.user;h.userId===f.userId&&-1!==t._myMutedRemainingTime&&i._startCheckMyMutedTimer(t._myMutedRemainingTime);break;case e.CollectionEventSource.EVENT_CHANNEL_LEFT:t.isPublic&&i._clearCheckMyMutedTimer()}_i((function(){return E(i,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:bp(r)&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelUpdated)&&this._handler.onChannelUpdated(n,this.channel);case 1:case"end":return e.stop()}}),e,this)})))}))})),i._postprocessChannelUpdateEvent(t[a],r))},onRemove:function(e,t){var n=e.indexOf(i.channel.url);n>=0&&(i._clearCheckMyMutedTimer(),_i((function(){return E(i,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url);case 1:case"end":return e.stop()}}),e,this)})))})),i._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],o=[],u=s(t);try{for(u.s();!(r=u.n()).done;){var c=r.value;c.channelUrl===i._channel.url&&(i.filter.match(c)?a.push(c):o.push(i.keyOf(c)))}}catch(e){u.e(e)}finally{u.f()}if(Ps(n)){if(a.length>0)switch(n){case e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.CollectionEventSource.EVENT_MESSAGE_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.CollectionEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}o.length>0&&i._removeMessagesFromView(o,n)}i._postprocessMessageUpdateEvent(t,n)},onRemove:function(e,t){i._removeMessagesFromView(e,t),i._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:function(e,t){i._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){i._applyThreadInfoEventToView(e,t)}});var y=ss.of(this._iid),k=y.cacheContext,b=y.dispatcher,C=y.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),b.dispatch(new Cp({channels:[this._channel],context:{source:e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Dv.of(this._iid,this._channel),!m&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=Lv.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Fv.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Ov(this._key,(function(t){return E(i,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,C.run("message-fill-sync-".concat(f.url,"-prev"),(function(){return E(r,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._getRemoteMessages(t,{prevLimit:this._prevResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:k.localCacheEnabled});case 2:if(s=n.sent,o=s.messages,u=s.isContinuousMessages,!(o.length>0)){n.next=10;break}return c=Math.min.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:o.length>=this._prevResultLimit&&this.viewTop0)){n.next=10;break}return c=Math.max.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:!(o.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>c,nextToken:this._syncRange.bottom});case 10:return k.localCacheEnabled&&g.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=k.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:k.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.abrupt("return",{hasNext:!1,nextToken:0});case 12:case"end":return n.stop()}}),n,this)})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=b.on((function(e){if(e instanceof Ha)switch(e.stateType){case Da.CONNECTED:mi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._activate();case 1:case"end":return e.stop()}}),e,this)})))}));break;case Da.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}}))}),[{key:"keyOf",value:function(e){return 0}},{key:"changelogIncludeParams",get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}},{key:"_postprocessChannelUpdateEvent",value:function(e,t){}},{key:"_postprocessChannelRemoveEvent",value:function(e){}},{key:"_postprocessMessageUpdateEvent",value:function(e,t){}},{key:"_postprocessMessageRemoveEvent",value:function(e){}},{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return v(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,v(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,v(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"_activate",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),n.logger.debug("check huge gap"),this._checkHugeGap(),t.next=5,this._refreshChannel(e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_replaceChannelOfCollection",value:function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}},{key:"_shouldStartBackgroundSync",value:function(){var e=ss.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}},{key:"_setBaseMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n instanceof eo&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,t){var n,r=this,a=[],i=s(e);try{for(i.s();!(n=i.n()).done;){var o=n.value,u=Av(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c.isUserMessage()&&c.applyPoll(o),a.push(c)}}}catch(e){i.e(e)}finally{i.f()}return a.length>0&&Ps(t)&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},a.length>0&&(null===(r=(n=this._handler).onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,a));case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_applyPollUpdateEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollUpdateEvent(e)&&Ps(t)&&_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollVoteEvent(e)&&Ps(t)&&_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyReactionEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ps(t)&&(a.applyReactionEvent(e),_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_applyThreadInfoEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.targetMessageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ps(t)&&(a.applyThreadInfoUpdateEvent(e),_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_removeMessagesFromView",value:function(e,t){var n,r=this,a=[],i=[],o=s(e);try{var u=function(){var e=n.value,t=r._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var s=r._messages[t];a.push(r.keyOf(s)),i.push(s),r._messages.splice(t,1)}};for(o.s();!(n=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return Ps(t)&&i.length>0&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===r||r.call(n,s,this.channel,a,i);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,t){var n=t.prevLimit,r=void 0===n?0:n,a=t.nextLimit,i=void 0===a?0:a,s=t.inclusive,o=void 0===s||s;return E(this,void 0,void 0,d().mark((function t(){var n,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!o){t.next=5;break}return t.next=4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter);case 4:n=t.sent;case 5:if(!(r>0)){t.next=11;break}return t.next=8,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r,!1);case 8:t.t0=t.sent,t.next=12;break;case 11:t.t0=[];case 12:if(a=t.t0,!(i>0)){t.next=19;break}return t.next=16,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,i,!1);case 16:t.t1=t.sent,t.next=20;break;case 19:t.t1=[];case 20:return s=t.t1,t.abrupt("return",{messages:[].concat(v(n),v(a),v(s)).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:a.length,nextMessagesCount:s.length});case 22:case"end":return t.stop()}}),t,this)})))}},{key:"_getRemoteMessages",value:function(t,n){var r=n.prevLimit,a=void 0===r?0:r,i=n.nextLimit,s=void 0===i?0:i,o=n.source,u=void 0===o?e.CollectionEventSource.REQUEST_MESSAGE:o,c=n.reverse,l=void 0!==c&&c,h=n.checkingHasNext,f=void 0!==h&&h,p=n.checkingContinuousMessages,v=void 0!==p&&p;return E(this,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=oh.of(this._iid),!(a>0||s>0)){e.next=7;break}return e.next=4,n._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,t,ve(Object.assign(Object.assign(Object.assign({},this.filter),Gv),{isInclusive:!0,reverse:l,prevResultSize:a,nextResultSize:s})),u,f,v);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 t,n,r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,_,m,g,y,k,b,C,w,x,S,T,I,N,M,O,U,D=this;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(o=ss.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=o.cacheContext,h=o.statManager,f=o.logger,!(this._messages.length>0)){s.next=25;break}return p=this._syncRange.top,_=this.viewTop,m=this._syncRange.bottom,g=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,s.next=8,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,_,p);case 8:return y=s.sent,s.next=11,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,m,g);case 11:return k=s.sent,s.prev=12,s.next=15,Ci((function(){return E(D,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,h,f,b,C,w,x,S,T,I,N,A,M=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new qv(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:_,prevEnd:p,prevCount:y,nextStart:m,nextEnd:g,nextCount:k,checkingContinuousMessages:l.localCacheEnabled},this.filter),Gv)),t.next=3,c.send(r);case 3:a=t.sent,i=a.as(Hv),s=i.isHugeGap,o=i.prevMessages,h=void 0===o?[]:o,f=i.prevHasMore,b=i.isContinuousPrevMessages,C=i.nextMessages,w=void 0===C?[]:C,x=i.nextHasmore,S=i.isContinuousNextMessages,s?_i((function(){return E(M,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this._handler)||void 0===t?void 0:t.onHugeGapDetected)&&this._handler.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(T=this.viewTop,I=this.viewBottom,N=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,T].concat(v(h.map((function(e){return e.createdAt}))))),A=Math.max.apply(Math,[0,I].concat(v(w.map((function(e){return e.createdAt}))))),u.dispatch(new Fs({messages:h,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),u.dispatch(new Fs({messages:w,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(N,A),(b||S)&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(N,A)),f&&this._prevFill.start(N),x&&this._nextFill.start(A));case 6:case"end":return t.stop()}}),t,this)})))}),1);case 15:s.next=20;break;case 17:s.prev=17,s.t0=s.catch(12),f.debug("Failed HugeGap Check ",s.t0);case 20:return s.prev=20,l.localCacheEnabled&&h.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(t=l.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(20);case 23:s.next=42;break;case 25:return b=Date.now(),s.prev=26,s.next=29,this._getRemoteMessages(b,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled});case 29:if(C=s.sent,w=C.messages,x=C.isContinuousMessages,S=C.hasNext,w.length>0){for(I=w.map((function(e){return e.createdAt})),N=0,M=0,O=0;O=b&&M++;this._hasPrevious=N>=this._prevResultLimit,this._hasNext=null!=S?S:M>=this._nextResultLimit,(T=this._syncRange).extends.apply(T,v(I)),x&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(w,e.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;s.next=39;break;case 36:s.prev=36,s.t1=s.catch(26),s.t1 instanceof A&&s.t1.code===e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 39:return s.prev=39,l.localCacheEnabled&&h.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=l.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(39);case 42:case"end":return s.stop()}}),s,this,[[12,17,20,23],[26,36,39,42]])})))}},{key:"_loadUnsentMessages",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter);case 2:this._unsentMessages=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1);case 2:if(!(e.sent.length>0)){e.next=5;break}return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.logger,n.prev=1,n.next=4,this._channelManager.refreshChannel(this.channel.url,!0,e,t);case 4:n.next=9;break;case 6:n.prev=6,n.t0=n.catch(1),a.warn("Failed to refresh channel",n.t0);case 9:case"end":return n.stop()}}),n,this,[[1,6]])})))}},{key:"_startCheckMyMutedTimer",value:function(t){var n=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=void 0,n=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:r=t.sent,n=!r.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),n=!0;case 12:return t.prev=12,n&&(a=ss.of(this._iid),i=a.sessionManager,this.channel._runIfHandleableWithGroupChannel((function(t){var n,r;t.myMutedState=e.MutedState.UNMUTED;var a={source:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i.currentUser};null===(r=null===(n=s._handler)||void 0===n?void 0:n.onChannelUpdated)||void 0===r||r.call(n,a,s.channel)}))),t.finish(12);case 15:case"end":return t.stop()}}),t,this,[[2,9,12,15]])})))}),t+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}},{key:"_setHasNextAndHasPrevious",value:function(e,t){for(var n=e.map((function(e){return e.createdAt})),r=0,a=0,i=0;ithis._startingPoint&&a++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=t?t:a>=this._nextResultLimit}},{key:"initialize",value:function(t){var n=this,r=new Bv;this._messages=[],this._unsentMessages=[],this._syncRange=new Sv({}),this._hasNext=!0,this._hasPrevious=!0;var a=[],i={messages:[],prevMessagesCount:0,nextMessagesCount:0};return _i((function(){return E(n,void 0,void 0,d().mark((function n(){var s,o,u,c,l,h=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,null===(s=this._backgroundSync)||void 0===s?void 0:s.loadMetadata();case 2:o=n.sent,u=ss.of(this._iid),c=u.cacheContext,l=u.statManager,n.t0=t,n.next=n.t0===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API?7:9;break;case 7:return this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(t){return E(h,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=t,a=this._filterUnderOffsetMessage(i.messages),this._addMessagesToView(a,e.CollectionEventSource.REQUEST_MESSAGE),n.next=5,this._loadUnsentMessages();case 5:r._invokeResponse("local",null,a);case 6:case"end":return n.stop()}}),n,this)})))})).catch((function(e){if(N(e))throw e;r._invokeResponse("local",e,null)})).finally((function(){return E(h,void 0,void 0,d().mark((function n(){var s,u,c,h,f,p,_,m,g=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return c=ss.of(this._iid),h=c.cacheContext,f=!0,p=!0,_=!1,h.localCacheEnabled&&a.length>0&&(m=o.range).includes.apply(m,v(a.map((function(e){return e.createdAt}))))&&(!o.previousComplete&&i.prevMessagesCounto.range.bottom||i.nextMessagesCount=e._latestMessageInfo.createdAt&&(p=!1)})),p?(f=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled}).then((function(t){var n,a,i,s=t.messages,o=t.isContinuousMessages,u=t.hasNext,c=g._filterUnderOffsetMessage(s);(g._messages=[],c.length>0)?(g._setHasNextAndHasPrevious(c,u),(i=g._syncRange).extends.apply(i,v(c.map((function(e){return e.createdAt})))),o&&(null===(n=g._backgroundSync)||void 0===n?void 0:n.range.overlap(g._syncRange))&&(null===(a=g._backgroundSync)||void 0===a||a.range.extends(g._syncRange.top,g._syncRange.bottom)),g._addMessagesToView(c,e.CollectionEventSource.REQUEST_MESSAGE)):(g._hasPrevious=!1,g._hasNext=!1);r._invokeResponse("remote",null,c)})).catch((function(e){if(N(e))throw e;r._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(a),r._invokeResponse("remote",null,a)),h.localCacheEnabled&&l.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:f?"cache_hit":"cache_miss",max_db_size:null!==(u=null===(s=h.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==u?u:0,message_init_policy:t,use_local_cache:h.localCacheEnabled,collection_id:this._key}}));case 10:case"end":return n.stop()}}),n,this)})))})),n.abrupt("break",9);case 9:l.put(new Yi({type:je.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message_init_policy:t,message:!0}}}));case 10:case"end":return n.stop()}}),n,this)})))})),r}},{key:"loadPrevious",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=ss.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasPrevious){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingPrevious){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingPrevious=!0,c=this.viewTop,l=[],a.next=13,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{prevLimit:this._prevResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._prevResultLimit,s.localCacheEnabled&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ss.of(this._iid),s=i.cacheContext,e.next=3,this._getRemoteMessages(c,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:s.localCacheEnabled});case 3:u=e.sent,(l=this._filterUnderOffsetMessage(u.messages)).length>0&&((h=this._syncRange).extends.apply(h,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&u.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top))),l=l.filter((function(e){return Nv(p._messages,e)<0})),this._hasPrevious=l.length>=this._prevResultLimit,f&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(r=s.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasPrevious=l.length>=this._prevResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingPrevious=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"loadNext",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=ss.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasNext){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingNext){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingNext=!0,c=this.viewBottom,l=[],a.next=13,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{nextLimit:this._nextResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._nextResultLimit,s.localCacheEnabled&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p,_=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=ss.of(this._iid),u=s.cacheContext,e.next=3,this._getRemoteMessages(c,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:u.localCacheEnabled});case 3:h=e.sent,(l=this._filterUnderOffsetMessage(h.messages)).length>0&&((p=this._syncRange).extends.apply(p,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.bottom))),l=l.filter((function(e){return Nv(_._messages,e)<0})),this._hasNext=null!==(r=h.hasNext)&&void 0!==r?r:l.length>=this._nextResultLimit,f&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(i=null===(a=u.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:u.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasNext=l.length>=this._nextResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingNext=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"removeFailedMessage",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:return n.next=4,this._channelManager.removeFailedMessageFromCache(t);case 4:(r=this._unsentMessages.findIndex((function(e){return e.reqId===t})))>-1&&this._unsentMessages.splice(r,1);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=this;if(!this._isDisposed){this._isDisposed=!0;var i=ss.of(this._iid),s=i.cacheContext,o=i.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(t){t.myMemberState!==e.MemberState.NONE&&(a._channel._updateMessageCollectionLastAccessedAt(),o.dispatch(new Cp({channels:[a._channel],context:{source:e.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}}])}(),Kv=function(t){function a(e,t){return r(this,a),n(this,a,[e,Object.assign(Object.assign({},t),{channelManager:Iv.of(e)})])}return c(a,t),i(a,[{key:"keyOf",value:function(e){return e.messageId}},{key:"initialize",value:function(e){var t=this;return mi((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),p(a,"initialize",this,3)([e])}},{key:"setMessageCollectionHandler",value:function(e){this._setBaseMessageCollectionHandler(e)}},{key:"_activate",value:function(){var e=this,t=Object.create(null,{_activate:{get:function(){return p(a,"_activate",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t._activate.call(this);case 2:return e.next=4,mi((function(){return E(n,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_addMessagesToView",value:function(t,n){var r,a=this,i=this._filterUnderOffsetMessage(t),o=[],u=[],c=s(i);try{for(c.s();!(r=c.n()).done;){var l=r.value;if(n===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(Nv(this._messages,l)<0){Nv(this._unsentMessages,l)<0&&o.push(l);var h=Mv(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof to){Nv(this._unsentMessages,l)<0&&Nv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var f=Nv(this._messages,l);if(f<0){var p=Nv(this._unsentMessages,l);p<0?o.push(l):(this._unsentMessages.splice(p,1),u.push(l));var _=Mv(this._messages,l);this._messages.splice(_,0,l)}else u.push(l),this._messages[f]=l;if(l.updatedAt>0){var m=this._updateChildMessagesInView(l);u.push.apply(u,v(m))}}else if(l instanceof to){var g=Nv(this._unsentMessages,l);g<0?Nv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[g]=l)}}}catch(e){c.e(e)}finally{c.f()}Ps(n)&&_i((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:n},o.length>0&&(null===(r=null===(t=this._handler)||void 0===t?void 0:t.onMessagesAdded)||void 0===r||r.call(t,s,this.channel,o)),u.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateMessagesToView",value:function(e,t){var n,r=this,a=[],i=[],o=[],u=s(e);try{for(u.s();!(n=u.n()).done;){var c=n.value;if(c.messageId>0){var l=Nv(this._messages,c);if(l>=0)i.push(c),this._messages[l]=c;else{var h=Nv(this._unsentMessages,c);if(h>=0){var p=f(this._unsentMessages.splice(h,1),1)[0];if(this.hasNext&&p)o.push(p);else{i.push(c);var _=Mv(this._messages,c);this._messages.splice(_,0,c)}}else{var m=this._messages.map((function(e){return e.createdAt}));(c.createdAtMath.max.apply(Math,v(m))&&!this._hasNext)&&a.push(c)}}}else if(c instanceof to){var g=Nv(this._unsentMessages,c);g>=0&&(i.push(c),this._unsentMessages[g]=c)}}}catch(e){u.e(e)}finally{u.f()}return Ps(t)&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c={source:t},i.length>0?null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,c,this.channel,i):o.length>0?null===(u=null===(s=this._handler)||void 0===s?void 0:s.onMessagesDeleted)||void 0===u||u.call(s,c,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t);case 2:case"end":return e.stop()}}),e,this)})))})),i}}])}(Qv),Wv={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},Yv=function(e){return D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isDiscoverable,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},Zv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,d=e.nicknameStartsWithFilter,h=e.operatorFilter;return(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/members"),a.params={token:s,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:d,operator_filter:h,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return c(t,e),i(t)}(Ve),Xv=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).members=[];var s=a.next,o=a.members;return i.token=s,o&&o.length>0&&(i.members=o.map((function(t){return new tp(e,t)}))),i}return c(t,e),i(t)}(ze);e.MutedMemberFilter=void 0,(jv=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",jv.MUTED="muted",jv.UNMUTED="unmuted",e.MemberListOrder=void 0,(Vv=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",Vv.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(zv=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",zv.JOINED="joined_only",zv.INVITED="invited_only",zv.INVITED_BY_FRIEND="invited_by_friend",zv.INVITED_BY_NON_FRIEND="invited_by_non_friend";var Jv,$v,e_=function(t){function a(t,i,s){var o,u,c,l,d;return r(this,a),(o=n(this,a,[t,i,e.ChannelType.GROUP,s])).mutedMemberFilter=e.MutedMemberFilter.ALL,o.memberStateFilter=e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null,o.operatorFilter=e.OperatorFilter.ALL,o.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o.mutedMemberFilter=null!==(u=s.mutedMemberFilter)&&void 0!==u?u:e.MutedMemberFilter.ALL,o.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,o.order=null!==(d=s.order)&&void 0!==d?d:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R(e.MutedMemberFilter,this.mutedMemberFilter)&&R(e.MemberStateFilter,this.memberStateFilter)&&(D("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&R(e.OperatorFilter,this.operatorFilter)&&R(e.MemberListOrder,this.order)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Zv(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Xv),s=i.members,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),t_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/accept"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(Ve),n_=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).channel=new x_(t,i),s.channel.myMemberState=e.MemberState.JOINED,s}return c(a,t),i(a)}(ze),r_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,d=e.accessCode,h=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a.params=pe({is_distinct:s,is_public:o,is_discoverable:u,name:h,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:d,operator_ids:v,message_survival_seconds:_}),a}return c(t,e),i(t)}(Ve),a_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),i_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(Ve),s_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a}return c(t,e),i(t)}(Ve),o_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.countPreference;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:o},a}return c(t,e),i(t)}(Ve),u_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).countPreference=a.count_preference,i}return c(t,e),i(t)}(ze),c_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.locale;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/reset_user_history"),a.params=pe({locale:s}),a}return c(t,e),i(t)}(Ve),l_=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(ze),d_=Object.assign(Object.assign({},uu),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),h_=function(e){return cu(e)&&D("number",e.scheduledAt,!0)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},f_=Object.assign(Object.assign({},lu),{scheduledAt:void 0}),p_=function(e){return du(e)&&D("number",e.scheduledAt,!0)},v_=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl,d=t.scheduledMessageId;return i.method=_e.PUT,i.path="".concat(Pe(c),"/").concat(encodeURIComponent(l),"/scheduled_messages/").concat(encodeURIComponent(d)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return us.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(Ve),__=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new yo(e,a),i}return c(t,e),i(t)}(ze),m_=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.PUT,i.path="".concat(Pe(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(Ve),g_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.DELETE,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(Ve),y_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return c(t,e),i(t)}(Ve),E_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:o},a}return c(t,e),i(t)}(Ve),k_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(ze),b_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),C_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(ze);e.CountPreference=void 0,(Jv=e.CountPreference||(e.CountPreference={})).ALL="all",Jv.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Jv.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Jv.OFF="off",e.HiddenState=void 0,($v=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",$v.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",$v.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var w_,x_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y,E,k,b,C,w,x,S,T;(r(this,a),(s=n(this,a,[t,i]))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s._hasBotInfo={general:!1,ai:!1},s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isChatNotification=!1,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.totalUnreadReplyCount=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.lastPinnedMessage=null,s._latestMessageInfo=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(o=i.is_distinct)&&void 0!==o&&o,s.isSuper=null!==(u=i.is_super)&&void 0!==u&&u,s.isBroadcast=null!==(c=i.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=i.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(d=i.is_public)&&void 0!==d&&d,s.isDiscoverable=null!==(h=i.is_discoverable)&&void 0!==h?h:s.isPublic,s.isChatNotification=null!==(f=i.is_chat_notification)&&void 0!==f&&f,s.isAccessCodeRequired=null!==(p=i.is_access_code_required)&&void 0!==p&&p,s.isPushEnabled=null!==(_=i.is_push_enabled)&&void 0!==_&&_,Array.isArray(i.members))&&(T=s.members).push.apply(T,v(i.members.map((function(e){return new tp(s._iid,e)}))));return s.memberCount=null!==(m=i.member_count)&&void 0!==m?m:0,s.joinedMemberCount=null!==(g=i.joined_member_count)&&void 0!==g?g:0,s.hiddenState=R(e.HiddenState,i.hidden_state)?i.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(y=i.ts_message_offset)&&void 0!==y?y:0,s.messageSurvivalSeconds=null!==(E=i.message_survival_seconds)&&void 0!==E?E:-1,s.lastMessage=i.last_message?go(s._iid,Object.assign({channel_type:s.channelType},i.last_message)):null,i.read_receipt&&Object.keys(i.read_receipt).forEach((function(e){D("number",i.read_receipt[e])&&s._updateUnreadMemberState(e,i.read_receipt[e])})),i.delivery_receipt&&Object.keys(i.delivery_receipt).forEach((function(e){D("number",i.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,i.delivery_receipt[e])})),s.myMemberState=R(e.MemberState,i.member_state)?i.member_state:e.MemberState.NONE,s.myRole=R(e.Role,i.my_role)?i.my_role:e.Role.NONE,R(e.MutedState,i.is_muted)?s.myMutedState=i.is_muted:D("boolean",i.is_muted)?s.myMutedState=i.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=R(e.CountPreference,i.count_preference)?i.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=R(e.PushTriggerOption,i.push_trigger_option)?i.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=i.user_last_read)&&void 0!==k?k:0,s.inviter=i.inviter?new li(s._iid,i.inviter):null,s.invitedAt=null!==(b=i.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(C=i.joined_ts)&&void 0!==C?C:0,s._updateUnreadCount(null!==(w=i.unread_message_count)&&void 0!==w?w:0,null!==(x=i.unread_mention_count)&&void 0!==x?x:0),s.totalUnreadReplyCount=null!==(S=i.total_unread_thread_message_count)&&void 0!==S?S:0,s.lastPinnedMessage=i.latest_pinned_message?go(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,i.latest_message&&(s._latestMessageInfo={messageId:i.latest_message.message_id,createdAt:i.latest_message.created_at}),s._hasBotInfo={general:!!i.has_bot,ai:!!i.has_ai_bot},s}return c(a,t),i(a,[{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=s(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=s(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"hasBot",get:function(){return this._hasBotInfo.general}},{key:"hasAiBot",get:function(){return this._hasBotInfo.ai}},{key:"_shouldUpdateLastMessageWith",value:function(t){if(t.silent)return!1;var n=ss.of(this._iid).appInfo;switch(null==n?void 0:n.lastMessageThreadingPolicy){case e.LastMessageThreadingPolicy.NONE:case e.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case e.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(t.parentMessageId>0)return!1;break;case e.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof to&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case e.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof to&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}},{key:"_updateLastMessage",value:function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}},{key:"_updateUnreadCount",value:function(t,n){if("number"==typeof t&&t>=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=ss.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=ss.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return si(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Kv(this._iid,Object.assign(Object.assign({},e),{channel:this}))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new e_(this._iid,this.url,e)}},{key:"createThreadedParentMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yh(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 tp?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 to&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=ss.of(this._iid).sdkState,a=t.createdAt,i=0,o=s(this.members);try{for(o.s();!(n=o.n()).done;){var u=n.value;if(r.userId!==u.userId&&u.state===e.MemberState.JOINED&&t.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=ss.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof to?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o>=e.createdAt&&i.push(s)}})),i}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=ss.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof to?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o0&&void 0!==arguments[0]&&arguments[0],n=ss.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 i=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new ws(e._iid,{channel_url:e.url,channel_type:e.channelType,user:tp.payloadify(a),ts:null!=i?i:0})}})),r}},{key:"getDeliveryStatus",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=ss.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 i=e._undeliveredMemberStateMap.get(a.userId);r[a.userId]=new np(e._iid,{channel_url:e.url,channel_type:e.channelType,user:tp.payloadify(a),ts:null!=i?i: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=ss.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,i){var s=a.ts;n-s>=t&&(e._typingStatus.delete(i),r=!0)})),r}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._refresh());case 1:case"end":return e.stop()}}),e,this)})))}},{key:"_refresh",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ip({channelUrl:this.url}),n.next=4,a.send(s);case 4:return o=n.sent,u=o.as(Np),c=u.channel,this._update(c),t||i.dispatch(new Cp({channels:[c],context:{source:e.CollectionEventSource.REFRESH_CHANNEL}})),n.abrupt("return",this);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"freeze",value:function(){var t=this,n=Object.create(null,{freeze:{get:function(){return p(a,"freeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.freeze.call(this);case 2:r=ss.of(this._iid),r.dispatcher.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"unfreeze",value:function(){var t=this,n=Object.create(null,{unfreeze:{get:function(){return p(a,"unfreeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.unfreeze.call(this);case 2:r=ss.of(this._iid),r.dispatcher.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannel",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Wv),t),ui(Yv(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new r_(Object.assign({channelUrl:this.url},r)),n.next=6,s.send(o);case 6:return u=n.sent,c=u.as(a_),l=c.channel,this._update(l),i.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(e.every((function(e){return e instanceof li}))).throw(A.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"inviteWithUserIds",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(P("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.requestQueue,s=r.sessionManager,o=new $p({channelUrl:this.url,userIds:t}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.as(ev),l=c.channel,this._update(l),a.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:s.currentUser,invitees:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"join",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",t,!0)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Wp({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(Yp),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"leave",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Xp({channelUrl:this.url,userId:a.userId,shouldRemoveOperatorStatus:t}),n.next=4,i.send(s);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return n.stop()}}),n,this)})))}},{key:"acceptInvitation",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",t,!0)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new t_({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(n_),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"declineInvitation",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new nv({channelUrl:this.url,userId:r.userId}),t.next=4,a.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"sendUserMessage",this,3)([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){s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),Iv.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"updateUserMessage",value:function(t,n){var r=this,i=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=ss.of(this._iid),s=a.dispatcher,r.next=3,i.updateUserMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Iv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new Cp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Iv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Fs({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"_autoResendUserMessage",this,3)([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 a=Iv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"sendFileMessage",this,3)([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 a=Iv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new fl,i=ss.of(this._iid).dispatcher;return p(a,"sendMultipleFilesMessage",this,3)([t]).onPending((function(e){r._trigger(e)})).onFailed((function(e,t){r._triggerFailed(e,t)})).onSucceeded((function(t){var a=Iv.of(n._iid);n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(t,n){var r=this,i=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=ss.of(this._iid),s=a.dispatcher,r.next=3,i.updateFileMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Iv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new Cp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Iv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Fs({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"_autoResendFileMessage",this,3)([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 a=Iv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"deleteMessage",value:function(t){var n=this,r=Object.create(null,{deleteMessage:{get:function(){return p(a,"deleteMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.deleteMessage.call(this,t);case 2:0===t.messageId&&t instanceof to&&(a=ss.of(this._iid),a.dispatcher.dispatch(new js({reqId:t.reqId,source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"hide",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},av),t),ui(iv(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new sv(Object.assign({channelUrl:this.url,userId:s.userId},r)),n.next=6,o.send(u);case 6:return c=n.sent,l=c.as(ov),h=l.messageOffsetTimestamp,this.hiddenState=r.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,r.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),i.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),n.abrupt("return",this);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"unhide",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new s_({channelUrl:this.url}),t.next=4,a.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,r.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new i_({channelUrl:this.url}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.sdkState,a=n.dispatcher,i=n.requestQueue,s=new xs({channelUrl:this.url}),t.next=4,i.send(s);case 4:o=t.sent,u=o.as(Ss),c=u.readStatus,this._updateUnreadMemberState(r.userId,c.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Iv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)}))),a.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ev({channelUrl:this.url,userId:n.userId}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=ss.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingStarted>=r)){e.next=8;break}return this._typingStarted=a,this._typingEnded=0,i=new cv({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=ss.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingEnded>=r)){e.next=8;break}return this._typingStarted=0,this._typingEnded=a,i=new dv({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Bd),e),ui(function(e){return $o(e)&&D("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new Bo;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},f_),t),ui(p_(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new m_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(bc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createScheduledFileMessage",value:function(e){var t=this;e=Object.assign(Object.assign({},Qd),e),ui(function(e){return Ko(e)&&D("number",e.scheduledAt)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(A.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new Bo;return ki(2).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);_i((function(){return E(t,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a._trigger(i));case 1:case"end":return e.stop()}}),e)})))}))})),H(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a}},{key:"updateScheduledFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Object.assign(Object.assign({},d_),t),ui(h_(r)).throw(A.invalidParameters),!H(r.file)){n.next=5;break}return n.next=5,this._uploadFileAndUpdateParams(r);case 5:return a=new v_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),i=ss.of(this._iid),s=i.requestQueue,n.next=9,s.send(a);case 9:return o=n.sent,u=o.as(__),c=u.message,n.abrupt("return",c);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new g_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=ss.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new y_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=ss.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new b_({userId:n.userId,channelUrl:this.url}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(C_),o=s.pushTriggerOption,this.myPushTriggerOption=o,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new E_({userId:i.userId,channelUrl:this.url,pushTriggerOption:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(k_),l=c.pushTriggerOption,this.myPushTriggerOption=l,a.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"setMyCountPreference",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.CountPreference,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new o_({channelUrl:this.url,userId:i.userId,countPreference:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(u_),l=c.countPreference,this.myCountPreference=l,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),a.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"resetMyHistory",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=n.sdkState,s=new c_({channelUrl:this.url,locale:i.localeForChatbot}),t.next=4,a.send(s);case 4:return o=t.sent,u=o.as(l_),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,this.lastMessage&&this.lastMessage.createdAt=this._limit&&!!b,h.nextToken=b,this._metadata&&(this._metadata.token=b,(C=this._metadata.range).extends.apply(C,v(k.map((function(e){return e.createdAt})))),this._metadata.completed=!h.hasNext),f.debug("channel background sync progress",h),t.next=30,this.saveMetadata();case 30:t.next=39;break;case 32:if(t.prev=32,t.t1=t.catch(6),f.debug("channel background sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=38;break}return t.next=38,this.clearMetaData();case 38:throw t.t1;case 39:return t.prev=39,_.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(o=null===(s=p.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==o?o:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:null!==(c=null===(u=m.order)||void 0===u?void 0:u.toString())&&void 0!==c?c:"",collection_id:l.userId}})),t.finish(39);case 42:t.next=46;break;case 44:h.hasNext=!1,h.nextToken="";case 46:return t.abrupt("return",h);case 47:case"end":return t.stop()}}),t,this,[[6,32,39,42],[8,15]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 Sv({})}},{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,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata={token:r?r.token:"",range:new Sv(r?r.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!r&&r.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.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=ss.of(this._iid),r=n.logger;n.sessionManager.session.hasSession&&(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(){ss.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 S_[this._iid])}}],[{key:"of",value:function(e){return S_[e]||(S_[e]=new t({_iid:e})),S_[e].ref++,S_[e]}},{key:"clear",value:function(e){S_[e]&&(S_[e].close(),delete S_[e])}}])}(),I_={},N_=function(){function t(n){var a=this,i=n._iid;r(this,t),this.ref=0,this._iid=i;var s,o=ss.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher,h=o.cacheContext,f=o.statManager;this._metadataKey=(s=c.userId,"sendbird:".concat(s,"@groupchannel/changelogs.meta")),this._subscribers=new de;var p=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(c.userId);this._sync=new Ov(p,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,l,p,v,_,m,g;return d().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 u.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,s={includeEmpty:!0,includeMetaData:!0},t.prev=6,t.next=9,h.preference.get(Ba(c.appId));case 9:o=t.sent,s.includeChatNotification=Boolean(o),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(6),s.includeChatNotification=!1;case 16:return l=Iv.of(this._iid),t.next=19,l.getMyGroupChannelChangeLogs(null!==(a=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==a?a:"",s,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 19:return p=t.sent,v=p.updatedChannels,_=p.deletedChannelUrls,m=p.hasMore,g=p.token,this._subscribers.dispatch("progress",{updatedChannels:v,deletedChannelUrls:_,hasMore:m,token:g}),i.hasNext=m,i.nextToken=g,this._metadata&&(this._metadata.token=g),u.debug("channel changelog sync progress",i),t.next=31,this.saveMetadata();case 31:h.localCacheEnabled&&f.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:v.length>0||_.length>0?"cache_miss":"cache_hit",max_db_size:v.length,use_local_cache:h.localCacheEnabled,starting_point:0,message_init_policy:_.length.toString(),collection_id:c.userId}})),t.next=41;break;case 34:if(t.prev=34,t.t1=t.catch(4),u.debug("channel changelog sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=40;break}return t.next=40,this.clearMetadata();case 40:throw t.t1;case 41:return t.abrupt("return",i);case 42:case"end":return t.stop()}}),t,this,[[4,34],[6,13]])})))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=l.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"isRunning",get:function(){return this._sync.isRunning}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"on",value:function(e,t){return this._subscribers.on(e,t)}},{key:"resume",value:function(){ss.of(this._iid).sessionManager.session.hasSession&&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 I_[this._iid])}}],[{key:"of",value:function(e){return I_[e]||(I_[e]=new t({_iid:e})),I_[e].ref++,I_[e]}},{key:"clear",value:function(e){I_[e]&&(I_[e].close(),delete I_[e])}}])}(),A_=function(t,n){var r,a,i,s;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!==(s=null===(i=t.lastMessage)||void 0===i?void 0:i.createdAt)&&void 0!==s?s:t.createdAt}},M_=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},O_=function(e,t,n){if(e.length>0){for(var r=M_(e,t),a=0,i=e.length-1,s=Math.floor((a+i)/2);a0)i=s,s=Math.floor((a+i)/2);else{if(!(o<0))return{place:s,oldPosition:r};a=s+1,s=Math.floor((a+i)/2)}}return{place:U_(e[s],t,n)>=0?s:s+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},U_=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(t.lastMessage&&n.lastMessage){var a=n.lastMessage.createdAt-t.lastMessage.createdAt;return 0===a?n.createdAt-t.createdAt:a}return 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 i=t.name.localeCompare(n.name);return 0===i?t.createdAt-n.createdAt:i;default:return 0}},D_=function(){return i((function t(n,a){var i=this,s=a.filter,o=void 0===s?new ap:s,u=a.order,c=void 0===u?e.GroupChannelListOrder.LATEST_LAST_MESSAGE:u,l=a.limit,h=void 0===l?100:l,f=a.includeChangesOnInitialLoad,p=void 0!==f&&f;r(this,t),this.channels=[],this._isInitialized=!1,this._iid=n,this._key="gcc-".concat(ce()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=o,this.order=c,this._hasMore=!0,this._token="",this._limit=h;var v=ss.of(this._iid),_=v.sdkState,m=v.cacheContext,g=v.dispatcher;m.localCacheEnabled&&(this._backgroundSync=T_.of(n),this._backgroundSync.resume()),this._changelogSync=N_.of(n),this._changelogSync.resume(),Iv.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(bp(n)){var r=e.filter((function(e){return i.filter.match(e,_.userId)})),a=e.filter((function(e){return!i.filter.match(e,_.userId)})).map((function(e){return e.url}));r.length>0&&i._addChannelsToView(r,t),a.length>0&&i._removeChannelsFromView(a,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),g.on((function(e){e instanceof Ha&&(e.stateType===Da.CONNECTED?i._isGetRemoteChannelsSucceeded||E(i,void 0,void 0,d().mark((function e(){return d().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===Da.LOGOUT&&i.dispose())}))}),[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(t,n){var r,a=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=s(t);try{for(l.s();!(r=l.n()).done;){var h=r.value,f=M_(this.channels,h);f>=0&&this.channels.splice(f,1);var p=O_(this.channels,h,this.order).place;if(f<0)p===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(p,0,h));else switch(n.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&p===this.channels.length?c.push(h):(this.channels.splice(p,0,h),u.push(h));break;default:this.channels.splice(p,0,h),u.push(h)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var v,_=s(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=M_(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}bp(n.source)&&_i((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsAdded)&&this._handler.onChannelsAdded(n,o),u.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,u),c.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,c.map((function(e){return e.url})));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,t){var n,r=this,a=[],i=s(e);try{var o=function(){var e=n.value,t=r.channels.findIndex((function(t){return t.url===e}));t>=0&&(a.push(r.channels[t].url),r.channels.splice(t,1))};for(i.s();!(n=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return bp(t.source)&&a.length>0&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(t,a);case 1:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_getLocalChannels",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Iv.of(this._iid),n=this.channels.length>0?A_(this.channels[this.channels.length-1],this.order):null,e.next=4,t.getChannelsFromCache(n,this.filter,this.order,this._limit,n?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,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Iv.of(this._iid),e.next=3,t.getMyGroupChannels(this._token,ve(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);case 3:return n=e.sent,r=n.channels,a=n.token,this._token=a,this._hasMore=!!a,e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:n=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(n,{source:e.CollectionEventSource.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()}}),t,this,[[2,10]])})))}},{key:"loadMore",value:function(){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(r=null,!this._includeChangesOnInitialLoad||0!==this.channels.length){n.next=9;break}if(!this._changelogSync.isRunning){n.next=9;break}return n.next=7,new Promise((function(e){C._changelogSyncSubscriberContext=C._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}));case 7:r=n.sent,null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close();case 9:if(a=ss.of(this._iid),i=a.cacheContext,o=a.connectionManager,u=a.statManager,this._isInitialized){n.next=16;break}if(this._isInitialized=!0,!i.localCacheEnabled){n.next=15;break}return n.next=15,this._backgroundSync.loadMetadata();case 15:u.put(new Yi({type:je.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}}));case 16:if(c=[],!this._hasMore){n.next=35;break}if(!i.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed){n.next=24;break}return n.next=21,mi((function(){return E(C,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:c=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 21:this._hasMore=c.length>=this._limit,n.next=34;break;case 24:return n.prev=24,n.next=27,this._getRemoteChannels();case 27:c=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=34;break;case 31:n.prev=31,n.t0=n.catch(24),this._isGetRemoteChannelsSucceeded=!1;case 34:this._addChannelsToView(c,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0);case 35:if(r){l=s(r.updatedChannels);try{for(l.s();!(h=l.n()).done;)f=h.value,(p=M_(c,f))>=0?c[p]=f:(v=O_(c,f,this.order),_=v.place,c.splice(_,0,f))}catch(e){l.e(e)}finally{l.f()}m=c.map((function(e){return e.url})),g=s(r.deletedChannelUrls);try{for(g.s();!(y=g.n()).done;)k=y.value,(b=m.indexOf(k))>=0&&(c.splice(b,1),m.splice(b,1))}catch(e){g.e(e)}finally{g.f()}}return n.abrupt("return",c);case 37:case"end":return n.stop()}}),n,this,[[24,31]])})))}},{key:"dispose",value:function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),Iv.of(this._iid).unsubscribeChannelEvent(this._key))}}])}(),R_=function(t){function a(t){var i;r(this,a);var s=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,d=t.channelNameContainsFilter,h=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,E=t.includeFrozen,k=t.includeMetaData;return(i=n(this,a)).method=_e.GET,i.path=ke,i.params=pe(ve({token:s,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:d,channel_urls:h,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:E,show_metadata:k})),i}return c(a,t),i(a)}(Ve),L_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new x_(e,t)}))),i.ts="number"==typeof u?u:0,i}return c(t,e),i(t)}(ze);e.MembershipFilter=void 0,(w_=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",w_.JOINED="joined";var P_,F_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;return r(this,a),(s=n(this,a,[t,i])).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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=i.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(d=i.customTypesFilter)&&void 0!==d?d:null,s.customTypeStartsWithFilter=null!==(h=i.customTypeStartsWithFilter)&&void 0!==h?h:null,s.channelNameContainsFilter=null!==(f=i.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=i.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=i.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=i.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=i.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=i.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=i.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(E=i.order)&&void 0!==E?E:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter,!0)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter,!0)&&R(e.MembershipFilter,this.membershipFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicGroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=ss.of(this._iid),r=n.requestQueue,a=new R_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(L_),o=s.channels,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(pu),q_=i((function e(){r(this,e),this.onUserMuted=ft,this.onUserUnmuted=ft,this.onUserBanned=ft,this.onUserUnbanned=ft,this.onChannelChanged=ft,this.onChannelDeleted=ft,this.onChannelFrozen=ft,this.onChannelUnfrozen=ft,this.onOperatorUpdated=ft,this.onChannelMemberCountChanged=ft,this.onMetaDataCreated=ft,this.onMetaDataUpdated=ft,this.onMetaDataDeleted=ft,this.onMetaCounterCreated=ft,this.onMetaCounterUpdated=ft,this.onMetaCounterDeleted=ft,this.onMessageReceived=ft,this.onMessageUpdated=ft,this.onMessageDeleted=ft,this.onMentionReceived=ft,this.onReactionUpdated=ft,this.onThreadInfoUpdated=ft})),H_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserJoined=ft,e.onUserLeft=ft,e.onUserReceivedInvitation=ft,e.onUserDeclinedInvitation=ft,e.onChannelHidden=ft,e.onUnreadMemberStatusUpdated=ft,e.onUndeliveredMemberStatusUpdated=ft,e.onTypingStatusUpdated=ft,e.onPollUpdated=ft,e.onPollVoted=ft,e.onPollDeleted=ft,e.onPinnedMessageUpdated=ft,e}return c(t,e),i(t)}(q_),G_=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(H_),j_=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,d=e.scheduledStatus;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ae),a.params=pe(ve({token:i,limit:s,reverse:u,channel_url:c,order:o,message_type:l,status:d})),a}return c(t,e),i(t)}(Ve),V_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).scheduledMessages=[];var s=a.next,o=a.scheduled_messages;return i.token=s,i.scheduledMessages=o.map((function(t){return go(e,t)})),i}return c(t,e),i(t)}(ze),z_=function(t){function a(t,i){var s,o,u,c,l,d;return r(this,a),(s=n(this,a,[t,i])).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(o=i.channelUrl)&&void 0!==o?o:null,s.order=null!==(u=i.order)&&void 0!==u?u:null,s.reverse=null!==(c=i.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=i.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(d=i.messageTypeFilter)&&void 0!==d?d:e.MessageTypeFilter.ALL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl,!0)&&(R(e.ScheduledMessageListOrder,this.order)||null===this.order)&&D("boolean",this.reverse)&&(P(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&R(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new j_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(V_),s=i.scheduledMessages,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),B_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="groupChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new Iv(e,{sdkState:r,cacheContext:c,dispatcher:a,sessionManager:i,requestQueue:s,logger:o})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new D_(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new vv(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new F_(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new z_(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){ui(D("string",e)&&t instanceof G_).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){ui(D("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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},lp),t),ui(D("string",e)&&dp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},lp),t),ui(D("number",e)&&dp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},hp),e),ui(fp(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},up),e),ui(cp(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.createChannel(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},up),e),ui(cp(n)).throw(A.invalidParameters),n&&(n.isDistinct=!0),t.abrupt("return",this.createChannel(n));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithUserIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=Object.assign(Object.assign({},up),{invitedUserIds:e,isDistinct:t,name:n,data:a,customType:i}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,s.abrupt("return",this.createChannel(o));case 3:case"end":return s.stop()}}),s,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:ui(P("string",e)).throw(A.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.next=3,this.getChannel(e);case 3:return n=t.sent,t.next=6,n.markAsDelivered();case 6:case"end":return t.stop()}}),t,this)})))}}])}(os),Q_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return c(t,e),i(t,[{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,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0: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)})),t.abrupt("return",n);case 3:case"end":return t.stop()}}),t)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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),K_={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},W_=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&(D("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&D("boolean",e.isEphemeral,!0)},Y_=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?we:Ce,"/").concat(encodeURIComponent(i)),a.params={show_pinned_messages:!0},a}return c(t,e),i(t)}(Ve),Z_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new hm(e,a),i}return c(t,e),i(t)}(ze),X_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,d=e.isEphemeral;return(a=n(this,t)).method=_e.POST,a.path=Ce,a.params=pe(ve({channel_url:i,cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:d})),a}return c(t,e),i(t)}(Ve),J_=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"ENTR",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(We),$_=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new li(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(Kp),em=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"EXIT",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(We),tm=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"EXIT",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new li(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(Kp),nm={},rm=function(t){function a(t,i){var o;return r(this,a),(o=n(this,a,[t,Object.assign(Object.assign({},i),{channelType:e.ChannelType.OPEN})])).subscribeChannelEvent=ft,o.unsubscribeChannelEvent=ft,o.refreshChannel=function(){return E(o,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}}),e)})))},o._openChannelCache=new Q_(t),o._openChannelHandlers=new Map,o._dispatcher.on((function(e){if(e instanceof Ke)o._handleEvent(e).catch((function(e){if(N(e)&&"foreground"===o._sdkState.appState)throw e}));else if(e instanceof Ha&&e.stateType===Da.CONNECTED){var t,n=s(o._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),nm[t]||(nm[t]=o),o}return c(a,t),i(a,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=oi(e);return new hm(this._iid,hm.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._openChannelCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((r=n.n()).done){t.next=9;break}return a=r.value,t.next=7,this._openChannelCache.remove(a);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),n.e(t.t0);case 14:return t.prev=14,n.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"handlers",get:function(){return v(this._openChannelHandlers.values())}},{key:"_handleEvent",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,A,M,O,U,D,R,L,P,F,q,H,G,j,V,z,B,Q,K,W,Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue,ce,le,de,he,fe,pe,ve,_e,me,ge,ye,Ee,ke,be,Ce,we,xe,Se,Te,Ie,Ne,Ae,Me,Oe,Ue,De,Re,Le,Pe,Fe,qe,He,Ge,je=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,n.t0=t.code,n.next="MESG"===n.t0||"FILE"===n.t0||"ADMM"===n.t0||"BRDM"===n.t0?4:"MEDI"===n.t0||"FEDI"===n.t0||"AEDI"===n.t0?14:"DELM"===n.t0?26:"MRCT"===n.t0?33:"MTHD"===n.t0?40:"MCNT"===n.t0?47:"PEDI"===n.t0?75:"VOTE"===n.t0?83:"SYEV"===n.t0?91:174;break;case 4:if(r=null,"MESG"===t.code?r=t.as(lc):"FILE"===t.code?r=t.as(Co):"ADMM"!==t.code&&"BRDM"!=t.code||(r=t.as(gv)),!r){n.next=13;break}if(i=(a=r).message,o=a.isMentioned,i.channelType!==e.ChannelType.OPEN){n.next=13;break}return n.next=11,this.getChannel(i.channelUrl,!0);case 11:u=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(u.url)&&(r.onMessageReceived&&r.onMessageReceived(u,i),o&&r.onMentionReceived&&r.onMentionReceived(u,i))}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return n.abrupt("break",174);case 14:if(c=null,"MEDI"===t.code?c=t.as(hc):"FEDI"===t.code?c=t.as(pc):"AEDI"===t.code&&(c=t.as(yv)),!c){n.next=25;break}if(h=(l=c).message,f=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){n.next=25;break}return n.next=21,this.getChannel(h.channelUrl,!0);case 21:p=n.sent,v=!1,p.lastPinnedMessage&&p.lastPinnedMessage.messageId===h.messageId&&p.lastPinnedMessage.updatedAt0&&i.onMentionReceived&&i.onMentionReceived(p,h))}catch(e){r.e(e)}finally{r.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 25:return n.abrupt("break",174);case 26:if(_=t.as(dt),m=_.channelUrl,g=_.channelType,y=_.messageId,g!==e.ChannelType.OPEN){n.next=32;break}return n.next=30,this.getChannel(m,!0);case 30:k=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(k.url)&&r.onMessageDeleted&&r.onMessageDeleted(k,y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 32:return n.abrupt("break",174);case 33:if(b=t.as(bv),C=b.channelUrl,w=b.channelType,x=b.event,w!==e.ChannelType.OPEN){n.next=39;break}return n.next=37,this.getChannel(C,!0);case 37:S=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(S.url)&&r.onReactionUpdated&&r.onReactionUpdated(S,x)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 39:return n.abrupt("break",174);case 40:if(T=t.as(Cv),(I=T.event).channelType!==e.ChannelType.OPEN){n.next=46;break}return n.next=44,this.getChannel(I.channelUrl,!0);case 44:A=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(A.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(A,I)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 46:return n.abrupt("break",174);case 47:M=t.as(wv),O=M.openChannelMemberCounts,U=[],D=s(O),n.prev=50,D.s();case 52:if((R=D.n()).done){n.next=61;break}return L=R.value,P=L.channelUrl,F=L.participantCount,q=L.updatedAt,n.next=57,this.getChannelFromCache(P);case 57:(H=n.sent)&&H._updateParticipantCount(F,q)&&U.push(H);case 59:n.next=52;break;case 61:n.next=66;break;case 63:n.prev=63,n.t1=n.catch(50),D.e(n.t1);case 66:return n.prev=66,D.f(),n.finish(66);case 69:if(!(U.length>0)){n.next=74;break}return n.next=72,this.upsertChannelsToCache(U);case 72:G=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(G)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 74:return n.abrupt("break",174);case 75:if(j=t.as(xv),V=j.event,z=j.status,B=j.channelUrl,Q=j.channelType,!B||Q!==e.ChannelType.OPEN){n.next=82;break}return n.next=79,this.getChannel(B,!0);case 79:K=n.sent,this._dispatcher.dispatch(new zs({event:V,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),_i(z===oo?function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(K,V.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(K,V)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 82:return n.abrupt("break",174);case 83:if(W=t.as(Fc),Y=W.event,Z=W.channelUrl,X=W.channelType,!Z||X!==e.ChannelType.OPEN){n.next=90;break}return n.next=87,this.getChannel(Z,!0);case 87:J=n.sent,this._dispatcher.dispatch(new Bs({event:Y,source:e.CollectionEventSource.EVENT_POLL_VOTED})),_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(J,Y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 90:return n.abrupt("break",174);case 91:if($=t.as(Kp),!(ee=$.event).isOpenChannelEvent){n.next=173;break}n.t2=ee.category,n.next=n.t2===rp.CHANNEL_ENTER?96:n.t2===rp.CHANNEL_EXIT?103:n.t2===rp.CHANNEL_OPERATOR_UPDATE?110:n.t2===rp.USER_CHANNEL_MUTE||n.t2===rp.USER_CHANNEL_UNMUTE?118:n.t2===rp.USER_CHANNEL_BAN||n.t2===rp.USER_CHANNEL_UNBAN?125:n.t2===rp.CHANNEL_FREEZE||n.t2===rp.CHANNEL_UNFREEZE?132:n.t2===rp.CHANNEL_DELETED?140:n.t2===rp.CHANNEL_PROP_CHANGED?147:n.t2===rp.CHANNEL_META_DATA_CHANGED?152:n.t2===rp.CHANNEL_META_COUNTERS_CHANGED?161:n.t2===rp.PINNED_MESSAGE_CHANGED?167:173;break;case 96:return n.next=98,this.getChannel(ee.channelUrl,!0);case 98:return te=n.sent,ne=t.as($_),re=ne.participantCount,ae=ne.user,ie=te._updateParticipantCount(re,ee.ts),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(te,ae),ie&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(te)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 103:return n.next=105,this.getChannel(ee.channelUrl,!0);case 105:return se=n.sent,oe=t.as(tm),ue=oe.participantCount,ce=oe.user,le=se._updateParticipantCount(ue,ee.ts),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(se,ce),le&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 110:return n.next=112,this.getChannel(ee.channelUrl,!0);case 112:return de=n.sent,he=t.as(fv),fe=he.operators,de.operators=fe,this.upsertChannelsToCache([de]),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(de,fe)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 118:return n.next=120,this.getChannel(ee.channelUrl,!0);case 120:return pe=n.sent,ve=ee.category===rp.USER_CHANNEL_MUTE,_e=t.as(ve?Xu:$u),me=_e.user,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ve?e.onUserMuted&&e.onUserMuted(pe,me):e.onUserUnmuted&&e.onUserUnmuted(pe,me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 125:return n.next=127,this.getChannel(ee.channelUrl,!0);case 127:return ge=n.sent,ye=ee.category===rp.USER_CHANNEL_BAN,Ee=t.as(ye?tc:rc),ke=Ee.user,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ye?e.onUserBanned&&e.onUserBanned(ge,ke):e.onUserUnbanned&&e.onUserUnbanned(ge,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 132:return n.next=134,this.getChannel(ee.channelUrl,!0);case 134:return be=n.sent,Ce=t.as(ic),we=Ce.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().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)})))})),n.abrupt("break",173);case 140:return n.next=142,this.getChannel(ee.channelUrl,!0);case 142:return xe=n.sent,n.next=145,this.removeChannelsFromCache([xe.url]);case 145:return _i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(xe.url,xe.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 147:return n.next=149,this.getChannelWithoutCache(ee.channelUrl,!0);case 149:return Se=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 152:return n.next=154,this.getChannel(ee.channelUrl,!0);case 154:return Te=n.sent,Ie=t.as(Lu),Ne=Ie.created,Ae=Ie.updated,Me=Ie.deleted,Ne&&Te._upsertCachedMetaData(Ne,ee.ts),Ae&&Te._upsertCachedMetaData(Ae,ee.ts),Me&&Te._removeFromCachedMetaData(Me,ee.ts),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ne&&e.onMetaDataCreated&&e.onMetaDataCreated(Te,Ne),Ae&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Te,Ae),Me&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Te,Me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 161:return n.next=163,this.getChannel(ee.channelUrl,!0);case 163:return Oe=n.sent,Ue=t.as(Ku),De=Ue.created,Re=Ue.updated,Le=Ue.deleted,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){De&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Oe,De),Re&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Oe,Re),Le&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Oe,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 167:return n.next=169,this.getChannel(ee.channelUrl,!0);case 169:return Pe=n.sent,Fe=t.as(_v),qe=Fe.pinnedMessageIds,He=Fe.latestPinnedMessage,(Ge=Fe.ts)>Pe._pinnedMessagesUpdatedAt&&(Pe.pinnedMessageIds=qe,Pe.lastPinnedMessage=He,Pe._pinnedMessagesUpdatedAt=Ge,this.upsertChannelsToCache([Pe]),_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Pe)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(Pe)}));case 1:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",173);case 173:return n.abrupt("break",174);case 174:n.next=180;break;case 176:if(n.prev=176,n.t3=n.catch(0),!N(n.t3)){n.next=180;break}throw n.t3;case 180:case"end":return n.stop()}}),n,this,[[0,176],[50,63,66,69]])})))}},{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){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),r=new Y_({channelUrl:e,isInternalCall:t}),n.next=4,this._requestQueue.send(r);case 4:return a=n.sent,i=a.as(Z_),s=i.channel,n.next=8,this.upsertChannelsToCache([s]);case 8:return n.abrupt("return",n.sent[0]);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},K_),e),ui(W_(n)).throw(A.invalidParameters),r=new X_(n),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Z_),s=i.channel,this.upsertChannelsToCache([s]),t.abrupt("return",s);case 9:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return nm[e]}}])}(mv),am={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},im=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)},sm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ce,"/").concat(encodeURIComponent(i),"/participants"),a.params={token:s,limit:o},a}return c(t,e),i(t)}(Ve),om=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).participants=[];var s=a.next,o=a.participants;return i.token=s,i.participants=o.map((function(t){return new zo(e,t)})),i}return c(t,e),i(t)}(ze),um=function(t){function a(t,i,s){return r(this,a),n(this,a,[t,i,e.ChannelType.OPEN,s])}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new sm(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(om),s=i.participants,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),cm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a.params=pe(ve({cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l})),a}return c(t,e),i(t)}(Ve),lm=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new hm(e,a),i}return c(t,e),i(t)}(ze),dm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(Ve),hm=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i]))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(o=i.participant_count)&&void 0!==o?o:0,s.operators=Array.isArray(i.operators)?i.operators.map((function(e){return new li(t,e)})):[],s.lastPinnedMessage=i.latest_pinned_message?go(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,s}return c(a,t),i(a,[{key:"serialize",value:function(){return si(this)}},{key:"isOperator",value:function(e){return e instanceof li?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 um(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=rm.of(this._iid),e.next=3,t.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new J_({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as($_),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),rm.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,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new em({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(tm),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),rm.of(this._iid).setExitedToCache(this),oh.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,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},am),e),ui(im(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new cm(Object.assign({channelUrl:this.url},n)),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(lm),u=o.channel,this._update(u),c=rm.of(this._iid),t.next=12,c.upsertChannelsToCache([u]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=Object.assign(Object.assign({},am),{name:e,coverUrlOrImage:t,data:n,operatorUserIds:r,customType:a}),i.abrupt("return",this.updateChannel(s));case 2:case"end":return i.stop()}}),i,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new dm({channelUrl:this.url}),e.next=4,n.send(r);case 4:return a=rm.of(this._iid),e.next=7,a.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"updateUserMessage",value:function(e,t){var n=this,r=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateUserMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&rm.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&rm.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFileMessage",value:function(e,t){var n=this,r=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateFileMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&rm.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&rm.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},kl.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return li.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?mo(e.lastPinnedMessage):null})))}}])}(kl),fm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserEntered=ft,e.onUserExited=ft,e.onChannelParticipantCountChanged=ft,e.onPollUpdated=ft,e.onPollVoted=ft,e.onPollDeleted=ft,e.onPinnedMessageUpdated=ft,e}return c(t,e),i(t)}(q_),pm=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(fm),vm=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,d=e.includeMetaData;return(a=n(this,t)).method=_e.GET,a.path=Ce,a.params=pe({token:i,limit:s,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:d,show_pinned_messages:!0}),a}return c(t,e),i(t)}(Ve),_m=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return new hm(e,t)}))),i.ts="number"==typeof u?u:null,i}return c(t,e),i(t)}(ze),mm=function(e){function t(e,a){var i,s,o,u,c,l;return r(this,t),(i=n(this,t,[e,a])).includeFrozen=!0,i.includeMetaData=!0,i.nameKeyword=null,i.urlKeyword=null,i.customTypes=null,i.includeFrozen=null===(s=a.includeFrozen)||void 0===s||s,i.includeMetaData=null===(o=a.includeMetaData)||void 0===o||o,i.nameKeyword=null!==(u=a.nameKeyword)&&void 0!==u?u:null,i.urlKeyword=null!==(c=a.urlKeyword)&&void 0!==c?c:null,i.customTypes=null!==(l=a.customTypes)&&void 0!==l?l:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.nameKeyword,!0)&&D("string",this.urlKeyword,!0)&&P("string",this.customTypes,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new vm(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(_m),s=i.channels,o=i.token,this._token=o,this._hasNext=!!o,u=rm.of(this._iid),e.next=15,u.upsertChannelsToCache(s);case 15:return this._isLoading=!1,e.abrupt("return",s);case 17:return e.abrupt("return",[]);case 20:throw A.queryInProgress;case 21:e.next=24;break;case 23:throw A.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}])}(pu),gm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="openChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new rm(e,{sdkState:r,dispatcher:a,requestQueue:s,logger:o,cacheContext:c,sessionManager:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new mm(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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return(s=Object.assign({},K_)).name=e,s.coverUrlOrImage=t,s.data=n,s.operatorUserIds=r,s.customType=a,i.abrupt("return",this._manager.createChannel(s));case 7:case"end":return i.stop()}}),i,this)})))}}])}(os),ym=Object.freeze({__proto__:null,xmlHttpRequest:function(e,t){return new Promise((function(n,r){if("undefined"!=typeof XMLHttpRequest){var a=ss.of(e),i=a.dispatcher,s=a.logger,o=t.requestId,u=t.method,c=t.url,l=t.headers,d=void 0===l?{}:l,h=t.data,f=void 0===h?"":h,p=t.uploadProgressHandler,v=!1,_=new XMLHttpRequest;_.open(u,c),Object.keys(d).forEach((function(e){_.setRequestHeader(e,d[e])})),p&&_.upload.addEventListener("progress",(function(e){e.lengthComputable?p(o,e.loaded,e.total):s.debug("Progress computing failed: `Content-Length` header is not given.")})),_.onabort=function(){r(A.requestCanceled)},_.onerror=function(e){r(A.networkError)},_.onreadystatechange=function(){if(_.readyState===XMLHttpRequest.DONE&&!v)if(0===_.status||_.status>=200&&_.status<400)try{var t=JSON.parse(_.responseText);n(new ze(e,t))}catch(s){r(A.networkError)}else try{var a=JSON.parse(_.responseText);if(a){var s=new A(a);if(s.isSessionExpiredError){if(i.dispatch(new Qe({reason:s.code,message:s.message})),!(_ instanceof Ye)){var o=new ut;return i.dispatch(new et({request:_,deferred:o,error:s})),o.promise}}else s.isSessionInvalidatedError&&i.dispatch(new Qe({reason:s.code,message:s.message}));r(s)}else r(A.requestFailed)}catch(s){r(A.requestFailed)}},i.on((function(e){e instanceof ct&&(e.requestId&&e.requestId!==o||(v=!0,_.abort()))})),_.send(f)}else r(A.xmlHttpRequestNotSupported)}))}});P_=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 Nm(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 Am(e){return"string"!=typeof e&&(e=String(e)),e}function Mm(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return Cm&&(t[Symbol.iterator]=function(){return t}),t}function Om(e){this.map={},e instanceof Om?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 Um(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function Dm(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Rm(e){var t=new FileReader,n=Dm(t);return t.readAsArrayBuffer(e),n}function Lm(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Pm(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:wm&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:xm&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:bm&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():Sm&&wm&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Lm(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Sm&&(ArrayBuffer.prototype.isPrototypeOf(e)||Im(e))?this._bodyArrayBuffer=Lm(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):bm&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},wm&&(this.blob=function(){var e=Um(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=Um(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(wm)return this.blob().then(Rm);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,n,r,a,i=Um(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Dm(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),a=r?r[1]:"utf-8",t.readAsText(e,a),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||function(){if("AbortController"in km)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 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 Hm(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 Gm(e,t){if(!(this instanceof Gm))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 Om(t.headers),this.url=t.url||"",this._initBody(e)}qm.prototype.clone=function(){return new qm(this,{body:this._bodyInit})},Pm.call(qm.prototype),Pm.call(Gm.prototype),Gm.prototype.clone=function(){return new Gm(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Om(this.headers),url:this.url})},Gm.error=function(){var e=new Gm(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var jm=[301,302,303,307,308];Gm.redirect=function(e,t){if(-1===jm.indexOf(t))throw new RangeError("Invalid status code");return new Gm(null,{status:t,headers:{location:e}})};var Vm=km.DOMException;try{new Vm}catch(On){(Vm=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),Vm.prototype.constructor=Vm}function zm(e,t){return new Promise((function(n,r){var a=new qm(e,t);if(a.signal&&a.signal.aborted)return r(new Vm("Aborted","AbortError"));var i=new XMLHttpRequest;function s(){i.abort()}if(i.onload=function(){var e,t,r={statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new Om,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();try{t.append(r,a)}catch(e){console.warn("Response "+e.message)}}})),t)};0===a.url.indexOf("file://")&&(i.status<200||i.status>599)?r.status=200:r.status=i.status,r.url="responseURL"in i?i.responseURL:r.headers.get("X-Request-URL");var s="response"in i?i.response:i.responseText;setTimeout((function(){n(new Gm(s,r))}),0)},i.onerror=function(){setTimeout((function(){r(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){r(new TypeError("Network request timed out"))}),0)},i.onabort=function(){setTimeout((function(){r(new Vm("Aborted","AbortError"))}),0)},i.open(a.method,function(e){try{return""===e&&km.location.href?km.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?i.withCredentials=!0:"omit"===a.credentials&&(i.withCredentials=!1),"responseType"in i&&(wm?i.responseType="blob":Sm&&(i.responseType="arraybuffer")),t&&"object"===m(t.headers)&&!(t.headers instanceof Om||km.Headers&&t.headers instanceof km.Headers)){var o=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){o.push(Nm(e)),i.setRequestHeader(e,Am(t.headers[e]))})),a.headers.forEach((function(e,t){-1===o.indexOf(t)&&i.setRequestHeader(t,e)}))}else a.headers.forEach((function(e,t){i.setRequestHeader(t,e)}));a.signal&&(a.signal.addEventListener("abort",s),i.onreadystatechange=function(){4===i.readyState&&a.signal.removeEventListener("abort",s)}),i.send(void 0===a._bodyInit?null:a._bodyInit)}))}zm.polyfill=!0,km.fetch||(km.fetch=zm,km.Headers=Om,km.Request=qm,km.Response=Gm);var Bm="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null};Bm.fetch||(Bm.fetch=zm);var Qm=Object.freeze({__proto__:null});e.AdminMessage=ao,e.AppInfo=Ja,e.AppleCriticalAlertOptions=ms,e.ApplicationUserListQuery=Al,e.BannedUserListQuery=xu,e.BaseChannel=kl,e.BaseMessage=eo,e.BlockedUserListQuery=Ul,e.CachedChannelInfo=K,e.ConnectionHandler=xl,e.DeliveryStatus=np,e.Emoji=bl,e.EmojiCategory=Cl,e.EmojiContainer=wl,e.Feedback=ys,e.FileMessage=yo,e.FriendListQuery=Ll,e.GroupChannel=x_,e.GroupChannelCollection=D_,e.GroupChannelEventSource=kp,e.GroupChannelFilter=ap,e.GroupChannelHandler=G_,e.GroupChannelListQuery=vv,e.GroupChannelModule=B_,e.LocalCacheConfig=W,e.Member=tp,e.MemberListQuery=e_,e.MemoryStore=Md,e.MessageCollection=Kv,e.MessageCollectionInitHandler=Bv,e.MessageEventSource=Ls,e.MessageFilter=jd,e.MessageForm=Zs,e.MessageFormItem=Xs,e.MessageMetaArray=ks,e.MessageModule=wh,e.MessageRequestHandler=Bo,e.MessageReviewInfo=fo,e.MessageSearchQuery=_h,e.MultipleFilesMessage=vo,e.MultipleFilesMessageRequestHandler=fl,e.MutedUserListQuery=bu,e.NotificationInfo=za,e.OGImage=vs,e.OGMetaData=_s,e.OpenChannel=hm,e.OpenChannelHandler=pm,e.OpenChannelListQuery=mm,e.OpenChannelModule=gm,e.OperatorListQuery=gu,e.Participant=zo,e.ParticipantListQuery=um,e.PinnedMessage=pl,e.PinnedMessageListQuery=ml,e.Plugin=io,e.PreviousMessageListQuery=yu,e.PublicGroupChannelListQuery=F_,e.Reaction=ps,e.ReactionEvent=fs,e.ReadStatus=ws,e.RestrictedUser=Vo,e.RestrictionInfo=jo,e.ScheduledMessageListQuery=z_,e.SendbirdChat=Qf,e.SendbirdChatOptions=j,e.SendbirdError=A,e.Sender=Es,e.SessionHandler=Sl,e.ThreadInfo=ds,e.ThreadInfoUpdateEvent=uh,e.ThreadedParentMessageListQuery=yh,e.Thumbnail=us,e.UIKitConfigInfo=Qa,e.UploadedFileInfo=Qs,e.User=li,e.UserEventHandler=Tl,e.UserMessage=po,Object.defineProperty(e,"__esModule",{value:!0})})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Sendbird={})}(this,(function(e){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=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 i,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw i}}}}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(r){var a=Object.getOwnPropertyDescriptor(r,t);return a.get?a.get.call(arguments.length<3?e:n):a.value}},o.apply(null,arguments)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function d(){d=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",u=i.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 i=t&&t.prototype instanceof g?t:g,s=Object.create(i.prototype),o=new M(r||[]);return a(s,"_invoke",{value:T(e,n,o)}),s}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var f="suspendedStart",p="suspendedYield",v="executing",_="completed",m={};function g(){}function y(){}function E(){}var k={};c(k,s,(function(){return this}));var b=Object.getPrototypeOf,C=b&&b(b(O([])));C&&C!==n&&r.call(C,s)&&(k=C);var w=E.prototype=g.prototype=Object.create(k);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(a,i,s,o){var u=h(e[a],e,i);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,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var i;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return i=i?i.then(a,a):a()}})}function T(t,n,r){var a=f;return function(i,s){if(a===v)throw Error("Generator is already running");if(a===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var o=r.delegate;if(o){var u=I(o,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===f)throw a=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=v;var c=h(t,n,r);if("normal"===c.type){if(a=r.done?_:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(a=_,r.method="throw",r.arg=c.arg)}}}function I(t,n){var r=n.method,a=t.iterator[r];if(a===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,I(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=h(a,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function N(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 A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function M(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(N,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function n(){for(;++a=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(u&&c){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),A(n),m}},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;A(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:O(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),m}},t}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,s,o=[],u=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(o.push(r.value),o.length!==t);u=!0);}catch(e){c=!0,a=e}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw a}}return o}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t,n,r){var a=o(u(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof a?function(e){return a.apply(n,e)}:a}function v(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){var t=function(e,t){if("object"!=typeof e||!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:t+""}function m(e){return m="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},m(e)}function g(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function y(e){var t="function"==typeof Map?new Map:void 0;return y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(l())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var a=new(e.bind.apply(e,r));return n&&h(a,n.prototype),a}(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)},y(e)}function E(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var k,b="4.14.6",C=function(){function e(){r(this,e)}return i(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return b}},{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.SendbirdErrorCode=void 0,(k=e.SendbirdErrorCode||(e.SendbirdErrorCode={}))[k.NON_AUTHORIZED=400108]="NON_AUTHORIZED",k[k.INVALID_TOKEN=400111]="INVALID_TOKEN",k[k.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",k[k.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",k[k.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",k[k.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",k[k.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",k[k.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",k[k.SESSION_REVOKED=400310]="SESSION_REVOKED",k[k.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",k[k.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",k[k.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",k[k.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",k[k.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",k[k.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",k[k.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",k[k.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",k[k.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",k[k.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",k[k.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",k[k.LOST_INSTANCE=700100]="LOST_INSTANCE",k[k.CONNECTION_RENEW=700102]="CONNECTION_RENEW",k[k.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",k[k.INVALID_COMMAND=700700]="INVALID_COMMAND",k[k.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",k[k.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",k[k.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",k[k.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",k[k.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",k[k.INVALID_PARAMETER=800110]="INVALID_PARAMETER",k[k.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",k[k.NETWORK_ERROR=800120]="NETWORK_ERROR",k[k.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",k[k.MALFORMED_DATA=800130]="MALFORMED_DATA",k[k.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",k[k.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",k[k.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",k[k.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",k[k.ACK_TIMEOUT=800180]="ACK_TIMEOUT",k[k.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",k[k.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",k[k.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",k[k.REQUEST_FAILED=800220]="REQUEST_FAILED",k[k.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",k[k.REQUEST_CANCELED=800240]="REQUEST_CANCELED",k[k.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",k[k.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",k[k.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED",k[k.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",k[k.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",k[k.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",k[k.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",k[k.DATABASE_ERROR=800700]="DATABASE_ERROR",k[k.USER_DEACTIVATED=900021]="USER_DEACTIVATED",k[k.CHANNEL_IS_FROZEN=900050]="CHANNEL_IS_FROZEN",k[k.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";var w,x,S,T,I,N=function(e){return!(e instanceof A&&!e.shouldThrowOutside)},A=function(t){function a(e){var t,i=e.code,s=void 0===i?0:i,o=e.message,u=void 0===o?"":o;return r(this,a),(t=n(this,a,[u])).shouldThrowOutside=!1,t._detail="",t.name="SendbirdError",t.code=s,Object.setPrototypeOf(t,a.prototype),t}return c(a,t),i(a,[{key:"detail",get:function(){return this._detail}},{key:"setDetail",value:function(e){this._detail=e}},{key:"isInvalidTokenError",get:function(){return this.code===e.SendbirdErrorCode.INVALID_TOKEN}},{key:"isSessionExpiredError",get:function(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}},{key:"isSessionTokenExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_KEY_EXPIRED}},{key:"isSessionInvalidatedError",get:function(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}},{key:"isSessionRevokedError",get:function(){return this.code===e.SendbirdErrorCode.SESSION_REVOKED}},{key:"isUserAuthDeactivedError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DEACTIVATED}},{key:"isUserAuthDeletedOrNotFoundError",get:function(){return this.code===e.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}},{key:"isNetworkError",get:function(){return this.code===e.SendbirdErrorCode.NETWORK_ERROR||this.code===e.SendbirdErrorCode.NETWORK_ROUTING_ERROR}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new a({code:e.SendbirdErrorCode.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new a({code:e.SendbirdErrorCode.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"invalidCommand",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new a({code:e.SendbirdErrorCode.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{key:"connectionRenew",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"xmlHttpRequestNotSupported",get:function(){return new a({code:e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}},{key:"connectionRequired",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new a({code:e.SendbirdErrorCode.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new a({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"channelTypeNotSupportedError",get:function(){return new a({code:e.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}},{key:"networkError",get:function(){return new a({code:e.SendbirdErrorCode.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new a({code:e.SendbirdErrorCode.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new a({code:e.SendbirdErrorCode.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new a({code:e.SendbirdErrorCode.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new a({code:e.SendbirdErrorCode.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new a({code:e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Request failed."})}},{key:"tooManyRequests",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}},{key:"alreadyConnectedAsAnotherUser",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}},{key:"fileUploadCanceled",get:function(){return new a({code:e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new a({code:e.SendbirdErrorCode.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new a({code:e.SendbirdErrorCode.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new a({code:e.SendbirdErrorCode.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}},{key:"statLogUploadLimitExceededError",get:function(){return new a({code:e.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}},{key:"malformedDataError",get:function(){return new a({code:e.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}}])}(y(Error)),M=[e.SendbirdErrorCode.CONNECTION_REQUIRED,e.SendbirdErrorCode.NETWORK_ERROR,e.SendbirdErrorCode.ACK_TIMEOUT,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,e.SendbirdErrorCode.REQUEST_CANCELED,e.SendbirdErrorCode.INTERNAL_SERVER_ERROR,e.SendbirdErrorCode.RATE_LIMIT_EXCEEDED,e.SendbirdErrorCode.UNKNOWN_SERVER_ERROR,e.SendbirdErrorCode.USER_DEACTIVATED,e.SendbirdErrorCode.CHANNEL_IS_FROZEN,e.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],O=[e.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,e.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,e.SendbirdErrorCode.CONNECTION_REQUIRED,e.SendbirdErrorCode.CHANNEL_IS_FROZEN],U=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},D=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||("string"!=typeof e?"object"===m(e)?R(e,t):L(e,t):m(t)===e)},R=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Object.values(e).includes(t)},L=function(e,t){return t instanceof e},P=function(e,t){return!!(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&G(t))||Array.isArray(t)&&t.every((function(t){return D(e,t)}))},F=function(e){return!!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))||"number"==typeof e&&13===e.toString().length},q=function(e){return e>0&&O.indexOf(e)>=0},H=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(e))return!0;var t="object"===m(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},G=function(e){return null==e},j=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,i=t.typingIndicatorInvalidateTime,s=void 0===i?1e4:i,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,d=t.websocketPayloadDecompression,h=void 0===d||d,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=s,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=h}),[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){D("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){D("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){D("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){D("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){D("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}])}(),V={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){return i((function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}),[{key:"_savePreferenceKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:v(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._version=n,this._keysAddress=e,a="".concat(e,".metadata.version"),r.next=5,this._store.get(a);case 5:return i=r.sent,r.next=8,this._store.get(e);case 8:if(r.t1=t=r.sent,r.t0=null!==r.t1,!r.t0){r.next=12;break}r.t0=void 0!==t;case 12:if(!r.t0){r.next=16;break}r.t2=t,r.next=17;break;case 16:r.t2=[];case 17:if(o=r.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},a=n.maxSize,i=void 0===a?256:a,s=n.clearOrder,o=void 0===s?e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT:s,u=n.customClearOrderComparator,c=n.enableAutoResend,l=void 0===c||c;r(this,t),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(i,64),u?(this._clearOrder=o,this._customClearOrderComparator=u):this._clearOrder=e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=l}),[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var t;return this._clearOrder===e.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(t=this._customClearOrderComparator)&&void 0!==t?t:this._clearOrderComparatorUseMessageCollectionAccessedAt}},{key:"enableAutoResend",get:function(){return this._enableAutoResend}}])}();!function(e){e.FEED="feed",e.CHAT="chat",e.CHAT_API="chat_api"}(Q||(Q={}));var Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue=function(){return i((function e(){r(this,e),this.isRefreshing=!1}),[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"hasChatServicePermission",get:function(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(Q.CHAT))}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}])}(),ce=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)}))},le=function(){return i((function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=ce()}),[{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=this;Object.keys(this._container).forEach((function(t){var n;null===(n=e._container[t])||void 0===n||n.delete(e.key)}))}}])}(),de=function(){return i((function e(){r(this,e),this._container={}}),[{key:"on",value:function(e,t){return new le({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new le({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],i=s(n.keys());try{for(i.s();!(r=i.n()).done;){var o=r.value,u=n.get(o);u.handler(t),u.occurence>0&&(u.occurence--,0===u.occurence&&a.push(o))}}catch(e){i.e(e)}finally{i.f()}a.forEach((function(e){return n.delete(e)}))}}}])}(),he=function(){return i((function e(){r(this,e),this._dispatcher=new de}),[{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)}}])}(),fe=i((function e(){r(this,e)})),pe=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},ve=function(e){if(null!=e){if("object"===m(e)){if(Array.isArray(e)){for(var t=v(e),n=0;n3&&void 0!==arguments[3]?arguments[3]:"";return r(this,t),(s=n(this,t))._iid=e,s.code=a,s.payload=i,s.requestId=null!==(o=i.req_id)&&void 0!==o?o:u,s}return c(t,e),i(t,[{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,n){var r=n.substring(0,4),a={};try{a=JSON.parse(n.substring(4))}catch(e){r="NOOP"}finally{return new t(e,r,a)}}}])}(fe),We=function(e){function t(e){var a,i,s=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?{}:u;return r(this,t),(a=n(this,t)).code=s,a.payload=c,a.requestId=null!==(i=a.payload.req_id)&&void 0!==i?i:ce(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return c(t,e),i(t,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}])}(fe),Ye=function(e){function t(e){var a,i=e.userId,s=e.authToken,o=e.services,u=e.expiringSession,c=void 0===u||u;return r(this,t),(a=n(this,t)).path="".concat(ge,"/").concat(i,"/session_key"),a.method=_e.POST,a.params=pe({token:s,services:o,expiring_session:!!c}),a.requireAuth=!1,a}return c(t,e),i(t)}(Ve),Ze=function(e){function t(e){var a=e.authToken,i=e.expiringSession,s=void 0===i||i,o=e.requestId,u=void 0===o?void 0:o;return r(this,t),n(this,t,[{code:"LOGI",payload:pe({token:a,expiring_session:s?1:0,req_id:u}),ackRequired:!0}])}return c(t,e),i(t)}(We),Xe=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.key,o=a.expires_at,u=a.services;return i.key=s,i.expiresAt=o,i.services=u,i}return c(t,e),i(t)}(ze),Je=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"LOGI",i])).error=null,s.newKey=null,s.newKey=null!==(o=i.new_key)&&void 0!==o?o:null,s.error=i.error?new A(i):null,s}return c(t,e),i(t)}(Ke),$e=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).statLog=e,a}return c(t,e),i(t)}(fe),et=function(e){function t(e){var a,i=e.request,s=e.deferred,o=e.error,u=void 0===o?A.requestFailed:o;return r(this,t),(a=n(this,t)).request=i,a.deferred=s,a.error=u,a}return c(t,e),i(t)}(fe);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",e.NOTIFICATION="noti:stats",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(je||(je={}));var tt,nt,rt,at=function(){return i((function e(t){var n=t.type,a=t.data,i=t.ts,s=void 0===i?Date.now():i;r(this,e),this.type=n,this.createdAt=s,this.data=a}),null,[{key:"payloadify",value:function(e){return pe({stat_type:e.type,ts:e.createdAt,data:pe(e.data)})}}])}(),it=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},st=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};e.SendbirdProduct=void 0,(tt=e.SendbirdProduct||(e.SendbirdProduct={})).CHAT="chat",tt.CALLS="calls",tt.DESK="desk",tt.LIVE="live",tt.UIKIT_CHAT="uikit-chat",tt.UIKIT_LIVE="uikit-live",e.SendbirdPlatform=void 0,(nt=e.SendbirdPlatform||(e.SendbirdPlatform={})).ANDROID="android",nt.IOS="ios",nt.JS="js",nt.UNREAL="unreal",nt.UNITY="unity",nt.REACT_NATIVE="react-native",nt.FLUTTER="flutter",e.DeviceOsPlatform=void 0,(rt=e.DeviceOsPlatform||(e.DeviceOsPlatform={})).ANDROID="android",rt.IOS="ios",rt.WEB="web",rt.MOBILE_WEB="mobile_web",rt.WINDOWS="windows";var ot=i((function e(){r(this,e)}));ot.sendbirdSdkUserAgentWithExtension=function(t){var n=it()?e.SendbirdPlatform.REACT_NATIVE:e.SendbirdPlatform.JS,r={main_sdk_info:"chat/".concat(n,"/").concat(C.SDK_VERSION),device_os_platform:st()?"mobile-web":"web",os_version:C.OS_VERSION};if(t){var a=t.sendbirdExtensions,i=t.deviceOS,s=t.customData,o=void 0===s?{}:s;i.version&&(r.os_version=i.version),i.platform&&(r.device_os_platform=i.platform),a.length>0&&(r.extension_sdk_info=a.map((function(e){var t=e.product,n=e.platform,r=e.version;return"".concat(t,"/").concat(n,"/").concat(r)})).join(",")),Object.keys(r).forEach((function(e){return delete o[e]})),Object.keys(o).length>0&&(r=Object.assign(Object.assign({},r),o))}return Object.entries(r).map((function(e){var t=f(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join("&")},ot.userAgentWithExtension=function(e){var t=it()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):st()?"omobile-web":"oweb";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)};var ut=i((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=function(e){n(e)}}))})),ct=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).requestId=e.requestId,a}return c(t,e),i(t)}(fe),lt=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),e.messageToken&&(a.params=pe({mesg_token:e.messageToken})),a}return c(t,e),i(t)}(Ve),dt=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"DELM",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s.silent=i.silent,s.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,s.senderId=null!==(o=i.sender_id)&&void 0!==o?o:void 0,s}return c(t,e),i(t)}(Ke),ht=function(){return i((function e(t,n){var a=this,i=n.session,s=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._session=i,this._sdkState=s,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof Be&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}),[{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,i=n.sendbirdRuntimeEnvironment,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":ot.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":ot.sendbirdSdkUserAgentWithExtension(i)});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(s["Session-Key"]=this._session.sessionKey),s["App-Id"]=r,this._session&&this._session.authToken&&(s["Access-Token"]=this._session.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){e.path.includes("/sdk/statistics")||this._dispatcher.dispatch(new $e(new at({type:je.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:"_isBodyRequired",value:function(e){var t=e.method;return t!==_e.GET&&(t!==_e.DELETE||e instanceof lt)}},{key:"send",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=t.path,a=t.method,i=t.uploadProgressHandler,s=this._isBodyRequired(t),o=this._sdkState.api,u="".concat(o.host).concat(r).concat(s?"":t.query),c=s?t.payload:null,l=this._createHeader(t,c instanceof FormData?c:void 0),h=new AbortController,f=h.signal,this._abortControl.set(t.requestId,h),p=Date.now(),n.prev=10,!i){n.next=32;break}return n.next=14,Promise.resolve().then((function(){return ym}));case 14:return v=n.sent,_=v.xmlHttpRequest,n.prev=16,n.next=19,_(this._iid,{requestId:t.requestId,method:t.method,url:u,headers:l,data:null!=c?c:void 0,uploadProgressHandler:i});case 19:return m=n.sent,this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",m);case 25:if(n.prev=25,n.t0=n.catch(16),!(n.t0 instanceof A&&n.t0.code===e.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED)){n.next=31;break}this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),n.next=32;break;case 31:throw n.t0;case 32: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){n.next=36;break}return n.next=36,Promise.resolve().then((function(){return Em}));case 36:if("function"==typeof fetch){n.next=39;break}return n.next=39,Promise.resolve().then((function(){return Qm}));case 39:return n.next=41,fetch(u,{method:a,body:c,headers:l,signal:f});case 41:return g=n.sent,n.next=44,g.json();case 44:if(y=n.sent,!g.ok&&!g.redirected){n.next=51;break}return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,p),n.abrupt("return",new ze(this._iid,y));case 51:if(!y){n.next=70;break}if(!(E=new A(y)).isSessionExpiredError){n.next=62;break}if(this._dispatcher.dispatch(new Qe({reason:E.code,message:E.message})),t instanceof Ye){n.next=59;break}return k=new ut,this._dispatcher.dispatch(new et({request:t,deferred:k,error:E})),n.abrupt("return",k.promise);case 59:case 67:throw E;case 62:if(!E.isSessionInvalidatedError){n.next=67;break}throw this._dispatcher.dispatch(new Qe({reason:E.code,message:E.message})),E;case 68:n.next=71;break;case 70:throw A.requestFailed;case 71:n.next=87;break;case 73:if(n.prev=73,n.t1=n.catch(10),this._statLogApiResult(t,p,n.t1),!(n.t1 instanceof A)){n.next=81;break}throw this._logger.debug("fail api request",n.t1),n.t1;case 81:if("AbortError"!==(null===n.t1||void 0===n.t1?void 0:n.t1.name)){n.next=85;break}throw A.requestCanceled;case 85:throw this._logger.debug("fail api request",n.t1),A.networkError;case 87:case"end":return n.stop()}}),n,this,[[10,73],[16,25]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e));this._dispatcher.dispatch(new ct({requestId:e}))}},{key:"cancelAll",value:function(){var e,t=s(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(),this._dispatcher.dispatch(new ct({}))}}])}(),ft=function(){};function pt(e){let t=e.length;for(;--t>=0;)e[t]=0}const vt=256,_t=286,mt=30,gt=15,yt=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]),Et=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]),kt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),bt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ct=new Array(576);pt(Ct);const wt=new Array(60);pt(wt);const xt=new Array(512);pt(xt);const St=new Array(256);pt(St);const Tt=new Array(29);pt(Tt);const It=new Array(mt);function Nt(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let At,Mt,Ot;function Ut(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}pt(It);const Dt=e=>e<256?xt[e]:xt[256+(e>>>7)],Rt=(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])},Ft=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},qt=(e,t,n)=>{const r=new Array(16);let a,i,s=0;for(a=1;a<=gt;a++)s=s+n[a-1]<<1,r[a]=s;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=Ft(r[t]++,t))}},Ht=e=>{let t;for(t=0;t<_t;t++)e.dyn_ltree[2*t]=0;for(t=0;t{e.bi_valid>8?Rt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},jt=(e,t,n,r)=>{const a=2*t,i=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,i,s,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?Pt(e,a,t):(i=St[a],Pt(e,i+vt+1,t),s=yt[i],0!==s&&(a-=Tt[i],Lt(e,a,s)),r--,i=Dt(r),Pt(e,i,n),s=Et[i],0!==s&&(r-=It[i],Lt(e,r,s)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,i=t.stat_desc.elems;let s,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)Vt(e,n,s);u=i;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Vt(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,n[2*u]=n[2*s]+n[2*o],e.depth[u]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,n[2*s+1]=n[2*o+1]=u,e.heap[1]=u++,Vt(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,i=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,d,h,f,p,v=0;for(h=0;h<=gt;h++)e.bl_count[h]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],h=n[2*n[2*l+1]+1]+1,h>u&&(h=u,v++),n[2*l+1]=h,l>r||(e.bl_count[h]++,f=0,l>=o&&(f=s[l-o]),p=n[2*l],e.opt_len+=p*(h+f),i&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(h=u-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(h=u;0!==h;h--)for(l=e.bl_count[h];0!==l;)d=e.heap[--c],d>r||(n[2*d+1]!==h&&(e.opt_len+=(h-n[2*d+1])*n[2*d],n[2*d+1]=h),l--)}})(e,t),qt(n,c,e.bl_count)},Qt=(e,t,n)=>{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=s,s=t[2*(r+1)+1],++o{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),r=0;r<=n;r++)if(a=s,s=t[2*(r+1)+1],!(++o{Lt(e,0+(r?1:0),3),Gt(e),Rt(e,n),Rt(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Zt=(e,t,n,r)=>{let a,i,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(Qt(e,e.dyn_ltree,e.l_desc.max_code),Qt(e,e.dyn_dtree,e.d_desc.max_code),Bt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*bt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=a&&(a=i)):a=i=n+5,n+4<=a&&-1!==t?Yt(e,t,n,r):4===e.strategy||i===a?(Lt(e,2+(r?1:0),3),zt(e,Ct,wt)):(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{Wt||((()=>{let e,t,n,r,a;const i=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*(St[n]+vt+1)]++,e.dyn_dtree[2*Dt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Lt(e,2,3),Pt(e,256,Ct),(e=>{16===e.bi_valid?(Rt(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 Jt=(e,t,n,r)=>{let a=65535&e,i=e>>>16&65535,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{a=a+t[r++]|0,i=i+a|0}while(--s);a%=65521,i%=65521}return a|i<<16};const $t=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 en=(e,t,n,r)=>{const a=$t,i=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return~e},tn={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"},nn={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:rn,_tr_stored_block:an,_tr_flush_block:sn,_tr_tally:on,_tr_align:un}=Xt,{Z_NO_FLUSH:cn,Z_PARTIAL_FLUSH:ln,Z_FULL_FLUSH:dn,Z_FINISH:hn,Z_BLOCK:fn,Z_OK:pn,Z_STREAM_END:vn,Z_STREAM_ERROR:_n,Z_DATA_ERROR:mn,Z_BUF_ERROR:gn,Z_DEFAULT_COMPRESSION:yn,Z_FILTERED:En,Z_HUFFMAN_ONLY:kn,Z_RLE:bn,Z_FIXED:Cn,Z_DEFAULT_STRATEGY:wn,Z_UNKNOWN:xn,Z_DEFLATED:Sn}=nn,Tn=258,In=262,Nn=42,An=113,Mn=666,On=(e,t)=>(e.msg=tn[t],t),Un=e=>2*e-(e>4?9:0),Dn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Rn=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))},Fn=(e,t)=>{sn(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Pn(e.strm)},qn=(e,t)=>{e.pending_buf[e.pending++]=t},Hn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Gn=(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=Jt(e.adler,t,a,n):2===e.state.wrap&&(e.adler=en(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},jn=(e,t)=>{let n,r,a=e.max_chain_length,i=e.strstart,s=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-In?e.strstart-(e.w_size-In):0,c=e.window,l=e.w_mask,d=e.prev,h=e.strstart+Tn;let f=c[i+s-1],p=c[i+s];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+s]===p&&c[n+s-1]===f&&c[n]===c[i]&&c[++n]===c[i+1]){i+=2,n++;do{}while(c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&is){if(e.match_start=t,s=r,r>=o)break;f=c[i+s-1],p=c[i+s]}}}while((t=d[t&l])>u&&0!=--a);return s<=e.lookahead?s:e.lookahead},Vn=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-In)&&(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),Rn(e),r+=t),0===e.strm.avail_in)break;if(n=Gn(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,i=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=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,Pn(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&&(Gn(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 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&&(Gn(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,i=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=i||(r||t===hn)&&t!==cn&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,s=t===hn&&0===e.strm.avail_in&&n===r?1:0,an(e,e.block_start,n,s),e.block_start+=n,Pn(e.strm)),s?3:1)},Bn=(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-In&&(e.match_length=jn(e,n)),e.match_length>=3)if(r=on(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=on(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2},Qn=(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=on(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&&(Fn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=on(e,0,e.window[e.strstart-1]),r&&Fn(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=on(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2};function Kn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const Wn=[new Kn(0,0,0,0,zn),new Kn(4,4,8,4,Bn),new Kn(4,5,16,8,Bn),new Kn(4,6,32,32,Bn),new Kn(4,4,16,16,Qn),new Kn(8,16,32,32,Qn),new Kn(8,16,128,128,Qn),new Kn(8,32,128,256,Qn),new Kn(32,128,258,1024,Qn),new Kn(32,258,258,4096,Qn)];function Yn(){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=Sn,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),Dn(this.dyn_ltree),Dn(this.dyn_dtree),Dn(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),Dn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Dn(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 Zn=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!==An&&t.status!==Mn?1:0},Xn=e=>{if(Zn(e))return On(e,_n);e.total_in=e.total_out=0,e.data_type=xn;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:An,e.adler=2===t.wrap?0:1,t.last_flush=-2,rn(t),pn},Jn=e=>{const t=Xn(e);var n;return t===pn&&((n=e.state).window_size=2*n.w_size,Dn(n.head),n.max_lazy_match=Wn[n.level].max_lazy,n.good_match=Wn[n.level].good_length,n.nice_match=Wn[n.level].nice_length,n.max_chain_length=Wn[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},$n=(e,t,n,r,a,i)=>{if(!e)return _n;let s=1;if(t===yn&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),a<1||a>9||n!==Sn||r<8||r>15||t<0||t>9||i<0||i>Cn||8===r&&1!==s)return On(e,_n);8===r&&(r=9);const o=new Yn;return e.state=o,o.strm=e,o.status=Nn,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<$n(e,t,Sn,15,8,wn),deflateInit2:$n,deflateReset:Jn,deflateResetKeep:Xn,deflateSetHeader:(e,t)=>Zn(e)||2!==e.state.wrap?_n:(e.state.gzhead=t,pn),deflate:(e,t)=>{if(Zn(e)||t>fn||t<0)return e?On(e,_n):_n;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Mn&&t!==hn)return On(e,0===e.avail_out?gn:_n);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Pn(e),0===e.avail_out)return n.last_flush=-1,pn}else if(0===e.avail_in&&Un(t)<=Un(r)&&t!==hn)return On(e,gn);if(n.status===Mn&&0!==e.avail_in)return On(e,gn);if(n.status===Nn&&0===n.wrap&&(n.status=An),n.status===Nn){let t=Sn+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=kn||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,Hn(n,t),0!==n.strstart&&(Hn(n,e.adler>>>16),Hn(n,65535&e.adler)),e.adler=1,n.status=An,Pn(e),0!==n.pending)return n.last_flush=-1,pn}if(57===n.status)if(e.adler=0,qn(n,31),qn(n,139),qn(n,8),n.gzhead)qn(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)),qn(n,255&n.gzhead.time),qn(n,n.gzhead.time>>8&255),qn(n,n.gzhead.time>>16&255),qn(n,n.gzhead.time>>24&255),qn(n,9===n.level?2:n.strategy>=kn||n.level<2?4:0),qn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(qn(n,255&n.gzhead.extra.length),qn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=en(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(qn(n,0),qn(n,0),qn(n,0),qn(n,0),qn(n,0),qn(n,9===n.level?2:n.strategy>=kn||n.level<2?4:0),qn(n,3),n.status=An,Pn(e),0!==n.pending)return n.last_flush=-1,pn;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=en(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,Pn(e),0!==n.pending)return n.last_flush=-1,pn;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=en(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=en(e.adler,n.pending_buf,n.pending-r,r)),Pn(e),0!==n.pending)return n.last_flush=-1,pn;r=0}t=n.gzindexr&&(e.adler=en(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=en(e.adler,n.pending_buf,n.pending-r,r)),Pn(e),0!==n.pending)return n.last_flush=-1,pn;r=0}t=n.gzindexr&&(e.adler=en(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&&(Pn(e),0!==n.pending))return n.last_flush=-1,pn;qn(n,255&e.adler),qn(n,e.adler>>8&255),e.adler=0}if(n.status=An,Pn(e),0!==n.pending)return n.last_flush=-1,pn}if(0!==e.avail_in||0!==n.lookahead||t!==cn&&n.status!==Mn){let r=0===n.level?zn(n,t):n.strategy===kn?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Vn(e),0===e.lookahead)){if(t===cn)return 1;break}if(e.match_length=0,n=on(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===bn?((e,t)=>{let n,r,a,i;const s=e.window;for(;;){if(e.lookahead<=Tn){if(Vn(e),e.lookahead<=Tn&&t===cn)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=s[a],r===s[++a]&&r===s[++a]&&r===s[++a])){i=e.strstart+Tn;do{}while(r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=on(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=on(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===hn?(Fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Fn(e,!1),0===e.strm.avail_out)?1:2})(n,t):Wn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=Mn),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),pn;if(2===r&&(t===ln?un(n):t!==fn&&(an(n,0,0,!1),t===dn&&(Dn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Pn(e),0===e.avail_out))return n.last_flush=-1,pn}return t!==hn?pn:n.wrap<=0?vn:(2===n.wrap?(qn(n,255&e.adler),qn(n,e.adler>>8&255),qn(n,e.adler>>16&255),qn(n,e.adler>>24&255),qn(n,255&e.total_in),qn(n,e.total_in>>8&255),qn(n,e.total_in>>16&255),qn(n,e.total_in>>24&255)):(Hn(n,e.adler>>>16),Hn(n,65535&e.adler)),Pn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?pn:vn)},deflateEnd:e=>{if(Zn(e))return _n;const t=e.state.status;return e.state=null,t===An?On(e,mn):pn},deflateSetDictionary:(e,t)=>{let n=t.length;if(Zn(e))return _n;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==Nn||r.lookahead)return _n;if(1===a&&(e.adler=Jt(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(Dn(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 i=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Vn(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,Vn(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=o,e.avail_in=i,r.wrap=a,pn},deflateInfo:"pako deflate (from Nodeca project)"};const tr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var nr=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)tr(n,t)&&(e[t]=n[t])}}return e},rr=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;ir[254]=ir[254]=1;var sr=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,i,s=e.length,o=0;for(a=0;a>>6,t[i++]=128|63&n):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|63&n):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|63&n);return t},or=(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 i=new Array(2*n);for(a=0,r=0;r4)i[a++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?i[a++]=65533:t<65536?i[a++]=t:(t-=65536,i[a++]=55296|t>>10&1023,i[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&ar)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+ir[e[n]]>t?n:t};var cr=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 lr=Object.prototype.toString,{Z_NO_FLUSH:dr,Z_SYNC_FLUSH:hr,Z_FULL_FLUSH:fr,Z_FINISH:pr,Z_OK:vr,Z_STREAM_END:_r,Z_DEFAULT_COMPRESSION:mr,Z_DEFAULT_STRATEGY:gr,Z_DEFLATED:yr}=nn;function Er(e){this.options=nr({level:mr,method:yr,chunkSize:16384,windowBits:15,memLevel:8,strategy:gr},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 cr,this.strm.avail_out=0;let n=er.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==vr)throw new Error(tn[n]);if(t.header&&er.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?sr(t.dictionary):"[object ArrayBuffer]"===lr.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=er.deflateSetDictionary(this.strm,e),n!==vr)throw new Error(tn[n]);this._dict_set=!0}}function kr(e,t){const n=new Er(t);if(n.push(e,!0),n.err)throw n.msg||tn[n.err];return n.result}Er.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,i;if(this.ended)return!1;for(i=t===~~t?t:!0===t?pr:dr,"string"==typeof e?n.input=sr(e):"[object ArrayBuffer]"===lr.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),(i===hr||i===fr)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=er.deflate(n,i),a===_r)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=er.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===vr;if(0!==n.avail_out){if(i>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},Er.prototype.onData=function(e){this.chunks.push(e)},Er.prototype.onEnd=function(e){e===vr&&(this.result=rr(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var br={Deflate:Er,deflate:kr,deflateRaw:function(e,t){return(t=t||{}).raw=!0,kr(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,kr(e,t)},constants:nn};const Cr=16209;var wr=function(e,t){let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x;const S=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,i=a-(t-e.avail_out),s=a+(e.avail_out-257),o=S.dmax,u=S.wsize,c=S.whave,l=S.wnext,d=S.window,h=S.hold,f=S.bits,p=S.lencode,v=S.distcode,_=(1<>>24,h>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(64&y){if(32&y){S.mode=16191;break e}e.msg="invalid literal/length code",S.mode=Cr;break e}g=p[(65535&g)+(h&(1<>>=y,f-=y),f<15&&(h+=w[n++]<>>24,h>>>=y,f-=y,y=g>>>16&255,16&y){if(k=65535&g,y&=15,fo){e.msg="invalid distance too far back",S.mode=Cr;break e}if(h>>>=y,f-=y,y=a-i,k>y){if(y=k-y,y>c&&S.sane){e.msg="invalid distance too far back",S.mode=Cr;break e}if(b=0,C=d,0===l){if(b+=u-y,y2;)x[a++]=C[b++],x[a++]=C[b++],x[a++]=C[b++],E-=3;E&&(x[a++]=C[b++],E>1&&(x[a++]=C[b++]))}else{b=a-k;do{x[a++]=x[b++],x[a++]=x[b++],x[a++]=x[b++],E-=3}while(E>2);E&&(x[a++]=x[b++],E>1&&(x[a++]=x[b++]))}break}if(64&y){e.msg="invalid distance code",S.mode=Cr;break e}g=v[(65535&g)+(h&(1<>3,n-=E,f-=E<<3,h&=(1<{const u=o.bits;let c,l,d,h,f,p,v=0,_=0,m=0,g=0,y=0,E=0,k=0,b=0,C=0,w=0,x=null;const S=new Uint16Array(16),T=new Uint16Array(16);let I,N,A,M=null;for(v=0;v<=xr;v++)S[v]=0;for(_=0;_=1&&0===S[g];g--);if(y>g&&(y=g),0===g)return a[i++]=20971520,a[i++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(T[1]=0,v=1;v852||2===e&&C>592)return 1;for(;;){I=v-k,s[_]+1=p?(N=M[s[_]-p],A=x[s[_]-p]):(N=96,A=0),c=1<>k)+l]=I<<24|N<<16|A}while(0!==l);for(c=1<>=1;if(0!==c?(w&=c-1,w+=c):w=0,_++,0==--S[v]){if(v===g)break;v=t[n+s[_]]}if(v>y&&(w&h)!==d){for(0===k&&(k=y),f+=m,E=v-k,b=1<852||2===e&&C>592)return 1;d=w&h,a[d]=y<<24|E<<16|f-i}}return 0!==w&&(a[f+w]=v-k<<24|64<<16),o.bits=y,0};const{Z_FINISH:Mr,Z_BLOCK:Or,Z_TREES:Ur,Z_OK:Dr,Z_STREAM_END:Rr,Z_NEED_DICT:Lr,Z_STREAM_ERROR:Pr,Z_DATA_ERROR:Fr,Z_MEM_ERROR:qr,Z_BUF_ERROR:Hr,Z_DEFLATED:Gr}=nn,jr=16180,Vr=16190,zr=16191,Br=16192,Qr=16194,Kr=16199,Wr=16200,Yr=16206,Zr=16209,Xr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Jr(){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},ea=e=>{if($r(e))return Pr;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=jr,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,Dr},ta=e=>{if($r(e))return Pr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ea(e)},na=(e,t)=>{let n;if($r(e))return Pr;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Pr:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,ta(e))},ra=(e,t)=>{if(!e)return Pr;const n=new Jr;e.state=n,n.strm=e,n.window=null,n.mode=jr;const r=na(e,t);return r!==Dr&&(e.state=null),r};let aa,ia,sa=!0;const oa=e=>{if(sa){aa=new Int32Array(512),ia=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(Ar(1,e.lens,0,288,aa,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Ar(2,e.lens,0,32,ia,0,e.work,{bits:5}),sa=!1}e.lencode=aa,e.lenbits=9,e.distcode=ia,e.distbits=5},ua=(e,t,n,r)=>{let a;const i=e.state;return null===i.window&&(i.wsize=1<=i.wsize?(i.window.set(t.subarray(n-i.wsize,n),0),i.wnext=0,i.whave=i.wsize):(a=i.wsize-i.wnext,a>r&&(a=r),i.window.set(t.subarray(n-r,n-r+a),i.wnext),(r-=a)?(i.window.set(t.subarray(n-r,n),0),i.wnext=r,i.whave=i.wsize):(i.wnext+=a,i.wnext===i.wsize&&(i.wnext=0),i.whavera(e,15),inflateInit2:ra,inflate:(e,t)=>{let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w=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($r(e)||!e.output||!e.input&&0!==e.avail_in)return Pr;n=e.state,n.mode===zr&&(n.mode=Br),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,d=o,h=u,C=Dr;e:for(;;)switch(n.mode){case jr:if(0===n.wrap){n.mode=Br;break}for(;l<16;){if(0===o)break e;o--,c+=r[i++]<>>8&255,n.check=en(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=Zr;break}if((15&c)!==Gr){e.msg="unknown compression method",n.mode=Zr;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=Zr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=en(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[i++]<>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=en(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[i++]<>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=en(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[i++]<>>8&255,n.check=en(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(i,i+f),b)),512&n.flags&&4&n.wrap&&(n.check=en(n.check,r,f,i)),o-=f,i+=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[i+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=zr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[i++]<>>=7&l,l-=7&l,n.mode=Yr;break}for(;l<3;){if(0===o)break e;o--,c+=r[i++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(oa(n),n.mode=Kr,t===Ur){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Zr}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[i++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Zr;break}if(n.length=65535&c,c=0,l=0,n.mode=Qr,t===Ur)break e;case Qr: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(i,i+f),s),o-=f,i+=f,u-=f,s+=f,n.length-=f;break}n.mode=zr;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[i++]<>>=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=Zr;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},C=Ar(0,n.lens,0,19,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid code lengths set",n.mode=Zr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=_,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=Zr;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=Zr;break}for(;f--;)n.lens[n.have++]=b}}if(n.mode===Zr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Zr;break}if(n.lenbits=9,S={bits:n.lenbits},C=Ar(1,n.lens,0,n.nlen,n.lencode,0,n.work,S),n.lenbits=S.bits,C){e.msg="invalid literal/lengths set",n.mode=Zr;break}if(n.distbits=6,n.distcode=n.distdyn,S={bits:n.distbits},C=Ar(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,S),n.distbits=S.bits,C){e.msg="invalid distances set",n.mode=Zr;break}if(n.mode=Kr,t===Ur)break e;case Kr:n.mode=Wr;case Wr:if(o>=6&&u>=258){e.next_out=s,e.avail_out=u,e.next_in=i,e.avail_in=o,n.hold=c,n.bits=l,wr(e,h),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===zr&&(n.back=-1);break}for(n.back=0;w=n.lencode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=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=zr;break}if(64&m){e.msg="invalid literal/length code",n.mode=Zr;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(;w=n.distcode[c&(1<>>24,m=w>>>16&255,g=65535&w,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=w>>>24,m=w>>>16&255,g=65535&w,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=Zr;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=Zr;break}n.mode=16204;case 16204:if(0===u)break e;if(f=h-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Zr;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=s-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[s++]=v[p++]}while(--f);0===n.length&&(n.mode=Wr);break;case 16205:if(0===u)break e;a[s++]=n.length,u--,n.mode=Wr;break;case Yr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[i++]<{if($r(e))return Pr;let t=e.state;return t.window&&(t.window=null),e.state=null,Dr},inflateGetHeader:(e,t)=>{if($r(e))return Pr;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Dr):Pr},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,i;return $r(e)?Pr:(r=e.state,0!==r.wrap&&r.mode!==Vr?Pr:r.mode===Vr&&(a=1,a=Jt(a,t,n,0),a!==r.check)?Fr:(i=ua(e,t,n,n),i?(r.mode=16210,qr):(r.havedict=1,Dr)))},inflateInfo:"pako inflate (from Nodeca project)"};var la=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 da=Object.prototype.toString,{Z_NO_FLUSH:ha,Z_FINISH:fa,Z_OK:pa,Z_STREAM_END:va,Z_NEED_DICT:_a,Z_STREAM_ERROR:ma,Z_DATA_ERROR:ga,Z_MEM_ERROR:ya}=nn;function Ea(e){this.options=nr({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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new cr,this.strm.avail_out=0;let n=ca.inflateInit2(this.strm,t.windowBits);if(n!==pa)throw new Error(tn[n]);if(this.header=new la,ca.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=sr(t.dictionary):"[object ArrayBuffer]"===da.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ca.inflateSetDictionary(this.strm,t.dictionary),n!==pa)))throw new Error(tn[n])}function ka(e,t){const n=new Ea(t);if(n.push(e),n.err)throw n.msg||tn[n.err];return n.result}Ea.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let i,s,o;if(this.ended)return!1;for(s=t===~~t?t:!0===t?fa:ha,"[object ArrayBuffer]"===da.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),i=ca.inflate(n,s),i===_a&&a&&(i=ca.inflateSetDictionary(n,a),i===pa?i=ca.inflate(n,s):i===ga&&(i=_a));n.avail_in>0&&i===va&&n.state.wrap>0&&0!==e[n.next_in];)ca.inflateReset(n),i=ca.inflate(n,s);switch(i){case ma:case ga:case _a:case ya:return this.onEnd(i),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||i===va))if("string"===this.options.to){let e=ur(n.output,n.next_out),t=n.next_out-e,a=or(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(i!==pa||0!==o){if(i===va)return i=ca.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Ea.prototype.onData=function(e){this.chunks.push(e)},Ea.prototype.onEnd=function(e){e===pa&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=rr(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ba={Inflate:Ea,inflate:ka,inflateRaw:function(e,t){return(t=t||{}).raw=!0,ka(e,t)},ungzip:ka,constants:nn};const{Deflate:Ca,deflate:wa,deflateRaw:xa,gzip:Sa}=br,{Inflate:Ta,inflate:Ia,inflateRaw:Na,ungzip:Aa}=ba;var Ma,Oa={Deflate:Ca,deflate:wa,deflateRaw:xa,gzip:Sa,Inflate:Ta,inflate:Ia,inflateRaw:Na,ungzip:Aa,constants:nn},Ua=function(e){return E(void 0,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Oa.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,n));case 2:case"end":return t.stop()}}),t)})))};e.ConnectionState=void 0,(Ma=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",Ma.OPEN="OPEN",Ma.CLOSED="CLOSED";var Da,Ra=function(t){function a(e,t){var i,s=t.sdkState,o=t.dispatcher,u=t.logger;return r(this,a),(i=n(this,a)).lastActive=0,i._iid=e,i._sdkState=s,i._dispatcher=o,i._logger=u,i}return c(a,t),i(a,[{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:"ws",get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ke.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 Qe(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return E(this,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:this._ws=new WebSocket(e,encodeURIComponent(t)),this._ws.onopen=function(){r._logger.debug("websocket open"),r.dispatch("open")},this._ws.onmessage=function(e){return E(r,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)){t.next=38;break}if(!(e.data instanceof Blob)){t.next=7;break}(r=new FileReader).readAsArrayBuffer(e.data),r.onloadend=function(){return E(u,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Ua(r.result);case 3:t=e.sent,this._handleMessage(t),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),this.error(e.t0);case 10:case"end":return e.stop()}}),e,this,[[0,7]])})))},t.next=36;break;case 7:if(!(e.data instanceof ArrayBuffer)){t.next=20;break}return t.prev=8,t.next=11,Ua(new Uint8Array(e.data));case 11:a=t.sent,this._handleMessage(a),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),this.error(t.t0);case 18:t.next=36;break;case 20:if(!("undefined"!=typeof Buffer&&e.data instanceof Buffer)){t.next=35;break}return t.prev=21,i=e.data,s=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),t.next=26,Ua(s);case 26:o=t.sent,this._handleMessage(o),t.next=33;break;case 30:t.prev=30,t.t1=t.catch(21),this.error(t.t1);case 33:t.next=36;break;case 35:"string"==typeof e.data&&this._handleMessage(e.data);case 36:t.next=39;break;case 38:this._handleMessage(e.data);case 39:case"end":return t.stop()}}),t,this,[[8,15],[21,30]])})))},this._ws.onerror=function(){r._logger.debug("websocket error"),r.dispatch("error",A.networkError)},this._ws.onclose=function(){r._logger.debug("websocket close"),r.dispatch("close")},this.lastActive=Date.now();case 6:case"end":return n.stop()}}),n,this)})))}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws?(t._ws.onopen=ft,t._ws.onmessage=ft,t._ws.onerror=ft,t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=void 0):n()):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)}}])}(de),La=function(e){function t(e){var a,i=e.all,s=e.feed,o=e.custom_types,u=e.ts;return r(this,t),(a=n(this,t)).all=i,a.feed=s,a.customTypes=o,a.ts=u,a}return c(t,e),i(t)}(fe),Pa=function(){return i((function e(t,n){var a=this,i=n.session,s=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=s,this._dispatcher=o,this._logger=u,this.apiClient=new ht(t,{session:i,sdkState:s,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new Ra(t,{sdkState:s,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new La(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()}))}),[{key:"_sendApiRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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(n=new ut,e.ackRequired){a=function(t,a){i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),r&&(clearTimeout(r),r=null),t?(i._logger.debug("fail websocket request",e.requestId,t),n.reject(t)):(i._logger.debug("receive websocket ack",e.requestId,e),i._logger.debug("receive websocket ack",a),n.resolve(a)))};try{r=setTimeout((function(){return a(A.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return a(void 0,e)},reject:function(e){return a(e)}}),this.websocketClient.send(e)}catch(e){a(e)}}else try{this.websocketClient.send(e),n.resolve()}catch(e){n.reject(e)}return t.abrupt("return",n.promise);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ve)){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 We)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw A.invalidParameters;case 11:case"end":return t.stop()}}),t,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}])}();!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"}(Da||(Da={}));var Fa,qa,Ha=function(e){function t(e){var a,i=e.stateType;return r(this,t),(a=n(this,t)).stateType=i,a}return c(t,e),i(t)}(fe),Ga=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),ja=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),Va=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),za=function(){return i((function e(t){var n,a,i,s;r(this,e),this.isEnabled=null!==(n=t.enabled)&&void 0!==n&&n,this.feedChannels=null!==(a=t.feed_channels)&&void 0!==a?a:{},this.templateListToken=null!==(i=t.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(s=t.settings_updated_at)&&void 0!==s?s:0}),null,[{key:"payloadify",value:function(e){return pe(ve({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}])}(),Ba=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},Qa=function(){return i((function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}),null,[{key:"payloadify",value:function(e){return pe(ve({last_updated_at:e.lastUpdatedAt}))}}])}(),Ka=function(){return i((function e(t){var n;r(this,e),this.token=null!==(n=t.template_list_token)&&void 0!==n?n:""}),null,[{key:"payloadify",value:function(e){return pe(ve({template_list_token:e.token}))}}])}(),Wa=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180};r(this,e),this.minStatCount=t.min_stat_count,this.minInterval=1e3*t.min_interval,this.maxStatCountPerRequest=t.max_stat_count_per_request,this.lowerThreshold=t.lower_threshold,this.requestDelayRange=1e3*t.request_delay_range}),null,[{key:"payloadify",value:function(e){return pe(ve({min_stat_count:e.minStatCount,min_interval:e.minInterval/1e3,max_stat_count_per_request:e.maxStatCountPerRequest,lower_threshold:e.lowerThreshold,request_delay_range:e.requestDelayRange/1e3}))}}])}(),Ya=function(){return i((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}};r(this,e),this.default=new Wa(t.default),this.realTime=new Wa(t.realtime)}),null,[{key:"payloadify",value:function(e){return pe(ve({default:Wa.payloadify(e.default),realtime:Wa.payloadify(e.realTime)}))}}])}(),Za=1048576;e.UnreadCountThreadingPolicy=void 0,(Fa=e.UnreadCountThreadingPolicy||(e.UnreadCountThreadingPolicy={}))[Fa.NONE=0]="NONE",Fa[Fa.INCLUDE_REPLY=1]="INCLUDE_REPLY",Fa[Fa.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",Fa[Fa.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL",e.LastMessageThreadingPolicy=void 0,(qa=e.LastMessageThreadingPolicy||(e.LastMessageThreadingPolicy={}))[qa.NONE=0]="NONE",qa[qa.INCLUDE_REPLY=1]="INCLUDE_REPLY",qa[qa.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",qa[qa.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL";var Xa,Ja=function(){return i((function t(){var n,a,i,s,o,u,c,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),this.emojiHash=l.emoji_hash||"",this.uploadSizeLimit=l.file_upload_size_limit?l.file_upload_size_limit*Za:Number.MAX_SAFE_INTEGER,this.useReaction=!!l.use_reaction,this.applicationAttributes=null!==(n=l.application_attributes)&&void 0!==n?n:[],this.premiumFeatureList=null!==(a=l.premium_feature_list)&&void 0!==a?a:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(i=l.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(s=l.allow_sdk_log_ingestion)||void 0===s||s,this.unreadCountThreadingPolicy=null!==(o=l.unread_cnt_threading_policy)&&void 0!==o?o:e.UnreadCountThreadingPolicy.NONE,this.lastMessageThreadingPolicy=null!==(u=l.last_msg_threading_policy)&&void 0!==u?u:e.LastMessageThreadingPolicy.NONE,this.uikitConfigInfo=new Qa(null!==(c=l.uikit_config)&&void 0!==c?c:{}),this.notificationInfo=l.notifications?new za(l.notifications):null,this.messageTemplateInfo=l.message_template?new Ka(l.message_template):null,this.statConfigInfo=l.log_publish_config?new Ya(l.log_publish_config):new Ya}),null,[{key:"payloadify",value:function(e){return pe(ve({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Za,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,unread_cnt_threading_policy:e.unreadCountThreadingPolicy,last_msg_threading_policy:e.lastMessageThreadingPolicy,uikit_config:e.uikitConfigInfo?Qa.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?za.payloadify(e.notificationInfo):null,message_template:e.messageTemplateInfo?Ka.payloadify(e.messageTemplateInfo):null,log_publish_config:e.statConfigInfo?Ya.payloadify(e.statConfigInfo):null}))}}])}(),$a=function(){return i((function e(t){r(this,e),this._iid="",this._iid=t}),null,[{key:"payloadify",value:function(e){return{}}}])}(),ei=function(e){function t(e){var a,i=e.userId,s=e.metadata;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s},a}return c(t,e),i(t)}(Ve),ti=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaData=a,i}return c(t,e),i(t)}(ze),ni=function(e){function t(e){var a,i=e.userId,s=e.metadata,o=e.upsert;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/metadata"),a.params={metadata:s,upsert:o},a}return c(t,e),i(t)}(Ve),ri=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metadata=a,i}return c(t,e),i(t)}(ze),ai=function(e){function t(e){var a,i=e.userId,s=e.metadataKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata/").concat(s),a}return c(t,e),i(t)}(Ve),ii=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(i,"/metadata"),a}return c(t,e),i(t)}(Ve),si=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},oi=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ui=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(Xa=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",Xa.OFFLINE="offline",Xa.NON_AVAILABLE="nonavailable";var ci,li=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y;return r(this,a),(s=n(this,a,[t])).userId=null!==(u=null!==(o=i.guest_id)&&void 0!==o?o:i.user_id)&&void 0!==u?u:"",s.nickname=null!==(l=null!==(c=i.nickname)&&void 0!==c?c:i.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(h=null!==(d=i.profile_url)&&void 0!==d?d:i.image)&&void 0!==h?h:"",s.requireAuth=null!==(f=i.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=i.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,R(e.UserOnlineState,i.is_online)?s.connectionStatus=i.is_online:D("boolean",i.is_online)&&(s.connectionStatus=i.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(_=i.is_active)||void 0===_||_,s.lastSeenAt=null!==(m=i.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=i.preferred_languages?v(i.preferred_languages):null,s.friendDiscoveryKey=null!==(g=i.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=i.friend_name)&&void 0!==y?y:null,s}return c(a,t),i(a,[{key:"profileUrl",get:function(){var e=ss.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return si(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 D("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,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(this._isValidMetaData(e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ei({userId:r.userId,metadata:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(ti),u=o.metaData,this._applyMetaData(u),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(this._isValidMetaData(e)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new ni({userId:a.userId,metadata:e,upsert:t}),n.next=5,i.send(s);case 5:return o=n.sent,u=o.as(ri),c=u.metadata,this._applyMetaData(c),n.abrupt("return",this.metaData);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ai({userId:r.userId,metadataKey:e}),t.next=5,a.send(i);case 5:return this._applyMetaData((s={},u=!0,(o=_(o=e))in s?Object.defineProperty(s,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):s[o]=u,s),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var s,o,u}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ii({userId:n.userId}),e.next=4,r.send(a);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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})))}}])}($a),di=function(e){function t(e){var a,i=e.userProfile;return r(this,t),(a=n(this,t)).userProfile=i,a}return c(t,e),i(t)}(fe),hi=function(){return i((function e(t,n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new Ja(n),this.user=new li(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=n.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(s=n.pong_timeout)&&void 0!==s?s: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!==(h=null===(d=n.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==h?h: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}),[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=ss.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 di({userProfile:this}))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign(Object.assign({},li.payloadify(e.user)),Ja.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})))}}])}(),fi=function(e){function t(e){var a,i=e.request,s=void 0===i||i,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c,d=e.statConfigInfo;return r(this,t),(a=n(this,t)).request=s,a.features=Object.assign({localCache:!0,notification:!0},u),a.options=Object.assign({ingestion:!0},l),a.statConfigInfo=d,a}return c(t,e),i(t)}(fe),pi=function(e){function t(e,a,i){var s,o,u,c,l;return r(this,t),(s=n(this,t,[e,a,i])).error=null,s.services=[],s.userProfile=new hi(e,i),s.deviceTokenLastDeletedAt=null!==(o=i.device_token_last_deleted_at)&&void 0!==o?o:0,s.key=null!==(u=i.key)&&void 0!==u?u:"",s.ekey=null!==(c=i.ekey)&&void 0!==c?c:"",s.error=i.error?new A(i):null,s.services=null!==(l=i.services)&&void 0!==l?l:[],s}return c(t,e),i(t,[{key:"applyTo",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=13;break}if(!(n=ss.of(e))){t.next=10;break}return r=n.sessionManager,a=n.dispatcher,t.next=6,r.login(this);case 6:this.userProfile.apply(),a.dispatch(new fi({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),t.next=11;break;case 10:throw A.lostInstance;case 11:t.next=14;break;case 13:throw this.error;case 14:case"end":return t.stop()}}),t,this)})))}}],[{key:"asError",value:function(e){return new t("","LOGI",Object.assign({user_id:"",error:!0},e))}}])}(Ke),vi=function(){return i((function e(){r(this,e),this.type=Da.NONE,this.name="none"}),[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,t){return t.resetReconnectCount,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,t){return t.error,t.autoReconnect,t.cause,E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}(),_i=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=12;break;case 5:if(t.prev=5,t.t0=t.catch(0),!(t.t0 instanceof A)){t.next=11;break}t.t0.throwOutside(),t.next=12;break;case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,null,[[0,5]])})))},mi=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e();case 3:t.next=7;break;case 5:t.prev=5,t.t0=t.catch(0);case 7:case"end":return t.stop()}}),t,null,[[0,5]])})))},gi=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t)).type=Da.LOGOUT,e.name="logout",e._wasPreviouslyConnected=null===(a=i.wasPreviouslyConnected)||void 0===a||a,e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=e.sdkState.userId,t.next=4,e.logout();case 4:return t.next=6,e.changeState(new Ai,n);case 6:this._wasPreviouslyConnected&&_i((function(){return E(a,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(r)}));case 1:case"end":return t.stop()}}),t)})))}));case 7:case"end":return t.stop()}}),t,this)})))}}])}(vi),yi=function(e){function t(){var e;return r(this,t),(e=n(this,t)).type=Da.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),t)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ti({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new wi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new gi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(vi),Ei=function(e){function t(e){var a,i=e.autoReconnect;return r(this,t),(a=n(this,t)).type=Da.INTERNAL_DISCONNECTED,a.name="internaldisconnected",a._autoReconnect=!1,a._autoReconnect=i,a}return c(t,e),i(t,[{key:"run",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new wi,n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Ti({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new wi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new yi,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new gi,n);case 3:case"end":return t.stop()}}),t)})))}}])}(vi),ki=function(e){return E(void 0,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),t)})))},bi=function(){return i((function e(){r(this,e)}),[{key:"calcTimeout",value:function(){return 0}}])}(),Ci=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new bi;return E(void 0,void 0,void 0,d().mark((function r(){var a,i,s,o,u;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=0,i=null,s=function(e){return i=null!=e?e:new Error("Halted")},o=function(){a=0};case 4:if(!(-1===t||a0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,e&&(this._webSocketClosedCause=ci.ExternalDisconnectWebSocket),t.next=4,n.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause});case 4:case"end":return t.stop()}}),t,this)})))}},{key:"logout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),t.next=4,n.onLogout(this._context,e);case 4:case"end":return t.stop()}}),t,this)})))}}])}(),Ti=function(t){function a(e){var t,i=e.authToken;return r(this,a),(t=n(this,a)).type=Da.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=i,t}return c(a,t),i(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(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ut,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,Ci((function(n){return E(i,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._haltConnect=n,r.prev=1,r.next=4,t.connect(this._authToken);case 4:r.next=16;break;case 6:if(r.prev=6,r.t0=r.catch(1),t.clearLoginTimer(),!(r.t0 instanceof A)){r.next=15;break}r.t1=r.t0.code,r.next=r.t1===e.SendbirdErrorCode.CONNECTION_CANCELED?13:15;break;case 13:return n(r.t0),r.abrupt("return");case 15:throw r.t0;case 16:case"end":return r.stop()}}),r,this,[[1,6]])})))}),t.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,t.changeState(new xi,r);case 8:_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(),t.connectionHandlers.forEach((function(e){e.onConnected&&e.onConnected(t.sdkState.userId)}));case 2:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),N(n.t0)){n.next=23;break}return n.next=16,t.disconnect();case 16:if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===e.SendbirdErrorCode.CONNECTION_CANCELED){n.next=20;break}return n.next=20,t.changeState(new Ai,r);case 20:_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new ut,this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){var n=t.error,r=void 0===n?null:n,a=t.autoReconnect,i=void 0!==a&&a,s=t.cause,o=void 0===s?null:s;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Date.now(),this._halt(null!=r?r:Ii(o)),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Ei({autoReconnect:i}),n);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new gi,n);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"onDisconnectWebSocket",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._halt(Ii((null==t?void 0:t.cause)||null)),r=Date.now(),!e.hasSession){n.next=7;break}return n.next=5,e.changeState(new yi,r);case 5:n.next=9;break;case 7:return n.next=9,e.changeState(new gi,r);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"onLogout",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),this._halt(null!=t?t:A.connectionCanceled),n.next=4,e.changeState(new gi,r);case 4:case"end":return n.stop()}}),n,this)})))}}])}(vi);function Ii(e){var t=A.connectionCanceled;if(e){var n=null;switch(e){case ci.ExternalSetBackground:n="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case ci.ExternalDisconnectWebSocket:n="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}n&&t.setDetail(n)}return t}var Ni,Ai=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).type=Da.INITIALIZED,e.name="initialized",e}return c(t,e),i(t,[{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.changeState(new Ti({authToken:t}),r);case 3:case"end":return n.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new gi({wasPreviouslyConnected:!1}),n);case 3:case"end":return t.stop()}}),t)})))}}])}(vi),Mi=function(e){function t(){return r(this,t),n(this,t,[{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1}])}return c(t,e),i(t)}(We),Oi=function(){return i((function e(t){var n=t.pingDelegate,a=t.sdkState,i=t.logger;r(this,e),this.pingDelegate=n,this.sdkState=a,this._logger=i}),[{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 Mi;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)}}])}(),Ui=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template"],Di=function(e){function t(e,a){var i,s,o=a.sdkState,u=a.cacheContext,c=a.connectionHandlers,l=a.sessionManager,d=a.websocketClient,h=a.dispatcher,f=a.logger,p=a.entryState,v=void 0===p?new Ai:p;return r(this,t),(i=n(this,t))._stateUpdatedAt=0,i._connectingAt=0,i._connectedAt=0,i._logiReceivedAt=0,i._connectionRequestQueue=[],i._iid=e,i.sdkState=o,i.cacheContext=u,i.connectionHandlers=c,i._sessionManager=l,i._websocketClient=d,i._dispatcher=h,i._logger=f,i._currentState=v,(null===(s=i.sdkState.websocket)||void 0===s?void 0:s.pingerDisabled)||(i._pinger=new Oi({pingDelegate:{send:function(e){return i._websocketClient.send(e)},error:function(e){return i._websocketClient.error(e)}},sdkState:i.sdkState,logger:f})),i._websocketClient.on("open",(function(){i._connectedAt=Date.now(),i._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)i.clearLoginTimer(),i._dispatcher.dispatch(e.as(pi))})).on("ping-refresh",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){i._logiProcessingTimer=setTimeout((function(){i._logiProcessingTimer=void 0,i._unresolvedLogi||i._rejectConnectionRequest(A.networkError)}),500)})),i._dispatcher.on((function(e){e instanceof pi&&(i._unresolvedLogi=e,i._tryResolveConnectionRequest())})),i}return c(t,e),i(t,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.session.hasSession}},{key:"changeState",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>=this._stateUpdatedAt)){n.next=8;break}return this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Ha({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),n.next=7,this._currentState.run(this);case 7:return n.abrupt("return",!0);case 8:return n.abrupt("return",!1);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._unresolvedLogi,!this._websocketClient.isOpen||!n){t.next=17;break}if(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),n.error){t.next=14;break}return t.next=7,n.applyTo(this._iid);case 7: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=17;break;case 14:this._sessionManager.session.authToken=void 0,n.error.isSessionExpiredError||n.error.isSessionInvalidatedError?this._dispatcher.dispatch(new Qe({reason:n.error.code,message:n.error.message})):this._logger.warn("login failed: ".concat(n.error)),this._rejectConnectionRequest(n.error);case 17:case"end":return t.stop()}}),t,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=this.sdkState,n=t.appId,r=t.appVersion,a=t.userId,i=t.extensions,s=t.sendbirdRuntimeEnvironment,o=this.cacheContext.localCacheEnabled,u=this._sessionManager.session,c=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!(null!=i?i:{}).sb_uikit,d=ot.userAgentWithExtension(i);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(u.hasSession?"":"&user_id=".concat(encodeURIComponent(a)),"&pmce=").concat(c?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(d,"&SB-SDK-User-Agent=").concat(encodeURIComponent(ot.sendbirdSdkUserAgentWithExtension(s)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(Ui))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new $e(new at({type:je.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:this._connectedAt>0?this._connectedAt-this._connectingAt:Date.now()-this._connectingAt,logi_latency:this._logiReceivedAt>0?this._logiReceivedAt-this._connectingAt:void 0,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(A.connectionCanceled)),r=new ut,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout((function(){s._loginTimer=void 0,s._rejectConnectionRequest(A.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),a=this._sessionManager.session,t&&(a.authToken=t,a.sessionKey=void 0),i=this._url(),a.sessionKey||a.authToken?this._websocketClient.connect(i,JSON.stringify(a.hasSession?{auth:a.sessionKey}:{token:a.authToken})):this._websocketClient.connect(i,JSON.stringify({}))),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(pi.asError(A.connectionRenew))}},{key:"disconnect",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function e(){return d().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.disconnect();case 4:return e.next=6,this._sessionManager.clear();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}])}(de),Ri=function(e){function t(e){var a,i=e.appId,s=e.userId,o=e.includeUIKitConfig,u=void 0!==o&&o,c=e.localCacheEnabled,l=void 0===c||c,d=e.expiringSession,h=void 0===d||d;return r(this,t),(a=n(this,t)).path="".concat(ye,"/").concat(s,"/authentication"),a.method=_e.POST,a.params=pe({expiring_session:!!h,include_logi:!0,include_extra_data:String(Ui),uikit_config:u,use_local_cache:l,app_id:i}),a.requireAuth=!1,a}return c(t,e),i(t)}(Ve),Li=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).logi=new pi(e,"LOGI",a),i}return c(t,e),i(t)}(ze);!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(Ni||(Ni={}));var Pi,Fi,qi=[Ye,Ri],Hi=function(){return i((function e(t,n){var a=this,i=n.session,o=n.sdkState,u=n.dispatcher,c=n.logger,l=n.useFetchCompat,d=void 0!==l&&l;r(this,e),this._currentConnectionStateType=Da.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Pa(t,{session:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:d}),this._session=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){var t;if(e instanceof Ha){var n=e.stateType;switch(a._currentConnectionStateType=n,n){case Da.CONNECTED:a._resolveLazyCallQueue();break;case Da.INITIALIZED:case Da.INTERNAL_DISCONNECTED:case Da.EXTERNAL_DISCONNECTED:case Da.LOGOUT:a._rejectLazyCallQueue((null===(t=a._session)||void 0===t?void 0:t.hasSession)?A.connectionClosed:A.connectionRequired)}}else if(e instanceof Ga)a._session.hasChatServicePermission||a._resolveLazyCallQueue(Ni.API);else if(e instanceof ja||e instanceof Va)a._rejectLazyCallQueue(A.connectionClosed);else if(e instanceof et){var r,i=e.request,o=e.deferred,u=e.error,c=s(qi);try{for(c.s();!(r=c.n()).done;){if(i instanceof r.value)return void o.reject(u)}}catch(e){c.e(e)}finally{c.f()}a._lazyCallQueue.push({command:i,deferred:o})}}))}),[{key:"isReady",get:function(){return this._currentConnectionStateType===Da.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===Da.CONNECTING||this._currentConnectionStateType===Da.RECONNECTING||this._session.isRefreshing}},{key:"_classifyLazyCallQueueByScope",value:function(e){var t,n=[],r=[];switch(e){case Ni.ALL:t=null;break;case Ni.WEBSOCKET:t=We;break;case Ni.API:t=Ve}var a=!1;return this._lazyCallQueue.forEach((function(e){!t||e.command instanceof t||(a=!0),a?r.push(e):n.push(e)})),[n,r]}},{key:"_resolveLazyCallQueue",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ni.ALL,n=f(this._classifyLazyCallQueueByScope(t),2),r=n[0],a=n[1];this._lazyCallQueue=a,r.forEach((function(t){return E(e,void 0,void 0,d().mark((function e(){var n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.command,r=t.deferred,(a=t.timeout)&&clearTimeout(a),e.prev=2,e.next=5,this.send(n);case 5:i=e.sent,r.resolve(i),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),r.reject(e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])})))}))}},{key:"_rejectLazyCallQueue",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ni.ALL,r=f(this._classifyLazyCallQueueByScope(n),2),a=r[0],i=r[1];this._lazyCallQueue=i,a.forEach((function(n){return E(t,void 0,void 0,d().mark((function t(){var r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n.deferred,a=n.timeout,clearTimeout(a),r.reject(e);case 3:case"end":return t.stop()}}),t)})))}))}},{key:"send",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof We)){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:case 31:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),n=new ut,this._lazyCallQueue.push({command:e,deferred:n,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",n.promise);case 15:throw this._logger.debug("fail websocket request"),A.connectionRequired;case 17:case 44:t.next=47;break;case 19:if(!(e instanceof Ve)){t.next=46;break}if(!this._session.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!e.hasSessionKey){t.next=34;break}return this._logger.debug("send api request with tmp session key",e),t.next=31,this.commandRouter.send(e);case 34:if(!this.isLazyCallActivated){t.next=41;break}return this._logger.debug("wait api request",e),r=new ut,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 41:throw a=A.connectionRequired,this._logger.debug("fail api request",a),a;case 46:throw A.invalidCommand;case 47:case"end":return t.stop()}}),t,this)})))}},{key:"forceSend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._logger.debug("send forced request",e),!(e instanceof We||e instanceof Ve)){t.next=7;break}return t.next=4,this.commandRouter.send(e);case 4:return t.abrupt("return",t.sent);case 7:throw A.invalidCommand;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(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()}}])}(),Gi="sendbird@devicetokens",ji=function(){return i((function e(t){var n=t.type,a=t.token,i=t.device_os,s=t.device_manufacturer,o=t.system_push_enabled;r(this,e),this.type=n,this.token=a,this.deviceOS=i,this.deviceManufacturer=s,this.systemPushEnabled=o}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,token:e.token,device_os:e.deviceOS,device_manufacturer:e.deviceManufacturer,system_push_enabled:e.systemPushEnabled}))}}])}(),Vi=new WeakMap,zi=function(t){function a(e){var t,i=e._iid,s=e.session,o=e.cacheContext,u=e.sdkState,c=e.dispatcher,l=e.requestQueue,d=e.logger,h=e.pushNotificationAckManager;return r(this,a),(t=n(this,a))._currentConnectionStateType=Da.INITIALIZED,t._isRefreshingAuthToken=!1,t.currentUser=null,t.session=s,t._iid=i,t._cacheContext=o,t._sdkState=u,t._dispatcher=c,t._requestQueue=l,t._logger=d,t._pushNotificationAckManager=h,t._deviceTokens=[],t._dispatcher.on((function(e){var n,r,a;if(e instanceof Ha){var i=e.stateType;t._currentConnectionStateType=i}else if(e instanceof Qe&&t.handler&&!t.isSessionKeyRefreshing){if(t._currentConnectionStateType===Da.CONNECTING)return;(null===(n=e.error)||void 0===n?void 0:n.isSessionInvalidatedError)?t.close():((null===(r=e.error)||void 0===r?void 0:r.isSessionTokenExpiredError)&&t.refreshAuthToken().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e})),(null===(a=e.error)||void 0===a?void 0:a.isSessionKeyExpiredError)&&(t._logger.debug("session expired"),t.handler.onSessionExpired&&t.handler.onSessionExpired(),t.refreshSessionKey().catch((function(e){if(N(e)&&"foreground"===t._sdkState.appState)throw e}))))}})),t}return c(a,t),i(a,[{key:"ekey",get:function(){return Vi.get(this)}},{key:"deviceTokens",get:function(){return this._deviceTokens}},{key:"deviceTokenLastDeletedAt",get:function(){return this._deviceTokenLastDeletedAt}},{key:"indexOfDeviceToken",value:function(e,t){return this._deviceTokens.findIndex((function(n){return n.type===e&&n.token===t}))}},{key:"hasDeviceToken",value:function(e,t){return this.indexOfDeviceToken(e,t)>=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new Ze({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(n);case 3:if(r=t.sent,a=r.as(Je),i=a.newKey,!(s=a.error)){t.next=7;break}throw s;case 7:this.session.sessionKey=null!=i?i:this.session.sessionKey;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Ye({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),t.next=3,Ci((function(e){return E(r,void 0,void 0,d().mark((function t(){var r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(n);case 3:r=t.sent,a=r.as(Xe),i=a.key,s=a.services,this.session.sessionKey=i,this.session.services=s,t.next=16;break;case 9:if(t.prev=9,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=15;break}e(t.t0),t.next=16;break;case 15:throw t.t0;case 16:case"end":return t.stop()}}),t,this,[[0,9]])})))}),3);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKey",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._currentConnectionStateType!==Da.CONNECTED){n.next=18;break}return n.prev=1,n.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),n.abrupt("return");case 8:return n.prev=8,n.t0=n.catch(1),n.prev=10,n.next=13,this._handleSessionRefreshError(n.t0,t);case 13:return n.abrupt("return");case 16:n.prev=16,n.t1=n.catch(10);case 18:return n.prev=18,n.next=21,this._refreshSessionKeyByApi(e);case 21:this.complete(),n.next=28;break;case 24:return n.prev=24,n.t2=n.catch(18),n.next=28,this._handleSessionRefreshError(n.t2,t);case 28:case"end":return n.stop()}}),n,this,[[1,8],[10,16],[18,24]])})))}},{key:"_receiveNewAuthToken",value:function(){var e,t=this,n=new ut;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){var r=null,a=function(){r&&(clearTimeout(r),r=null)},i=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.resolve(e))},s=function(e){a(),t._isRefreshingAuthToken&&(t._isRefreshingAuthToken=!1,n.reject(e))};r=setTimeout((function(){return s()}),1e3*this._sdkState.sessionTokenRefreshTimeout),_i((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this.handler)||void 0===t?void 0:t.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(i,s);case 1:case"end":return e.stop()}}),e,this)})))}))}else n.resolve(null);return n.promise}},{key:"_handleSessionRefreshError",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(t instanceof A)){r.next=16;break}if(!t.isSessionTokenExpiredError&&t.code!==e.SendbirdErrorCode.APPLICATION_NOT_FOUND){r.next=16;break}if(this.session.authToken=void 0,!n){r.next=16;break}return r.next=6,this._receiveNewAuthToken();case 6:if(!(a=r.sent)){r.next=13;break}return this.session.authToken=a,r.next=11,this._refreshSessionKey(this.session.authToken,!1);case 11:r.next=15;break;case 13:return r.next=15,this.clear();case 15:return r.abrupt("return");case 16:throw t;case 17:case"end":return r.stop()}}),r,this)})))}},{key:"_isSessionRelatedError",value:function(e){return e instanceof A&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}},{key:"isSessionKeyRefreshing",get:function(){return this.session.isRefreshing}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"isSessionExpiring",get:function(){return!!this.handler}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.session.authToken=t,a=new Ri({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!(null!==(n=this._sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:this.isSessionExpiring}),r.next=4,this._requestQueue.commandRouter.send(a);case 4:if(i=r.sent,s=i.as(Li),(o=s.logi).error){r.next=12;break}if(this.session.hasChatServicePermission){r.next=10;break}return r.next=10,o.applyTo(this._iid);case 10:r.next=13;break;case 12:throw o.error;case 13:case"end":return r.stop()}}),r,this)})))}},{key:"login",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=e.key,a=e.ekey,i=e.services,s=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.session.sessionKey=r,this.session.services=i,Vi.set(this,a),this._deviceTokenCacheEnabled=null===(t=null==s?void 0:s.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){n.next=21;break}return n.next=9,c.get(Gi);case 9:if((l=n.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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return t=this._cacheContext.preference,e.next=4,t.set(Gi,{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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.session.clear(),this.close(),Vi.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:this._pushNotificationAckManager.clear();case 9:case"end":return e.stop()}}),e,this)})))}}])}(de),Bi=function(e,t){if(null!==e&&null!==t){var n,r=Object.keys(e),a=Object.keys(t),i={},o=s(v(new Set([].concat(r,a))));try{for(o.s();!(n=o.n()).done;){var u=n.value,c=m(e[u]),l=m(t[u]);"undefined"===c?i[u]=t[u]:"undefined"===l?i[u]=e[u]:c!==l?i[u]=t[u]:"object"===c&&e[u]&&t[u]?i[u]=Bi(e[u],t[u]):i[u]=t[u]}}catch(e){o.e(e)}finally{o.f()}return i}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"}(Pi||(Pi={})),function(e){e.DAILY="daily",e.DEFAULT="default",e.REALTIME="realtime"}(Fi||(Fi={}));var Qi,Ki=100,Wi=function(){return i((function e(t){var n=t.deviceId,a=t.cacheContext,i=t.requestQueue;r(this,e),this.queue=[],this.flushWaitQueue=[],this.enabledState=Pi.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=n,this.cacheContext=a,this.requestQueue=i,this.logInfo={deviceId:n,statLogs:[],generation:1,lastFlushedAt:0},this.limit=Ki}),[{key:"isEnabled",get:function(){return this.enabledState===Pi.ENABLED}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:(n=t.sent)&&(this.logInfo=n);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_mergeQueue",value:function(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])}},{key:"_isDuplicateStat",value:function(e){var t=this._sentLogStats.find((function(t){var n;return t.channelUrl===e.data.channel_url&&t.messageId===(null!==(n=e.data.notificationId)&&void 0!==n?n:e.data.message_id)&&t.action===e.data.action}));return t||this._sentLogStats.push({channelUrl:e.data.channel_url,messageId:e.data.message_id,action:e.data.action}),!!t}},{key:"_save",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(v(this.queue),v(this.flushWaitQueue)),e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:t.map((function(e){return at.payloadify(e)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save();case 4:case"end":return e.stop()}}),e,this)})))}}])}(),Yi=function(e){function t(e){var a,i,s,o,u,c=e.type,l=e.data,d=e.ts,h=void 0===d?Date.now():d;return r(this,t),(a=n(this,t,[{type:c,data:l,ts:h}])).date=new Date(h),a.key="".concat((i=a.date,s=i.getFullYear(),o=String(i.getMonth()+1).padStart(2,"0"),u=String(i.getDate()).padStart(2,"0"),"".concat(s).concat(o).concat(u)),"_").concat(c),a}return c(t,e),i(t)}(at),Zi=function(e){function t(e){var a,i=e.deviceId,s=e.statLogs;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Oe),a.params={device_id:i,log_entries:s.map((function(e){return at.payloadify(e)}))},a}return c(t,e),i(t)}(Ve),Xi=function(t){function a(e){var t=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:i,requestQueue:s}])}return c(a,t),i(a,[{key:"_isSendable",get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var t=this,n=Object.create(null,{init:{get:function(){return p(a,"init",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.init.call(this,e+".daily");case 2:this.queue=this.logInfo.statLogs.map((function(e){return new at({type:e.stat_type,ts:e.ts,data:e.data})}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this.statConfig.minInterval=864e5,this._mergeQueue(),!t.localCacheStat){n.next=7;break}this.enabledState=t.enabledStat?Pi.ENABLED:Pi.COLLECT_ONLY,n.next=10;break;case 7:return this.enabledState=Pi.DISABLED,n.next=10,this.clear();case 10:if(!this.isEnabled||!this._isSendable){n.next=25;break}return n.next=13,this._getUploadStats();case 13:r=n.sent,a=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),i=0;case 16:if(!(i0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Zi({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Ki,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Pi.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Pi.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}(Wi),Ji=function(t){function a(e){var t=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:i,requestQueue:s}])}return c(a,t),i(a,[{key:"_isSendable",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.queue.length0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new Zi({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Ki,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Pi.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Pi.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}(Wi),$i=function(e){function t(e){var a,i=e.deviceId,s=e.statLogs;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Ue),a.params={device_id:i,log_entries:s.map((function(e){return at.payloadify(e)}))},a}return c(t,e),i(t)}(Ve),es=function(t){function a(e){var t=e.deviceId,i=e.cacheContext,s=e.requestQueue;return r(this,a),n(this,a,[{deviceId:t,cacheContext:i,requestQueue:s}])}return c(a,t),i(a,[{key:"_isSendable",get:function(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval}},{key:"init",value:function(e){var t=this,n=Object.create(null,{init:{get:function(){return p(a,"init",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.init.call(this,e+".realtime");case 2:this.queue=this.logInfo.statLogs.map((function(e){var t;return e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),new at({type:e.stat_type,ts:e.ts,data:e.data})})),this._sentLogStats=this.queue.map((function(e){var t;return{channelUrl:e.data.channelUrl,messageId:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,action:e.data.action}}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setConfig",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.statConfig=e,this._mergeQueue(),!t.notificationStat){n.next=6;break}this.enabledState=t.enabledStat?Pi.ENABLED:Pi.COLLECT_ONLY,n.next=9;break;case 6:return this.enabledState=Pi.DISABLED,n.next=9,this.clear();case 9:if(!this.isEnabled||!this._isSendable){n.next=15;break}return r=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),n.next=13,ki(r);case 13:return n.next=15,this._flush(this.queue);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState!==Pi.DISABLED){t.next=2;break}return t.abrupt("return",!0);case 2:if(n=this.enabledState===Pi.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,!this._isDuplicateStat(e)){t.next=5;break}return t.abrupt("return",!0);case 5:if(n.push(e),this.enabledState===Pi.PENDING){t.next=9;break}return t.next=9,this._save();case 9:if(!this.isEnabled){t.next=15;break}if(this._mergeQueue(),!this.isEnabled||!this._isSendable){t.next=15;break}return t.next=14,this._flush(n);case 14:return t.abrupt("return",t.sent);case 15:return t.abrupt("return",!0);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"_flush",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=!0,!(t.length>0)){n.next=34;break}if(this.isFlushing){n.next=32;break}return this.isFlushing=!0,n.prev=4,a=v(t).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),i=new $i({deviceId:this.deviceId,statLogs:a}),n.next=9,this.requestQueue.send(i);case 9:return this.queue=v(t).slice(a.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=Ki,this.logInfo.lastFlushedAt=Date.now(),n.next=15,this._save();case 15:n.next=29;break;case 17:if(n.prev=17,n.t0=n.catch(4),!(n.t0 instanceof A)){n.next=27;break}if(n.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED){n.next=26;break}return n.next=23,this.clear();case 23:this.enabledState=Pi.DISABLED,n.next=27;break;case 26:n.t0.code===e.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Pi.COLLECT_ONLY);case 27:this.limit=this.limit+20,r=!1;case 29:return n.prev=29,this.isFlushing=!1,n.finish(29);case 32:n.next=35;break;case 34:this.isFlushing=!1;case 35:return n.abrupt("return",r);case 36:case"end":return n.stop()}}),n,this,[[4,17,29,32]])})))}}])}(Wi),ts=function(){return i((function e(t){var n=t.cacheContext,a=t.requestQueue,i=t.dispatcher,s=t.logger;r(this,e),this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._retryCount=0,this.deviceId=ce(),this.cacheContext=n,this.requestQueue=a,this.dispatcher=i,this.logger=s,this._dailyStatCollector=new Xi({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new Ji({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new es({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}),[{key:"_migration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cacheContext.preference.get(this.key);case 2:if(!(t=e.sent)){e.next=18;break}return n=[],t.statLogs.forEach((function(e){e.stat_type===je.FEATURE_LOCALCACHE&&n.push(new at({type:e.stat_type,ts:e.ts,data:e.data}))})),e.next=8,this.cacheContext.preference.set(this.key+".daily",{deviceId:t.deviceId,statLogs:n.map((function(e){return at.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 8:return r=[],t.statLogs.forEach((function(e){e.stat_type!==je.FEATURE_LOCALCACHE&&e.stat_type!==je.NOTIFICATION&&(e.stat_type===je.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),r.push(new at({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=12,this.cacheContext.preference.set(this.key+".default",{deviceId:t.deviceId,statLogs:r.map((function(e){return at.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 12:return a=[],t.statLogs.forEach((function(e){var t;e.stat_type===je.NOTIFICATION&&(e.data=pe(Object.assign(Object.assign({},e.data),{message_id:null!==(t=e.data.notificationId)&&void 0!==t?t:e.data.message_id,notificationId:void 0})),a.push(new at({type:e.stat_type,ts:e.ts,data:e.data})))})),e.next=16,this.cacheContext.preference.set(this.key+".realtime",{deviceId:t.deviceId,statLogs:a.map((function(e){return at.payloadify(e)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt});case 16:return e.next=18,this.cacheContext.preference.remove(this.key);case 18:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this._migration();case 3:return t.next=5,this._dailyStatCollector.init(this.key);case 5:return t.next=7,this._defaultStatCollector.init(this.key);case 7:return t.next=9,this._notificationStatCollector.init(this.key);case 9:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e instanceof $e?(r=e.statLog,this.put(r)):e instanceof fi&&(a=e.request,i=e.features,s=e.options,o=e.statConfigInfo,this._retryCount=0,this._collectRequestStat=a,this._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,this._collectionNotificationStat=null==i?void 0:i.notification,this._statConfig=o,this._dailyStatCollector.setConfig(this._statConfig.default,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:s.ingestion}),this._notificationStatCollector.setConfig(null!==(n=this._statConfig.realTime)&&void 0!==n?n:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:s.ingestion}));case 1:case"end":return t.stop()}}),t,this)})))})));case 10:case"end":return t.stop()}}),t,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=!0,!(e instanceof Yi)){t.next=8;break}if(!this._collectFeatureLocalCacheStat){t.next=6;break}return t.next=5,this._dailyStatCollector.put(e);case 5:n=t.sent;case 6:t.next=26;break;case 8:t.t0=e.type,t.next=t.t0===je.API_RESULT||t.t0===je.WEBSOCKET_CONNECT?11:t.t0===je.FEATURE_LOCALCACHE||t.t0===je.FEATURE_LOCALCACHE_EVENT?16:t.t0===je.NOTIFICATION?21:26;break;case 11:if(!this._collectRequestStat){t.next=15;break}return t.next=14,this._defaultStatCollector.put(e);case 14:n=t.sent;case 15:return t.abrupt("break",26);case 16:if(!this._collectFeatureLocalCacheStat){t.next=20;break}return t.next=19,this._defaultStatCollector.put(e);case 19:n=t.sent;case 20:return t.abrupt("break",26);case 21:if(!this._collectionNotificationStat){t.next=25;break}return t.next=24,this._notificationStatCollector.put(e);case 24:n=t.sent;case 25:return t.abrupt("break",26);case 26:n?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Pi.COLLECT_ONLY,this._defaultStatCollector.enabledState=Pi.COLLECT_ONLY,this._notificationStatCollector.enabledState=Pi.COLLECT_ONLY,this.logger.debug(A.statLogUploadLimitExceededError)));case 27:case"end":return t.stop()}}),t,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}])}(),ns=function(){return i((function e(t){var n=t.limit,a=void 0===n?5:n;r(this,e),this.workersByKey={},this.limit=a}),[{key:"run",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.workersByKey[e]||(this.workersByKey[e]=[]),!(this.workersByKey[e].length0:void 0,i.lastRepliedAt=null!==(c=a.last_replied_at)&&void 0!==c?c:0,i.updatedAt=null!==(l=a.updated_at)&&void 0!==l?l:0,i}return c(t,e),i(t,[{key:"_isUpdateRequired",get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}},{key:"_updateFrom",value:function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((function(e){return li.payloadify(e)})):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}}])}($a);e.ReactionEventOperation=void 0,(rs=e.ReactionEventOperation||(e.ReactionEventOperation={})).ADD="add",rs.DELETE="delete";var hs,fs=i((function t(n){r(this,t),this.messageId=0,this.operation=null,this.updatedAt=0;var a=D("string",n.msg_id)?parseInt(n.msg_id):n.msg_id,i=n.user_id,s=n.operation?n.operation.toLowerCase():null,o=n.reaction,u=n.updated_at;a&&D("string",i)&&D("string",s)&&R(e.ReactionEventOperation,s)&&D("string",o)&&o&&D("number",u)&&(this.messageId=a,this.userId=i,this.key=o,this.operation=s,this.updatedAt=u)})),ps=function(){return i((function e(t){var n;r(this,e);var a=t.key,i=null!==(n=v(t.user_ids))&&void 0!==n?n:[],o=t.updated_at;D("string",a)&&a&&P("string",i)&&i.length>0&&D("number",o)&&(this.key=a,this.userIds=i,this.updatedAt=o);var u,c={},l=s(this.userIds);try{for(l.s();!(u=l.n()).done;){c[u.value]=this.updatedAt}}catch(e){l.e(e)}finally{l.f()}this._version=c}),[{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 pe(ve({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}}])}(),vs=function(){return i((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)}),null,[{key:"payloadify",value:function(e){var t,n;return pe(ve({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}))}}])}(),_s=function(){return i((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 vs(t["og:image"]))}),null,[{key:"payloadify",value:function(e){return pe(ve({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?vs.payloadify(e.defaultImage):null}))}}])}(),ms=function(){return i((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}),[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return pe(ve({name:e.name,volume:e.volume}))}}])}();e.FeedbackRating=void 0,(hs=e.FeedbackRating||(e.FeedbackRating={})).GOOD="good",hs.BAD="bad";var gs,ys=function(){function e(t){r(this,e),this.id=t.id,this.rating=t.rating,this.comment=t.comment}return i(e,null,[{key:"_getStatus",value:function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"}},{key:"_isSubmitted",value:function(t){return"SUBMITTED"===e._getStatus(t)}},{key:"_getPayloadByStatus",value:function(e){return"NO_FEEDBACK"===e?{}:null}},{key:"payloadify",value:function(e){return pe(ve({id:e.id,rating:e.rating,comment:e.comment}))}}])}(),Es=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i])).isBlockedByMe=!1,s.role=R(e.Role,i.role)?i.role:e.Role.NONE,s.isBlockedByMe=null!==(o=i.is_blocked_by_me)&&void 0!==o&&o,s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}])}(li),ks=function(){return i((function e(t){r(this,e),this.key=t.key,this.value=P("string",t.value)?v(t.value):[]}),null,[{key:"payloadify",value:function(e){var t;return pe(ve({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}])}(),bs=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"}},Cs=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;r(this,a),(s=n(this,a,[t])).channelType=e.ChannelType.BASE,s.messageType=e.MessageType.BASE,s.mentionType=null,s.mentionedUsers=null,s.mentionedUserIds=null,s.mentionedMessageTemplate=void 0,s.metaArrays=[],s.extendedMessage={},s.createdAt=0,s.updatedAt=0,s.channelUrl=i.channel_url,s.channelType=R(e.ChannelType,i.channel_type)?i.channel_type:e.ChannelType.GROUP,i.channel&&(i.channel.channel_url&&(s.channelUrl=i.channel.channel_url),i.channel.channel_type&&(s.channelType=i.channel.channel_type)),s.data=null!==(o=i.data)&&void 0!==o?o:"",s.customType=null!==(u=i.custom_type)&&void 0!==u?u:"",s.mentionType=R(e.MentionType,i.mention_type)?i.mention_type:null,s.mentionedUsers=i.mentioned_users?i.mentioned_users.map((function(e){return new li(s._iid,e)})):null,s.mentionedUserIds=null!==(c=i.mentioned_user_ids)&&void 0!==c?c:null,s.mentionedUsers&&!s.mentionedUserIds&&(s.mentionedUserIds=s.mentionedUsers.map((function(e){return e.userId}))),s.mentionedMessageTemplate=i.mentioned_message_template;var _=null!==(l=i.metaarray)&&void 0!==l?l:{},m=null!==(d=i.metaarray_key_order)&&void 0!==d?d:Object.keys(_).sort((function(e,t){return e.localeCompare(t)}));s.metaArrays=[];for(var g=0;g0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,items:e.items.map((function(e){return Xs.payloadify(e)})),version:e.version,is_submitted:e._isSubmitted}))}},{key:"isMessageFormPayload",value:function(e){return Boolean(null==e?void 0:e.message_form)}}])}(),Xs=function(){return i((function e(t){r(this,e);var n=t.id,a=t.name,i=t.required,s=t.sort_order,o=t.placeholder,u=t.style,c=t.item_type,l=t.validators,d=t.value,h=t.values;this.id=n,this.name=a,this.required=i,this.sortOrder=s,this.placeholder=o,0===Object.keys(u).length?this.style={layout:c}:this.style=pe({layout:u.layout,options:u.options,defaultOptions:u.default_options,resultCount:u.result_count}),h?this.submittedValues=h:d&&(this.submittedValues=[d]),this._validators=l}),[{key:"isValid",value:function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case Ds.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&nt.max);case Ds.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case Ds.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.lengtht.max_length);case Ds.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case Ds.DECIMAL_PLACE:if(0===e.length)return!1;var r=Number(e);return!(isNaN(r)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(r,t.max_decimal_place));default:return!0}}))}(e,t._validators);return n}))}}],[{key:"payloadify",value:function(e){return pe(ve({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:pe({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))}}])}(),Js=function(e){function t(e){var a;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Le,"/").concat(e.formId,"/submit"),a.params=pe({message_id:e.messageId,items:e.items}),a}return c(t,e),i(t)}(Ve);e.ScheduledStatus=void 0,(Ws=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",Ws.SENT="sent",Ws.FAILED="failed",Ws.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 $s,eo=function(t){function a(e,t){var i,s,o,u,c,l,d,h,f,p;return r(this,a),(i=n(this,a,[e,t])).parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.threadInfo=null,i.reactions=[],i.appleCriticalAlertOptions=null,i.scheduledInfo=null,i.suggestedReplies=null,i.myFeedback=null,i.myFeedbackStatus="NOT_APPLICABLE",i.messageForm=null,i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(o=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==o?o:0,i.parentMessageId=null!==(u="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==u?u:0,i.threadInfo=t.thread_info?new ds(i._iid,t.thread_info):null,i.reactions=t.reactions?t.reactions.map((function(e){return new ps(e)})):[],i.ogMetaData=t.og_tag?new _s(t.og_tag):null,i.silent=null!==(c=t.silent)&&void 0!==c&&c,i.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,i.appleCriticalAlertOptions=t.apple_critical_alert_options?new ms(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(i.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},i._scheduledStatus=t.scheduled_status),i._isContinuousMessages=null!==(d=t.is_continuous_messages)&&void 0!==d&&d,i.myFeedback=ys._isSubmitted(t.feedback)?new ys(t.feedback):null,i.myFeedbackStatus=ys._getStatus(t.feedback),i.suggestedReplies=null!==(f=null===(h=t.extended_message_payload)||void 0===h?void 0:h.suggested_replies)&&void 0!==f?f:null,i.messageForm=Zs.isMessageFormPayload(t.extended_message_payload)?new Zs(i.messageId,t.extended_message_payload.message_form):null,i.message=null!==(p=t.message)&&void 0!==p?p:"",i}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.messageId===e.messageId}},{key:"applyThreadInfoUpdateEvent",value:function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}},{key:"applyReactionEvent",value:function(e){if(this.messageId===e.messageId){for(var t=!1,n=0;n=t)return this.parentMessage=e,!0}return!1}},{key:"_triggerThreadInfoUpdatedEvent",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=ss.of(this._iid),(r=n.dispatcher).dispatch(new Ks({channelType:e.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),r.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"markThreadAsRead",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Ts({channelUrl:this.channelUrl,messageId:this.messageId}),e.next=4,n.send(r);case 4:if(!this.threadInfo||0===this.threadInfo.unreadReplyCount){e.next=8;break}return this.threadInfo.unreadReplyCount=0,e.next=8,this._triggerThreadInfoUpdatedEvent();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setPushNotificationEnabled",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Is({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),t.next=4,r.send(a);case 4:this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"submitMessageForm",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=ss.of(this._iid),a=r.requestQueue,i=null,s=null,o=this.messageForm,t||!o){n.next=13;break}if(o.isSubmittable){n.next=7;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});case 7:if(!o.isSubmitted){n.next=9;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"The form has already been submitted."});case 9:i=o.id,s=o.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[]),n.next=14;break;case 13:t&&(i=t.formId,s=Object.entries(t.answers).reduce((function(t,n){var r=f(n,2),a=r[0],i=r[1],s=Number(a);if(Number.isNaN(s))throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return t.push({form_item_id:s,value:i}),t}),[]));case 14:if(i&&s){n.next=16;break}throw new A({code:e.SendbirdErrorCode.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});case 16:return u=new Js({messageId:this.messageId,formId:i,items:s}),n.next=19,a.send(u);case 19:case"end":return n.stop()}}),n,this)})))}},{key:"submitFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ns({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(As),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ms({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t.id,rating:t.rating,comment:t.comment}),n.next=4,a.send(s);case 4:o=n.sent,u=o.as(Os),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteFeedback",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Us({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:t}),n.next=4,a.send(s);case 4:this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new Fs({messages:[this],source:e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}));case 7:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?ds.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return ps.payloadify(e)})),og_tag:e.ogMetaData?_s.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?ms.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(t=e.scheduledInfo)||void 0===t?void 0:t.scheduledMessageId,scheduled_at:null===(n=e.scheduledInfo)||void 0===n?void 0:n.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?ys.payloadify(e.myFeedback):ys._getPayloadByStatus(e.myFeedbackStatus),message:e.message})))}},{key:"_getParentMessageInfoPayload",value:function(e){return pe(ve({type:bs(e.messageType),ts:e.createdAt,user:e.sender?Es.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Qs.payloadify(e)})):null}))}}])}(Cs),to=function(t){function a(t,i){var s,o,u,c,l;if(r(this,a),(s=n(this,a,[t,i])).reqId="",s.replyToChannel=!1,s.errorCode=0,s.sender=i.user?new Es(s._iid,i.user):i.sender_id,s.reqId=null!==(u=null!==(o=i.req_id)&&void 0!==o?o:i.request_id)&&void 0!==u?u:"",s.replyToChannel=null!==(c=i.is_reply_to_channel)&&void 0!==c&&c,i.request_state&&R(e.SendingStatus,i.request_state)&&(s.sendingStatus=i.request_state),!s.sendingStatus)if(s.messageId>0)s.sendingStatus=e.SendingStatus.SUCCEEDED;else if(s.scheduledInfo)switch(i.scheduled_status&&(s._scheduledStatus=i.scheduled_status),i.scheduled_status){case Ys.SENT:case Ys.IN_QUEUE:s.sendingStatus=e.SendingStatus.SUCCEEDED;break;case Ys.PENDING:s.sendingStatus=e.SendingStatus.SCHEDULED;break;case Ys.FAILED:case Ys.REMOVED:s.sendingStatus=e.SendingStatus.FAILED;break;case Ys.CANCELED:s.sendingStatus=e.SendingStatus.CANCELED}else s.sendingStatus=e.SendingStatus.PENDING;return s.errorCode=null!==(l=i.error_code)&&void 0!==l?l:0,s._messageToken=i.mesg_token,s}return c(a,t),i(a,[{key:"isResendable",get:function(){return(this.sendingStatus===e.SendingStatus.FAILED||this.sendingStatus===e.SendingStatus.CANCELED)&&((t=this.errorCode)>0&&M.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 pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{user:Es.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))}}])}(eo),no={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ro=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)},ao=function(t){function a(t,i){var s,o,u,c;if(r(this,a),(s=n(this,a,[t,i])).translations={},s.messageType=e.MessageType.ADMIN,s.translations=null!==(o=i.translations)&&void 0!==o?o:{},i.parent_message_info){var l=i.parent_message_info;s.parentMessage=go(t,pe(ve(Object.assign(Object.assign({},l),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:l.file,url:null===(u=l.file)||void 0===u?void 0:u.url,require_auth:null===(c=l.file)||void 0===c?void 0:c.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{translations:e.translations,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(eo),io=function(){return i((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&&D("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}),null,[{key:"payloadify",value:function(e){return pe(ve({type:e.type,vendor:e.vendor,detail:e.detail}))}}])}();!function(e){e.OPEN="open",e.CLOSED="closed"}($s||($s={}));var so,oo="removed",uo=function(e){switch(e){case"open":return $s.OPEN;case"closed":return $s.CLOSED;default:return null}},co=function(e){return!e||!!e.text&&D("string",e.text)},lo=function(e){function t(e,a){var i,s,o,u,c,l,d,h;return r(this,t),(i=n(this,t,[e])).pollId=0,i.id=0,i.text=null,i.voteCount=0,i.createdBy=null,i.createdAt=0,i.updatedAt=0,i._lastVotedAt=0,i.pollId=null!==(s=a.poll_id)&&void 0!==s?s:0,i.id=null!==(o=a.id)&&void 0!==o?o:0,i.text=null!==(u=a.text)&&void 0!==u?u:null,i.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,i.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,i.createdAt=null!==(d=a.created_at)&&void 0!==d?d:0,i.updatedAt=null!==(h=a.updated_at)&&void 0!==h?h:0,i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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})))}}])}($a),ho=function(e){function t(e,a){var i,s,o,u,c,l,d,h,f,p,v,_,m,g;return r(this,t),(i=n(this,t,[e])).id=0,i.title=null,i.createdAt=0,i.updatedAt=0,i.closeAt=-1,i.status=$s.CLOSED,i.messageId=0,i.data=null,i.voterCount=-1,i.options=[],i.createdBy=null,i.allowUserSuggestion=!1,i.allowMultipleVotes=!1,i.votedPollOptionIds=[],i.id=null!==(s=a.id)&&void 0!==s?s:0,i.title=null!==(o=a.title)&&void 0!==o?o:null,i.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,i.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,i.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,i.status=null!==(d=uo(a.status))&&void 0!==d?d:$s.CLOSED,i.messageId=null!==(h=a.message_id)&&void 0!==h?h:0,i.data=null!==(f=a.data)&&void 0!==f?f:null,i.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,i.options=a.options?a.options.map((function(e){return new lo(i._iid,e)})):[],i.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,i.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,i.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,i.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],i}return c(t,e),i(t,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,i,s,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=uo(e.status))&&void 0!==a?a:this.status,this.data=null!==(i=e.data)&&void 0!==i?i:this.data,this.voterCount=null!==(s=e.voter_count)&&void 0!==s?s:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new lo(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var i=t[r];a>=i._lastVotedAt&&(i.voteCount=e.vote_count,i._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0}},{key:"serialize",value:function(){return si(this)}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([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 lo.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}])}($a),fo=function(){return i((function e(t){r(this,e),this.status=t.status,t.original_message_info&&(this.originalMessageInfo={createdAt:t.original_message_info.ts,messageId:t.original_message_info.id})}),null,[{key:"payloadify",value:function(e){return pe({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}])}(),po=function(t){function a(t,i){var o,u,c,l,d,h;if(r(this,a),(o=n(this,a,[t,i])).messageParams=null,o.translations={},o.translationTargetLanguages=[],o.messageSurvivalSeconds=-1,o.plugins=[],o._poll=null,o.messageType=e.MessageType.USER,o.translations=null!==(u=i.translations)&&void 0!==u?u:{},o.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(o.translations).length&&o.translationTargetLanguages.length>0){var f,p=s(o.translationTargetLanguages);try{for(p.s();!(f=p.n()).done;){var v=f.value;o.translations[v]=""}}catch(e){p.e(e)}finally{p.f()}}if(o.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,o.plugins=i.plugins?i.plugins.map((function(e){return new io(e)})):[],o._poll=i.poll?new ho(o._iid,i.poll):null,i.parent_message_info){var _=i.parent_message_info;o.parentMessage=go(t,pe(ve(Object.assign(Object.assign({},_),{created_at:_.ts,message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(o.messageReviewInfo=new fo(i.review_info)),o}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return io.payloadify(e)})),poll:e._poll?ho.payloadify(e._poll):null,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null,review_info:e.messageReviewInfo?fo.payloadify(e.messageReviewInfo):void 0})))}}])}(to),vo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p;if(r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.fileInfoList=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE,s.data=null!==(c=null!==(u=null===(o=i.file)||void 0===o?void 0:o.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",s.fileInfoList=null!==(d=null===(l=i.files)||void 0===l?void 0:l.map((function(e){return new Qs(t,e)})))&&void 0!==d?d:[],s.messageSurvivalSeconds=null!==(h=i.message_survival_seconds)&&void 0!==h?h:-1,i.parent_message_info){var v=i.parent_message_info;s.parentMessage=go(t,pe(ve(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===(f=v.file)||void 0===f?void 0:f.url,require_auth:null===(p=v.file)||void 0===p?void 0:p.require_auth}))))}return s}return c(a,t),i(a,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t,n,r,i,s,o;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{file:{name:null!==(n=null===(t=e.fileInfoList[0])||void 0===t?void 0:t.fileName)&&void 0!==n?n:"",size:null!==(i=null===(r=e.fileInfoList[0])||void 0===r?void 0:r.fileSize)&&void 0!==i?i:0,type:null!==(o=null===(s=e.fileInfoList[0])||void 0===s?void 0:s.mimeType)&&void 0!==o?o:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Qs.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(a,"_getParentMessageInfoPayload",this,2)([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)}}])}(to);!function(e){e.SENT="SENT",e.READ="READ"}(so||(so={}));var _o=function(t){function a(t,i){var s,o,u;if(r(this,a),(s=n(this,a,[t,i])).notificationData=null,s.notificationId=i.notification_message_id,s.messageType=e.MessageType.ADMIN,s.messageStatus=null!==(o=i.message_status)&&void 0!==o?o:so.SENT,s.priority=null!==(u=i.priority)&&void 0!==u?u:se.NORMAL,s.notificationEventDeadline=i.notification_event_deadline,0===s.extendedMessage.sub_type)try{var c=JSON.parse(s.extendedMessage.sub_data),l=c.label,d=c.tags,h=void 0===d?[]:d,f=c.template_key,p=c.template_variables;s.notificationData={label:l,tags:h,templateKey:f,templateVariables:p}}catch(e){}return s}return c(a,t),i(a,[{key:"isIdentical",value:function(e){return this.notificationId===e.notificationId}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))}}])}(Cs),mo=function(t){if(t.notificationId)return _o.payloadify(t);switch(t.messageType){case e.MessageType.USER:return po.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?vo.payloadify(t):yo.payloadify(t);case e.MessageType.ADMIN:return ao.payloadify(t);default:throw A.unknown}},go=function(e,t){if(t.notification_message_id)return new _o(e,t);switch(t.type){case"MESG":return new po(e,t);case"FILE":return vo._isMultipleFilesMessagePayload(t)?new vo(e,t):new yo(e,t);case"ADMM":case"BRDM":return new ao(e,t);default:return null}},yo=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;r(this,a),(s=n(this,a,[t,i])).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var k=i.file;if(s.plainUrl=(null!==(u=null!==(o=null==k?void 0:k.url)&&void 0!==o?o:i.url)&&void 0!==u?u:"").split("?auth=")[0],s.name=null!==(l=null!==(c=null==k?void 0:k.name)&&void 0!==c?c:i.name)&&void 0!==l?l:"File",s.size=null!==(h=null!==(d=null==k?void 0:k.size)&&void 0!==d?d:i.size)&&void 0!==h?h:0,s.data=null!==(p=null!==(f=null==k?void 0:k.data)&&void 0!==f?f:i.custom)&&void 0!==p?p:"",s.type=k?null!==(v=k.type)&&void 0!==v?v:"":null!==(_=i.type)&&void 0!==_?_:"",s.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,s.thumbnails=i.thumbnails?i.thumbnails.map((function(e){var t;return new us(s._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),s.requireAuth)})):[],s.messageSurvivalSeconds=null!==(g=i.message_survival_seconds)&&void 0!==g?g:-1,i.parent_message_info){var b=i.parent_message_info;s.parentMessage=go(t,pe(ve(Object.assign(Object.assign({},b),{created_at:b.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:b.file,url:null===(y=b.file)||void 0===y?void 0:y.url,require_auth:null===(E=b.file)||void 0===E?void 0:E.require_auth}))))}return s}return c(a,t),i(a,[{key:"url",get:function(){var e=ss.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},no),t),ui(this.messageId>0&&D("number",e)&&ro(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){var t;return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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.plainUrl,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(a,"_getParentMessageInfoPayload",this,2)([e.parentMessage]):null})))}}])}(to),Eo=function(e){function t(e,a){var i,s=a.file,o=a.fileUrl,u=a.fileName,c=a.fileSize,l=a.mimeType,d=a.thumbnailSizes,h=a._uploadedMetaData,f=a._thumbnails;return r(this,t),(i=n(this,t,[e]))._plainUrl=o,i.file=s,i.fileName=u,i.fileSize=c,i.mimeType=l,i.thumbnailSizes=d,i._uploadedMetaData=h,i._thumbnails=f,i}return c(t,e),i(t,[{key:"fileUrl",get:function(){var e,t=ss.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e}},{key:"toJSON",value:function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}],[{key:"getPlainUrl",value:function(e){return e instanceof t?e._plainUrl:e.fileUrl}}])}($a),ko=function(t){function a(t){var i,s,o,u;r(this,a);var c=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?c=t.mentionedUserIds:t.mentionedUsers&&(c=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FILE",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,files:t.files?xo(t.files):null,url:t.url,name:null!==(i=t.fileName)&&void 0!==i?i:"",type:null!==(s=t.mimeType)&&void 0!==s?s:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:null===(u=t._thumbnails)||void 0===u?void 0:u.map((function(e){return us.payloadify(e)})),require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:c,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.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,message:t.message}))}])}return c(a,t),i(a)}(We),bo=function(t){function a(t){var i,s,o;r(this,a),i=n(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})))),i.method=_e.POST,i.path="".concat(Pe(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),i.params=pe(ve({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?xo(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===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return us.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return ks.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage})),i}return c(a,t),i(a)}(Ve),Co=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"FILE",i])).message=i.files&&i.files.length>=2?new vo(e,i):new yo(e,i);var d=ss.of(e).sdkState;return s.isMentioned=qe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),wo=function(e){function t(e,a){var i,s,o,u,c;r(this,t),(i=n(this,t,[e,a])).message=a.files&&a.files.length>=2?new vo(e,a):new yo(e,a);var l=ss.of(e).sdkState;return i.isMentioned=qe(i.message.mentionType,null!==(u=null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:null===(o=i.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),i.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,i}return c(t,e),i(t)}(ze);function xo(e){return e.map((function(e){var t,n;return pe(ve({url:Eo.getPlainUrl(e),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 us.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var So;!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"}(So||(So={}));var To=function(){return i((function e(t,n){var a=this,i=n.sdkState,s=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._iid=t,this._sdkState=i,this._requestQueue=o,this._cacheContext=c,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof Ha&&(a._connectionState=e.stateType)})),this._onlineDetector=u}),[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===Da.CONNECTED||this._connectionState===Da.CONNECTING||this._connectionState===Da.RECONNECTING}},{key:"_sendFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=this._createSendFileMessageRequestParams(e,t),!this._shouldSendThroughWebSocket){n.next=10;break}return a=new ko(r),n.next=5,this._requestQueue.send(a);case 5:return i=n.sent,s=i.as(Co),o=s.message,n.abrupt("return",o);case 10:return u=new bo(Object.assign(Object.assign({},r),{userId:this._sdkState.userId})),n.next=13,this._requestQueue.send(u);case 13:return c=n.sent,l=c.as(wo),h=l.message,n.abrupt("return",h);case 16:case"end":return n.stop()}}),n,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(t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(a=this._queueMap.get(t.url))){r.next=58;break}if(a.isResolving){r.next=57;break}a.isResolving=!0,i=[],o=!0,u=s(a.messageQueue),r.prev=7,u.s();case 9:if((c=u.n()).done){r.next=40;break}l=c.value,r.t0=l.state,r.next=r.t0===So.PENDING||r.t0===So.UPLOADING?14:r.t0===So.UPLOADED?17:r.t0===So.FAILED?35:38;break;case 14:return o=!1,i.push(l),r.abrupt("break",38);case 17:if(!o){r.next=33;break}return r.prev=18,l.state=So.SENDING,r.next=22,this._sendFileMessage(t,l);case 22:return h=r.sent,l.deferred.resolve(h),r.next=26,ki(100);case 26:r.next=31;break;case 28:r.prev=28,r.t1=r.catch(18),l.deferred.reject(r.t1);case 31:r.next=34;break;case 33:i.push(l);case 34:return r.abrupt("break",38);case 35:return f=null!==(n=l.error)&&void 0!==n?n:A.unknown,l.deferred.reject(f.code===e.SendbirdErrorCode.REQUEST_CANCELED?A.fileUploadCanceled:f),r.abrupt("break",38);case 38:r.next=9;break;case 40:r.next=45;break;case 42:r.prev=42,r.t2=r.catch(7),u.e(r.t2);case 45:return r.prev=45,u.f(),r.finish(45);case 48:if(p=a.isResolveRequestPending,a.messageQueue=i,a.isResolving=!1,a.isResolveRequestPending=!1,!p){r.next=55;break}return r.next=55,this._resolveMessageQueue(t);case 55:r.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return r.stop()}}),r,this,[[7,42,45,48],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(r=this._queueMap.get(e.url))){n.next=30;break}if(!(a=r.messageQueue.find((function(e){return e.state===So.PENDING})))){n.next=30;break}if(!a.multipleFileUploadInfo){n.next=19;break}if(i=a.multipleFileUploadInfo,s=i.uploadIndex,o=i.uploadCount,u=i.requestHandler,c=a.params,l=c.fileInfoList[s],!H(l.file)||(null===(t=l._uploadedMetaData)||void 0===t?void 0:t.isUploaded)){n.next=13;break}return n.next=11,this._tryUploadNextItemAndUpdateItemState(e,r,a);case 11:n.next=14;break;case 13:a.state=s=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=new cs({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),s.next=3,this._requestQueue.send(o);case 3:u=s.sent,c=u.as(ls),l=c.url,h=c.fileSize,f=void 0===h?n.fileSize:h,p=c.thumbnails,v=void 0===p?[]:p,_=c.requireAuth,m=void 0!==_&&_,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i:n.file.size,n.fileUrl=l,n.fileSize=f,n.requireAuth=m,n._thumbnails=v;case 12:case"end":return s.stop()}}),s,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[o],c=new cs({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),s.next=5,this._requestQueue.send(c);case 5:l=s.sent,h=l.as(ls),f=h.url,p=h.fileSize,v=void 0===p?u.fileSize:p,_=h.thumbnails,m=h.requireAuth,g=void 0!==m&&m,u.fileName=null!==(r=u.fileName)&&void 0!==r?r: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=f,u.fileSize=v,u._thumbnails=_,u._uploadedMetaData=Object.assign(Object.assign({},u._uploadedMetaData),{requireAuth:g,isUploaded:!0}),u instanceof Eo||(n.fileInfoList[o]=new Eo(this._iid,u));case 16:case"end":return s.stop()}}),s,this)})))}},{key:"request",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),o=new ut,u={requestId:t,params:n,state:So.PENDING,deferred:o},Io(n)&&(c=n,l=Object.assign({uploadIndex:0,uploadCount:c.fileInfoList.length},r),u.multipleFileUploadInfo=l),s.messageQueue.push(u),this._uploadNextPendingItem(e),a.abrupt("return",o.promise);case 8:case"end":return a.stop()}}),a,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}))]:v(n.messageQueue),i=s(a);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o)switch(o.state){case So.PENDING:if(o.state=So.FAILED,o.error=A.requestCanceled,o.multipleFileUploadInfo&&!o.multipleFileUploadInfo.isCopy){var u=o.multipleFileUploadInfo,c=u.uploadIndex,l=u.requestHandler,d=o.params.fileInfoList[c];null==l||l._triggerOnFileUploaded(o.requestId,c,d,A.fileUploadCanceled)}this._resolveMessageQueue(e);break;case So.UPLOADING:this._requestQueue.cancel(o.requestId),this._dispatcher.dispatch(new ct({requestId:o.requestId}))}}}catch(e){i.e(e)}finally{i.f()}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new ct({requestId:t})))}}])}();function Io(e){return"fileInfoList"in e}var No,Ao={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},Mo=function(t){return D("number",t.prevResultSize)&&D("number",t.nextResultSize)&&D("boolean",t.isInclusive)&&D("boolean",t.reverse)&&D("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&P("string",t.customTypesFilter,!0)&&P("string",t.senderUserIdsFilter,!0)&&R(e.ReplyType,t.replyType)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeReactions)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)&&D("boolean",t.showSubchannelMessagesOnly)},Oo={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Uo=function(t){return R(e.ReplyType,t.replyType)&&D("boolean",t.includeReactions)&&D("boolean",t.includeMetaArray)&&D("boolean",t.includeParentMessageInfo)&&D("boolean",t.includeThreadInfo)},Do=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:d,include_poll_details:!0},a}return c(t,e),i(t)}(Ve),Ro=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?go(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(ze),Lo=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,d=e.isInclusive,h=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,E=e.includeThreadInfo,k=e.includeParentMessageInfo,b=e.showSubchannelMessagesOnly,C=e.checkingHasNext,w=e.checkingContinuousMessages;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages"),a.params=pe(ve({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,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:E,include_parent_message_info:k,show_subchannel_message_only:b,include_poll_details:!0,checking_has_next:C,checking_continuous_messages:w})),a}return c(t,e),i(t)}(Ve),Po=function(e){function t(e,a){var i;return r(this,t),i=n(this,t,[e,a]),void 0!==a.is_continuous_messages&&(i.isContinuousMessages=a.is_continuous_messages),void 0!==a.has_next&&(i.hasNext=a.has_next),i.messages=a.messages.map((function(t){return go(e,t)})),i}return c(t,e),i(t)}(ze),Fo=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,d=e.includeReactions,h=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:d,include_thread_info:h,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return c(t,e),i(t)}(Ve),qo=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedMessages=a.updated.map((function(t){return go(e,t)})),i.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(ze),Ho=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledMessageId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s)),a.params={},a}return c(t,e),i(t)}(Ve),Go=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=a?go(e,Object.assign({},a)):null,i}return c(t,e),i(t)}(ze);e.RestrictionType=void 0,(No=e.RestrictionType||(e.RestrictionType={})).MUTED="muted",No.BANNED="banned";var jo=function(){return i((function t(n){var a,i,s,o;r(this,t),this.restrictionType=null,R(e.RestrictionType,n.restriction_type)&&(this.restrictionType=n.restriction_type),this.description=null!==(a=n.description)&&void 0!==a?a:null,this.endAt=null!==(s=null!==(i=n.end_at)&&void 0!==i?i:n.muted_end_at)&&void 0!==s?s:-1,this.remainingDuration=null!==(o=n.remaining_duration)&&void 0!==o?o:-1}),null,[{key:"payloadify",value:function(e){return pe(ve({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}])}(),Vo=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).restrictionInfo=new jo(a),i}return c(t,e),i(t,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(t,"payloadify",this,2)([e])),jo.payloadify(e.restrictionInfo))))}}])}(li),zo=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.isMuted=null!==(s=a.is_muted)&&void 0!==s&&s,i}return c(t,e),i(t)}(li),Bo=function(){return i((function e(){r(this,e),this._onPending=ft,this._onFailed=ft,this._onSucceeded=ft}),[{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}}])}(),Qo={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},Ko=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(li,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(ks,t.metaArrays,!0)&&D("number",t.parentMessageId,!0)&&D("boolean",t.isReplyToChannel)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ms,t.appleCriticalAlertOptions,!0)&&D("boolean",t.isPinnedMessage,!0)},Wo=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Yo=Object.assign(Object.assign({},Qo),{message:"",translationTargetLanguages:void 0,pollId:void 0,extendedMessagePayload:void 0});function Zo(t){var n,r,a;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(t.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var Xo,Jo=function(e){var t;return pe(ve({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),extendedMessagePayload:e.extendedMessagePayload}))},$o=function(e){return Ko(e)&&D("string",e.message)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)&&D("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Xo||(Xo={}));var eu=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},tu=function(e){return e===Xo.BLOB||e===Xo.FILE},nu=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},ru=Object.assign(Object.assign({},Qo),{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,message:void 0});function au(t){var n,r,a,i;return null!==(n=t.messageParams)&&void 0!==n?n:ve(Object.assign(Object.assign({},t),{fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.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,_thumbnails:t.thumbnails,message:t.message}))}var iu,su=function(e,t){var n;return e.messageParams?(!e.url&&H(t)&&(e.messageParams.file=t),e.messageParams):pe(ve({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}})),message:e.message}))},ou=function(e){return Ko(e)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&D("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},uu={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},cu=function(t){return D("string",t.data,!0)&&D("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&P("string",t.mentionedUserIds,!0)&&P(li,t.mentionedUsers,!0)&&D("string",t.mentionedMessageTemplate,!0)&&P(ks,t.metaArrays,!0)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&D(ms,t.appleCriticalAlertOptions,!0)},lu=Object.assign(Object.assign({},uu),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),du=function(e){return cu(e)&&D("string",e.message,!0)&&P("string",e.translationTargetLanguages,!0)&&D("number",e.pollId,!0)},hu=Object.assign({},uu),fu=function(e){return cu(e)},pu=function(){return i((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}),[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return D("number",this.limit)&&this.limit>0}}])}(),vu=function(t){function a(e,t,i,s){var o;return r(this,a),(o=n(this,a,[e,s])).channelUrl=t,o.channelType=i,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl)&&R(e.ChannelType,this.channelType)}}])}(pu),_u=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={token:o,limit:u},a}return c(t,e),i(t)}(Ve),mu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).operators=a.operators.map((function(t){return new li(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(ze),gu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=ss.of(this._iid),r=n.requestQueue,a=new _u(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(mu),o=s.operators,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(vu),yu=function(t){function a(t,i,s,o){var u,c,l,d,h,f,p,v,_,m,g;return r(this,a),(u=n(this,a,[t,i,s,o])).reverse=!1,u.messageTypeFilter=e.MessageTypeFilter.ALL,u.customTypesFilter=null,u.senderUserIdsFilter=null,u.replyType=e.ReplyType.NONE,u.includeMetaArray=!1,u.includeReactions=!1,u.includeParentMessageInfo=!1,u.includeThreadInfo=!1,u.showSubchannelMessagesOnly=!1,u._edge=Number.MAX_SAFE_INTEGER,u.reverse=null!==(c=o.reverse)&&void 0!==c&&c,u.messageTypeFilter=null!==(l=o.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,u.customTypesFilter=null!==(d=o.customTypesFilter)&&void 0!==d?d:null,u.senderUserIdsFilter=null!==(h=o.senderUserIdsFilter)&&void 0!==h?h:null,u.replyType=null!==(f=o.replyType)&&void 0!==f?f:e.ReplyType.NONE,u.includeMetaArray=null!==(p=o.includeMetaArray)&&void 0!==p&&p,u.includeReactions=null!==(v=o.includeReactions)&&void 0!==v&&v,u.includeParentMessageInfo=null!==(_=o.includeParentMessageInfo)&&void 0!==_&&_,u.includeThreadInfo=null!==(m=o.includeThreadInfo)&&void 0!==m&&m,u.showSubchannelMessagesOnly=null!==(g=o.showSubchannelMessagesOnly)&&void 0!==g&&g,u}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.reverse)&&R(e.MessageTypeFilter,this.messageTypeFilter)&&R(e.ReplyType,this.replyType)&&P("string",this.customTypesFilter,!0)&&P("string",this.senderUserIdsFilter,!0)&&D("boolean",this.includeMetaArray)&&D("boolean",this.includeReactions)&&D("boolean",this.includeParentMessageInfo)&&D("boolean",this.includeThreadInfo)&&D("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,t=oh.of(this._iid),e.next=7,t.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,ve({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));case 7:return n=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(v(n.map((function(e){return e.createdAt}))))),this._hasNext=n.length>=this.limit,this._isLoading=!1,e.abrupt("return",n);case 12:return e.abrupt("return",[]);case 15:throw A.queryInProgress;case 16:e.next=19;break;case 18:throw A.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}])}(vu),Eu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={limit:o,token:u},a}return c(t,e),i(t)}(Ve),ku=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).mutedUsers=[];var s=a.next,o=a.muted_list;return i.token=s,o&&o.length>0&&(i.mutedUsers=o.map((function(t){return new Vo(e,t)}))),i}return c(t,e),i(t)}(ze),bu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Eu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(ku),s=i.mutedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),Cu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({limit:o,token:u}),a}return c(t,e),i(t)}(Ve),wu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).bannedUsers=[];var s=a.next,o=a.banned_list;return i.token=s,o&&o.length>0&&(i.bannedUsers=o.map((function(t){return new Vo(e,t.user)}))),i}return c(t,e),i(t)}(ze),xu=function(e){function t(e,a,i,s){return r(this,t),n(this,t,[e,a,i,s])}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Cu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(wu),s=i.bannedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu);e.ReportCategory=void 0,(iu=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",iu.HARASSING="harassing",iu.SUSPICIOUS="suspicious",iu.INAPPROPRIATE="inappropriate";var Su=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(Ve),Tu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return c(t,e),i(t)}(Ve),Iu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute/").concat(o),a}return c(t,e),i(t)}(Ve),Nu=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).isMuted=!1,i.startAt=0,i.endAt=0;var s=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return i.isMuted=s,i.startAt=o,i.endAt=u,i.remainingDuration=c,i.description=l,i}return c(t,e),i(t)}(ze),Au=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={keys:o,include_ts:!0},a}return c(t,e),i(t)}(Ve),Mu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(ze),Ou=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0},a}return c(t,e),i(t)}(Ve),Uu=function(e){function t(e,a){var i,s,o;return r(this,t),(i=n(this,t,[e,a])).metaData=null!==(s=a.metadata)&&void 0!==s?s:{},i.ts=null!==(o=a.ts)&&void 0!==o?o:null,i}return c(t,e),i(t)}(ze),Du=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metadata,u=e.upsert;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return c(t,e),i(t)}(Ve),Ru=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return c(t,e),i(t)}(ze),Lu=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),Pu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(o),a.params={include_ts:!0},a}return c(t,e),i(t)}(Ve),Fu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(ze),qu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={include_ts:!0},a}return c(t,e),i(t)}(Ve),Hu=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts;return i.ts=s,i}return c(t,e),i(t)}(ze),Gu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={keys:o},a}return c(t,e),i(t)}(Ve),ju=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(ze),Vu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o},a}return c(t,e),i(t)}(Ve),zu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(ze),Bu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,d=void 0===l?"set":l;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o,upsert:c,mode:d},a}return c(t,e),i(t)}(Ve),Qu=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).metaCounter=a,i}return c(t,e),i(t)}(ze),Ku=function(e){function t(e,a,i){var s;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return c(t,e),i(t)}(Ke),Wu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(o),a.params={},a}return c(t,e),i(t)}(Ve),Yu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={},a}return c(t,e),i(t)}(Ve),Zu=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return c(t,e),i(t)}(Ve),Xu=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),s}return c(t,e),i(t)}(Ke),Ju=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(Ve),$u=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),s}return c(t,e),i(t)}(Ke),ec=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=pe({user_id:o,seconds:u,description:c}),a}return c(t,e),i(t)}(Ve),tc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),i.data.member_count&&(s.memberCount=i.data.member_count),i.data.joined_member_count&&(s.joinedMemberCount=i.data.joined_member_count),s}return c(t,e),i(t)}(Ke),nc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(Ve),rc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new Vo(e,i.data),s}return c(t,e),i(t)}(Ke),ac=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.freezing;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Pe(s),"/").concat(encodeURIComponent(i),"/freeze"),a.params={freeze:o},a}return c(t,e),i(t)}(Ve),ic=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).freeze=i.data.freeze,s}return c(t,e),i(t)}(Ke),sc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=n(this,t)).method=_e.POST,a.path="".concat(Fe(s),"/").concat(encodeURIComponent(i)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return c(t,e),i(t)}(Ve),oc=function(t){function a(t){var i;r(this,a);var s=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,d=t.description;return(i=n(this,a)).method=_e.POST,i.path="".concat(Se,"/users/").concat(l),i.params={channel_url:s,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:d},i}return c(a,t),i(a)}(Ve),uc=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,d=e.description,h=e.messageToken;return(a=n(this,t)).method=_e.POST,a.path="".concat(Fe(s),"/").concat(encodeURIComponent(i),"/messages/").concat(l),a.params=pe({report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c,mesg_token:h}),a}return c(t,e),i(t)}(Ve),cc=function(t){function a(t){r(this,a);var i=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MESG",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:i,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,extended_message_payload:t.extendedMessagePayload}))}])}return c(a,t),i(a)}(We),lc=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"MESG",i])).message=new po(e,i);var d=ss.of(e).sdkState;return s.isMentioned=qe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),dc=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"MEDI",ackRequired:!0,payload:pe(ve({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))}])}return c(a,t),i(a)}(We),hc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"MEDI",i])).message=new po(e,i);var h=ss.of(e).sdkState;return s.mentionCountChange=He({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),fc=function(t){function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n(this,a,[{code:"FEDI",ackRequired:!0,payload:pe(ve({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:i,apple_critical_alert_options:t.appleCriticalAlertOptions}))}])}return c(a,t),i(a)}(We),pc=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"FEDI",i])).message=new yo(e,i);var h=ss.of(e).sdkState;return s.mentionCountChange=He({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),vc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(Ve),_c=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new fs(a),i}return c(t,e),i(t)}(ze),mc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return c(t,e),i(t)}(Ve),gc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).reactionEvent=new fs(Object.assign({},a)),i}return c(t,e),i(t)}(ze),yc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return c(t,e),i(t)}(Ve),Ec=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new po(e,a),i}return c(t,e),i(t)}(ze),kc=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.POST,i.path="".concat(Pe(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(Ve),bc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new po(e,a),i}return c(t,e),i(t)}(ze),Cc=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl;return i.method=_e.POST,i.path="".concat(Pe(c),"/").concat(encodeURIComponent(l),"/scheduled_messages"),i.params=ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return us.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),i}return c(a,t),i(a)}(Ve),wc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new yo(e,a),i}return c(t,e),i(t)}(ze),xc=function(e){return D("string",e.title,!0)&&co(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0)},Sc=function(e){function t(e){var a,i=e.pollId,s=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a.params={title:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(Ve),Tc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Ic=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(Ve),Nc=function(e){function t(e){var a,i=e.pollId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/close"),a}return c(t,e),i(t)}(Ve),Ac=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Mc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.optionText;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:i,channel_type:s,text:u},a}return c(t,e),i(t)}(Ve),Oc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Uc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId,o=e.optionText;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a.params={text:o},a}return c(t,e),i(t)}(Ve),Dc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Rc=function(e){function t(e){var a,i=e.pollId,s=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),Lc=function(t){function a(t){var i=t.reqId,s=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n(this,a,[{code:"VOTE",ackRequired:!0,payload:pe({req_id:i,channel_type:s===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})}])}return c(a,t),i(a)}(We),Pc=i((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})),Fc=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"VOTE",i])).event=new Pc(i),s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),qc=function(e){function t(e){var a,i=e.title,s=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=Ne,a.params={title:i,options:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return c(t,e),i(t)}(Ve),Hc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Gc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(Ve),jc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).poll=new ho(e,a),i}return c(t,e),i(t)}(ze),Vc=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:i,channel_type:s},a}return c(t,e),i(t)}(Ve),zc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pollOption=new lo(e,a),i}return c(t,e),i(t)}(ze),Bc=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/polls/changelogs"),a.params=pe({change_ts:o,token:u}),a}return c(t,e),i(t)}(Ve),Qc=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedPolls=a.updated.map((function(t){return function(e,t){return new ho(e,t)}(e,t)})),i.deletedPollIds=a.deleted.map((function(e){return e})),i.hasMore=a.has_more,i.nextToken=a.next,i}return c(t,e),i(t)}(ze),Kc={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Wc=function(e){return D("string",e.title)&&(t=e.optionTexts,P("string",t)&&t.every((function(e){return""!==e.trim()})))&&co(e.data)&&D("boolean",e.allowUserSuggestion,!0)&&D("boolean",e.allowMultipleVotes,!0)&&D("number",e.closeAt,!0);var t},Yc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},Zc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)&&t.pollId>0&&D("number",t.pollOptionId)&&t.pollOptionId>0},Xc={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},Jc=function(t){return D("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&D("number",t.pollId)},$c={},el=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,u=n.logger;r(this,e),this._iid=t,this._sdkState=a,this._sessionManager=s,this._requestQueue=o,this._dispatcher=i,this._logger=u,$c[t]=this}),[{key:"buildPollFromSerializedData",value:function(e){var t=oi(e);return new ho(this._iid,ho.payloadify(t))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(Jc(e)).throw(A.invalidParameters),n=new Gc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(jc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(Wc(e)).throw(A.invalidParameters),n=new qc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(Hc),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(Zc(e)).throw(A.invalidParameters),n=new Vc(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(zc),i=a.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogs",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.SYNC_POLL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Bc(ve({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null})),e.next=3,this._requestQueue.send(i);case 3:return s=e.sent,o=s.as(Qc),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,u.length>0&&this._dispatcher.dispatch(new Vs({polls:u,source:a})),e.abrupt("return",{updatedPolls:u,deletedPollIds:c,hasMore:l,token:h});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return $c[e]}}])}(),tl="GroupChannel",nl="Message",rl="NotificationMessage",al=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=Ne,a.params={channel_url:i,channel_type:s,token:o,limit:u},a}return c(t,e),i(t)}(Ve),il=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).polls=(null!==(s=a.polls)&&void 0!==s?s:[]).map((function(t){return new ho(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(ze),sl=function(e){function t(e,a){return r(this,t),n(this,t,[e,a.channelUrl,a.channelType,a])}return c(t,e),i(t,[{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new al(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(il),s=i.polls,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),ol=function(e){function t(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:i,channel_type:s,token:c,limit:l},a}return c(t,e),i(t)}(Ve),ul=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).voters=(null!==(s=a.voters)&&void 0!==s?s:[]).map((function(t){return new li(e,t)})),i.token=a.next,i}return c(t,e),i(t)}(ze),cl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a.channelUrl,a.channelType,a])).pollId=a.pollId,i.pollOptionId=a.pollOptionId,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("number",this.pollId)&&D("number",this.pollOptionId)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new ol(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(ul),s=i.voters,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu);var ll,dl=Object.assign(Object.assign({},Qo),{fileInfoList:[],message:""}),hl=function(e){return(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},fl=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._onFileUploaded=ft,e}return c(t,e),i(t,[{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(t,"onPending",this,3)([e]),this}},{key:"onFailed",value:function(e){return p(t,"onFailed",this,3)([e]),this}},{key:"onSucceeded",value:function(e){return p(t,"onSucceeded",this,3)([e]),this}}])}(Bo),pl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e])).message=null,i.message=go(e,a.message),i}return c(t,e),i(t)}($a),vl=function(e){function t(e){var a;r(this,t);var i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,d=e.includeParentMessageInfo,h=e.includeThreadInfo,f=e.includePollDetails;return(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/pinned_messages"),a.params=pe({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),a}return c(t,e),i(t)}(Ve),_l=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.pinned_messages,o=a.has_more,u=a.next;return i.pinnedMessages=s.map((function(t){return new pl(e,t)})),i.hasMore=o,i.token=u,i}return c(t,e),i(t)}(ze),ml=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s])).includeMetaArray=s.includeMetaArray,o.includeReactions=s.includeReactions,o.includeParentMessageInfo=s.includeParentMessageInfo,o.includeThreadInfo=s.includeThreadInfo,o.includePollDetails=s.includePollDetails,o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeMetaArray,!0)&&D("boolean",this.includeReactions,!0)&&D("boolean",this.includeParentMessageInfo,!0)&&D("boolean",this.includeThreadInfo,!0)&&D("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new vl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(_l),s=i.pinnedMessages,o=i.hasMore,u=i.token,this._token=u,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(vu),gl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(Ve),yl=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return c(t,e),i(t)}(Ve);!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(ll||(ll={}));var El,kl=function(t){function a(t,i){var s,o,u,c,l,d,h,f;return r(this,a),(s=n(this,a,[t]))._name="",s._createdAt=0,s.pinnedMessageIds=[],s.channelType=e.ChannelType.BASE,s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s._messageCollectionLastAccessedAt=0,s._url=i.channel_url,s._name=null!==(o=i.name)&&void 0!==o?o:"",s._createdAt=1e3*i.created_at,s.coverUrl=null!==(u=i.cover_url)&&void 0!==u?u:"",s.customType=null!==(c=i.custom_type)&&void 0!==c?c:"",s.data=null!==(l=i.data)&&void 0!==l?l:"",s.isFrozen=null!==(d=i.freeze)&&void 0!==d&&d,s.isEphemeral=null!==(h=i.is_ephemeral)&&void 0!==h&&h,s.creator=i.created_by?new li(s._iid,i.created_by):null,i.metadata&&Object.keys(i.metadata).length>0&&i.ts?(s._cachedMetaData=new Map,Object.keys(i.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:i.metadata[e],isRemoved:!1,updatedAt:i.ts})}))):"string"==typeof i.metadata&&(s._cachedMetaData=new Map(Object.entries(JSON.parse(i.metadata)))),s.pinnedMessageIds=null!==(f=i.pinned_message_ids)&&void 0!==f?f:[],s}return c(a,t),i(a,[{key:"url",get:function(){return this._url}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"createdAt",get:function(){return this._createdAt}},{key:"toJSON",value:function(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}},{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"isFeedChannel",value:function(){return this.channelType===e.ChannelType.FEED}},{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:"_serializeCachedMetaData",value:function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=pe(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:"_updateCachedMetaData",value:function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(a,i){var s;a.updatedAt<=t&&(n._cachedMetaData.set(i,{value:null!==(s=e[i])&&void 0!==s?s:a.value,isRemoved:!e[i],updatedAt:t}),r=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})),r=!0),{isUpdated:r}}},{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 gu(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new bu(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new xu(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yu(this._iid,this.url,this.channelType,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ml(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Su({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"removeOperators",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Tu({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyMutedInfo",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Iu({channelUrl:this.url,channelType:this.channelType,userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Nu),o=s.isMuted,u=s.startAt,c=s.endAt,l=s.remainingDuration,h=s.description,e.abrupt("return",{isMuted:o,startAt:u,endAt:c,remainingDuration:l,description:h});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Au({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(Mu),o=s.metadata,u=s.ts,this._upsertCachedMetaData(o,u),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Au({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Mu),s=i.metadata,o=i.ts,this._updateCachedMetaData(s,o),e.abrupt("return",s);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Ou({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Uu),o=s.metaData,this._upsertCachedMetaData(o,0),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=new Du({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Ru),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Pu({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:i=t.sent,s=i.as(Fu),o=s.ts,this._removeFromCachedMetaData([e],o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new qu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Hu),s=i.ts,this._removeFromCachedMetaData(v(this._cachedMetaData.keys()),s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Gu({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(ju),o=s.metaCounter,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Gu({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(ju),s=i.metaCounter,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Vu({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(zu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaCounters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=new Bu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Qu),u=o.metaCounter,n.abrupt("return",u);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Bu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Qu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Bu({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Qu),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Wu({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaCounters",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Yu({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.muteUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"muteUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new Zu({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unmuteUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new Ju({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"banUser",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.banUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"banUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",e)&&D("number",t,!0)&&D("string",n,!0)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new ec({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unbanUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unbanUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new nc({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"freeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new ac({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,n.send(r);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new ac({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,n.send(r);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Ao),t),ui(D("number",e)&&Mo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessagesByMessageId(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Ao),t),ui(D("number",e)&&Mo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessagesByTimestamp(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Oo),t),ui(D("number",e)&&Uo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Oo),t),ui(D("string",e)&&Uo(r)).throw(A.invalidParameters),a=oh.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,i=ss.of(this._iid).sessionManager;return pe(ve({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 ks.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:i.currentUser?Es.payloadify(i.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 li.payloadify(e)}))}))}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var i,o=s(t.translationTargetLanguages);try{for(o.s();!(i=o.n()).done;){a[i.value]=""}}catch(e){o.e(e)}finally{o.f()}}var u=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a,extended_message_payload:t.extendedMessagePayload})),c=new po(this._iid,u);return c.messageParams=t,c}},{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,i,s,o,u,c,l,d=pe(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===(i=t.file)||void 0===i?void 0:i.name,size:null!==(s=t.fileSize)&&void 0!==s?s: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:null===(l=t._thumbnails)||void 0===l?void 0:l.map((function(e){return us.payloadify(e)})),message:t.message})),h=new yo(this._iid,d);return h.messageParams=t,h}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=pe(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,file:t.fileInfoList.length>0?{name:t.fileInfoList[0].fileName,size:t.fileInfoList[0].fileSize,type:t.fileInfoList[0].mimeType,data:t.data}:void 0,message:t.message})),i=new vo(this._iid,a);return i.messageParams=t,i}},{key:"_validateFailedFileMessageHasFile",value:function(e,t){var n;return Boolean(e.url)||H(t)||H(null===(n=e.messageParams)||void 0===n?void 0:n.file)}},{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.SendbirdErrorCode.REQUEST_CANCELED||n.code===e.SendbirdErrorCode.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({},Yo),e);return ui($o(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ll.SEND,a=arguments.length>2?arguments[2]:void 0,i=ss.of(this._iid),s=i.dispatcher,o=i.requestQueue,u=null!=a?a:this._generateRequestId(),c=Date.now(),l=new Bo;return ki(2).then((function(){var a=n._createPendingUserMessage(t,u,c);s.dispatch(new Fs({messages:[a],source:r===ll.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a));case 1:case"end":return e.stop()}}),e)})))}));var i=new cc(Object.assign(Object.assign({},t),{channelUrl:n.url,channelType:n.channelType,reqId:u}));o.send(i).then((function(t){var r=t.as(lc).message;s.dispatch(new Fs({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().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)})))}))})).catch((function(r){if(N(r))throw r;ki(2).then((function(){var a=n._createPendingUserMessage(t,u,c),i=ss.of(n._iid).cacheContext,o=i.localCacheEnabled&&i.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,o),s.dispatch(new Fs({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),l}},{key:"_autoResendUserMessage",value:function(e){return ui(e instanceof po&&!!e.messageParams).throw(A.invalidParameters),this._sendUserMessage(e.messageParams,ll.SEND,e.reqId)}},{key:"resendUserMessage",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof po&&!e.scheduledInfo).throw(A.invalidParameters),r=new ut,a=null!==(t=e.messageParams)&&void 0!==t?t:Jo(e),this._sendUserMessage(a,ll.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"updateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},lu),t),ui(D("number",e)&&du(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new dc(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(hc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"copyUserMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ui(t instanceof a&&n instanceof po&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),ui(!n.poll).throw(A.notSupportedError),u=new ut,c=null!==(r=n.messageParams)&&void 0!==r?r:ve(Object.assign(Object.assign({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(s=n.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),t._sendUserMessage(c).onSucceeded((function(e){u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 6:case"end":return o.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof po&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new yc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(Ec),u=o.message,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_createScheduledUserMessage",value:function(e,t){var n=this,r=ss.of(this._iid).requestQueue,a=Date.now(),i=this._generateRequestId();ki(2).then((function(){var r=n._createPendingScheduledUserMessage(e,i,a);_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))}));var s=new kc(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(bc).message;_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;ki(2).then((function(){var s=n._createPendingScheduledUserMessage(e,i,a);n._markMessageAsFailed(s,r),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},ru),e);return ui(ou(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},dl),e),r=ss.of(this._iid);ui(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return Ko(e)&&D("string",e.message,!0)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return hl(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 ui(!a).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ll.SEND,a=arguments.length>2?arguments[2]:void 0,i=ss.of(this._iid).dispatcher,s=oh.of(this._iid).fileMessageQueue,o=null!=a?a:this._generateRequestId(),u=Date.now(),c=new Bo;return ki(2).then((function(){var a=n._createPendingFileMessage(t,o,u);i.dispatch(new Fs({messages:[a],source:r===ll.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a));case 1:case"end":return e.stop()}}),e)})))})),s.request(n,o,t).then((function(t){i.dispatch(new Fs({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(N(r))throw r;ki(2).then((function(){var a=n._createPendingFileMessage(t,o,u),s=ss.of(n._iid).cacheContext,l=s.localCacheEnabled&&s.localCacheConfig.enableAutoResend&&q(r.code);n._markMessageAsFailed(a,r,l),i.dispatch(new Fs({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:r.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),_i((function(){return E(n,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_autoResendFileMessage",value:function(e){ui(e instanceof yo&&!!e.messageParams).throw(A.invalidParameters);var t=ss.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,ll.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(t,n,r){var a=this,i=ss.of(this._iid).dispatcher,s=oh.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new fl;return ki(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);i.dispatch(new Fs({messages:[r],source:n===ll.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(r));case 1:case"end":return e.stop()}}),e)})))})),s.request(a,o,t,{requestHandler:c,isCopy:n===ll.COPY}).then((function(t){i.dispatch(new Fs({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(n){if(N(n))throw n;ki(2).then((function(){var r=a._createPendingMultipleFilesMessage(t,o,u);a._markMessageAsFailed(r,n),i.dispatch(new Fs({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(n,r));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_createScheduledFileMessage",value:function(e,t,n,r){var a=this,i=ss.of(this._iid).requestQueue,s=new Cc(Object.assign(Object.assign({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(s).then((function(e){var n=e.as(wc).message;_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(N(i))throw i;ki(2).then((function(){var s=a._createPendingScheduledFileMessage(e,n,r);a._markMessageAsFailed(s,i),_i((function(){return E(a,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._triggerFailed(i,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){ui(e.every((function(e){return ou(Object.assign(Object.assign({},ru),e))}))).throw(A.invalidParameters);var t,n=new Bo,r=s(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,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._validateFailedFileMessageHasFile(e,t),ui(e instanceof yo&&r&&!e.scheduledInfo).throw(A.invalidParameters),a=new ut,i=su(e,t),this._sendFileMessage(i,ll.RESEND,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),n.abrupt("return",a.promise);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"resendMessage",value:function(e,t){var n,r;if(ui(e instanceof to&&!e.scheduledInfo&&e.isResendable).throw(A.invalidParameters),e.isUserMessage()){var a=null!==(n=e.messageParams)&&void 0!==n?n:Jo(e);return this._sendUserMessage(a,ll.RESEND,e.reqId)}if(e.isFileMessage()){var i=this._validateFailedFileMessageHasFile(e,t);ui(i).throw(A.invalidParameters);var s=null!==(r=e.messageParams)&&void 0!==r?r:su(e,t);return this._sendFileMessage(s,ll.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"updateFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},hu),t),ui(D("number",e)&&fu(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new fc(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:r.metaArrays?{array:r.metaArrays,mode:"add",upsert:!0}:void 0},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(pc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"uploadFile",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=ce(),(i=new cs({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:a})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(a),t.next=7,r.send(i);case 7:return s=t.sent,o=s.as(ls),u=o.url,c=o.thumbnails,t.abrupt("return",{requestId:a,url:u,thumbnails:c});case 10:case"end":return t.stop()}}),t,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=oh.of(this._iid),n.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"copyFileMessage",value:function(t,n){var r,i,s;return E(this,void 0,void 0,d().mark((function o(){var u,c;return d().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return ui(t instanceof a&&n instanceof yo&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters),u=new ut,c=ve(Object.assign(Object.assign({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=n.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1})),t._sendFileMessage(c).onSucceeded((function(e){return u.resolve(e)})).onFailed((function(e){return u.reject(e)})),o.abrupt("return",u.promise);case 5:case"end":return o.stop()}}),o,this)})))}},{key:"copyMessage",value:function(t,n){ui(t instanceof a&&n instanceof to&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(A.invalidParameters);var r=n,i=t;if(r.isUserMessage()){ui(!r.poll).throw(A.notSupportedError);var s=Zo(r);return i._sendUserMessage(s)}if(r.isFileMessage()){var o=au(r);return i._sendFileMessage(o)}if(n.isMultipleFilesMessage())throw A.channelTypeNotSupportedError}},{key:"deleteMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ui(e instanceof eo).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return n=ss.of(this._iid),r=n.requestQueue,a=new lt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof to?e._messageToken:void 0}),t.next=6,r.send(a);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"addReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof eo&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new vc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(_c),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteReaction",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(e instanceof eo&&e.messageId>0&&D("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new mc({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(gc),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_updateUserMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=ss.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new dc({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(hc),f=h.message,o.dispatch(new Fs({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=ss.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new fc({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(pc),f=h.message,o.dispatch(new Fs({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",f);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new ks({key:e})})),!(e instanceof yo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"add",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"add",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&P("string",t)).throw(A.invalidParameters),r=t.map((function(e){return new ks({key:e})})),!(e instanceof yo)){n.next=6;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,r,"remove",!0));case 6:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,r,"remove",!0));case 7:case"end":return n.stop()}}),n,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&t.every((function(e){return e instanceof ks}))).throw(A.invalidParameters),!(e instanceof yo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"add",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"add",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(e instanceof eo&&e.messageId>0&&t.every((function(e){return e instanceof ks}))).throw(A.invalidParameters),!(e instanceof yo)){n.next=5;break}return n.abrupt("return",this._updateFileMessageMetaArray(e.messageId,t,"remove",!0));case 5:return n.abrupt("return",this._updateUserMessageMetaArray(e.messageId,t,"remove",!0));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"report",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(R(e.ReportCategory,t)&&D("string",n)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new sc({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:t,description:n}),r.next=5,s.send(o);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"reportUser",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ui(t instanceof li&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=ss.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new oc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.userId,category:n,description:r}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"reportMessage",value:function(t,n,r){return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ui(t instanceof to&&R(e.ReportCategory,n)&&D("string",r)).throw(A.invalidParameters),i=ss.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new uc({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r,messageToken:t._messageToken}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"updatePoll",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("number",e)&&xc(t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Sc(Object.assign({pollId:e},t)),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(Tc),u=o.poll,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deletePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ui(n).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Ic({pollId:e}),t.next=6,a.send(i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"closePoll",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D("number",e),ui(n).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Nc({pollId:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Ac),u=o.poll,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"addPollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("string",t)&&""!==t.trim(),ui(r).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new Mc({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(Oc),c=u.poll,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updatePollOption",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",e)&&D("number",t)&&D("string",n)&&""!==n.trim(),ui(a).throw(A.invalidParameters),i=ss.of(this._iid),s=i.requestQueue,o=new Uc({pollId:e,pollOptionId:t,optionText:n}),r.next=6,s.send(o);case 6:return u=r.sent,c=u.as(Dc),l=c.poll,r.abrupt("return",l);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"deletePollOption",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=D("number",e)&&D("number",t),ui(r).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new Rc({pollId:e,pollOptionId:t}),n.next=6,i.send(s);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"votePoll",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=D("number",t)&&P("number",n),ui(a).throw(A.invalidParameters),i=ss.of(this._iid),s=i.requestQueue,o=i.dispatcher,u=new Lc({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:n}),r.next=6,s.send(u);case 6:return c=r.sent,l=c.as(Fc),h=l.event,o.dispatch(new Bs({event:h,source:e.CollectionEventSource.EVENT_POLL_VOTED})),r.abrupt("return",h);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("number",e)).throw(A.invalidParameters),n=el.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e,!0)),n=el.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new sl(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 cl(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}},{key:"pinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("number",e)&&e>0).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new gl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unpinMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("number",e)&&e>0).throw(A.invalidParameters),n=ss.of(this._iid),r=n.requestQueue,a=new yl({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([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?li.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds})))}}])}($a),bl=i((function e(t){r(this,e),this.key=t.key,this.url=t.url})),Cl=i((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 bl(e)})):[]})),wl=i((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new Cl(e)})):[]})),xl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onConnected=ft,this.onReconnectStarted=ft,this.onReconnectSucceeded=ft,this.onReconnectFailed=ft,this.onDisconnected=ft}))),Sl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onSessionExpired=ft,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=ft,this.onSessionRefreshed=ft,this.onSessionClosed=ft}))),Tl=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(i((function e(){r(this,e),this.onFriendsDiscovered=ft,this.onTotalUnreadMessageCountChanged=ft,this.onTotalUnreadMessageCountUpdated=ft}))),Il=function(e){function t(e){var a,i=e.limit,s=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path=ge,a.params=pe({limit:i,token:s,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return c(t,e),i(t)}(Ve),Nl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new li(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(ze),Al=function(e){function t(e,a){var i,s,o,u;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.metaDataKeyFilter=null,i.metaDataValuesFilter=null,i.nicknameStartsWithFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i.metaDataKeyFilter=null!==(o=a.metaDataKeyFilter)&&void 0!==o?o:null,i.metaDataValuesFilter=null!==(u=a.metaDataValuesFilter)&&void 0!==u?u:null,i.nicknameStartsWithFilter=a.nicknameStartsWithFilter||null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)&&D("string",this.metaDataKeyFilter,!0)&&P("string",this.metaDataValuesFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Il(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Nl),s=i.users,o=i.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),Ml=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token,u=e.userIdsFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/block"),a.params=pe({limit:s,token:o,user_ids:u}),a}return c(t,e),i(t)}(Ve),Ol=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new li(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(ze),Ul=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).userIdsFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&P("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ml(ve(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token}))),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Ol),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),Dl=function(e){function t(e){var a,i=e.userId,s=e.limit,o=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={limit:s,token:o},a}return c(t,e),i(t)}(Ve),Rl=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).hasMore=a.has_more,i.users=a.users.map((function(t){return new li(e,t)})),i.next=a.next,i}return c(t,e),i(t)}(ze),Ll=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Dl(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Rl),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),Pl={},Fl=function(){return i((function e(t){var n=t.dbname,a=t.itemSizeLimit,i=void 0===a?1048576:a,s=t.cacheLimit,o=void 0===s?256:s,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,d=void 0===l?10:l,h=t.blockHashConstant,f=void 0===h?11:h,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),Pl[n]||(this.itemSizeLimit=i,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=d,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,Pl[n]=this),Pl[n]}),null,[{key:"get",value:function(e){return Pl[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"}(El||(El={}));var ql,Hl=function(e){function t(e){var a,i=e.code,s=void 0===i?El.UNKNOWN_ERROR:i,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,t),(a=n(this,t,[u])).code=s,Object.setPrototypeOf(a,t.prototype),a}return c(t,e),i(t,null,[{key:"storeNotDefined",get:function(){return new t({code:El.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new t({code:El.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new t({code:El.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new t({code:El.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new t({code:El.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new t({code:El.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new t({code:El.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new t({code:El.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new t({code:El.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new t({code:El.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new t({code:El.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new t({code:El.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new t({code:El.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new t({code:El.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new t({code:El.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new t({code:El.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new t({code:El.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new t({code:El.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new t({code:El.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new t({code:El.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new t({code:El.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new t({code:El.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new t({code:El.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new t({code:El.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new t({code:El.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}])}(y(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(ql||(ql={}));var Gl,jl=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===m(e)&&null!==e){if(t.has(e))throw Hl.circularReferenceFound;var n;return t.set(e,!0),Array.isArray(e)?n=e.map((function(e){return jl(e,t)})):e instanceof RegExp||e instanceof Date?n=e:(n={},Object.keys(e).forEach((function(r){n[r]=jl(e[r],t)}))),t.delete(e),n}return e},Vl=function(e,t){if(null==t)return 1;if(null==e)return-1;if(m(e)!==m(t))throw Hl.compareTypesNotMatch;var n=0;switch(m(e)){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},zl=function(e,t){for(var n=0,r=0;r>>0)%t},Bl=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Ql=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!Ql(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Ql(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"===m(e[r])){var a=e[r];for(var i in a)switch(i){case"/eq":case"=":if(t[r]!==a[i])return!1;break;case"/neq":case"!=":if(t[r]===a[i])return!1;break;case"/gt":case">":var s=t[r],o=a[i];if(!(Vl(s,o)>0))return!1;break;case"/gte":case">=":var u=t[r],c=a[i];if(!(Vl(u,c)>=0))return!1;break;case"/lt":case"<":var l=t[r],d=a[i];if(!(Vl(l,d)<0))return!1;break;case"/lte":case"<=":var h=t[r],f=a[i];if(!(Vl(h,f)<=0))return!1;break;case"/in":var p=t[r];if(!a[i].includes(p))return!1;break;case"/nin":var v=t[r];if(a[i].includes(v))return!1;break;case"/contain":var _=t[r],g=a[i];if(!_.includes(g))return!1;break;case"/regex":var y=t[r];if(!a[i].test(y))return!1;break;case"/where":var E=t[r];if(!(0,a[i])(E))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)},Kl=function(){},Wl=function(){return Promise.resolve()},Yl=function(e){return e},Zl=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Gl||(Gl={}));var Xl,Jl,$l,ed=function(){return i((function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,i=t.initialNextValue,s=void 0===i?null:i,o=t.iterator,u=t.map,c=void 0===u?Yl:u,l=t.backward,d=void 0===l?Wl:l,h=t.forward,f=void 0===h?Wl:h,p=t.complete,v=void 0===p?Kl:p;r(this,e),this._prevValue=a,this._nextValue=s,this._error=null,this._map=c,this._backward=d,this._forward=f,this._iterator=o,this._complete=v}),[{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,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,t=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,t=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}])}(),td=function(){return i((function e(t){var n=t.condition,a=void 0===n?{}:n,i=t.backward,s=void 0!==i&&i,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=s,this._blockManager=o,this._indexer=u}),[{key:"findOptimizedStartPosition",value: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 a=0;a0?n:t;for(var u in this.condition[i])if(o.includes(u))for(var c=r;c>=0;c--)if(s*Vl(this._indexer.origin[c].columnValues[a],this.condition[i][u])<=0){r=c;break}}else for(var l=r;l>=0;l--)if(s*Vl(this._indexer.origin[l].columnValues[a],this.condition[i])<=0){r=l;break}}return Math.min(r+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var h=function(r){var a=e._indexer.fields[r],i=1;if("-"===a[0]&&(a=a.slice(1),i=-1),e.condition[a])if("object"===m(e.condition[a]))Object.keys(e.condition[a]).forEach((function(s){if((i>0?t:n).includes(s))for(var o=d;o=0){d=o;break}}));else for(var s=d;s=0){d=s;break}},f=0;f0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Math.max(e.offset||0,0),0!==(r="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){t.next=6;break}return t.abrupt("return",[]);case 6:if(!(r<0)){t.next=8;break}throw Hl.collectionQueryNotValid;case 8:return t.prev=8,a=[],t.next=12,this._mutex.lock();case 12:return t.next=14,this._iterator.each((function(e){return E(i,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===n?(a.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(od(e,t)).concat(n,".").concat(r)},cd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=i}),[{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(n=t.sent)){t.next=19;break}if(r=n.data,a=n.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(r);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(s=[],o=atob(r.split(",")[1]),u=0;u1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,new Promise((function(n){var r=ud(o.dbname,o.collectionName,t),a=new FileReader;a.onload=function(){n({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return r=n.sent,a=r.blobId,i=r.data,s=r.type,n.next=8,this.store.set({key:a,value:{data:i,type:s}});case 8:return n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=od(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return n=e.sent,e.next=6,Promise.all(n.filter((function(e){return e.startsWith(t)})).map((function(e){return E(r,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}])}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Xl||(Xl={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Jl||(Jl={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}($l||($l={}));var ld,dd,hd=[Jl.PENDING,Jl.VOLATILE],fd={},pd=function(){return i((function e(t){var n=t.dbname,a=t.limit,i=void 0===a?256:a;return r(this,e),fd[n]||(this.dbname=n,this._items=[],this._limit=i,fd[n]=this),fd[n]}),[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$l.DEFAULT;return E(this,void 0,void 0,d().mark((function r(){var a,i;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=this.get(t)){r.next=8;break}return r.next=4,e.get(t);case 4:(i=r.sent)&&(a={key:t,value:i,state:n===$l.PERSISTENT?Jl.PERSISTENT:Jl.VOLATILE},this.put(a)),r.next=9;break;case 8:n===$l.PERSISTENT&&(a.state=Jl.PERSISTENT);case 9:return r.abrupt("return",a);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$l.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===$l.PERSISTENT&&(r.state=Jl.PERSISTENT),t!==$l.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)hd.includes(this._items[t].state)&&hd.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===Jl.VOLATILE})),r=n.length-this._limit;if(r>0){var a,i=[],o=s(this._items);try{for(o.s();!(a=o.n()).done;){var u=a.value;u.state===Jl.VOLATILE&&r>0?r--:i.push(u)}}catch(e){o.e(e)}finally{o.f()}this._items=i}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clearForDatabase",value:function(e){this.clearByCondition((function(t){return t.key.startsWith(rd(e))}))}},{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!==Jl.VOLATILE}))}}],[{key:"get",value:function(e){return fd[e]}}])}(),vd=function(){return i((function e(t){var n=t.dbname,a=t.collectionName,i=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(ad(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(ad(e,t),"/trans.recordset")}(n,a),this._store=i}),[{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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(n=t.t0).push.apply(n,v(e)),t.abrupt("return",this._reduceRecordSet(n));case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],i=[],s=a.requests.length-1;s>=0;s--){var o=a.requests[s],u=o.data;n[u.key]||(i.unshift(o),n[u.key]=!0)}i.length>0&&(a.requests=i,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=pd.get(this.dbname),a=t.generation,i=t.requests,s=null,n.prev=3,n.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:a})})));case 6:for(o=n.sent,u=0;u0)){e.next=20;break}for(n=[],r={},a=t.length-1;a>=0;a--)i=t[a],s=i.data,r[s.key]||(r[s.key]=!0,n.unshift(i));return o={generation:this.generation,requests:n},e.next=8,this._getReducedRecordset([o]);case 8:return u=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:u});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(c=pd.get(this.dbname),l=0;l1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=i,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||zl)(e,r)}(e,i,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(sd(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=pd.get(this.dbname),r=this.metadata.blockLevel;case 2:if(!(r>0)){t.next=15;break}return a=this.createBlockId(e,r),t.next=6,n.find(this._store,a);case 6:if(!(i=t.sent)){t.next=12;break}if(s=_d.createFromCacheItem(i),!(null==s?void 0:s.getItemByKey(e))){t.next=12;break}return t.abrupt("return",s);case 12:r--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"getFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return n=t.sent,t.abrupt("return",n?n.getItemByKey(e):null);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"putToBlock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Fl.get(this.dbname),a=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/r.itemSizeLimit),s=pd.get(this.dbname),n.next=6,s.find(this._store,a);case 6:if(o=n.sent,!(null==(u=o?_d.createFromCacheItem(o):new _d({blockId:a,keyName:this.keyName,items:[],limit:i}))?void 0:u.add(t))){n.next=11;break}return this._transaction.requestWrite({key:u.blockId,value:u.serialize()}),n.abrupt("return",!0);case 11:return n.abrupt("return",!1);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"removeFromBlock",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(n=t.sent)){t.next=7;break}if(!n.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:n.blockId,value:n.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"clearAllBlocks",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=sd(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return n=e.sent,r=n.filter((function(e){return e.startsWith(t)})),e.next=7,this._store.removeMany(r);case 7:return e.next=9,this._transaction.clear();case 9:pd.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(t)}));case 11:case"end":return e.stop()}}),e,this)})))}}])}(),gd=function(){return i((function e(t){var n=this,a=t.dbname,i=t.collectionName,s=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(ad(e,t),"/index.").concat(n)}(a,i,o.join(">"));this.dbname=a,this.collectionName=i,this.keyName=s,this.fields=o,this.indexerKey=l,this._store=c,this._transaction=u,this._transaction.on(Xl.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Xl.ERROR,this.indexerKey,(function(){return n.abort()}))}),[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=f(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=f(this.indexOf(n),2),a=r[0];if(r[1]){var i=this._table[a].keys.indexOf(t);if(i>-1)return this._table[a].keys.splice(i,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,n,r,a=[],i=s(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),n=e[o],r=void 0,r=m(n),null!==n&&"undefined"!==r&&"boolean"!==r&&"number"!==r&&"string"!==r)throw Hl.indexTypesNotMatch;a.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return a}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Vl(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,d().mark((function e(){var t,n,r,a,i,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=pd.get(this.dbname),e.next=3,t.find(this._store,this.indexerKey,$l.PERSISTENT);case 3:if(n=e.sent){e.next=33;break}return r=sd(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:a=e.sent,i=s(a),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=22;break}if(!(u=o.value).startsWith(r)){e.next=20;break}return e.next=17,t.find(this._store,u,$l.NO_CACHE);case 17:if(c=e.sent,l=_d.createFromCacheItem(c)){h=s(l.items);try{for(h.s();!(f=h.n()).done;)p=f.value,this._addItem(p)}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=n.value,this._table=jl(this._origin);case 35:case"end":return e.stop()}}),e,this,[[10,24,27,30]])})))}},{key:"drop",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return pd.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeItem",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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=jl(this._origin)}},{key:"abort",value:function(){this._table=jl(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}}])}(),yd=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},Ed=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"}(ld||(ld={})),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"}(dd||(dd={}));var kd,bd={},Cd=function(){return i((function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=ld.PROCESSING,this._queue=[],this._activationQueue=[],bd[t]&&!a.forceCreate||(this.nodeId=Ed(),this.key=t,yd()&&(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;if(null==t?void 0:t.isNestDbMessage){var r=t.nodeId,a=t.requestId,i=t.key,o=t.op,u=t.data;if(r!==n.nodeId&&i===n.key)switch(o){case dd.NEWNODE:n._sendSync();break;case dd.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case dd.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var c,l=u.currentItemRequestId,d=s(u.queue);try{var h=function(){var e=c.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:dd.REQUEST_LOCK,ts:e.ts})};for(d.s();!(c=d.n()).done;)h()}catch(e){d.e(e)}finally{d.f()}n._currentItem=n._queue.find((function(e){return e.requestId===l})),n._completeSync()}break;case dd.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 dd.REQUEST_LOCK:n._requestLock(t);break;case dd.ACQUIRE_LOCK:var f=n._queue.find((function(e){return e.requestId===a}));n._acquire(f);break;case dd.RELEASE_LOCK:n._release(a)}}})),window.addEventListener("beforeunload",(function(){n._send(dd.REMOVENODE)}))),bd[t]=this),bd[t]}),[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==ld.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:Ed(),key:this.key,op:e,data:n.data,ts:Date.now()};return yd()&&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(dd.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){for(var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(dd.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1,i=0;ir.ts){t._queue.splice(i,0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(dd.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,d().mark((function e(){var t=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){t._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=ld.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(dd.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(dd.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return t=this._send(dd.REQUEST_LOCK),e.next=5,this._requestLock(t);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)}}])}(),wd=function(){function e(t){var n=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=ql.INIT,this._indexers=[],this.dbname=a,this.name=i,this.keyName=s,this.indexes=[[s]].concat(v(u.filter((function(e){return gd.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new Cd(function(e,t){return"".concat(ad(e,t),".lock")}(a,i)),this._blobContainer=new cd({dbname:a,collectionName:i,store:c}),this._transaction=new vd({dbname:a,collectionName:i,store:c})}return i(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===ql.READY}},{key:"init",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l,h,f,p,_=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,n=Fl.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return r=t.sent,this._metadata=r||{keyName:this.keyName,blockLevel:1,blockHashBase:n.blockHashBase,blockHashMultiplier:n.blockHashMultiplier,blockHashConstant:n.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new md({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),a=v(this.indexes),i=[],o=a.map((function(e){return gd.createKey(e)})),u=r?r.indexes.map((function(e){return gd.createKey(e)})):[],c=s(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(gd.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(f=[]).push.apply(f,v(a.map((function(e){var t=new gd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()})))),f.push.apply(f,v(i.map((function(e){return new gd({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()})))),t.next=22,Promise.all(f);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return p=id(this.dbname,this.name),this._metadata.indexes=a,t.next=29,this._store.set({key:p,value:this._metadata});case 29:this._state=ql.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),t,this,[[2,33]])})))}},{key:"close",value:function(){this._state=ql.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=gd.createKey(e),r=s(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===gd.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Hl.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=id(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:t,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:r=s(this._indexers),t.prev=14,r.s();case 16:if((a=r.n()).done){t.next=22;break}return i=a.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),r.e(t.t0);case 27:return t.prev=27,r.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Hl.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),t,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c,l;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(r=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:a=s(this._indexers),t.prev=14,a.s();case 16:if((i=a.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),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(n,e);case 34:u=s(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(r),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(r);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()}}),t,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(!(r=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:a=s(this._indexers),t.prev=8,a.s();case 10:if((i=a.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(r),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(r);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),a.e(t.t0);case 24:return t.prev=24,a.f(),t.finish(24);case 27:case"end":return t.stop()}}),t,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(n=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:r=s(this._indexers),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return i=a.value,t.next=13,i.removeItem(n);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:case"end":return t.stop()}}),t,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:t=s(this._indexers),e.prev=3,t.s();case 5:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=9,r.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return n=t.sent,this._mutex.unlock(),t.abrupt("return",jl(n));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Hl.collectionNotReady;case 18:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new nd({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Hl.collectionNotReady}},{key:"insertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Hl.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(jl(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 Hl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Hl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestInsert(jl(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Hl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Hl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(jl(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 Hl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i=this;return d().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 Hl.collectionKeyNotGiven;case 6:n=s(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestUpsert(jl(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Hl.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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 Hl.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(jl(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 Hl.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"updateIf",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.isReady){n.next=31;break}return n.next=3,this._mutex.lock();case 3:return n.prev=3,r=e.where,a=void 0===r?{}:r,i=e.index,s=void 0===i?null:i,o=e.backward,u=void 0!==o&&o,c=[],l=new td({condition:a,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(s)}),n.next=9,l.each((function(e){return E(v,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.error){n.next=4;break}e.hasNext?(r=e.nextValue,Ql(a,r)&&t.set&&("function"!=typeof t.set?Object.keys(t.set).forEach((function(e){var n;r[e]=null===(n=t.set)||void 0===n?void 0:n[e]})):t.set(r),c.push(r)),e.next()):e.stop(),n.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return n.stop()}}),n)})))}));case 9:h=0,f=c;case 10:if(!(h1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return v(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)),i=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(i).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:i}),r}))}},{key:"_resetIfEncryptionChanged",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(this._encryptionCheckKey);case 2:if(t=e.sent,n={encrypted:Id.map((function(e){var t;return null===(t=s.encryption)||void 0===t?void 0:t.encrypt(e)}))},!t){e.next=22;break}if(!t.encrypted||!Array.isArray(t.encrypted)){e.next=20;break}e.t0=d().keys(t.encrypted);case 7:if((e.t1=e.t0()).done){e.next=18;break}if(r=e.t1.value,a=JSON.stringify(t.encrypted[r]),i=JSON.stringify(n.encrypted[r]),a===i){e.next=16;break}return Td.warning("Encryption algorithm has changed. Stored data would be cleared."),e.next=15,this.clear();case 15:return e.abrupt("break",18);case 16:e.next=7;break;case 18:e.next=22;break;case 20:return e.next=22,this.clear();case 22:return e.next=24,this.set({key:this._encryptionCheckKey,value:n});case 24:case"end":return e.stop()}}),e,this)})))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=0,e.next=3,this._getAllRawKeys();case 3:n=e.sent,r=s(n),e.prev=5,r.s();case 7:if((a=r.n()).done){e.next=15;break}return i=a.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(t+=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),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})).filter((function(e){return!n._reservedKeys.includes(e)})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=21;break}if(t.prev=5,a=r.data,!((null==(i=r.metadata)?void 0:i.shards)&&i.shards>1)){t.next=13;break}return t.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return E(o,void 0,void 0,d().mark((function n(){var r,i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>0)){n.next=10;break}return r=this._getRawKey(e,".".concat(t)),n.next=4,this._getRaw(r);case 4:if(i=n.sent){n.next=7;break}throw Hl.storeBrokenIntegrity;case 7:return n.abrupt("return",i.data);case 10:return n.abrupt("return",a);case 11:case"end":return n.stop()}}),n,this)})))})));case 10:t.t0=t.sent,t.next=14;break;case 13:t.t0=[a];case 14:return s=t.t0,t.abrupt("return",this.encryption.decrypt(JSON.parse(s.join(""))));case 18:return t.prev=18,t.t1=t.catch(5),t.abrupt("return",null);case 21:return t.abrupt("return",null);case 22:case"end":return t.stop()}}),t,this,[[5,18]])})))}},{key:"set",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._shardify(e),t.next=3,this._setRaw(n);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[],t.next=3,this._setRaw(n.concat.apply(n,v(e.map((function(e){return r._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=12;break}return a=r.metadata,i=this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return o._getRawKey(e,".".concat(t))})),t.next=9,this._removeRaw(i);case 9:return null==(s=pd.get(this.dbname))||s.remove(e),t.abrupt("return",!0);case 12:return t.abrupt("return",!1);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"removeMany",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=pd.get(this.dbname),r=[],a=s(e),t.prev=3,o=d().mark((function e(){var t,a,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.value,a=u._getRawKey(t,".0"),e.next=4,u._getRaw(a);case 4:(s=e.sent)&&(o=s.metadata,r.push.apply(r,v(u._generateShardPostfixArray(null==o?void 0:o.shards).map((function(e){return u._getRawKey(t,".".concat(e))}))))),null==n||n.remove(t);case 7:case"end":return e.stop()}}),e)})),a.s();case 6:if((i=a.n()).done){t.next=10;break}return t.delegateYield(o(),"t0",8);case 8:t.next=6;break;case 10:t.next=15;break;case 12:t.prev=12,t.t1=t.catch(3),a.e(t.t1);case 15:return t.prev=15,a.f(),t.finish(15);case 18:if(!(r.length>0)){t.next=21;break}return t.next=21,this._removeRaw(r);case 21:return t.abrupt("return",e);case 22:case"end":return t.stop()}}),t,this,[[3,12,15,18]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==(t=pd.get(this.dbname))||t.clearForDatabase(this.dbname);case 2:case"end":return e.stop()}}),e,this)})))}}])}(),Ad={},Md=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,t),e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:4194304})]);var s=i.delay,o=void 0===s?1:s;return e.delay=o,e.observer={},e}return c(t,e),i(t,[{key:"rawData",get:function(){return Ad[this.dbname]},set:function(e){Ad[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Ad[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(Ad[this.dbname]));case 4:throw Hl.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ad[this.dbname]){t.next=6;break}return t.next=3,Bl(this.delay);case 3:return t.abrupt("return",Ad[this.dbname][e]?Object.assign({key:e},Ad[this.dbname][e]):null);case 6:throw Hl.storeNotAvailable;case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ad[this.dbname]){t.next=7;break}return t.next=3,Bl(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,i=a.key,o=a.data,u=a.metadata,Ad[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Hl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ad[this.dbname]){t.next=7;break}return t.next=3,Bl(this.delay);case 3:n=s(e);try{for(n.s();!(r=n.n()).done;)a=r.value,Ad[this.dbname][a]&&delete Ad[this.dbname][a]}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Hl.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,Ad[this.dbname]||(Ad[this.dbname]={}),t.next=4,this._resetIfEncryptionChanged();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(t,"set",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=this.observer[e.key])||"function"!=typeof n.set){t.next=5;break}if(!(a=n.set())){t.next=5;break}throw a;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(t,"setMany",n,1)}}});return E(this,void 0,void 0,d().mark((function t(){var n,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((a=n.n()).done){t.next=12;break}if(i=a.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),n.e(t.t0);case 17:return t.prev=17,n.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),t,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,Bl(this.delay);case 4:Ad[this.dbname]={};case 5:case"end":return e.stop()}}),e,this)})))}}])}(Nd),Od="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(kd||(kd={}));var Ud,Dd=function(e){function t(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),(e=n(this,t,[Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:104857600})]))._storeName=Od,e._state=kd.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 c(t,e),i(t,[{key:"state",get:function(){return this._state}},{key:"isTransactionInactiveError",value:function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")}},{key:"_putToObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.put(t);a.addEventListener("success",(function(e){n(e.target.result)})),a.addEventListener("error",(function(){r("Failed to write.")}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_deleteFromObjectStore",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){var a=e.delete(t);a.addEventListener("success",(function(){return n(t)})),a.addEventListener("error",(function(e){return r(e.target.error)}))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=kd.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Od,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=kd.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=kd.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=kd.UNINITIALIZED,r(e.target.error)}))}else r(Hl.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().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===kd.UNINITIALIZED||t.t0===kd.OPEN?7:t.t0===kd.OPENING||t.t0===kd.CLOSED?8:9;break;case 7:throw Hl.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){n._openJobQueue.push((function(){return t(n._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()}}),t,this)})))}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readonly");case 2:return t=e.sent,e.next=5,new Promise((function(e,n){var r=t.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return n(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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readonly");case 2:return n=t.sent,t.next=5,new Promise((function(t,r){var a=n.get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return r(e.target.error)}))}));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._putToObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._putToObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return n=t.sent,t.prev=3,t.next=6,Promise.all(e.map((function(e){return o._deleteFromObjectStore(n,e)})));case 6:t.next=31;break;case 8:if(t.prev=8,t.t0=t.catch(3),!this.isTransactionInactiveError(t.t0)){t.next=30;break}r=s(e),t.prev=12,r.s();case 14:if((a=r.n()).done){t.next=20;break}return i=a.value,t.next=18,this._deleteFromObjectStore(n,i);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t1=t.catch(12),r.e(t.t1);case 25:return t.prev=25,r.f(),t.finish(25);case 28:t.next=31;break;case 30:throw t.t0;case 31:case"end":return t.stop()}}),t,this,[[3,8],[12,22,25,28]])})))}},{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,d().mark((function e(){var t,n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(t="undefined"!=typeof window?window:null)?void 0:t.indexedDB)||(null==t?void 0:t.mozIndexedDB)||(null==t?void 0:t.webkitIndexedDB)||(null==t?void 0:t.msIndexedDB))){e.next=16;break}if(this._indexedDb=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB,!this._window||!yd()){e.next=13;break}if(!(yd()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!t.PointerEvent&&!t.MSPointerEvent){e.next=7;break}throw Hl.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(n._indexedDb)try{var r=n._indexedDb.open("_testMozilla");r.onerror=function(){return t(Hl.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),n._indexedDb){var a=n._indexedDb.deleteDatabase("_testMozilla");a.onerror=function(){return e()},a.onsuccess=function(){return e()}}else t(Hl.storeNotAvailable)}}catch(e){t(Hl.storeNotAvailableInPrivateBrowsing)}else t(Hl.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Hl.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,d().mark((function t(){return d().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:return t.next=7,this._resetIfEncryptionChanged();case 7:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){var e=this,n=Object.create(null,{clear:{get:function(){return p(t,"clear",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.clear.call(this);case 2:return e.next=4,this._getObjectStore("readwrite");case 4:return t=e.sent,e.next=7,new Promise((function(e,n){var r=t.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))}}])}(Nd),Rd=function(e){function t(e){var a;r(this,t);var i=e.AsyncStorage,s=e.itemSizeLimit,o=void 0===s?2097152:s,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof to))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}if(t instanceof eo)switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof to&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}])}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Hd||(Hd={}));var Vd,zd=function(e){switch(e){case Hd.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Hd.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Bd=Object.assign(Object.assign({},Yo),{scheduledAt:void 0}),Qd=Object.assign(Object.assign({},Qo),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Kd="UnsentMessage",Wd={},Yd=function(e){function t(e){var a;return r(this,t),(a=n(this,t,[e]))._mutex=new Cd("unsendmessagecache.lock"),Wd[e]=a,a}return c(t,e),i(t,[{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Kd);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 po?(e.messageParams&&(n.messageParams=Wo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},Wo(t)),{scheduledAt:t.scheduledAt})))):e instanceof yo?(e.messageParams&&(n.messageParams=nu(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},nu(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof vo&&e.messageParams&&(n.messageParams=function(e){return pe({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)}),oh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(i=oh.of(this._iid),s=this._deserialize(e),!e.messageParams){a.next=32;break}if(!(s instanceof po)){a.next=8;break}o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),a.next=32;break;case 8:if(!(s instanceof yo)){a.next=26;break}if(!(u=e.messageParams).fileKey||"string"!=typeof u.fileKey||!tu(null!==(t=u.fileType)&&void 0!==t?t:"")){a.next=23;break}return a.next=13,this.collection.getBlob(u.fileKey);case 13:if(a.t1=n=a.sent,a.t0=null!==a.t1,!a.t0){a.next=17;break}a.t0=void 0!==n;case 17:if(!a.t0){a.next=21;break}a.t2=n,a.next=22;break;case 21:a.t2=void 0;case 22:u.file=a.t2;case 23:s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(u,s),a.next=32;break;case 26:if(!(s instanceof vo)){a.next=32;break}if(!(c=e.messageParams)||!c.fileInfoList){a.next=32;break}return s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(c,s),a.next=32,Promise.all(s.messageParams.fileInfoList.map((function(e){return E(f,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)||!tu(null!==(a=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==a?a:"")){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()}}),t,this)})))})));case 32:if(!(s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){a.next=54;break}if(!(s instanceof po)){a.next=38;break}l=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(l,s),a.next=54;break;case 38:if(!(s instanceof yo)){a.next=54;break}if(!(h=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof h.fileKey||"string"!=typeof h.fileType||!tu(h.fileType)){a.next=53;break}return a.next=43,this.collection.getBlob(h.fileKey);case 43:if(a.t4=r=a.sent,a.t3=null!==a.t4,!a.t3){a.next=47;break}a.t3=void 0!==r;case 47:if(!a.t3){a.next=51;break}a.t5=r,a.next=52;break;case 51:a.t5=void 0;case 52:h.file=a.t5;case 53:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(h,s);case 54:return a.abrupt("return",s);case 55:case"end":return a.stop()}}),a,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new jd:n,a=e.order,i=void 0===a?Hd.CHANNEL_LATEST:a,s=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return E(this,void 0,void 0,d().mark((function e(){var n,a,o,l,h,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=zd(i),a={"/where":function(e){return!!(i!==Hd.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(f._deserialize(e))}},t&&(a.channelUrl=t),s&&(a.sendingStatus=s),o={where:a,index:n,backward:u},e.next=8,this.collection.query(o);case 8:return l=e.sent,e.next=11,l.fetch({});case 11:return h=e.sent,e.abrupt("return",Promise.all(h.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new jd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({filter:t,order:Hd.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof yo||e instanceof vo)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return n=this._serialize(e),t.next=10,this.collection.upsertOne(n);case 10:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:n=t.sent;case 5:if(!(n.length>0)){t.next=9;break}return n.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(n);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){var n,r,a,i,s,o=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof yo)){t.next=19;break}if(!e.messageParams){t.next=9;break}if(!(n=e.messageParams).file||!eu(n.file)){t.next=9;break}return t.next=6,this.collection.saveBlob(n.file,e.reqId);case 6:r=t.sent,n.fileKey=r,n.fileType=Xo.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){t.next=17;break}if(!(a=e.scheduledInfo.scheduledMessageParams).file||!eu(a.file)){t.next=17;break}return t.next=14,this.collection.saveBlob(a.file,e.reqId);case 14:i=t.sent,a.fileKey=i,a.fileType=Xo.BLOB;case 17:t.next=24;break;case 19:if(!(e instanceof vo)){t.next=24;break}if(!((s=e.messageParams)&&s.fileInfoList&&Array.isArray(s.fileInfoList))){t.next=24;break}return t.next=24,Promise.all(s.fileInfoList.map((function(t,n){return E(o,void 0,void 0,d().mark((function r(){var a;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!t.file||!eu(t.file)){r.next=7;break}return r.next=3,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n));case 3:a=r.sent,t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=a,t._uploadedMetaData.fileType=Xo.BLOB;case 7:case"end":return r.stop()}}),r,this)})))})));case 24:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Wd[e]&&!n||(Wd[e]=new t(e)),Wd[e]}}])}($a),Zd={},Xd=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Zd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return ss.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"_unsentMessageCache",get:function(){return Yd.of(this._iid)}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ui(!!e).throw(A.databaseError),e.collection(nl)}},{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)}),oh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new jd:i,o=e.order,u=void 0===o?Hd.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,h=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,d().mark((function e(){var r,i,o,c,f=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r=zd(u),i={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(u){case Hd.CHANNEL_LATEST:if(_&&e.createdAt!==n)return!1;if(l){if(g&&e.createdAtn||!g&&e.createdAt>=n)return!1;break;case Hd.NEWEST_CHILD_MESSAGE:if(!h||0===e.parentMessageId||e.parentMessageId!==h)return!1}return!(p&&!e._poll)&&s.match(f._deserialize(e))}},index:r,backward:l},e.next=5,this.collection.query(i);case 5:return o=e.sent,e.next=8,o.fetch({limit:null!=a?a:void 0});case 8:return c=e.sent,e.abrupt("return",Promise.all(c.map((function(e){return E(f,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}))));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new jd;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:Hd.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=30;break}return n.next=3,this.saveBlobs(e);case 3:r=s(e),n.prev=4,r.s();case 6:if((a=r.n()).done){n.next=15;break}if(i=a.value,!(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)){n.next=13;break}return n.next=11,this.get(i.messageId);case 11:(null==(o=n.sent)?void 0:o.threadInfo)&&i.threadInfo._updateFrom(o.threadInfo);case 13:n.next=6;break;case 15:n.next=20;break;case 17:n.prev=17,n.t0=n.catch(4),r.e(n.t0);case 20:return n.prev=20,r.f(),n.finish(20);case 23:return u=e.map((function(e){return c._serialize(e)})),n.next=26,this.collection.upsertMany(u);case 26:return n.next=28,this.upsertChildMessages(e);case 28:return n.next=30,this._unsentMessageCache.upsertChildMessages(e);case 30:case"end":return n.stop()}}),n,this,[[4,17,20,23]])})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!((null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)&&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()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove("".concat(a));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:zd(Hd.CHANNEL_LATEST)});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:zd(Hd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=zd(Hd.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map((function(e){return E(n,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof yo&&e.messageParams)){t.next=7;break}if(!(n=e.messageParams).file||!eu(n.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(n.file,e.reqId);case 5:r=t.sent,n.fileKey=r;case 7:case"end":return t.stop()}}),t,this)})))})));case 2:case"end":return t.stop()}}),t)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=0,r=this._cacheContext.preference,t.next=4,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return a=t.sent,t.next=7,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return s=t.sent,t.next=13,r.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return o=t.sent,a&&(n+=JSON.stringify(a).length),i&&(n+=JSON.stringify(i).length),s&&(n+=JSON.stringify(s).length),o&&(n+=JSON.stringify(o).length),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Zd[e]&&!n||(Zd[e]=new t(e)),Zd[e]}}])}($a),Jd={},$d=function(e){function t(e){var a;return r(this,t),a=n(this,t,[e]),Jd[e]=a,a}return c(t,e),i(t,[{key:"_sdkState",get:function(){return ss.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ui(!!e).throw(A.databaseError),e.collection(rl)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign({},e.serialize())}},{key:"_deserialize",value:function(e){return oh.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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(e);case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?100:r,i=e.filter,s=void 0===i?new jd:i,o=e.backward,u=void 0!==o&&o,c=e.exactMatch,l=void 0!==c&&c,h=e.inclusive,f=void 0===h||h;return E(this,void 0,void 0,d().mark((function e(){var r,i,o,c=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r={where:{channelUrl:t,"/where":function(e){if(n){if(l&&e.createdAt!==n)return!1;if(u){if(f&&e.createdAtn||!f&&e.createdAt>=n)return!1}return s.match(c._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:u},e.next=5,this.collection.query(r);case 5:return i=e.sent,e.next=8,i.fetch({limit:null!=a?a:void 0});case 8:return o=e.sent,e.abrupt("return",o.map((function(e){return c._deserialize(e)})));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=4;break}return n=e.map((function(e){return r._serialize(e)})),t.next=4,this.collection.upsertMany(n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=s(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"markAsReadByTimestamp",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,messageStatus:so.SENT,createdAt:{"<":t}}},{set:{messageStatus:so.READ}});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"markAsReadByMessageIds",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=5;break}return n.next=3,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:so.SENT}},{set:{messageStatus:so.READ}});case 3:return r=n.sent,n.abrupt("return",r.length);case 5:return n.abrupt("return",0);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:["channelUrl","-createdAt","-notificationId"]});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:zd(Hd.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,s=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=["channelUrl","-createdAt","-notificationId"],i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}}],[{key:"of",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Jd[e]&&!n||(Jd[e]=new t(e)),Jd[e]}}])}($a),eh={},th=function(t){function a(t){var i;return r(this,a),(i=n(this,a,[t]))._observers=new Map,i._dispatcherContext=i._dispatcher.on((function(t){return E(i,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,N,A,M,O=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof Fs)){n.next=19;break}if(r=t.messages,a=t.source,i=t.isWebSocketEventComing,s=r.filter((function(t){return t instanceof eo&&t.channelType!==e.ChannelType.OPEN&&t.messageId>0})),o=r.filter((function(t){return t instanceof eo&&t.channelType!==e.ChannelType.OPEN&&0===t.messageId})),u=r.filter((function(e){return e instanceof _o})),!(s.length>0)){n.next=9;break}return n.next=8,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(s);case 2:return e.next=4,this._unsentMessageCache.remove(s.map((function(e){return e instanceof to?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e,this)})))}));case 8:i||this._broadcastUpdateEvent(s,a);case 9:if(!(o.length>0)){n.next=13;break}return n.next=12,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.upsert(o);case 2:case"end":return e.stop()}}),e,this)})))}));case 12:i||this._broadcastUpdateEvent(o,a);case 13:if(!(u.length>0)){n.next=17;break}return n.next=16,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._notificationCache.upsert(u);case 2:case"end":return e.stop()}}),e,this)})))}));case 16:i||this._broadcastUpdateEvent(u,a);case 17:n.next=71;break;case 19:if(!(t instanceof qs)){n.next=28;break}return c=t.messageIds,l=t.source,h=t.isWebSocketEventComing,f=c.filter((function(e){return"number"==typeof e})),p=c.filter((function(e){return"string"==typeof e})),n.next=25,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(f.length>0)){e.next=3;break}return e.next=3,this._messageCache.remove(f);case 3:if(!(p.length>0)){e.next=6;break}return e.next=6,this._notificationCache.remove(p);case 6:case"end":return e.stop()}}),e,this)})))}));case 25:h||this._broadcastRemoveEvent(c,l),n.next=71;break;case 28:if(!(t instanceof js)){n.next=35;break}return v=t.reqId,_=t.source,n.next=32,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.remove([v]);case 2:case"end":return e.stop()}}),e,this)})))}));case 32:this._broadcastRemoveUnsentEvent(v,_),n.next=71;break;case 35:if(!(t instanceof Vs)){n.next=48;break}if(m=t.polls,g=t.source,!this._cacheContext.localCacheEnabled){n.next=45;break}return y=m.map((function(e){return e.messageId})),n.next=41,Promise.all(y.map((function(e){return O._messageCache.get(e)})));case 41:return k=n.sent.filter((function(e){return e})),k.length>0&&m.forEach((function(e){var t=k.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=45,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(k);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 45:this._broadcastPollChangeLogEvent(m,g),n.next=71;break;case 48:if(!(t instanceof zs)){n.next=59;break}return b=t.event,C=t.source,n.next=52,this._messageCache.get(b.messageId);case 52:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollUpdateEvent(b))){n.next=56;break}return n.next=56,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 56:this._broadcastPollUpdateEvent(b,C),n.next=71;break;case 59:if(!(t instanceof Bs)){n.next=70;break}return x=t.event,S=t.source,n.next=63,this._messageCache.get(x.messageId);case 63:if(!((T=n.sent)&&T.isUserMessage()&&T.poll&&T.poll.applyPollVoteEvent(x))){n.next=67;break}return n.next=67,mi((function(){return E(O,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([T]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 67:this._broadcastPollVoteEvent(x,S),n.next=71;break;case 70:t instanceof Hs?(I=t.event,N=t.source,I.messageId>0&&this._broadcastReactionUpdateEvent(I,N)):t instanceof Gs&&(A=t.event,M=t.source,this._broadcastThreadUpdateEvent(A,M));case 71:case"end":return n.stop()}}),n,this)})))})),i}return c(a,t),i(a,[{key:"_cacheContext",get:function(){return ss.of(this._iid).cacheContext}},{key:"_dispatcher",get:function(){return ss.of(this._iid).dispatcher}},{key:"_messageCache",get:function(){return Xd.of(this._iid)}},{key:"_unsentMessageCache",get:function(){return Yd.of(this._iid)}},{key:"_notificationCache",get:function(){return $d.of(this._iid)}},{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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=s(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=s(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=s(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=s(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=s(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:"_broadcastReactionUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onReactionUpdate&&a.onReactionUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastThreadUpdateEvent",value:function(e,t){var n,r=s(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onThreadInfoUpdate&&a.onThreadInfoUpdate(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()}}],[{key:"of",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return eh[e]&&!n||(eh[e]&&(null===(t=eh[e]._dispatcherContext)||void 0===t||t.close()),eh[e]=new a(e)),eh[e]}}])}($a),nh=function(e){function t(e){var a;r(this,t);var i=e.reverse,s=void 0!==i&&i,o=e.limit,u=void 0===o?20:o,c=e.keys,l=e.token;return(a=n(this,t)).method=_e.GET,a.path="".concat(De),a.params=pe({token:l,limit:u,reverse:s,order:oe.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:c}),a}return c(t,e),i(t)}(Ve),rh=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.next,o=a.has_more,u=void 0!==o&&o,c=a.templates;return i.nextToken=s,i.hasMore=u,i.templates=c.map((function(e){return{template:JSON.stringify(e)}})),i}return c(t,e),i(t)}(ze),ah=function(e){function t(e){var a;r(this,t);var i=e.key;return(a=n(this,t)).method=_e.GET,a.path="".concat(De,"/").concat(i),a}return c(t,e),i(t)}(Ve),ih=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).template=JSON.stringify(a),i}return c(t,e),i(t)}(ze),sh={},oh=function(){return i((function e(t,n){var a=n.sdkState,i=n.dispatcher,s=n.requestQueue,o=n.onlineDetector,u=n.cacheContext;r(this,e),this._iid=t,this._sdkState=a,this._requestQueue=s,this._dispatcher=i,this._cacheContext=u,Xd.of(t),Yd.of(t),th.of(t),this.fileMessageQueue=new To(t,{sdkState:a,dispatcher:i,requestQueue:s,onlineDetector:o,cacheContext:u}),sh[t]=this}),[{key:"buildMessageFromSerializedData",value:function(t){var n=oi(t);if(n.notificationId)return new _o(this._iid,_o.payloadify(n));switch(n.messageType){case e.MessageType.USER:return new po(this._iid,po.payloadify(n));case e.MessageType.FILE:return vo._isMultipleFilesMessageSerializedData(n)?new vo(this._iid,vo.payloadify(n)):new yo(this._iid,yo.payloadify(n));case e.MessageType.ADMIN:return new ao(this._iid,ao.payloadify(n))}throw A.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return pe(ve({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 pe(ve({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){var n=this;return pe({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.map((function(e){return new Eo(n._iid,e)}))})}},{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=oi(e);return new Es(this._iid,Es.payloadify(t))}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Do(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Ro),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Ho(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Go),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessagesByMessageId",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Lo(Object.assign(Object.assign({channelType:n,channelUrl:t,token:String(r)},Ao),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Po),c=u.messages,this._dispatcher.dispatch(new Fs({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Lo(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},Ao),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Po),c=u.messages,this._dispatcher.dispatch(new Fs({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0;return E(this,void 0,void 0,d().mark((function e(){var u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new Lo(Object.assign(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},Ao),a),{checkingHasNext:s,checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.as(Po),h=l.messages,f=l.isContinuousMessages,p=l.hasNext,this._dispatcher.dispatch(new Fs({messages:h,source:i})),e.abrupt("return",{messages:h,isContinuousMessages:f,hasNext:p});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_THREADED_MESSAGE;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=new Lo(Object.assign(Object.assign(Object.assign({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:n},no),r),{replyType:e.ReplyType.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),i.next=3,this._requestQueue.send(s);case 3:return o=i.sent,u=o.as(Po),c=u.messages,(l=c.slice(1)).forEach((function(e){e.parentMessage=t})),this._dispatcher.dispatch(new Fs({messages:l,source:a})),i.abrupt("return",{parentMessage:c[0],threadedMessages:l});case 9:case"end":return i.stop()}}),i,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new nh(Object.assign({token:e},t)),n.next=3,this._requestQueue.send(r);case 3:return a=n.sent,i=a.as(rh),s=i.hasMore,o=i.nextToken,u=i.templates,n.abrupt("return",{hasMore:s,token:o,templates:u});case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new ah({key:e}),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(ih),i=a.template,t.abrupt("return",{template:i});case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageChangelogs",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Fo(pe(ve(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null},Oo),a)))),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(qo),c=u.updatedMessages,l=u.deletedMessagesInfo,h=u.hasMore,f=u.nextToken,p=l.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new Fs({messages:c,source:i})),p.length>0&&this._dispatcher.dispatch(new qs({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:c,deletedMessageIds:p,hasMore:h,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return sh[e]}}])}(),uh=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e])).targetMessageId=0;var s=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return s&&D("object",s)&&D("number",o)&&D("string",u)&&D("string",c)&&(i.threadInfo=new ds(e,s),i.targetMessageId=o,i.channelUrl=u,i.channelType=c),i}return c(t,e),i(t)}($a),ch={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},lh=function(t){return D("string",t.channelUrl)&&R(e.ChannelType,t.channelType)&&D("number",t.messageId)&&D("boolean",t.includeReactions,!0)&&D("boolean",t.includeMetaArray,!0)&&D("boolean",t.includeParentMessageInfo,!0)&&D("boolean",t.includeThreadInfo,!0)},dh=function(e){function t(e){var a,i=e.channelCustomType,s=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,d=e.order,h=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(xe,"/messages"),a.params={custom_type:i,query:s,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:h,message_ts_to:f,sort_field:d,advanced_query:p,target_fields:v,after:_},a}return c(t,e),i(t)}(Ve),hh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).messages=a.results.map((function(t){return go(e,t)})),i.hasNext=a.has_next,i.nextToken=a.end_cursor,i.totalCount=a.total_count,i}return c(t,e),i(t)}(ze);e.MessageSearchOrder=void 0,(Vd=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",Vd.TIMESTAMP="ts";var fh,ph,vh,_h=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v;return r(this,a),(s=n(this,a,[t,i])).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=i.keyword,s.reverse=null!==(o=i.reverse)&&void 0!==o&&o,s.exactMatch=null!==(u=i.exactMatch)&&void 0!==u&&u,s.channelUrl=null!==(c=i.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=i.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(d=i.messageTimestampFrom)&&void 0!==d?d:null,s.messageTimestampTo=null!==(h=i.messageTimestampTo)&&void 0!==h?h:null,s.order=null!==(f=i.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=i.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=i.targetFields)&&void 0!==v?v:null,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.keyword)&&this.keyword.length>0&&D("boolean",this.reverse)&&D("boolean",this.exactMatch)&&D("string",this.channelUrl)&&D("string",this.channelCustomType)&&(D("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(D("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&R(e.MessageSearchOrder,this.order)&&D("boolean",this.advancedQuery)&&P("string",this.targetFields,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new dh(ve(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(hh),s=i.messages,o=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,e.abrupt("return",s);case 15:return e.abrupt("return",[]);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}])}(pu),mh=function(e){function t(e){var a,i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/messages/parent_thread_message"),a.params=pe(ve({limit:o,token:u})),a}return c(t,e),i(t)}(Ve),gh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).token=a.next,i.messages=a.messages.map((function(t){return go(e,t)})),i}return c(t,e),i(t)}(ze),yh=function(e){function t(e,a,i,s){var o;return r(this,t),(o=n(this,t,[e,a,i,s]))._edge="",o}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])}},{key:"load",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new mh({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(gh),s=i.messages,o=i.token,this._edge=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);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)})))}}])}(vu),Eh={channelUrl:"",scheduledMessageId:0},kh=function(e){return D("string",e.channelUrl)&&""!==e.channelUrl&&D("number",e.scheduledMessageId)&&e.scheduledMessageId>0},bh={reverse:!1,limit:20},Ch=function(e){return D("boolean",e.reverse,!0)&&D("number",e.limit,!0)&&P("string",e.keys,!0)},wh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="message",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new oh(e,{sdkState:r,dispatcher:a,requestQueue:s,onlineDetector:u,cacheContext:c})}},{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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},ch),e),ui(lh(n)).throw(A.invalidParameters),t.next=4,this._manager.getMessage(n);case 4:if(!((r=t.sent)instanceof eo||r instanceof _o||null===r)){t.next=7;break}return t.abrupt("return",r);case 7:throw"Unknown message type is given.";case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Eh),e),ui(kh(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageTemplatesByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},bh),t),ui(D("string",e,!0)&&Ch(r)).throw(A.invalidParameters),n.abrupt("return",this._manager.getMessageTemplatesByToken(e,r));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageTemplate",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getMessageTemplate(e));case 2:case"end":return t.stop()}}),t,this)})))}}])}(os),xh=i((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})),Sh=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="poll",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new el(e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c})}},{key:"create",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Kc),e),ui(Wc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.create(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Xc),e),ui(Jc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.get(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Yc),e),ui(Zc(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getOption(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}])}(os),Th={profileImage:void 0,profileUrl:void 0,nickname:void 0},Ih=function(e){return H(e.profileImage,!0)&&D("string",e.profileUrl,!0)&&D("string",e.nickname,!0)};e.GroupChannelListOrder=void 0,(fh=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",fh.CHRONOLOGICAL="chronological",fh.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",fh.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(ph=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",ph.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",ph.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(vh=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",vh.SCHEDULED_AT="scheduled_at";var Nh,Ah=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"]}},Mh=function(t){return{v2:function(){return E(void 0,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.commitSchema([{collectionName:tl,keyName:"url",index:[Ah(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),Ah(e.GroupChannelListOrder.CHRONOLOGICAL),Ah(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:nl,keyName:"messageId",index:[zd(Hd.CHANNEL_LATEST),zd(Hd.NEWEST_CHILD_MESSAGE)]},{collectionName:Kd,keyName:"reqId",index:[zd(Hd.CHANNEL_LATEST),zd(Hd.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))},v3:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:"FeedChannel",keyName:"url",index:[["-lastMessageUpdatedAt","-createdAt","syncIndex"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))},v4:function(){return E(void 0,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.commitSchema([{collectionName:rl,keyName:"notificationId",index:[["channelUrl","-createdAt","-notificationId"]]}]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}},Oh=function(t){return function(n,r){return E(void 0,void 0,void 0,d().mark((function a(){var i,s,o,u,c;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=n,a.next=1===a.t0||2===a.t0||3===a.t0||4===a.t0?3:5===a.t0?5:6===a.t0?9:26;break;case 3:return r(),a.abrupt("break",27);case 5:return a.next=7,t.reset();case 7:return r(),a.abrupt("break",27);case 9:return a.prev=9,i=Mh(t),s=i.v2,o=i.v3,u=i.v4,a.next=13,s();case 13:return a.next=15,o();case 15:return a.next=17,u();case 17:return c=t.collection(nl),a.next=20,c.removeIf({where:{channelType:e.ChannelType.OPEN}});case 20:a.next=24;break;case 22:a.prev=22,a.t1=a.catch(9);case 24:return r(),a.abrupt("break",27);case 26:r();case 27:case"end":return a.stop()}}),a,null,[[9,22]])})))}},Uh=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Dh=function(e){function t(e){var a,i=e.getVisibilityState,s=void 0===i?Uh:i,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,d=e.pauseCheckDelay,h=void 0===d?3e4:d;return r(this,t),(a=n(this,t))._pauseCheckDelay=3e4,a._currentState="visible",a._getVisibilityState=s,a._pauseCheckDelay=h,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(a),a}return c(t,e),i(t,[{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})}}])}(de),Rh=function(){return i((function e(t){var n=this,a=t.logger,i=t.connectionDelegate,s=void 0===i?null:i;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,s&&(this.connectionDelegate=s)}),[{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,d().mark((function e(){return d().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:_e.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}])}(),Lh=function(e){function t(e){var a,i=e.message;return r(this,t),(a=n(this,t)).message=i,a}return c(t,e),i(t)}(fe),Ph={},Fh=function(){return i((function e(t,n){var a=this,i=n.localCacheEnabled,s=n.enableAutoResend,o=n.dispatcher,u=n.sdkState,c=n.logger;r(this,e),this._iid=t,Ph[t]=this,this._localCacheEnabled=i,this._enableAutoResend=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=o,this._logger=c,this._sdkState=u,this._localCacheEnabled&&o.on((function(e){if(e instanceof Ha)switch(e.stateType){case Da.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case Da.INTERNAL_DISCONNECTED:case Da.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}),[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._enableAutoResend){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this._fetchAllCachedPendingMessages();case 4:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)0===(i=a.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=e.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new Fs({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){r.e(e)}finally{r.f()}case 7:case"end":return t.stop()}}),t,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:n=t.sent,r=s(n);try{for(r.s();!(a=r.n()).done;)i=a.value,this._enableAutoResend&&i.errorCode&&q(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,this._enableAutoResend&&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 Fs({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return t.stop()}}),t,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&this._enableAutoResend&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!q(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,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Yd.of(this._iid),(r=new jd).replyType=e.ReplyType.ALL,t.next=5,n.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0,filter:r});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&this._enableAutoResend&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),t=this._autoResendQueue[0],this._dispatcher.dispatch(new Lh({message:t})),this._logger.debug("processing auto-resend for message request id: ",t.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Ph[e]}}])}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Nh||(Nh={}));var qh,Hh=function(){return i((function e(t){r(this,e),this.category=t.cat,this.data=t.data}),null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new li(e,r),blockee:new li(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 li(e,t)})):[]}}}])}(),Gh=function(e){function t(){return r(this,t),n(this,t,arguments)}return c(t,e),i(t)}(fe),jh=function(e){function t(e,a){var i,s=a.userId;return r(this,t),(i=n(this,t))._iid=e,i.userId=s,i}return c(t,e),i(t)}(fe),Vh=function(e){function t(){return r(this,t),n(this,t)}return c(t,e),i(t)}(fe),zh=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"USEV",i])).event=new Hh(i),s}return c(t,e),i(t)}(Ke),Bh=function(e){function t(e){var a,i=e.userId,s=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i)),a.params=pe(ve({nickname:s,profile_url:o,profile_file:u,preferred_languages:c})),a}return c(t,e),i(t)}(Ve),Qh=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).user=new li(e,Object.assign({},a)),i}return c(t,e),i(t)}(ze),Kh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a.params=pe({apns_device_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(Ve),Wh=function(e){function t(e){var a,i=e.userId,s=e.token,o=e.deviceOS,u=e.deviceManufacturer,c=e.systemPushEnabled;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a.params=pe({gcm_reg_token:s,always_push:!0,device_os:o,device_manufacturer:u,system_push_enabled:c}),a}return c(t,e),i(t)}(Ve),Yh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),Zh=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),Xh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/apns"),a}return c(t,e),i(t)}(Ve),Jh=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/gcm"),a}return c(t,e),i(t)}(Ve),$h=function(e){function t(e){var a,i=e.userId,s=e.type,o=e.token,u=e.ts;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/").concat(encodeURIComponent(s),"/device_tokens"),a.params={created_ts:u,token:o},a}return c(t,e),i(t)}(Ve),ef=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).pushTokens={type:i.type?e.PushTokenType[i.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:i.device_tokens,hasMore:i.has_more,token:i.token},s}return c(a,t),i(a)}(ze),tf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a}return c(t,e),i(t)}(Ve),nf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(ze),rf=function(e){function t(e){var a,i=e.userId,s=e.willAutoAccept;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a.params={auto_accept:s},a}return c(t,e),i(t)}(Ve),af=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).autoAccept=a.auto_accept,i}return c(t,e),i(t)}(ze),sf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(Ve),of=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(ze),uf=function(e){function t(e){var a,i=e.userId,s=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,d=e.timezone;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={do_not_disturb:s,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:d},a}return c(t,e),i(t)}(Ve),cf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return c(t,e),i(t)}(ze),lf=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(Ve),df=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(ze),hf=function(e){function t(e){var a,i=e.userId,s=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={snooze_enabled:s,snooze_start_ts:o,snooze_end_ts:u},a}return c(t,e),i(t)}(Ve),ff=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return c(t,e),i(t)}(ze),pf=function(e){function t(e){var a,i=e.userId,s=e.blockedUserId;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block"),a.params={target_id:s},a}return c(t,e),i(t)}(Ve),vf=function(e){function t(e){var a,i=e.userId,s=e.unblockedUserId;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/block/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),_f=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a}return c(t,e),i(t)}(Ve),mf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(ze),gf=function(e){function t(e){var a,i=e.userId,s=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={push_trigger_option:s},a}return c(t,e),i(t)}(Ve),yf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i}return c(t,e),i(t)}(ze),Ef=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a}return c(t,e),i(t)}(Ve),kf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(ze),bf=function(e){function t(e){var a,i=e.userId,s=e.templateName;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push/template"),a.params={name:s},a}return c(t,e),i(t)}(Ve),Cf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).name=a.name,i}return c(t,e),i(t)}(ze),wf=function(e){function t(e){var a,i=e.userId,s=e.token;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends/changelogs"),a.params={token:s},a}return c(t,e),i(t)}(Ve),xf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).changelogs={addedUsers:a.added.map((function(t){return new li(e,t)})),updatedUsers:a.updated.map((function(t){return new li(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},i}return c(t,e),i(t)}(ze),Sf=function(e){function t(e){var a,i=e.userId,s=e.discoveries;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discoveries:s.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return c(t,e),i(t)}(Ve),Tf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).friendDiscoveryRequestId=a.friend_discovery_request_id,i}return c(t,e),i(t)}(ze),If=function(e){function t(e){var a,i=e.userId,s=e.discoveryKeys;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discovery_keys:s},a}return c(t,e),i(t)}(Ve),Nf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.POST,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(Ve),Af=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).users=a.users.map((function(t){return new li(e,t)})),i}return c(t,e),i(t)}(ze),Mf=function(e){function t(e){var a,i=e.userId,s=e.userIds;return r(this,t),(a=n(this,t)).method=_e.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return c(t,e),i(t)}(Ve),Of=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={},a}return c(t,e),i(t)}(Ve),Uf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).allowFriendDiscovery=a.allow_friend_discovery,i}return c(t,e),i(t)}(ze),Df=function(e){function t(e){var a,i=e.userId,s=e.allowFriendDiscovery;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(i,"/allow_friend_discovery"),a.params={allow_friend_discovery:s},a}return c(t,e),i(t)}(Ve),Rf=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path=Ie,e}return c(t,e),i(t)}(Ve),Lf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiContainer=new wl(a),i}return c(t,e),i(t)}(ze),Pf=function(e){function t(e){var a,i=e.categoryId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ie,"/").concat(i),a}return c(t,e),i(t)}(Ve),Ff=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emojiCategory=new Cl(a),i}return c(t,e),i(t)}(ze),qf=function(e){function t(e){var a,i=e.key;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Te,"/").concat(i),a}return c(t,e),i(t)}(Ve),Hf=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).emoji=new bl(a),i}return c(t,e),i(t)}(ze),Gf=function(e){function t(){var e;return r(this,t),(e=n(this,t)).method=_e.GET,e.path="".concat(Me),e}return c(t,e),i(t)}(Ve),jf=function(e){function t(e,a){var i,s;r(this,t);var o=null!=a?a:{};return(i=n(this,t,[e,a])).uikitConfiguration={string:JSON.stringify(o),json:o},i.updatedAt=null!==(s=null==a?void 0:a.updated_at)&&void 0!==s?s:0,i}return c(t,e),i(t)}(ze);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(qh||(qh={}));var Vf,zf=function(e){function t(e){var a,i=e.deviceToken,s=e.pushTrackingId,o=e.messageId,u=e.allowedPushNotification,c=e.channelKey,l=e.templateKey,d=e.eventType,h=e.notificationEventDeadline;return r(this,t),(a=n(this,t)).method=_e.POST,a.path=Re,a.params=pe({device_token:i,push_tracking_id:s,message_id:o,allowed_push_notification:u,channel_key:c,template_key:l,event_type:d,notification_event_deadline:h}),a}return c(t,e),i(t)}(Ve);var Bf,Qf=function(){function t(e,n,a){var i=this;r(this,t),this._storeInitialized=!1,this._iid=e,this.options=n;var s=ss.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,l=s.sessionManager,h=s.requestQueue,f=s.logger,p=s.userEventHandlers,v=s.appStateToggleEnabled;this._onlineDetector=new Rh({logger:f,connectionDelegate:{reconnect:function(){return E(i,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=ss.of(e),r=n.sdkState,a=n.connectionManager,(i=n.sessionManager).session.hasSession){t.next=14;break}return t.prev=2,t.next=5,a.connect(i.session.authToken);case 5:t.next=12;break;case 7:if(t.prev=7,t.t0=t.catch(2),!N(t.t0)){t.next=11;break}throw t.t0;case 11:f.debug("connect failed by reconnect event = ",t.t0);case 12:t.next=25;break;case 14:if("foreground"!==r.appState){t.next=25;break}return t.prev=15,t.next=18,a.resetAndReconnect();case 18:t.next=25;break;case 20:if(t.prev=20,t.t1=t.catch(15),!N(t.t1)){t.next=24;break}throw t.t1;case 24:f.debug("resetAndReconnect failed by reconnect event = ",t.t1);case 25:c.dispatch(new Gh);case 26:case"end":return t.stop()}}),t,null,[[2,7],[15,20]])})))},disconnect:function(){mi((function(){return E(i,void 0,void 0,d().mark((function t(){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(e),r=n.connectionManager,t.next=3,r.disconnect();case 3:case"end":return t.stop()}}),t)})))}))}}});var _=new Fh(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,dispatcher:c,sdkState:o,logger:f});a.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:l,requestQueue:h,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new Dh({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()})),c.on((function(t){var n;if(t instanceof Ha){if(t.stateType===Da.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof Ke){if("USEV"===t.code){var r=t.as(zh).event;if(r.category===Nh.FRIEND_DISCOVERED){var a=Hh.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().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(t instanceof La){var s=ss.of(i._iid).subscribedUnreadMessageCount,c=!1,l=t.ts;"number"==typeof l&&l>s.ts&&(s.all!==t.all&&(c=!0),s.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){s.customTypes[e]!==t.customTypes[e]&&(c=!0),s.customTypes[e]=t.customTypes[e]})),c=c&&s.ts>0,s.ts=l),c&&_i((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:s.all,feedChannelCount:s.feed,customTypeUnreadCount:s.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else t instanceof di?(u.preference.set(i._getUserProfileCacheKey(o.userId),hi.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(Ba(i.appId),{value:!0})):t instanceof Qe&&t.error&&t.error.isSessionInvalidatedError&&(f.debug("session revoked."),i._internalDisconnect(t.error))}))}return i(t,[{key:"appId",get:function(){return ss.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=ss.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=ss.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!ss.of(this._iid).debugMode}},{key:"logLevel",get:function(){return ss.of(this._iid).logger.level},set:function(e){ss.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return ss.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=ss.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return ss.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=ss.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=ss.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=ss.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:"_getNestDBVersion",value:function(){return 7}},{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:"_internalDisconnect",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.connectionManager,a=n.sdkState,i=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),t.next=6,r.logout(e);case 6:return t.next=8,this.clearCachedData();case 8:a.appState="foreground";case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getMemoryStoreForDebugging",value:function(){var e=ss.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Md?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=ss.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)}},{key:"addSendbirdExtensions",value:function(e,t,n){var r=ss.of(this._iid),a=r.logger,i=r.sdkState,s=new RegExp("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");if(0===e.length)return a.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!s.test(e.version)})))return a.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(var o=0,u=Object.entries(n);o2&&void 0!==arguments[2]?arguments[2]:{};return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(ui(D("string",e)&&D("string",t,!0)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,s=a.cacheContext,o=a.connectionManager,u=n.errorForOtherUser,!i.userId||i.userId===e){r.next=10;break}if(u){r.next=9;break}return r.next=7,o.logout();case 7:r.next=10;break;case 9:throw u;case 10:return r.prev=10,r.next=13,this.initializeCache(e);case 13:c=ss.of(this._iid),c.dispatcher.dispatch(new Vh),r.next=22;break;case 17:r.prev=17,r.t0=r.catch(10),l=ss.of(this._iid),h=l.logger,s.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 22:case"end":return r.stop()}}),r,this,[[10,17]])})))}},{key:"authenticateFeed",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.authenticate(e,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"authenticate",value:function(e,t){var n;return E(this,void 0,void 0,d().mark((function r(){var a,i,s;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=ss.of(this._iid),i=a.sessionManager,s=a.connectionManager,r.next=3,this._ready(e,t,{errorForOtherUser:s.isConnected?A.alreadyConnectedAsAnotherUser:void 0});case 3:if(null===(n=i.session.services)||void 0===n?void 0:n.includes(Q.CHAT)){r.next=7;break}return t||i.handler||this.setSessionHandler(new Sl),r.next=7,i.authenticate(e,t);case 7:return r.abrupt("return",this.currentUser);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"connect",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._ready(e,t);case 2:return n.prev=2,r=ss.of(this._iid),a=r.connectionManager,n.next=6,a.connect(t);case 6:return n.prev=6,this._onlineDetector.start(),this._appStateChangeDetector.start(),n.finish(6);case 10:return n.abrupt("return",this.currentUser);case 11:case"end":return n.stop()}}),n,this,[[2,,6,10]])})))}},{key:"reconnect",value:function(){var e=ss.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.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,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._internalDisconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.connectionManager,r=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),e.next=6,n.disconnectWebSocket(!0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=ss.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().catch((function(e){r.debug("setBackgroundState error = ",e)})))}},{key:"setForegroundState",value:function(){var e=ss.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,a=e.logger;"background"===n.appState&&(n.appState="foreground",a.debug("going foreground state"),t.resetAndReconnect().catch((function(e){a.debug("setForgroundState error = ",e)})),r.dispatch(new Gh))}},{key:"setSessionHandler",value:function(e){ui(e instanceof Sl).throw(A.invalidParameters),ss.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){ui(D("string",e)&&t instanceof Tl).throw(A.invalidParameters),ss.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){ss.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){ss.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){ui(D("string",e)&&t instanceof xl).throw(A.invalidParameters),ss.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){ss.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){ss.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Al(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ul(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ll(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new _h(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new sl(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new cl(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=oi(e);return new li(this._iid,li.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Object.assign(Object.assign({},Th),e),ui(Ih(n)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Bh(Object.assign({userId:a.userId},n)),t.next=7,i.send(s);case 7:return o=t.sent,u=o.as(Qh),c=u.user,this.currentUser&&(n.nickname&&(this.currentUser.nickname=c.nickname),(n.profileUrl||n.profileImage)&&(this.currentUser.plainProfileUrl=c.profileUrl)),t.abrupt("return",c);case 13:throw A.connectionRequired;case 14:case"end":return t.stop()}}),t,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ui(P("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Bh({userId:r.userId,preferredLanguages:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Qh),u=o.user,this.currentUser&&(this.currentUser.preferredLanguages=u.preferredLanguages),t.abrupt("return",u);case 12:throw A.connectionRequired;case 13:case"end":return t.stop()}}),t,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ui(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ui(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.ANDROID,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=ss.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.FCM,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new Wh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,mi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.FCM,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._fcmPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._fcmPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=ss.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Zh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,mi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.FCM,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=ss.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Jh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,mi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.FCM),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(t,n){var r,a;return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l,h,f=this;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(ui(D("string",t)&&D("string",null==n?void 0:n.deviceManufacturer,!0)).throw(A.invalidParameters),(null==n?void 0:n.deviceOS)&&ui(R(e.DeviceOsPlatform,n.deviceOS.platform,!0)&&D("string",n.deviceOS.version,!0)).throw(A.invalidParameters),!this.currentUser){i.next=22;break}if(s={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||e.DeviceOsPlatform.IOS,"-").concat((null===(a=null==n?void 0:n.deviceOS)||void 0===a?void 0:a.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},i.prev=4,o=ss.of(this._iid),u=o.sessionManager,c=o.sdkState,l=o.requestQueue,!u.hasDeviceToken(e.PushTokenType.APNS,t)){i.next=8;break}return i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 8:return h=new Kh({userId:c.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled}),i.next=11,l.send(h);case 11:return i.next=13,mi((function(){return E(f,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u.setDeviceToken(e.PushTokenType.APNS,t,s),n.next=3,u.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 13:return this._apnsPushToken="",i.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 17:return i.prev=17,i.t0=i.catch(4),i.abrupt("return",e.PushTokenRegistrationState.ERROR);case 20:i.next=24;break;case 22:return this._apnsPushToken=t,i.abrupt("return",e.PushTokenRegistrationState.PENDING);case 24:case"end":return i.stop()}}),i,this,[[4,17]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ui(D("string",t)).throw(A.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=ss.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Yh({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,mi((function(){return E(l,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.APNS,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._apnsPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._apnsPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=ss.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Xh({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,mi((function(){return E(c,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.APNS),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markPushNotificationAsDelivered",value:function(e){var t,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l,h,f,p,v,_,m,g,y,E,k,b;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=ss.of(this._iid),i=a.logger,s=a.sessionManager,o=a.requestQueue,u=a.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=qh.DELIVERED,l=u.parseData(e),h=l.pushTrackingId,f=l.sessionTopics,p=l.sessionKey,v=l.messageId,_=l.channelKey,m=l.templateKey,g=l.notificationEventDeadline,p){r.next=7;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 7:if(f.includes(Qi.PUSH_ACKNOWLEDGEMENT)){r.next=10;break}throw i.info("Can't use markPushNotificationAsDelivered() feature."),A.malformedDataError;case 10:if(!u.isAcked(h,c)){r.next=13;break}return i.info("already delivered push notification:",h),r.abrupt("return");case 13:return y=Boolean(_),E=n&&y,k=null===(t=s.deviceTokens[0])||void 0===t?void 0:t.token,b=new zf({deviceToken:null!=k?k:"",pushTrackingId:h,eventType:c,messageId:v,channelKey:_,templateKey:m,notificationEventDeadline:g,allowedPushNotification:E}),p&&(b.headers["Session-Key"]=p),r.prev=18,r.next=21,o.send(b);case 21:u.markAsAcked(h,c),r.next=28;break;case 24:throw r.prev=24,r.t0=r.catch(18),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(h,". error: ").concat(r.t0)),r.t0;case 28:case"end":return r.stop()}}),r,this,[[18,24]])})))}},{key:"markPushNotificationAsClicked",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h,f,p,v,_,m,g,y;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=ss.of(this._iid),a=r.logger,i=r.sessionManager,s=r.requestQueue,o=r.pushNotificationAckManager,a.debug("markPushNotificationAsClicked:",e),u=qh.CLICKED,c=o.parseData(e),l=c.pushTrackingId,h=c.sessionTopics,f=c.sessionKey,p=c.messageId,v=c.channelKey,_=c.templateKey,m=c.notificationEventDeadline,f){n.next=7;break}throw a.info("Can't use markPushNotificationAsClicked() feature."),A.malformedDataError;case 7:if(h.includes(Qi.PUSH_ACKNOWLEDGEMENT)){n.next=10;break}throw a.info("Can't use markPushNotificationAsClicked() feature."),A.malformedDataError;case 10:if(!o.isAcked(l,u)){n.next=13;break}return a.info("already clicked push notification:",l),n.abrupt("return");case 13:return g=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,y=new zf({deviceToken:null!=g?g:"",pushTrackingId:l,eventType:u,messageId:p,channelKey:v,templateKey:_,notificationEventDeadline:m}),f&&(y.headers["Session-Key"]=f),n.prev=16,n.next=19,s.send(y);case 19:o.markAsAcked(l,u),n.next=26;break;case 22:throw n.prev=22,n.t0=n.catch(16),a.debug("failed to mark push notification as clicked. push tracking id: ".concat(l,". error: ").concat(n.t0)),n.t0;case 26:case"end":return n.stop()}}),n,this,[[16,22]])})))}},{key:"getChannelInvitationPreference",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new tf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(nf),o=s.autoAccept,e.abrupt("return",{autoAccept:o});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("boolean",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new rf({userId:r.userId,willAutoAccept:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(af),u=o.autoAccept,t.abrupt("return",{autoAccept:u});case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getDoNotDisturb",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new sf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(of),o=s.preference,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return ui(D("boolean",e)&&D("number",t)&&D("number",n)&&D("number",r)&&D("number",a)&&D("string",i)).throw(A.invalidParameters),o=ss.of(this._iid),u=o.sdkState,c=o.requestQueue,l=new uf({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:a,timezone:i}),s.next=5,c.send(l);case 5:return h=s.sent,f=h.as(cf),p=f.preference,s.abrupt("return",p);case 8:case"end":return s.stop()}}),s,this)})))}},{key:"getSnoozePeriod",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new lf({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(df),o=s.snoozePeriod,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c,l;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("boolean",e)&&D("number",t)&&D("number",n)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new hf({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),r.next=5,s.send(o);case 5:return u=r.sent,c=u.as(ff),l=c.snoozePeriod,r.abrupt("return",l);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"getMyPushTokensByToken",value:function(t,n){return E(this,void 0,void 0,d().mark((function r(){var a,i,o,u,c,l,h,f,p,v,_;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",t)&&R(e.PushTokenType,n)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.sdkState,o=a.requestQueue,u=a.sessionManager,c=new $h({userId:i.userId,type:n,token:t}),r.next=5,o.send(c);case 5:l=r.sent,h=l.as(ef),f=h.pushTokens,p=s(f.deviceTokens);try{for(p.s();!(v=p.n()).done;)_=v.value,u.setDeviceToken(f.type,_)}catch(e){p.e(e)}finally{p.f()}return r.next=11,u.saveDeviceToken();case 11:return r.abrupt("return",f);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"getPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new _f({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(mf).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new gf({userId:a.userId,pushTriggerOption:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(yf).pushTriggerOption);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"getPushTemplate",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ef({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(kf).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.PushTemplate,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new bf({userId:a.userId,templateName:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(Cf).name);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"blockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(e instanceof li||D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new pf({userId:r.userId,blockedUserId:e instanceof li?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUser",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(e instanceof li||D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new vf({userId:r.userId,unblockedUserId:e instanceof li?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new wf({userId:r.userId,token:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(xf),u=o.changelogs,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Of({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Uf),o=s.allowFriendDiscovery,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("boolean",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Df({userId:r.userId,allowFriendDiscovery:e}),t.next=5,a.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Sf({userId:r.userId,discoveries:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(Tf),u=o.friendDiscoveryRequestId,t.abrupt("return",u);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new If({userId:r.userId,discoveryKeys:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"addFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Nf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(Af),u=o.users,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriend",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriends",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(P("string",e)).throw(A.invalidParameters),n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Mf({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getAllEmoji",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new Rf,e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Lf),s=i.emojiContainer,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new Pf({categoryId:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Ff),o=s.emojiCategory,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getEmoji",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.requestQueue,a=new qf({key:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Hf),o=s.emoji,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getUIKitConfiguration",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),ui(t.hasExtension("sb_uikit")).throw(A.notSupportedError),n=t.requestQueue,r=new Gf,e.next=6,n.send(r);case 6:return a=e.sent,i=a.as(jf),s=i.uikitConfiguration,e.abrupt("return",s);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(n){var r=n.appId,a=n.appVersion,i=n.modules,s=void 0===i?[]:i,o=n.options,u=void 0===o?new j:o,c=n.debugMode,l=void 0!==c&&c,d=n.customApiHost,h=n.customWebSocketHost,f=n.newInstance,p=void 0!==f&&f,_=n.logLevel,m=n.localCacheEnabled,g=void 0!==m&&m,y=n.localCacheConfig,E=void 0===y?new W:y,k=n.localCacheEncryption,b=n.useAsyncStorageStore,C=void 0===b?null:b,w=n.useMMKVStorageStore,x=void 0===w?null:w,S=n.appStateToggleEnabled,T=void 0===S||S;if(!Vf||p){var I="su-".concat(ce()),N=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},A=new Gd;A.level=null!=_?_:e.LogLevel.WARN;var M=new Md({encryption:N});l||(it()?x?M=new Ld({MMKV:x,encryption:N}):C&&(M=new Rd({AsyncStorage:C,encryption:N}),A.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):M=new Dd({encryption:N})),new ss(I,{appId:r,appVersion:a,options:u,apiHost:null!=d?d:"https://api-".concat(r,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(r,".sendbird.com"),store:M,encryption:N,logger:A,localCacheEnabled:g,localCacheConfig:E,debugMode:l,appStateToggleEnabled:T});var O=[new wh,new Sh],U=new t(I,u,[].concat(v(s),O));return Vf||(Vf=U),U}return Vf}},{key:"instance",get:function(){return Vf}},{key:"version",get:function(){return b}}])}();e.MemberState=void 0,(Bf=e.MemberState||(e.MemberState={})).NONE="none",Bf.JOINED="joined",Bf.INVITED="invited",Bf.LEFT="left";var Kf,Wf,Yf,Zf,Xf,Jf,$f,ep,tp=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).state=null,s.role=null,s.isMuted=!1,s.isBlockedByMe=!1,s.isBlockingMe=!1,s.state=R(e.MemberState,i.state)?i.state:null,s.role=R(e.Role,i.role)?i.role:null,"boolean"==typeof i.is_muted&&(s.isMuted=i.is_muted),"boolean"==typeof i.is_blocked_by_me&&(s.isBlockedByMe=i.is_blocked_by_me),"boolean"==typeof i.is_blocking_me&&(s.isBlockingMe=i.is_blocking_me),s}return c(a,t),i(a,null,[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},p(a,"payloadify",this,2)([e])),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}])}(Vo),np=function(t){function a(t,i){var s,o,u;return r(this,a),(s=n(this,a,[t])).channelUrl=null!==(o=i.channel_url)&&void 0!==o?o:"",s.channelType=null!==(u=i.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,s.member=new li(s._iid,i.user),s.deliveryAt=i.ts,s}return c(a,t),i(a)}($a);e.PublicChannelFilter=void 0,(Kf=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",Kf.PUBLIC="public",Kf.PRIVATE="private",e.MyMemberStateFilter=void 0,(Wf=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",Wf.JOINED="joined_only",Wf.INVITED="invited_only",Wf.INVITED_BY_FRIEND="invited_by_friend",Wf.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(Yf=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",Yf.SUPER="super",Yf.NON_SUPER="nonsuper",Yf.BROADCAST_ONLY="broadcast_only",Yf.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(Zf=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",Zf.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(Xf=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",Xf.UNHIDDEN="unhidden_only",Xf.HIDDEN="hidden_only",Xf.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Xf.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(Jf=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",Jf.OPERATOR="operator",Jf.NONOPERATOR="nonoperator",e.QueryType=void 0,($f=e.QueryType||(e.QueryType={})).AND="AND",$f.OR="OR",e.GroupChannelSearchField=void 0,(ep=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",ep.CHANNEL_NAME="channel_name";var rp,ap=function(){function t(n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m,g;r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=null!==(a=null==n?void 0:n.includeEmpty)&&void 0!==a&&a,this.nicknameContainsFilter=null!==(i=null==n?void 0:n.nicknameContainsFilter)&&void 0!==i?i:null,this.nicknameStartsWithFilter=null!==(s=null==n?void 0:n.nicknameStartsWithFilter)&&void 0!==s?s:null,this.nicknameExactMatchFilter=null!==(o=null==n?void 0:n.nicknameExactMatchFilter)&&void 0!==o?o:null,this.channelNameContainsFilter=null!==(u=null==n?void 0:n.channelNameContainsFilter)&&void 0!==u?u:"",this.myMemberStateFilter=null!==(c=null==n?void 0:n.myMemberStateFilter)&&void 0!==c?c:e.MyMemberStateFilter.ALL,this.customTypesFilter=null!==(l=null==n?void 0:n.customTypesFilter)&&void 0!==l?l:null,this.channelUrlsFilter=null!==(d=null==n?void 0:n.channelUrlsFilter)&&void 0!==d?d:null,this.superChannelFilter=null!==(h=null==n?void 0:n.superChannelFilter)&&void 0!==h?h:e.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(f=null==n?void 0:n.publicChannelFilter)&&void 0!==f?f:e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null!==(p=null==n?void 0:n.customTypeStartsWithFilter)&&void 0!==p?p:null,this.unreadChannelFilter=null!==(v=null==n?void 0:n.unreadChannelFilter)&&void 0!==v?v:e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=null!==(_=null==n?void 0:n.hiddenChannelFilter)&&void 0!==_?_:e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=null===(m=null==n?void 0:n.includeFrozen)||void 0===m||m,(null==n?void 0:n.createdAfter)&&(this.createdAfter=n.createdAfter),(null==n?void 0:n.createdBefore)&&(this.createdBefore=n.createdBefore),this.includeMetaData=null===(g=null==n?void 0:n.includeMetaData)||void 0===g||g}return i(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,i=r.fields;if(a&&i&&i.length>0&&!i.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var s=this._userIdsFilter,o=s.userIds,u=s.includeMode,c=s.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=v(e).sort(),r=v(t).sort(),a=0;a0&&!this.customTypesFilter.includes("*")&&!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 d=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(d)})))return!1}if(this.nicknameStartsWithFilter){var h=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(h)})))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.ALL:if("none"===t.myMemberState)return!1;break;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!(this.createdAfter&&t.createdAtthis.createdBefore)}}])}(),ip=function(t){function a(e,t){var i,s=t.sdkState,o=t.cacheContext;return r(this,a),(i=n(this,a,[e]))._channels=new Map,i._sdkState=s,i._cacheContext=o,i}return c(a,t),i(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ui(!!e).throw(A.databaseError),e.collection(tl)}},{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 Iv.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return v(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>n||s&&t.createdAtn||s&&t.lastMessageUpdatedAte._messageCollectionLastAccessedAt&&Object.assign(e,{_messageCollectionLastAccessedAt:void 0}),e.cachedMetaData&&t)n._updateCachedMetaData(e.cachedMetaData,t).isUpdated||Object.assign(e,{_cachedMetaData:void 0});n._update(e),r.push(n)}else s._channels.set(e.url,e),r.push(e)})),!this.localCacheEnabled){n.next=7;break}for(a=[],i=0;i0)){r.next=76;break}return r.next=76,this.upsert(a);case 76:case"end":return r.stop()}}),r,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!0);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"unblock",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!1);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"markAsRead",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v(this._channels.keys());return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=s(t),n.prev=2,a.s();case 4:if((i=a.n()).done){n.next=12;break}return o=i.value,n.next=8,this.get(o);case 8:(null==(u=n.sent)?void 0:u._updateUnreadMemberState(this._sdkState.userId,e))&&(u._updateUnreadCount(0,0),r.push(u));case 10:n.next=4;break;case 12:n.next=17;break;case 14:n.prev=14,n.t0=n.catch(2),a.e(n.t0);case 17:return n.prev=17,a.f(),n.finish(17);case 20:if(!(r.length>0)){n.next=23;break}return n.next=23,this.upsert(r);case 23:case"end":return n.stop()}}),n,this,[[2,14,17,20]])})))}}])}($a);!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"}(rp||(rp={}));var sp,op=function(){return i((function e(t){var n;r(this,e),this.channelUrl=t.channel_url,this.channelType=t.channel_type,this.category=t.cat,this.data=null!==(n=t.data)&&void 0!==n?n:{},this.ts=t.ts}),[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}])}(),up={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},cp=function(e){return P("string",e.invitedUserIds,!0)&&D("string",e.channelUrl,!0)&&D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isSuper,!0)&&D("boolean",e.isBroadcast,!0)&&D("boolean",e.isExclusive,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isStrict,!0)&&D("boolean",e.isDiscoverable,!0)&&D("boolean",e.isEphemeral,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},lp={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},dp=function(e){return P("string",e.customTypes,!0)&&D("boolean",e.includeEmpty,!0)&&D("boolean",e.includeFrozen,!0)&&D("boolean",e.includeMetaData,!0)&&D("boolean",e.includeChatNotification,!0)},hp={myMemberStateFilter:e.MyMemberStateFilter.ALL},fp=function(t){return R(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(sp=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",sp.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",sp.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",sp.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",sp.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",sp.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",sp.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",sp.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",sp.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var pp,vp={keys:[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT,e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT,e.UnreadItemKey.NONSUPER_INVITATION_COUNT,e.UnreadItemKey.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},_p=function(t){return P(e.UnreadItemKey,t.keys)&&P("string",t.customTypeFilters,!0)&&P("string",t.customTypesFilter,!0)},mp={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},gp=function(t){return P("string",t.channelCustomTypesFilter,!0)&&R(e.SuperChannelFilter,t.superChannelFilter)},yp={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},Ep=function(t){return D("string",t.channelUrl,!0)&&P(e.ScheduledStatus,t.scheduledStatus,!0)&&R(e.MessageTypeFilter,t.messageTypeFilter)},kp=Object.assign({},e.CollectionEventSource),bp=function(t){return t.startsWith("EVENT_")||t===e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.CollectionEventSource.REFRESH_CHANNEL},Cp=function(e){function t(e){var a,i=e.channels,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.ts;return r(this,t),(a=n(this,t)).channels=i,a.context=s,a.isWebSocketEventComing=u,a.ts=c,a}return c(t,e),i(t)}(fe),wp=function(e){function t(e){var a,i=e.channelUrls,s=e.context,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,t),(a=n(this,t)).channelUrls=i,a.context=s,a.isWebSocketEventComing=u,a}return c(t,e),i(t)}(fe),xp=function(){return i((function t(n){var a=this,i=n.groupChannelCache,o=n.messageCache,u=n.unsentMessageCache,c=n.dispatcher;r(this,t),this._observers=new Map,c.on((function(t){return E(a,void 0,void 0,d().mark((function n(){var r,a,c,l,h,f,p,v,_,m,g,y,k,b,C,w=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t instanceof Cp)){n.next=47;break}if(r=t.channels,a=t.context,c=t.isWebSocketEventComing,l=r.filter((function(e){return e instanceof x_})),a.source!==e.CollectionEventSource.EVENT_CHANNEL_RESET_HISTORY&&a.source!==e.CollectionEventSource.EVENT_CHANNEL_HIDDEN){n.next=23;break}h=s(l),n.prev=5,h.s();case 7:if((f=h.n()).done){n.next=13;break}return p=f.value,n.next=11,o.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),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:n.next=41;break;case 23:v=i.filterOffsetChanged(l),_=s(v),n.prev=25,_.s();case 27:if((m=_.n()).done){n.next=33;break}return g=m.value,n.next=31,o.removeUnderOffset(g.url,g.messageOffsetTimestamp);case 31:n.next=27;break;case 33:n.next=38;break;case 35:n.prev=35,n.t1=n.catch(25),_.e(n.t1);case 38:return n.prev=38,_.f(),n.finish(38);case 41:return n.next=43,i.upsert(l,t.ts);case 43:y=n.sent,c||this._broadcastUpdateEvent(y,a),n.next=59;break;case 47:if(!(t instanceof wp)){n.next=56;break}return k=t.channelUrls,b=t.context,C=t.isWebSocketEventComing,n.next=51,i.remove(k);case 51:return n.next=53,mi((function(){return E(w,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(k),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=7,o.removeMessagesOfChannel(r);case 7:return e.next=9,u.removeMessagesOfChannel(r);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 53:C||this._broadcastRemoveEvent(k,b),n.next=59;break;case 56:if(!(t instanceof jh)){n.next=59;break}return n.next=59,i.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 59:case"end":return n.stop()}}),n,this,[[5,15,18,21],[25,35,38,41]])})))}))}),[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=s(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:"_broadcastRemoveEvent",value:function(e,t){var n,r=s(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()}}])}(),Sp=function(e){function t(e){var a,i=e.userId,s=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c;r(this,t),a=n(this,t);var d=Object.assign(Object.assign({},lp),u),h=d.customTypes,f=d.includeEmpty,p=d.includeFrozen;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels/changelogs"),a.params=pe(ve({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:s||null,token:o,custom_types:h,show_empty:f,show_frozen:p,include_chat_notification:l})),a}return c(t,e),i(t)}(Ve),Tp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).updatedChannels=a.updated.map((function(t){return new x_(e,Object.assign(t,{ts:a.ts}))})),i.deletedChannelUrls=a.deleted,i.hasMore=a.has_more,i.token=a.next,i.ts=a.ts,i}return c(t,e),i(t)}(ze),Ip=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall,o=e.showLatestMessage;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?be:ke,"/").concat(encodeURIComponent(i)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=o&&o},a}return c(t,e),i(t)}(Ve),Np=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),Ap={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,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,createdAfter:void 0,createdBefore:void 0},Mp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,d=e.superChannelFilter,h=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,E=e.customTypeStartsWithFilter,k=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,C=e.metadataKey,w=e.metadataValues,x=e.metadataValueStartsWith,S=e.includeFrozen,T=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter,A=e.includeChatNotification,M=void 0!==A&&A,O=e.includeLeftChannel,U=void 0!==O&&O,D=e.createdAfter,R=e.createdBefore;return(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/my_group_channels"),a.params=pe({token:s,limit:o,order:null!=u?u:Ap.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:Ap.includeEmpty,member_state_filter:null!=l?l:Ap.myMemberStateFilter,super_mode:null!=d?d:Ap.superChannelFilter,public_mode:null!=h?h:Ap.publicChannelFilter,unread_filter:null!=f?f:Ap.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:E,hidden_mode:k,metadata_order_key:b,metadata_key:C,metadata_values:w,metadata_value_startswith:x,show_frozen:S,show_metadata:T,include_chat_notification:M,include_left_channel:U,created_after:D,created_before:R}),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 c(t,e),i(t)}(Ve),Op=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new x_(e,t)}))),i.ts=null!=u?u:0,i}return c(t,e),i(t)}(ze),Up=function(t){function a(t){var i,s=t.userId,o=t.filter;r(this,a),i=n(this,a);var u=o.myMemberStateFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/group_channel_count"),i.params={state:null!=u?u:e.MyMemberStateFilter.ALL},i}return c(a,t),i(a)}(Ve),Dp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).groupChannelCount=a.group_channel_count,i}return c(t,e),i(t)}(ze),Rp=function(e){function t(e){var a,i=e.userId,s=e.filter;r(this,t),a=n(this,t);var o=s.keys,u=s.customTypeFilters,c=s.customTypesFilter;return a.method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_item_count"),a.params=pe({item_keys:o,custom_types:null!=c?c:u}),a}return c(t,e),i(t)}(Ve),Lp=function(t){function a(t,i){var s;return r(this,a),s=n(this,a,[t,i]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=i[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),s}return c(a,t),i(a)}(ze),Pp=function(e){function t(e){var a,i=e.userId;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/unread_channel_count"),a}return c(t,e),i(t)}(Ve),Fp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i}return c(t,e),i(t)}(ze),qp=function(t){function a(t){var i,s=t.userId,o=t.filter,u=t.includeFeedChannel,c=void 0!==u&&u;r(this,a),i=n(this,a);var l=o.channelCustomTypesFilter,d=o.superChannelFilter;return i.method=_e.GET,i.path="".concat(ge,"/").concat(encodeURIComponent(s),"/unread_message_count"),i.params={super_mode:null!=d?d:e.SuperChannelFilter.ALL,custom_types:l,include_feed_channel:c},i}return c(a,t),i(a)}(Ve),Hp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).unreadCount=a.unread_count,i.unreadFeedCount=a.unread_feed_count,i}return c(t,e),i(t)}(ze),Gp=function(e){function t(e){var a,i=e.channelUrl,s=e.scheduledStatus,o=e.messageTypeFilter;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(Ae,"/count"),a.params={channel_url:i,status:Vp(s)},o&&(a.params.message_type=o),a}return c(t,e),i(t)}(Ve),jp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).count=a.count,i}return c(t,e),i(t)}(ze),Vp=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},zp=function(e){function t(e){var a;r(this,t);var i=e.userId,s=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,d=e.isBroadcast,h=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,_=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,E=e.data,k=e.customType,b=e.messageSurvivalSeconds,C=e.invitedUserIds,w=e.operatorUserIds;return(a=n(this,t)).method=_e.POST,a.path=ke,a.params=pe({user_ids:[i].concat(v(null!=C?C:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:d,is_exclusive:f,is_public:h,is_discoverable:p,strict:_,is_ephemeral:m,access_code:g,name:y,data:E,custom_type:k,operator_ids:w,message_survival_seconds:b}),a}return c(t,e),i(t)}(Ve),Bp=function(e){function t(e,a){var i,s;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i.isCreated=null===(s=a.is_created)||void 0===s||s,i}return c(t,e),i(t)}(ze),Qp=function(e){function t(e){var a,i=e.userId,s=e.channelUrls;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/mark_as_read_all"),a.params={channel_urls:s},a}return c(t,e),i(t)}(Ve),Kp=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).event=new op(i),s}return c(t,e),i(t)}(Ke),Wp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/join"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(Ve),Yp=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),Zp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.users,f=void 0===h?null:h;return s.memberCount=c,s.joinedMemberCount=d,s.members=Array.isArray(f)?f.map((function(t){return new tp(e,t)})):[new tp(e,i.data)],s}return c(t,e),i(t)}(Kp),Xp=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.shouldRemoveOperatorStatus;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/leave"),a.params={user_id:s,should_remove_operator_status:o},a}return c(t,e),i(t)}(Ve),Jp=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l;return s.memberCount=c,s.joinedMemberCount=d,s.member=new tp(s._iid,i.data),s}return c(t,e),i(t)}(Kp),$p=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userIds;return(a=n(this,t)).method=_e.POST,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/invite"),a.params={user_ids:s},a}return c(t,e),i(t)}(Ve),ev=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),tv=function(e){function t(e,a,i){var s;r(this,t),(s=n(this,t,[e,a,i])).inviter=null;var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.inviter,f=o.invitees,p=void 0===f?[]:f;return s.memberCount=c,s.joinedMemberCount=d,h&&Object.keys(h).length>0&&(s.inviter=new li(e,h)),s.invitees=p.map((function(t){return new tp(e,t)})),s}return c(t,e),i(t)}(Kp),nv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/decline"),a.params={user_id:s},a}return c(t,e),i(t)}(Ve),rv=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data,u=o.member_count,c=o.joined_member_count,l=o.inviter,d=o.invitee;return s.memberCount=null!=u?u:0,s.joinedMemberCount=null!=c?c:0,s.inviter=new li(e,l),s.invitee=new tp(e,d),s}return c(t,e),i(t)}(Kp),av={hidePreviousMessages:!1,allowAutoUnhide:!0},iv=function(e){return D("boolean",e.hidePreviousMessages,!0)&&D("boolean",e.allowAutoUnhide,!0)},sv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a.params={user_id:s,hide_previous_messages:null!=o?o:av.hidePreviousMessages,allow_auto_unhide:null!=u?u:av.allowAutoUnhide},a}return c(t,e),i(t)}(Ve),ov=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(ze),uv=function(e){function t(e,a,i){var s,o,u,c;return r(this,t),(s=n(this,t,[e,"SYEV",i])).allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,i.data&&(s.allowAutoUnhide=null!==(o=i.data.allow_auto_unhide)&&void 0!==o?o:null,s.hidePreviousMessages=null!==(u=i.data.hide_previous_messages)&&void 0!==u?u:null),s.messageOffsetTimestamp=null!==(c=i.ts_message_offset)&&void 0!==c?c:null,s}return c(t,e),i(t)}(Ke),cv=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(We),lv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new li(e,i.data),s}return c(t,e),i(t)}(Ke),dv=function(e){function t(e){var a=e.channelUrl,i=e.time;return r(this,t),n(this,t,[{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:i}}])}return c(t,e),i(t)}(We),hv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"SYEV",i])).user=new li(e,i.data),s}return c(t,e),i(t)}(Ke),fv=function(e){function t(e,a,i){var s;r(this,t),s=n(this,t,[e,a,i]);var o=i.data.operators,u=void 0===o?[]:o;return s.operators=u.map((function(e){return new li(s._iid,e)})),s}return c(t,e),i(t)}(Kp),pv=function(e){function t(e){var a=e.channelUrl,i=e.messageId;return r(this,t),n(this,t,[{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:i}}])}return c(t,e),i(t)}(We),vv=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E,k,b,C,w,x,S,T,I,N;return r(this,a),(s=n(this,a,[t,i])).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.includeChatNotification=!1,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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.includeChatNotification=null!==(l=i.includeChatNotification)&&void 0!==l&&l,s.channelUrlsFilter=null!==(d=i.channelUrlsFilter)&&void 0!==d?d:null,s.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(f=i.customTypeStartsWithFilter)&&void 0!==f?f:"",s.nicknameContainsFilter=null!==(p=i.nicknameContainsFilter)&&void 0!==p?p:null,s.nicknameStartsWithFilter=null!==(v=i.nicknameStartsWithFilter)&&void 0!==v?v:null,s.nicknameExactMatchFilter=null!==(_=i.nicknameExactMatchFilter)&&void 0!==_?_:null,s.channelNameContainsFilter=null!==(m=i.channelNameContainsFilter)&&void 0!==m?m:"",s.myMemberStateFilter=null!==(g=i.myMemberStateFilter)&&void 0!==g?g:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(y=i.unreadChannelFilter)&&void 0!==y?y:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(E=i.superChannelFilter)&&void 0!==E?E:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=i.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=i.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(C=i.searchFilter)&&void 0!==C?C:{fields:[],query:null},s.userIdsFilter=null!==(w=i.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(x=i.metadataKey)&&void 0!==x?x:null,s.metadataValues=null!==(S=i.metadataValues)&&void 0!==S?S:null,s.metadataOrderKeyFilter=null!==(T=i.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(I=i.metadataValueStartsWith)&&void 0!==I?I:null,s.order=null!==(N=i.order)&&void 0!==N?N:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i.createdAfter&&(s.createdAfter=i.createdAfter),i.createdBefore&&(s.createdBefore=i.createdBefore),s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter)&&D("string",this.nicknameContainsFilter,!0)&&D("string",this.nicknameStartsWithFilter,!0)&&D("string",this.nicknameExactMatchFilter,!0)&&R(e.MyMemberStateFilter,this.myMemberStateFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicChannelFilter,this.publicChannelFilter)&&R(e.UnreadChannelFilter,this.unreadChannelFilter)&&R(e.HiddenChannelFilter,this.hiddenChannelFilter)&&P(e.GroupChannelSearchField,this.searchFilter.fields)&&D("string",this.searchFilter.query,!0)&&P("string",this.userIdsFilter.userIds)&&D("boolean",this.userIdsFilter.includeMode)&&R(e.QueryType,this.userIdsFilter.queryType)&&R(e.GroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)&&F(this.createdAfter,!0)&&F(this.createdBefore,!0)}},{key:"serialize",value:function(){return si(this)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._validate()){t.next=20;break}if(this._isLoading){t.next=17;break}if(!this._hasNext){t.next=14;break}return this._isLoading=!0,n=Iv.of(this._iid),t.next=7,n.getMyGroupChannels(this._token,ve(Object.assign({},this)),this.limit,e.CollectionEventSource.REQUEST_CHANNEL,!0);case 7:return r=t.sent,a=r.channels,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,t.abrupt("return",a);case 14:return t.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:t.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return t.stop()}}),t,this)})))}}])}(pu),_v=function(e){function t(e,a,i){var s,o;return r(this,t),(s=n(this,t,[e,"SYEV",i])).pinnedMessageIds=[],s.latestPinnedMessage=null,s.ts=0,i.data&&(s.pinnedMessageIds=null!==(o=i.data.pinned_message_ids)&&void 0!==o?o:[],s.latestPinnedMessage=i.data.latest_pinned_message?go(e,Object.assign({},i.data.latest_pinned_message)):null),s.ts=i.ts,s}return c(t,e),i(t)}(Ke),mv=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e]))._logger=a.logger,i._sdkState=a.sdkState,i._sessionManager=a.sessionManager,i._requestQueue=a.requestQueue,i._dispatcher=a.dispatcher,i._cacheContext=a.cacheContext,i._channelType=a.channelType,i}return c(t,e),i(t,[{key:"_messageBroadcast",get:function(){return th.of(this._iid)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"getMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null);case 1:case"end":return e.stop()}}),e)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r,a,i){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",0);case 1:case"end":return e.stop()}}),e)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}}),e)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}])}($a),gv=function(e){function t(e,a,i){var s,o,u,c,l;r(this,t),(s=n(this,t,[e,"ADMM",i])).message=new ao(e,i);var d=ss.of(e).sdkState;return s.isMentioned=qe(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return c(t,e),i(t)}(Ke),yv=function(e){function t(e,a,i){var s,o,u,c,l,d;r(this,t),(s=n(this,t,[e,"AEDI",i])).message=new ao(e,i);var h=ss.of(e).sdkState;return s.mentionCountChange=He({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ve({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return c(t,e),i(t)}(Ke),Ev=function(e){function t(e){var a,i=e.channelUrl,s=e.userId;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/messages/mark_as_delivered"),a.params=pe({userId:s}),a}return c(t,e),i(t)}(Ve),kv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"DLVR",i])).channelUrl=i.channel_url,s.deliveredStateUpdate=i.updated,s}return c(t,e),i(t)}(Ke),bv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MRCT",i])).channelUrl=i.channel_url,s.channelType=i.channel_type,s.event=new fs(i),s}return c(t,e),i(t)}(Ke),Cv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MTHD",i])).event=new uh(e,i),s}return c(t,e),i(t)}(Ke),wv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"MCNT",i])).groupChannelMemberCounts=i.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=i.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return c(t,e),i(t)}(Ke),xv=function(e){function t(e,a,i){var s;return r(this,t),(s=n(this,t,[e,"PEDI",i])).event=new xh(e,i),s.status=uo(i.poll.status)||i.poll.status,s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return c(t,e),i(t)}(Ke),Sv=function(){return i((function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,i=t.bottom,s=void 0===i?0:i;r(this,e),this.top=a,this.bottom=s}),[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0&&r.onMentionReceived&&r.onMentionReceived(T,w)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 63:return a.abrupt("break",344);case 64:if(D=t.as(dt),R=D.channelUrl,L=D.channelType,P=D.messageId,F=D.silent,q=D.messageCreatedAt,H=D.senderId,L!==e.ChannelType.GROUP){a.next=73;break}return a.next=68,this.getChannel(R,!0);case 68:G=a.sent,j=H===this._sdkState.userId,F||j||q>0&&G.myLastRead0&&G._updateUnreadCount(G.unreadMessageCount-1,0),this._dispatcher.dispatch(new qs({messageIds:[P],source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onMessageDeleted&&r.onMessageDeleted(G,P)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 73:return a.abrupt("break",344);case 74:if(V=t.as(Ss),(z=V.readStatus).channelType!==e.ChannelType.GROUP){a.next=82;break}return B=this._groupChannelCache.isCachedInMemory(z.channelUrl),a.next=79,this.getChannel(z.channelUrl,!0);case 79:Q=a.sent,B&&Q._updateUnreadMemberState(z.reader.userId,z.readAt),z.reader.userId===this._sdkState.userId?B?(Q.unreadMessageCount>0||Q.unreadMentionCount>0)&&(Q._updateUnreadCount(0,0),this._dispatcher.dispatch(new Cp({channels:[Q],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Q)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==Q.unreadMessageCount&&0!==Q.unreadMentionCount||(this._dispatcher.dispatch(new Cp({channels:[Q],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Q)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new Cp({channels:[Q],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUnreadMemberStatusUpdated&&r.onUnreadMemberStatusUpdated(Q)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 82:return a.abrupt("break",344);case 83:return K=t.as(kv),W=K.channelUrl,Y=K.deliveredStateUpdate,Z=void 0===Y?{}:Y,X=this._groupChannelCache.isCachedInMemory(W),a.next=87,this.getChannel(W,!0);case 87:return J=a.sent,X&&Object.keys(Z).forEach((function(e){J._updateUndeliveredMemberState(e,Z[e])})),Object.keys(Z).some((function(e){return e!==mn._sdkState.userId}))&&(this._dispatcher.dispatch(new Cp({channels:[J],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELIVERED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onUndeliveredMemberStatusUpdated&&r.onUndeliveredMemberStatusUpdated(J)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 91:if($=t.as(bv),ee=$.channelUrl,te=$.channelType,ne=$.event,te!==e.ChannelType.GROUP){a.next=101;break}return a.next=95,this.getChannel(ee,!0);case 95:return re=a.sent,a.next=98,this.getMessageFromCache(ne.messageId);case 98:(ae=a.sent)?ae instanceof eo&&(ae.applyReactionEvent(ne),this._dispatcher.dispatch(new Fs({messages:[ae],source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new Hs({event:ne,source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onReactionUpdated&&r.onReactionUpdated(re,ne)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 101:return a.abrupt("break",344);case 102:if(ie=t.as(Cv),(se=ie.event).channelType!==e.ChannelType.GROUP){a.next=112;break}return a.next=106,this.getChannel(se.channelUrl,!0);case 106:return oe=a.sent,a.next=109,this.getMessageFromCache(se.targetMessageId);case 109:(ue=a.sent)?ue instanceof eo&&(ue.applyThreadInfoUpdateEvent(se),this._dispatcher.dispatch(new Fs({messages:[ue],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new Gs({event:se,source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onThreadInfoUpdated&&r.onThreadInfoUpdated(oe,se)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 112:return a.abrupt("break",344);case 113:ce=t.as(wv),le=ce.groupChannelMemberCounts,de=[],he=s(le),a.prev=116,he.s();case 118:if((fe=he.n()).done){a.next=127;break}return pe=fe.value,ve=pe.channelUrl,_e=pe.memberCount,me=pe.joinedMemberCount,ge=pe.updatedAt,a.next=123,this.getChannelFromCache(ve);case 123:(ye=a.sent)&&ye._setLatestMemberCount(_e,me,ge)&&de.push(ye);case 125:a.next=118;break;case 127:a.next=132;break;case 129:a.prev=129,a.t2=a.catch(116),he.e(a.t2);case 132:return a.prev=132,he.f(),a.finish(132);case 135:return de.length>0&&(this._dispatcher.dispatch(new Cp({channels:de,context:{source:e.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(de)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",344);case 137:if(Ee=t.as(xv),ke=Ee.event,be=Ee.status,Ce=Ee.channelUrl,we=Ee.channelType,!Ce||we!==e.ChannelType.GROUP){a.next=144;break}return a.next=141,this.getChannel(Ce,!0);case 141:xe=a.sent,this._dispatcher.dispatch(new zs({event:ke,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),_i(be===oo?function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(xe,ke.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(xe,ke)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 144:return a.abrupt("break",344);case 145:if(Se=t.as(Fc),Te=Se.event,Ie=Se.channelUrl,Ne=Se.channelType,!Ie||Ne!==e.ChannelType.GROUP){a.next=152;break}return a.next=149,this.getChannel(Ie,!0);case 149:Ae=a.sent,this._dispatcher.dispatch(new Bs({event:Te,source:e.CollectionEventSource.EVENT_POLL_VOTED})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(Ae,Te)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 152:return a.abrupt("break",344);case 153:if(Me=t.as(Kp),!(Oe=Me.event).isGroupChannelEvent){a.next=332;break}a.t3=Oe.category,a.next=a.t3===rp.CHANNEL_JOIN?158:a.t3===rp.CHANNEL_LEAVE?167:a.t3===rp.CHANNEL_OPERATOR_UPDATE?183:a.t3===rp.CHANNEL_INVITE?194:a.t3===rp.CHANNEL_DECLINE_INVITE?204:a.t3===rp.TYPING_START||a.t3===rp.TYPING_END?212:a.t3===rp.USER_CHANNEL_MUTE||a.t3===rp.USER_CHANNEL_UNMUTE?221:a.t3===rp.USER_CHANNEL_BAN?248:a.t3===rp.USER_CHANNEL_UNBAN?263:a.t3===rp.CHANNEL_FREEZE||a.t3===rp.CHANNEL_UNFREEZE?271:a.t3===rp.CHANNEL_HIDE?279:a.t3===rp.CHANNEL_UNHIDE?289:a.t3===rp.CHANNEL_DELETED?296:a.t3===rp.CHANNEL_PROP_CHANGED?302:a.t3===rp.CHANNEL_META_DATA_CHANGED?308:a.t3===rp.CHANNEL_META_COUNTERS_CHANGED?317:a.t3===rp.PINNED_MESSAGE_CHANGED?326:332;break;case 158:return a.next=160,this.getChannel(Oe.channelUrl,!0);case 160:return Ue=a.sent,De=t.as(Zp),Re=De.memberCount,Le=De.joinedMemberCount,Pe=De.members,Fe=!1,Pe.forEach((function(t){Ue.isExclusive||Ue.isSuper||Ue.isBroadcast?Fe=Fe||Ue._setLatestMemberCount(Re,Le,Oe.ts):(t.state=e.MemberState.JOINED,Ue.addMember(t,Oe.ts),mn._updateJoinedMemberCount(Ue)),t.userId===mn._sdkState.userId&&(Ue.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new Cp({channels:[Ue],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:Pe}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=s(Pe);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ue,r)}}catch(e){n.e(e)}finally{n.f()}Ue.isBroadcast&&Fe&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ue])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 167:if(!(qe=this._leftChannels.get(Oe.channelUrl))){a.next=172;break}a.t4=qe.channel,a.next=175;break;case 172:return a.next=174,this.getChannel(Oe.channelUrl,!0);case 174:a.t4=a.sent;case 175:return He=a.t4,Ge=t.as(Jp),je=Ge.memberCount,Ve=Ge.joinedMemberCount,ze=Ge.member,Be=!1,Qe=ss.of(this._iid),Ke=Qe.appInfo,He.isExclusive||He.isSuper||He.isBroadcast?Be=He._setLatestMemberCount(je,Ve,Oe.ts):((null==Ke?void 0:Ke.enabledChannelMemberShipHistory)?((We=He.members.find((function(e){return e.userId===ze.userId})))&&(We.state=e.MemberState.LEFT),He.memberCount=je):He.removeMember(ze),this._updateJoinedMemberCount(He)),ze.userId===this._sdkState.userId?(He.myMemberState=e.MemberState.NONE,He.invitedAt=0,He.joinedAt=0,He._updateUnreadCount(0,0),He.isPublic?this._dispatcher.dispatch(new Cp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})):(this._markAsLeave(He),this._dispatcher.dispatch(new wp({channelUrls:[He.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})))):this._dispatcher.dispatch(new Cp({channels:[He],context:{source:e.CollectionEventSource.EVENT_CHANNEL_LEFT,user:ze}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(He,ze),He.isBroadcast&&Be&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([He])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 183:return a.next=185,this.getChannel(Oe.channelUrl,!0);case 185:Ye=a.sent,Ze=t.as(fv),Xe=Ze.operators,Je=Xe.map((function(e){return e.userId})),$e=s(Ye.members);try{for($e.s();!(et=$e.n()).done;)(tt=et.value).role=Je.includes(tt.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){$e.e(e)}finally{$e.f()}return Ye.myRole=Je.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new Cp({channels:[Ye],context:{source:e.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED,operators:Xe}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Ye,Xe)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 194:return a.next=196,this.getChannel(Oe.channelUrl,!0);case 196:nt=a.sent,rt=t.as(tv),at=rt.memberCount,it=rt.joinedMemberCount,st=rt.inviter,(ot=rt.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),ut=s(ot);try{for(ut.s();!(ct=ut.n()).done;)lt=ct.value,nt.isExclusive||nt.isSuper||nt.isBroadcast?nt._setLatestMemberCount(at,it,Oe.ts):nt.addMember(lt,Oe.ts),this._sdkState.userId===lt.userId&&(nt.hiddenState=e.HiddenState.UNHIDDEN,nt.myMemberState!==e.MemberState.JOINED&&(nt.myMemberState=e.MemberState.INVITED),nt.invitedAt=Oe.ts)}catch(e){ut.e(e)}finally{ut.f()}return this._dispatcher.dispatch(new Cp({channels:[nt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:st,invitees:ot}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(nt,st,ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 204:return a.next=206,this.getChannel(Oe.channelUrl,!0);case 206:return ht=a.sent,ft=t.as(rv),pt=ft.memberCount,vt=ft.joinedMemberCount,_t=ft.inviter,mt=ft.invitee,ht.isExclusive||ht.isSuper||ht.isBroadcast?ht._setLatestMemberCount(pt,vt,Oe.ts):ht.removeMember(mt),this._sdkState.userId===mt.userId?(ht.invitedAt=0,ht.myMemberState=e.MemberState.NONE,ht.isPublic?this._dispatcher.dispatch(new Cp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})):this._dispatcher.dispatch(new wp({channelUrls:[ht.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}}))):this._dispatcher.dispatch(new Cp({channels:[ht],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE,inviter:_t,invitee:mt}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ht,_t,mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 212:return a.next=214,this.getChannel(Oe.channelUrl,!0);case 214:return gt=a.sent,yt=Oe.category===rp.TYPING_START,Et=t.as(yt?lv:hv),kt=Et.user,gt._updateTypingStatus(kt,yt?Oe.ts:0),this._dispatcher.dispatch(new Cp({channels:[gt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(gt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 221:return a.next=223,this.getChannel(Oe.channelUrl,!0);case 223:bt=a.sent,Ct=Oe.category===rp.USER_CHANNEL_MUTE,wt=t.as(Ct?Xu:$u),(xt=wt.user).userId===this._sdkState.userId&&(bt.myMutedState=Ct?e.MutedState.MUTED:e.MutedState.UNMUTED,bt._myMutedRemainingTime=xt.restrictionInfo.remainingDuration),St=s(bt.members),a.prev=228,St.s();case 230:if((Tt=St.n()).done){a.next=237;break}if((It=Tt.value).userId!==xt.userId){a.next=235;break}return It.isMuted=Ct,a.abrupt("break",237);case 235:a.next=230;break;case 237:a.next=242;break;case 239:a.prev=239,a.t5=a.catch(228),St.e(a.t5);case 242:return a.prev=242,St.f(),a.finish(242);case 245:return this._dispatcher.dispatch(new Cp({channels:[bt],context:{source:Ct?e.CollectionEventSource.EVENT_CHANNEL_MUTED:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:xt}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ct?e.onUserMuted&&e.onUserMuted(bt,xt):e.onUserUnmuted&&e.onUserUnmuted(bt,xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 248:if(!(Nt=this._leftChannels.get(Oe.channelUrl))){a.next=253;break}a.t6=Nt.channel,a.next=256;break;case 253:return a.next=255,this.getChannel(Oe.channelUrl,!0);case 255:a.t6=a.sent;case 256:return At=a.t6,this._markAsLeave(At),Mt=t.as(tc),Ot=Mt.user,Ot.userId===this._sdkState.userId&&this._dispatcher.dispatch(new wp({channelUrls:[At.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_BANNED,user:Ot}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(At,Ot)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 263:return a.next=265,this.getChannel(Oe.channelUrl,!0);case 265:return Ut=a.sent,Dt=t.as(rc),Rt=Dt.user,Rt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new wp({channelUrls:[Ut.url],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNBANNED,user:Rt}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(Ut,Rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 271:return a.next=273,this.getChannel(Oe.channelUrl,!0);case 273:return Lt=a.sent,Pt=t.as(ic),Ft=Pt.freeze,Lt.isFrozen=Ft,this._dispatcher.dispatch(new Cp({channels:[Lt],context:{source:Ft?e.CollectionEventSource.EVENT_CHANNEL_FROZEN:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ft?e.onChannelFrozen&&e.onChannelFrozen(Lt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 279:return a.next=281,this.getChannel(Oe.channelUrl,!0);case 281:return qt=a.sent,Ht=t.as(uv),Gt=Ht.allowAutoUnhide,jt=Ht.hidePreviousMessages,Vt=Ht.messageOffsetTimestamp,null!==Gt&&(qt.hiddenState=Gt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==jt&&jt&&qt._updateUnreadCount(0,0),null!==Vt&&(qt.messageOffsetTimestamp=Vt),this._dispatcher.dispatch(new Cp({channels:[qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 289:return a.next=291,this.getChannel(Oe.channelUrl,!0);case 291:return(zt=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new Cp({channels:[zt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(zt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 296:return a.next=298,this.getChannel(Oe.channelUrl,!0);case 298:return Bt=a.sent,this._dispatcher.dispatch(new wp({channelUrls:[Oe.channelUrl],context:{source:e.CollectionEventSource.EVENT_CHANNEL_DELETED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Bt.url,Bt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 302:return a.next=304,this.getChannelWithoutCache(Oe.channelUrl,!0);case 304:return Qt=a.sent,this._dispatcher.dispatch(new Cp({channels:[Qt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 308:return a.next=310,this.getChannel(Oe.channelUrl,!0);case 310:return Kt=a.sent,Wt=t.as(Lu),Yt=Wt.created,Zt=Wt.updated,Xt=Wt.deleted,Yt&&(Kt._upsertCachedMetaData(Yt,Oe.ts),this._dispatcher.dispatch(new Cp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED,metaData:Yt},ts:Oe.ts}))),Zt&&(Kt._upsertCachedMetaData(Zt,Oe.ts),this._dispatcher.dispatch(new Cp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED,metaData:Zt},ts:Oe.ts}))),Xt&&(Kt._removeFromCachedMetaData(Xt,Oe.ts),this._dispatcher.dispatch(new Cp({channels:[Kt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:Xt},ts:Oe.ts}))),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Yt&&e.onMetaDataCreated&&e.onMetaDataCreated(Kt,Yt),Zt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Kt,Zt),Xt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Kt,Xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 317:return a.next=319,this.getChannel(Oe.channelUrl,!0);case 319:return Jt=a.sent,$t=t.as(Ku),en=$t.created,tn=$t.updated,nn=$t.deleted,en&&this._dispatcher.dispatch(new Cp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:en}})),tn&&this._dispatcher.dispatch(new Cp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:tn}})),nn&&this._dispatcher.dispatch(new Cp({channels:[Jt],context:{source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:nn}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){en&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Jt,en),tn&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Jt,tn),nn&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Jt,nn)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",332);case 326:return a.next=328,this.getChannel(Oe.channelUrl,!0);case 328:return rn=a.sent,an=t.as(_v),sn=an.pinnedMessageIds,on=an.latestPinnedMessage,(un=an.ts)>rn._pinnedMessagesUpdatedAt&&(rn.pinnedMessageIds=null!=sn?sn:[],rn.lastPinnedMessage=on,rn._pinnedMessagesUpdatedAt=un,this._dispatcher.dispatch(new Cp({channels:[rn],context:{source:e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED}})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(rn)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),_i((function(){return E(mn,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(rn)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",332);case 332:return a.abrupt("break",344);case 333:cn=t.as(zh),ln=cn.event,a.t7=ln.category,a.next=a.t7===Nh.USER_BLOCK?337:a.t7===Nh.USER_UNBLOCK?340:343;break;case 337:return dn=Hh.getDataAsUserBlockEvent(this._iid,ln),hn=dn.blocker,fn=dn.blockee,this._groupChannelCache.block(hn.userId,fn.userId),a.abrupt("break",343);case 340:return pn=Hh.getDataAsUserBlockEvent(this._iid,ln),vn=pn.blocker,_n=pn.blockee,this._groupChannelCache.unblock(vn.userId,_n.userId),a.abrupt("break",343);case 343:return a.abrupt("break",344);case 344:a.next=350;break;case 346:if(a.prev=346,a.t8=a.catch(0),!N(a.t8)){a.next=350;break}throw a.t8;case 350:case"end":return a.stop()}}),a,this,[[0,346],[18,29,32,35],[116,129,132,135],[228,239,242,245]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function r(){var a,i,s,o,u,c;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ui(D("string",t)).throw(A.invalidParameters),a=new Ip({channelUrl:t,isInternalCall:n}),r.next=4,this._requestQueue.send(a);case 4:i=r.sent,s=i.as(Np),o=s.channel,u=o.unreadMessageCount,c=o.unreadMentionCount,r.t0=o.myCountPreference,r.next=r.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:r.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:r.t0===e.CountPreference.OFF?14:17;break;case 10:return c=0,r.abrupt("break",17);case 12:return u=0,r.abrupt("break",17);case 14:return u=0,c=0,r.abrupt("break",17);case 17:return o._updateUnreadCount(u,c),r.next=20,this.upsertChannelsToCache([o]);case 20:return r.abrupt("return",r.sent[0]);case 21:case"end":return r.stop()}}),r,this)})))}},{key:"refreshChannel",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REFRESH_CHANNEL,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return E(this,void 0,void 0,d().mark((function i(){var s,o,u,c,l;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,s=new Ip({channelUrl:t,isInternalCall:n,showLatestMessage:a}),i.next=4,this._requestQueue.send(s);case 4:if(o=i.sent,u=o.as(Np),(c=u.channel).myMemberState!==e.MemberState.NONE){i.next=10;break}this._dispatcher.dispatch(new wp({channelUrls:[c.url],context:{source:r}})),i.next=14;break;case 10:return i.next=12,this.upsertChannelsToCache([c]);case 12:l=i.sent,this._dispatcher.dispatch(new Cp({channels:l,context:{source:r}}));case 14:i.next=19;break;case 16:i.prev=16,i.t0=i.catch(0),i.t0.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&i.t0.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new wp({channelUrls:[t],context:{source:r}}));case 19:case"end":return i.stop()}}),i,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_CHANNEL,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return E(this,void 0,void 0,d().mark((function e(){var s,o,u,c,l,h,f,p,v;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.createdAfter&&(n.createdAfter=Math.floor(n.createdAfter/1e3)),n.createdBefore&&(n.createdBefore=Math.floor(n.createdBefore/1e3)),s=!1,i&&(o=ss.of(this._iid),u=o.appInfo,(c=o.cacheContext)&&!c.localCacheEnabled&&(null==u?void 0:u.enabledChannelMemberShipHistory)&&(null==u?void 0:u.applicationAttributes.includes("left_user_view_support"))&&(s=!0)),l=new Mp(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:r,includeLeftChannel:i&&s})),e.next=7,this._requestQueue.send(l);case 7:return h=e.sent,f=h.as(Op),p=f.channels,v=f.token,this._dispatcher.dispatch(new Cp({channels:p,context:{source:a}})),e.abrupt("return",{channels:p,token:v});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS;return E(this,void 0,void 0,d().mark((function e(){var a,i,s,o,u,c,l,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Object.assign(Object.assign({},lp),n),ui((D("string",t)||D("number",t))&&dp(a)).throw(A.invalidParameters),i=new Sp(ve({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,filter:a})),e.next=5,this._requestQueue.send(i);case 5:return s=e.sent,o=s.as(Tp),u=o.updatedChannels,c=o.deletedChannelUrls,l=o.hasMore,h=o.ts,u.length>0&&this._dispatcher.dispatch(new Cp({channels:u,context:{source:r},ts:h})),c.length>0&&this._dispatcher.dispatch(new wp({channelUrls:c,context:{source:r}})),e.abrupt("return",{updatedChannels:u,deletedChannelUrls:c,hasMore:l,token:o.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},hp),e),ui(fp(n)).throw(A.invalidParameters),r=new Up({userId:this._sdkState.userId,filter:n}),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Dp),s=i.groupChannelCount,t.abrupt("return",s);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l,h,f,p,v,_,m,g;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},vp),e),ui(_p(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Rp({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Lp),c=u.groupChannelUnreadMentionCount,l=u.groupChannelUnreadMessageCount,h=u.groupChannelInvitationCount,f=u.superGroupChannelUnreadMentionCount,p=u.superGroupChannelUnreadMessageCount,v=u.superGroupChannelInvitationCount,_=u.nonSuperGroupChannelUnreadMentionCount,m=u.nonSuperGroupChannelUnreadMessageCount,g=u.nonSuperGroupChannelInvitationCount,t.abrupt("return",pe({groupChannelUnreadMentionCount:c,groupChannelUnreadMessageCount:l,groupChannelInvitationCount:h,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Pp({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Fp),o=s.unreadCount,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},mp),e),ui(gp(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new qp({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Hp),c=u.unreadCount,t.abrupt("return",c);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},yp),e),ui(Ep(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new Gp(n),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(jp),u=o.count,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=ss.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=ss.of(this._iid).subscribedUnreadMessageCount;return Object.keys(t.customTypes).forEach((function(n){e+=t.customTypes[n]})),e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=ss.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},up),e),ui(cp(n)).throw(A.invalidParameters),n.isPublic||(n.accessCode=void 0),r=new zp(Object.assign({userId:this._sdkState.userId},n)),t.next=6,this._requestQueue.send(r);case 6:return a=t.sent,i=a.as(Bp),s=i.channel,t.next=10,this.upsertChannelsToCache([s]);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Date.now(),ui(t-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Qp({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(n);case 6:r=this._groupChannelCache.channels,a=s(r);try{for(a.s();!(i=a.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0)}catch(e){a.e(e)}finally{a.f()}if(!(r.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(r);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),ui(P("string",e)&&n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new Qp({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,i=[],o=s(a);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,n),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()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return n=t.sent,t.next=5,n.markAsDelivered();case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMessageFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._messageCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"getExactlyMatchingMessagesForTokenFromCache",value:function(e,t,n){return E(this,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0});case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),r,this)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:100,i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return E(this,void 0,void 0,d().mark((function s(){return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i});case 2:return s.abrupt("return",s.sent);case 3:case"end":return s.stop()}}),s,this)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,d().mark((function a(){return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.countBetween(e,t,new Sv({top:n,bottom:r}));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:t});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return Tv[e]||(Tv[e]=new a(e,ss.of(e))),Tv[e]}},{key:"clear",value:function(e){Tv[e]&&delete Tv[e]}}])}(mv),Nv=function(e,t){return t instanceof to?e.findIndex((function(e){return e instanceof to&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Av=function(e,t){return e.findIndex((function(e){return e instanceof eo?e.messageId===t:e instanceof _o?e.notificationId===t:void 0}))},Mv=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(i<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length};!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(pp||(pp={}));var Ov=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t))._state=pp.IDLE,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=a,i}return c(t,e),i(t,[{key:"isIdle",get:function(){return this._state===pp.IDLE}},{key:"isRunning",get:function(){return this._state===pp.RUNNING}},{key:"isDone",get:function(){return this._state===pp.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,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:n=t.sent,this._retryCount=0,this.dispatch("progress",n),n.hasNext?this._run(n.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(E=_.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(y=u.range).intersect.apply(y,v(E)))?this.extendRange(_):this._metadata={range:new Sv({top:Math.min.apply(Math,v(E)),bottom:Math.max.apply(Math,v(E))}),previousComplete:!1}),h.hasNext=_.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(h.nextToken=this._metadata.range.top,this._metadata.previousComplete=_.length0&&(y=f.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(_=o.range).intersect.apply(_,v(y)))?this.extendRange(f):this._metadata={range:new Sv({top:Math.min.apply(Math,v(y)),bottom:Math.max.apply(Math,v(y))}),previousComplete:!1}),l.hasNext=f.length>=this._limit,this._metadata&&(l.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",l),n.next=15,this.saveMetadata();case 15:n.next=21;break;case 17:throw n.prev=17,n.t0=n.catch(4),m.debug("message background next sync error",n.t0),n.t0;case 21:return n.prev=21,g.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:s.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(c=null===(u=p.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==c?c:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.finish(21);case 24:return n.abrupt("return",l);case 25:case"end":return n.stop()}}),n,this,[[4,17,21,24]])})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=_.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 Sv({})}},{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,v(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,v(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{range:new Sv(r.range),previousComplete:r.previousComplete}:{range:new Sv({}),previousComplete:!1};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,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.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,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now(),i=ss.of(this._iid),s=i.logger,o=i.sessionManager;i.cacheContext.localCacheEnabled&&o.session.hasSession&&(s.debug("message background sync resume()"),this._prevSyncLoopCount=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(){ss.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 Uv[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n){return Uv[e]||(Uv[e]={}),Uv[e][n.url]||(Uv[e][n.url]=new t({_iid:e,channel:n})),Uv[e][n.url].ref++,Uv[e][n.url]}},{key:"clear",value:function(e,t){Uv[e]&&Uv[e][t]&&(Uv[e][t].close(),delete Uv[e])}}])}(),Rv={},Lv=function(){function t(n){var a=this,i=n._iid,s=n.channel,o=n.includeParams;r(this,t),this.ref=0,this._iid=i,this._channel=s,this._includeParams=o;var u,c,l=ss.of(this._iid),h=l.logger,f=l.sdkState,p=l.dispatcher;this._metadataKey=(u=f.userId,c=s.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var v=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(f.userId,this._channel.url);this._sync=new Ov(v,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,a=oh.of(this._iid),t.next=8,a.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,Object.assign({replyType:e.ReplyType.ALL},this._includeParams),e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,s=i.updatedMessages,o=i.deletedMessageIds,u=i.hasMore,c=i.token,r.hasNext=u,r.nextToken=c,(s.length>0||o.length>0)&&this._metadata&&(this._metadata.token=c),h.debug("message changelog sync progress",r),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),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",r);case 29:case"end":return t.stop()}}),t,this,[[4,21]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.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=ss.of(this._iid),t=e.logger;e.sessionManager.session.hasSession&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){ss.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Rv[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n,r){return Rv[e]||(Rv[e]={}),Rv[e][n.url]||(Rv[e][n.url]=new t({_iid:e,channel:n,includeParams:r})),Rv[e][n.url].ref++,Rv[e][n.url]}},{key:"clear",value:function(e,t){Rv[e]&&Rv[e][t]&&(Rv[e][t].close(),delete Rv[e])}}])}(),Pv={},Fv=function(){function e(t){var n=this,a=t._iid,i=t.channel,s=t.hasPollMessage;r(this,e),this.ref=0,this._iid=a,this._channel=i;var o,u,c=ss.of(this._iid),l=c.logger,h=c.sdkState,f=c.dispatcher;this._metadataKey=(o=h.userId,u=i.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new Ov(p,(function(){return E(n,void 0,void 0,d().mark((function e(){var t,n,r,a,i,o,u,c,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(l.debug("poll changelog sync from",null===(t=this._metadata)||void 0===t?void 0:t.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,s();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return r={hasNext:!1,nextToken:0},e.abrupt("return",r);case 12:return this._metadata||(a=ss.of(this._iid),i=a.firstConnectedAt,this._metadata={token:i}),e.prev=13,o=el.of(this._iid),e.next=17,o.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return u=e.sent,c=u.hasMore,h=u.token,n.hasNext=c,n.nextToken=h,this._metadata.token=h,l.debug("poll changelog sync progress",n),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),l.debug("poll changelog sync error",e.t1),!(e.t1 instanceof 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",n);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)n.resume();else n.pause()}))}return i(e,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{token:r.token}:void 0;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ss.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){ss.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 Pv[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Pv[t]||(Pv[t]={}),Pv[t][n.url]||(Pv[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Pv[t][n.url].ref++,Pv[t][n.url]}}])}(),qv=function(t){function a(t){var i,s,o,u,c,l,d,h,f,p,v;return r(this,a),(i=n(this,a)).method=_e.GET,i.path="".concat(Pe(t.channelType),"/").concat(t.channelUrl,"/messages_gap"),i.params=pe({prev_start_ts:t.prevStart,prev_end_ts:t.prevEnd,prev_cache_count:t.prevCount,next_start_ts:t.nextStart,next_end_ts:t.nextEnd,next_cache_count:t.nextCount,huge_gap_threshold:null!==(s=t.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(o=t.customTypes)&&void 0!==o?o:["*"],message_type:null!==(u=t.messageType)&&void 0!==u?u:null,include_reply_type:null!==(c=t.replyType)&&void 0!==c?c:e.ReplyType.NONE,include_reactions:null===(l=t.includeReactions)||void 0===l||l,include_meta_array:null===(d=t.includeMetaArray)||void 0===d||d,include_thread_info:null===(h=t.includeThreadInfo)||void 0===h||h,include_parent_message_info:null===(f=t.includeParentMessageInfo)||void 0===f||f,with_sorted_meta_array:null===(p=t.includeMetaArray)||void 0===p||p,show_subchannel_messages_only:null!==(v=t.showSubchannelMessagesOnly)&&void 0!==v&&v,include_poll_details:!0,checking_continuous_messages:t.checkingContinuousMessages}),i}return c(a,t),i(a)}(Ve),Hv=function(e){function t(e,a){var i,s,o,u,c,l,d;return r(this,t),(i=n(this,t,[e,a])).isHugeGap=a.is_huge_gap,i.prevMessages=(null!==(s=a.prev_messages)&&void 0!==s?s:[]).map((function(t){return go(e,t)})),i.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,i.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,i.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return go(e,t)})),i.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,i.isContinuousNextMessages=null!==(d=a.is_continuous_next_messages)&&void 0!==d&&d,i}return c(t,e),i(t)}(ze),Gv={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var jv,Vv,zv,Bv=function(){return i((function e(){r(this,e),this._onCacheResult=ft,this._onApiResult=ft}),[{key:"_invokeResponse",value:function(e,t,n){var r=this;_i((function(){return E(r,void 0,void 0,d().mark((function r(){return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next="local"===r.t0?3:"remote"===r.t0?5:7;break;case 3:return this._onCacheResult(t,n),r.abrupt("break",7);case 5:return this._onApiResult(t,n),r.abrupt("break",7);case 7:case"end":return r.stop()}}),r,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}])}(),Qv=function(){return i((function t(n,a){var i=this,o=a.filter,u=a.startingPoint,c=a.limit,l=a.prevResultLimit,h=a.nextResultLimit,f=a.channel,p=a.channelManager,_=a.disableBackgroundSync,m=void 0!==_&&_;r(this,t),this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._iid=n,this._key="mc-".concat(ce()),this._isDisposed=!1,this.filter=null!=o?o:new jd,this._channel=f,this._syncRange=new Sv({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof u&&Number.isFinite(u)?u:Number.MAX_SAFE_INTEGER,this._limit=c||100,this._prevResultLimit=null!=l?l:Math.floor(this._limit/2),this._nextResultLimit=null!=h?h:Math.floor(this._limit/2),this._channelManager=p;var g=ss.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(t,n){var r=n.source,a=t.findIndex((function(e){return e.isIdentical(i.channel)}));a>=0&&(i._replaceChannelOfCollection(t[a]),i.channel._runIfHandleableWithGroupChannel((function(t){switch(r){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:for(var a=!1,s=0;s=t.messageOffsetTimestamp){a=!0;var o=s;if(o>0){var u=i._messages.splice(0,o);i._removeMessagesFromView(u.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!a&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return i.keyOf(e)})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.CollectionEventSource.EVENT_CHANNEL_UNMUTED:var c=ss.of(i._iid).sdkState,l=n.user;c.userId===l.userId&&i._clearCheckMyMutedTimer();break;case e.CollectionEventSource.EVENT_CHANNEL_MUTED:var h=ss.of(i._iid).sdkState,f=n.user;h.userId===f.userId&&-1!==t._myMutedRemainingTime&&i._startCheckMyMutedTimer(t._myMutedRemainingTime);break;case e.CollectionEventSource.EVENT_CHANNEL_LEFT:t.isPublic&&i._clearCheckMyMutedTimer()}_i((function(){return E(i,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:bp(r)&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelUpdated)&&this._handler.onChannelUpdated(n,this.channel);case 1:case"end":return e.stop()}}),e,this)})))}))})),i._postprocessChannelUpdateEvent(t[a],r))},onRemove:function(e,t){var n=e.indexOf(i.channel.url);n>=0&&(i._clearCheckMyMutedTimer(),_i((function(){return E(i,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(t,this.channel.url);case 1:case"end":return e.stop()}}),e,this)})))})),i._postprocessChannelRemoveEvent(e[n]))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],o=[],u=s(t);try{for(u.s();!(r=u.n()).done;){var c=r.value;c.channelUrl===i._channel.url&&(i.filter.match(c)?a.push(c):o.push(i.keyOf(c)))}}catch(e){u.e(e)}finally{u.f()}if(Ps(n)){if(a.length>0)switch(n){case e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.CollectionEventSource.EVENT_MESSAGE_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED:case e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.CollectionEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}o.length>0&&i._removeMessagesFromView(o,n)}i._postprocessMessageUpdateEvent(t,n)},onRemove:function(e,t){i._removeMessagesFromView(e,t),i._postprocessMessageRemoveEvent(e)},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)},onReactionUpdate:function(e,t){i._applyReactionEventToView(e,t)},onThreadInfoUpdate:function(e,t){i._applyThreadInfoEventToView(e,t)}});var y=ss.of(this._iid),k=y.cacheContext,b=y.dispatcher,C=y.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),b.dispatch(new Cp({channels:[this._channel],context:{source:e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=Dv.of(this._iid,this._channel),!m&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=Lv.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=Fv.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Ov(this._key,(function(t){return E(i,void 0,void 0,d().mark((function n(){var r=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,C.run("message-fill-sync-".concat(f.url,"-prev"),(function(){return E(r,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._getRemoteMessages(t,{prevLimit:this._prevResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:k.localCacheEnabled});case 2:if(s=n.sent,o=s.messages,u=s.isContinuousMessages,!(o.length>0)){n.next=10;break}return c=Math.min.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:o.length>=this._prevResultLimit&&this.viewTop0)){n.next=10;break}return c=Math.max.apply(Math,v(o.map((function(e){return e.createdAt})))),this._syncRange.extends(c),u&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(c)),n.abrupt("return",{hasNext:!(o.length>=this._nextResultLimit&&this._hasNext)||this.viewBottom>c,nextToken:this._syncRange.bottom});case 10:return k.localCacheEnabled&&g.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=k.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:k.localCacheEnabled,starting_point:0,message_init_policy:""}})),n.abrupt("return",{hasNext:!1,nextToken:0});case 12:case"end":return n.stop()}}),n,this)})))}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))})),this._connectionEventContext=b.on((function(e){if(e instanceof Ha)switch(e.stateType){case Da.CONNECTED:mi((function(){return E(i,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._activate();case 1:case"end":return e.stop()}}),e,this)})))}));break;case Da.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}}))}),[{key:"keyOf",value:function(e){return 0}},{key:"changelogIncludeParams",get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}}},{key:"_postprocessChannelUpdateEvent",value:function(e,t){}},{key:"_postprocessChannelRemoveEvent",value:function(e){}},{key:"_postprocessMessageUpdateEvent",value:function(e,t){}},{key:"_postprocessMessageRemoveEvent",value:function(e){}},{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return v(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,v(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,v(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"_activate",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),n.logger.debug("check huge gap"),this._checkHugeGap(),t.next=5,this._refreshChannel(e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_replaceChannelOfCollection",value:function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}},{key:"_shouldStartBackgroundSync",value:function(){var e=ss.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}},{key:"_setBaseMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n instanceof eo&&n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,t){var n,r=this,a=[],i=s(e);try{for(i.s();!(n=i.n()).done;){var o=n.value,u=Av(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c.isUserMessage()&&c.applyPoll(o),a.push(c)}}}catch(e){i.e(e)}finally{i.f()}return a.length>0&&Ps(t)&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},a.length>0&&(null===(r=(n=this._handler).onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,a));case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_applyPollUpdateEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollUpdateEvent(e)&&Ps(t)&&_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollVoteEvent(e)&&Ps(t)&&_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyReactionEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ps(t)&&(a.applyReactionEvent(e),_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_applyThreadInfoEventToView",value:function(e,t){var n=this,r=Av(this._messages,e.targetMessageId);if(r>=0){var a=this._messages[r];a&&(a.isUserMessage()||a.isFileMessage()||a.isMultipleFilesMessage())&&Ps(t)&&(a.applyThreadInfoUpdateEvent(e),_i((function(){return E(n,void 0,void 0,d().mark((function e(){var n,r,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,i,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))})))}}},{key:"_removeMessagesFromView",value:function(e,t){var n,r=this,a=[],i=[],o=s(e);try{var u=function(){var e=n.value,t=r._messages.findIndex((function(t){return r.keyOf(t)===e}));if(t>=0){var s=r._messages[t];a.push(r.keyOf(s)),i.push(s),r._messages.splice(t,1)}};for(o.s();!(n=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return Ps(t)&&i.length>0&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:t},null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===r||r.call(n,s,this.channel,a,i);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,t){var n=t.prevLimit,r=void 0===n?0:n,a=t.nextLimit,i=void 0===a?0:a,s=t.inclusive,o=void 0===s||s;return E(this,void 0,void 0,d().mark((function t(){var n,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=[],!o){t.next=5;break}return t.next=4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter);case 4:n=t.sent;case 5:if(!(r>0)){t.next=11;break}return t.next=8,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r,!1);case 8:t.t0=t.sent,t.next=12;break;case 11:t.t0=[];case 12:if(a=t.t0,!(i>0)){t.next=19;break}return t.next=16,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,i,!1);case 16:t.t1=t.sent,t.next=20;break;case 19:t.t1=[];case 20:return s=t.t1,t.abrupt("return",{messages:[].concat(v(n),v(a),v(s)).sort((function(e,t){return t.createdAt-e.createdAt})),prevMessagesCount:a.length,nextMessagesCount:s.length});case 22:case"end":return t.stop()}}),t,this)})))}},{key:"_getRemoteMessages",value:function(t,n){var r=n.prevLimit,a=void 0===r?0:r,i=n.nextLimit,s=void 0===i?0:i,o=n.source,u=void 0===o?e.CollectionEventSource.REQUEST_MESSAGE:o,c=n.reverse,l=void 0!==c&&c,h=n.checkingHasNext,f=void 0!==h&&h,p=n.checkingContinuousMessages,v=void 0!==p&&p;return E(this,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=oh.of(this._iid),!(a>0||s>0)){e.next=7;break}return e.next=4,n._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,t,ve(Object.assign(Object.assign(Object.assign({},this.filter),Gv),{isInclusive:!0,reverse:l,prevResultSize:a,nextResultSize:s})),u,f,v);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 t,n,r,a,i;return E(this,void 0,void 0,d().mark((function s(){var o,u,c,l,h,f,p,_,m,g,y,k,b,C,w,x,S,T,I,N,M,O,U,D=this;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(o=ss.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=o.cacheContext,h=o.statManager,f=o.logger,!(this._messages.length>0)){s.next=25;break}return p=this._syncRange.top,_=this.viewTop,m=this._syncRange.bottom,g=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,s.next=8,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,_,p);case 8:return y=s.sent,s.next=11,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,m,g);case 11:return k=s.sent,s.prev=12,s.next=15,Ci((function(){return E(D,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,h,f,b,C,w,x,S,T,I,N,A,M=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new qv(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:_,prevEnd:p,prevCount:y,nextStart:m,nextEnd:g,nextCount:k,checkingContinuousMessages:l.localCacheEnabled},this.filter),Gv)),t.next=3,c.send(r);case 3:a=t.sent,i=a.as(Hv),s=i.isHugeGap,o=i.prevMessages,h=void 0===o?[]:o,f=i.prevHasMore,b=i.isContinuousPrevMessages,C=i.nextMessages,w=void 0===C?[]:C,x=i.nextHasmore,S=i.isContinuousNextMessages,s?_i((function(){return E(M,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(t=this._handler)||void 0===t?void 0:t.onHugeGapDetected)&&this._handler.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(T=this.viewTop,I=this.viewBottom,N=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,T].concat(v(h.map((function(e){return e.createdAt}))))),A=Math.max.apply(Math,[0,I].concat(v(w.map((function(e){return e.createdAt}))))),u.dispatch(new Fs({messages:h,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),u.dispatch(new Fs({messages:w,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(N,A),(b||S)&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(N,A)),f&&this._prevFill.start(N),x&&this._nextFill.start(A));case 6:case"end":return t.stop()}}),t,this)})))}),1);case 15:s.next=20;break;case 17:s.prev=17,s.t0=s.catch(12),f.debug("Failed HugeGap Check ",s.t0);case 20:return s.prev=20,l.localCacheEnabled&&h.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(t=l.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(20);case 23:s.next=42;break;case 25:return b=Date.now(),s.prev=26,s.next=29,this._getRemoteMessages(b,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:l.localCacheEnabled});case 29:if(C=s.sent,w=C.messages,x=C.isContinuousMessages,S=C.hasNext,w.length>0){for(I=w.map((function(e){return e.createdAt})),N=0,M=0,O=0;O=b&&M++;this._hasPrevious=N>=this._prevResultLimit,this._hasNext=null!=S?S:M>=this._nextResultLimit,(T=this._syncRange).extends.apply(T,v(I)),x&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(w,e.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;s.next=39;break;case 36:s.prev=36,s.t1=s.catch(26),s.t1 instanceof A&&s.t1.code===e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 39:return s.prev=39,l.localCacheEnabled&&h.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(a=l.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),s.finish(39);case 42:case"end":return s.stop()}}),s,this,[[12,17,20,23],[26,36,39,42]])})))}},{key:"_loadUnsentMessages",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter);case 2:this._unsentMessages=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1);case 2:if(!(e.sent.length>0)){e.next=5;break}return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.logger,n.prev=1,n.next=4,this._channelManager.refreshChannel(this.channel.url,!0,e,t);case 4:n.next=9;break;case 6:n.prev=6,n.t0=n.catch(1),a.warn("Failed to refresh channel",n.t0);case 9:case"end":return n.stop()}}),n,this,[[1,6]])})))}},{key:"_startCheckMyMutedTimer",value:function(t){var n=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return E(n,void 0,void 0,d().mark((function t(){var n,r,a,i,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=void 0,n=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:r=t.sent,n=!r.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),n=!0;case 12:return t.prev=12,n&&(a=ss.of(this._iid),i=a.sessionManager,this.channel._runIfHandleableWithGroupChannel((function(t){var n,r;t.myMutedState=e.MutedState.UNMUTED;var a={source:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,user:i.currentUser};null===(r=null===(n=s._handler)||void 0===n?void 0:n.onChannelUpdated)||void 0===r||r.call(n,a,s.channel)}))),t.finish(12);case 15:case"end":return t.stop()}}),t,this,[[2,9,12,15]])})))}),t+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}},{key:"_setHasNextAndHasPrevious",value:function(e,t){for(var n=e.map((function(e){return e.createdAt})),r=0,a=0,i=0;ithis._startingPoint&&a++}this._hasPrevious=r>=this._prevResultLimit,this._hasNext=null!=t?t:a>=this._nextResultLimit}},{key:"initialize",value:function(t){var n=this,r=new Bv;this._messages=[],this._unsentMessages=[],this._syncRange=new Sv({}),this._hasNext=!0,this._hasPrevious=!0;var a=[],i={messages:[],prevMessagesCount:0,nextMessagesCount:0};return _i((function(){return E(n,void 0,void 0,d().mark((function n(){var s,o,u,c,l,h=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,null===(s=this._backgroundSync)||void 0===s?void 0:s.loadMetadata();case 2:o=n.sent,u=ss.of(this._iid),c=u.cacheContext,l=u.statManager,n.t0=t,n.next=n.t0===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API?7:9;break;case 7:return this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit}).then((function(t){return E(h,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=t,a=this._filterUnderOffsetMessage(i.messages),this._addMessagesToView(a,e.CollectionEventSource.REQUEST_MESSAGE),n.next=5,this._loadUnsentMessages();case 5:r._invokeResponse("local",null,a);case 6:case"end":return n.stop()}}),n,this)})))})).catch((function(e){if(N(e))throw e;r._invokeResponse("local",e,null)})).finally((function(){return E(h,void 0,void 0,d().mark((function n(){var s,u,c,h,f,p,_,m,g=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return c=ss.of(this._iid),h=c.cacheContext,f=!0,p=!0,_=!1,h.localCacheEnabled&&a.length>0&&(m=o.range).includes.apply(m,v(a.map((function(e){return e.createdAt}))))&&(!o.previousComplete&&i.prevMessagesCounto.range.bottom||i.nextMessagesCount=e._latestMessageInfo.createdAt&&(p=!1)})),p?(f=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled}).then((function(t){var n,a,i,s=t.messages,o=t.isContinuousMessages,u=t.hasNext,c=g._filterUnderOffsetMessage(s);(g._messages=[],c.length>0)?(g._setHasNextAndHasPrevious(c,u),(i=g._syncRange).extends.apply(i,v(c.map((function(e){return e.createdAt})))),o&&(null===(n=g._backgroundSync)||void 0===n?void 0:n.range.overlap(g._syncRange))&&(null===(a=g._backgroundSync)||void 0===a||a.range.extends(g._syncRange.top,g._syncRange.bottom)),g._addMessagesToView(c,e.CollectionEventSource.REQUEST_MESSAGE)):(g._hasPrevious=!1,g._hasNext=!1);r._invokeResponse("remote",null,c)})).catch((function(e){if(N(e))throw e;r._invokeResponse("remote",e,null)}))):(this._setHasNextAndHasPrevious(a),r._invokeResponse("remote",null,a)),h.localCacheEnabled&&l.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:f?"cache_hit":"cache_miss",max_db_size:null!==(u=null===(s=h.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==u?u:0,message_init_policy:t,use_local_cache:h.localCacheEnabled,collection_id:this._key}}));case 10:case"end":return n.stop()}}),n,this)})))})),n.abrupt("break",9);case 9:l.put(new Yi({type:je.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message_init_policy:t,message:!0}}}));case 10:case"end":return n.stop()}}),n,this)})))})),r}},{key:"loadPrevious",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=ss.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasPrevious){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingPrevious){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingPrevious=!0,c=this.viewTop,l=[],a.next=13,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{prevLimit:this._prevResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._prevResultLimit,s.localCacheEnabled&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ss.of(this._iid),s=i.cacheContext,e.next=3,this._getRemoteMessages(c,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:s.localCacheEnabled});case 3:u=e.sent,(l=this._filterUnderOffsetMessage(u.messages)).length>0&&((h=this._syncRange).extends.apply(h,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&u.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top))),l=l.filter((function(e){return Nv(p._messages,e)<0})),this._hasPrevious=l.length>=this._prevResultLimit,f&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(a=null===(r=s.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==a?a:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasPrevious=l.length>=this._prevResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingPrevious=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"loadNext",value:function(){var t,n,r;return E(this,void 0,void 0,d().mark((function a(){var i,s,o,u,c,l,h,f,p=this;return d().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._isDisposed){a.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(i=ss.of(this._iid),s=i.cacheContext,o=i.statManager,u=i.logger,this._hasNext){a.next=5;break}return a.abrupt("return",[]);case 5:if(!this._isLoadingNext){a.next=8;break}return u.warn("Messages are already fetching."),a.abrupt("return",[]);case 8:return this._isLoadingNext=!0,c=this.viewBottom,l=[],a.next=13,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalMessages(c,{nextLimit:this._nextResultLimit,inclusive:!1});case 2:t=e.sent,l=this._filterUnderOffsetMessage(t.messages);case 4:case"end":return e.stop()}}),e,this)})))}));case 13:if(h=l.length>=this._nextResultLimit,s.localCacheEnabled&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:h?"cache_hit":"cache_miss",max_db_size:null!==(n=null===(t=s.localCacheConfig)||void 0===t?void 0:t.maxSize)&&void 0!==n?n:0,use_local_cache:s.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),h&&(null===(r=this._backgroundSync)||void 0===r?void 0:r.isWrappingMessages(l))){a.next=22;break}return f=!1,a.next=19,mi((function(){return E(p,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,u,h,p,_=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=ss.of(this._iid),u=s.cacheContext,e.next=3,this._getRemoteMessages(c,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:u.localCacheEnabled});case 3:h=e.sent,(l=this._filterUnderOffsetMessage(h.messages)).length>0&&((p=this._syncRange).extends.apply(p,v(l.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&h.isContinuousMessages&&(f=!0,null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.bottom))),l=l.filter((function(e){return Nv(_._messages,e)<0})),this._hasNext=null!==(r=h.hasNext)&&void 0!==r?r:l.length>=this._nextResultLimit,f&&o.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(i=null===(a=u.localCacheConfig)||void 0===a?void 0:a.maxSize)&&void 0!==i?i:0,use_local_cache:u.localCacheEnabled,collection_id:this._key,message_init_policy:""}}));case 9:case"end":return e.stop()}}),e,this)})))}));case 19:this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE),a.next=24;break;case 22:this._hasNext=l.length>=this._nextResultLimit,l.length>0&&this._addMessagesToView(l,e.CollectionEventSource.REQUEST_MESSAGE);case 24:return this._isLoadingNext=!1,a.abrupt("return",l);case 26:case"end":return a.stop()}}),a,this)})))}},{key:"removeFailedMessage",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:return n.next=4,this._channelManager.removeFailedMessageFromCache(t);case 4:(r=this._unsentMessages.findIndex((function(e){return e.reqId===t})))>-1&&this._unsentMessages.splice(r,1);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=this;if(!this._isDisposed){this._isDisposed=!0;var i=ss.of(this._iid),s=i.cacheContext,o=i.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(t){t.myMemberState!==e.MemberState.NONE&&(a._channel._updateMessageCollectionLastAccessedAt(),o.dispatch(new Cp({channels:[a._channel],context:{source:e.CollectionEventSource.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(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}}])}(),Kv=function(t){function a(e,t){return r(this,a),n(this,a,[e,Object.assign(Object.assign({},t),{channelManager:Iv.of(e)})])}return c(a,t),i(a,[{key:"keyOf",value:function(e){return e.messageId}},{key:"initialize",value:function(e){var t=this;return mi((function(){return E(t,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),p(a,"initialize",this,3)([e])}},{key:"setMessageCollectionHandler",value:function(e){this._setBaseMessageCollectionHandler(e)}},{key:"_activate",value:function(){var e=this,t=Object.create(null,{_activate:{get:function(){return p(a,"_activate",e,1)}}});return E(this,void 0,void 0,d().mark((function e(){var n=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t._activate.call(this);case 2:return e.next=4,mi((function(){return E(n,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(t=e.sent).isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_addMessagesToView",value:function(t,n){var r,a=this,i=this._filterUnderOffsetMessage(t),o=[],u=[],c=s(i);try{for(c.s();!(r=c.n()).done;){var l=r.value;if(n===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(Nv(this._messages,l)<0){Nv(this._unsentMessages,l)<0&&o.push(l);var h=Mv(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof to){Nv(this._unsentMessages,l)<0&&Nv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var f=Nv(this._messages,l);if(f<0){var p=Nv(this._unsentMessages,l);p<0?o.push(l):(this._unsentMessages.splice(p,1),u.push(l));var _=Mv(this._messages,l);this._messages.splice(_,0,l)}else u.push(l),this._messages[f]=l;if(l.updatedAt>0){var m=this._updateChildMessagesInView(l);u.push.apply(u,v(m))}}else if(l instanceof to){var g=Nv(this._unsentMessages,l);g<0?Nv(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[g]=l)}}}catch(e){c.e(e)}finally{c.f()}Ps(n)&&_i((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a,i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s={source:n},o.length>0&&(null===(r=null===(t=this._handler)||void 0===t?void 0:t.onMessagesAdded)||void 0===r||r.call(t,s,this.channel,o)),u.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateMessagesToView",value:function(e,t){var n,r=this,a=[],i=[],o=[],u=s(e);try{for(u.s();!(n=u.n()).done;){var c=n.value;if(c.messageId>0){var l=Nv(this._messages,c);if(l>=0)i.push(c),this._messages[l]=c;else{var h=Nv(this._unsentMessages,c);if(h>=0){var p=f(this._unsentMessages.splice(h,1),1)[0];if(this.hasNext&&p)o.push(p);else{i.push(c);var _=Mv(this._messages,c);this._messages.splice(_,0,c)}}else{var m=this._messages.map((function(e){return e.createdAt}));(c.createdAtMath.max.apply(Math,v(m))&&!this._hasNext)&&a.push(c)}}}else if(c instanceof to){var g=Nv(this._unsentMessages,c);g>=0&&(i.push(c),this._unsentMessages[g]=c)}}}catch(e){u.e(e)}finally{u.f()}return Ps(t)&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n,r,s,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c={source:t},i.length>0?null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,c,this.channel,i):o.length>0?null===(u=null===(s=this._handler)||void 0===s?void 0:s.onMessagesDeleted)||void 0===u||u.call(s,c,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t);case 2:case"end":return e.stop()}}),e,this)})))})),i}}])}(Qv),Wv={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},Yv=function(e){return D("string",e.coverUrl,!0)&&(H(e.coverImage)||D("string",e.coverImage,!0))&&D("boolean",e.isDistinct,!0)&&D("boolean",e.isPublic,!0)&&D("boolean",e.isDiscoverable,!0)&&D("string",e.accessCode,!0)&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&P("string",e.operatorUserIds,!0)&&D("number",e.messageSurvivalSeconds,!0)},Zv=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,d=e.nicknameStartsWithFilter,h=e.operatorFilter;return(a=n(this,t)).method=_e.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/members"),a.params={token:s,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:d,operator_filter:h,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return c(t,e),i(t)}(Ve),Xv=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).members=[];var s=a.next,o=a.members;return i.token=s,o&&o.length>0&&(i.members=o.map((function(t){return new tp(e,t)}))),i}return c(t,e),i(t)}(ze);e.MutedMemberFilter=void 0,(jv=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",jv.MUTED="muted",jv.UNMUTED="unmuted",e.MemberListOrder=void 0,(Vv=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",Vv.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(zv=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",zv.JOINED="joined_only",zv.INVITED="invited_only",zv.INVITED_BY_FRIEND="invited_by_friend",zv.INVITED_BY_NON_FRIEND="invited_by_non_friend";var Jv,$v,e_=function(t){function a(t,i,s){var o,u,c,l,d;return r(this,a),(o=n(this,a,[t,i,e.ChannelType.GROUP,s])).mutedMemberFilter=e.MutedMemberFilter.ALL,o.memberStateFilter=e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null,o.operatorFilter=e.OperatorFilter.ALL,o.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o.mutedMemberFilter=null!==(u=s.mutedMemberFilter)&&void 0!==u?u:e.MutedMemberFilter.ALL,o.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,o.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,o.order=null!==(d=s.order)&&void 0!==d?d:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,o}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&R(e.MutedMemberFilter,this.mutedMemberFilter)&&R(e.MemberStateFilter,this.memberStateFilter)&&(D("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&R(e.OperatorFilter,this.operatorFilter)&&R(e.MemberListOrder,this.order)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new Zv(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Xv),s=i.members,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),t_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/accept"),a.params={user_id:s,access_code:o},a}return c(t,e),i(t)}(Ve),n_=function(t){function a(t,i){var s;return r(this,a),(s=n(this,a,[t,i])).channel=new x_(t,i),s.channel.myMemberState=e.MemberState.JOINED,s}return c(a,t),i(a)}(ze),r_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,d=e.accessCode,h=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a.params=pe({is_distinct:s,is_public:o,is_discoverable:u,name:h,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:d,operator_ids:v,message_survival_seconds:_}),a}return c(t,e),i(t)}(Ve),a_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new x_(e,a),i}return c(t,e),i(t)}(ze),i_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(Ve),s_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a}return c(t,e),i(t)}(Ve),o_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.countPreference;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:o},a}return c(t,e),i(t)}(Ve),u_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).countPreference=a.count_preference,i}return c(t,e),i(t)}(ze),c_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.locale;return(a=n(this,t)).method=_e.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/reset_user_history"),a.params=pe({locale:s}),a}return c(t,e),i(t)}(Ve),l_=function(e){function t(e,a){var i;r(this,t),i=n(this,t,[e,a]);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return c(t,e),i(t)}(ze),d_=Object.assign(Object.assign({},uu),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),h_=function(e){return cu(e)&&D("number",e.scheduledAt,!0)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},f_=Object.assign(Object.assign({},lu),{scheduledAt:void 0}),p_=function(e){return du(e)&&D("number",e.scheduledAt,!0)},v_=function(t){function a(t){var i,s,o;r(this,a),i=n(this,a);var u=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId}))));var c=t.channelType,l=t.channelUrl,d=t.scheduledMessageId;return i.method=_e.PUT,i.path="".concat(Pe(c),"/").concat(encodeURIComponent(l),"/scheduled_messages/").concat(encodeURIComponent(d)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(s=t._thumbnails)||void 0===s?void 0:s.map((function(e){return us.payloadify(e)})),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:u,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(Ve),__=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).message=new yo(e,a),i}return c(t,e),i(t)}(ze),m_=function(t){function a(t){var i,s;r(this,a),i=n(this,a);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 i.method=_e.PUT,i.path="".concat(Pe(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=pe(ve({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:ee.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return ks.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return c(a,t),i(a)}(Ve),g_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.DELETE,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return c(t,e),i(t)}(Ve),y_=function(e){function t(e){var a;r(this,t),a=n(this,t);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=_e.POST,a.path="".concat(Pe(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return c(t,e),i(t)}(Ve),E_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl,o=e.pushTriggerOption;return r(this,t),(a=n(this,t)).method=_e.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:o},a}return c(t,e),i(t)}(Ve),k_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(ze),b_=function(e){function t(e){var a,i=e.userId,s=e.channelUrl;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a}return c(t,e),i(t)}(Ve),C_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return c(t,e),i(t)}(ze);e.CountPreference=void 0,(Jv=e.CountPreference||(e.CountPreference={})).ALL="all",Jv.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Jv.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Jv.OFF="off",e.HiddenState=void 0,($v=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",$v.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",$v.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var w_,x_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,_,m,g,y,E,k,b,C,w,x,S,T;(r(this,a),(s=n(this,a,[t,i]))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s._hasBotInfo={general:!1,ai:!1},s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isChatNotification=!1,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.totalUnreadReplyCount=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.lastPinnedMessage=null,s._latestMessageInfo=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(o=i.is_distinct)&&void 0!==o&&o,s.isSuper=null!==(u=i.is_super)&&void 0!==u&&u,s.isBroadcast=null!==(c=i.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=i.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(d=i.is_public)&&void 0!==d&&d,s.isDiscoverable=null!==(h=i.is_discoverable)&&void 0!==h?h:s.isPublic,s.isChatNotification=null!==(f=i.is_chat_notification)&&void 0!==f&&f,s.isAccessCodeRequired=null!==(p=i.is_access_code_required)&&void 0!==p&&p,s.isPushEnabled=null!==(_=i.is_push_enabled)&&void 0!==_&&_,Array.isArray(i.members))&&(T=s.members).push.apply(T,v(i.members.map((function(e){return new tp(s._iid,e)}))));return s.memberCount=null!==(m=i.member_count)&&void 0!==m?m:0,s.joinedMemberCount=null!==(g=i.joined_member_count)&&void 0!==g?g:0,s.hiddenState=R(e.HiddenState,i.hidden_state)?i.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(y=i.ts_message_offset)&&void 0!==y?y:0,s.messageSurvivalSeconds=null!==(E=i.message_survival_seconds)&&void 0!==E?E:-1,s.lastMessage=i.last_message?go(s._iid,Object.assign({channel_type:s.channelType},i.last_message)):null,i.read_receipt&&Object.keys(i.read_receipt).forEach((function(e){D("number",i.read_receipt[e])&&s._updateUnreadMemberState(e,i.read_receipt[e])})),i.delivery_receipt&&Object.keys(i.delivery_receipt).forEach((function(e){D("number",i.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,i.delivery_receipt[e])})),s.myMemberState=R(e.MemberState,i.member_state)?i.member_state:e.MemberState.NONE,s.myRole=R(e.Role,i.my_role)?i.my_role:e.Role.NONE,R(e.MutedState,i.is_muted)?s.myMutedState=i.is_muted:D("boolean",i.is_muted)?s.myMutedState=i.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=R(e.CountPreference,i.count_preference)?i.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=R(e.PushTriggerOption,i.push_trigger_option)?i.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=i.user_last_read)&&void 0!==k?k:0,s.inviter=i.inviter?new li(s._iid,i.inviter):null,s.invitedAt=null!==(b=i.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(C=i.joined_ts)&&void 0!==C?C:0,s._updateUnreadCount(null!==(w=i.unread_message_count)&&void 0!==w?w:0,null!==(x=i.unread_mention_count)&&void 0!==x?x:0),s.totalUnreadReplyCount=null!==(S=i.total_unread_thread_message_count)&&void 0!==S?S:0,s.lastPinnedMessage=i.latest_pinned_message?go(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,i.latest_message&&(s._latestMessageInfo={messageId:i.latest_message.message_id,createdAt:i.latest_message.created_at}),s._hasBotInfo={general:!!i.has_bot,ai:!!i.has_ai_bot},s}return c(a,t),i(a,[{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=s(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=s(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"hasBot",get:function(){return this._hasBotInfo.general}},{key:"hasAiBot",get:function(){return this._hasBotInfo.ai}},{key:"_shouldUpdateLastMessageWith",value:function(t){if(t.silent)return!1;var n=ss.of(this._iid).appInfo;switch(null==n?void 0:n.lastMessageThreadingPolicy){case e.LastMessageThreadingPolicy.NONE:case e.LastMessageThreadingPolicy.INCLUDE_REPLY:break;case e.LastMessageThreadingPolicy.EXCLUDE_REPLY:if(t.parentMessageId>0)return!1;break;case e.LastMessageThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof to&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case e.UnreadCountThreadingPolicy.INCLUDE_REPLY_TO_CHANNEL:if(t instanceof to&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}},{key:"_updateLastMessage",value:function(e){return!!this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e,!0)}},{key:"_updateUnreadCount",value:function(t,n){if("number"==typeof t&&t>=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=ss.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=ss.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return si(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState,Object.assign(t,e._serializeCachedMetaData())}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Kv(this._iid,Object.assign(Object.assign({},e),{channel:this}))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new e_(this._iid,this.url,e)}},{key:"createThreadedParentMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yh(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 tp?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 to&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=ss.of(this._iid).sdkState,a=t.createdAt,i=0,o=s(this.members);try{for(o.s();!(n=o.n()).done;){var u=n.value;if(r.userId!==u.userId&&u.state===e.MemberState.JOINED&&t.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=ss.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof to?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o>=e.createdAt&&i.push(s)}})),i}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=ss.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof to?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o0&&void 0!==arguments[0]&&arguments[0],n=ss.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 i=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new ws(e._iid,{channel_url:e.url,channel_type:e.channelType,user:tp.payloadify(a),ts:null!=i?i:0})}})),r}},{key:"getDeliveryStatus",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=ss.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 i=e._undeliveredMemberStateMap.get(a.userId);r[a.userId]=new np(e._iid,{channel_url:e.url,channel_type:e.channelType,user:tp.payloadify(a),ts:null!=i?i: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=ss.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,i){var s=a.ts;n-s>=t&&(e._typingStatus.delete(i),r=!0)})),r}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._refresh());case 1:case"end":return e.stop()}}),e,this)})))}},{key:"_refresh",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new Ip({channelUrl:this.url}),n.next=4,a.send(s);case 4:return o=n.sent,u=o.as(Np),c=u.channel,this._update(c),t||i.dispatch(new Cp({channels:[c],context:{source:e.CollectionEventSource.REFRESH_CHANNEL}})),n.abrupt("return",this);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"freeze",value:function(){var t=this,n=Object.create(null,{freeze:{get:function(){return p(a,"freeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.freeze.call(this);case 2:r=ss.of(this._iid),r.dispatcher.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"unfreeze",value:function(){var t=this,n=Object.create(null,{unfreeze:{get:function(){return p(a,"unfreeze",t,1)}}});return E(this,void 0,void 0,d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.unfreeze.call(this);case 2:r=ss.of(this._iid),r.dispatcher.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannel",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Wv),t),ui(Yv(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new r_(Object.assign({channelUrl:this.url},r)),n.next=6,s.send(o);case 6:return u=n.sent,c=u.as(a_),l=c.channel,this._update(l),i.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(e.every((function(e){return e instanceof li}))).throw(A.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"inviteWithUserIds",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(P("string",t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.requestQueue,s=r.sessionManager,o=new $p({channelUrl:this.url,userIds:t}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.as(ev),l=c.channel,this._update(l),a.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,inviter:s.currentUser,invitees:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"join",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",t,!0)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Wp({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(Yp),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"leave",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ss.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Xp({channelUrl:this.url,userId:a.userId,shouldRemoveOperatorStatus:t}),n.next=4,i.send(s);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return n.stop()}}),n,this)})))}},{key:"acceptInvitation",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",t,!0)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new t_({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(n_),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(l),a.dispatch(new Cp({channels:[l],context:{source:e.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),n.abrupt("return",this);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"declineInvitation",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new nv({channelUrl:this.url,userId:r.userId}),t.next=4,a.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"sendUserMessage",this,3)([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){s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),Iv.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"updateUserMessage",value:function(t,n){var r=this,i=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=ss.of(this._iid),s=a.dispatcher,r.next=3,i.updateUserMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Iv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new Cp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Iv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Fs({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"_autoResendUserMessage",this,3)([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 a=Iv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"sendFileMessage",this,3)([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 a=Iv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new fl,i=ss.of(this._iid).dispatcher;return p(a,"sendMultipleFilesMessage",this,3)([t]).onPending((function(e){r._trigger(e)})).onFailed((function(e,t){r._triggerFailed(e,t)})).onSucceeded((function(t){var a=Iv.of(n._iid);n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(t,n){var r=this,i=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",r,1)}}});return E(this,void 0,void 0,d().mark((function r(){var a,s,o,u,c,l=this;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=ss.of(this._iid),s=a.dispatcher,r.next=3,i.updateFileMessage.call(this,t,n);case 3:return o=r.sent,u=this._updateLastMessage(o),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Iv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)})),s.dispatch(new Cp({channels:[this],context:{source:c?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}}))),c&&Iv.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(l)})),s.dispatch(new Fs({messages:[o],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 11:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new Bo,i=ss.of(this._iid).dispatcher,s=Fh.of(this._iid);return p(a,"_autoResendFileMessage",this,3)([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 a=Iv.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._updateLastMessage(t),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),i.dispatch(new Cp({channels:[n],context:{source:e.CollectionEventSource.EVENT_MESSAGE_SENT}})),r._trigger(t)})),r}},{key:"deleteMessage",value:function(t){var n=this,r=Object.create(null,{deleteMessage:{get:function(){return p(a,"deleteMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.deleteMessage.call(this,t);case 2:0===t.messageId&&t instanceof to&&(a=ss.of(this._iid),a.dispatcher.dispatch(new js({reqId:t.reqId,source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"hide",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l,h;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},av),t),ui(iv(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new sv(Object.assign({channelUrl:this.url,userId:s.userId},r)),n.next=6,o.send(u);case 6:return c=n.sent,l=c.as(ov),h=l.messageOffsetTimestamp,this.hiddenState=r.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,r.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),i.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),n.abrupt("return",this);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"unhide",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new s_({channelUrl:this.url}),t.next=4,a.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,r.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new i_({channelUrl:this.url}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c,l=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.sdkState,a=n.dispatcher,i=n.requestQueue,s=new xs({channelUrl:this.url}),t.next=4,i.send(s);case 4:o=t.sent,u=o.as(Ss),c=u.readStatus,this._updateUnreadMemberState(r.userId,c.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Iv.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(l)}))),a.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_READ}}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ev({channelUrl:this.url,userId:n.userId}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=ss.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingStarted>=r)){e.next=8;break}return this._typingStarted=a,this._typingEnded=0,i=new cv({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=ss.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,!((a=(new Date).getTime())-this._typingEnded>=r)){e.next=8;break}return this._typingStarted=0,this._typingEnded=a,i=new dv({channelUrl:this.url,time:this._typingStarted}),e.next=8,n.send(i);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Bd),e),ui(function(e){return $o(e)&&D("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new Bo;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},f_),t),ui(p_(r)).throw(A.invalidParameters),a=ss.of(this._iid),i=a.requestQueue,s=new m_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(bc),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createScheduledFileMessage",value:function(e){var t=this;e=Object.assign(Object.assign({},Qd),e),ui(function(e){return Ko(e)&&D("number",e.scheduledAt)&&(H(e.file)||D("string",e.fileUrl))&&D("string",e.fileName,!0)&&D("string",e.mimeType,!0)&&D("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return D("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(A.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new Bo;return ki(2).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);_i((function(){return E(t,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a._trigger(i));case 1:case"end":return e.stop()}}),e)})))}))})),H(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a}},{key:"updateScheduledFileMessage",value:function(e,t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Object.assign(Object.assign({},d_),t),ui(h_(r)).throw(A.invalidParameters),!H(r.file)){n.next=5;break}return n.next=5,this._uploadFileAndUpdateParams(r);case 5:return a=new v_(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),i=ss.of(this._iid),s=i.requestQueue,n.next=9,s.send(a);case 9:return o=n.sent,u=o.as(__),c=u.message,n.abrupt("return",c);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new g_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=ss.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new y_({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=ss.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyPushTriggerOption",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new b_({userId:n.userId,channelUrl:this.url}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(C_),o=s.pushTriggerOption,this.myPushTriggerOption=o,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.PushTriggerOption,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new E_({userId:i.userId,channelUrl:this.url,pushTriggerOption:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(k_),l=c.pushTriggerOption,this.myPushTriggerOption=l,a.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"setMyCountPreference",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s,o,u,c,l;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(R(e.CountPreference,t)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new o_({channelUrl:this.url,userId:i.userId,countPreference:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(u_),l=c.countPreference,this.myCountPreference=l,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),a.dispatch(new Cp({channels:[this],context:{source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),n.abrupt("return",l);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"resetMyHistory",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ss.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=n.sdkState,s=new c_({channelUrl:this.url,locale:i.localeForChatbot}),t.next=4,a.send(s);case 4:return o=t.sent,u=o.as(l_),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,this.lastMessage&&this.lastMessage.createdAt=this._limit&&!!b,h.nextToken=b,this._metadata&&(this._metadata.token=b,(C=this._metadata.range).extends.apply(C,v(k.map((function(e){return e.createdAt})))),this._metadata.completed=!h.hasNext),f.debug("channel background sync progress",h),t.next=30,this.saveMetadata();case 30:t.next=39;break;case 32:if(t.prev=32,t.t1=t.catch(6),f.debug("channel background sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=38;break}return t.next=38,this.clearMetaData();case 38:throw t.t1;case 39:return t.prev=39,_.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(o=null===(s=p.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==o?o:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:null!==(c=null===(u=m.order)||void 0===u?void 0:u.toString())&&void 0!==c?c:"",collection_id:l.userId}})),t.finish(39);case 42:t.next=46;break;case 44:h.hasNext=!1,h.nextToken="";case 46:return t.abrupt("return",h);case 47:case"end":return t.stop()}}),t,this,[[6,32,39,42],[8,15]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{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 Sv({})}},{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,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata={token:r?r.token:"",range:new Sv(r?r.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!r&&r.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.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=ss.of(this._iid),r=n.logger;n.sessionManager.session.hasSession&&(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(){ss.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 S_[this._iid])}}],[{key:"of",value:function(e){return S_[e]||(S_[e]=new t({_iid:e})),S_[e].ref++,S_[e]}},{key:"clear",value:function(e){S_[e]&&(S_[e].close(),delete S_[e])}}])}(),I_={},N_=function(){function t(n){var a=this,i=n._iid;r(this,t),this.ref=0,this._iid=i;var s,o=ss.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher,h=o.cacheContext,f=o.statManager;this._metadataKey=(s=c.userId,"sendbird:".concat(s,"@groupchannel/changelogs.meta")),this._subscribers=new de;var p=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(c.userId);this._sync=new Ov(p,(function(){return E(a,void 0,void 0,d().mark((function t(){var n,r,a,i,s,o,l,p,v,_,m,g;return d().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 u.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,s={includeEmpty:!0,includeMetaData:!0},t.prev=6,t.next=9,h.preference.get(Ba(c.appId));case 9:o=t.sent,s.includeChatNotification=Boolean(o),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(6),s.includeChatNotification=!1;case 16:return l=Iv.of(this._iid),t.next=19,l.getMyGroupChannelChangeLogs(null!==(a=null===(r=this._metadata)||void 0===r?void 0:r.token)&&void 0!==a?a:"",s,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 19:return p=t.sent,v=p.updatedChannels,_=p.deletedChannelUrls,m=p.hasMore,g=p.token,this._subscribers.dispatch("progress",{updatedChannels:v,deletedChannelUrls:_,hasMore:m,token:g}),i.hasNext=m,i.nextToken=g,this._metadata&&(this._metadata.token=g),u.debug("channel changelog sync progress",i),t.next=31,this.saveMetadata();case 31:h.localCacheEnabled&&f.put(new at({type:je.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:v.length>0||_.length>0?"cache_miss":"cache_hit",max_db_size:v.length,use_local_cache:h.localCacheEnabled,starting_point:0,message_init_policy:_.length.toString(),collection_id:c.userId}})),t.next=41;break;case 34:if(t.prev=34,t.t1=t.catch(4),u.debug("channel changelog sync error",t.t1),!(t.t1 instanceof A&&t.t1.isInvalidTokenError)){t.next=40;break}return t.next=40,this.clearMetadata();case 40:throw t.t1;case 41:return t.abrupt("return",i);case 42:case"end":return t.stop()}}),t,this,[[4,34],[6,13]])})))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=l.on((function(e){if(e instanceof Ha)if(e.stateType===Da.CONNECTED)a.resume();else a.pause()}))}return i(t,[{key:"isRunning",get:function(){return this._sync.isRunning}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=ss.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=ss.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"on",value:function(e,t){return this._subscribers.on(e,t)}},{key:"resume",value:function(){ss.of(this._iid).sessionManager.session.hasSession&&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 I_[this._iid])}}],[{key:"of",value:function(e){return I_[e]||(I_[e]=new t({_iid:e})),I_[e].ref++,I_[e]}},{key:"clear",value:function(e){I_[e]&&(I_[e].close(),delete I_[e])}}])}(),A_=function(t,n){var r,a,i,s;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!==(s=null===(i=t.lastMessage)||void 0===i?void 0:i.createdAt)&&void 0!==s?s:t.createdAt}},M_=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},O_=function(e,t,n){if(e.length>0){for(var r=M_(e,t),a=0,i=e.length-1,s=Math.floor((a+i)/2);a0)i=s,s=Math.floor((a+i)/2);else{if(!(o<0))return{place:s,oldPosition:r};a=s+1,s=Math.floor((a+i)/2)}}return{place:U_(e[s],t,n)>=0?s:s+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},U_=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(t.lastMessage&&n.lastMessage){var a=n.lastMessage.createdAt-t.lastMessage.createdAt;return 0===a?n.createdAt-t.createdAt:a}return 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 i=t.name.localeCompare(n.name);return 0===i?t.createdAt-n.createdAt:i;default:return 0}},D_=function(){return i((function t(n,a){var i=this,s=a.filter,o=void 0===s?new ap:s,u=a.order,c=void 0===u?e.GroupChannelListOrder.LATEST_LAST_MESSAGE:u,l=a.limit,h=void 0===l?100:l,f=a.includeChangesOnInitialLoad,p=void 0!==f&&f;r(this,t),this.channels=[],this._isInitialized=!1,this._iid=n,this._key="gcc-".concat(ce()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=o,this.order=c,this._hasMore=!0,this._token="",this._limit=h;var v=ss.of(this._iid),_=v.sdkState,m=v.cacheContext,g=v.dispatcher;m.localCacheEnabled&&(this._backgroundSync=T_.of(n),this._backgroundSync.resume()),this._changelogSync=N_.of(n),this._changelogSync.resume(),Iv.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(bp(n)){var r=e.filter((function(e){return i.filter.match(e,_.userId)})),a=e.filter((function(e){return!i.filter.match(e,_.userId)})).map((function(e){return e.url}));r.length>0&&i._addChannelsToView(r,t),a.length>0&&i._removeChannelsFromView(a,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),g.on((function(e){e instanceof Ha&&(e.stateType===Da.CONNECTED?i._isGetRemoteChannelsSucceeded||E(i,void 0,void 0,d().mark((function e(){return d().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===Da.LOGOUT&&i.dispose())}))}),[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(t,n){var r,a=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=s(t);try{for(l.s();!(r=l.n()).done;){var h=r.value,f=M_(this.channels,h);f>=0&&this.channels.splice(f,1);var p=O_(this.channels,h,this.order).place;if(f<0)p===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(p,0,h));else switch(n.source){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:this.order===e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&p===this.channels.length?c.push(h):(this.channels.splice(p,0,h),u.push(h));break;default:this.channels.splice(p,0,h),u.push(h)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var v,_=s(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=M_(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}bp(n.source)&&_i((function(){return E(a,void 0,void 0,d().mark((function e(){var t,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsAdded)&&this._handler.onChannelsAdded(n,o),u.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,u),c.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,c.map((function(e){return e.url})));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,t){var n,r=this,a=[],i=s(e);try{var o=function(){var e=n.value,t=r.channels.findIndex((function(t){return t.url===e}));t>=0&&(a.push(r.channels[t].url),r.channels.splice(t,1))};for(i.s();!(n=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return bp(t.source)&&a.length>0&&_i((function(){return E(r,void 0,void 0,d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(t,a);case 1:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_getLocalChannels",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Iv.of(this._iid),n=this.channels.length>0?A_(this.channels[this.channels.length-1],this.order):null,e.next=4,t.getChannelsFromCache(n,this.filter,this.order,this._limit,n?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,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Iv.of(this._iid),e.next=3,t.getMyGroupChannels(this._token,ve(Object.assign(Object.assign({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit);case 3:return n=e.sent,r=n.channels,a=n.token,this._token=a,this._hasMore=!!a,e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return E(this,void 0,void 0,d().mark((function t(){var n;return d().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:n=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(n,{source:e.CollectionEventSource.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()}}),t,this,[[2,10]])})))}},{key:"loadMore",value:function(){var t;return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(r=null,!this._includeChangesOnInitialLoad||0!==this.channels.length){n.next=9;break}if(!this._changelogSync.isRunning){n.next=9;break}return n.next=7,new Promise((function(e){C._changelogSyncSubscriberContext=C._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}));case 7:r=n.sent,null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close();case 9:if(a=ss.of(this._iid),i=a.cacheContext,o=a.connectionManager,u=a.statManager,this._isInitialized){n.next=16;break}if(this._isInitialized=!0,!i.localCacheEnabled){n.next=15;break}return n.next=15,this._backgroundSync.loadMetadata();case 15:u.put(new Yi({type:je.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{group_channel:!0}}}));case 16:if(c=[],!this._hasMore){n.next=35;break}if(!i.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed){n.next=24;break}return n.next=21,mi((function(){return E(C,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:c=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 21:this._hasMore=c.length>=this._limit,n.next=34;break;case 24:return n.prev=24,n.next=27,this._getRemoteChannels();case 27:c=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=34;break;case 31:n.prev=31,n.t0=n.catch(24),this._isGetRemoteChannelsSucceeded=!1;case 34:this._addChannelsToView(c,{source:e.CollectionEventSource.REQUEST_CHANNEL},!0);case 35:if(r){l=s(r.updatedChannels);try{for(l.s();!(h=l.n()).done;)f=h.value,(p=M_(c,f))>=0?c[p]=f:(v=O_(c,f,this.order),_=v.place,c.splice(_,0,f))}catch(e){l.e(e)}finally{l.f()}m=c.map((function(e){return e.url})),g=s(r.deletedChannelUrls);try{for(g.s();!(y=g.n()).done;)k=y.value,(b=m.indexOf(k))>=0&&(c.splice(b,1),m.splice(b,1))}catch(e){g.e(e)}finally{g.f()}}return n.abrupt("return",c);case 37:case"end":return n.stop()}}),n,this,[[24,31]])})))}},{key:"dispose",value:function(){var e,t,n;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(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),Iv.of(this._iid).unsubscribeChannelEvent(this._key))}}])}(),R_=function(t){function a(t){var i;r(this,a);var s=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,d=t.channelNameContainsFilter,h=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,E=t.includeFrozen,k=t.includeMetaData;return(i=n(this,a)).method=_e.GET,i.path=ke,i.params=pe(ve({token:s,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:d,channel_urls:h,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:E,show_metadata:k})),i}return c(a,t),i(a)}(Ve),L_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new x_(e,t)}))),i.ts="number"==typeof u?u:0,i}return c(t,e),i(t)}(ze);e.MembershipFilter=void 0,(w_=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",w_.JOINED="joined";var P_,F_=function(t){function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,E;return r(this,a),(s=n(this,a,[t,i])).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!==(o=i.includeEmpty)&&void 0!==o&&o,s.includeFrozen=null===(u=i.includeFrozen)||void 0===u||u,s.includeMetaData=null===(c=i.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=i.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(d=i.customTypesFilter)&&void 0!==d?d:null,s.customTypeStartsWithFilter=null!==(h=i.customTypeStartsWithFilter)&&void 0!==h?h:null,s.channelNameContainsFilter=null!==(f=i.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=i.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=i.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=i.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=i.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=i.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=i.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(E=i.order)&&void 0!==E?E:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("boolean",this.includeEmpty)&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.channelNameContainsFilter,!0)&&P("string",this.channelUrlsFilter,!0)&&P("string",this.customTypesFilter,!0)&&D("string",this.customTypeStartsWithFilter,!0)&&R(e.MembershipFilter,this.membershipFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicGroupChannelListOrder,this.order)&&D("string",this.metadataOrderKeyFilter,!0)&&D("string",this.metadataKey,!0)&&P("string",this.metadataValues,!0)&&D("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().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(t=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,n=ss.of(this._iid),r=n.requestQueue,a=new R_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,r.send(a);case 9:return i=e.sent,s=i.as(L_),o=s.channels,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 15:return e.abrupt("return",t);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)})))}}])}(pu),q_=i((function e(){r(this,e),this.onUserMuted=ft,this.onUserUnmuted=ft,this.onUserBanned=ft,this.onUserUnbanned=ft,this.onChannelChanged=ft,this.onChannelDeleted=ft,this.onChannelFrozen=ft,this.onChannelUnfrozen=ft,this.onOperatorUpdated=ft,this.onChannelMemberCountChanged=ft,this.onMetaDataCreated=ft,this.onMetaDataUpdated=ft,this.onMetaDataDeleted=ft,this.onMetaCounterCreated=ft,this.onMetaCounterUpdated=ft,this.onMetaCounterDeleted=ft,this.onMessageReceived=ft,this.onMessageUpdated=ft,this.onMessageDeleted=ft,this.onMentionReceived=ft,this.onReactionUpdated=ft,this.onThreadInfoUpdated=ft})),H_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserJoined=ft,e.onUserLeft=ft,e.onUserReceivedInvitation=ft,e.onUserDeclinedInvitation=ft,e.onChannelHidden=ft,e.onUnreadMemberStatusUpdated=ft,e.onUndeliveredMemberStatusUpdated=ft,e.onTypingStatusUpdated=ft,e.onPollUpdated=ft,e.onPollVoted=ft,e.onPollDeleted=ft,e.onPinnedMessageUpdated=ft,e}return c(t,e),i(t)}(q_),G_=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(H_),j_=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,d=e.scheduledStatus;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ae),a.params=pe(ve({token:i,limit:s,reverse:u,channel_url:c,order:o,message_type:l,status:d})),a}return c(t,e),i(t)}(Ve),V_=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).scheduledMessages=[];var s=a.next,o=a.scheduled_messages;return i.token=s,i.scheduledMessages=o.map((function(t){return go(e,t)})),i}return c(t,e),i(t)}(ze),z_=function(t){function a(t,i){var s,o,u,c,l,d;return r(this,a),(s=n(this,a,[t,i])).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(o=i.channelUrl)&&void 0!==o?o:null,s.order=null!==(u=i.order)&&void 0!==u?u:null,s.reverse=null!==(c=i.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=i.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(d=i.messageTypeFilter)&&void 0!==d?d:e.MessageTypeFilter.ALL,s}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])&&D("string",this.channelUrl,!0)&&(R(e.ScheduledMessageListOrder,this.order)||null===this.order)&&D("boolean",this.reverse)&&(P(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&R(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new j_(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(V_),s=i.scheduledMessages,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(pu),B_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="groupChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new Iv(e,{sdkState:r,cacheContext:c,dispatcher:a,sessionManager:i,requestQueue:s,logger:o})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new D_(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new vv(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new F_(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new z_(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){ui(D("string",e)&&t instanceof G_).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){ui(D("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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},lp),t),ui(D("string",e)&&dp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},lp),t),ui(D("number",e)&&dp(r)).throw(A.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},hp),e),ui(fp(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},up),e),ui(cp(n)).throw(A.invalidParameters),t.abrupt("return",this._manager.createChannel(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},up),e),ui(cp(n)).throw(A.invalidParameters),n&&(n.isDistinct=!0),t.abrupt("return",this.createChannel(n));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithUserIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,d().mark((function s(){var o;return d().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=Object.assign(Object.assign({},up),{invitedUserIds:e,isDistinct:t,name:n,data:a,customType:i}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,s.abrupt("return",this.createChannel(o));case 3:case"end":return s.stop()}}),s,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:ui(P("string",e)).throw(A.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),t.next=3,this.getChannel(e);case 3:return n=t.sent,t.next=6,n.markAsDelivered();case 6:case"end":return t.stop()}}),t,this)})))}}])}(os),Q_=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return c(t,e),i(t,[{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,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0: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)})),t.abrupt("return",n);case 3:case"end":return t.stop()}}),t)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,d().mark((function e(){return d().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),K_={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},W_=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)&&(D("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&D("boolean",e.isEphemeral,!0)},Y_=function(e){function t(e){var a,i=e.channelUrl,s=e.isInternalCall;return r(this,t),(a=n(this,t)).method=_e.GET,a.path="".concat(s?we:Ce,"/").concat(encodeURIComponent(i)),a.params={show_pinned_messages:!0},a}return c(t,e),i(t)}(Ve),Z_=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new hm(e,a),i}return c(t,e),i(t)}(ze),X_=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,d=e.isEphemeral;return(a=n(this,t)).method=_e.POST,a.path=Ce,a.params=pe(ve({channel_url:i,cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:d})),a}return c(t,e),i(t)}(Ve),J_=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"ENTR",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(We),$_=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"SYEV",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new li(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(Kp),em=function(e){function t(e){var a=e.channelUrl;return r(this,t),n(this,t,[{code:"EXIT",payload:{channel_url:a},ackRequired:!0}])}return c(t,e),i(t)}(We),tm=function(e){function t(e,a,i){var s,o,u;return r(this,t),s=n(this,t,[e,"EXIT",i]),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new li(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return c(t,e),i(t)}(Kp),nm={},rm=function(t){function a(t,i){var o;return r(this,a),(o=n(this,a,[t,Object.assign(Object.assign({},i),{channelType:e.ChannelType.OPEN})])).subscribeChannelEvent=ft,o.unsubscribeChannelEvent=ft,o.refreshChannel=function(){return E(o,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}}),e)})))},o._openChannelCache=new Q_(t),o._openChannelHandlers=new Map,o._dispatcher.on((function(e){if(e instanceof Ke)o._handleEvent(e).catch((function(e){if(N(e)&&"foreground"===o._sdkState.appState)throw e}));else if(e instanceof Ha&&e.stateType===Da.CONNECTED){var t,n=s(o._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),nm[t]||(nm[t]=o),o}return c(a,t),i(a,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=oi(e);return new hm(this._iid,hm.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var t;return E(this,void 0,void 0,d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._openChannelCache.get(e);case 2:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=6;break}n.t0=void 0!==t;case 6:if(!n.t0){n.next=10;break}n.t2=t,n.next=11;break;case 10:n.t2=null;case 11:return n.abrupt("return",n.t2);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().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()}}),t,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=s(e),t.prev=1,n.s();case 3:if((r=n.n()).done){t.next=9;break}return a=r.value,t.next=7,this._openChannelCache.remove(a);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),n.e(t.t0);case 14:return t.prev=14,n.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"handlers",get:function(){return v(this._openChannelHandlers.values())}},{key:"_handleEvent",value:function(t){return E(this,void 0,void 0,d().mark((function n(){var r,a,i,o,u,c,l,h,f,p,v,_,m,g,y,k,b,C,w,x,S,T,I,A,M,O,U,D,R,L,P,F,q,H,G,j,V,z,B,Q,K,W,Y,Z,X,J,$,ee,te,ne,re,ae,ie,se,oe,ue,ce,le,de,he,fe,pe,ve,_e,me,ge,ye,Ee,ke,be,Ce,we,xe,Se,Te,Ie,Ne,Ae,Me,Oe,Ue,De,Re,Le,Pe,Fe,qe,He,Ge,je=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,n.t0=t.code,n.next="MESG"===n.t0||"FILE"===n.t0||"ADMM"===n.t0||"BRDM"===n.t0?4:"MEDI"===n.t0||"FEDI"===n.t0||"AEDI"===n.t0?14:"DELM"===n.t0?26:"MRCT"===n.t0?33:"MTHD"===n.t0?40:"MCNT"===n.t0?47:"PEDI"===n.t0?75:"VOTE"===n.t0?83:"SYEV"===n.t0?91:174;break;case 4:if(r=null,"MESG"===t.code?r=t.as(lc):"FILE"===t.code?r=t.as(Co):"ADMM"!==t.code&&"BRDM"!=t.code||(r=t.as(gv)),!r){n.next=13;break}if(i=(a=r).message,o=a.isMentioned,i.channelType!==e.ChannelType.OPEN){n.next=13;break}return n.next=11,this.getChannel(i.channelUrl,!0);case 11:u=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(u.url)&&(r.onMessageReceived&&r.onMessageReceived(u,i),o&&r.onMentionReceived&&r.onMentionReceived(u,i))}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return n.abrupt("break",174);case 14:if(c=null,"MEDI"===t.code?c=t.as(hc):"FEDI"===t.code?c=t.as(pc):"AEDI"===t.code&&(c=t.as(yv)),!c){n.next=25;break}if(h=(l=c).message,f=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){n.next=25;break}return n.next=21,this.getChannel(h.channelUrl,!0);case 21:p=n.sent,v=!1,p.lastPinnedMessage&&p.lastPinnedMessage.messageId===h.messageId&&p.lastPinnedMessage.updatedAt0&&i.onMentionReceived&&i.onMentionReceived(p,h))}catch(e){r.e(e)}finally{r.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 25:return n.abrupt("break",174);case 26:if(_=t.as(dt),m=_.channelUrl,g=_.channelType,y=_.messageId,g!==e.ChannelType.OPEN){n.next=32;break}return n.next=30,this.getChannel(m,!0);case 30:k=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(k.url)&&r.onMessageDeleted&&r.onMessageDeleted(k,y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 32:return n.abrupt("break",174);case 33:if(b=t.as(bv),C=b.channelUrl,w=b.channelType,x=b.event,w!==e.ChannelType.OPEN){n.next=39;break}return n.next=37,this.getChannel(C,!0);case 37:S=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(S.url)&&r.onReactionUpdated&&r.onReactionUpdated(S,x)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 39:return n.abrupt("break",174);case 40:if(T=t.as(Cv),(I=T.event).channelType!==e.ChannelType.OPEN){n.next=46;break}return n.next=44,this.getChannel(I.channelUrl,!0);case 44:A=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(A.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(A,I)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 46:return n.abrupt("break",174);case 47:M=t.as(wv),O=M.openChannelMemberCounts,U=[],D=s(O),n.prev=50,D.s();case 52:if((R=D.n()).done){n.next=61;break}return L=R.value,P=L.channelUrl,F=L.participantCount,q=L.updatedAt,n.next=57,this.getChannelFromCache(P);case 57:(H=n.sent)&&H._updateParticipantCount(F,q)&&U.push(H);case 59:n.next=52;break;case 61:n.next=66;break;case 63:n.prev=63,n.t1=n.catch(50),D.e(n.t1);case 66:return n.prev=66,D.f(),n.finish(66);case 69:if(!(U.length>0)){n.next=74;break}return n.next=72,this.upsertChannelsToCache(U);case 72:G=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(G)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 74:return n.abrupt("break",174);case 75:if(j=t.as(xv),V=j.event,z=j.status,B=j.channelUrl,Q=j.channelType,!B||Q!==e.ChannelType.OPEN){n.next=82;break}return n.next=79,this.getChannel(B,!0);case 79:K=n.sent,this._dispatcher.dispatch(new zs({event:V,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),_i(z===oo?function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollDeleted&&r.onPollDeleted(K,V.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollUpdated&&r.onPollUpdated(K,V)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 82:return n.abrupt("break",174);case 83:if(W=t.as(Fc),Y=W.event,Z=W.channelUrl,X=W.channelType,!Z||X!==e.ChannelType.OPEN){n.next=90;break}return n.next=87,this.getChannel(Z,!0);case 87:J=n.sent,this._dispatcher.dispatch(new Bs({event:Y,source:e.CollectionEventSource.EVENT_POLL_VOTED})),_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onPollVoted&&r.onPollVoted(J,Y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 90:return n.abrupt("break",174);case 91:if($=t.as(Kp),!(ee=$.event).isOpenChannelEvent){n.next=173;break}n.t2=ee.category,n.next=n.t2===rp.CHANNEL_ENTER?96:n.t2===rp.CHANNEL_EXIT?103:n.t2===rp.CHANNEL_OPERATOR_UPDATE?110:n.t2===rp.USER_CHANNEL_MUTE||n.t2===rp.USER_CHANNEL_UNMUTE?118:n.t2===rp.USER_CHANNEL_BAN||n.t2===rp.USER_CHANNEL_UNBAN?125:n.t2===rp.CHANNEL_FREEZE||n.t2===rp.CHANNEL_UNFREEZE?132:n.t2===rp.CHANNEL_DELETED?140:n.t2===rp.CHANNEL_PROP_CHANGED?147:n.t2===rp.CHANNEL_META_DATA_CHANGED?152:n.t2===rp.CHANNEL_META_COUNTERS_CHANGED?161:n.t2===rp.PINNED_MESSAGE_CHANGED?167:173;break;case 96:return n.next=98,this.getChannel(ee.channelUrl,!0);case 98:return te=n.sent,ne=t.as($_),re=ne.participantCount,ae=ne.user,ie=te._updateParticipantCount(re,ee.ts),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(te,ae),ie&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(te)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 103:return n.next=105,this.getChannel(ee.channelUrl,!0);case 105:return se=n.sent,oe=t.as(tm),ue=oe.participantCount,ce=oe.user,le=se._updateParticipantCount(ue,ee.ts),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(se,ce),le&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 110:return n.next=112,this.getChannel(ee.channelUrl,!0);case 112:return de=n.sent,he=t.as(fv),fe=he.operators,de.operators=fe,this.upsertChannelsToCache([de]),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(de,fe)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 118:return n.next=120,this.getChannel(ee.channelUrl,!0);case 120:return pe=n.sent,ve=ee.category===rp.USER_CHANNEL_MUTE,_e=t.as(ve?Xu:$u),me=_e.user,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ve?e.onUserMuted&&e.onUserMuted(pe,me):e.onUserUnmuted&&e.onUserUnmuted(pe,me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 125:return n.next=127,this.getChannel(ee.channelUrl,!0);case 127:return ge=n.sent,ye=ee.category===rp.USER_CHANNEL_BAN,Ee=t.as(ye?tc:rc),ke=Ee.user,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ye?e.onUserBanned&&e.onUserBanned(ge,ke):e.onUserUnbanned&&e.onUserUnbanned(ge,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 132:return n.next=134,this.getChannel(ee.channelUrl,!0);case 134:return be=n.sent,Ce=t.as(ic),we=Ce.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().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)})))})),n.abrupt("break",173);case 140:return n.next=142,this.getChannel(ee.channelUrl,!0);case 142:return xe=n.sent,n.next=145,this.removeChannelsFromCache([xe.url]);case 145:return _i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(xe.url,xe.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 147:return n.next=149,this.getChannelWithoutCache(ee.channelUrl,!0);case 149:return Se=n.sent,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Se)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 152:return n.next=154,this.getChannel(ee.channelUrl,!0);case 154:return Te=n.sent,Ie=t.as(Lu),Ne=Ie.created,Ae=Ie.updated,Me=Ie.deleted,Ne&&Te._upsertCachedMetaData(Ne,ee.ts),Ae&&Te._upsertCachedMetaData(Ae,ee.ts),Me&&Te._removeFromCachedMetaData(Me,ee.ts),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ne&&e.onMetaDataCreated&&e.onMetaDataCreated(Te,Ne),Ae&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Te,Ae),Me&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Te,Me)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 161:return n.next=163,this.getChannel(ee.channelUrl,!0);case 163:return Oe=n.sent,Ue=t.as(Ku),De=Ue.created,Re=Ue.updated,Le=Ue.deleted,_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){De&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Oe,De),Re&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Oe,Re),Le&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Oe,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",173);case 167:return n.next=169,this.getChannel(ee.channelUrl,!0);case 169:return Pe=n.sent,Fe=t.as(_v),qe=Fe.pinnedMessageIds,He=Fe.latestPinnedMessage,(Ge=Fe.ts)>Pe._pinnedMessagesUpdatedAt&&(Pe.pinnedMessageIds=qe,Pe.lastPinnedMessage=He,Pe._pinnedMessagesUpdatedAt=Ge,this.upsertChannelsToCache([Pe]),_i((function(){return E(je,void 0,void 0,d().mark((function e(){var t,n,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)(r=n.value).onChannelChanged&&r.onChannelChanged(Pe)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),_i((function(){return E(je,void 0,void 0,d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(Pe)}));case 1:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",173);case 173:return n.abrupt("break",174);case 174:n.next=180;break;case 176:if(n.prev=176,n.t3=n.catch(0),!N(n.t3)){n.next=180;break}throw n.t3;case 180:case"end":return n.stop()}}),n,this,[[0,176],[50,63,66,69]])})))}},{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){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,d().mark((function n(){var r,a,i,s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ui(D("string",e)).throw(A.invalidParameters),r=new Y_({channelUrl:e,isInternalCall:t}),n.next=4,this._requestQueue.send(r);case 4:return a=n.sent,i=a.as(Z_),s=i.channel,n.next=8,this.upsertChannelsToCache([s]);case 8:return n.abrupt("return",n.sent[0]);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,d().mark((function t(){var n,r,a,i,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},K_),e),ui(W_(n)).throw(A.invalidParameters),r=new X_(n),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Z_),s=i.channel,this.upsertChannelsToCache([s]),t.abrupt("return",s);case 9:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return nm[e]}}])}(mv),am={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},im=function(e){return P("string",e.operatorUserIds,!0)&&(D("string",e.coverUrlOrImage,!0)||H(e.coverUrlOrImage,!0))&&D("string",e.name,!0)&&D("string",e.data,!0)&&D("string",e.customType,!0)},sm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.token,o=e.limit;return(a=n(this,t)).method=_e.GET,a.path="".concat(Ce,"/").concat(encodeURIComponent(i),"/participants"),a.params={token:s,limit:o},a}return c(t,e),i(t)}(Ve),om=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).participants=[];var s=a.next,o=a.participants;return i.token=s,i.participants=o.map((function(t){return new zo(e,t)})),i}return c(t,e),i(t)}(ze),um=function(t){function a(t,i,s){return r(this,a),n(this,a,[t,i,e.ChannelType.OPEN,s])}return c(a,t),i(a,[{key:"_validate",value:function(){return p(a,"_validate",this,3)([])}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new sm(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(om),s=i.participants,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}])}(vu),cm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=n(this,t)).method=_e.PUT,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a.params=pe(ve({cover_url:D("string",s)?s:null,cover_file:H(s)?s:null,name:o,data:u,custom_type:c,operators:l})),a}return c(t,e),i(t)}(Ve),lm=function(e){function t(e,a){var i;return r(this,t),(i=n(this,t,[e,a])).channel=new hm(e,a),i}return c(t,e),i(t)}(ze),dm=function(e){function t(e){var a;r(this,t);var i=e.channelUrl;return(a=n(this,t)).method=_e.DELETE,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a}return c(t,e),i(t)}(Ve),hm=function(t){function a(t,i){var s,o;return r(this,a),(s=n(this,a,[t,i]))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(o=i.participant_count)&&void 0!==o?o:0,s.operators=Array.isArray(i.operators)?i.operators.map((function(e){return new li(t,e)})):[],s.lastPinnedMessage=i.latest_pinned_message?go(s._iid,Object.assign({channel_type:s.channelType},i.latest_pinned_message)):null,s}return c(a,t),i(a,[{key:"serialize",value:function(){return si(this)}},{key:"isOperator",value:function(e){return e instanceof li?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 um(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=rm.of(this._iid),e.next=3,t.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new J_({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as($_),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),rm.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,d().mark((function e(){var t,n,r,a,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new em({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(tm),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),rm.of(this._iid).setExitedToCache(this),oh.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,d().mark((function t(){var n,r,a,i,s,o,u,c;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},am),e),ui(im(n)).throw(A.invalidParameters),r=ss.of(this._iid),a=r.requestQueue,i=new cm(Object.assign({channelUrl:this.url},n)),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(lm),u=o.channel,this._update(u),c=rm.of(this._iid),t.next=12,c.upsertChannelsToCache([u]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=Object.assign(Object.assign({},am),{name:e,coverUrlOrImage:t,data:n,operatorUserIds:r,customType:a}),i.abrupt("return",this.updateChannel(s));case 2:case"end":return i.stop()}}),i,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ss.of(this._iid),n=t.requestQueue,r=new dm({channelUrl:this.url}),e.next=4,n.send(r);case 4:return a=rm.of(this._iid),e.next=7,a.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"updateUserMessage",value:function(e,t){var n=this,r=Object.create(null,{updateUserMessage:{get:function(){return p(a,"updateUserMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateUserMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&rm.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&rm.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updateFileMessage",value:function(e,t){var n=this,r=Object.create(null,{updateFileMessage:{get:function(){return p(a,"updateFileMessage",n,1)}}});return E(this,void 0,void 0,d().mark((function n(){var a,i,s,o=this;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.updateFileMessage.call(this,e,t);case 2:return a=n.sent,i=!1,s=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===a.messageId&&(this.lastPinnedMessage=a,i=!0,s=!0),i&&rm.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),s&&rm.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return pe(ve(Object.assign(Object.assign({},kl.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return li.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?mo(e.lastPinnedMessage):null})))}}])}(kl),fm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).onUserEntered=ft,e.onUserExited=ft,e.onChannelParticipantCountChanged=ft,e.onPollUpdated=ft,e.onPollVoted=ft,e.onPollDeleted=ft,e.onPinnedMessageUpdated=ft,e}return c(t,e),i(t)}(q_),pm=function(e){function t(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),e=n(this,t),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return c(t,e),i(t)}(fm),vm=function(e){function t(e){var a;r(this,t);var i=e.token,s=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,d=e.includeMetaData;return(a=n(this,t)).method=_e.GET,a.path=Ce,a.params=pe({token:i,limit:s,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:d,show_pinned_messages:!0}),a}return c(t,e),i(t)}(Ve),_m=function(e){function t(e,a){var i;r(this,t),(i=n(this,t,[e,a])).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return new hm(e,t)}))),i.ts="number"==typeof u?u:null,i}return c(t,e),i(t)}(ze),mm=function(e){function t(e,a){var i,s,o,u,c,l;return r(this,t),(i=n(this,t,[e,a])).includeFrozen=!0,i.includeMetaData=!0,i.nameKeyword=null,i.urlKeyword=null,i.customTypes=null,i.includeFrozen=null===(s=a.includeFrozen)||void 0===s||s,i.includeMetaData=null===(o=a.includeMetaData)||void 0===o||o,i.nameKeyword=null!==(u=a.nameKeyword)&&void 0!==u?u:null,i.urlKeyword=null!==(c=a.urlKeyword)&&void 0!==c?c:null,i.customTypes=null!==(l=a.customTypes)&&void 0!==l?l:null,i}return c(t,e),i(t,[{key:"_validate",value:function(){return p(t,"_validate",this,3)([])&&D("boolean",this.includeFrozen)&&D("boolean",this.includeMetaData)&&D("string",this.nameKeyword,!0)&&D("string",this.urlKeyword,!0)&&P("string",this.customTypes,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,d().mark((function e(){var t,n,r,a,i,s,o,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,t=ss.of(this._iid),n=t.requestQueue,r=new vm(ve(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(_m),s=i.channels,o=i.token,this._token=o,this._hasNext=!!o,u=rm.of(this._iid),e.next=15,u.upsertChannelsToCache(s);case 15:return this._isLoading=!1,e.abrupt("return",s);case 17:return e.abrupt("return",[]);case 20:throw A.queryInProgress;case 21:e.next=24;break;case 23:throw A.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}])}(pu),gm=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).name="openChannel",e}return c(t,e),i(t,[{key:"init",value:function(e,n){var r=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;p(t,"init",this,3)([e,{sdkState:r,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}]),this._manager=new rm(e,{sdkState:r,dispatcher:a,requestQueue:s,logger:o,cacheContext:c,sessionManager:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new mm(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,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,d().mark((function i(){var s;return d().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return(s=Object.assign({},K_)).name=e,s.coverUrlOrImage=t,s.data=n,s.operatorUserIds=r,s.customType=a,i.abrupt("return",this._manager.createChannel(s));case 7:case"end":return i.stop()}}),i,this)})))}}])}(os),ym=Object.freeze({__proto__:null,xmlHttpRequest:function(e,t){return new Promise((function(n,r){if("undefined"!=typeof XMLHttpRequest){var a=ss.of(e),i=a.dispatcher,s=a.logger,o=t.requestId,u=t.method,c=t.url,l=t.headers,d=void 0===l?{}:l,h=t.data,f=void 0===h?"":h,p=t.uploadProgressHandler,v=!1,_=new XMLHttpRequest;_.open(u,c),Object.keys(d).forEach((function(e){_.setRequestHeader(e,d[e])})),p&&_.upload.addEventListener("progress",(function(e){e.lengthComputable?p(o,e.loaded,e.total):s.debug("Progress computing failed: `Content-Length` header is not given.")})),_.onabort=function(){r(A.requestCanceled)},_.onerror=function(e){r(A.networkError)},_.onreadystatechange=function(){if(_.readyState===XMLHttpRequest.DONE&&!v)if(0===_.status||_.status>=200&&_.status<400)try{var t=JSON.parse(_.responseText);n(new ze(e,t))}catch(s){r(A.networkError)}else try{var a=JSON.parse(_.responseText);if(a){var s=new A(a);if(s.isSessionExpiredError){if(i.dispatch(new Qe({reason:s.code,message:s.message})),!(_ instanceof Ye)){var o=new ut;return i.dispatch(new et({request:_,deferred:o,error:s})),o.promise}}else s.isSessionInvalidatedError&&i.dispatch(new Qe({reason:s.code,message:s.message}));r(s)}else r(A.requestFailed)}catch(s){r(A.requestFailed)}},i.on((function(e){e instanceof ct&&(e.requestId&&e.requestId!==o||(v=!0,_.abort()))})),_.send(f)}else r(A.xmlHttpRequestNotSupported)}))}});P_=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 Nm(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 Am(e){return"string"!=typeof e&&(e=String(e)),e}function Mm(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return Cm&&(t[Symbol.iterator]=function(){return t}),t}function Om(e){this.map={},e instanceof Om?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 Um(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function Dm(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Rm(e){var t=new FileReader,n=Dm(t);return t.readAsArrayBuffer(e),n}function Lm(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Pm(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:wm&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:xm&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:bm&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():Sm&&wm&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Lm(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Sm&&(ArrayBuffer.prototype.isPrototypeOf(e)||Im(e))?this._bodyArrayBuffer=Lm(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):bm&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},wm&&(this.blob=function(){var e=Um(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=Um(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(wm)return this.blob().then(Rm);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,n,r,a,i=Um(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Dm(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),a=r?r[1]:"utf-8",t.readAsText(e,a),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||function(){if("AbortController"in km)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 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 Hm(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 Gm(e,t){if(!(this instanceof Gm))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 Om(t.headers),this.url=t.url||"",this._initBody(e)}qm.prototype.clone=function(){return new qm(this,{body:this._bodyInit})},Pm.call(qm.prototype),Pm.call(Gm.prototype),Gm.prototype.clone=function(){return new Gm(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Om(this.headers),url:this.url})},Gm.error=function(){var e=new Gm(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var jm=[301,302,303,307,308];Gm.redirect=function(e,t){if(-1===jm.indexOf(t))throw new RangeError("Invalid status code");return new Gm(null,{status:t,headers:{location:e}})};var Vm=km.DOMException;try{new Vm}catch(On){(Vm=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),Vm.prototype.constructor=Vm}function zm(e,t){return new Promise((function(n,r){var a=new qm(e,t);if(a.signal&&a.signal.aborted)return r(new Vm("Aborted","AbortError"));var i=new XMLHttpRequest;function s(){i.abort()}if(i.onload=function(){var e,t,r={statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new Om,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();try{t.append(r,a)}catch(e){console.warn("Response "+e.message)}}})),t)};0===a.url.indexOf("file://")&&(i.status<200||i.status>599)?r.status=200:r.status=i.status,r.url="responseURL"in i?i.responseURL:r.headers.get("X-Request-URL");var s="response"in i?i.response:i.responseText;setTimeout((function(){n(new Gm(s,r))}),0)},i.onerror=function(){setTimeout((function(){r(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){r(new TypeError("Network request timed out"))}),0)},i.onabort=function(){setTimeout((function(){r(new Vm("Aborted","AbortError"))}),0)},i.open(a.method,function(e){try{return""===e&&km.location.href?km.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?i.withCredentials=!0:"omit"===a.credentials&&(i.withCredentials=!1),"responseType"in i&&(wm?i.responseType="blob":Sm&&(i.responseType="arraybuffer")),t&&"object"===m(t.headers)&&!(t.headers instanceof Om||km.Headers&&t.headers instanceof km.Headers)){var o=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){o.push(Nm(e)),i.setRequestHeader(e,Am(t.headers[e]))})),a.headers.forEach((function(e,t){-1===o.indexOf(t)&&i.setRequestHeader(t,e)}))}else a.headers.forEach((function(e,t){i.setRequestHeader(t,e)}));a.signal&&(a.signal.addEventListener("abort",s),i.onreadystatechange=function(){4===i.readyState&&a.signal.removeEventListener("abort",s)}),i.send(void 0===a._bodyInit?null:a._bodyInit)}))}zm.polyfill=!0,km.fetch||(km.fetch=zm,km.Headers=Om,km.Request=qm,km.Response=Gm);var Bm="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null};Bm.fetch||(Bm.fetch=zm);var Qm=Object.freeze({__proto__:null});e.AdminMessage=ao,e.AppInfo=Ja,e.AppleCriticalAlertOptions=ms,e.ApplicationUserListQuery=Al,e.BannedUserListQuery=xu,e.BaseChannel=kl,e.BaseMessage=eo,e.BlockedUserListQuery=Ul,e.CachedChannelInfo=K,e.ConnectionHandler=xl,e.DeliveryStatus=np,e.Emoji=bl,e.EmojiCategory=Cl,e.EmojiContainer=wl,e.Feedback=ys,e.FileMessage=yo,e.FriendListQuery=Ll,e.GroupChannel=x_,e.GroupChannelCollection=D_,e.GroupChannelEventSource=kp,e.GroupChannelFilter=ap,e.GroupChannelHandler=G_,e.GroupChannelListQuery=vv,e.GroupChannelModule=B_,e.LocalCacheConfig=W,e.Member=tp,e.MemberListQuery=e_,e.MemoryStore=Md,e.MessageCollection=Kv,e.MessageCollectionInitHandler=Bv,e.MessageEventSource=Ls,e.MessageFilter=jd,e.MessageForm=Zs,e.MessageFormItem=Xs,e.MessageMetaArray=ks,e.MessageModule=wh,e.MessageRequestHandler=Bo,e.MessageReviewInfo=fo,e.MessageSearchQuery=_h,e.MultipleFilesMessage=vo,e.MultipleFilesMessageRequestHandler=fl,e.MutedUserListQuery=bu,e.NotificationInfo=za,e.OGImage=vs,e.OGMetaData=_s,e.OpenChannel=hm,e.OpenChannelHandler=pm,e.OpenChannelListQuery=mm,e.OpenChannelModule=gm,e.OperatorListQuery=gu,e.Participant=zo,e.ParticipantListQuery=um,e.PinnedMessage=pl,e.PinnedMessageListQuery=ml,e.Plugin=io,e.PreviousMessageListQuery=yu,e.PublicGroupChannelListQuery=F_,e.Reaction=ps,e.ReactionEvent=fs,e.ReadStatus=ws,e.RestrictedUser=Vo,e.RestrictionInfo=jo,e.ScheduledMessageListQuery=z_,e.SendbirdChat=Qf,e.SendbirdChatOptions=j,e.SendbirdError=A,e.Sender=Es,e.SessionHandler=Sl,e.ThreadInfo=ds,e.ThreadInfoUpdateEvent=uh,e.ThreadedParentMessageListQuery=yh,e.Thumbnail=us,e.UIKitConfigInfo=Qa,e.UploadedFileInfo=Qs,e.User=li,e.UserEventHandler=Tl,e.UserMessage=po,Object.defineProperty(e,"__esModule",{value:!0})}));